chiark / gitweb /
Whoops. I'd left the type of the jump buffer as `sigjmp_buf'.
[mLib] / trace.h
1 /* -*-c-*-
2  *
3  * $Id: trace.h,v 1.3 1999/05/06 19:51:35 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 Library General Public License as
16  * published by the Free Software Foundation; either version 2 of the
17  * License, or (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 Library General Public License for more details.
23  * 
24  * You should have received a copy of the GNU Library General Public
25  * License along with mLib; if not, write to the Free
26  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27  * MA 02111-1307, USA.
28  */
29
30 /*----- Revision history --------------------------------------------------*
31  *
32  * $Log: trace.h,v $
33  * Revision 1.3  1999/05/06 19:51:35  mdw
34  * Reformatted the LGPL notice a little bit.
35  *
36  * Revision 1.2  1999/05/05 18:50:31  mdw
37  * Change licensing conditions to LGPL.
38  *
39  * Revision 1.1.1.1  1998/06/17 23:44:42  mdw
40  * Initial version of mLib
41  *
42  */
43
44 #ifndef TRACE_H
45 #define TRACE_H
46
47 #ifdef __cplusplus
48   extern "C" {
49 #endif
50
51 #include <stdio.h>
52
53 /*----- Functions provided ------------------------------------------------*/
54
55 /* --- @trace@ --- *
56  *
57  * Arguments:   @unsigned int l@ = trace level for output
58  *              @const char *f@ = a @printf@-style format string
59  *              @...@ = other arguments
60  *
61  * Returns:     ---
62  *
63  * Use:         Reports a message to the trace output.
64  */
65
66 extern void trace(unsigned int /*l*/, const char */*f*/, ...);
67
68 /* --- @trace_block@ --- *
69  *
70  * Arguments:   @unsigned int l@ = trace level for output
71  *              @const char *s@ = some header string to write
72  *              @const void *b@ = pointer to a block of memory to dump
73  *              @size_t sz@ = size of the block of memory
74  *
75  * Returns:     ---
76  *
77  * Use:         Dumps the contents of a block to the trace output.
78  */
79
80 extern void trace_block(unsigned int /*l*/, const char */*s*/,
81                         const void */*b*/, size_t /*sz*/);
82
83 /* --- @trace_on@ --- *
84  *
85  * Arguments:   @FILE *fp@ = a file to trace on
86  *              @unsigned int l@ = trace level to set
87  *
88  * Returns:     ---
89  *
90  * Use:         Enables tracing to a file.
91  */
92
93 extern void trace_on(FILE */*fp*/, unsigned int /*l*/);
94
95 /* --- @trace_setLevel@ --- *
96  *
97  * Arguments:   @unsigned int l@ = trace level to set
98  *
99  * Returns:     ---
100  *
101  * Use:         Sets the tracing level.
102  */
103
104 extern void trace_setLevel(unsigned int /*l*/);
105
106 /* --- @tracing@ --- *
107  *
108  * Arguments:   ---
109  *
110  * Returns:     Zero if not tracing, tracing level if tracing.
111  *
112  * Use:         Informs the caller whether tracing is enabled.
113  */
114
115 extern unsigned int tracing(void);
116
117 /*----- Tracing macros ----------------------------------------------------*/
118
119 #ifndef NTRACE
120 #  define T(x) x
121 #  define IF_TRACING(l, x) if ((l) & tracing()) x
122 #else
123 #  define T(x)
124 #  define IF_TRACING(l, x)
125 #endif
126
127 /*----- That's all, folks -------------------------------------------------*/
128
129 #ifdef __cplusplus
130   }
131 #endif
132
133 #endif