chiark / gitweb /
Bump the version number.
[mLib] / trace.h
CommitLineData
0875b58f 1/* -*-c-*-
2 *
3 * $Id: trace.h,v 1.1 1998/06/17 23:44:42 mdw Exp $
4 *
5 * Tracing functions for debugging
6 *
7 * (c) 1998 Straylight/Edgeware
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
12 * This file is part of the mLib utilities library.
13 *
14 * mLib is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * mLib is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with mLib; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 */
28
29/*----- Revision history --------------------------------------------------*
30 *
31 * $Log: trace.h,v $
32 * Revision 1.1 1998/06/17 23:44:42 mdw
33 * Initial revision
34 *
35 */
36
37#ifndef TRACE_H
38#define TRACE_H
39
40#ifdef __cplusplus
41 extern "C" {
42#endif
43
44#include <stdio.h>
45
46/*----- Functions provided ------------------------------------------------*/
47
48/* --- @trace@ --- *
49 *
50 * Arguments: @unsigned int l@ = trace level for output
51 * @const char *f@ = a @printf@-style format string
52 * @...@ = other arguments
53 *
54 * Returns: ---
55 *
56 * Use: Reports a message to the trace output.
57 */
58
59extern void trace(unsigned int /*l*/, const char */*f*/, ...);
60
61/* --- @trace_block@ --- *
62 *
63 * Arguments: @unsigned int l@ = trace level for output
64 * @const char *s@ = some header string to write
65 * @const void *b@ = pointer to a block of memory to dump
66 * @size_t sz@ = size of the block of memory
67 *
68 * Returns: ---
69 *
70 * Use: Dumps the contents of a block to the trace output.
71 */
72
73extern void trace_block(unsigned int /*l*/, const char */*s*/,
74 const void */*b*/, size_t /*sz*/);
75
76/* --- @trace_on@ --- *
77 *
78 * Arguments: @FILE *fp@ = a file to trace on
79 * @unsigned int l@ = trace level to set
80 *
81 * Returns: ---
82 *
83 * Use: Enables tracing to a file.
84 */
85
86extern void trace_on(FILE */*fp*/, unsigned int /*l*/);
87
88/* --- @trace_setLevel@ --- *
89 *
90 * Arguments: @unsigned int l@ = trace level to set
91 *
92 * Returns: ---
93 *
94 * Use: Sets the tracing level.
95 */
96
97extern void trace_setLevel(unsigned int /*l*/);
98
99/* --- @tracing@ --- *
100 *
101 * Arguments: ---
102 *
103 * Returns: Zero if not tracing, tracing level if tracing.
104 *
105 * Use: Informs the caller whether tracing is enabled.
106 */
107
108extern unsigned int tracing(void);
109
110/*----- Tracing macros ----------------------------------------------------*/
111
112#ifndef NTRACE
113# define T(x) x
114# define IF_TRACING(l, x) if ((l) & tracing()) x
115#else
116# define T(x)
117# define IF_TRACING(l, x)
118#endif
119
120/*----- That's all, folks -------------------------------------------------*/
121
122#ifdef __cplusplus
123 }
124#endif
125
126#endif