Mercurial > pidgin
comparison libpurple/protocols/qq/packet_parse.c @ 24088:147ada94a1d8
2008.08.16 - ccpaging <ecc_hy(at)hotmail.com>
* Rename group to room. If you used pidginqq before, this may create a new room with same title, you may
delete old one
* Replace purple_debug with purple_debug_info, purple_debug_warning, purple_debug_error
* Add server notice and server new, and two options to turn on/off
* Minor modify for reducing transaction's debug infor
* Minor modifies for system notice and QQ news.
* Add 4 new strings need translate compare with p10.
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Thu, 11 Sep 2008 13:25:07 +0000 |
parents | 1c50f12b1c52 |
children | 25f62d21b3f8 |
comparison
equal
deleted
inserted
replaced
24087:40a4e02027f4 | 24088:147ada94a1d8 |
---|---|
44 { | 44 { |
45 guint8 b_dest; | 45 guint8 b_dest; |
46 memcpy(&b_dest, buf, sizeof(b_dest)); | 46 memcpy(&b_dest, buf, sizeof(b_dest)); |
47 *b = b_dest; | 47 *b = b_dest; |
48 #ifdef PARSER_DEBUG | 48 #ifdef PARSER_DEBUG |
49 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get8] buf %p\n", (void *)buf); | 49 purple_debug_info("QQ", "[DBG][get8] buf %p\n", (void *)buf); |
50 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get8] b_dest 0x%2x, *b 0x%02x\n", b_dest, *b); | 50 purple_debug_info("QQ", "[DBG][get8] b_dest 0x%2x, *b 0x%02x\n", b_dest, *b); |
51 #endif | 51 #endif |
52 return sizeof(b_dest); | 52 return sizeof(b_dest); |
53 } | 53 } |
54 | 54 |
55 | 55 |
59 { | 59 { |
60 guint16 w_dest; | 60 guint16 w_dest; |
61 memcpy(&w_dest, buf, sizeof(w_dest)); | 61 memcpy(&w_dest, buf, sizeof(w_dest)); |
62 *w = g_ntohs(w_dest); | 62 *w = g_ntohs(w_dest); |
63 #ifdef PARSER_DEBUG | 63 #ifdef PARSER_DEBUG |
64 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get16] buf %p\n", (void *)buf); | 64 purple_debug_info("QQ", "[DBG][get16] buf %p\n", (void *)buf); |
65 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get16] w_dest 0x%04x, *w 0x%04x\n", w_dest, *w); | 65 purple_debug_info("QQ", "[DBG][get16] w_dest 0x%04x, *w 0x%04x\n", w_dest, *w); |
66 #endif | 66 #endif |
67 return sizeof(w_dest); | 67 return sizeof(w_dest); |
68 } | 68 } |
69 | 69 |
70 /* read four bytes as "guint32" from buf, | 70 /* read four bytes as "guint32" from buf, |
73 { | 73 { |
74 guint32 dw_dest; | 74 guint32 dw_dest; |
75 memcpy(&dw_dest, buf, sizeof(dw_dest)); | 75 memcpy(&dw_dest, buf, sizeof(dw_dest)); |
76 *dw = g_ntohl(dw_dest); | 76 *dw = g_ntohl(dw_dest); |
77 #ifdef PARSER_DEBUG | 77 #ifdef PARSER_DEBUG |
78 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get32] buf %p\n", (void *)buf); | 78 purple_debug_info("QQ", "[DBG][get32] buf %p\n", (void *)buf); |
79 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get32] dw_dest 0x%08x, *dw 0x%08x\n", dw_dest, *dw); | 79 purple_debug_info("QQ", "[DBG][get32] dw_dest 0x%08x, *dw 0x%08x\n", dw_dest, *dw); |
80 #endif | 80 #endif |
81 return sizeof(dw_dest); | 81 return sizeof(dw_dest); |
82 } | 82 } |
83 | 83 |
84 gint qq_getIP(struct in_addr *ip, guint8 *buf) | 84 gint qq_getIP(struct in_addr *ip, guint8 *buf) |
91 * return the number of bytes read if succeeds, otherwise return -1 */ | 91 * return the number of bytes read if succeeds, otherwise return -1 */ |
92 gint qq_getdata(guint8 *data, gint datalen, guint8 *buf) | 92 gint qq_getdata(guint8 *data, gint datalen, guint8 *buf) |
93 { | 93 { |
94 memcpy(data, buf, datalen); | 94 memcpy(data, buf, datalen); |
95 #ifdef PARSER_DEBUG | 95 #ifdef PARSER_DEBUG |
96 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][getdata] buf %p\n", (void *)buf); | 96 purple_debug_info("QQ", "[DBG][getdata] buf %p\n", (void *)buf); |
97 #endif | 97 #endif |
98 return datalen; | 98 return datalen; |
99 } | 99 } |
100 | 100 |
101 | 101 |
105 gint qq_getime(time_t *t, guint8 *buf) | 105 gint qq_getime(time_t *t, guint8 *buf) |
106 { | 106 { |
107 guint32 dw_dest; | 107 guint32 dw_dest; |
108 memcpy(&dw_dest, buf, sizeof(dw_dest)); | 108 memcpy(&dw_dest, buf, sizeof(dw_dest)); |
109 #ifdef PARSER_DEBUG | 109 #ifdef PARSER_DEBUG |
110 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][getime] buf %p\n", (void *)buf); | 110 purple_debug_info("QQ", "[DBG][getime] buf %p\n", (void *)buf); |
111 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][getime] dw_dest before 0x%08x\n", dw_dest); | 111 purple_debug_info("QQ", "[DBG][getime] dw_dest before 0x%08x\n", dw_dest); |
112 #endif | 112 #endif |
113 dw_dest = g_ntohl(dw_dest); | 113 dw_dest = g_ntohl(dw_dest); |
114 #ifdef PARSER_DEBUG | 114 #ifdef PARSER_DEBUG |
115 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][getime] dw_dest after 0x%08x\n", dw_dest); | 115 purple_debug_info("QQ", "[DBG][getime] dw_dest after 0x%08x\n", dw_dest); |
116 #endif | 116 #endif |
117 memcpy(t, &dw_dest, sizeof(dw_dest)); | 117 memcpy(t, &dw_dest, sizeof(dw_dest)); |
118 return sizeof(dw_dest); | 118 return sizeof(dw_dest); |
119 } | 119 } |
120 | 120 |
123 * return the number of bytes packed, otherwise return -1 */ | 123 * return the number of bytes packed, otherwise return -1 */ |
124 gint qq_put8(guint8 *buf, guint8 b) | 124 gint qq_put8(guint8 *buf, guint8 b) |
125 { | 125 { |
126 memcpy(buf, &b, sizeof(b)); | 126 memcpy(buf, &b, sizeof(b)); |
127 #ifdef PARSER_DEBUG | 127 #ifdef PARSER_DEBUG |
128 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put8] buf %p\n", (void *)buf); | 128 purple_debug_info("QQ", "[DBG][put8] buf %p\n", (void *)buf); |
129 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put8] b 0x%02x\n", b); | 129 purple_debug_info("QQ", "[DBG][put8] b 0x%02x\n", b); |
130 #endif | 130 #endif |
131 return sizeof(b); | 131 return sizeof(b); |
132 } | 132 } |
133 | 133 |
134 | 134 |
137 gint qq_put16(guint8 *buf, guint16 w) | 137 gint qq_put16(guint8 *buf, guint16 w) |
138 { | 138 { |
139 guint16 w_porter; | 139 guint16 w_porter; |
140 w_porter = g_htons(w); | 140 w_porter = g_htons(w); |
141 #ifdef PARSER_DEBUG | 141 #ifdef PARSER_DEBUG |
142 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put16] buf %p\n", (void *)buf); | 142 purple_debug_info("QQ", "[DBG][put16] buf %p\n", (void *)buf); |
143 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put16] w 0x%04x, w_porter 0x%04x\n", w, w_porter); | 143 purple_debug_info("QQ", "[DBG][put16] w 0x%04x, w_porter 0x%04x\n", w, w_porter); |
144 #endif | 144 #endif |
145 memcpy(buf, &w_porter, sizeof(w_porter)); | 145 memcpy(buf, &w_porter, sizeof(w_porter)); |
146 return sizeof(w_porter); | 146 return sizeof(w_porter); |
147 } | 147 } |
148 | 148 |
152 gint qq_put32(guint8 *buf, guint32 dw) | 152 gint qq_put32(guint8 *buf, guint32 dw) |
153 { | 153 { |
154 guint32 dw_porter; | 154 guint32 dw_porter; |
155 dw_porter = g_htonl(dw); | 155 dw_porter = g_htonl(dw); |
156 #ifdef PARSER_DEBUG | 156 #ifdef PARSER_DEBUG |
157 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put32] buf %p\n", (void *)buf); | 157 purple_debug_info("QQ", "[DBG][put32] buf %p\n", (void *)buf); |
158 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put32] dw 0x%08x, dw_porter 0x%08x\n", dw, dw_porter); | 158 purple_debug_info("QQ", "[DBG][put32] dw 0x%08x, dw_porter 0x%08x\n", dw, dw_porter); |
159 #endif | 159 #endif |
160 memcpy(buf, &dw_porter, sizeof(dw_porter)); | 160 memcpy(buf, &dw_porter, sizeof(dw_porter)); |
161 return sizeof(dw_porter); | 161 return sizeof(dw_porter); |
162 } | 162 } |
163 | 163 |
171 * return the number of bytes packed, otherwise return -1 */ | 171 * return the number of bytes packed, otherwise return -1 */ |
172 gint qq_putdata(guint8 *buf, const guint8 *data, const int datalen) | 172 gint qq_putdata(guint8 *buf, const guint8 *data, const int datalen) |
173 { | 173 { |
174 memcpy(buf, data, datalen); | 174 memcpy(buf, data, datalen); |
175 #ifdef PARSER_DEBUG | 175 #ifdef PARSER_DEBUG |
176 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][putdata] buf %p\n", (void *)buf); | 176 purple_debug_info("QQ", "[DBG][putdata] buf %p\n", (void *)buf); |
177 #endif | 177 #endif |
178 return datalen; | 178 return datalen; |
179 } | 179 } |