SANEI  1.2.1.196-0f472
sanei_debug.h
Go to the documentation of this file.
1 
7 #ifndef _SANEI_DEBUG_H
8 #define _SANEI_DEBUG_H
9 
10 #include <sane/sanei.h>
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
70 /* @} */
71 
72 
74 #define ENTRY(name) PASTE(PASTE(PASTE(sane_,BACKEND_NAME),_),name)
75 
76 #ifdef NDEBUG
77 
78 extern void sanei_debug_ndebug (int level, const char *msg, ...);
79 
80 # define DBG_LEVEL (0)
81 # define DBG_INIT()
82 # define DBG sanei_debug_ndebug
83 # define IF_DBG(x)
84 
85 #else /* !NDEBUG */
86 
88 # define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME)
89 
90 # if defined(BACKEND_NAME) && !defined(STUBS)
91 # ifdef DEBUG_DECLARE_ONLY
92 extern int DBG_LEVEL;
93 # else /* !DEBUG_DECLARE_ONLY */
94 int DBG_LEVEL = 0;
95 # endif /* DEBUG_DECLARE_ONLY */
96 # endif /* BACKEND_NAME && !STUBS */
97 
99 # define DBG_INIT() \
100  sanei_init_debug (STRINGIFY(BACKEND_NAME), &DBG_LEVEL)
101 
103 # define DBG_LOCAL PASTE(DBG_LEVEL,_call)
104 
105 
106 # ifndef STUBS
107 
108 # ifdef DEBUG_DECLARE_ONLY
109 
110 extern void DBG_LOCAL (int level, const char *msg, ...)
111 #ifdef __GNUC__
112 __attribute__ ((format (printf, 2, 3)))
113 #endif
114 ;
115 
116 # else /* !DEBUG_DECLARE_ONLY */
117 
118 # include <stdarg.h>
119 
120 extern void sanei_debug_msg
121  (int level, int max_level, const char *be, const char *fmt, va_list ap);
122 
123 #ifdef __GNUC__
124 # ifndef DEBUG_NOT_STATIC
125 static
126 # endif /* !DEBUG_NOT_STATIC */
127 void DBG_LOCAL (int level, const char *msg, ...) __attribute__ ((format (printf, 2, 3)));
128 #endif /* __GNUC__ */
129 
130 # ifndef DEBUG_NOT_STATIC
131 static
132 # endif /* !DEBUG_NOT_STATIC */
133 void
134 DBG_LOCAL (int level, const char *msg, ...)
135 {
136  va_list ap;
137 
138  va_start (ap, msg);
139  sanei_debug_msg (level, DBG_LEVEL, STRINGIFY(BACKEND_NAME), msg, ap);
140  va_end (ap);
141 }
142 
143 # endif /* DEBUG_DECLARE_ONLY */
144 
145 # endif /* !STUBS */
146 
148 # define DBG DBG_LOCAL
149 
150 extern void sanei_init_debug (const char * backend, int * debug_level_var);
151 
153 # define IF_DBG(x) x
154 
155 #endif /* NDEBUG */
156 
157 #ifdef __cplusplus
158 } // extern "C"
159 #endif
160 
161 #endif /* _SANEI_DEBUG_H */
Convenience macros and function declarations for backends.
#define STRINGIFY(x)
Turn parameter into string.
Definition: sanei.h:159
#define DBG_LEVEL
Current debug level.
Definition: sanei_debug.h:88
void sanei_init_debug(const char *backend, int *debug_level_var)
Expands to sane_BACKEND_NAME_name.
#define DBG_LOCAL
Expands to sane_BACKEND_NAME_name.
Definition: sanei_debug.h:103
void sanei_debug_msg(int level, int max_level, const char *be, const char *fmt, va_list ap)
Expands to sane_BACKEND_NAME_name.