Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / nvi / common / trace.c
blob8ab611b3e7f027c7000461e3120201e22a199dcf
1 /* $NetBSD$ */
3 /*-
4 * Copyright (c) 1996
5 * Rob Zimmermann. All rights reserved.
6 * Copyright (c) 1996
7 * Keith Bostic. All rights reserved.
9 * See the LICENSE file for redistribution information.
12 #include "config.h"
14 #ifndef lint
15 static const char sccsid[] = "Id: trace.c,v 8.4 1997/08/03 15:04:23 bostic Exp (Berkeley) Date: 1997/08/03 15:04:23";
16 #endif /* not lint */
18 #include <sys/queue.h>
20 #include <bitstring.h>
21 #include <stdio.h>
23 #ifdef __STDC__
24 #include <stdarg.h>
25 #else
26 #include <varargs.h>
27 #endif
29 #include "common.h"
31 #ifdef TRACE
33 static FILE *tfp;
36 * vtrace_end --
37 * End tracing.
39 * PUBLIC: void vtrace_end __P((void));
41 void
42 vtrace_end()
44 if (tfp != NULL && tfp != stderr)
45 (void)fclose(tfp);
49 * vtrace_init --
50 * Initialize tracing.
52 * PUBLIC: void vtrace_init __P((char *));
54 void
55 vtrace_init(name)
56 char *name;
58 if (name == NULL || (tfp = fopen(name, "w")) == NULL)
59 tfp = stderr;
60 vtrace("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nTRACE\n");
64 * vtrace --
65 * Debugging trace routine.
67 * PUBLIC: void vtrace __P((const char *, ...));
69 void
70 #ifdef __STDC__
71 vtrace(const char *fmt, ...)
72 #else
73 vtrace(fmt, va_alist)
74 char *fmt;
75 va_dcl
76 #endif
78 va_list ap;
80 if (tfp == NULL)
81 vtrace_init(NULL);
83 #ifdef __STDC__
84 va_start(ap, fmt);
85 #else
86 va_start(ap);
87 #endif
88 (void)vfprintf(tfp, fmt, ap);
89 va_end(ap);
91 (void)fflush(tfp);
93 #endif