add a .gitignore file
[nvi.git] / common / trace.c
blob67bfc26a9f2368a07653d995631ea9953fad9309
1 /*-
2 * Copyright (c) 1996
3 * Rob Zimmermann. All rights reserved.
4 * Copyright (c) 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
8 */
10 #include "config.h"
12 #ifndef lint
13 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 $";
14 #endif /* not lint */
16 #include <sys/queue.h>
18 #include <bitstring.h>
19 #include <stdio.h>
21 #ifdef __STDC__
22 #include <stdarg.h>
23 #else
24 #include <varargs.h>
25 #endif
27 #include "common.h"
29 #ifdef TRACE
31 static FILE *tfp;
34 * vtrace_end --
35 * End tracing.
37 * PUBLIC: void vtrace_end __P((void));
39 void
40 vtrace_end()
42 if (tfp != NULL && tfp != stderr)
43 (void)fclose(tfp);
47 * vtrace_init --
48 * Initialize tracing.
50 * PUBLIC: void vtrace_init __P((char *));
52 void
53 vtrace_init(name)
54 char *name;
56 if (name == NULL || (tfp = fopen(name, "w")) == NULL)
57 tfp = stderr;
58 vtrace("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nTRACE\n");
62 * vtrace --
63 * Debugging trace routine.
65 * PUBLIC: void vtrace __P((const char *, ...));
67 void
68 #ifdef __STDC__
69 vtrace(const char *fmt, ...)
70 #else
71 vtrace(fmt, va_alist)
72 char *fmt;
73 va_dcl
74 #endif
76 va_list ap;
78 if (tfp == NULL)
79 vtrace_init(NULL);
81 #ifdef __STDC__
82 va_start(ap, fmt);
83 #else
84 va_start(ap);
85 #endif
86 (void)vfprintf(tfp, fmt, ap);
87 va_end(ap);
89 (void)fflush(tfp);
91 #endif