objdb.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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 0
  38. #include <stdio.h>
  39. typedef enum {
  40. OBJECT_TRACK_DEPTH_ONE,
  41. OBJECT_TRACK_DEPTH_RECURSIVE
  42. } object_track_depth_t;
  43. typedef enum {
  44. OBJECT_KEY_CREATED,
  45. OBJECT_KEY_REPLACED,
  46. OBJECT_KEY_DELETED
  47. } object_change_type_t;
  48. typedef void (*object_key_change_notify_fn_t)(object_change_type_t change_type,
  49. unsigned int parent_object_handle,
  50. unsigned int object_handle,
  51. void *object_name_pt, int object_name_len,
  52. void *key_name_pt, int key_len,
  53. void *key_value_pt, int key_value_len,
  54. void *priv_data_pt);
  55. typedef void (*object_create_notify_fn_t) (unsigned int parent_object_handle,
  56. unsigned int object_handle,
  57. void *name_pt, int name_len,
  58. void *priv_data_pt);
  59. typedef void (*object_destroy_notify_fn_t) (unsigned int parent_object_handle,
  60. void *name_pt, int name_len,
  61. void *priv_data_pt);
  62. struct object_valid {
  63. char *object_name;
  64. int object_len;
  65. };
  66. struct object_key_valid {
  67. char *key_name;
  68. int key_len;
  69. int (*validate_callback) (void *key, int key_len, void *value, int value_len);
  70. };
  71. struct objdb_iface_ver0 {
  72. int (*objdb_init) (void);
  73. int (*object_create) (
  74. unsigned int parent_object_handle,
  75. unsigned int *object_handle,
  76. void *object_name,
  77. unsigned int object_name_len);
  78. int (*object_priv_set) (
  79. unsigned int object_handle,
  80. void *priv);
  81. int (*object_key_create) (
  82. unsigned int object_handle,
  83. void *key_name,
  84. int key_len,
  85. void *value,
  86. int value_len);
  87. int (*object_destroy) (
  88. unsigned int object_handle);
  89. int (*object_valid_set) (
  90. unsigned int object_handle,
  91. struct object_valid *object_valid_list,
  92. unsigned int object_valid_list_entries);
  93. int (*object_key_valid_set) (
  94. unsigned int object_handle,
  95. struct object_key_valid *object_key_valid_list,
  96. unsigned int object_key_valid_list_entries);
  97. int (*object_find_create) (
  98. unsigned int parent_object_handle,
  99. void *object_name,
  100. int object_name_len,
  101. unsigned int *object_find_handle);
  102. int (*object_find_next) (
  103. unsigned int object_find_handle,
  104. unsigned int *object_handle);
  105. int (*object_find_destroy) (
  106. unsigned int object_find_handle);
  107. int (*object_key_get) (
  108. unsigned int object_handle,
  109. void *key_name,
  110. int key_len,
  111. void **value,
  112. int *value_len);
  113. int (*object_priv_get) (
  114. unsigned int jobject_handle,
  115. void **priv);
  116. int (*object_key_replace) (
  117. unsigned int object_handle,
  118. void *key_name,
  119. int key_len,
  120. void *old_value,
  121. int old_value_len,
  122. void *new_value,
  123. int new_value_len);
  124. int (*object_key_delete) (
  125. unsigned int object_handle,
  126. void *key_name,
  127. int key_len,
  128. void *value,
  129. int value_len);
  130. int (*object_iter_reset) (
  131. unsigned int parent_object_handle);
  132. int (*object_iter) (
  133. unsigned int parent_object_handle,
  134. void **object_name,
  135. int *name_len,
  136. unsigned int *object_handle);
  137. int (*object_key_iter_reset) (
  138. unsigned int object_handle);
  139. int (*object_key_iter) (
  140. unsigned int parent_object_handle,
  141. void **key_name,
  142. int *key_len,
  143. void **value,
  144. int *value_len);
  145. int (*object_parent_get) (
  146. unsigned int object_handle,
  147. unsigned int *parent_handle);
  148. int (*object_name_get) (
  149. unsigned int object_handle,
  150. char *object_name,
  151. int *object_name_len);
  152. int (*object_dump) (
  153. unsigned int object_handle,
  154. FILE *file);
  155. int (*object_key_iter_from) (
  156. unsigned int parent_object_handle,
  157. unsigned int start_pos,
  158. void **key_name,
  159. int *key_len,
  160. void **value,
  161. int *value_len);
  162. int (*object_track_start) (
  163. unsigned int object_handle,
  164. object_track_depth_t depth,
  165. object_key_change_notify_fn_t key_change_notify_fn,
  166. object_create_notify_fn_t object_create_notify_fn,
  167. object_destroy_notify_fn_t object_destroy_notify_fn,
  168. void * priv_data_pt);
  169. void (*object_track_stop) (
  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. void * priv_data_pt);
  174. int (*object_write_config) (char **error_string);
  175. int (*object_reload_config) (
  176. int flush,
  177. char **error_string);
  178. int (*object_key_increment) (
  179. unsigned int object_handle,
  180. void *key_name,
  181. int key_len,
  182. unsigned int *value);
  183. int (*object_key_decrement) (
  184. unsigned int object_handle,
  185. void *key_name,
  186. int key_len,
  187. unsigned int *value);
  188. };
  189. #endif /* OBJDB_H_DEFINED */