Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

dbus_dict_helpers.h 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * WPA Supplicant / dbus-based control interface
  3. * Copyright (c) 2006, Dan Williams <dcbw@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. #ifndef DBUS_DICT_HELPERS_H
  15. #define DBUS_DICT_HELPERS_H
  16. /*
  17. * Adding a dict to a DBusMessage
  18. */
  19. dbus_bool_t wpa_dbus_dict_open_write(DBusMessageIter *iter,
  20. DBusMessageIter *iter_dict);
  21. dbus_bool_t wpa_dbus_dict_close_write(DBusMessageIter *iter,
  22. DBusMessageIter *iter_dict);
  23. const char * wpa_dbus_type_as_string(const int type);
  24. dbus_bool_t wpa_dbus_dict_append_string(DBusMessageIter *iter_dict,
  25. const char *key, const char *value);
  26. dbus_bool_t wpa_dbus_dict_append_byte(DBusMessageIter *iter_dict,
  27. const char *key, const char value);
  28. dbus_bool_t wpa_dbus_dict_append_bool(DBusMessageIter *iter_dict,
  29. const char *key,
  30. const dbus_bool_t value);
  31. dbus_bool_t wpa_dbus_dict_append_int16(DBusMessageIter *iter_dict,
  32. const char *key,
  33. const dbus_int16_t value);
  34. dbus_bool_t wpa_dbus_dict_append_uint16(DBusMessageIter *iter_dict,
  35. const char *key,
  36. const dbus_uint16_t value);
  37. dbus_bool_t wpa_dbus_dict_append_int32(DBusMessageIter *iter_dict,
  38. const char *key,
  39. const dbus_int32_t value);
  40. dbus_bool_t wpa_dbus_dict_append_uint32(DBusMessageIter *iter_dict,
  41. const char *key,
  42. const dbus_uint32_t value);
  43. dbus_bool_t wpa_dbus_dict_append_int64(DBusMessageIter *iter_dict,
  44. const char *key,
  45. const dbus_int64_t value);
  46. dbus_bool_t wpa_dbus_dict_append_uint64(DBusMessageIter *iter_dict,
  47. const char *key,
  48. const dbus_uint64_t value);
  49. dbus_bool_t wpa_dbus_dict_append_double(DBusMessageIter *iter_dict,
  50. const char *key,
  51. const double value);
  52. dbus_bool_t wpa_dbus_dict_append_object_path(DBusMessageIter *iter_dict,
  53. const char *key,
  54. const char *value);
  55. dbus_bool_t wpa_dbus_dict_append_byte_array(DBusMessageIter *iter_dict,
  56. const char *key,
  57. const char *value,
  58. const dbus_uint32_t value_len);
  59. /* Manual construction and addition of string array elements */
  60. dbus_bool_t wpa_dbus_dict_begin_string_array(DBusMessageIter *iter_dict,
  61. const char *key,
  62. DBusMessageIter *iter_dict_entry,
  63. DBusMessageIter *iter_dict_val,
  64. DBusMessageIter *iter_array);
  65. dbus_bool_t wpa_dbus_dict_string_array_add_element(DBusMessageIter *iter_array,
  66. const char *elem);
  67. dbus_bool_t wpa_dbus_dict_end_string_array(DBusMessageIter *iter_dict,
  68. DBusMessageIter *iter_dict_entry,
  69. DBusMessageIter *iter_dict_val,
  70. DBusMessageIter *iter_array);
  71. /* Convenience function to add a whole string list */
  72. dbus_bool_t wpa_dbus_dict_append_string_array(DBusMessageIter *iter_dict,
  73. const char *key,
  74. const char **items,
  75. const dbus_uint32_t num_items);
  76. /*
  77. * Reading a dict from a DBusMessage
  78. */
  79. struct wpa_dbus_dict_entry {
  80. int type; /** the dbus type of the dict entry's value */
  81. int array_type; /** the dbus type of the array elements if the dict
  82. entry value contains an array */
  83. const char *key; /** key of the dict entry */
  84. /** Possible values of the property */
  85. union {
  86. char *str_value;
  87. char byte_value;
  88. dbus_bool_t bool_value;
  89. dbus_int16_t int16_value;
  90. dbus_uint16_t uint16_value;
  91. dbus_int32_t int32_value;
  92. dbus_uint32_t uint32_value;
  93. dbus_int64_t int64_value;
  94. dbus_uint64_t uint64_value;
  95. double double_value;
  96. char *bytearray_value;
  97. char **strarray_value;
  98. };
  99. dbus_uint32_t array_len; /** length of the array if the dict entry's
  100. value contains an array */
  101. };
  102. dbus_bool_t wpa_dbus_dict_open_read(DBusMessageIter *iter,
  103. DBusMessageIter *iter_dict);
  104. dbus_bool_t wpa_dbus_dict_get_entry(DBusMessageIter *iter_dict,
  105. struct wpa_dbus_dict_entry *entry);
  106. dbus_bool_t wpa_dbus_dict_has_dict_entry(DBusMessageIter *iter_dict);
  107. void wpa_dbus_dict_entry_clear(struct wpa_dbus_dict_entry *entry);
  108. #endif /* DBUS_DICT_HELPERS_H */