X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/af959d56a01cc9112000d8cb9937d5a274db43f3..64561039d3dec9e50b4eaf1b78b3edef71898383:/src/xbt/config.c diff --git a/src/xbt/config.c b/src/xbt/config.c index 67f2e4cfee..cd6cfbc63a 100644 --- a/src/xbt/config.c +++ b/src/xbt/config.c @@ -337,17 +337,30 @@ void xbt_cfg_register_str(xbt_cfg_t * cfg, const char *entry) free(entrycpy); /* strdup'ed by dict mechanism, but cannot be const */ } +static int strcmp_voidp(const void *pa, const void *pb) +{ + return strcmp(*(const char **)pa, *(const char **)pb); +} + /** @brief Displays the declared options and their description */ void xbt_cfg_help(xbt_cfg_t cfg) { - xbt_dict_cursor_t cursor; + xbt_dict_cursor_t dict_cursor; + unsigned int dynar_cursor; xbt_cfgelm_t variable; char *name; + xbt_dynar_t names = xbt_dynar_new(sizeof(char *), NULL); - int i; - int size; + xbt_dict_foreach((xbt_dict_t )cfg, dict_cursor, name, variable) { + xbt_dynar_push(names, &name); + } + xbt_dynar_sort(names, strcmp_voidp); + + xbt_dynar_foreach(names, dynar_cursor, name) { + int i; + int size; + variable = xbt_dict_get((xbt_dict_t )cfg, name); - xbt_dict_foreach((xbt_dict_t) cfg, cursor, name, variable) { printf(" %s: %s\n", name, variable->desc); printf(" Type: %s; ", xbt_cfgelm_type_name[variable->type]); if (variable->min != 1 || variable->max != 1) { @@ -399,6 +412,8 @@ void xbt_cfg_help(xbt_cfg_t cfg) } } + + xbt_dynar_free(&names); } /** @brief Check that each variable have the right amount of values */ @@ -636,7 +651,8 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options) } *(val++) = '\0'; - DEBUG2("Configuration change: Set '%s' to '%s'", name, val); + if (strcmp(name,"contexts/factory")) + INFO2("Configuration change: Set '%s' to '%s'", name, val); TRY { variable = xbt_dict_get((xbt_dict_t) cfg, name); @@ -728,9 +744,11 @@ void xbt_cfg_setdefault_int(xbt_cfg_t cfg, const char *name, int val) { xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_int); - if (variable->isdefault) + if (variable->isdefault){ xbt_cfg_set_int(cfg, name, val); - else + variable->isdefault = 1; + } + else DEBUG2 ("Do not override configuration variable '%s' with value '%d' because it was already set.", name, val); @@ -745,8 +763,10 @@ void xbt_cfg_setdefault_double(xbt_cfg_t cfg, const char *name, double val) { xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_double); - if (variable->isdefault) + if (variable->isdefault) { xbt_cfg_set_double(cfg, name, val); + variable->isdefault = 1; + } else DEBUG2 ("Do not override configuration variable '%s' with value '%lf' because it was already set.", @@ -763,8 +783,10 @@ void xbt_cfg_setdefault_string(xbt_cfg_t cfg, const char *name, { xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_string); - if (variable->isdefault) + if (variable->isdefault){ xbt_cfg_set_string(cfg, name, val); + variable->isdefault = 1; + } else DEBUG2 ("Do not override configuration variable '%s' with value '%s' because it was already set.", @@ -781,8 +803,10 @@ void xbt_cfg_setdefault_peer(xbt_cfg_t cfg, const char *name, { xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_peer); - if (variable->isdefault) + if (variable->isdefault){ xbt_cfg_set_peer(cfg, name, host, port); + variable->isdefault = 1; + } else DEBUG3 ("Do not override configuration variable '%s' with value '%s:%d' because it was already set.", @@ -1136,6 +1160,14 @@ void xbt_cfg_empty(xbt_cfg_t cfg, const char *name) xbt_dynar_reset(variable->content); } } +/* + * Say if the value is the default value + */ +int xbt_cfg_is_default_value(xbt_cfg_t cfg, const char *name) +{ + xbt_cfgelm_t variable = xbt_cfgelm_get(cfg, name, xbt_cfgelm_any); + return variable->isdefault; +} /*----[ Getting ]---------------------------------------------------------*/