1 #ifndef MPLAYER_DEBUGTOOLS_H
2 #define MPLAYER_DEBUGTOOLS_H
3 
4 #include <stdarg.h>
5 #include "config.h"
6 #include "windef.h"
7 
8 struct GUID;
9 
10 /* Internal definitions (do not use these directly) */
11 
12 enum DEBUG_CLASS { DBCL_FIXME, DBCL_ERR, DBCL_WARN, DBCL_TRACE, DBCL_COUNT };
13 
14 #ifndef NO_TRACE_MSGS
15 # define GET_DEBUGGING_trace(dbch) ((dbch)[0] & (1 << DBCL_TRACE))
16 #else
17 # define GET_DEBUGGING_trace(dbch) 0
18 #endif
19 
20 #ifndef NO_DEBUG_MSGS
21 # define GET_DEBUGGING_warn(dbch)  ((dbch)[0] & (1 << DBCL_WARN))
22 # define GET_DEBUGGING_fixme(dbch) ((dbch)[0] & (1 << DBCL_FIXME))
23 #else
24 # define GET_DEBUGGING_warn(dbch)  0
25 # define GET_DEBUGGING_fixme(dbch) 0
26 #endif
27 
28 /* define error macro regardless of what is configured */
29 #define GET_DEBUGGING_err(dbch)  ((dbch)[0] & (1 << DBCL_ERR))
30 
31 #define GET_DEBUGGING(dbcl,dbch)  GET_DEBUGGING_##dbcl(dbch)
32 #define SET_DEBUGGING(dbcl,dbch,on) \
33     ((on) ? ((dbch)[0] |= 1 << (dbcl)) : ((dbch)[0] &= ~(1 << (dbcl))))
34 
35 /* Exported definitions and macros */
36 
37 /* These function return a printable version of a string, including
38    quotes.  The string will be valid for some time, but not indefinitely
39    as strings are re-used.  */
40 LPCSTR debugstr_an( LPCSTR s, int n );
41 LPCSTR debugstr_wn( LPCWSTR s, int n );
42 LPCSTR debugres_a( LPCSTR res );
43 LPCSTR debugres_w( LPCWSTR res );
44 LPCSTR debugstr_guid( const struct GUID *id );
45 LPCSTR debugstr_hex_dump( const void *ptr, int len );
46 int dbg_header_err( const char *dbg_channel, const char *func );
47 int dbg_header_warn( const char *dbg_channel, const char *func );
48 int dbg_header_fixme( const char *dbg_channel, const char *func );
49 int dbg_header_trace( const char *dbg_channel, const char *func );
50 int dbg_vprintf( const char *format, va_list args );
51 
debugstr_a(LPCSTR s)52 static inline LPCSTR debugstr_a( LPCSTR s )  { return debugstr_an( s, 80 ); }
debugstr_w(LPCWSTR s)53 static inline LPCSTR debugstr_w( LPCWSTR s ) { return debugstr_wn( s, 80 ); }
54 
55 #define TRACE_(X) TRACE
56 #define WARN_(X) TRACE
57 #define WARN TRACE
58 #define ERR_(X) printf
59 #define ERR printf
60 #define FIXME_(X) TRACE
61 #define FIXME TRACE
62 
63 #define TRACE_ON(X) 1
64 #define ERR_ON(X) 1
65 
66 #define DECLARE_DEBUG_CHANNEL(ch) \
67     extern char dbch_##ch[];
68 #define DEFAULT_DEBUG_CHANNEL(ch) \
69     extern char dbch_##ch[]; static char * const __dbch_default = dbch_##ch;
70 
71 #endif  /* MPLAYER_DEBUGTOOLS_H */
72