[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25433 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25433 - in gnunet/src: include util |
Date: |
Wed, 12 Dec 2012 22:44:22 +0100 |
Author: grothoff
Date: 2012-12-12 22:44:22 +0100 (Wed, 12 Dec 2012)
New Revision: 25433
Modified:
gnunet/src/include/gnunet_configuration_lib.h
gnunet/src/util/configuration.c
Log:
adding function to compute configuration differences in memory
Modified: gnunet/src/include/gnunet_configuration_lib.h
===================================================================
--- gnunet/src/include/gnunet_configuration_lib.h 2012-12-12 21:22:57 UTC
(rev 25432)
+++ gnunet/src/include/gnunet_configuration_lib.h 2012-12-12 21:44:22 UTC
(rev 25433)
@@ -154,6 +154,7 @@
GNUNET_CONFIGURATION_write (struct GNUNET_CONFIGURATION_Handle *cfg,
const char *filename);
+
/**
* Write only configuration entries that have been changed to configuration
file
* @param cfgDefault default configuration
@@ -167,7 +168,22 @@
const struct GNUNET_CONFIGURATION_Handle
*cfgNew, const char *filename);
+
/**
+ * Compute configuration with only entries that have been changed
+ *
+ * @param cfgDefault original configuration
+ * @param cfgNew new configuration
+ * @return configuration with only the differences, never NULL
+ */
+struct GNUNET_CONFIGURATION_Handle *
+GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle
+ *cfgDefault,
+ const struct GNUNET_CONFIGURATION_Handle
+ *cfgNew);
+
+
+/**
* Test if there are configuration options that were
* changed since the last save.
*
Modified: gnunet/src/util/configuration.c
===================================================================
--- gnunet/src/util/configuration.c 2012-12-12 21:22:57 UTC (rev 25432)
+++ gnunet/src/util/configuration.c 2012-12-12 21:44:22 UTC (rev 25433)
@@ -736,8 +736,8 @@
* @param value value to copy (of the default conf.)
*/
static void
-compareEntries (void *cls, const char *section, const char *option,
- const char *value)
+compare_entries (void *cls, const char *section, const char *option,
+ const char *value)
{
struct DiffHandle *dh = cls;
struct ConfigEntry *entNew;
@@ -750,6 +750,28 @@
/**
+ * Compute configuration with only entries that have been changed
+ *
+ * @param cfgDefault original configuration
+ * @param cfgNew new configuration
+ * @return configuration with only the differences, never NULL
+ */
+struct GNUNET_CONFIGURATION_Handle *
+GNUNET_CONFIGURATION_get_diff (const struct GNUNET_CONFIGURATION_Handle
+ *cfgDefault,
+ const struct GNUNET_CONFIGURATION_Handle
+ *cfgNew)
+{
+ struct DiffHandle diffHandle;
+
+ diffHandle.cfgDiff = GNUNET_CONFIGURATION_create ();
+ diffHandle.cfgDefault = cfgDefault;
+ GNUNET_CONFIGURATION_iterate (cfgNew, &compare_entries, &diffHandle);
+ return diffHandle.cfgDiff;
+}
+
+
+/**
* Write only configuration entries that have been changed to configuration
file
* @param cfgDefault default configuration
* @param cfgNew new configuration
@@ -763,13 +785,11 @@
*cfgNew, const char *filename)
{
int ret;
- struct DiffHandle diffHandle;
+ struct GNUNET_CONFIGURATION_Handle *diff;
- diffHandle.cfgDiff = GNUNET_CONFIGURATION_create ();
- diffHandle.cfgDefault = cfgDefault;
- GNUNET_CONFIGURATION_iterate (cfgNew, compareEntries, &diffHandle);
- ret = GNUNET_CONFIGURATION_write (diffHandle.cfgDiff, filename);
- GNUNET_CONFIGURATION_destroy (diffHandle.cfgDiff);
+ diff = GNUNET_CONFIGURATION_get_diff (cfgDefault, cfgNew);
+ ret = GNUNET_CONFIGURATION_write (diff, filename);
+ GNUNET_CONFIGURATION_destroy (diff);
return ret;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25433 - in gnunet/src: include util,
gnunet <=