]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSCore/mDNSDebug.h
mDNSResponder-58.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.14 2003/08/12 19:56:24 cheshire
27 Update to APSL 2.0
28
29 Revision 1.13 2003/07/02 21:19:46 cheshire
30 <rdar://problem/3313413> Update copyright notices, etc., in source code comments
31
32 Revision 1.12 2003/05/26 03:01:27 cheshire
33 <rdar://problem/3268904> sprintf/vsprintf-style functions are unsafe; use snprintf/vsnprintf instead
34
35 Revision 1.11 2003/05/21 17:48:10 cheshire
36 Add macro to enable GCC's printf format string checking
37
38 Revision 1.10 2003/04/26 02:32:57 cheshire
39 Add extern void LogMsg(const char *format, ...);
40
41 Revision 1.9 2002/09/21 20:44:49 zarzycki
42 Added APSL info
43
44 Revision 1.8 2002/09/19 04:20:43 cheshire
45 Remove high-ascii characters that confuse some systems
46
47 Revision 1.7 2002/09/16 18:41:42 cheshire
48 Merge in license terms from Quinn's copy, in preparation for Darwin release
49
50 */
51
52 #ifndef __mDNSDebug_h
53 #define __mDNSDebug_h
54
55 // Set MDNS_DEBUGMSGS to 0 to optimize debugf() calls out of the compiled code
56 // Set MDNS_DEBUGMSGS to 1 to generate normal debugging messages
57 // Set MDNS_DEBUGMSGS to 2 to generate verbose debugging messages
58 // MDNS_DEBUGMSGS is normally set in the project options (or makefile) but can also be set here if desired
59
60 //#define MDNS_DEBUGMSGS 2
61
62 // Set MDNS_CHECK_PRINTF_STYLE_FUNCTIONS to 1 to enable extra GCC compiler warnings
63 // Note: You don't normally want to do this, because it generates a bunch of
64 // spurious warnings for the following custom extensions implemented by mDNS_vsnprintf:
65 // warning: `#' flag used with `%s' printf format (for %#s -- pascal string format)
66 // warning: repeated `#' flag in format (for %##s -- DNS name string format)
67 // warning: double format, pointer arg (arg 2) (for %.4a, %.16a, %#a -- IP address formats)
68 #define MDNS_CHECK_PRINTF_STYLE_FUNCTIONS 0
69 #if MDNS_CHECK_PRINTF_STYLE_FUNCTIONS
70 #define IS_A_PRINTF_STYLE_FUNCTION(F,A) __attribute__ ((format(printf,F,A)))
71 #else
72 #define IS_A_PRINTF_STYLE_FUNCTION(F,A)
73 #endif
74
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78
79 #if MDNS_DEBUGMSGS
80 #define debugf debugf_
81 extern void debugf_(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
82 #else // If debug breaks are off, use a preprocessor trick to optimize those calls out of the code
83 #if( defined( __GNUC__ ) )
84 #define debugf( ARGS... ) ((void)0)
85 #elif( defined( __MWERKS__ ) )
86 #define debugf( ... )
87 #else
88 #define debugf 1 ? ((void)0) : (void)
89 #endif
90 #endif
91
92 #if MDNS_DEBUGMSGS > 1
93 #define verbosedebugf verbosedebugf_
94 extern void verbosedebugf_(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
95 #else
96 #if( defined( __GNUC__ ) )
97 #define verbosedebugf( ARGS... ) ((void)0)
98 #elif( defined( __MWERKS__ ) )
99 #define verbosedebugf( ... )
100 #else
101 #define verbosedebugf 1 ? ((void)0) : (void)
102 #endif
103 #endif
104
105 // LogMsg is used even in shipping code, to write truly serious error messages to syslog (or equivalent)
106 extern void LogMsg(const char *format, ...) IS_A_PRINTF_STYLE_FUNCTION(1,2);
107
108 #ifdef __cplusplus
109 }
110 #endif
111
112 #endif