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