- errcode = xbt_cfg_set_host(cfg,name,str,i);
- if (errcode != no_error) {
- free(optionlist_cpy);
- return errcode;
+ TRY {
+ switch (variable->type) {
+ case xbt_cfgelm_string:
+ xbt_cfg_set_string(cfg, name, val); /* throws */
+ break;
+
+ case xbt_cfgelm_int:
+ i=strtol(val, &val, 0);
+ if (val==NULL) {
+ free(optionlist_cpy);
+ xbt_assert1(FALSE,
+ "Value of option %s not valid. Should be an integer",
+ name);
+ }
+
+ xbt_cfg_set_int(cfg,name,i); /* throws */
+ break;
+
+ case xbt_cfgelm_double:
+ d=strtod(val, &val);
+ if (val==NULL) {
+ free(optionlist_cpy);
+ xbt_assert1(FALSE,
+ "Value of option %s not valid. Should be a double",
+ name);
+ }
+
+ xbt_cfg_set_double(cfg,name,d); /* throws */
+ break;
+
+ case xbt_cfgelm_host:
+ str=val;
+ val=strchr(val,':');
+ if (!val) {
+ free(optionlist_cpy);
+ xbt_assert1(FALSE,
+ "Value of option %s not valid. Should be an host (machine:port)",
+ name);
+ }
+
+ *(val++)='\0';
+ i=strtol(val, &val, 0);
+ if (val==NULL) {
+ free(optionlist_cpy);
+ xbt_assert1(FALSE,
+ "Value of option %s not valid. Should be an host (machine:port)",
+ name);
+ }
+
+ xbt_cfg_set_host(cfg,name,str,i); /* throws */
+ break;
+
+ default:
+ THROW1(unknown_error,0,"Type of config element %s is not valid.",name);