objdb.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (c) 2006 MontaVista Software, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@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 OBJDB_H_DEFINED
  35. #define OBJDB_H_DEFINED
  36. #define OBJECT_PARENT_HANDLE 0
  37. #include <stdio.h>
  38. struct object_valid {
  39. char *object_name;
  40. int object_len;
  41. };
  42. struct object_key_valid {
  43. char *key_name;
  44. int key_len;
  45. int (*validate_callback) (void *key, int key_len, void *value, int value_len);
  46. };
  47. struct objdb_iface_ver0 {
  48. int (*objdb_init) (void);
  49. int (*object_create) (
  50. unsigned int parent_object_handle,
  51. unsigned int *object_handle,
  52. void *object_name,
  53. unsigned int object_name_len);
  54. int (*object_priv_set) (
  55. unsigned int object_handle,
  56. void *priv);
  57. int (*object_key_create) (
  58. unsigned int object_handle,
  59. void *key_name,
  60. int key_len,
  61. void *value,
  62. int value_len);
  63. int (*object_destroy) (
  64. unsigned int object_handle);
  65. int (*object_valid_set) (
  66. unsigned int object_handle,
  67. struct object_valid *object_valid_list,
  68. unsigned int object_valid_list_entries);
  69. int (*object_key_valid_set) (
  70. unsigned int object_handle,
  71. struct object_key_valid *object_key_valid_list,
  72. unsigned int object_key_valid_list_entries);
  73. int (*object_find_reset) (
  74. unsigned int parent_object_handle);
  75. int (*object_find) (
  76. unsigned int parent_object_handle,
  77. void *object_name,
  78. int object_name_len,
  79. unsigned int *object_handle);
  80. int (*object_key_get) (
  81. unsigned int object_handle,
  82. void *key_name,
  83. int key_len,
  84. void **value,
  85. int *value_len);
  86. int (*object_priv_get) (
  87. unsigned int jobject_handle,
  88. void **priv);
  89. int (*object_key_replace) (
  90. unsigned int object_handle,
  91. void *key_name,
  92. int key_len,
  93. void *old_value,
  94. int old_value_len,
  95. void *new_value,
  96. int new_value_len);
  97. int (*object_key_delete) (
  98. unsigned int object_handle,
  99. void *key_name,
  100. int key_len,
  101. void *value,
  102. int value_len);
  103. int (*object_iter_reset) (
  104. unsigned int parent_object_handle);
  105. int (*object_iter) (
  106. unsigned int parent_object_handle,
  107. void **object_name,
  108. int *name_len,
  109. unsigned int *object_handle);
  110. int (*object_key_iter_reset) (
  111. unsigned int object_handle);
  112. int (*object_key_iter) (
  113. unsigned int parent_object_handle,
  114. void **key_name,
  115. int *key_len,
  116. void **value,
  117. int *value_len);
  118. int (*object_parent_get) (
  119. unsigned int object_handle,
  120. unsigned int *parent_handle);
  121. int (*object_dump) (
  122. unsigned int object_handle,
  123. FILE *file);
  124. int (*object_find_from) (
  125. unsigned int parent_object_handle,
  126. unsigned int start_pos,
  127. void *object_name,
  128. int object_name_len,
  129. unsigned int *object_handle,
  130. unsigned int *next_pos);
  131. int (*object_iter_from) (
  132. unsigned int parent_object_handle,
  133. unsigned int start_pos,
  134. void **object_name,
  135. int *name_len,
  136. unsigned int *object_handle);
  137. int (*object_key_iter_from) (
  138. unsigned int parent_object_handle,
  139. unsigned int start_pos,
  140. void **key_name,
  141. int *key_len,
  142. void **value,
  143. int *value_len);
  144. int (*object_write_config) (char **error_string);
  145. };
  146. #endif /* OBJDB_H_DEFINED */