10969
|
1
|
|
2 /*
|
|
3 Meanwhile - Unofficial Lotus Sametime Community Client Library
|
|
4 Copyright (C) 2004 Christopher (siege) O'Brien
|
|
5
|
|
6 This library is free software; you can redistribute it and/or
|
|
7 modify it under the terms of the GNU Library General Public
|
|
8 License as published by the Free Software Foundation; either
|
|
9 version 2 of the License, or (at your option) any later version.
|
|
10
|
|
11 This library is distributed in the hope that it will be useful,
|
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 Library General Public License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU Library General Public
|
|
17 License along with this library; if not, write to the Free
|
|
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19 */
|
|
20
|
|
21 #ifndef _MW_DEBUG_H
|
|
22 #define _MW_DEBUG_H
|
|
23
|
|
24
|
|
25 #include <stdarg.h>
|
|
26 #include <glib.h>
|
|
27
|
|
28 #include "mw_common.h"
|
|
29
|
|
30
|
|
31 /** replaces NULL strings with "(null)". useful for printf where
|
|
32 you're unsure that the %s will be non-NULL. Note that while the
|
|
33 linux printf will do this automatically, not all will. The others
|
|
34 will instead segfault */
|
|
35 #define NSTR(str) ((str)? (str): "(null)")
|
|
36
|
|
37
|
|
38 #ifndef g_debug
|
|
39 #define g_debug(format...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
|
|
40 #endif
|
|
41
|
|
42
|
|
43 #ifndef g_info
|
|
44 #define g_info(format...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
|
|
45 #endif
|
|
46
|
|
47
|
|
48 /** logs buf as hex pairs. Requires DEBUG enabled during build */
|
|
49 void pretty_print(const char *buf, gsize len);
|
|
50
|
|
51
|
|
52 /** logs block as hex pairs. Requires DEBUG enabled during build */
|
|
53 void pretty_print_opaque(struct mwOpaque *block);
|
|
54
|
|
55
|
|
56 #ifndef MW_MAILME_ADDRESS
|
|
57 /** email address used in mw_debug_mailme. */
|
|
58 #define MW_MAILME_ADDRESS "meanwhile-devel@lists.sourceforge.net"
|
|
59 #endif
|
|
60
|
|
61
|
|
62 #ifndef MW_MAILME_CUT_START
|
|
63 #define MW_MAILME_CUT_START "-------- begin copy --------"
|
|
64 #endif
|
|
65
|
|
66
|
|
67 #ifndef MW_MAILME_CUT_STOP
|
|
68 #define MW_MAILME_CUT_STOP "--------- end copy ---------"
|
|
69 #endif
|
|
70
|
|
71
|
|
72 #ifndef MW_MAILME_MESSAGE
|
|
73 /** message used in mw_debug_mailme instructing user on what to do
|
|
74 with the debugging output produced from that function */
|
|
75 #define MW_MAILME_MESSAGE "\n" \
|
|
76 " Greetings! It seems that you've run across protocol data that the\n" \
|
|
77 "Meanwhile library does not yet know about. As such, there may be\n" \
|
|
78 "some unexpected behaviour in this session. If you'd like to help\n" \
|
|
79 "resolve this issue, please copy and paste the following block into\n" \
|
|
80 "an email to the address listed below with a brief explanation of\n" \
|
|
81 "what you were doing at the time of this message. Thanks a lot!"
|
|
82 #endif
|
|
83
|
|
84
|
|
85 /** Outputs a hex dump of a mwOpaque with debugging info and a
|
|
86 pre-defined message. Identical to mw_debug_mailme, but taking a
|
|
87 va_list argument */
|
|
88 void mw_debug_mailme_v(struct mwOpaque *block,
|
|
89 const char *info, va_list args);
|
|
90
|
|
91
|
|
92 /** Outputs a hex dump of a mwOpaque with debugging info and a
|
|
93 pre-defined message.
|
|
94
|
|
95 @arg block data to be printed in a hex block
|
|
96 @arg info a printf-style format string
|
|
97
|
|
98 The resulting message is in the following format:
|
|
99 @code
|
|
100 MW_MAILME_MESSAGE
|
|
101 " Please send mail to: " MW_MAILME_ADDRESS
|
|
102 MW_MAILME_CUT_START
|
|
103 info
|
|
104 block
|
|
105 MW_MAILME_CUT_STOP
|
|
106 @endcode
|
|
107 */
|
|
108 void mw_debug_mailme(struct mwOpaque *block, const char *info, ...);
|
|
109
|
|
110
|
|
111 #endif
|
|
112
|