ret = GNUNET_SYSERR;
break;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished deserializing config\n", tag);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Finished deserializing config\n");
+ GNUNET_free_non_null (line_orig);
GNUNET_free (section);
GNUNET_assert ( (GNUNET_OK != ret) || (r_bytes == size) );
return ret;
* @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;
}
+/**
+ * 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
*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;
}
(filename != NULL))
GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG",
filename);
- if ((GNUNET_YES ==
- GNUNET_CONFIGURATION_have_value (cfg, "TESTING", "WEAKRANDOM")) &&
- (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_yesno (cfg, "TESTING", "WEAKRANDOM")))
- GNUNET_CRYPTO_random_disable_entropy_gathering ();
return GNUNET_OK;
}