[daemon-fix] fixed querying about name information
[platform/upstream/dbus.git] / dbus / dbus-marshal-recursive.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-marshal-recursive.h  Marshalling routines for recursive types
3  *
4  * Copyright (C) 2004, 2005 Red Hat, Inc.
5  *
6  * Licensed under the Academic Free License version 2.1
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23
24 #ifndef DBUS_MARSHAL_RECURSIVE_H
25 #define DBUS_MARSHAL_RECURSIVE_H
26
27 #include <dbus/dbus-protocol.h>
28 #include <dbus/dbus-list.h>
29
30 typedef struct DBusTypeReader      DBusTypeReader;
31 typedef struct DBusTypeWriter      DBusTypeWriter;
32 typedef struct DBusTypeReaderClass DBusTypeReaderClass;
33 typedef struct DBusArrayLenFixup   DBusArrayLenFixup;
34
35 /**
36  * The type reader is an iterator for reading values from a block of
37  * values.
38  */
39 struct DBusTypeReader
40 {
41   dbus_uint32_t byte_order : 8; /**< byte order of the block */
42
43   dbus_uint32_t finished : 1;   /**< marks we're at end iterator for cases
44                                  * where we don't have another way to tell
45                                  */
46   dbus_uint32_t array_len_offset : 3; /**< bytes back from start_pos that len ends */
47   const DBusString *type_str;   /**< string containing signature of block */
48   int type_pos;                 /**< current position in signature */
49   const DBusString *value_str;  /**< string containing values of block */
50   int value_pos;                /**< current position in values */
51
52   const DBusTypeReaderClass *klass; /**< the vtable for the reader */
53   union
54   {
55     struct {
56       int start_pos;                /**< for array readers, the start of the array values */
57     } array;
58   } u; /**< class-specific data */
59 };
60
61 /**
62  * The type writer is an iterator for writing to a block of values.
63  */
64 struct DBusTypeWriter
65 {
66   dbus_uint32_t byte_order : 8;            /**< byte order to write values with */
67
68   dbus_uint32_t container_type : 8;        /**< what are we inside? (e.g. struct, variant, array) */
69
70   dbus_uint32_t type_pos_is_expectation : 1; /**< type_pos can be either an insertion point for or an expected next type */
71
72   dbus_uint32_t enabled : 1; /**< whether to write values */
73
74   DBusString *type_str; /**< where to write typecodes (or read type expectations) */
75   int type_pos;         /**< current pos in type_str */
76   DBusString *value_str; /**< where to write values */
77   int value_pos;         /**< next position to write */
78
79   union
80   {
81     struct {
82       int start_pos; /**< position of first element in the array */
83       int len_pos;   /**< position of length of the array */
84       int element_type_pos; /**< position of array element type in type_str */
85     } array;
86   } u; /**< class-specific data */
87 };
88
89 /**
90  * When modifying an existing block of values, array lengths may need
91  * to be adjusted; those adjustments are described by this struct.
92  */
93 struct DBusArrayLenFixup
94 {
95   int len_pos_in_reader; /**< where the length was in the original block */
96   int new_len;           /**< the new value of the length in the written-out block */
97 };
98
99 void        _dbus_type_reader_init                      (DBusTypeReader        *reader,
100                                                          int                    byte_order,
101                                                          const DBusString      *type_str,
102                                                          int                    type_pos,
103                                                          const DBusString      *value_str,
104                                                          int                    value_pos);
105 void        _dbus_type_reader_init_types_only           (DBusTypeReader        *reader,
106                                                          const DBusString      *type_str,
107                                                          int                    type_pos);
108 int         _dbus_type_reader_get_current_type          (const DBusTypeReader  *reader);
109 int         _dbus_type_reader_get_element_type          (const DBusTypeReader  *reader);
110 int         _dbus_type_reader_get_value_pos             (const DBusTypeReader  *reader);
111 void        _dbus_type_reader_read_basic                (const DBusTypeReader  *reader,
112                                                          void                  *value);
113 int         _dbus_type_reader_get_array_length          (const DBusTypeReader  *reader);
114 void        _dbus_type_reader_read_fixed_multi          (const DBusTypeReader  *reader,
115                                                          void                  *value,
116                                                          int                   *n_elements);
117 void        _dbus_type_reader_read_raw                  (const DBusTypeReader  *reader,
118                                                          const unsigned char  **value_location);
119 void        _dbus_type_reader_recurse                   (DBusTypeReader        *reader,
120                                                          DBusTypeReader        *subreader);
121 dbus_bool_t _dbus_type_reader_next                      (DBusTypeReader        *reader);
122 dbus_bool_t _dbus_type_reader_has_next                  (const DBusTypeReader  *reader);
123 void        _dbus_type_reader_get_signature             (const DBusTypeReader  *reader,
124                                                          const DBusString     **str_p,
125                                                          int                   *start_p,
126                                                          int                   *len_p);
127 dbus_bool_t _dbus_type_reader_set_basic                 (DBusTypeReader        *reader,
128                                                          const void            *value,
129                                                          const DBusTypeReader  *realign_root);
130 dbus_bool_t _dbus_type_reader_delete                    (DBusTypeReader        *reader,
131                                                          const DBusTypeReader  *realign_root);
132
133 dbus_bool_t _dbus_type_reader_equal_values              (const DBusTypeReader *lhs,
134                                                          const DBusTypeReader *rhs);
135
136 void        _dbus_type_signature_next                   (const char            *signature,
137                                                          int                   *type_pos);
138
139 void        _dbus_type_writer_init                 (DBusTypeWriter        *writer,
140                                                     int                    byte_order,
141                                                     DBusString            *type_str,
142                                                     int                    type_pos,
143                                                     DBusString            *value_str,
144                                                     int                    value_pos);
145 void        _dbus_type_writer_init_types_delayed   (DBusTypeWriter        *writer,
146                                                     int                    byte_order,
147                                                     DBusString            *value_str,
148                                                     int                    value_pos);
149 void        _dbus_type_writer_add_types            (DBusTypeWriter        *writer,
150                                                     DBusString            *type_str,
151                                                     int                    type_pos);
152 void        _dbus_type_writer_remove_types         (DBusTypeWriter        *writer);
153 void        _dbus_type_writer_init_values_only     (DBusTypeWriter        *writer,
154                                                     int                    byte_order,
155                                                     const DBusString      *type_str,
156                                                     int                    type_pos,
157                                                     DBusString            *value_str,
158                                                     int                    value_pos);
159 dbus_bool_t _dbus_type_writer_write_basic          (DBusTypeWriter        *writer,
160                                                     int                    type,
161                                                     const void            *value);
162 dbus_bool_t _dbus_type_writer_write_fixed_multi    (DBusTypeWriter        *writer,
163                                                     int                    element_type,
164                                                     const void            *value,
165                                                     int                    n_elements);
166 dbus_bool_t _dbus_type_writer_recurse              (DBusTypeWriter        *writer,
167                                                     int                    container_type,
168                                                     const DBusString      *contained_type,
169                                                     int                    contained_type_start,
170                                                     DBusTypeWriter        *sub);
171 dbus_bool_t _dbus_type_writer_unrecurse            (DBusTypeWriter        *writer,
172                                                     DBusTypeWriter        *sub);
173 dbus_bool_t _dbus_type_writer_append_array         (DBusTypeWriter        *writer,
174                                                     const DBusString      *contained_type,
175                                                     int                    contained_type_start,
176                                                     DBusTypeWriter        *sub);
177 dbus_bool_t _dbus_type_writer_write_reader         (DBusTypeWriter        *writer,
178                                                     DBusTypeReader        *reader);
179
180
181 #endif /* DBUS_MARSHAL_RECURSIVE_H */