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.
16 #include <dbus/dbus.h>
19 #include "dbus_dict_helpers.h"
23 * Start a dict in a dbus message. Should be paired with a call to
24 * wpa_dbus_dict_close_write().
26 * @param iter A valid dbus message iterator
27 * @param iter_dict (out) A dict iterator to pass to further dict functions
28 * @return TRUE on success, FALSE on failure
31 dbus_bool_t wpa_dbus_dict_open_write(DBusMessageIter *iter,
32 DBusMessageIter *iter_dict)
36 if (!iter || !iter_dict)
39 result = dbus_message_iter_open_container(
42 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
43 DBUS_TYPE_STRING_AS_STRING
44 DBUS_TYPE_VARIANT_AS_STRING
45 DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
52 * End a dict element in a dbus message. Should be paired with
53 * a call to wpa_dbus_dict_open_write().
55 * @param iter valid dbus message iterator, same as passed to
56 * wpa_dbus_dict_open_write()
57 * @param iter_dict a dbus dict iterator returned from
58 * wpa_dbus_dict_open_write()
59 * @return TRUE on success, FALSE on failure
62 dbus_bool_t wpa_dbus_dict_close_write(DBusMessageIter *iter,
63 DBusMessageIter *iter_dict)
65 if (!iter || !iter_dict)
68 return dbus_message_iter_close_container(iter, iter_dict);
72 static const char * _wpa_get_type_as_string_from_type(const int type)
76 return DBUS_TYPE_BYTE_AS_STRING;
77 case DBUS_TYPE_BOOLEAN:
78 return DBUS_TYPE_BOOLEAN_AS_STRING;
80 return DBUS_TYPE_INT16_AS_STRING;
81 case DBUS_TYPE_UINT16:
82 return DBUS_TYPE_UINT16_AS_STRING;
84 return DBUS_TYPE_INT32_AS_STRING;
85 case DBUS_TYPE_UINT32:
86 return DBUS_TYPE_UINT32_AS_STRING;
88 return DBUS_TYPE_INT64_AS_STRING;
89 case DBUS_TYPE_UINT64:
90 return DBUS_TYPE_UINT64_AS_STRING;
91 case DBUS_TYPE_DOUBLE:
92 return DBUS_TYPE_DOUBLE_AS_STRING;
93 case DBUS_TYPE_STRING:
94 return DBUS_TYPE_STRING_AS_STRING;
95 case DBUS_TYPE_OBJECT_PATH:
96 return DBUS_TYPE_OBJECT_PATH_AS_STRING;
98 return DBUS_TYPE_ARRAY_AS_STRING;
105 static dbus_bool_t _wpa_dbus_add_dict_entry_start(
106 DBusMessageIter *iter_dict, DBusMessageIter *iter_dict_entry,
107 const char *key, const int value_type)
109 if (!dbus_message_iter_open_container(iter_dict,
110 DBUS_TYPE_DICT_ENTRY, NULL,
114 if (!dbus_message_iter_append_basic(iter_dict_entry, DBUS_TYPE_STRING,
122 static dbus_bool_t _wpa_dbus_add_dict_entry_end(
123 DBusMessageIter *iter_dict, DBusMessageIter *iter_dict_entry,
124 DBusMessageIter *iter_dict_val)
126 if (!dbus_message_iter_close_container(iter_dict_entry, iter_dict_val))
128 if (!dbus_message_iter_close_container(iter_dict, iter_dict_entry))
135 static dbus_bool_t _wpa_dbus_add_dict_entry_basic(DBusMessageIter *iter_dict,
137 const int value_type,
140 DBusMessageIter iter_dict_entry, iter_dict_val;
141 const char *type_as_string = NULL;
143 type_as_string = _wpa_get_type_as_string_from_type(value_type);
147 if (!_wpa_dbus_add_dict_entry_start(iter_dict, &iter_dict_entry,
151 if (!dbus_message_iter_open_container(&iter_dict_entry,
153 type_as_string, &iter_dict_val))
156 if (!dbus_message_iter_append_basic(&iter_dict_val, value_type, value))
159 if (!_wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry,
167 static dbus_bool_t _wpa_dbus_add_dict_entry_byte_array(
168 DBusMessageIter *iter_dict, const char *key,
169 const char *value, const dbus_uint32_t value_len)
171 DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
174 if (!_wpa_dbus_add_dict_entry_start(iter_dict, &iter_dict_entry,
175 key, DBUS_TYPE_ARRAY))
178 if (!dbus_message_iter_open_container(&iter_dict_entry,
180 DBUS_TYPE_ARRAY_AS_STRING
181 DBUS_TYPE_BYTE_AS_STRING,
185 if (!dbus_message_iter_open_container(&iter_dict_val, DBUS_TYPE_ARRAY,
186 DBUS_TYPE_BYTE_AS_STRING,
190 for (i = 0; i < value_len; i++) {
191 if (!dbus_message_iter_append_basic(&iter_array,
197 if (!dbus_message_iter_close_container(&iter_dict_val, &iter_array))
200 if (!_wpa_dbus_add_dict_entry_end(iter_dict, &iter_dict_entry,
209 * Add a string entry to the dict.
211 * @param iter_dict A valid DBusMessageIter returned from
212 * wpa_dbus_dict_open_write()
213 * @param key The key of the dict item
214 * @param value The string value
215 * @return TRUE on success, FALSE on failure
218 dbus_bool_t wpa_dbus_dict_append_string(DBusMessageIter *iter_dict,
219 const char *key, const char *value)
223 return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_STRING,
229 * Add a byte entry to the dict.
231 * @param iter_dict A valid DBusMessageIter returned from
232 * wpa_dbus_dict_open_write()
233 * @param key The key of the dict item
234 * @param value The byte value
235 * @return TRUE on success, FALSE on failure
238 dbus_bool_t wpa_dbus_dict_append_byte(DBusMessageIter *iter_dict,
239 const char *key, const char value)
243 return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_BYTE,
249 * Add a boolean entry to the dict.
251 * @param iter_dict A valid DBusMessageIter returned from
252 * wpa_dbus_dict_open_write()
253 * @param key The key of the dict item
254 * @param value The boolean value
255 * @return TRUE on success, FALSE on failure
258 dbus_bool_t wpa_dbus_dict_append_bool(DBusMessageIter *iter_dict,
259 const char *key, const dbus_bool_t value)
263 return _wpa_dbus_add_dict_entry_basic(iter_dict, key,
264 DBUS_TYPE_BOOLEAN, &value);
269 * Add a 16-bit signed integer entry to the dict.
271 * @param iter_dict A valid DBusMessageIter returned from
272 * wpa_dbus_dict_open_write()
273 * @param key The key of the dict item
274 * @param value The 16-bit signed integer value
275 * @return TRUE on success, FALSE on failure
278 dbus_bool_t wpa_dbus_dict_append_int16(DBusMessageIter *iter_dict,
280 const dbus_int16_t value)
284 return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_INT16,
290 * Add a 16-bit unsigned integer entry to the dict.
292 * @param iter_dict A valid DBusMessageIter returned from
293 * wpa_dbus_dict_open_write()
294 * @param key The key of the dict item
295 * @param value The 16-bit unsigned integer value
296 * @return TRUE on success, FALSE on failure
299 dbus_bool_t wpa_dbus_dict_append_uint16(DBusMessageIter *iter_dict,
301 const dbus_uint16_t value)
305 return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_UINT16,
311 * Add a 32-bit signed integer to the dict.
313 * @param iter_dict A valid DBusMessageIter returned from
314 * wpa_dbus_dict_open_write()
315 * @param key The key of the dict item
316 * @param value The 32-bit signed integer value
317 * @return TRUE on success, FALSE on failure
320 dbus_bool_t wpa_dbus_dict_append_int32(DBusMessageIter *iter_dict,
322 const dbus_int32_t value)
326 return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_INT32,
332 * Add a 32-bit unsigned integer entry to the dict.
334 * @param iter_dict A valid DBusMessageIter returned from
335 * wpa_dbus_dict_open_write()
336 * @param key The key of the dict item
337 * @param value The 32-bit unsigned integer value
338 * @return TRUE on success, FALSE on failure
341 dbus_bool_t wpa_dbus_dict_append_uint32(DBusMessageIter *iter_dict,
343 const dbus_uint32_t value)
347 return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_UINT32,
353 * Add a 64-bit integer entry to the dict.
355 * @param iter_dict A valid DBusMessageIter returned from
356 * wpa_dbus_dict_open_write()
357 * @param key The key of the dict item
358 * @param value The 64-bit integer value
359 * @return TRUE on success, FALSE on failure
362 dbus_bool_t wpa_dbus_dict_append_int64(DBusMessageIter *iter_dict,
364 const dbus_int64_t value)
368 return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_INT64,
374 * Add a 64-bit unsigned integer entry to the dict.
376 * @param iter_dict A valid DBusMessageIter returned from
377 * wpa_dbus_dict_open_write()
378 * @param key The key of the dict item
379 * @param value The 64-bit unsigned integer value
380 * @return TRUE on success, FALSE on failure
383 dbus_bool_t wpa_dbus_dict_append_uint64(DBusMessageIter *iter_dict,
385 const dbus_uint64_t value)
389 return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_UINT64,
395 * Add a double-precision floating point entry to the dict.
397 * @param iter_dict A valid DBusMessageIter returned from
398 * wpa_dbus_dict_open_write()
399 * @param key The key of the dict item
400 * @param value The double-precision floating point value
401 * @return TRUE on success, FALSE on failure
404 dbus_bool_t wpa_dbus_dict_append_double(DBusMessageIter *iter_dict,
410 return _wpa_dbus_add_dict_entry_basic(iter_dict, key, DBUS_TYPE_DOUBLE,
416 * Add a DBus object path entry to the dict.
418 * @param iter_dict A valid DBusMessageIter returned from
419 * wpa_dbus_dict_open_write()
420 * @param key The key of the dict item
421 * @param value The DBus object path value
422 * @return TRUE on success, FALSE on failure
425 dbus_bool_t wpa_dbus_dict_append_object_path(DBusMessageIter *iter_dict,
431 return _wpa_dbus_add_dict_entry_basic(iter_dict, key,
432 DBUS_TYPE_OBJECT_PATH, &value);
437 * Add a byte array entry to the dict.
439 * @param iter_dict A valid DBusMessageIter returned from
440 * wpa_dbus_dict_open_write()
441 * @param key The key of the dict item
442 * @param value The byte array
443 * @param value_len The length of the byte array, in bytes
444 * @return TRUE on success, FALSE on failure
447 dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict,
450 const dbus_uint32_t value_len)
454 if (!value && (value_len != 0))
456 return _wpa_dbus_add_dict_entry_byte_array(iter_dict, key, value,
462 * Begin a string array entry in the dict
464 * @param iter_dict A valid DBusMessageIter returned from
465 * wpa_dbus_dict_open_write()
466 * @param key The key of the dict item
467 * @param iter_dict_entry A private DBusMessageIter provided by the caller to
468 * be passed to wpa_dbus_dict_end_string_array()
469 * @param iter_dict_val A private DBusMessageIter provided by the caller to
470 * be passed to wpa_dbus_dict_end_string_array()
471 * @param iter_array On return, the DBusMessageIter to be passed to
472 * wpa_dbus_dict_string_array_add_element()
473 * @return TRUE on success, FALSE on failure
476 dbus_bool_t wpa_dbus_dict_begin_string_array(DBusMessageIter *iter_dict,
478 DBusMessageIter *iter_dict_entry,
479 DBusMessageIter *iter_dict_val,
480 DBusMessageIter *iter_array)
482 if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array)
485 if (!_wpa_dbus_add_dict_entry_start(iter_dict, iter_dict_entry,
486 key, DBUS_TYPE_ARRAY))
489 if (!dbus_message_iter_open_container(iter_dict_entry,
491 DBUS_TYPE_ARRAY_AS_STRING
492 DBUS_TYPE_STRING_AS_STRING,
496 if (!dbus_message_iter_open_container(iter_dict_val, DBUS_TYPE_ARRAY,
497 DBUS_TYPE_BYTE_AS_STRING,
506 * Add a single string element to a string array dict entry
508 * @param iter_array A valid DBusMessageIter returned from
509 * wpa_dbus_dict_begin_string_array()'s
510 * iter_array parameter
511 * @param elem The string element to be added to the dict entry's string array
512 * @return TRUE on success, FALSE on failure
515 dbus_bool_t wpa_dbus_dict_string_array_add_element(DBusMessageIter *iter_array,
518 if (!iter_array || !elem)
521 return dbus_message_iter_append_basic(iter_array, DBUS_TYPE_STRING,
527 * End a string array dict entry
529 * @param iter_dict A valid DBusMessageIter returned from
530 * wpa_dbus_dict_open_write()
531 * @param iter_dict_entry A private DBusMessageIter returned from
532 * wpa_dbus_dict_end_string_array()
533 * @param iter_dict_val A private DBusMessageIter returned from
534 * wpa_dbus_dict_end_string_array()
535 * @param iter_array A DBusMessageIter returned from
536 * wpa_dbus_dict_end_string_array()
537 * @return TRUE on success, FALSE on failure
540 dbus_bool_t wpa_dbus_dict_end_string_array(DBusMessageIter *iter_dict,
541 DBusMessageIter *iter_dict_entry,
542 DBusMessageIter *iter_dict_val,
543 DBusMessageIter *iter_array)
545 if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array)
548 if (!dbus_message_iter_close_container(iter_dict_val, iter_array))
551 if (!_wpa_dbus_add_dict_entry_end(iter_dict, iter_dict_entry,
560 * Convenience function to add an entire string array to the dict.
562 * @param iter_dict A valid DBusMessageIter returned from
563 * wpa_dbus_dict_open_write()
564 * @param key The key of the dict item
565 * @param items The array of strings
566 * @param num_items The number of strings in the array
567 * @return TRUE on success, FALSE on failure
570 dbus_bool_t wpa_dbus_dict_append_string_array(DBusMessageIter *iter_dict,
573 const dbus_uint32_t num_items)
575 DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
580 if (!items && (num_items != 0))
583 if (!wpa_dbus_dict_begin_string_array(iter_dict, key,
584 &iter_dict_entry, &iter_dict_val,
588 for (i = 0; i < num_items; i++) {
589 if (!wpa_dbus_dict_string_array_add_element(&iter_array,
594 if (!wpa_dbus_dict_end_string_array(iter_dict, &iter_dict_entry,
595 &iter_dict_val, &iter_array))
602 /*****************************************************/
603 /* Stuff for reading dicts */
604 /*****************************************************/
607 * Start reading from a dbus dict.
609 * @param iter A valid DBusMessageIter pointing to the start of the dict
610 * @param iter_dict (out) A DBusMessageIter to be passed to
611 * wpa_dbus_dict_read_next_entry()
612 * @return TRUE on success, FALSE on failure
615 dbus_bool_t wpa_dbus_dict_open_read(DBusMessageIter *iter,
616 DBusMessageIter *iter_dict)
618 if (!iter || !iter_dict)
621 if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY ||
622 dbus_message_iter_get_element_type(iter) != DBUS_TYPE_DICT_ENTRY)
625 dbus_message_iter_recurse(iter, iter_dict);
630 #define BYTE_ARRAY_CHUNK_SIZE 34
631 #define BYTE_ARRAY_ITEM_SIZE (sizeof(char))
633 static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
634 DBusMessageIter *iter, int array_type,
635 struct wpa_dbus_dict_entry *entry)
637 dbus_uint32_t count = 0;
638 dbus_bool_t success = FALSE;
641 entry->bytearray_value = NULL;
642 entry->array_type = DBUS_TYPE_BYTE;
644 buffer = os_zalloc(BYTE_ARRAY_ITEM_SIZE * BYTE_ARRAY_CHUNK_SIZE);
646 perror("_wpa_dbus_dict_entry_get_byte_array[dbus]: out of "
651 entry->bytearray_value = buffer;
652 entry->array_len = 0;
653 while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_BYTE) {
656 if ((count % BYTE_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
657 buffer = os_realloc(buffer, BYTE_ARRAY_ITEM_SIZE *
658 (count + BYTE_ARRAY_CHUNK_SIZE));
659 if (buffer == NULL) {
660 perror("_wpa_dbus_dict_entry_get_byte_array["
661 "dbus] out of memory trying to "
662 "retrieve the string array");
666 entry->bytearray_value = buffer;
668 dbus_message_iter_get_basic(iter, &byte);
669 entry->bytearray_value[count] = byte;
670 entry->array_len = ++count;
671 dbus_message_iter_next(iter);
674 /* Zero-length arrays are valid. */
675 if (entry->array_len == 0) {
676 os_free(entry->bytearray_value);
677 entry->bytearray_value = NULL;
687 #define STR_ARRAY_CHUNK_SIZE 8
688 #define STR_ARRAY_ITEM_SIZE (sizeof(char *))
690 static dbus_bool_t _wpa_dbus_dict_entry_get_string_array(
691 DBusMessageIter *iter, int array_type,
692 struct wpa_dbus_dict_entry *entry)
694 dbus_uint32_t count = 0;
695 dbus_bool_t success = FALSE;
698 entry->strarray_value = NULL;
699 entry->array_type = DBUS_TYPE_STRING;
701 buffer = os_zalloc(STR_ARRAY_ITEM_SIZE * STR_ARRAY_CHUNK_SIZE);
702 if (buffer == NULL) {
703 perror("_wpa_dbus_dict_entry_get_string_array[dbus] out of "
704 "memory trying to retrieve a string array");
708 entry->strarray_value = buffer;
709 entry->array_len = 0;
710 while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRING) {
714 if ((count % STR_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
715 buffer = os_realloc(buffer, STR_ARRAY_ITEM_SIZE *
716 (count + STR_ARRAY_CHUNK_SIZE));
717 if (buffer == NULL) {
718 perror("_wpa_dbus_dict_entry_get_string_array["
719 "dbus] out of memory trying to "
720 "retrieve the string array");
724 entry->strarray_value = buffer;
726 dbus_message_iter_get_basic(iter, &value);
727 str = os_strdup(value);
729 perror("_wpa_dbus_dict_entry_get_string_array[dbus] "
730 "out of memory trying to duplicate the string "
734 entry->strarray_value[count] = str;
735 entry->array_len = ++count;
736 dbus_message_iter_next(iter);
739 /* Zero-length arrays are valid. */
740 if (entry->array_len == 0) {
741 os_free(entry->strarray_value);
742 entry->strarray_value = NULL;
752 static dbus_bool_t _wpa_dbus_dict_entry_get_array(
753 DBusMessageIter *iter_dict_val, struct wpa_dbus_dict_entry *entry)
755 int array_type = dbus_message_iter_get_element_type(iter_dict_val);
756 dbus_bool_t success = FALSE;
757 DBusMessageIter iter_array;
762 dbus_message_iter_recurse(iter_dict_val, &iter_array);
764 switch (array_type) {
766 success = _wpa_dbus_dict_entry_get_byte_array(&iter_array,
770 case DBUS_TYPE_STRING:
771 success = _wpa_dbus_dict_entry_get_string_array(&iter_array,
783 static dbus_bool_t _wpa_dbus_dict_fill_value_from_variant(
784 struct wpa_dbus_dict_entry *entry, DBusMessageIter *iter_dict_val)
786 dbus_bool_t success = TRUE;
788 switch (entry->type) {
789 case DBUS_TYPE_STRING: {
791 dbus_message_iter_get_basic(iter_dict_val, &v);
792 entry->str_value = os_strdup(v);
795 case DBUS_TYPE_BOOLEAN: {
797 dbus_message_iter_get_basic(iter_dict_val, &v);
798 entry->bool_value = v;
801 case DBUS_TYPE_BYTE: {
803 dbus_message_iter_get_basic(iter_dict_val, &v);
804 entry->byte_value = v;
807 case DBUS_TYPE_INT16: {
809 dbus_message_iter_get_basic(iter_dict_val, &v);
810 entry->int16_value = v;
813 case DBUS_TYPE_UINT16: {
815 dbus_message_iter_get_basic(iter_dict_val, &v);
816 entry->uint16_value = v;
819 case DBUS_TYPE_INT32: {
821 dbus_message_iter_get_basic(iter_dict_val, &v);
822 entry->int32_value = v;
825 case DBUS_TYPE_UINT32: {
827 dbus_message_iter_get_basic(iter_dict_val, &v);
828 entry->uint32_value = v;
831 case DBUS_TYPE_INT64: {
833 dbus_message_iter_get_basic(iter_dict_val, &v);
834 entry->int64_value = v;
837 case DBUS_TYPE_UINT64: {
839 dbus_message_iter_get_basic(iter_dict_val, &v);
840 entry->uint64_value = v;
843 case DBUS_TYPE_DOUBLE: {
845 dbus_message_iter_get_basic(iter_dict_val, &v);
846 entry->double_value = v;
849 case DBUS_TYPE_OBJECT_PATH: {
851 dbus_message_iter_get_basic(iter_dict_val, &v);
852 entry->str_value = os_strdup(v);
855 case DBUS_TYPE_ARRAY: {
856 success = _wpa_dbus_dict_entry_get_array(iter_dict_val, entry);
869 * Read the current key/value entry from the dict. Entries are dynamically
870 * allocated when needed and must be freed after use with the
871 * wpa_dbus_dict_entry_clear() function.
873 * The returned entry object will be filled with the type and value of the next
874 * entry in the dict, or the type will be DBUS_TYPE_INVALID if an error
877 * @param iter_dict A valid DBusMessageIter returned from
878 * wpa_dbus_dict_open_read()
879 * @param entry A valid dict entry object into which the dict key and value
881 * @return TRUE on success, FALSE on failure
884 dbus_bool_t wpa_dbus_dict_get_entry(DBusMessageIter *iter_dict,
885 struct wpa_dbus_dict_entry * entry)
887 DBusMessageIter iter_dict_entry, iter_dict_val;
891 if (!iter_dict || !entry)
894 if (dbus_message_iter_get_arg_type(iter_dict) != DBUS_TYPE_DICT_ENTRY)
897 dbus_message_iter_recurse(iter_dict, &iter_dict_entry);
898 dbus_message_iter_get_basic(&iter_dict_entry, &key);
901 if (!dbus_message_iter_next(&iter_dict_entry))
903 type = dbus_message_iter_get_arg_type(&iter_dict_entry);
904 if (type != DBUS_TYPE_VARIANT)
907 dbus_message_iter_recurse(&iter_dict_entry, &iter_dict_val);
908 entry->type = dbus_message_iter_get_arg_type(&iter_dict_val);
909 if (!_wpa_dbus_dict_fill_value_from_variant(entry, &iter_dict_val))
912 dbus_message_iter_next(iter_dict);
917 wpa_dbus_dict_entry_clear(entry);
918 entry->type = DBUS_TYPE_INVALID;
919 entry->array_type = DBUS_TYPE_INVALID;
927 * Return whether or not there are additional dictionary entries.
929 * @param iter_dict A valid DBusMessageIter returned from
930 * wpa_dbus_dict_open_read()
931 * @return TRUE if more dict entries exists, FALSE if no more dict entries
934 dbus_bool_t wpa_dbus_dict_has_dict_entry(DBusMessageIter *iter_dict)
937 perror("wpa_dbus_dict_has_dict_entry[dbus]: out of memory");
940 return dbus_message_iter_get_arg_type(iter_dict) ==
941 DBUS_TYPE_DICT_ENTRY;
946 * Free any memory used by the entry object.
948 * @param entry The entry object
950 void wpa_dbus_dict_entry_clear(struct wpa_dbus_dict_entry *entry)
956 switch (entry->type) {
957 case DBUS_TYPE_OBJECT_PATH:
958 case DBUS_TYPE_STRING:
959 os_free(entry->str_value);
961 case DBUS_TYPE_ARRAY:
962 switch (entry->array_type) {
964 os_free(entry->bytearray_value);
966 case DBUS_TYPE_STRING:
967 for (i = 0; i < entry->array_len; i++)
968 os_free(entry->strarray_value[i]);
969 os_free(entry->strarray_value);
975 memset(entry, 0, sizeof(struct wpa_dbus_dict_entry));