gdbus: do not call memset for terminating NUL
[platform/upstream/ofono.git] / gisi / iter.h
1 /*
2  *
3  *  oFono - Open Source Telephony
4  *
5  *  Copyright (C) 2009-2010  Nokia Corporation and/or its subsidiary(-ies).
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License version 2 as
9  *  published by the Free Software Foundation.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21
22 #ifndef __GISI_ITER_H
23 #define __GISI_ITER_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <stdint.h>
30
31 #include "message.h"
32
33 struct _GIsiSubBlockIter {
34         uint8_t *start;
35         uint8_t *end;
36         gboolean longhdr;
37         uint16_t cursor;
38         uint16_t sub_blocks;
39 };
40 typedef struct _GIsiSubBlockIter GIsiSubBlockIter;
41
42 void g_isi_sb_iter_init(GIsiSubBlockIter *iter, const GIsiMessage *msg,
43                         size_t used);
44 void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter, const GIsiMessage *msg,
45                                 size_t used, gboolean longhdr,
46                                 uint16_t sub_blocks);
47 void g_isi_sb_subiter_init(GIsiSubBlockIter *outer, GIsiSubBlockIter *inner,
48                                 size_t used);
49 void g_isi_sb_subiter_init_full(GIsiSubBlockIter *out, GIsiSubBlockIter *in,
50                                 size_t used, gboolean longhdr,
51                                 uint16_t sub_blocks);
52 gboolean g_isi_sb_iter_is_valid(const GIsiSubBlockIter *iter);
53
54 gboolean g_isi_sb_iter_next(GIsiSubBlockIter *iter);
55
56 int g_isi_sb_iter_get_id(const GIsiSubBlockIter *iter);
57 size_t g_isi_sb_iter_get_len(const GIsiSubBlockIter *iter);
58
59 gboolean g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
60                                 void **data, unsigned pos);
61 gboolean g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
62                                 uint8_t *byte, unsigned pos);
63 gboolean g_isi_sb_iter_get_word(const GIsiSubBlockIter *restrict iter,
64                                 uint16_t *word, unsigned pos);
65 gboolean g_isi_sb_iter_get_dword(const GIsiSubBlockIter *restrict iter,
66                                         uint32_t *dword, unsigned pos);
67 gboolean g_isi_sb_iter_eat_byte(GIsiSubBlockIter *restrict iter,
68                                 uint8_t *byte);
69 gboolean g_isi_sb_iter_eat_word(GIsiSubBlockIter *restrict iter,
70                                 uint16_t *word);
71 gboolean g_isi_sb_iter_eat_dword(GIsiSubBlockIter *restrict iter,
72                                 uint32_t *dword);
73 gboolean g_isi_sb_iter_get_oper_code(const GIsiSubBlockIter *restrict iter,
74                                         char *mcc, char *mnc, unsigned pos);
75 gboolean g_isi_sb_iter_eat_oper_code(GIsiSubBlockIter *restrict iter,
76                                         char *mcc, char *mnc);
77 gboolean g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter *restrict iter,
78                                         char **utf8, size_t len, unsigned pos);
79 gboolean g_isi_sb_iter_eat_alpha_tag(GIsiSubBlockIter *restrict iter,
80                                         char **utf8, size_t len);
81 gboolean g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter *restrict iter,
82                                         char **ascii, size_t len, unsigned pos);
83 gboolean g_isi_sb_iter_eat_latin_tag(GIsiSubBlockIter *restrict iter,
84                                         char **ascii, size_t len);
85 gboolean g_isi_sb_iter_get_struct(const GIsiSubBlockIter *restrict iter,
86                                         void **ptr, size_t len, unsigned pos);
87
88 #ifdef __cplusplus
89 }
90 #endif
91
92 #endif /* __GISI_ITER_H */