annotate libpurple/protocols/oscar/bstream.c @ 30631:b00967045cc2

Ouch, I accidentally removed too much code in b367bdaac1f79166db0e9478ae30e2a7628f6848. Fixes #12768.
author ivan.komarov@soc.pidgin.im
date Sun, 24 Oct 2010 18:57:21 +0000
parents 9d028dbd76f4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
2 * Purple's oscar protocol plugin
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * This file is the legal property of its developers.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Please see the AUTHORS file distributed alongside this file.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * This library is free software; you can redistribute it and/or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * version 2 of the License, or (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This library 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
12 * 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
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * Lesser General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * License along with this library; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 17191
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * This file contains all functions needed to use bstreams.
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 "oscar.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
30417
9d028dbd76f4 Change the "length of bstream" data type to be a gsize, since it represents
Mark Doliner <mark@kingant.net>
parents: 30394
diff changeset
27 int byte_stream_new(ByteStream *bs, size_t len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 if (bs == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 return -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 return byte_stream_init(bs, g_malloc(len), len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34
30417
9d028dbd76f4 Change the "length of bstream" data type to be a gsize, since it represents
Mark Doliner <mark@kingant.net>
parents: 30394
diff changeset
35 int byte_stream_init(ByteStream *bs, guint8 *data, size_t len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 if (bs == NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 return -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 bs->data = data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 bs->len = len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 bs->offset = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46
22717
979a81468e19 All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evan.s@dreskin.net>
parents: 19681
diff changeset
47 void byte_stream_destroy(ByteStream *bs)
979a81468e19 All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evan.s@dreskin.net>
parents: 19681
diff changeset
48 {
979a81468e19 All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evan.s@dreskin.net>
parents: 19681
diff changeset
49 g_free(bs->data);
979a81468e19 All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evan.s@dreskin.net>
parents: 19681
diff changeset
50 }
979a81468e19 All SNACs on FLAP channel 2 except in the auth family are now sent through
Evan Schoenberg <evan.s@dreskin.net>
parents: 19681
diff changeset
51
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
52 int byte_stream_bytes_left(ByteStream *bs)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 return bs->len - bs->offset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 }
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 int byte_stream_curpos(ByteStream *bs)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 return bs->offset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61
30417
9d028dbd76f4 Change the "length of bstream" data type to be a gsize, since it represents
Mark Doliner <mark@kingant.net>
parents: 30394
diff changeset
62 int byte_stream_setpos(ByteStream *bs, size_t off)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
64 g_return_val_if_fail(off <= bs->len, -1);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 bs->offset = off;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 return off;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 void byte_stream_rewind(ByteStream *bs)
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 byte_stream_setpos(bs, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 * N can be negative, which can be used for going backwards
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
77 * in a bstream.
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 int byte_stream_advance(ByteStream *bs, int n)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 {
30394
ed520e6e972b Renames and cleanups.
ivan.komarov@soc.pidgin.im
parents: 30393
diff changeset
81 g_return_val_if_fail(byte_stream_curpos(bs) + n >= 0, 0);
ed520e6e972b Renames and cleanups.
ivan.komarov@soc.pidgin.im
parents: 30393
diff changeset
82 g_return_val_if_fail(n <= byte_stream_bytes_left(bs), 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 bs->offset += n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 return n;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 guint8 byte_stream_get8(ByteStream *bs)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
90 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 1, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 bs->offset++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 return aimutil_get8(bs->data + bs->offset - 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 guint16 byte_stream_get16(ByteStream *bs)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
98 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 2, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 bs->offset += 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 return aimutil_get16(bs->data + bs->offset - 2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 guint32 byte_stream_get32(ByteStream *bs)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
106 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 4, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 bs->offset += 4;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 return aimutil_get32(bs->data + bs->offset - 4);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 guint8 byte_stream_getle8(ByteStream *bs)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
114 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 1, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 bs->offset++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 return aimutil_getle8(bs->data + bs->offset - 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 guint16 byte_stream_getle16(ByteStream *bs)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
122 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 2, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 bs->offset += 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 return aimutil_getle16(bs->data + bs->offset - 2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 guint32 byte_stream_getle32(ByteStream *bs)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
130 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 4, 0);
15373
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 bs->offset += 4;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 return aimutil_getle32(bs->data + bs->offset - 4);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
30417
9d028dbd76f4 Change the "length of bstream" data type to be a gsize, since it represents
Mark Doliner <mark@kingant.net>
parents: 30394
diff changeset
136 static void byte_stream_getrawbuf_nocheck(ByteStream *bs, guint8 *buf, size_t len)
27194
7f43d6779764 Apply [9bac0a540156fb1848eedd61c8630737dee752c7] here as well. I should
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25975
diff changeset
137 {
7f43d6779764 Apply [9bac0a540156fb1848eedd61c8630737dee752c7] here as well. I should
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25975
diff changeset
138 memcpy(buf, bs->data + bs->offset, len);
7f43d6779764 Apply [9bac0a540156fb1848eedd61c8630737dee752c7] here as well. I should
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25975
diff changeset
139 bs->offset += len;
7f43d6779764 Apply [9bac0a540156fb1848eedd61c8630737dee752c7] here as well. I should
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25975
diff changeset
140 }
7f43d6779764 Apply [9bac0a540156fb1848eedd61c8630737dee752c7] here as well. I should
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25975
diff changeset
141
30417
9d028dbd76f4 Change the "length of bstream" data type to be a gsize, since it represents
Mark Doliner <mark@kingant.net>
parents: 30394
diff changeset
142 int byte_stream_getrawbuf(ByteStream *bs, guint8 *buf, size_t len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
144 g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
27194
7f43d6779764 Apply [9bac0a540156fb1848eedd61c8630737dee752c7] here as well. I should
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25975
diff changeset
146 byte_stream_getrawbuf_nocheck(bs, buf, len);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 return len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149
30417
9d028dbd76f4 Change the "length of bstream" data type to be a gsize, since it represents
Mark Doliner <mark@kingant.net>
parents: 30394
diff changeset
150 guint8 *byte_stream_getraw(ByteStream *bs, size_t len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 guint8 *ob;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
154 g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, NULL);
27194
7f43d6779764 Apply [9bac0a540156fb1848eedd61c8630737dee752c7] here as well. I should
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25975
diff changeset
155
17191
1927f4ead3ca Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15822
diff changeset
156 ob = g_malloc(len);
27194
7f43d6779764 Apply [9bac0a540156fb1848eedd61c8630737dee752c7] here as well. I should
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25975
diff changeset
157 byte_stream_getrawbuf_nocheck(bs, ob, len);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 return ob;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160
30417
9d028dbd76f4 Change the "length of bstream" data type to be a gsize, since it represents
Mark Doliner <mark@kingant.net>
parents: 30394
diff changeset
161 char *byte_stream_getstr(ByteStream *bs, size_t len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 char *ob;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
165 g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, NULL);
27194
7f43d6779764 Apply [9bac0a540156fb1848eedd61c8630737dee752c7] here as well. I should
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25975
diff changeset
166
17191
1927f4ead3ca Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 15822
diff changeset
167 ob = g_malloc(len + 1);
27194
7f43d6779764 Apply [9bac0a540156fb1848eedd61c8630737dee752c7] here as well. I should
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 25975
diff changeset
168 byte_stream_getrawbuf_nocheck(bs, (guint8 *)ob, len);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 ob[len] = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 return ob;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 int byte_stream_put8(ByteStream *bs, guint8 v)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
175 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 1, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 bs->offset += aimutil_put8(bs->data + bs->offset, v);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 int byte_stream_put16(ByteStream *bs, guint16 v)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
183 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 2, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 bs->offset += aimutil_put16(bs->data + bs->offset, v);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 return 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 int byte_stream_put32(ByteStream *bs, guint32 v)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
191 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 4, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 bs->offset += aimutil_put32(bs->data + bs->offset, v);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 int byte_stream_putle8(ByteStream *bs, guint8 v)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
199 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 1, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 bs->offset += aimutil_putle8(bs->data + bs->offset, v);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 int byte_stream_putle16(ByteStream *bs, guint16 v)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
207 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 2, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 bs->offset += aimutil_putle16(bs->data + bs->offset, v);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 return 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 int byte_stream_putle32(ByteStream *bs, guint32 v)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
215 g_return_val_if_fail(byte_stream_bytes_left(bs) >= 4, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 bs->offset += aimutil_putle32(bs->data + bs->offset, v);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 return 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221
30417
9d028dbd76f4 Change the "length of bstream" data type to be a gsize, since it represents
Mark Doliner <mark@kingant.net>
parents: 30394
diff changeset
222 int byte_stream_putraw(ByteStream *bs, const guint8 *v, size_t len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
224 g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 memcpy(bs->data + bs->offset, v, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 bs->offset += len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 return len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 int byte_stream_putstr(ByteStream *bs, const char *str)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 return byte_stream_putraw(bs, (guint8 *)str, strlen(str));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
30417
9d028dbd76f4 Change the "length of bstream" data type to be a gsize, since it represents
Mark Doliner <mark@kingant.net>
parents: 30394
diff changeset
236 int byte_stream_putbs(ByteStream *bs, ByteStream *srcbs, size_t len)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 {
30393
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
238 g_return_val_if_fail(byte_stream_bytes_left(srcbs) >= len, 0);
bbb27d65681f Bstream cleanups:
ivan.komarov@soc.pidgin.im
parents: 27194
diff changeset
239 g_return_val_if_fail(byte_stream_bytes_left(bs) >= len, 0);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 memcpy(bs->data + bs->offset, srcbs->data + srcbs->offset, len);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 bs->offset += len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 srcbs->offset += len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 return len;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 }
24665
531922f4ea2a Minor cleanup: remove od->sn, since it's the same as PurpleAccount->username
Mark Doliner <mark@kingant.net>
parents: 22717
diff changeset
246
531922f4ea2a Minor cleanup: remove od->sn, since it's the same as PurpleAccount->username
Mark Doliner <mark@kingant.net>
parents: 22717
diff changeset
247 int byte_stream_putuid(ByteStream *bs, OscarData *od)
531922f4ea2a Minor cleanup: remove od->sn, since it's the same as PurpleAccount->username
Mark Doliner <mark@kingant.net>
parents: 22717
diff changeset
248 {
531922f4ea2a Minor cleanup: remove od->sn, since it's the same as PurpleAccount->username
Mark Doliner <mark@kingant.net>
parents: 22717
diff changeset
249 PurpleAccount *account;
531922f4ea2a Minor cleanup: remove od->sn, since it's the same as PurpleAccount->username
Mark Doliner <mark@kingant.net>
parents: 22717
diff changeset
250
531922f4ea2a Minor cleanup: remove od->sn, since it's the same as PurpleAccount->username
Mark Doliner <mark@kingant.net>
parents: 22717
diff changeset
251 account = purple_connection_get_account(od->gc);
531922f4ea2a Minor cleanup: remove od->sn, since it's the same as PurpleAccount->username
Mark Doliner <mark@kingant.net>
parents: 22717
diff changeset
252
531922f4ea2a Minor cleanup: remove od->sn, since it's the same as PurpleAccount->username
Mark Doliner <mark@kingant.net>
parents: 22717
diff changeset
253 return byte_stream_putle32(bs, atoi(purple_account_get_username(account)));
531922f4ea2a Minor cleanup: remove od->sn, since it's the same as PurpleAccount->username
Mark Doliner <mark@kingant.net>
parents: 22717
diff changeset
254 }
25975
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
255
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
256 void byte_stream_put_bart_asset(ByteStream *bs, guint16 type, ByteStream *data)
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
257 {
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
258 byte_stream_put16(bs, type);
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
259
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
260 if (data != NULL && data->len > 0) {
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
261 /* Flags. 0x04 means "this asset has data attached to it" */
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
262 byte_stream_put8(bs, 0x04); /* Flags */
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
263 byte_stream_put8(bs, data->len); /* Length */
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
264 byte_stream_rewind(data);
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
265 byte_stream_putbs(bs, data, data->len); /* Data */
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
266 } else {
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
267 byte_stream_put8(bs, 0x00); /* No flags */
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
268 byte_stream_put8(bs, 0x00); /* Length */
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
269 /* No data */
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
270 }
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
271 }
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
272
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
273 void byte_stream_put_bart_asset_str(ByteStream *bs, guint16 type, const char *datastr)
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
274 {
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
275 ByteStream data;
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
276 size_t len = datastr != NULL ? strlen(datastr) : 0;
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
277
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
278 if (len > 0) {
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
279 byte_stream_new(&data, 2 + len + 2);
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
280 byte_stream_put16(&data, len); /* Length */
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
281 byte_stream_putstr(&data, datastr); /* String */
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
282 byte_stream_put16(&data, 0x0000); /* Unknown */
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
283 byte_stream_put_bart_asset(bs, type, &data);
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
284 byte_stream_destroy(&data);
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
285 } else {
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
286 byte_stream_put_bart_asset(bs, type, NULL);
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
287 }
3f3d21ae1825 Create two helper functions for setting the available message and iTunes
Mark Doliner <mark@kingant.net>
parents: 24665
diff changeset
288 }