annotate libpurple/protocols/qq/packet_parse.c @ 23619:d70aad03b491

Properly escape text when sending MSN pages.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Wed, 23 Jul 2008 05:36:12 +0000
parents 55f986ccbb6a
children 1c50f12b1c52
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file packet_parse.c
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
4 * purple
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15823
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15374
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19680
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18141
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include <string.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "packet_parse.h"
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
28 #include "debug.h"
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
29
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
30
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
31 /*------------------------------------------------PUT------------------------------------------------*/
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
32
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
33 /* note:
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
34 * 1, in these functions, 'b' stands for byte, 'w' stands for word, 'dw' stands for double word.
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
35 * 2, we use '*cursor' and 'buf' as two addresses to calculate the length.
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
36 * 3, change '0' to '1', if want to get more info about the packet parsing. */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
37
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
38 #if 0
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
39 #define PARSER_DEBUG
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
40 #endif
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 /* read one byte from buf,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 * return the number of bytes read if succeeds, otherwise return -1 */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
44 gint qq_get8(guint8 *b, guint8 *buf)
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
45 {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
46 guint8 b_dest;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
47 memcpy(&b_dest, buf, sizeof(b_dest));
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
48 *b = b_dest;
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
49 #ifdef PARSER_DEBUG
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
50 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get8] buf %p\n", (void *)buf);
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
51 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get8] b_dest 0x%2x, *b 0x%02x\n", b_dest, *b);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
52 #endif
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
53 return sizeof(b_dest);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
54 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
55
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 /* read two bytes as "guint16" from buf,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 * return the number of bytes read if succeeds, otherwise return -1 */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
59 gint qq_get16(guint16 *w, guint8 *buf)
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
60 {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
61 guint16 w_dest;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
62 memcpy(&w_dest, buf, sizeof(w_dest));
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
63 *w = g_ntohs(w_dest);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
64 #ifdef PARSER_DEBUG
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
65 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get16] buf %p\n", (void *)buf);
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
66 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get16] w_dest 0x%04x, *w 0x%04x\n", w_dest, *w);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
67 #endif
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
68 return sizeof(w_dest);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
69 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
70
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 /* read four bytes as "guint32" from buf,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 * return the number of bytes read if succeeds, otherwise return -1 */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
74 gint qq_get32(guint32 *dw, guint8 *buf)
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
75 {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
76 guint32 dw_dest;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
77 memcpy(&dw_dest, buf, sizeof(dw_dest));
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
78 *dw = g_ntohl(dw_dest);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
79 #ifdef PARSER_DEBUG
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
80 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get32] buf %p\n", (void *)buf);
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
81 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][get32] dw_dest 0x%08x, *dw 0x%08x\n", dw_dest, *dw);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
82 #endif
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
83 return sizeof(dw_dest);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
84 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
85
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
86
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
87 /* read datalen bytes from buf,
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
88 * return the number of bytes read if succeeds, otherwise return -1 */
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
89 gint qq_getdata(guint8 *data, gint datalen, guint8 *buf)
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
90 {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
91 memcpy(data, buf, datalen);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
92 #ifdef PARSER_DEBUG
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
93 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][getdata] buf %p\n", (void *)buf);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
94 #endif
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
95 return datalen;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
96 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
97
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98
18141
833f7cbe4f12 A patch from o_sukhodolsky to fix a compiler warning in the QQ code. I've
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
99 /* read four bytes as "time_t" from buf,
833f7cbe4f12 A patch from o_sukhodolsky to fix a compiler warning in the QQ code. I've
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
100 * return the number of bytes read if succeeds, otherwise return -1
833f7cbe4f12 A patch from o_sukhodolsky to fix a compiler warning in the QQ code. I've
Richard Laager <rlaager@wiktel.com>
parents: 15823
diff changeset
101 * This function is a wrapper around read_packet_dw() to avoid casting. */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
102 gint qq_getime(time_t *t, guint8 *buf)
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
103 {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
104 guint32 dw_dest;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
105 memcpy(&dw_dest, buf, sizeof(dw_dest));
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
106 #ifdef PARSER_DEBUG
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
107 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][getime] buf %p\n", (void *)buf);
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
108 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][getime] dw_dest before 0x%08x\n", dw_dest);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
109 #endif
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
110 dw_dest = g_ntohl(dw_dest);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
111 #ifdef PARSER_DEBUG
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
112 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][getime] dw_dest after 0x%08x\n", dw_dest);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
113 #endif
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
114 memcpy(t, &dw_dest, sizeof(dw_dest));
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
115 return sizeof(dw_dest);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
118 /*------------------------------------------------PUT------------------------------------------------*/
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 /* pack one byte into buf
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 * return the number of bytes packed, otherwise return -1 */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
121 gint qq_put8(guint8 *buf, guint8 b)
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
122 {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
123 memcpy(buf, &b, sizeof(b));
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
124 #ifdef PARSER_DEBUG
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
125 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put8] buf %p\n", (void *)buf);
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
126 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put8] b 0x%02x\n", b);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
127 #endif
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
128 return sizeof(b);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
129 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
130
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 /* pack two bytes as "guint16" into buf
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 * return the number of bytes packed, otherwise return -1 */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
134 gint qq_put16(guint8 *buf, guint16 w)
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
135 {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
136 guint16 w_porter;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
137 w_porter = g_htons(w);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
138 #ifdef PARSER_DEBUG
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
139 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put16] buf %p\n", (void *)buf);
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
140 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put16] w 0x%04x, w_porter 0x%04x\n", w, w_porter);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
141 #endif
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
142 memcpy(buf, &w_porter, sizeof(w_porter));
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
143 return sizeof(w_porter);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
144 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
145
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 /* pack four bytes as "guint32" into buf
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 * return the number of bytes packed, otherwise return -1 */
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
149 gint qq_put32(guint8 *buf, guint32 dw)
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
150 {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
151 guint32 dw_porter;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
152 dw_porter = g_htonl(dw);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
153 #ifdef PARSER_DEBUG
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
154 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put32] buf %p\n", (void *)buf);
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
155 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][put32] dw 0x%08x, dw_porter 0x%08x\n", dw, dw_porter);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
156 #endif
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
157 memcpy(buf, &dw_porter, sizeof(dw_porter));
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
158 return sizeof(dw_porter);
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
159 }
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
160
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 /* pack datalen bytes into buf
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 * return the number of bytes packed, otherwise return -1 */
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
164 gint qq_putdata(guint8 *buf, const guint8 *data, const int datalen)
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
165 {
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
166 memcpy(buf, data, datalen);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
167 #ifdef PARSER_DEBUG
23053
55f986ccbb6a patch-05-reconnect-and-code-cleanup
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23052
diff changeset
168 purple_debug(PURPLE_DEBUG_INFO, "QQ", "[DBG][putdata] buf %p\n", (void *)buf);
23052
51dbe83ebbd3 patch-04-tcp-pending
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23051
diff changeset
169 #endif
23050
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
170 return datalen;
9a5d140400f1 patch-02-fix-multiarch
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19680
diff changeset
171 }