diff options
Diffstat (limited to 'src/include/gnunet_configuration_lib.h')
-rw-r--r-- | src/include/gnunet_configuration_lib.h | 188 |
1 files changed, 99 insertions, 89 deletions
diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h index 24705f0fb..7167d8bd6 100644 --- a/src/include/gnunet_configuration_lib.h +++ b/src/include/gnunet_configuration_lib.h | |||
@@ -49,7 +49,8 @@ struct GNUNET_CONFIGURATION_Handle; | |||
49 | * Create a new configuration object. | 49 | * Create a new configuration object. |
50 | * @return fresh configuration object | 50 | * @return fresh configuration object |
51 | */ | 51 | */ |
52 | struct GNUNET_CONFIGURATION_Handle *GNUNET_CONFIGURATION_create (void); | 52 | struct GNUNET_CONFIGURATION_Handle * |
53 | GNUNET_CONFIGURATION_create (void); | ||
53 | 54 | ||
54 | 55 | ||
55 | /** | 56 | /** |
@@ -58,9 +59,8 @@ struct GNUNET_CONFIGURATION_Handle *GNUNET_CONFIGURATION_create (void); | |||
58 | * @param cfg configuration to duplicate | 59 | * @param cfg configuration to duplicate |
59 | * @return duplicate configuration | 60 | * @return duplicate configuration |
60 | */ | 61 | */ |
61 | struct GNUNET_CONFIGURATION_Handle *GNUNET_CONFIGURATION_dup (const struct | 62 | struct GNUNET_CONFIGURATION_Handle * |
62 | GNUNET_CONFIGURATION_Handle | 63 | GNUNET_CONFIGURATION_dup (const struct GNUNET_CONFIGURATION_Handle *cfg); |
63 | *cfg); | ||
64 | 64 | ||
65 | 65 | ||
66 | /** | 66 | /** |
@@ -68,7 +68,8 @@ struct GNUNET_CONFIGURATION_Handle *GNUNET_CONFIGURATION_dup (const struct | |||
68 | * | 68 | * |
69 | * @param cfg configuration to destroy | 69 | * @param cfg configuration to destroy |
70 | */ | 70 | */ |
71 | void GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg); | 71 | void |
72 | GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg); | ||
72 | 73 | ||
73 | 74 | ||
74 | /** | 75 | /** |
@@ -80,8 +81,9 @@ void GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg); | |||
80 | * @param filename name of the configuration file, NULL to load defaults | 81 | * @param filename name of the configuration file, NULL to load defaults |
81 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 82 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
82 | */ | 83 | */ |
83 | int GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | 84 | int |
84 | const char *filename); | 85 | GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, |
86 | const char *filename); | ||
85 | 87 | ||
86 | 88 | ||
87 | /** | 89 | /** |
@@ -92,8 +94,9 @@ int GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
92 | * @param filename name of the configuration file | 94 | * @param filename name of the configuration file |
93 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 95 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
94 | */ | 96 | */ |
95 | int GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | 97 | int |
96 | const char *filename); | 98 | GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, |
99 | const char *filename); | ||
97 | 100 | ||
98 | 101 | ||
99 | /** | 102 | /** |
@@ -103,8 +106,9 @@ int GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
103 | * @param filename where to write the configuration | 106 | * @param filename where to write the configuration |
104 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 107 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
105 | */ | 108 | */ |
106 | int GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, | 109 | int |
107 | const char *filename); | 110 | GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, |
111 | const char *filename); | ||
108 | 112 | ||
109 | /** | 113 | /** |
110 | * Write only configuration entries that have been changed to configuration file | 114 | * Write only configuration entries that have been changed to configuration file |
@@ -113,10 +117,11 @@ int GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
113 | * @param filename where to write the configuration diff between default and new | 117 | * @param filename where to write the configuration diff between default and new |
114 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 118 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
115 | */ | 119 | */ |
116 | int GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle | 120 | int |
117 | *cfgDefault, | 121 | GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle |
118 | const struct GNUNET_CONFIGURATION_Handle | 122 | *cfgDefault, |
119 | *cfgNew, const char *filename); | 123 | const struct GNUNET_CONFIGURATION_Handle |
124 | *cfgNew, const char *filename); | ||
120 | 125 | ||
121 | /** | 126 | /** |
122 | * Test if there are configuration options that were | 127 | * Test if there are configuration options that were |
@@ -125,8 +130,8 @@ int GNUNET_CONFIGURATION_write_diffs (const struct GNUNET_CONFIGURATION_Handle | |||
125 | * @param cfg configuration to inspect | 130 | * @param cfg configuration to inspect |
126 | * @return GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on error (i.e. last save failed) | 131 | * @return GNUNET_NO if clean, GNUNET_YES if dirty, GNUNET_SYSERR on error (i.e. last save failed) |
127 | */ | 132 | */ |
128 | int GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle | 133 | int |
129 | *cfg); | 134 | GNUNET_CONFIGURATION_is_dirty (const struct GNUNET_CONFIGURATION_Handle *cfg); |
130 | 135 | ||
131 | 136 | ||
132 | /** | 137 | /** |
@@ -159,9 +164,10 @@ typedef void (*GNUNET_CONFIGURATION_Section_Iterator) (void *cls, | |||
159 | * @param iter function to call on each option | 164 | * @param iter function to call on each option |
160 | * @param iter_cls closure for iter | 165 | * @param iter_cls closure for iter |
161 | */ | 166 | */ |
162 | void GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle | 167 | void |
163 | *cfg, GNUNET_CONFIGURATION_Iterator iter, | 168 | GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg, |
164 | void *iter_cls); | 169 | GNUNET_CONFIGURATION_Iterator iter, |
170 | void *iter_cls); | ||
165 | 171 | ||
166 | 172 | ||
167 | /** | 173 | /** |
@@ -171,10 +177,11 @@ void GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle | |||
171 | * @param iter function to call on each section | 177 | * @param iter function to call on each section |
172 | * @param iter_cls closure for iter | 178 | * @param iter_cls closure for iter |
173 | */ | 179 | */ |
174 | void GNUNET_CONFIGURATION_iterate_sections (const struct | 180 | void |
175 | GNUNET_CONFIGURATION_Handle *cfg, | 181 | GNUNET_CONFIGURATION_iterate_sections (const struct GNUNET_CONFIGURATION_Handle |
176 | GNUNET_CONFIGURATION_Section_Iterator | 182 | *cfg, |
177 | iter, void *iter_cls); | 183 | GNUNET_CONFIGURATION_Section_Iterator |
184 | iter, void *iter_cls); | ||
178 | 185 | ||
179 | 186 | ||
180 | /** | 187 | /** |
@@ -183,8 +190,9 @@ void GNUNET_CONFIGURATION_iterate_sections (const struct | |||
183 | * @param cfg configuration to inspect | 190 | * @param cfg configuration to inspect |
184 | * @param section name of the section to remove | 191 | * @param section name of the section to remove |
185 | */ | 192 | */ |
186 | void GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle | 193 | void |
187 | *cfg, const char *section); | 194 | GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle *cfg, |
195 | const char *section); | ||
188 | 196 | ||
189 | /** | 197 | /** |
190 | * Get a configuration value that should be a number. | 198 | * Get a configuration value that should be a number. |
@@ -195,11 +203,11 @@ void GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle | |||
195 | * @param number where to store the numeric value of the option | 203 | * @param number where to store the numeric value of the option |
196 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 204 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
197 | */ | 205 | */ |
198 | int GNUNET_CONFIGURATION_get_value_number (const struct | 206 | int |
199 | GNUNET_CONFIGURATION_Handle *cfg, | 207 | GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle |
200 | const char *section, | 208 | *cfg, const char *section, |
201 | const char *option, | 209 | const char *option, |
202 | unsigned long long *number); | 210 | unsigned long long *number); |
203 | 211 | ||
204 | 212 | ||
205 | /** | 213 | /** |
@@ -211,11 +219,11 @@ int GNUNET_CONFIGURATION_get_value_number (const struct | |||
211 | * @param time set to the time value stored in the configuration | 219 | * @param time set to the time value stored in the configuration |
212 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 220 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
213 | */ | 221 | */ |
214 | int GNUNET_CONFIGURATION_get_value_time (const struct | 222 | int |
215 | GNUNET_CONFIGURATION_Handle *cfg, | 223 | GNUNET_CONFIGURATION_get_value_time (const struct GNUNET_CONFIGURATION_Handle |
216 | const char *section, | 224 | *cfg, const char *section, |
217 | const char *option, | 225 | const char *option, |
218 | struct GNUNET_TIME_Relative *time); | 226 | struct GNUNET_TIME_Relative *time); |
219 | 227 | ||
220 | 228 | ||
221 | /** | 229 | /** |
@@ -226,9 +234,9 @@ int GNUNET_CONFIGURATION_get_value_time (const struct | |||
226 | * @param option option of interest | 234 | * @param option option of interest |
227 | * @return GNUNET_YES if so, GNUNET_NO if not. | 235 | * @return GNUNET_YES if so, GNUNET_NO if not. |
228 | */ | 236 | */ |
229 | int GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle | 237 | int |
230 | *cfg, const char *section, | 238 | GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, |
231 | const char *option); | 239 | const char *section, const char *option); |
232 | 240 | ||
233 | 241 | ||
234 | /** | 242 | /** |
@@ -241,10 +249,10 @@ int GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle | |||
241 | * value, or NULL if option is not specified | 249 | * value, or NULL if option is not specified |
242 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 250 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
243 | */ | 251 | */ |
244 | int GNUNET_CONFIGURATION_get_value_string (const struct | 252 | int |
245 | GNUNET_CONFIGURATION_Handle *cfg, | 253 | GNUNET_CONFIGURATION_get_value_string (const struct GNUNET_CONFIGURATION_Handle |
246 | const char *section, | 254 | *cfg, const char *section, |
247 | const char *option, char **value); | 255 | const char *option, char **value); |
248 | 256 | ||
249 | 257 | ||
250 | /** | 258 | /** |
@@ -258,10 +266,11 @@ int GNUNET_CONFIGURATION_get_value_string (const struct | |||
258 | * value, or NULL if option is not specified | 266 | * value, or NULL if option is not specified |
259 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 267 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
260 | */ | 268 | */ |
261 | int GNUNET_CONFIGURATION_get_value_filename (const struct | 269 | int |
262 | GNUNET_CONFIGURATION_Handle *cfg, | 270 | GNUNET_CONFIGURATION_get_value_filename (const struct |
263 | const char *section, | 271 | GNUNET_CONFIGURATION_Handle *cfg, |
264 | const char *option, char **value); | 272 | const char *section, |
273 | const char *option, char **value); | ||
265 | 274 | ||
266 | /** | 275 | /** |
267 | * Iterate over the set of filenames stored in a configuration value. | 276 | * Iterate over the set of filenames stored in a configuration value. |
@@ -273,12 +282,13 @@ int GNUNET_CONFIGURATION_get_value_filename (const struct | |||
273 | * @param cb_cls closure for cb | 282 | * @param cb_cls closure for cb |
274 | * @return number of filenames iterated over, -1 on error | 283 | * @return number of filenames iterated over, -1 on error |
275 | */ | 284 | */ |
276 | int GNUNET_CONFIGURATION_iterate_value_filenames (const struct | 285 | int |
277 | GNUNET_CONFIGURATION_Handle | 286 | GNUNET_CONFIGURATION_iterate_value_filenames (const struct |
278 | *cfg, const char *section, | 287 | GNUNET_CONFIGURATION_Handle *cfg, |
279 | const char *option, | 288 | const char *section, |
280 | GNUNET_FileNameCallback cb, | 289 | const char *option, |
281 | void *cb_cls); | 290 | GNUNET_FileNameCallback cb, |
291 | void *cb_cls); | ||
282 | 292 | ||
283 | /** | 293 | /** |
284 | * Iterate over values of a section in the configuration. | 294 | * Iterate over values of a section in the configuration. |
@@ -288,11 +298,12 @@ int GNUNET_CONFIGURATION_iterate_value_filenames (const struct | |||
288 | * @param iter function to call on each option | 298 | * @param iter function to call on each option |
289 | * @param iter_cls closure for iter | 299 | * @param iter_cls closure for iter |
290 | */ | 300 | */ |
291 | void GNUNET_CONFIGURATION_iterate_section_values (const struct | 301 | void |
292 | GNUNET_CONFIGURATION_Handle | 302 | GNUNET_CONFIGURATION_iterate_section_values (const struct |
293 | *cfg, const char *section, | 303 | GNUNET_CONFIGURATION_Handle *cfg, |
294 | GNUNET_CONFIGURATION_Iterator | 304 | const char *section, |
295 | iter, void *iter_cls); | 305 | GNUNET_CONFIGURATION_Iterator iter, |
306 | void *iter_cls); | ||
296 | 307 | ||
297 | /** | 308 | /** |
298 | * Get a configuration value that should be in a set of | 309 | * Get a configuration value that should be in a set of |
@@ -306,12 +317,11 @@ void GNUNET_CONFIGURATION_iterate_section_values (const struct | |||
306 | * or NULL if option is not specified and no default given | 317 | * or NULL if option is not specified and no default given |
307 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 318 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
308 | */ | 319 | */ |
309 | int GNUNET_CONFIGURATION_get_value_choice (const struct | 320 | int |
310 | GNUNET_CONFIGURATION_Handle *cfg, | 321 | GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle |
311 | const char *section, | 322 | *cfg, const char *section, |
312 | const char *option, | 323 | const char *option, const char **choices, |
313 | const char **choices, | 324 | const char **value); |
314 | const char **value); | ||
315 | 325 | ||
316 | /** | 326 | /** |
317 | * Get a configuration value that should be in a set of | 327 | * Get a configuration value that should be in a set of |
@@ -322,10 +332,10 @@ int GNUNET_CONFIGURATION_get_value_choice (const struct | |||
322 | * @param option option of interest | 332 | * @param option option of interest |
323 | * @return GNUNET_YES, GNUNET_NO or if option has no valid value, GNUNET_SYSERR | 333 | * @return GNUNET_YES, GNUNET_NO or if option has no valid value, GNUNET_SYSERR |
324 | */ | 334 | */ |
325 | int GNUNET_CONFIGURATION_get_value_yesno (const struct | 335 | int |
326 | GNUNET_CONFIGURATION_Handle *cfg, | 336 | GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle |
327 | const char *section, | 337 | *cfg, const char *section, |
328 | const char *option); | 338 | const char *option); |
329 | 339 | ||
330 | /** | 340 | /** |
331 | * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" | 341 | * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" |
@@ -336,9 +346,9 @@ int GNUNET_CONFIGURATION_get_value_yesno (const struct | |||
336 | * @param orig string to $-expand (will be freed!) | 346 | * @param orig string to $-expand (will be freed!) |
337 | * @return $-expanded string | 347 | * @return $-expanded string |
338 | */ | 348 | */ |
339 | char *GNUNET_CONFIGURATION_expand_dollar (const struct | 349 | char * |
340 | GNUNET_CONFIGURATION_Handle *cfg, | 350 | GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle |
341 | char *orig); | 351 | *cfg, char *orig); |
342 | 352 | ||
343 | 353 | ||
344 | /** | 354 | /** |
@@ -349,10 +359,10 @@ char *GNUNET_CONFIGURATION_expand_dollar (const struct | |||
349 | * @param option option of interest | 359 | * @param option option of interest |
350 | * @param number value to set | 360 | * @param number value to set |
351 | */ | 361 | */ |
352 | void GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle | 362 | void |
353 | *cfg, const char *section, | 363 | GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle *cfg, |
354 | const char *option, | 364 | const char *section, const char *option, |
355 | unsigned long long number); | 365 | unsigned long long number); |
356 | 366 | ||
357 | 367 | ||
358 | /** | 368 | /** |
@@ -363,10 +373,10 @@ void GNUNET_CONFIGURATION_set_value_number (struct GNUNET_CONFIGURATION_Handle | |||
363 | * @param option option of interest | 373 | * @param option option of interest |
364 | * @param value value to set | 374 | * @param value value to set |
365 | */ | 375 | */ |
366 | void GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle | 376 | void |
367 | *cfg, const char *section, | 377 | GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle *cfg, |
368 | const char *option, | 378 | const char *section, const char *option, |
369 | const char *value); | 379 | const char *value); |
370 | 380 | ||
371 | /** | 381 | /** |
372 | * Remove a filename from a configuration value that | 382 | * Remove a filename from a configuration value that |
@@ -379,11 +389,11 @@ void GNUNET_CONFIGURATION_set_value_string (struct GNUNET_CONFIGURATION_Handle | |||
379 | * @return GNUNET_OK on success, | 389 | * @return GNUNET_OK on success, |
380 | * GNUNET_SYSERR if the filename is not in the list | 390 | * GNUNET_SYSERR if the filename is not in the list |
381 | */ | 391 | */ |
382 | int GNUNET_CONFIGURATION_remove_value_filename (struct | 392 | int |
383 | GNUNET_CONFIGURATION_Handle | 393 | GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle |
384 | *cfg, const char *section, | 394 | *cfg, const char *section, |
385 | const char *option, | 395 | const char *option, |
386 | const char *value); | 396 | const char *value); |
387 | 397 | ||
388 | /** | 398 | /** |
389 | * Append a filename to a configuration value that | 399 | * Append a filename to a configuration value that |
@@ -396,11 +406,11 @@ int GNUNET_CONFIGURATION_remove_value_filename (struct | |||
396 | * @return GNUNET_OK on success, | 406 | * @return GNUNET_OK on success, |
397 | * GNUNET_SYSERR if the filename already in the list | 407 | * GNUNET_SYSERR if the filename already in the list |
398 | */ | 408 | */ |
399 | int GNUNET_CONFIGURATION_append_value_filename (struct | 409 | int |
400 | GNUNET_CONFIGURATION_Handle | 410 | GNUNET_CONFIGURATION_append_value_filename (struct GNUNET_CONFIGURATION_Handle |
401 | *cfg, const char *section, | 411 | *cfg, const char *section, |
402 | const char *option, | 412 | const char *option, |
403 | const char *value); | 413 | const char *value); |
404 | 414 | ||
405 | 415 | ||
406 | #if 0 /* keep Emacsens' auto-indent happy */ | 416 | #if 0 /* keep Emacsens' auto-indent happy */ |