settings.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. *
  3. * Embedded Linux library
  4. *
  5. * Copyright (C) 2011-2014 Intel Corporation. All rights reserved.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. #ifndef __ELL_SETTINGS_H
  23. #define __ELL_SETTINGS_H
  24. #include <stdbool.h>
  25. #include <stddef.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. struct l_settings;
  30. typedef void (*l_settings_debug_cb_t) (const char *str, void *user_data);
  31. typedef void (*l_settings_destroy_cb_t) (void *user_data);
  32. struct l_settings *l_settings_new(void);
  33. void l_settings_free(struct l_settings *settings);
  34. bool l_settings_load_from_data(struct l_settings *settings,
  35. const char *data, size_t len);
  36. char *l_settings_to_data(const struct l_settings *settings, size_t *len);
  37. bool l_settings_load_from_file(struct l_settings *settings,
  38. const char *filename);
  39. bool l_settings_set_debug(struct l_settings *settings,
  40. l_settings_debug_cb_t callback,
  41. void *user_data,
  42. l_settings_destroy_cb_t destroy);
  43. char **l_settings_get_groups(const struct l_settings *settings);
  44. char **l_settings_get_keys(const struct l_settings *settings,
  45. const char *group_name);
  46. bool l_settings_add_group(struct l_settings *settings, const char *group_name);
  47. bool l_settings_has_group(const struct l_settings *settings,
  48. const char *group_name);
  49. bool l_settings_has_key(const struct l_settings *settings,
  50. const char *group_name, const char *key);
  51. const char *l_settings_get_value(const struct l_settings *settings,
  52. const char *group_name,
  53. const char *key);
  54. bool l_settings_set_value(struct l_settings *settings, const char *group_name,
  55. const char *key, const char *value);
  56. bool l_settings_get_bool(const struct l_settings *settings,
  57. const char *group_name,
  58. const char *key, bool *out);
  59. bool l_settings_set_bool(struct l_settings *settings, const char *group_name,
  60. const char *key, bool in);
  61. bool l_settings_get_int(const struct l_settings *settings,
  62. const char *group_name, const char *key, int *out);
  63. bool l_settings_set_int(struct l_settings *settings, const char *group_name,
  64. const char *key, int in);
  65. bool l_settings_get_uint(const struct l_settings *settings,
  66. const char *group_name,
  67. const char *key, unsigned int *out);
  68. bool l_settings_set_uint(struct l_settings *settings, const char *group_name,
  69. const char *key, unsigned int in);
  70. bool l_settings_get_int64(const struct l_settings *settings,
  71. const char *group_name,
  72. const char *key, int64_t *out);
  73. bool l_settings_set_int64(struct l_settings *settings, const char *group_name,
  74. const char *key, int64_t in);
  75. bool l_settings_get_uint64(const struct l_settings *settings,
  76. const char *group_name,
  77. const char *key, uint64_t *out);
  78. bool l_settings_set_uint64(struct l_settings *settings, const char *group_name,
  79. const char *key, uint64_t in);
  80. char *l_settings_get_string(const struct l_settings *settings,
  81. const char *group_name, const char *key);
  82. bool l_settings_set_string(struct l_settings *settings, const char *group_name,
  83. const char *key, const char *value);
  84. char **l_settings_get_string_list(const struct l_settings *settings,
  85. const char *group_name,
  86. const char *key, char delimiter);
  87. bool l_settings_set_string_list(struct l_settings *settings,
  88. const char *group_name,
  89. const char *key, char **list,
  90. char delimiter);
  91. bool l_settings_get_double(const struct l_settings *settings,
  92. const char *group_name,
  93. const char *key, double *out);
  94. bool l_settings_set_double(struct l_settings *settings, const char *group_name,
  95. const char *key, double in);
  96. bool l_settings_get_float(const struct l_settings *settings,
  97. const char *group_name,
  98. const char *key, float *out);
  99. bool l_settings_set_float(struct l_settings *settings, const char *group_name,
  100. const char *key, float in);
  101. uint8_t *l_settings_get_bytes(const struct l_settings *settings,
  102. const char *group_name, const char *key,
  103. size_t *out_len);
  104. bool l_settings_set_bytes(struct l_settings *settings, const char *group_name,
  105. const char *key,
  106. const uint8_t *value, size_t value_len);
  107. bool l_settings_remove_key(struct l_settings *settings, const char *group_name,
  108. const char *key);
  109. bool l_settings_remove_group(struct l_settings *settings,
  110. const char *group_name);
  111. char **l_settings_get_embedded_groups(struct l_settings *settings);
  112. bool l_settings_has_embedded_group(struct l_settings *settings,
  113. const char *group);
  114. const char *l_settings_get_embedded_value(struct l_settings *settings,
  115. const char *group_name,
  116. const char **out_type);
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif /* __ELL_SETTINGS_H */