comparison libpurple/protocols/msn/tlv.h @ 31047:a6d2d7de8a08

Nick some TLV functions from AIM. I don't know if I need all of these, but I guess we'll see. Too bad they don't use the same sizes for the fields.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 17 Dec 2010 09:01:26 +0000
parents
children b8e076d51817
comparison
equal deleted inserted replaced
31046:b4064198e017 31047:a6d2d7de8a08
1 /**
2 * @file tlv.h MSN TLV functions
3 *
4 * purple
5 *
6 * Purple is the legal property of its developers, whose names are too numerous
7 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * source distribution.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 */
24
25 #ifndef MSN_TLV_H
26 #define MSN_TLV_H
27
28 #include "msn.h"
29
30 /* TLV structure */
31 typedef struct msn_tlv_s
32 {
33 guint8 type;
34 guint8 length;
35 guint8 *value;
36 } msn_tlv_t;
37
38 /* TLV handling functions */
39 char *msn_tlv_getvalue_as_string(msn_tlv_t *tlv);
40
41 msn_tlv_t *msn_tlv_gettlv(GSList *list, const guint16 type, const int nth);
42 int msn_tlv_getlength(GSList *list, const guint16 type, const int nth);
43 char *msn_tlv_getstr(GSList *list, const guint16 type, const int nth);
44 guint8 msn_tlv_get8(GSList *list, const guint16 type, const int nth);
45 guint16 msn_tlv_get16(GSList *list, const guint16 type, const int nth);
46 guint32 msn_tlv_get32(GSList *list, const guint16 type, const int nth);
47
48 /* TLV list handling functions */
49 GSList *msn_tlvlist_read(char *bs, size_t bs_len);
50 GSList *msn_tlvlist_copy(GSList *orig);
51
52 int msn_tlvlist_count(GSList *list);
53 size_t msn_tlvlist_size(GSList *list);
54 gboolean msn_tlvlist_equal(GSList *one, GSList *two);
55 int msn_tlvlist_write(char *bs, size_t bs_len, GSList **list);
56 void msn_tlvlist_free(GSList *list);
57
58 int msn_tlvlist_add_raw(GSList **list, const guint16 type, const guint16 length, const char *value);
59 int msn_tlvlist_add_empty(GSList **list, const guint16 type);
60 int msn_tlvlist_add_8(GSList **list, const guint16 type, const guint8 value);
61 int msn_tlvlist_add_16(GSList **list, const guint16 type, const guint16 value);
62 int msn_tlvlist_add_32(GSList **list, const guint16 type, const guint32 value);
63 int msn_tlvlist_add_str(GSList **list, const guint16 type, const char *value);
64
65 int msn_tlvlist_replace_raw(GSList **list, const guint16 type, const guint16 lenth, const char *value);
66 int msn_tlvlist_replace_str(GSList **list, const guint16 type, const char *str);
67 int msn_tlvlist_replace_empty(GSList **list, const guint16 type);
68 int msn_tlvlist_replace_8(GSList **list, const guint16 type, const guint8 value);
69 int msn_tlvlist_replace_16(GSList **list, const guint16 type, const guint16 value);
70 int msn_tlvlist_replace_32(GSList **list, const guint16 type, const guint32 value);
71
72 void msn_tlvlist_remove(GSList **list, const guint16 type);
73
74 #endif /* MSN_TLV_H */
75