Implemented DeviceIoControl VWIN32_DIOC_DOS_DRIVEINFO, needed by
[wine.git] / include / debugtools.h
blob3624b4bcdd742f2a47743e1a1f1a7f468900d24d
2 #ifndef __WINE_DEBUGTOOLS_H
3 #define __WINE_DEBUGTOOLS_H
5 #ifdef __WINE__ /* Debugging interface is internal to Wine */
7 #include <stdarg.h>
8 #include "config.h"
9 #include "windef.h"
11 struct _GUID;
13 /* Internal definitions (do not use these directly) */
15 enum __DEBUG_CLASS { __DBCL_FIXME, __DBCL_ERR, __DBCL_WARN, __DBCL_TRACE, __DBCL_COUNT };
17 #ifndef NO_TRACE_MSGS
18 # define __GET_DEBUGGING_trace(dbch) ((dbch)[0] & (1 << __DBCL_TRACE))
19 #else
20 # define __GET_DEBUGGING_trace(dbch) 0
21 #endif
23 #ifndef NO_DEBUG_MSGS
24 # define __GET_DEBUGGING_warn(dbch) ((dbch)[0] & (1 << __DBCL_WARN))
25 # define __GET_DEBUGGING_fixme(dbch) ((dbch)[0] & (1 << __DBCL_FIXME))
26 #else
27 # define __GET_DEBUGGING_warn(dbch) 0
28 # define __GET_DEBUGGING_fixme(dbch) 0
29 #endif
31 /* define error macro regardless of what is configured */
32 #define __GET_DEBUGGING_err(dbch) ((dbch)[0] & (1 << __DBCL_ERR))
34 #define __GET_DEBUGGING(dbcl,dbch) __GET_DEBUGGING_##dbcl(dbch)
35 #define __SET_DEBUGGING(dbcl,dbch,on) \
36 ((on) ? ((dbch)[0] |= 1 << (dbcl)) : ((dbch)[0] &= ~(1 << (dbcl))))
38 #ifndef __GNUC__
39 #define __FUNCTION__ ""
40 #endif
42 #define __DPRINTF(dbcl,dbch) \
43 (!__GET_DEBUGGING(dbcl,(dbch)) || (dbg_header_##dbcl((dbch),__FUNCTION__),0)) ? \
44 (void)0 : (void)dbg_printf
46 /* Exported definitions and macros */
48 /* These function return a printable version of a string, including
49 quotes. The string will be valid for some time, but not indefinitely
50 as strings are re-used. */
51 extern LPCSTR debugstr_an (LPCSTR s, int n);
52 extern LPCSTR debugstr_wn (LPCWSTR s, int n);
53 extern LPCSTR debugres_a (LPCSTR res);
54 extern LPCSTR debugres_w (LPCWSTR res);
55 extern LPCSTR debugstr_guid( const struct _GUID *id );
56 extern LPCSTR debugstr_hex_dump (const void *ptr, int len);
57 extern int dbg_header_err( const char *dbg_channel, const char *func );
58 extern int dbg_header_warn( const char *dbg_channel, const char *func );
59 extern int dbg_header_fixme( const char *dbg_channel, const char *func );
60 extern int dbg_header_trace( const char *dbg_channel, const char *func );
61 extern int dbg_vprintf( const char *format, va_list args );
63 static inline LPCSTR debugstr_a( LPCSTR s ) { return debugstr_an( s, 80 ); }
64 static inline LPCSTR debugstr_w( LPCWSTR s ) { return debugstr_wn( s, 80 ); }
66 #ifdef __GNUC__
67 extern int dbg_printf(const char *format, ...) __attribute__((format (printf,1,2)));
68 #else
69 extern int dbg_printf(const char *format, ...);
70 #endif
72 #define TRACE __DPRINTF(trace,__dbch_default)
73 #define TRACE_(ch) __DPRINTF(trace,dbch_##ch)
74 #define TRACE_ON(ch) __GET_DEBUGGING(trace,dbch_##ch)
76 #define WARN __DPRINTF(warn,__dbch_default)
77 #define WARN_(ch) __DPRINTF(warn,dbch_##ch)
78 #define WARN_ON(ch) __GET_DEBUGGING(warn,dbch_##ch)
80 #define FIXME __DPRINTF(fixme,__dbch_default)
81 #define FIXME_(ch) __DPRINTF(fixme,dbch_##ch)
82 #define FIXME_ON(ch) __GET_DEBUGGING(fixme,dbch_##ch)
84 #undef ERR /* Solaris got an 'ERR' define in <sys/reg.h> */
85 #define ERR __DPRINTF(err,__dbch_default)
86 #define ERR_(ch) __DPRINTF(err,dbch_##ch)
87 #define ERR_ON(ch) __GET_DEBUGGING(err,dbch_##ch)
89 #define DECLARE_DEBUG_CHANNEL(ch) \
90 extern char dbch_##ch[];
91 #define DEFAULT_DEBUG_CHANNEL(ch) \
92 extern char dbch_##ch[]; static char * const __dbch_default = dbch_##ch;
94 #define DPRINTF dbg_printf
95 #define MESSAGE dbg_printf
97 #endif /* __WINE__ */
99 #endif /* __WINE_DEBUGTOOLS_H */