Mercurial > pidgin
annotate libpurple/protocols/msn/tlv.c @ 31549:506b77a27a53
This should fix TLV in from and out of the wire.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Thu, 05 May 2011 21:49:21 +0000 |
parents | b8e076d51817 |
children | dfc2a8e98430 |
rev | line source |
---|---|
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
1 /** |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
2 * @file tlv.c MSN TLV functions |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
3 * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
4 * purple |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
5 * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
6 * Purple is the legal property of its developers, whose names are too numerous |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
7 * to list here. Please refer to the COPYRIGHT file distributed with this |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
8 * source distribution. |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
9 * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
10 * This program is free software; you can redistribute it and/or modify |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
13 * (at your option) any later version. |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
14 * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
15 * This program is distributed in the hope that it will be useful, |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
18 * GNU General Public License for more details. |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
19 * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
20 * You should have received a copy of the GNU General Public License |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
21 * along with this program; if not, write to the Free Software |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
23 */ |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
24 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
25 #include "tlv.h" |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
26 #include "msnutils.h" |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
27 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
28 static msn_tlv_t * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
29 createtlv(guint8 type, guint8 length, guint8 *value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
30 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
31 msn_tlv_t *ret; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
32 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
33 ret = g_new(msn_tlv_t, 1); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
34 ret->type = type; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
35 ret->length = length; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
36 ret->value = value; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
37 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
38 return ret; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
39 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
40 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
41 static void |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
42 freetlv(msn_tlv_t *oldtlv) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
43 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
44 g_free(oldtlv->value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
45 g_free(oldtlv); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
46 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
47 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
48 GSList * |
31322
b8e076d51817
Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
49 msn_tlvlist_read(const char *bs, size_t bs_len) |
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
50 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
51 GSList *list = NULL; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
52 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
53 while (bs_len > 0) { |
31549
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
54 guint8 type, length; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
55 msn_tlv_t *tlv; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
56 |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
57 if (bs_len < 2) { |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
58 msn_tlvlist_free(list); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
59 return NULL; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
60 } |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
61 |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
62 type = msn_pop8(bs); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
63 length = msn_pop8(bs); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
64 bs_len -= 2; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
65 |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
66 if (length > bs_len) { |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
67 msn_tlvlist_free(list); |
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
68 return NULL; |
31549
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
69 } |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
70 |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
71 tlv = createtlv(type, length, NULL); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
72 if (length > 0) { |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
73 tlv->value = g_memdup(bs, length); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
74 if (!tlv->value) { |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
75 freetlv(tlv); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
76 msn_tlvlist_free(list); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
77 return NULL; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
78 } |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
79 } |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
80 |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
81 bs_len -= length; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
82 bs += length; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
83 |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
84 list = g_slist_prepend(list, tlv); |
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
85 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
86 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
87 return g_slist_reverse(list); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
88 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
89 |
31549
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
90 GSList * |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
91 msn_tlvlist_copy(GSList *orig) |
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
92 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
93 GSList *new = NULL; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
94 msn_tlv_t *tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
95 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
96 while (orig != NULL) { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
97 tlv = orig->data; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
98 msn_tlvlist_add_raw(&new, tlv->type, tlv->length, (const char *)tlv->value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
99 orig = orig->next; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
100 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
101 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
102 return new; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
103 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
104 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
105 gboolean |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
106 msn_tlvlist_equal(GSList *one, GSList *two) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
107 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
108 while (one && two) { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
109 msn_tlv_t *a = one->data; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
110 msn_tlv_t *b = two->data; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
111 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
112 if (a->type != b->type) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
113 return FALSE; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
114 else if (a->length != b->length) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
115 return FALSE; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
116 else if (!a->value && b->value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
117 return FALSE; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
118 else if (a->value && !b->value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
119 return FALSE; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
120 else if (a->value && b->value && memcmp(a->value, b->value, a->length) != 0) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
121 return FALSE; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
122 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
123 one = one->next; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
124 two = two->next; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
125 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
126 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
127 return one == two; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
128 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
129 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
130 void |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
131 msn_tlvlist_free(GSList *list) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
132 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
133 while (list != NULL) { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
134 freetlv(list->data); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
135 list = g_slist_delete_link(list, list); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
136 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
137 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
138 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
139 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
140 msn_tlvlist_count(GSList *list) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
141 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
142 return g_slist_length(list); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
143 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
144 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
145 size_t |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
146 msn_tlvlist_size(GSList *list) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
147 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
148 int size; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
149 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
150 if (list == NULL) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
151 return 0; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
152 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
153 for (size = 0; list; list = list->next) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
154 size += (2 + ((msn_tlv_t *)list->data)->length); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
155 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
156 return size; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
157 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
158 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
159 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
160 msn_tlvlist_add_raw(GSList **list, const guint16 type, const guint16 length, const char *value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
161 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
162 msn_tlv_t *tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
163 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
164 if (list == NULL) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
165 return 0; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
166 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
167 tlv = createtlv(type, length, NULL); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
168 if (length > 0) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
169 tlv->value = g_memdup(value, length); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
170 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
171 *list = g_slist_append(*list, tlv); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
172 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
173 return tlv->length; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
174 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
175 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
176 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
177 msn_tlvlist_add_8(GSList **list, const guint16 type, const guint8 value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
178 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
179 char v8[1]; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
180 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
181 msn_write8(v8, value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
182 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
183 return msn_tlvlist_add_raw(list, type, 1, v8); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
184 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
185 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
186 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
187 msn_tlvlist_add_16(GSList **list, const guint16 type, const guint16 value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
188 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
189 char v16[2]; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
190 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
191 msn_write16be(v16, value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
192 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
193 return msn_tlvlist_add_raw(list, type, 2, v16); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
194 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
195 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
196 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
197 msn_tlvlist_add_32(GSList **list, const guint16 type, const guint32 value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
198 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
199 char v32[4]; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
200 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
201 msn_write32be(v32, value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
202 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
203 return msn_tlvlist_add_raw(list, type, 4, v32); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
204 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
205 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
206 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
207 msn_tlvlist_add_str(GSList **list, const guint16 type, const char *value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
208 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
209 return msn_tlvlist_add_raw(list, type, strlen(value), value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
210 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
211 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
212 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
213 msn_tlvlist_add_empty(GSList **list, const guint16 type) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
214 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
215 return msn_tlvlist_add_raw(list, type, 0, NULL); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
216 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
217 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
218 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
219 msn_tlvlist_replace_raw(GSList **list, const guint16 type, const guint16 length, const char *value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
220 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
221 GSList *cur; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
222 msn_tlv_t *tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
223 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
224 if (list == NULL) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
225 return 0; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
226 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
227 for (cur = *list; cur != NULL; cur = cur->next) { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
228 tlv = cur->data; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
229 if (tlv->type == type) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
230 break; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
231 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
232 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
233 if (cur == NULL) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
234 /* TLV does not exist, so add a new one */ |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
235 return msn_tlvlist_add_raw(list, type, length, value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
236 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
237 g_free(tlv->value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
238 tlv->length = length; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
239 if (length > 0) { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
240 tlv->value = g_memdup(value, length); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
241 } else |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
242 tlv->value = NULL; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
243 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
244 return length; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
245 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
246 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
247 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
248 msn_tlvlist_replace_str(GSList **list, const guint16 type, const char *str) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
249 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
250 return msn_tlvlist_replace_raw(list, type, strlen(str), str); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
251 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
252 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
253 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
254 msn_tlvlist_replace_empty(GSList **list, const guint16 type) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
255 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
256 return msn_tlvlist_replace_raw(list, type, 0, NULL); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
257 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
258 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
259 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
260 msn_tlvlist_replace_8(GSList **list, const guint16 type, const guint8 value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
261 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
262 char v8[1]; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
263 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
264 msn_write8(v8, value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
265 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
266 return msn_tlvlist_replace_raw(list, type, 1, v8); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
267 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
268 |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31047
diff
changeset
|
269 int |
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
270 msn_tlvlist_replace_32(GSList **list, const guint16 type, const guint32 value) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
271 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
272 char v32[4]; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
273 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
274 msn_write32be(v32, value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
275 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
276 return msn_tlvlist_replace_raw(list, type, 4, v32); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
277 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
278 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
279 void |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
280 msn_tlvlist_remove(GSList **list, const guint16 type) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
281 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
282 GSList *cur, *next; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
283 msn_tlv_t *tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
284 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
285 if (list == NULL || *list == NULL) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
286 return; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
287 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
288 cur = *list; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
289 while (cur != NULL) { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
290 tlv = cur->data; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
291 next = cur->next; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
292 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
293 if (tlv->type == type) { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
294 /* Delete this TLV */ |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
295 *list = g_slist_delete_link(*list, cur); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
296 g_free(tlv->value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
297 g_free(tlv); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
298 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
299 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
300 cur = next; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
301 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
302 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
303 |
31549
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
304 char * |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
305 msn_tlvlist_write(GSList *list, size_t *out_len) |
31322
b8e076d51817
Add P2Pv2 parsing and saving functions. Tested by compiling them!
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31086
diff
changeset
|
306 { |
31549
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
307 char *buf; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
308 char *tmp; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
309 size_t bytes_left; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
310 size_t total_len; |
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
311 |
31549
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
312 tmp = buf = g_malloc(256); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
313 bytes_left = total_len = 256; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
314 |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
315 for (; list; list = g_slist_next(list)) { |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
316 msn_tlv_t *tlv = (msn_tlv_t *)list->data; |
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
317 |
31549
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
318 if (G_UNLIKELY(tlv->length + 2 > bytes_left)) { |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
319 buf = g_realloc(buf, total_len + 256); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
320 bytes_left += 256; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
321 total_len += 256; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
322 tmp = buf + (total_len - bytes_left); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
323 } |
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
324 |
31549
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
325 msn_push8(tmp, tlv->type); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
326 msn_push8(tmp, tlv->length); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
327 memcpy(tmp, tlv->value, tlv->length); |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
328 tmp += tlv->length; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
329 |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
330 bytes_left -= (tlv->length + 2); |
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
331 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
332 |
31549
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
333 *out_len = total_len - bytes_left; |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
334 |
506b77a27a53
This should fix TLV in from and out of the wire.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31322
diff
changeset
|
335 return buf; |
31047
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
336 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
337 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
338 msn_tlv_t * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
339 msn_tlv_gettlv(GSList *list, const guint16 type, const int nth) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
340 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
341 msn_tlv_t *tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
342 int i; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
343 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
344 for (i = 0; list != NULL; list = list->next) { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
345 tlv = list->data; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
346 if (tlv->type == type) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
347 i++; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
348 if (i >= nth) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
349 return tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
350 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
351 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
352 return NULL; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
353 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
354 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
355 int |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
356 msn_tlv_getlength(GSList *list, const guint16 type, const int nth) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
357 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
358 msn_tlv_t *tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
359 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
360 tlv = msn_tlv_gettlv(list, type, nth); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
361 if (tlv == NULL) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
362 return -1; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
363 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
364 return tlv->length; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
365 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
366 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
367 char * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
368 msn_tlv_getvalue_as_string(msn_tlv_t *tlv) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
369 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
370 char *ret; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
371 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
372 ret = g_malloc(tlv->length + 1); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
373 memcpy(ret, tlv->value, tlv->length); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
374 ret[tlv->length] = '\0'; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
375 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
376 return ret; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
377 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
378 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
379 char * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
380 msn_tlv_getstr(GSList *list, const guint16 type, const int nth) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
381 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
382 msn_tlv_t *tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
383 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
384 tlv = msn_tlv_gettlv(list, type, nth); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
385 if (tlv == NULL) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
386 return NULL; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
387 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
388 return msn_tlv_getvalue_as_string(tlv); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
389 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
390 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
391 guint8 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
392 msn_tlv_get8(GSList *list, const guint16 type, const int nth) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
393 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
394 msn_tlv_t *tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
395 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
396 tlv = msn_tlv_gettlv(list, type, nth); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
397 if (tlv == NULL) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
398 return 0; /* erm */ |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
399 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
400 return msn_read8((const char *)tlv->value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
401 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
402 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
403 guint16 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
404 msn_tlv_get16(GSList *list, const guint16 type, const int nth) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
405 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
406 msn_tlv_t *tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
407 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
408 tlv = msn_tlv_gettlv(list, type, nth); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
409 if (tlv == NULL) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
410 return 0; /* erm */ |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
411 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
412 return msn_read16be((const char *)tlv->value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
413 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
414 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
415 guint32 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
416 msn_tlv_get32(GSList *list, const guint16 type, const int nth) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
417 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
418 msn_tlv_t *tlv; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
419 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
420 tlv = msn_tlv_gettlv(list, type, nth); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
421 if (tlv == NULL) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
422 return 0; /* erm */ |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
423 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
424 return msn_read32be((const char *)tlv->value); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
425 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
426 |