aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-07-18 08:18:37 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-07-18 08:18:37 +0000
commitb245a60021ef93b0157f6445aa152e808763a145 (patch)
tree05ca29430c16b377ff2025ed96c15a8a96703180 /src
parent44c3d88a33a82e66144ba0bbe491febd0e244703 (diff)
downloadgnunet-b245a60021ef93b0157f6445aa152e808763a145.tar.gz
gnunet-b245a60021ef93b0157f6445aa152e808763a145.zip
aaded new function to iterate over section entries
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_configuration_lib.h14
-rw-r--r--src/util/configuration.c33
2 files changed, 47 insertions, 0 deletions
diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h
index 3cdd54c8f..642bbde53 100644
--- a/src/include/gnunet_configuration_lib.h
+++ b/src/include/gnunet_configuration_lib.h
@@ -277,6 +277,20 @@ int GNUNET_CONFIGURATION_iterate_value_filenames (const struct
277 cb, void *cb_cls); 277 cb, void *cb_cls);
278 278
279/** 279/**
280 * Iterate over values of a section in the configuration.
281 *
282 * @param cfg configuration to inspect
283 * @param section the section
284 * @param iter function to call on each option
285 * @param iter_cls closure for iter
286 */
287void
288GNUNET_CONFIGURATION_iterate_section_values (const struct GNUNET_CONFIGURATION_Handle *cfg,
289 const char *section,
290 GNUNET_CONFIGURATION_Iterator iter,
291 void *iter_cls);
292
293/**
280 * Get a configuration value that should be in a set of 294 * Get a configuration value that should be in a set of
281 * predefined strings 295 * predefined strings
282 * 296 *
diff --git a/src/util/configuration.c b/src/util/configuration.c
index 978765970..88bde1c38 100644
--- a/src/util/configuration.c
+++ b/src/util/configuration.c
@@ -390,6 +390,39 @@ GNUNET_CONFIGURATION_iterate (const struct GNUNET_CONFIGURATION_Handle *cfg,
390 390
391 391
392/** 392/**
393 * Iterate over values of a section in the configuration.
394 *
395 * @param cfg configuration to inspect
396 * @param section the section
397 * @param iter function to call on each option
398 * @param iter_cls closure for iter
399 */
400void
401GNUNET_CONFIGURATION_iterate_section_values (const struct GNUNET_CONFIGURATION_Handle *cfg,
402 const char *section,
403 GNUNET_CONFIGURATION_Iterator iter,
404 void *iter_cls)
405{
406 struct ConfigSection *spos;
407 struct ConfigEntry *epos;
408
409 spos = cfg->sections;
410 while ((spos != NULL) && (0 != strcmp (spos->name, section)))
411 spos = spos->next;
412
413 if (spos == NULL)
414 return;
415
416 epos = spos->entries;
417 while (epos != NULL)
418 {
419 iter (iter_cls, spos->name, epos->key, epos->val);
420 epos = epos->next;
421 }
422}
423
424
425/**
393 * Iterate over all sections in the configuration. 426 * Iterate over all sections in the configuration.
394 * 427 *
395 * @param cfg configuration to inspect 428 * @param cfg configuration to inspect