From f105a48ab7fd40c4285ca202340d4991ea316eef Mon Sep 17 00:00:00 2001 From: Sree Harsha Totakura Date: Mon, 28 May 2012 18:27:25 +0000 Subject: [PATCH] -reverted GNUNET_TESTING_configuration_create() --- src/include/gnunet_testing_lib-new.h | 9 ++++--- src/testing/testing_new.c | 39 +++++++++++----------------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/include/gnunet_testing_lib-new.h b/src/include/gnunet_testing_lib-new.h index 46cd5a466..1fb3c1a02 100644 --- a/src/include/gnunet_testing_lib-new.h +++ b/src/include/gnunet_testing_lib-new.h @@ -146,12 +146,13 @@ GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system, * by 'GNUNET_TESTING_peer_configure'. * * @param system system to use to coordinate resource usage - * @param cfg template configuration - * @return the new configuration; NULL upon error; + * @param cfg template configuration to update + * @return GNUNET_OK on success, GNUNET_SYSERR on error - the configuration will + * be incomplete and should not be used there upon */ -struct GNUNET_CONFIGURATION_Handle * +int GNUNET_TESTING_configuration_create (struct GNUNET_TESTING_System *system, - const struct GNUNET_CONFIGURATION_Handle *cfg); + struct GNUNET_CONFIGURATION_Handle *cfg); // FIXME: add dual to 'release' ports again... diff --git a/src/testing/testing_new.c b/src/testing/testing_new.c index ecbe0d2bb..6b5413c89 100644 --- a/src/testing/testing_new.c +++ b/src/testing/testing_new.c @@ -416,12 +416,7 @@ struct UpdateContext * The system for which we are building configurations */ struct GNUNET_TESTING_System *system; - - /** - * The original configuration template - */ - const struct GNUNET_CONFIGURATION_Handle *orig; - + /** * The configuration we are building */ @@ -465,7 +460,7 @@ update_config (void *cls, const char *section, const char *option, { if ((ival != 0) && (GNUNET_YES != - GNUNET_CONFIGURATION_get_value_yesno (uc->orig, "testing", + GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing", single_variable))) { /* FIXME: What about UDP? */ @@ -480,9 +475,9 @@ update_config (void *cls, const char *section, const char *option, } else if ((ival != 0) && (GNUNET_YES == - GNUNET_CONFIGURATION_get_value_yesno (uc->orig, "testing", + GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing", single_variable)) && - GNUNET_CONFIGURATION_get_value_number (uc->orig, "testing", + GNUNET_CONFIGURATION_get_value_number (uc->cfg, "testing", per_host_variable, &num_per_host)) { @@ -495,7 +490,7 @@ update_config (void *cls, const char *section, const char *option, if (0 == strcmp (option, "UNIXPATH")) { if (GNUNET_YES != - GNUNET_CONFIGURATION_get_value_yesno (uc->orig, "testing", + GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing", single_variable)) { GNUNET_snprintf (uval, sizeof (uval), "%s-%s-%u", @@ -505,7 +500,7 @@ update_config (void *cls, const char *section, const char *option, value = uval; } else if ((GNUNET_YES == - GNUNET_CONFIGURATION_get_value_number (uc->orig, "testing", + GNUNET_CONFIGURATION_get_value_number (uc->cfg, "testing", per_host_variable, &num_per_host)) && (num_per_host > 0)) @@ -538,7 +533,7 @@ update_config_sections (void *cls, char *allowed_hosts; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (uc->orig, section, "ACCEPT_FROM", + GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, "ACCEPT_FROM", &orig_allowed_hosts)) { orig_allowed_hosts = "127.0.0.1;"; @@ -565,27 +560,23 @@ update_config_sections (void *cls, * by 'GNUNET_TESTING_peer_configure'. * * @param system system to use to coordinate resource usage - * @param cfg template configuration - * @return the new configuration; NULL upon error; + * @param cfg template configuration to update + * @return GNUNET_OK on success, GNUNET_SYSERR on error - the configuration will + * be incomplete and should not be used there upon */ -struct GNUNET_CONFIGURATION_Handle * +int GNUNET_TESTING_configuration_create (struct GNUNET_TESTING_System *system, - const struct GNUNET_CONFIGURATION_Handle *cfg) + struct GNUNET_CONFIGURATION_Handle *cfg) { struct UpdateContext uc; uc.system = system; - uc.orig = cfg; - uc.cfg = GNUNET_CONFIGURATION_create (); + uc.cfg = cfg; + uc.status = GNUNET_OK; GNUNET_CONFIGURATION_iterate (cfg, &update_config, &uc); - if (GNUNET_OK != uc.status) - { - GNUNET_CONFIGURATION_destroy (uc.cfg); - return NULL; - } GNUNET_CONFIGURATION_iterate_sections (cfg, &update_config_sections, &uc); /* FIXME: add other options which enable communication with controller */ - return uc.cfg; + return uc.status; } -- 2.25.1