#include "xbt/peer.h"
#include "xbt/config.h" /* prototypes of this module */
-#include "surf/surf.h" /* COORD_HOST_LEVEL and COORD_ASR_LEVEL */
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_cfg, xbt, "configuration support");
XBT_DEBUG("Copy cfg set %p", tocopy);
*whereto = NULL;
- xbt_assert0(tocopy, "cannot copy NULL config");
+ xbt_assert(tocopy, "cannot copy NULL config");
xbt_dict_foreach((xbt_dict_t) tocopy, cursor, name, variable) {
xbt_cfg_register(whereto, name, variable->desc, variable->type, NULL,
if (*cfg == NULL)
*cfg = xbt_cfg_new();
- xbt_assert4(type >= xbt_cfgelm_int && type <= xbt_cfgelm_peer,
+ xbt_assert(type >= xbt_cfgelm_int && type <= xbt_cfgelm_peer,
"type of %s not valid (%d should be between %d and %d)",
name, type, xbt_cfgelm_int, xbt_cfgelm_peer);
res = xbt_dict_get_or_null((xbt_dict_t) * cfg, name);
* Each of them must use the following syntax: \<name\>:\<min nb\>_to_\<max nb\>_\<type\>
* with type being one of 'string','int', 'peer' or 'double'.
*
- * @fixme: this does not allow to set the description
+ * FIXME: this does not allow to set the description
*/
void xbt_cfg_register_str(xbt_cfg_t * cfg, const char *entry)
XBT_DEBUG("Register string '%s'", entry);
tok = strchr(entrycpy, ':');
- xbt_assert2(tok, "Invalid config element descriptor: %s%s",
+ xbt_assert(tok, "Invalid config element descriptor: %s%s",
entry, "; Should be <name>:<min nb>_to_<max nb>_<type>");
*(tok++) = '\0';
min = strtol(tok, &tok, 10);
- xbt_assert1(tok, "Invalid minimum in config element descriptor %s",
+ xbt_assert(tok, "Invalid minimum in config element descriptor %s",
entry);
- xbt_assert2(strcmp(tok, "_to_"),
+ xbt_assert(strcmp(tok, "_to_"),
"Invalid config element descriptor : %s%s",
entry, "; Should be <name>:<min nb>_to_<max nb>_<type>");
tok += strlen("_to_");
max = strtol(tok, &tok, 10);
- xbt_assert1(tok, "Invalid maximum in config element descriptor %s",
+ xbt_assert(tok, "Invalid maximum in config element descriptor %s",
entry);
- xbt_assert2(*tok == '_',
+ xbt_assert(*tok == '_',
"Invalid config element descriptor: %s%s", entry,
"; Should be <name>:<min nb>_to_<max nb>_<type>");
tok++;
for (type = 0;
type < xbt_cfgelm_type_count
&& strcmp(tok, xbt_cfgelm_type_name[type]); type++);
- xbt_assert2(type < xbt_cfgelm_type_count,
+ xbt_assert(type < xbt_cfgelm_type_count,
"Invalid type in config element descriptor: %s%s", entry,
"; Should be one of 'string', 'int', 'peer' or 'double'.");
char *name;
int size;
- xbt_assert0(cfg, "NULL config set.");
+ xbt_assert(cfg, "NULL config set.");
XBT_DEBUG("Check cfg set %p", cfg);
xbt_dict_foreach((xbt_dict_t) cfg, cursor, name, variable) {
"No registered variable '%s' in this config set", name);
}
- xbt_assert3(type == xbt_cfgelm_any || res->type == type,
+ xbt_assert(type == xbt_cfgelm_any || res->type == type,
"You tried to access to the config element %s as an %s, but its type is %s.",
name,
xbt_cfgelm_type_name[type], xbt_cfgelm_type_name[res->type]);
TRY {
type = xbt_cfg_get_type(cfg, name);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category == not_found_error) {
xbt_ex_free(e);
THROWF(not_found_error, 0,
}
*(val++) = '\0';
- if (!strcmp(name,"coordinates")){
- if(!strcmp(val,"yes") && !COORD_HOST_LEVEL){
- XBT_INFO("Configuration change: Set '%s' to '%s'", name, val);
- COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp);
- COORD_ASR_LEVEL = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
- free(optionlist_cpy);
- return;
- }
- if(strcmp(val,"yes"))
- xbt_die("Setting CMD prop coordinates must be \"yes\"");
- }
-
- if (strcmp(name,"contexts/factory"))
+ if (strncmp(name, "contexts/", strlen("contexts/")))
XBT_INFO("Configuration change: Set '%s' to '%s'", name, val);
TRY {
variable = xbt_dict_get((xbt_dict_t) cfg, name);
}
CATCH(e) {
- /* put it back on what won't get freed, ie within "options" and out of "optionlist_cpy" */
- name = (char *) (optionlist_cpy - name + options);
- free(optionlist_cpy);
if (e.category == not_found_error) {
xbt_ex_free(e);
+ name = xbt_strdup(name);
+ free(optionlist_cpy);
THROWF(not_found_error, 0,
"No registered variable corresponding to '%s'.", name);
}
+ free(optionlist_cpy);
RETHROW;
}
name);
}
}
- CATCH(e) {
+ CATCH_ANONYMOUS {
free(optionlist_cpy);
RETHROW;
}
TRY {
variable = xbt_dict_get((xbt_dict_t) cfg, name);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
RETHROW;
TRY {
variable = xbt_dict_get((xbt_dict_t) cfg, name);
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category == not_found_error) {
xbt_ex_free(e);
THROWF(not_found_error, 0,
TRY {
xbt_cfg_set_parse(myset, "color:blue");
- } CATCH(e) {
+ }
+ CATCH(e) {
if (e.category != not_found_error)
xbt_test_exception(e);
xbt_ex_free(e);