diff options
Diffstat (limited to 'src/lib/include/gnunet_dbus_lib_pop.h')
-rw-r--r-- | src/lib/include/gnunet_dbus_lib_pop.h | 408 |
1 files changed, 408 insertions, 0 deletions
diff --git a/src/lib/include/gnunet_dbus_lib_pop.h b/src/lib/include/gnunet_dbus_lib_pop.h new file mode 100644 index 0000000..6ffde70 --- /dev/null +++ b/src/lib/include/gnunet_dbus_lib_pop.h | |||
@@ -0,0 +1,408 @@ | |||
1 | #ifndef GNUNET_DBUS_LIB_POP_H | ||
2 | #define GNUNET_DBUS_LIB_POP_H | ||
3 | |||
4 | /** | ||
5 | * Pop a byte from a DBus message, advancing the iterator. `arg_name` is used | ||
6 | * for reporting useful diagnostics if the value in the message is missing or | ||
7 | * the wrong type. | ||
8 | */ | ||
9 | DBusMessage * | ||
10 | GNUNET_DBUS_pop_byte ( | ||
11 | DBusMessage *message, | ||
12 | DBusMessageIter *iter, | ||
13 | const char *arg_name, | ||
14 | unsigned char *value); | ||
15 | |||
16 | /** | ||
17 | * Pop a boolean from a DBus message, advancing the iterator. `arg_name` is | ||
18 | * used for reporting useful diagnostics if the value in the message is missing | ||
19 | * or the wrong type. | ||
20 | */ | ||
21 | DBusMessage * | ||
22 | GNUNET_DBUS_pop_boolean ( | ||
23 | DBusMessage *message, | ||
24 | DBusMessageIter *iter, | ||
25 | const char *arg_name, | ||
26 | dbus_bool_t *value); | ||
27 | |||
28 | /** | ||
29 | * Pop an int16 from a DBus message, advancing the iterator. `arg_name` is used | ||
30 | * for reporting useful diagnostics if the value in the message is missing or | ||
31 | * the wrong type. | ||
32 | */ | ||
33 | DBusMessage * | ||
34 | GNUNET_DBUS_pop_int16 ( | ||
35 | DBusMessage *message, | ||
36 | DBusMessageIter *iter, | ||
37 | const char *arg_name, | ||
38 | dbus_int16_t *value); | ||
39 | |||
40 | /** | ||
41 | * Pop a uint16 from a DBus message, advancing the iterator. `arg_name` is used | ||
42 | * for reporting useful diagnostics if the value in the message is missing or | ||
43 | * the wrong type. | ||
44 | */ | ||
45 | DBusMessage * | ||
46 | GNUNET_DBUS_pop_uint16 ( | ||
47 | DBusMessage *message, | ||
48 | DBusMessageIter *iter, | ||
49 | const char *arg_name, | ||
50 | dbus_uint16_t *value); | ||
51 | |||
52 | /** | ||
53 | * Pop an int32 from a DBus message, advancing the iterator. `arg_name` is | ||
54 | * used for reporting useful diagnostics if the value in the message is missing | ||
55 | * or the wrong type. | ||
56 | */ | ||
57 | DBusMessage * | ||
58 | GNUNET_DBUS_pop_int32 ( | ||
59 | DBusMessage *message, | ||
60 | DBusMessageIter *iter, | ||
61 | const char *arg_name, | ||
62 | dbus_int32_t *value); | ||
63 | |||
64 | /** | ||
65 | * Pop a uint32 from a DBus message, advancing the iterator. `arg_name` is | ||
66 | * used for reporting useful diagnostics if the value in the message is missing | ||
67 | * or the wrong type. | ||
68 | */ | ||
69 | DBusMessage * | ||
70 | GNUNET_DBUS_pop_uint32 ( | ||
71 | DBusMessage *message, | ||
72 | DBusMessageIter *iter, | ||
73 | const char *arg_name, | ||
74 | dbus_uint32_t *value); | ||
75 | |||
76 | /** | ||
77 | * Pop an int64 from a DBus message, advancing the iterator. `arg_name` is | ||
78 | * used for reporting useful diagnostics if the value in the message is missing | ||
79 | * or the wrong type. | ||
80 | */ | ||
81 | DBusMessage * | ||
82 | GNUNET_DBUS_pop_int64 ( | ||
83 | DBusMessage *message, | ||
84 | DBusMessageIter *iter, | ||
85 | const char *arg_name, | ||
86 | dbus_int64_t *value); | ||
87 | |||
88 | /** | ||
89 | * Pop a uint64 from a DBus message, advancing the iterator. `arg_name` is | ||
90 | * used for reporting useful diagnostics if the value in the message is missing | ||
91 | * or the wrong type. | ||
92 | */ | ||
93 | DBusMessage * | ||
94 | GNUNET_DBUS_pop_uint64 ( | ||
95 | DBusMessage *message, | ||
96 | DBusMessageIter *iter, | ||
97 | const char *arg_name, | ||
98 | dbus_uint64_t *value); | ||
99 | |||
100 | /** | ||
101 | * Pop a double from a DBus message, advancing the iterator. `arg_name` is used | ||
102 | * for reporting useful diagnostics if the value in the message is missing or | ||
103 | * the wrong type. | ||
104 | */ | ||
105 | DBusMessage * | ||
106 | GNUNET_DBUS_pop_double ( | ||
107 | DBusMessage *message, | ||
108 | DBusMessageIter *iter, | ||
109 | const char *arg_name, | ||
110 | double *value); | ||
111 | |||
112 | /** | ||
113 | * Pop a string from a DBus message, advancing the iterator. `arg_name` is used | ||
114 | * for reporting useful diagnostics if the value in the message is missing or | ||
115 | * the wrong type. | ||
116 | */ | ||
117 | DBusMessage * | ||
118 | GNUNET_DBUS_pop_string ( | ||
119 | DBusMessage *message, | ||
120 | DBusMessageIter *iter, | ||
121 | const char *arg_name, | ||
122 | const char **value); | ||
123 | |||
124 | /** | ||
125 | * Pop a DBus object path from a DBus message, advancing the iterator. The | ||
126 | * object path is returned in *value as a string. `arg_name` is used for | ||
127 | * reporting useful diagnostics if the value in the message is missing or the | ||
128 | * wrong type. | ||
129 | */ | ||
130 | DBusMessage * | ||
131 | GNUNET_DBUS_pop_object_path ( | ||
132 | DBusMessage *message, | ||
133 | DBusMessageIter *iter, | ||
134 | const char *arg_name, | ||
135 | const char **value); | ||
136 | |||
137 | /** | ||
138 | * Pop a DBus type signature from a DBusMessage, advancing the iterator. The | ||
139 | * type signature is returned in *value as a string. `arg_name` is used for | ||
140 | * reporting useful diagnostics if the value in the message is missing or the | ||
141 | * wrong type. | ||
142 | */ | ||
143 | DBusMessage * | ||
144 | GNUNET_DBUS_pop_signature ( | ||
145 | DBusMessage *message, | ||
146 | DBusMessageIter *iter, | ||
147 | const char *arg_name, | ||
148 | const char **value); | ||
149 | |||
150 | /** | ||
151 | * Pop a unix file descriptor from a DBusMessage, advancing the iterator. | ||
152 | * `arg_name` is used for reporting useful diagnostics if the value in the | ||
153 | * message is missing or the wrong type. | ||
154 | */ | ||
155 | DBusMessage * | ||
156 | GNUNET_DBUS_pop_unix_fd ( | ||
157 | DBusMessage *message, | ||
158 | DBusMessageIter *iter, | ||
159 | const char *arg_name, | ||
160 | int *value); | ||
161 | |||
162 | /** | ||
163 | * Pop an array from a DBusMessage. Moves iter past the array and initialises | ||
164 | * iter_sub to point to the first element of the array. The length of the array | ||
165 | * is returned in *len. `arg_name` is used for reporting useful diagnostics if | ||
166 | * the value in the message is missing or the wrong type. | ||
167 | */ | ||
168 | DBusMessage * | ||
169 | GNUNET_DBUS_pop_enter_array ( | ||
170 | DBusMessage *message, | ||
171 | DBusMessageIter *iter, | ||
172 | DBusMessageIter *iter_sub, | ||
173 | const char *arg_name, | ||
174 | size_t *len); | ||
175 | |||
176 | /** | ||
177 | * Pop a struct from a DBusMessage. Moves iter past the struct and initialises | ||
178 | * iter_sub to point to the first element of the struct. `arg_name` is used for | ||
179 | * reporting useful diagnostics if the value in the message is missing or the | ||
180 | * wrong type. | ||
181 | */ | ||
182 | DBusMessage * | ||
183 | GNUNET_DBUS_pop_enter_struct ( | ||
184 | DBusMessage *message, | ||
185 | DBusMessageIter *iter, | ||
186 | DBusMessageIter *iter_sub, | ||
187 | const char *arg_name); | ||
188 | |||
189 | /** | ||
190 | * Pop a variant from a DBusMessage. Moves iter past the variant and | ||
191 | * initialises iter_sub to point to the value inside the variant. `arg_name` | ||
192 | * is used for reporting useful diagnostics if the value in the message is | ||
193 | * missing or the wrong type. | ||
194 | */ | ||
195 | DBusMessage * | ||
196 | GNUNET_DBUS_pop_enter_variant ( | ||
197 | DBusMessage *message, | ||
198 | DBusMessageIter *iter, | ||
199 | DBusMessageIter *iter_sub, | ||
200 | const char *arg_name); | ||
201 | |||
202 | /** | ||
203 | * Pop a dictionary entry from a DBusMessage. Moves iter past the dictionary | ||
204 | * entry and initialises iter_sub to point to the key. The key and value can | ||
205 | * then be popped in sequence using iter_sub. `arg_name` is used for reporting | ||
206 | * useful diagnostics if the value in the message is missing or the wrong type. | ||
207 | */ | ||
208 | DBusMessage * | ||
209 | GNUNET_DBUS_pop_enter_dict_entry ( | ||
210 | DBusMessage *message, | ||
211 | DBusMessageIter *iter, | ||
212 | DBusMessageIter *iter_sub, | ||
213 | const char *arg_name); | ||
214 | |||
215 | /** | ||
216 | * Pop an array of bytes from a DBusMessage. A pointer to the array is stored | ||
217 | * in *value. The array is not copied so *value will become invalid once the | ||
218 | * message has been freed. The length of the array is stored in *n_elements. | ||
219 | * `arg_name` is used for reporting useful diagnostics if the value in the | ||
220 | * message is missing or the wrong type. | ||
221 | */ | ||
222 | DBusMessage * | ||
223 | GNUNET_DBUS_pop_byte_array ( | ||
224 | DBusMessage *message, | ||
225 | DBusMessageIter *iter, | ||
226 | const char *arg_name, | ||
227 | const unsigned char **value, | ||
228 | int *n_elements); | ||
229 | |||
230 | /** | ||
231 | * Pop an array of booleans from a DBusMessage. A pointer to the array is | ||
232 | * stored in *value. The array is not copied so *value will become invalid once | ||
233 | * the message has been freed. The length of the array is stored in | ||
234 | * *n_elements. `arg_name` is used for reporting useful diagnostics if the | ||
235 | * value in the message is missing or the wrong type. | ||
236 | */ | ||
237 | DBusMessage * | ||
238 | GNUNET_DBUS_pop_boolean_array ( | ||
239 | DBusMessage *message, | ||
240 | DBusMessageIter *iter, | ||
241 | const char *arg_name, | ||
242 | const dbus_bool_t **value, | ||
243 | int *n_elements); | ||
244 | |||
245 | /** | ||
246 | * Pop an array of int16s from a DBusMessage. A pointer to the array is stored | ||
247 | * in *value. The array is not copied so *value will become invalid once the | ||
248 | * message has been freed. The length of the array is stored in *n_elements. | ||
249 | * `arg_name` is used for reporting useful diagnostics if the value in the | ||
250 | * message is missing or the wrong type. | ||
251 | */ | ||
252 | DBusMessage * | ||
253 | GNUNET_DBUS_pop_int16_array ( | ||
254 | DBusMessage *message, | ||
255 | DBusMessageIter *iter, | ||
256 | const char *arg_name, | ||
257 | const int16_t **value, | ||
258 | int *n_elements); | ||
259 | |||
260 | /** | ||
261 | * Pop an array of uint16s from a DBusMessage. A pointer to the array is stored | ||
262 | * in *value. The array is not copied so *value will become invalid once the | ||
263 | * message has been freed. The length of the array is stored in *n_elements. | ||
264 | * `arg_name` is used for reporting useful diagnostics if the value in the | ||
265 | * message is missing or the wrong type. | ||
266 | */ | ||
267 | DBusMessage * | ||
268 | GNUNET_DBUS_pop_uint16_array ( | ||
269 | DBusMessage *message, | ||
270 | DBusMessageIter *iter, | ||
271 | const char *arg_name, | ||
272 | const uint16_t **value, | ||
273 | int *n_elements); | ||
274 | |||
275 | /** | ||
276 | * Pop an array of int32s from a DBusMessage. A pointer to the array is stored | ||
277 | * in *value. The array is not copied so *value will become invalid once the | ||
278 | * message has been freed. The length of the array is stored in *n_elements. | ||
279 | * `arg_name` is used for reporting useful diagnostics if the value in the | ||
280 | * message is missing or the wrong type. | ||
281 | */ | ||
282 | DBusMessage * | ||
283 | GNUNET_DBUS_pop_int32_array ( | ||
284 | DBusMessage *message, | ||
285 | DBusMessageIter *iter, | ||
286 | const char *arg_name, | ||
287 | const int32_t **value, | ||
288 | int *n_elements); | ||
289 | |||
290 | /** | ||
291 | * Pop an array of uint32s from a DBusMessage. A pointer to the array is stored | ||
292 | * in *value. The array is not copied so *value will become invalid once the | ||
293 | * message has been freed. The length of the array is stored in *n_elements. | ||
294 | * `arg_name` is used for reporting useful diagnostics if the value in the | ||
295 | * message is missing or the wrong type. | ||
296 | */ | ||
297 | DBusMessage * | ||
298 | GNUNET_DBUS_pop_uint32_array ( | ||
299 | DBusMessage *message, | ||
300 | DBusMessageIter *iter, | ||
301 | const char *arg_name, | ||
302 | const uint32_t **value, | ||
303 | int *n_elements); | ||
304 | |||
305 | /** | ||
306 | * Pop an array of int64s from a DBusMessage. A pointer to the array is stored | ||
307 | * in *value. The array is not copied so *value will become invalid once the | ||
308 | * message has been freed. The length of the array is stored in *n_elements. | ||
309 | * `arg_name` is used for reporting useful diagnostics if the value in the | ||
310 | * message is missing or the wrong type. | ||
311 | */ | ||
312 | DBusMessage * | ||
313 | GNUNET_DBUS_pop_int64_array ( | ||
314 | DBusMessage *message, | ||
315 | DBusMessageIter *iter, | ||
316 | const char *arg_name, | ||
317 | const int64_t **value, | ||
318 | int *n_elements); | ||
319 | |||
320 | /** | ||
321 | * Pop an array of uint64s from a DBusMessage. A pointer to the array is stored | ||
322 | * in *value. The array is not copied so *value will become invalid once the | ||
323 | * message has been freed. The length of the array is stored in *n_elements. | ||
324 | * `arg_name` is used for reporting useful diagnostics if the value in the | ||
325 | * message is missing or the wrong type. | ||
326 | */ | ||
327 | DBusMessage * | ||
328 | GNUNET_DBUS_pop_uint64_array ( | ||
329 | DBusMessage *message, | ||
330 | DBusMessageIter *iter, | ||
331 | const char *arg_name, | ||
332 | const uint64_t **value, | ||
333 | int *n_elements); | ||
334 | |||
335 | /* | ||
336 | * Pop a bitfield enum from a DBusMessage, advancing the iterator. A bitfield | ||
337 | * enum is an enum where the individual bits represent different flags. See for | ||
338 | * example the definition of GNUNET_GNSRECORD_Flags: | ||
339 | * | ||
340 | * enum GNUNET_GNSRECORD_Flags { | ||
341 | * GNUNET_GNSRECORD_RF_PRIVATE = 2, | ||
342 | * // GNUNET_GNSRECORD_RF_UNUSED = 4, | ||
343 | * GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION = 8, | ||
344 | * GNUNET_GNSRECORD_RF_SHADOW_RECORD = 16 | ||
345 | * } | ||
346 | * | ||
347 | * Bitfield enums can be sent across the wire in either their integer form (as | ||
348 | * a uint32) or as an array of strings. Sending an int is more efficient and is | ||
349 | * what libraries built around the DBus API would use. People using the DBus | ||
350 | * API directly via the command line or a DBus debugger may want to pass | ||
351 | * human-readable strings for convenience. names is a pointer to a | ||
352 | * {NULL, 0}-terminated array of GNUNET_DBUS_StringEnumPair which assigns | ||
353 | * human-readable names to the bitfields. `arg_name` is used for reporting | ||
354 | * useful diagnostics if the value in the message is missing or the wrong type. | ||
355 | */ | ||
356 | DBusMessage * | ||
357 | GNUNET_DBUS_pop_bitfield ( | ||
358 | DBusMessage *message, | ||
359 | DBusMessageIter *iter, | ||
360 | const char *arg_name, | ||
361 | int *value, | ||
362 | const struct GNUNET_DBUS_StringEnumPair *fields); | ||
363 | |||
364 | /** | ||
365 | * Pop an enum from a DBusMessage, advancing the iterator. enums can be sent | ||
366 | * across the wire as either a uint32 or as a string. Sending a uint32 is more | ||
367 | * efficient and is what libraries built around the DBus API would use. People | ||
368 | * using the DBus API directly via the command line or a DBus debugger may want | ||
369 | * to pass human-readable strings for convenience. names is a pointer to a | ||
370 | * {NULL, 0}-terminated array of GNUNET_DBUS_StringEnumPair which assigns | ||
371 | * human-readable names to the different enum variants. `arg_name` is used for | ||
372 | * reporting useful diagnostics if the value in the message is missing or the | ||
373 | * wrong type. | ||
374 | */ | ||
375 | DBusMessage * | ||
376 | GNUNET_DBUS_pop_enum ( | ||
377 | DBusMessage *message, | ||
378 | DBusMessageIter *iter, | ||
379 | const char *arg_name, | ||
380 | int *value, | ||
381 | const struct GNUNET_DBUS_StringEnumPair *names); | ||
382 | |||
383 | /** | ||
384 | * Pop a GNUNET_HashCode from a DBusMessage, advancing the iterator. | ||
385 | * `arg_name` is used for reporting useful diagnostics if the value in the | ||
386 | * message is missing or the wrong type. | ||
387 | */ | ||
388 | DBusMessage * | ||
389 | GNUNET_DBUS_pop_hashcode ( | ||
390 | DBusMessage *message, | ||
391 | DBusMessageIter *iter, | ||
392 | const char *arg_name, | ||
393 | struct GNUNET_HashCode *value); | ||
394 | |||
395 | /** | ||
396 | * Pop a GNUNET_PeerIdentity from a DBusMessage, advancing the iterator. | ||
397 | * `arg_name` is used for reporting useful diagnostics if the value in the | ||
398 | * message is missing or the wrong type. | ||
399 | */ | ||
400 | DBusMessage * | ||
401 | GNUNET_DBUS_pop_peer_identity ( | ||
402 | DBusMessage *message, | ||
403 | DBusMessageIter *iter, | ||
404 | const char *arg_name, | ||
405 | struct GNUNET_PeerIdentity *value); | ||
406 | |||
407 | #endif | ||
408 | |||