1 /*
2  * Private debugging macros for CUPS.
3  *
4  * Copyright 2007-2012 by Apple Inc.
5  * Copyright 1997-2005 by Easy Software Products.
6  *
7  * These coded instructions, statements, and computer programs are the
8  * property of Apple Inc. and are protected by Federal copyright
9  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
10  * which should have been included with this file.  If this file is
11  * missing or damaged, see the license at "http://www.cups.org/".
12  *
13  * This file is subject to the Apple OS-Developed Software exception.
14  */
15 
16 #ifndef _CUPS_DEBUG_PRIVATE_H_
17 #  define _CUPS_DEBUG_PRIVATE_H_
18 
19 
20 /*
21  * Include necessary headers...
22  */
23 
24 #  include <cups/versioning.h>
25 
26 
27 /*
28  * C++ magic...
29  */
30 
31 #  ifdef __cplusplus
32 extern "C" {
33 #  endif /* __cplusplus */
34 
35 
36 /*
37  * The debug macros are used if you compile with DEBUG defined.
38  *
39  * Usage:
40  *
41  *   DEBUG_puts("string")
42  *   DEBUG_printf(("format string", arg, arg, ...));
43  *
44  * Note the extra parenthesis around the DEBUG_printf macro...
45  *
46  * Newlines are not required on the end of messages, as both add one when
47  * writing the output.
48  *
49  * If the first character is a digit, then it represents the "log level" of the
50  * message from 0 to 9.  The default level is 1.  The following defines the
51  * current levels we use:
52  *
53  * 0 = public APIs, other than value accessor functions
54  * 1 = return values for public APIs
55  * 2 = public value accessor APIs, progress for public APIs
56  * 3 = return values for value accessor APIs
57  * 4 = private APIs, progress for value accessor APIs
58  * 5 = return values for private APIs
59  * 6 = progress for private APIs
60  * 7 = static functions
61  * 8 = return values for static functions
62  * 9 = progress for static functions
63  *
64  * The DEBUG_set macro allows an application to programmatically enable (or
65  * disable) debug logging.  The arguments correspond to the CUPS_DEBUG_LOG,
66  * CUPS_DEBUG_LEVEL, and CUPS_DEBUG_FILTER environment variables.
67  */
68 
69 #  ifdef DEBUG
70 #    ifdef WIN32
71 #      ifdef LIBCUPS2_EXPORTS
72 #        define DLLExport __declspec(dllexport)
73 #      else
74 #        define DLLExport
75 #      endif /* LIBCUPS2_EXPORTS */
76 #    else
77 #      define DLLExport
78 #    endif /* WIN32 */
79 #    define DEBUG_puts(x) _cups_debug_puts(x)
80 #    define DEBUG_printf(x) _cups_debug_printf x
81 #    define DEBUG_set(logfile,level,filter) _cups_debug_set(logfile,level,filter,1)
82 #  else
83 #    define DLLExport
84 #    define DEBUG_puts(x)
85 #    define DEBUG_printf(x)
86 #    define DEBUG_set(logfile,level,filter)
87 #  endif /* DEBUG */
88 
89 
90 /*
91  * Prototypes...
92  */
93 
94 extern int	_cups_debug_fd;
95 extern int	_cups_debug_level;
96 extern void	DLLExport _cups_debug_printf(const char *format, ...)
97 		__attribute__ ((__format__ (__printf__, 1, 2)));
98 extern void	DLLExport _cups_debug_puts(const char *s);
99 extern void	DLLExport _cups_debug_set(const char *logfile,
100 					  const char *level, const char *filter,
101 					  int force);
102 #  ifdef WIN32
103 extern int	_cups_gettimeofday(struct timeval *tv, void *tz);
104 #    define gettimeofday(a,b) _cups_gettimeofday(a, b)
105 #  endif /* WIN32 */
106 
107 #  ifdef __cplusplus
108 }
109 #  endif /* __cplusplus */
110 
111 #endif /* !_CUPS_DEBUG_PRIVATE_H_ */
112