FreeBSD isn't evil - just misguided
[cvsps-yd/commitid.git] / cbtcommon / debug.h
blob2ede381ec5d1de01ee9b185db9f7003f1df00fe5
1 /*
2 * Copyright 2001, 2002, 2003 David Mansfield and Cobite, Inc.
3 * See COPYING file for license information
4 */
6 #ifndef _DEBUG_H
7 #define _DEBUG_H
9 #include <stdio.h>
10 #include <stdarg.h>
11 #ifndef MACINTOSH
12 #include <sys/types.h>
13 #endif
15 #include "inline.h"
17 #define DEBUG_NUM_FACILITIES 32 /* should be 64 on 64bit CPU... */
18 #define DEBUG_SYSERROR 1 /* same as DEBUG_ERROR, but here for clarity */
19 #define DEBUG_ERROR 1
20 #define DEBUG_STATUS 2
21 #define DEBUG_TCP 4
22 #define DEBUG_SIGNALS 8
23 #define DEBUG_APPERROR 16
24 #define DEBUG_APPMSG1 32
25 #define DEBUG_APPMSG2 64
26 #define DEBUG_APPMSG3 128
27 #define DEBUG_APPMSG4 256
28 #define DEBUG_APPMSG5 512
29 #define DEBUG_LIBERROR 1024
30 #define DEBUG_LIBSTATUS 2048
32 #ifdef __cplusplus
33 extern "C"
35 #endif
37 extern unsigned int debuglvl;
39 void hexdump( const char *ptr, int size, const char *fmt, ... );
40 void vdebug(int dtype, const char *fmt, va_list);
41 void vmdebug(int dtype, const char *fmt, va_list);
42 void to_hex( char* dest, const char* src, size_t n );
43 void debug_set_error_file(FILE *);
44 void debug_set_error_facility(int mask, FILE *);
46 static INLINE void debug(unsigned int dtype, const char *fmt, ...)
48 va_list ap;
50 if (!(debuglvl & dtype))
51 return;
53 va_start(ap, fmt);
54 vdebug(dtype, fmt, ap);
55 va_end(ap);
58 static INLINE void mdebug(unsigned int dtype, const char *fmt, ...)
60 va_list ap;
62 if (!(debuglvl & dtype))
63 return;
65 va_start(ap, fmt);
66 vmdebug(dtype, fmt, ap);
67 va_end(ap);
70 #ifdef __cplusplus
72 #endif
75 #endif /* DEBUG_H */