2 * WPA Supplicant / dbus-based control interface
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
15 #ifndef DBUS_DICT_HELPERS_H
16 #define DBUS_DICT_HELPERS_H
19 * Adding a dict to a DBusMessage
22 dbus_bool_t
wpa_dbus_dict_open_write(DBusMessageIter
*iter
,
23 DBusMessageIter
*iter_dict
);
25 dbus_bool_t
wpa_dbus_dict_close_write(DBusMessageIter
*iter
,
26 DBusMessageIter
*iter_dict
);
28 const char * wpa_dbus_type_as_string(const int type
);
30 dbus_bool_t
wpa_dbus_dict_append_string(DBusMessageIter
*iter_dict
,
31 const char *key
, const char *value
);
33 dbus_bool_t
wpa_dbus_dict_append_byte(DBusMessageIter
*iter_dict
,
34 const char *key
, const char value
);
36 dbus_bool_t
wpa_dbus_dict_append_bool(DBusMessageIter
*iter_dict
,
38 const dbus_bool_t value
);
40 dbus_bool_t
wpa_dbus_dict_append_int16(DBusMessageIter
*iter_dict
,
42 const dbus_int16_t value
);
44 dbus_bool_t
wpa_dbus_dict_append_uint16(DBusMessageIter
*iter_dict
,
46 const dbus_uint16_t value
);
48 dbus_bool_t
wpa_dbus_dict_append_int32(DBusMessageIter
*iter_dict
,
50 const dbus_int32_t value
);
52 dbus_bool_t
wpa_dbus_dict_append_uint32(DBusMessageIter
*iter_dict
,
54 const dbus_uint32_t value
);
56 dbus_bool_t
wpa_dbus_dict_append_int64(DBusMessageIter
*iter_dict
,
58 const dbus_int64_t value
);
60 dbus_bool_t
wpa_dbus_dict_append_uint64(DBusMessageIter
*iter_dict
,
62 const dbus_uint64_t value
);
64 dbus_bool_t
wpa_dbus_dict_append_double(DBusMessageIter
*iter_dict
,
68 dbus_bool_t
wpa_dbus_dict_append_object_path(DBusMessageIter
*iter_dict
,
72 dbus_bool_t
wpa_dbus_dict_append_byte_array(DBusMessageIter
*iter_dict
,
75 const dbus_uint32_t value_len
);
77 /* Manual construction and addition of string array elements */
78 dbus_bool_t
wpa_dbus_dict_begin_string_array(DBusMessageIter
*iter_dict
,
80 DBusMessageIter
*iter_dict_entry
,
81 DBusMessageIter
*iter_dict_val
,
82 DBusMessageIter
*iter_array
);
84 dbus_bool_t
wpa_dbus_dict_string_array_add_element(DBusMessageIter
*iter_array
,
87 dbus_bool_t
wpa_dbus_dict_end_string_array(DBusMessageIter
*iter_dict
,
88 DBusMessageIter
*iter_dict_entry
,
89 DBusMessageIter
*iter_dict_val
,
90 DBusMessageIter
*iter_array
);
92 /* Convenience function to add a whole string list */
93 dbus_bool_t
wpa_dbus_dict_append_string_array(DBusMessageIter
*iter_dict
,
96 const dbus_uint32_t num_items
);
99 * Reading a dict from a DBusMessage
102 struct wpa_dbus_dict_entry
{
103 int type
; /** the dbus type of the dict entry's value */
104 int array_type
; /** the dbus type of the array elements if the dict
105 entry value contains an array */
106 const char *key
; /** key of the dict entry */
108 /** Possible values of the property */
112 dbus_bool_t bool_value
;
113 dbus_int16_t int16_value
;
114 dbus_uint16_t uint16_value
;
115 dbus_int32_t int32_value
;
116 dbus_uint32_t uint32_value
;
117 dbus_int64_t int64_value
;
118 dbus_uint64_t uint64_value
;
120 char *bytearray_value
;
121 char **strarray_value
;
123 dbus_uint32_t array_len
; /** length of the array if the dict entry's
124 value contains an array */
127 dbus_bool_t
wpa_dbus_dict_open_read(DBusMessageIter
*iter
,
128 DBusMessageIter
*iter_dict
);
130 dbus_bool_t
wpa_dbus_dict_get_entry(DBusMessageIter
*iter_dict
,
131 struct wpa_dbus_dict_entry
*entry
);
133 dbus_bool_t
wpa_dbus_dict_has_dict_entry(DBusMessageIter
*iter_dict
);
135 void wpa_dbus_dict_entry_clear(struct wpa_dbus_dict_entry
*entry
);
137 #endif /* DBUS_DICT_HELPERS_H */