confdb.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. * Get a file descriptor on which to poll. confdb_handle_t is NOT a
  90. * file descriptor and may not be used directly.
  91. */
  92. confdb_error_t confdb_fd_get (
  93. confdb_handle_t handle,
  94. int *fd);
  95. /*
  96. * Dispatch configuration changes
  97. */
  98. confdb_error_t confdb_dispatch (
  99. confdb_handle_t handle,
  100. confdb_dispatch_t dispatch_types);
  101. /*
  102. * Change notification
  103. */
  104. confdb_error_t confdb_track_changes (
  105. confdb_handle_t handle,
  106. unsigned int object_handle,
  107. unsigned int flags);
  108. confdb_error_t confdb_stop_track_changes (
  109. confdb_handle_t handle);
  110. /*
  111. * Manipulate objects
  112. */
  113. confdb_error_t confdb_object_create (
  114. confdb_handle_t handle,
  115. unsigned int parent_object_handle,
  116. void *object_name,
  117. int object_name_len,
  118. unsigned int *object_handle);
  119. confdb_error_t confdb_object_destroy (
  120. confdb_handle_t handle,
  121. unsigned int object_handle);
  122. confdb_error_t confdb_object_parent_get (
  123. confdb_handle_t handle,
  124. unsigned int object_handle,
  125. unsigned int *parent_object_handle);
  126. /*
  127. * Manipulate keys
  128. */
  129. confdb_error_t confdb_key_create (
  130. confdb_handle_t handle,
  131. unsigned int parent_object_handle,
  132. void *key_name,
  133. int key_name_len,
  134. void *value,
  135. int value_len);
  136. confdb_error_t confdb_key_delete (
  137. confdb_handle_t handle,
  138. unsigned int parent_object_handle,
  139. void *key_name,
  140. int key_name_len,
  141. void *value,
  142. int value_len);
  143. /*
  144. * Key queries
  145. */
  146. confdb_error_t confdb_key_get (
  147. confdb_handle_t handle,
  148. unsigned int parent_object_handle,
  149. void *key_name,
  150. int key_name_len,
  151. void *value,
  152. int *value_len);
  153. confdb_error_t confdb_key_replace (
  154. confdb_handle_t handle,
  155. unsigned int parent_object_handle,
  156. void *key_name,
  157. int key_name_len,
  158. void *old_value,
  159. int old_value_len,
  160. void *new_value,
  161. int new_value_len);
  162. /*
  163. * Object queries
  164. * "find" loops through all objects of a given name and is also
  165. * a quick way of finding a specific object,
  166. * "iter" returns ech object in sequence.
  167. */
  168. confdb_error_t confdb_object_find_start (
  169. confdb_handle_t handle,
  170. unsigned int parent_object_handle);
  171. confdb_error_t confdb_object_find (
  172. confdb_handle_t handle,
  173. unsigned int parent_object_handle,
  174. void *object_name,
  175. int object_name_len,
  176. unsigned int *object_handle);
  177. confdb_error_t confdb_object_iter_start (
  178. confdb_handle_t handle,
  179. unsigned int parent_object_handle);
  180. confdb_error_t confdb_object_iter (
  181. confdb_handle_t handle,
  182. unsigned int parent_object_handle,
  183. unsigned int *object_handle,
  184. void *object_name,
  185. int *object_name_len);
  186. /*
  187. * Key iterator
  188. */
  189. confdb_error_t confdb_key_iter_start (
  190. confdb_handle_t handle,
  191. unsigned int object_handle);
  192. confdb_error_t confdb_key_iter (
  193. confdb_handle_t handle,
  194. unsigned int parent_object_handle,
  195. void *key_name,
  196. int *key_name_len,
  197. void *value,
  198. int *value_len);
  199. #endif /* OPENAIS_CONFDB_H_DEFINED */