File: mw_debug.h

package info (click to toggle)
meanwhile 1.0.2-5
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,732 kB
  • ctags: 3,503
  • sloc: ansic: 13,856; sh: 8,360; makefile: 145
file content (128 lines) | stat: -rw-r--r-- 3,694 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

/*
  Meanwhile - Unofficial Lotus Sametime Community Client Library
  Copyright (C) 2004  Christopher (siege) O'Brien
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.
  
  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the Free
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#ifndef _MW_DEBUG_H
#define _MW_DEBUG_H


#include <stdarg.h>
#include <glib.h>

#include "mw_common.h"


/** replaces NULL strings with "(null)". useful for printf where
    you're unsure that the %s will be non-NULL. Note that while the
    linux printf will do this automatically, not all will. The others
    will instead segfault */
#define NSTR(str) ((str)? (str): "(null)")


#ifndef g_debug
#define g_debug(format...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format)
#endif


#ifndef g_info
#define g_info(format...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format)
#endif


#ifndef MW_MAILME_ADDRESS
/** email address used in mw_debug_mailme. */
#define MW_MAILME_ADDRESS  "meanwhile-devel@lists.sourceforge.net"
#endif


#ifndef MW_MAILME_CUT_START
#define MW_MAILME_CUT_START  "-------- begin copy --------"
#endif


#ifndef MW_MAILME_CUT_STOP
#define MW_MAILME_CUT_STOP   "--------- end copy ---------"
#endif


#ifndef MW_MAILME_MESSAGE
/** message used in mw_debug_mailme instructing user on what to do
    with the debugging output produced from that function */
#define MW_MAILME_MESSAGE "\n" \
 "  Greetings! It seems that you've run across protocol data that the\n" \
 "Meanwhile library does not yet know about. As such, there may be\n"    \
 "some unexpected behaviour in this session. If you'd like to help\n"    \
 "resolve this issue, please copy and paste the following block into\n"  \
 "an email to the address listed below with a brief explanation of\n"    \
 "what you were doing at the time of this message. Thanks a lot!"
#endif


void mw_debug_datav(const guchar *buf, gsize len,
		    const char *info, va_list args);


void mw_debug_data(const guchar *buf, gsize len,
		   const char *info, ...);


void mw_debug_opaquev(struct mwOpaque *o, const char *info, va_list args);


void mw_debug_opaque(struct mwOpaque *o, const char *info, ...);


void mw_mailme_datav(const guchar *buf, gsize len,
		     const char *info, va_list args);

void mw_mailme_data(const guchar *buf, gsize len,
		    const char *info, ...);


/** Outputs a hex dump of a mwOpaque with debugging info and a
    pre-defined message. Identical to mw_mailme_opaque, but taking a
    va_list argument */
void mw_mailme_opaquev(struct mwOpaque *o, const char *info, va_list args);



/** Outputs a hex dump of a mwOpaque with debugging info and a
    pre-defined message.

    if MW_MAILME is undefined or false, this function acts the same as
    mw_mailme_opaque.

    @arg block  data to be printed in a hex block
    @arg info   a printf-style format string

    The resulting message is in the following format:
    @code
    MW_MAILME_MESSAGE
    " Please send mail to: " MW_MAILME_ADDRESS
    MW_MAILME_CUT_START
    info
    block
    MW_MAILME_CUT_STOP
    @endcode
 */
void mw_mailme_opaque(struct mwOpaque *o, const char *info, ...);


#endif