Home | History | Annotate | Download | only in wpa_supplicant
      1 /*
      2  * WPA Supplicant / dbus-based control interface
      3  * Copyright (c) 2006, Dan Williams <dcbw (at) redhat.com> and Red Hat, Inc.
      4  *
      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.
      8  *
      9  * Alternatively, this software may be distributed under the terms of BSD
     10  * license.
     11  *
     12  * See README and COPYING for more details.
     13  */
     14 
     15 #ifndef DBUS_DICT_HELPERS_H
     16 #define DBUS_DICT_HELPERS_H
     17 
     18 /*
     19  * Adding a dict to a DBusMessage
     20  */
     21 
     22 dbus_bool_t wpa_dbus_dict_open_write(DBusMessageIter *iter,
     23 				     DBusMessageIter *iter_dict);
     24 
     25 dbus_bool_t wpa_dbus_dict_close_write(DBusMessageIter *iter,
     26 				      DBusMessageIter *iter_dict);
     27 
     28 dbus_bool_t wpa_dbus_dict_append_string(DBusMessageIter *iter_dict,
     29 					const char *key, const char *value);
     30 
     31 dbus_bool_t wpa_dbus_dict_append_byte(DBusMessageIter *iter_dict,
     32 				      const char *key, const char value);
     33 
     34 dbus_bool_t wpa_dbus_dict_append_bool(DBusMessageIter *iter_dict,
     35 				      const char *key,
     36 				      const dbus_bool_t value);
     37 
     38 dbus_bool_t wpa_dbus_dict_append_int16(DBusMessageIter *iter_dict,
     39 				       const char *key,
     40 				       const dbus_int16_t value);
     41 
     42 dbus_bool_t wpa_dbus_dict_append_uint16(DBusMessageIter *iter_dict,
     43 					const char *key,
     44 					const dbus_uint16_t value);
     45 
     46 dbus_bool_t wpa_dbus_dict_append_int32(DBusMessageIter *iter_dict,
     47 				       const char *key,
     48 				       const dbus_int32_t value);
     49 
     50 dbus_bool_t wpa_dbus_dict_append_uint32(DBusMessageIter *iter_dict,
     51 					const char *key,
     52 					const dbus_uint32_t value);
     53 
     54 dbus_bool_t wpa_dbus_dict_append_int64(DBusMessageIter *iter_dict,
     55 				       const char *key,
     56 				       const dbus_int64_t value);
     57 
     58 dbus_bool_t wpa_dbus_dict_append_uint64(DBusMessageIter *iter_dict,
     59 					const char *key,
     60 					const dbus_uint64_t value);
     61 
     62 dbus_bool_t wpa_dbus_dict_append_double(DBusMessageIter *iter_dict,
     63 					const char *key,
     64 					const double value);
     65 
     66 dbus_bool_t wpa_dbus_dict_append_object_path(DBusMessageIter *iter_dict,
     67 					     const char *key,
     68 					     const char *value);
     69 
     70 dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict,
     71 					    const char *key,
     72 					    const char *value,
     73 					    const dbus_uint32_t value_len);
     74 
     75 /* Manual construction and addition of string array elements */
     76 dbus_bool_t wpa_dbus_dict_begin_string_array(DBusMessageIter *iter_dict,
     77                                              const char *key,
     78                                              DBusMessageIter *iter_dict_entry,
     79                                              DBusMessageIter *iter_dict_val,
     80                                              DBusMessageIter *iter_array);
     81 
     82 dbus_bool_t wpa_dbus_dict_string_array_add_element(DBusMessageIter *iter_array,
     83                                              const char *elem);
     84 
     85 dbus_bool_t wpa_dbus_dict_end_string_array(DBusMessageIter *iter_dict,
     86                                            DBusMessageIter *iter_dict_entry,
     87                                            DBusMessageIter *iter_dict_val,
     88                                            DBusMessageIter *iter_array);
     89 
     90 /* Convenience function to add a whole string list */
     91 dbus_bool_t wpa_dbus_dict_append_string_array(DBusMessageIter *iter_dict,
     92 					      const char *key,
     93 					      const char **items,
     94 					      const dbus_uint32_t num_items);
     95 
     96 /*
     97  * Reading a dict from a DBusMessage
     98  */
     99 
    100 struct wpa_dbus_dict_entry {
    101 	int type;         /** the dbus type of the dict entry's value */
    102 	int array_type;   /** the dbus type of the array elements if the dict
    103 			      entry value contains an array */
    104 	const char *key;  /** key of the dict entry */
    105 
    106 	/** Possible values of the property */
    107 	union {
    108 		char *str_value;
    109 		char byte_value;
    110 		dbus_bool_t bool_value;
    111 		dbus_int16_t int16_value;
    112 		dbus_uint16_t uint16_value;
    113 		dbus_int32_t int32_value;
    114 		dbus_uint32_t uint32_value;
    115 		dbus_int64_t int64_value;
    116 		dbus_uint64_t uint64_value;
    117 		double double_value;
    118 		char *bytearray_value;
    119 		char **strarray_value;
    120 	};
    121 	dbus_uint32_t array_len; /** length of the array if the dict entry's
    122 				     value contains an array */
    123 };
    124 
    125 dbus_bool_t wpa_dbus_dict_open_read(DBusMessageIter *iter,
    126 				    DBusMessageIter *iter_dict);
    127 
    128 dbus_bool_t wpa_dbus_dict_get_entry(DBusMessageIter *iter_dict,
    129 				    struct wpa_dbus_dict_entry *entry);
    130 
    131 dbus_bool_t wpa_dbus_dict_has_dict_entry(DBusMessageIter *iter_dict);
    132 
    133 void wpa_dbus_dict_entry_clear(struct wpa_dbus_dict_entry *entry);
    134 
    135 #endif  /* DBUS_DICT_HELPERS_H */
    136