Patch to remove segfault on the exiting of a service.
[openais.git] / include / confdb.h
blob831d982635c47550caa2696ce1ea8335455c2689
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);
101 * Write back the configuration
103 confdb_error_t confdb_write (
104 confdb_handle_t handle,
105 char *error_text);
108 * Get a file descriptor on which to poll. confdb_handle_t is NOT a
109 * file descriptor and may not be used directly.
111 confdb_error_t confdb_fd_get (
112 confdb_handle_t handle,
113 int *fd);
116 * Dispatch configuration changes
118 confdb_error_t confdb_dispatch (
119 confdb_handle_t handle,
120 confdb_dispatch_t dispatch_types);
124 * Change notification
126 confdb_error_t confdb_track_changes (
127 confdb_handle_t handle,
128 unsigned int object_handle,
129 unsigned int flags);
131 confdb_error_t confdb_stop_track_changes (
132 confdb_handle_t handle);
135 * Manipulate objects
137 confdb_error_t confdb_object_create (
138 confdb_handle_t handle,
139 unsigned int parent_object_handle,
140 void *object_name,
141 int object_name_len,
142 unsigned int *object_handle);
144 confdb_error_t confdb_object_destroy (
145 confdb_handle_t handle,
146 unsigned int object_handle);
148 confdb_error_t confdb_object_parent_get (
149 confdb_handle_t handle,
150 unsigned int object_handle,
151 unsigned int *parent_object_handle);
154 * Manipulate keys
156 confdb_error_t confdb_key_create (
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);
164 confdb_error_t confdb_key_delete (
165 confdb_handle_t handle,
166 unsigned int parent_object_handle,
167 void *key_name,
168 int key_name_len,
169 void *value,
170 int value_len);
173 * Key queries
175 confdb_error_t confdb_key_get (
176 confdb_handle_t handle,
177 unsigned int parent_object_handle,
178 void *key_name,
179 int key_name_len,
180 void *value,
181 int *value_len);
183 confdb_error_t confdb_key_replace (
184 confdb_handle_t handle,
185 unsigned int parent_object_handle,
186 void *key_name,
187 int key_name_len,
188 void *old_value,
189 int old_value_len,
190 void *new_value,
191 int new_value_len);
194 * Object queries
195 * "find" loops through all objects of a given name and is also
196 * a quick way of finding a specific object,
197 * "iter" returns ech object in sequence.
199 confdb_error_t confdb_object_find_start (
200 confdb_handle_t handle,
201 unsigned int parent_object_handle);
203 confdb_error_t confdb_object_find (
204 confdb_handle_t handle,
205 unsigned int parent_object_handle,
206 void *object_name,
207 int object_name_len,
208 unsigned int *object_handle);
210 confdb_error_t confdb_object_iter_start (
211 confdb_handle_t handle,
212 unsigned int parent_object_handle);
214 confdb_error_t confdb_object_iter (
215 confdb_handle_t handle,
216 unsigned int parent_object_handle,
217 unsigned int *object_handle,
218 void *object_name,
219 int *object_name_len);
222 * Key iterator
224 confdb_error_t confdb_key_iter_start (
225 confdb_handle_t handle,
226 unsigned int object_handle);
228 confdb_error_t confdb_key_iter (
229 confdb_handle_t handle,
230 unsigned int parent_object_handle,
231 void *key_name,
232 int *key_name_len,
233 void *value,
234 int *value_len);
237 #endif /* OPENAIS_CONFDB_H_DEFINED */