Allow libconfdb to run standalone (without aisexec)
[openais.git] / include / confdb.h
blob095e1e4a20ba47ae6ecd64ee886514f0df48546d
1 /*
2 * Copyright (c) 2008 Red Hat, Inc.
4 * All rights reserved.
6 * Author: Christine Caulfield (ccaulfi@redhat.com)
8 * This software licensed under BSD license, the text of which follows:
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
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.
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.
34 #ifndef OPENAIS_CONFDB_H_DEFINED
35 #define OPENAIS_CONFDB_H_DEFINED
37 /**
38 * @addtogroup confdb_openais
40 * @{
42 typedef uint64_t confdb_handle_t;
44 #define OBJECT_PARENT_HANDLE 0
46 typedef enum {
47 CONFDB_DISPATCH_ONE,
48 CONFDB_DISPATCH_ALL,
49 CONFDB_DISPATCH_BLOCKING
50 } confdb_dispatch_t;
52 typedef enum {
53 CONFDB_OK = 1,
54 CONFDB_ERR_LIBRARY = 2,
55 CONFDB_ERR_TIMEOUT = 5,
56 CONFDB_ERR_TRY_AGAIN = 6,
57 CONFDB_ERR_INVALID_PARAM = 7,
58 CONFDB_ERR_NO_MEMORY = 8,
59 CONFDB_ERR_BAD_HANDLE = 9,
60 CONFDB_ERR_ACCESS = 11,
61 CONFDB_ERR_NOT_EXIST = 12,
62 CONFDB_ERR_EXIST = 14,
63 CONFDB_ERR_CONTEXT_NOT_FOUND = 17,
64 CONFDB_ERR_NOT_SUPPORTED = 20,
65 CONFDB_ERR_SECURITY = 29,
66 } confdb_error_t;
69 typedef void (*confdb_change_notify_fn_t) (
70 confdb_handle_t handle,
71 unsigned int parent_object_handle,
72 unsigned int object_handle,
73 void *object_name,
74 int object_name_len,
75 void *key_name,
76 int key_name_len,
77 void *key_value,
78 int key_value_len);
80 typedef struct {
81 confdb_change_notify_fn_t confdb_change_notify_fn;
82 } confdb_callbacks_t;
84 /** @} */
87 * Create a new confdb connection
89 confdb_error_t confdb_initialize (
90 confdb_handle_t *handle,
91 confdb_callbacks_t *callbacks);
94 * Close the confdb handle
96 confdb_error_t confdb_finalize (
97 confdb_handle_t handle);
100 * Get a file descriptor on which to poll. confdb_handle_t is NOT a
101 * file descriptor and may not be used directly.
103 confdb_error_t confdb_fd_get (
104 confdb_handle_t handle,
105 int *fd);
108 * Dispatch configuration changes
110 confdb_error_t confdb_dispatch (
111 confdb_handle_t handle,
112 confdb_dispatch_t dispatch_types);
116 * Change notification
118 confdb_error_t confdb_track_changes (
119 confdb_handle_t handle,
120 unsigned int object_handle,
121 unsigned int flags);
123 confdb_error_t confdb_stop_track_changes (
124 confdb_handle_t handle);
127 * Manipulate objects
129 confdb_error_t confdb_object_create (
130 confdb_handle_t handle,
131 unsigned int parent_object_handle,
132 void *object_name,
133 int object_name_len,
134 unsigned int *object_handle);
136 confdb_error_t confdb_object_destroy (
137 confdb_handle_t handle,
138 unsigned int object_handle);
140 confdb_error_t confdb_object_parent_get (
141 confdb_handle_t handle,
142 unsigned int object_handle,
143 unsigned int *parent_object_handle);
146 * Manipulate keys
148 confdb_error_t confdb_key_create (
149 confdb_handle_t handle,
150 unsigned int parent_object_handle,
151 void *key_name,
152 int key_name_len,
153 void *value,
154 int value_len);
156 confdb_error_t confdb_key_delete (
157 confdb_handle_t handle,
158 unsigned int parent_object_handle,
159 void *key_name,
160 int key_name_len,
161 void *value,
162 int value_len);
165 * Key queries
167 confdb_error_t confdb_key_get (
168 confdb_handle_t handle,
169 unsigned int parent_object_handle,
170 void *key_name,
171 int key_name_len,
172 void *value,
173 int *value_len);
175 confdb_error_t confdb_key_replace (
176 confdb_handle_t handle,
177 unsigned int parent_object_handle,
178 void *key_name,
179 int key_name_len,
180 void *old_value,
181 int old_value_len,
182 void *new_value,
183 int new_value_len);
186 * Object queries
187 * "find" loops through all objects of a given name and is also
188 * a quick way of finding a specific object,
189 * "iter" returns ech object in sequence.
191 confdb_error_t confdb_object_find_start (
192 confdb_handle_t handle,
193 unsigned int parent_object_handle);
195 confdb_error_t confdb_object_find (
196 confdb_handle_t handle,
197 unsigned int parent_object_handle,
198 void *object_name,
199 int object_name_len,
200 unsigned int *object_handle);
202 confdb_error_t confdb_object_iter_start (
203 confdb_handle_t handle,
204 unsigned int parent_object_handle);
206 confdb_error_t confdb_object_iter (
207 confdb_handle_t handle,
208 unsigned int parent_object_handle,
209 unsigned int *object_handle,
210 void *object_name,
211 int *object_name_len);
214 * Key iterator
216 confdb_error_t confdb_key_iter_start (
217 confdb_handle_t handle,
218 unsigned int object_handle);
220 confdb_error_t confdb_key_iter (
221 confdb_handle_t handle,
222 unsigned int parent_object_handle,
223 void *key_name,
224 int *key_name_len,
225 void *value,
226 int *value_len);
229 #endif /* OPENAIS_CONFDB_H_DEFINED */