[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r15543 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r15543 - in gnunet/src: include util |
Date: |
Fri, 10 Jun 2011 17:51:49 +0200 |
Author: grothoff
Date: 2011-06-10 17:51:48 +0200 (Fri, 10 Jun 2011)
New Revision: 15543
Modified:
gnunet/src/include/gnunet_configuration_lib.h
gnunet/src/util/configuration.c
Log:
add API to remove section
Modified: gnunet/src/include/gnunet_configuration_lib.h
===================================================================
--- gnunet/src/include/gnunet_configuration_lib.h 2011-06-10 15:43:20 UTC
(rev 15542)
+++ gnunet/src/include/gnunet_configuration_lib.h 2011-06-10 15:51:48 UTC
(rev 15543)
@@ -174,7 +174,17 @@
GNUNET_CONFIGURATION_Section_Iterator iter,
void *iter_cls);
+
/**
+ * Remove the given section and all options in it.
+ *
+ * @param cfg configuration to inspect
+ * @param section name of the section to remove
+ */
+void GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle
*cfg,
+ const char *section);
+
+/**
* Get a configuration value that should be a number.
*
* @param cfg configuration to inspect
Modified: gnunet/src/util/configuration.c
===================================================================
--- gnunet/src/util/configuration.c 2011-06-10 15:43:20 UTC (rev 15542)
+++ gnunet/src/util/configuration.c 2011-06-10 15:51:48 UTC (rev 15543)
@@ -132,21 +132,9 @@
GNUNET_CONFIGURATION_destroy (struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct ConfigSection *sec;
- struct ConfigEntry *ent;
while (NULL != (sec = cfg->sections))
- {
- cfg->sections = sec->next;
- while (NULL != (ent = sec->entries))
- {
- sec->entries = ent->next;
- GNUNET_free (ent->key);
- GNUNET_free_non_null (ent->val);
- GNUNET_free (ent);
- }
- GNUNET_free (sec->name);
- GNUNET_free (sec);
- }
+ GNUNET_CONFIGURATION_remove_section (cfg, sec->name);
GNUNET_free (cfg);
}
@@ -414,12 +402,59 @@
void *iter_cls)
{
struct ConfigSection *spos;
+ struct ConfigSection *next;
- for (spos = cfg->sections; spos != NULL; spos = spos->next)
- iter (iter_cls, spos->name);
+ next = cfg->sections;
+ while (next != NULL)
+ {
+ spos = next;
+ next = spos->next;
+ iter (iter_cls, spos->name);
+ }
}
+/**
+ * Remove the given section and all options in it.
+ *
+ * @param cfg configuration to inspect
+ * @param section name of the section to remove
+ */
+void GNUNET_CONFIGURATION_remove_section (struct GNUNET_CONFIGURATION_Handle
*cfg,
+ const char *section)
+{
+ struct ConfigSection *spos;
+ struct ConfigSection *prev;
+ struct ConfigEntry *ent;
+ prev = NULL;
+ spos = cfg->sections;
+ while (spos != NULL)
+ {
+ if (0 == strcmp (section,
+ spos->name))
+ {
+ if (prev == NULL)
+ cfg->sections = spos->next;
+ else
+ prev->next = spos->next;
+ while (NULL != (ent = spos->entries))
+ {
+ spos->entries = ent->next;
+ GNUNET_free (ent->key);
+ GNUNET_free_non_null (ent->val);
+ GNUNET_free (ent);
+ cfg->dirty = GNUNET_YES;
+ }
+ GNUNET_free (spos->name);
+ GNUNET_free (spos);
+ return;
+ }
+ prev = spos;
+ spos = spos->next;
+ }
+}
+
+
/**
* Copy a configuration value to the given target configuration.
* Overwrites existing entries.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r15543 - in gnunet/src: include util,
gnunet <=