libpurple/protocols/gg/lib/protobuf.h

changeset 38882
bea4cc95b40f
parent 38881
25cb836b9cec
parent 38182
783878958371
child 38883
90462fef3dd8
equal deleted inserted replaced
38881:25cb836b9cec 38882:bea4cc95b40f
1 /* $Id$ */
2
3 /*
4 * (C) Copyright 2012 Tomek Wasilczyk <www.wasilczyk.pl>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License Version
8 * 2.1 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
18 * USA.
19 */
20
21 #ifndef LIBGADU_PROTOBUF_H
22 #define LIBGADU_PROTOBUF_H
23
24 #include <stdlib.h>
25 #include <errno.h>
26 #include <string.h>
27
28 #include "config.h"
29 #ifdef GG_CONFIG_HAVE_PROTOBUF_C
30 #include <protobuf-c/protobuf-c.h>
31 #else
32 #include "protobuf-c.h"
33 #endif
34
35 #include "internal.h"
36 #include "fileio.h"
37
38 typedef size_t (*gg_protobuf_size_cb_t)(const void *message);
39 typedef size_t (*gg_protobuf_pack_cb_t)(const void *message, uint8_t *out);
40
41 typedef struct _gg_protobuf_uin_buff gg_protobuf_uin_buff_t;
42
43 /* Ostatni warunek (msg != NULL) jest tylko po to, żeby uciszyć analizę
44 * statyczną (zawiera się w pierwszym). */
45 #define GG_PROTOBUF_VALID(gs, name, msg) \
46 (gg_protobuf_valid_chknull(gs, name, msg == NULL) && \
47 gg_protobuf_valid_chkunknown(gs, name, &msg->base) && \
48 msg != NULL)
49
50 #define GG_PROTOBUF_SEND(gs, ge, packet_type, msg_type, msg) \
51 gg_protobuf_send_ex(gs, ge, packet_type, &msg, \
52 (gg_protobuf_size_cb_t) msg_type ## __get_packed_size, \
53 (gg_protobuf_pack_cb_t) msg_type ## __pack)
54
55 void gg_protobuf_expected(struct gg_session *gs, const char *field_name,
56 uint32_t value, uint32_t expected);
57
58 int gg_protobuf_valid_chknull(struct gg_session *gs, const char *msg_name,
59 int isNull);
60 int gg_protobuf_valid_chkunknown(struct gg_session *gs, const char *msg_name,
61 ProtobufCMessage *base);
62
63 int gg_protobuf_send_ex(struct gg_session *gs, struct gg_event *ge, int type,
64 void *msg, gg_protobuf_size_cb_t size_cb,
65 gg_protobuf_pack_cb_t pack_cb);
66
67 void gg_protobuf_set_uin(ProtobufCBinaryData *dst, uin_t uin, gg_protobuf_uin_buff_t *buff);
68 uin_t gg_protobuf_get_uin(ProtobufCBinaryData uin_data);
69
70 #endif /* LIBGADU_PROTOBUF_H */

mercurial