1 2 #ifndef __DEBUG_H__ 3 #define __DEBUG_H__ 4 5 #include "config.h" 6 7 #include <glib.h> 8 9 #if 0 10 #include "gibber-xmpp-stanza.h" 11 #endif 12 13 G_BEGIN_DECLS 14 15 #ifdef ENABLE_DEBUG 16 17 typedef enum 18 { 19 DEBUG_TRANSPORT = 1 << 0, 20 DEBUG_NET = 1 << 1, 21 DEBUG_XMPP_READER = 1 << 2, 22 DEBUG_XMPP_WRITER = 1 << 3, 23 DEBUG_SASL = 1 << 4, 24 DEBUG_SSL = 1 << 5, 25 DEBUG_RMULTICAST = 1 << 6, 26 DEBUG_RMULTICAST_SENDER = 1 << 7, 27 DEBUG_MUC_CONNECTION = 1 << 8, 28 DEBUG_BYTESTREAM = 1 << 9, 29 DEBUG_FILE_TRANSFER = 1 << 10, 30 } DebugFlags; 31 32 #define DEBUG_XMPP (DEBUG_XMPP_READER | DEBUG_XMPP_WRITER) 33 34 void gibber_debug_set_flags_from_env (void); 35 void gibber_debug_set_flags (DebugFlags flags); 36 gboolean gibber_debug_flag_is_set (DebugFlags flag); 37 void gibber_debug (DebugFlags flag, const gchar *format, ...) 38 G_GNUC_PRINTF (2, 3); 39 #if 0 40 void gibber_debug_stanza (DebugFlags flag, GibberXmppStanza *stanza, 41 const gchar *format, ...) 42 G_GNUC_PRINTF (3, 4); 43 #endif 44 45 #ifdef DEBUG_FLAG 46 47 #define DEBUG(format, ...) \ 48 G_STMT_START { \ 49 gibber_debug (DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__); \ 50 } G_STMT_END 51 52 #define DEBUG_STANZA(stanza, format, ...) \ 53 G_STMT_START { \ 54 gibber_debug_stanza (DEBUG_FLAG, stanza, "%s: " format, G_STRFUNC,\ 55 ##__VA_ARGS__); \ 56 } G_STMT_END 57 58 #define DEBUGGING (debug_flag_is_set (DEBUG_FLAG)) 59 60 #endif /* DEBUG_FLAG */ 61 62 #else /* ENABLE_DEBUG */ 63 64 #ifdef DEBUG_FLAG 65 66 #define DEBUG(format, ...) G_STMT_START { } G_STMT_END 67 68 #define DEBUG_STANZA(stanza, format, ...) G_STMT_START { } G_STMT_END 69 70 #define DEBUGGING (0) 71 72 #endif /* DEBUG_FLAG */ 73 74 #endif /* ENABLE_DEBUG */ 75 76 G_END_DECLS 77 78 #endif 79