rename __vi_send -> vi_send, __vi_trans -> vi_translate, they're
[nvi.git] / common / trace.c
blobd0289b533dfae6b8acaac73706f5caa9c841826c
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.1 1996/12/12 09:16:24 bostic Exp $ (Berkeley) $Date: 1996/12/12 09:16:24 $";
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 * trace_end --
35 * End tracing.
37 * PUBLIC: void trace_end __P((void));
39 void
40 trace_end()
42 if (tfp != NULL && tfp != stderr)
43 (void)fclose(tfp);
47 * trace_init --
48 * Initialize tracing.
50 * PUBLIC: void trace_init __P((char *));
52 void
53 trace_init(name)
54 char *name;
56 if (name == NULL || (tfp = fopen(name, "w")) == NULL)
57 tfp = stderr;
58 trace("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\nTRACE\n");
62 * trace --
63 * Debugging trace routine.
65 * PUBLIC: void trace __P((const char *, ...));
67 void
68 #ifdef __STDC__
69 trace(const char *fmt, ...)
70 #else
71 trace(fmt, va_alist)
72 char *fmt;
73 va_dcl
74 #endif
76 va_list ap;
78 if (tfp == NULL)
79 trace_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