confdb.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * Copyright (c) 2008 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Christine Caulfield (ccaulfi@redhat.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef OPENAIS_CONFDB_H_DEFINED
  35. #define OPENAIS_CONFDB_H_DEFINED
  36. /**
  37. * @addtogroup confdb_openais
  38. *
  39. * @{
  40. */
  41. typedef uint64_t confdb_handle_t;
  42. #define OBJECT_PARENT_HANDLE 0
  43. typedef enum {
  44. CONFDB_DISPATCH_ONE,
  45. CONFDB_DISPATCH_ALL,
  46. CONFDB_DISPATCH_BLOCKING
  47. } confdb_dispatch_t;
  48. typedef enum {
  49. CONFDB_OK = 1,
  50. CONFDB_ERR_LIBRARY = 2,
  51. CONFDB_ERR_TIMEOUT = 5,
  52. CONFDB_ERR_TRY_AGAIN = 6,
  53. CONFDB_ERR_INVALID_PARAM = 7,
  54. CONFDB_ERR_NO_MEMORY = 8,
  55. CONFDB_ERR_BAD_HANDLE = 9,
  56. CONFDB_ERR_ACCESS = 11,
  57. CONFDB_ERR_NOT_EXIST = 12,
  58. CONFDB_ERR_EXIST = 14,
  59. CONFDB_ERR_CONTEXT_NOT_FOUND = 17,
  60. CONFDB_ERR_NOT_SUPPORTED = 20,
  61. CONFDB_ERR_SECURITY = 29,
  62. } confdb_error_t;
  63. typedef void (*confdb_change_notify_fn_t) (
  64. confdb_handle_t handle,
  65. unsigned int parent_object_handle,
  66. unsigned int object_handle,
  67. void *object_name,
  68. int object_name_len,
  69. void *key_name,
  70. int key_name_len,
  71. void *key_value,
  72. int key_value_len);
  73. typedef struct {
  74. confdb_change_notify_fn_t confdb_change_notify_fn;
  75. } confdb_callbacks_t;
  76. /** @} */
  77. /*
  78. * Create a new confdb connection
  79. */
  80. confdb_error_t confdb_initialize (
  81. confdb_handle_t *handle,
  82. confdb_callbacks_t *callbacks);
  83. /*
  84. * Close the confdb handle
  85. */
  86. confdb_error_t confdb_finalize (
  87. confdb_handle_t handle);
  88. /*
  89. * Write back the configuration
  90. */
  91. confdb_error_t confdb_write (
  92. confdb_handle_t handle,
  93. char *error_text);
  94. /*
  95. * Get a file descriptor on which to poll. confdb_handle_t is NOT a
  96. * file descriptor and may not be used directly.
  97. */
  98. confdb_error_t confdb_fd_get (
  99. confdb_handle_t handle,
  100. int *fd);
  101. /*
  102. * Dispatch configuration changes
  103. */
  104. confdb_error_t confdb_dispatch (
  105. confdb_handle_t handle,
  106. confdb_dispatch_t dispatch_types);
  107. /*
  108. * Change notification
  109. */
  110. confdb_error_t confdb_track_changes (
  111. confdb_handle_t handle,
  112. unsigned int object_handle,
  113. unsigned int flags);
  114. confdb_error_t confdb_stop_track_changes (
  115. confdb_handle_t handle);
  116. /*
  117. * Manipulate objects
  118. */
  119. confdb_error_t confdb_object_create (
  120. confdb_handle_t handle,
  121. unsigned int parent_object_handle,
  122. void *object_name,
  123. int object_name_len,
  124. unsigned int *object_handle);
  125. confdb_error_t confdb_object_destroy (
  126. confdb_handle_t handle,
  127. unsigned int object_handle);
  128. confdb_error_t confdb_object_parent_get (
  129. confdb_handle_t handle,
  130. unsigned int object_handle,
  131. unsigned int *parent_object_handle);
  132. /*
  133. * Manipulate keys
  134. */
  135. confdb_error_t confdb_key_create (
  136. confdb_handle_t handle,
  137. unsigned int parent_object_handle,
  138. void *key_name,
  139. int key_name_len,
  140. void *value,
  141. int value_len);
  142. confdb_error_t confdb_key_delete (
  143. confdb_handle_t handle,
  144. unsigned int parent_object_handle,
  145. void *key_name,
  146. int key_name_len,
  147. void *value,
  148. int value_len);
  149. /*
  150. * Key queries
  151. */
  152. confdb_error_t confdb_key_get (
  153. confdb_handle_t handle,
  154. unsigned int parent_object_handle,
  155. void *key_name,
  156. int key_name_len,
  157. void *value,
  158. int *value_len);
  159. confdb_error_t confdb_key_replace (
  160. confdb_handle_t handle,
  161. unsigned int parent_object_handle,
  162. void *key_name,
  163. int key_name_len,
  164. void *old_value,
  165. int old_value_len,
  166. void *new_value,
  167. int new_value_len);
  168. /*
  169. * Object queries
  170. * "find" loops through all objects of a given name and is also
  171. * a quick way of finding a specific object,
  172. * "iter" returns ech object in sequence.
  173. */
  174. confdb_error_t confdb_object_find_start (
  175. confdb_handle_t handle,
  176. unsigned int parent_object_handle);
  177. confdb_error_t confdb_object_find (
  178. confdb_handle_t handle,
  179. unsigned int parent_object_handle,
  180. void *object_name,
  181. int object_name_len,
  182. unsigned int *object_handle);
  183. confdb_error_t confdb_object_iter_start (
  184. confdb_handle_t handle,
  185. unsigned int parent_object_handle);
  186. confdb_error_t confdb_object_iter (
  187. confdb_handle_t handle,
  188. unsigned int parent_object_handle,
  189. unsigned int *object_handle,
  190. void *object_name,
  191. int *object_name_len);
  192. /*
  193. * Key iterator
  194. */
  195. confdb_error_t confdb_key_iter_start (
  196. confdb_handle_t handle,
  197. unsigned int object_handle);
  198. confdb_error_t confdb_key_iter (
  199. confdb_handle_t handle,
  200. unsigned int parent_object_handle,
  201. void *key_name,
  202. int *key_name_len,
  203. void *value,
  204. int *value_len);
  205. #endif /* OPENAIS_CONFDB_H_DEFINED */