]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSCore/mDNSDebug.h
mDNSResponder-87.tar.gz
[apple/mdnsresponder.git] / mDNSCore / mDNSDebug.h
1 /*
2 * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22
23 Change History (most recent first):
24
25 $Log: mDNSDebug.h,v $
26 Revision 1.24 2004/09/16 01:58:21 cheshire
27 Fix compiler warnings
28
29 Revision 1.23 2004/05/18 23:51:25 cheshire
30 Tidy up all checkin comments to use consistent "<rdar://problem/xxxxxxx>" format for bug numbers
31
32 Revision 1.22 2004/04/22 04:27:42 cheshire
33 Spacing tidyup
34
35 Revision 1.21 2004/04/14 23:21:41 ksekar
36 Removed accidental checkin of MALLOC_DEBUGING flag in 1.20
37
38 Revision 1.20 2004/04/14 23:09:28 ksekar
39 Support for TSIG signed dynamic updates.
40
41 Revision 1.19 2004/03/15 18:57:59 cheshire
42 Undo last checkin that accidentally made verbose debugging the default for all targets
43
44 Revision 1.18 2004/03/13 01:57:33 ksekar
45 <rdar://problem/3192546>: DynDNS: Dynamic update of service records
46
47 Revision 1.17 2004/01/28 21:14:23 cheshire
48 Reconcile debug_mode and gDebugLogging into a single flag (mDNS_DebugMode)
49
50 Revision 1.16 2003/12/09 01:30:06 rpantos
51 Fix usage of ARGS... macros to build properly on Windows.
52
53 Revision 1.15 2003/12/08 20:55:26 rpantos
54 Move some definitions here from mDNSMacOSX.h.
55
56 Revision 1.14 2003/08/12 19:56:24 cheshire
57 Update to APSL 2.0
58
59 Revision 1.13 2003/07/02 21:19:46 cheshire
60 <rdar://problem/3313413> Update copyright notices, etc., in source code comments
61
62 Revision 1.12 2003/05/26 03:01:27 cheshire
63 <rdar://problem/3268904> sprintf/vsprintf-style functions are unsafe; use snprintf/vsnprintf instead
64
65 Revision 1.11 2003/05/21 17:48:10 cheshire
66 Add macro to enable GCC's printf format string checking
67
68 Revision 1.10 2003/04/26 02:32:57 cheshire
69 Add extern void LogMsg(const char *format, ...);
70
71 Revision 1.9 2002/09/21 20:44:49 zarzycki
72 Added APSL info
73
74 Revision 1.8 2002/09/19 04:20:43 cheshire
75 Remove high-ascii characters that confuse some systems
76
77 Revision 1.7 2002/09/16 18:41:42 cheshire
78 Merge in license terms from Quinn's copy, in preparation for Darwin release
79
80 */
81
82 #ifndef __mDNSDebug_h
83 #define __mDNSDebug_h
84
85 // Set MDNS_DEBUGMSGS to 0 to optimize debugf() calls out of the compiled code
86 // Set MDNS_DEBUGMSGS to 1 to generate normal debugging messages
87 // Set MDNS_DEBUGMSGS to 2 to generate verbose debugging messages
88 // MDNS_DEBUGMSGS is normally set in the project options (or makefile) but can also be set here if desired
89 // (If you edit the file here to turn on MDNS_DEBUGMSGS while you're debugging some code, be careful
90 // not to accidentally check-in that change by mistake when you check in your other changes.)
91
92 //#undef MDNS_DEBUGMSGS
93 //#define MDNS_DEBUGMSGS 2
94
95 // Set MDNS_CHECK_PRINTF_STYLE_FUNCTIONS to 1 to enable extra GCC compiler warnings
96 // Note: You don't normally want to do this, because it generates a bunch of
97 // spurious warnings for the following custom extensions implemented by mDNS_vsnprintf:
98 // warning: `#' flag used with `%s' printf format (for %#s -- pascal string format)
99 // warning: repeated `#' flag in format (for %##s -- DNS name string format)
100 // warning: double format, pointer arg (arg 2) (for %.4a, %.16a, %#a -- IP address formats)
101 #define MDNS_CHECK_PRINTF_STYLE_FUNCTIONS 0
102 #if MDNS_CHECK_PRINTF_STYLE_FUNCTIONS
103 #define IS_A_PRINTF_STYLE_FUNCTION(F,A) __attribute__ ((format(printf,F,A)))
104 #else
105 #define IS_A_PRINTF_STYLE_FUNCTION(F,A)
106 #endif
107
108 #ifdef __cplusplus
109 extern "C" {
110 #endif
111
112 #if MDNS_DEBUGMSGS
113 #define debugf debugf_
114 extern void debugf_(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
115 #else // If debug breaks are off, use a preprocessor trick to optimize those calls out of the code
116 #if (defined(__GNUC__))
117 #define debugf( ARGS... ) ((void)0)
118 #elif (defined(__MWERKS__))
119 #define debugf( ... )
120 #else
121 #define debugf 1 ? ((void)0) : (void)
122 #endif
123 #endif
124
125 #if MDNS_DEBUGMSGS > 1
126 #define verbosedebugf verbosedebugf_
127 extern void verbosedebugf_(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
128 #else
129 #if (defined(__GNUC__))
130 #define verbosedebugf( ARGS... ) ((void)0)
131 #elif (defined(__MWERKS__))
132 #define verbosedebugf( ... )
133 #else
134 #define verbosedebugf 1 ? ((void)0) : (void)
135 #endif
136 #endif
137
138 // LogMsg is used even in shipping code, to write truly serious error messages to syslog (or equivalent)
139 extern int mDNS_DebugMode; // If non-zero, LogMsg() writes to stderr instead of syslog
140 extern void LogMsg(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
141 extern void LogMsgIdent(const char *ident, const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(2,3);
142 extern void LogMsgNoIdent(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
143
144 // Set this symbol to 1 to do extra debug checks on malloc() and free()
145 // Set this symbol to 2 to write a log message for every malloc() and free()
146 #define MACOSX_MDNS_MALLOC_DEBUGGING 0
147
148 #if MACOSX_MDNS_MALLOC_DEBUGGING >= 1
149 extern void *mallocL(char *msg, unsigned int size);
150 extern void freeL(char *msg, void *x);
151 #else
152 #define mallocL(X,Y) malloc(Y)
153 #define freeL(X,Y) free(Y)
154 #endif
155
156 #if MACOSX_MDNS_MALLOC_DEBUGGING >= 2
157 #define LogMalloc LogMsg
158 #else
159 #if (defined( __GNUC__ ))
160 #define LogMalloc(ARGS...) ((void)0)
161 #elif (defined( __MWERKS__ ))
162 #define LogMalloc( ... )
163 #else
164 #define LogMalloc 1 ? ((void)0) : (void)
165 #endif
166 #endif
167
168 #define LogAllOperations 0
169
170 #if LogAllOperations
171 #define LogOperation LogMsg
172 #else
173 #define LogOperation debugf
174 #endif
175
176 #ifdef __cplusplus
177 }
178 #endif
179
180 #endif