Mercurial > pidgin.yaz
annotate libpurple/protocols/msn/tlv.c @ 32007:ea3c7de5a07d
Add P2Pv2 Data Header struct.
author | masca@cpw.pidgin.im |
---|---|
date | Tue, 04 Jan 2011 04:47:57 +0000 |
parents | a6d2d7de8a08 |
children | a8cc50c2279f |
rev | line source |
---|---|
31494
a6d2d7de8a08
Nick some 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 static GSList * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
49 msn_tlv_read(GSList *list, char *bs, size_t *bs_len) |
a6d2d7de8a08
Nick some 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 guint8 type, 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
|
52 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
|
53 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
54 type = msn_read8(bs); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
55 length = msn_read8(bs); |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
56 *bs_len -= 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
|
57 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
58 if (length > *bs_len) { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
59 msn_tlvlist_free(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
|
60 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
|
61 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
62 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
63 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
|
64 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
|
65 tlv->value = g_memdup(bs, 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
|
66 if (!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
|
67 freetlv(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
|
68 msn_tlvlist_free(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
|
69 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
|
70 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
71 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
72 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
73 *bs_len -= 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
|
74 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
75 return g_slist_prepend(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
|
76 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
77 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
78 GSList * |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
79 msn_tlvlist_read(char *bs, size_t bs_len) |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
80 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
81 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
|
82 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
83 while (bs_len > 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
|
84 list = msn_tlv_read(list, bs, &bs_len); |
a6d2d7de8a08
Nick some 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 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
|
86 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
|
87 } |
a6d2d7de8a08
Nick some 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 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
|
90 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
91 |
a6d2d7de8a08
Nick some 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 GSList *msn_tlvlist_copy(GSList *orig) |
a6d2d7de8a08
Nick some 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 { |
a6d2d7de8a08
Nick some 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 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
|
95 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
|
96 |
a6d2d7de8a08
Nick some 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 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
|
98 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
|
99 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
|
100 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
107 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
|
108 { |
a6d2d7de8a08
Nick some 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 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
|
110 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
|
111 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
|
112 |
a6d2d7de8a08
Nick some 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 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 |
a6d2d7de8a08
Nick some 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 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
|
125 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
132 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
|
133 { |
a6d2d7de8a08
Nick some 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 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
|
135 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
|
136 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
141 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
|
142 { |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
147 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
|
148 { |
a6d2d7de8a08
Nick some 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 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
|
150 |
a6d2d7de8a08
Nick some 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 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
|
152 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
|
153 |
a6d2d7de8a08
Nick some 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 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
|
155 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
|
156 |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
161 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
|
162 { |
a6d2d7de8a08
Nick some 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 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
|
164 |
a6d2d7de8a08
Nick some 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 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
|
166 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
|
167 |
a6d2d7de8a08
Nick some 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 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
|
169 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
|
170 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
|
171 |
a6d2d7de8a08
Nick some 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 *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
|
173 |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
178 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
|
179 { |
a6d2d7de8a08
Nick some 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 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
|
181 |
a6d2d7de8a08
Nick some 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 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
|
183 |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
188 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
|
189 { |
a6d2d7de8a08
Nick some 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 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
|
191 |
a6d2d7de8a08
Nick some 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 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
|
193 |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
198 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
|
199 { |
a6d2d7de8a08
Nick some 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 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
|
201 |
a6d2d7de8a08
Nick some 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 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
|
203 |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
208 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
|
209 { |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
214 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
|
215 { |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
220 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
|
221 { |
a6d2d7de8a08
Nick some 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 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
|
223 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
|
224 |
a6d2d7de8a08
Nick some 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 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
|
226 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
|
227 |
a6d2d7de8a08
Nick some 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 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
|
229 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
|
230 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
|
231 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
235 /* 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
|
236 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
|
237 |
a6d2d7de8a08
Nick some 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 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
|
239 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
|
240 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
|
241 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
|
242 } 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
|
243 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
|
244 |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
249 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
|
250 { |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
255 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
|
256 { |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
261 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
|
262 { |
a6d2d7de8a08
Nick some 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 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
|
264 |
a6d2d7de8a08
Nick some 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 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
|
266 |
a6d2d7de8a08
Nick some 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 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
|
268 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
269 |
a6d2d7de8a08
Nick some 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 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
|
271 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
|
272 { |
a6d2d7de8a08
Nick some 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 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
|
274 |
a6d2d7de8a08
Nick some 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 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
|
276 |
a6d2d7de8a08
Nick some 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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
281 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
|
282 { |
a6d2d7de8a08
Nick some 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 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
|
284 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
|
285 |
a6d2d7de8a08
Nick some 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 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
|
287 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
|
288 |
a6d2d7de8a08
Nick some 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 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
|
290 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
|
291 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
|
292 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
|
293 |
a6d2d7de8a08
Nick some 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 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
|
295 /* 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
|
296 *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
|
297 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
|
298 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
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 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
304 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
305 #if 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
|
306 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
|
307 msn_tlvlist_write(ByteStream *bs, 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
|
308 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
309 int goodbuflen; |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
310 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
|
311 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
|
312 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
313 /* do an initial run to test total 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
|
314 goodbuflen = msn_tlvlist_size(*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
|
315 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
316 if (goodbuflen > byte_stream_bytes_left(bs)) |
a6d2d7de8a08
Nick some 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 return 0; /* not enough buffer */ |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
318 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
319 /* do the real write-out */ |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
320 for (cur = *list; cur; 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
|
321 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
|
322 byte_stream_put16(bs, tlv->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
|
323 byte_stream_put16(bs, 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
|
324 if (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
|
325 byte_stream_putraw(bs, 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
|
326 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
327 |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
328 return 1; /* TODO: This is a nonsensical 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
|
329 } |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
330 #endif |
a6d2d7de8a08
Nick some 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 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
|
333 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
|
334 { |
a6d2d7de8a08
Nick some TLV functions from AIM. I don't know if I need all of these,
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
335 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
|
336 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
|
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 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
|
339 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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 } |
a6d2d7de8a08
Nick some 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 |
a6d2d7de8a08
Nick some 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 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
|
347 } |
a6d2d7de8a08
Nick some 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 |
a6d2d7de8a08
Nick some 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 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
|
350 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
|
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 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
|
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 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
|
355 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
|
356 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
|
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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
362 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
|
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 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
|
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 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
|
367 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
|
368 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
|
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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
374 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
|
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 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
|
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 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
|
379 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
|
380 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
|
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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
386 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
|
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 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
|
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 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
|
391 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
|
392 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
|
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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
398 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
|
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 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
|
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 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
|
403 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
|
404 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
|
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 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
|
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 |
a6d2d7de8a08
Nick some 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 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
|
410 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
|
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 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
|
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 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
|
415 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
|
416 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
|
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 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
|
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 |