annotate src/protocols/sametime/meanwhile/mw_debug.c @ 11690:872932089400

[gaim-migrate @ 13976] Removing the a_virgin field from GaimGtkImPane. It's no longer used. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 17 Oct 2005 23:04:59 +0000
parents 3ef77720e577
children 0110fc7c6a8a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10969
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
1
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
2 /*
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
3 Meanwhile - Unofficial Lotus Sametime Community Client Library
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
4 Copyright (C) 2004 Christopher (siege) O'Brien
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
5
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
6 This library is free software; you can redistribute it and/or
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
7 modify it under the terms of the GNU Library General Public
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
8 License as published by the Free Software Foundation; either
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
9 version 2 of the License, or (at your option) any later version.
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
10
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
11 This library is distributed in the hope that it will be useful,
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
14 Library General Public License for more details.
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
15
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
16 You should have received a copy of the GNU Library General Public
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
17 License along with this library; if not, write to the Free
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
19 */
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
20
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
21 #include <glib/gstring.h>
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
22
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
23 #include "mw_debug.h"
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
24
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
25
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
26 #define FRM "%02x"
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
27 #define FRMT "%02x%02x "
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
28 #define BUF(n) ((unsigned char) buf[n])
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
29 #define ADVANCE(b, n, c) {b += c; n -= c;}
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
30
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
31
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
32 #ifdef DEBUG
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
33 /** writes hex pairs of buf to str */
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
34 static void t_pretty_print(GString *str, const char *buf, gsize len) {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
35 while(len) {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
36 if(len >= 16) {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
37 g_string_append_printf(str,
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
38 FRMT FRMT FRMT FRMT FRMT FRMT FRMT FRMT "\n",
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
39 BUF(0), BUF(1), BUF(2), BUF(3),
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
40 BUF(4), BUF(5), BUF(6), BUF(7),
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
41 BUF(8), BUF(9), BUF(10), BUF(11),
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
42 BUF(12), BUF(13), BUF(14), BUF(15));
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
43 ADVANCE(buf, len, 16);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
44
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
45 } else if(len == 2) {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
46 g_string_append_printf(str, FRMT "\n", BUF(0), BUF(1));
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
47 ADVANCE(buf, len, 2);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
48
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
49 } else if(len > 1) {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
50 g_string_append_printf(str, FRMT, BUF(0), BUF(1));
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
51 ADVANCE(buf, len, 2);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
52
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
53 } else {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
54 g_string_append_printf(str, FRM "\n", BUF(0));
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
55 ADVANCE(buf, len, 1);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
56 }
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
57 }
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
58 }
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
59 #endif
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
60
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
61
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
62 void pretty_print(const char *buf, gsize len) {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
63 #ifdef DEBUG
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
64 GString *str;
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
65
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
66 if(! len) return;
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
67
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
68 g_return_if_fail(buf != NULL);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
69
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
70 str = g_string_new(NULL);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
71 t_pretty_print(str, buf, len);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
72 g_debug(str->str);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
73 g_string_free(str, TRUE);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
74 #endif
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
75 ;
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
76 }
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
77
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
78
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
79 void pretty_print_opaque(struct mwOpaque *o) {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
80 if(! o) return;
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
81 pretty_print(o->data, o->len);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
82 }
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
83
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
84
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
85 void mw_debug_mailme_v(struct mwOpaque *block,
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
86 const char *info, va_list args) {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
87 /*
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
88 MW_MAILME_MESSAGE
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
89 begin here
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
90 info % args
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
91 pretty_print
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
92 end here
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
93 */
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
94
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
95 #ifdef DEBUG
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
96 GString *str;
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
97 char *txt;
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
98
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
99 str = g_string_new(MW_MAILME_MESSAGE "\n"
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
100 " Please send mail to: " MW_MAILME_ADDRESS "\n"
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
101 MW_MAILME_CUT_START "\n");
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
102
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
103 txt = g_strdup_vprintf(info, args);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
104 g_string_append(str, txt);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
105 g_free(txt);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
106
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
107 g_string_append(str, "\n");
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
108
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
109 if(block) {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
110 t_pretty_print(str, block->data, block->len);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
111 }
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
112
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
113 g_string_append(str, MW_MAILME_CUT_STOP);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
114
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
115 g_debug(str->str);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
116 g_string_free(str, TRUE);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
117 #endif
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
118 ;
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
119 }
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
120
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
121
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
122 void mw_debug_mailme(struct mwOpaque *block,
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
123 const char *info, ...) {
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
124 va_list args;
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
125 va_start(args, info);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
126 mw_debug_mailme_v(block, info, args);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
127 va_end(args);
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
128 }
3ef77720e577 [gaim-migrate @ 12790]
Christopher O'Brien <siege@pidgin.im>
parents:
diff changeset
129