objdb.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * Copyright (c) 2006 MontaVista Software, Inc.
  3. * Copyright (c) 2007-2008 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@redhat.com)
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above copyright notice,
  15. * this list of conditions and the following disclaimer.
  16. * - Redistributions in binary form must reproduce the above copyright notice,
  17. * this list of conditions and the following disclaimer in the documentation
  18. * and/or other materials provided with the distribution.
  19. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  33. * THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef OBJDB_H_DEFINED
  36. #define OBJDB_H_DEFINED
  37. #define OBJECT_PARENT_HANDLE 0xFFFFFFFF00000000ULL
  38. #include <stdio.h>
  39. #include <corosync/hdb.h>
  40. typedef enum {
  41. OBJECT_TRACK_DEPTH_ONE,
  42. OBJECT_TRACK_DEPTH_RECURSIVE
  43. } object_track_depth_t;
  44. typedef enum {
  45. OBJECT_KEY_CREATED,
  46. OBJECT_KEY_REPLACED,
  47. OBJECT_KEY_DELETED
  48. } object_change_type_t;
  49. typedef enum {
  50. OBJDB_RELOAD_NOTIFY_START,
  51. OBJDB_RELOAD_NOTIFY_END,
  52. OBJDB_RELOAD_NOTIFY_FAILED
  53. } objdb_reload_notify_type_t;
  54. typedef void (*object_key_change_notify_fn_t)(
  55. object_change_type_t change_type,
  56. hdb_handle_t parent_object_handle,
  57. hdb_handle_t object_handle,
  58. void *object_name_pt, int object_name_len,
  59. void *key_name_pt, int key_len,
  60. void *key_value_pt, int key_value_len,
  61. void *priv_data_pt);
  62. typedef void (*object_create_notify_fn_t) (unsigned int parent_object_handle,
  63. hdb_handle_t object_handle,
  64. void *name_pt, int name_len,
  65. void *priv_data_pt);
  66. typedef void (*object_destroy_notify_fn_t) (unsigned int parent_object_handle,
  67. void *name_pt, int name_len,
  68. void *priv_data_pt);
  69. typedef void (*object_reload_notify_fn_t) (objdb_reload_notify_type_t, int flush,
  70. void *priv_data_pt);
  71. struct object_valid {
  72. char *object_name;
  73. int object_len;
  74. };
  75. struct object_key_valid {
  76. char *key_name;
  77. int key_len;
  78. int (*validate_callback) (void *key, int key_len, void *value, int value_len);
  79. };
  80. struct objdb_iface_ver0 {
  81. int (*objdb_init) (void);
  82. int (*object_create) (
  83. hdb_handle_t parent_object_handle,
  84. hdb_handle_t *object_handle,
  85. void *object_name,
  86. unsigned int object_name_len);
  87. int (*object_priv_set) (
  88. hdb_handle_t object_handle,
  89. void *priv);
  90. int (*object_key_create) (
  91. hdb_handle_t object_handle,
  92. void *key_name,
  93. int key_len,
  94. void *value,
  95. int value_len);
  96. int (*object_destroy) (
  97. hdb_handle_t object_handle);
  98. int (*object_valid_set) (
  99. hdb_handle_t object_handle,
  100. struct object_valid *object_valid_list,
  101. unsigned int object_valid_list_entries);
  102. int (*object_key_valid_set) (
  103. hdb_handle_t object_handle,
  104. struct object_key_valid *object_key_valid_list,
  105. unsigned int object_key_valid_list_entries);
  106. int (*object_find_create) (
  107. hdb_handle_t parent_object_handle,
  108. void *object_name,
  109. int object_name_len,
  110. hdb_handle_t *object_find_handle);
  111. int (*object_find_next) (
  112. hdb_handle_t object_find_handle,
  113. hdb_handle_t *object_handle);
  114. int (*object_find_destroy) (
  115. hdb_handle_t object_find_handle);
  116. int (*object_key_get) (
  117. hdb_handle_t object_handle,
  118. void *key_name,
  119. int key_len,
  120. void **value,
  121. int *value_len);
  122. int (*object_priv_get) (
  123. hdb_handle_t jobject_handle,
  124. void **priv);
  125. int (*object_key_replace) (
  126. hdb_handle_t object_handle,
  127. void *key_name,
  128. int key_len,
  129. void *new_value,
  130. int new_value_len);
  131. int (*object_key_delete) (
  132. hdb_handle_t object_handle,
  133. void *key_name,
  134. int key_len);
  135. int (*object_iter_reset) (
  136. hdb_handle_t parent_object_handle);
  137. int (*object_iter) (
  138. hdb_handle_t parent_object_handle,
  139. void **object_name,
  140. int *name_len,
  141. hdb_handle_t *object_handle);
  142. int (*object_key_iter_reset) (
  143. hdb_handle_t object_handle);
  144. int (*object_key_iter) (
  145. hdb_handle_t parent_object_handle,
  146. void **key_name,
  147. int *key_len,
  148. void **value,
  149. int *value_len);
  150. int (*object_parent_get) (
  151. hdb_handle_t object_handle,
  152. hdb_handle_t *parent_handle);
  153. int (*object_name_get) (
  154. hdb_handle_t object_handle,
  155. char *object_name,
  156. int *object_name_len);
  157. int (*object_dump) (
  158. hdb_handle_t object_handle,
  159. FILE *file);
  160. int (*object_key_iter_from) (
  161. hdb_handle_t parent_object_handle,
  162. hdb_handle_t start_pos,
  163. void **key_name,
  164. int *key_len,
  165. void **value,
  166. int *value_len);
  167. int (*object_track_start) (
  168. hdb_handle_t object_handle,
  169. object_track_depth_t depth,
  170. object_key_change_notify_fn_t key_change_notify_fn,
  171. object_create_notify_fn_t object_create_notify_fn,
  172. object_destroy_notify_fn_t object_destroy_notify_fn,
  173. object_reload_notify_fn_t object_reload_notify_fn,
  174. void * priv_data_pt);
  175. void (*object_track_stop) (
  176. object_key_change_notify_fn_t key_change_notify_fn,
  177. object_create_notify_fn_t object_create_notify_fn,
  178. object_destroy_notify_fn_t object_destroy_notify_fn,
  179. object_reload_notify_fn_t object_reload_notify_fn,
  180. void * priv_data_pt);
  181. int (*object_write_config) (char **error_string);
  182. int (*object_reload_config) (
  183. int flush,
  184. char **error_string);
  185. int (*object_key_increment) (
  186. hdb_handle_t object_handle,
  187. void *key_name,
  188. int key_len,
  189. unsigned int *value);
  190. int (*object_key_decrement) (
  191. hdb_handle_t object_handle,
  192. void *key_name,
  193. int key_len,
  194. unsigned int *value);
  195. };
  196. #endif /* OBJDB_H_DEFINED */