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