| version 1.40, 2002/05/30 22:29:45 |
version 1.41, 2002/06/23 10:48:46 |
| Line 69 cfg_get_context(options) |
|
| Line 69 cfg_get_context(options) |
|
| for (i = 0; i < CFG_N_PROPS; i++) { |
for (i = 0; i < CFG_N_PROPS; i++) { |
| con->prop[i] = strdyn_create_ar(cfg_default_properties[i]); |
con->prop[i] = strdyn_create_ar(cfg_default_properties[i]); |
| if (con->prop[i] == NULL) { |
if (con->prop[i] == NULL) { |
| /*TODO: possible freeing on failure */ |
/* TODO: possible freeing on failure */ |
| return NULL; |
return NULL; |
| } |
} |
| } |
} |
| Line 267 cfg_get_error_str(con) |
|
| Line 267 cfg_get_error_str(con) |
|
| |
|
| switch (con->error_code) { |
switch (con->error_code) { |
| |
|
| /* case CFG_ERR_OK: */ |
|
| /* case CFG_ERROR_OK: */ |
|
| case CFG_OK: |
case CFG_OK: |
| sprintf(s, "no error on %s", str_type); |
sprintf(s, "no error on %s", str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_NOARG: */ |
|
| case CFG_ERROR_NOARG: |
case CFG_ERROR_NOARG: |
| sprintf(s, "argument is missing for option '%s' %s %d %s", |
sprintf(s, "argument is missing for option '%s' %s %d %s", |
| str_opt, str_pos, idx, str_type); |
str_opt, str_pos, idx, str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_NOTALLOWEDARG: */ |
|
| case CFG_ERROR_NOTALLOWEDARG: |
case CFG_ERROR_NOTALLOWEDARG: |
| sprintf(s, "option '%s' does not have allowed argument %s %d %s", |
sprintf(s, "option '%s' does not have allowed argument %s %d %s", |
| str_opt, str_pos, idx, str_type); |
str_opt, str_pos, idx, str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_BADOPT: */ |
|
| case CFG_ERROR_BADOPT: |
case CFG_ERROR_BADOPT: |
| sprintf(s, "argument '%s' for option '%s' could not be parsed" |
sprintf(s, "argument '%s' for option '%s' could not be parsed" |
| " %s %d %s", |
" %s %d %s", |
| str_arg, str_opt, str_pos, idx, str_type); |
str_arg, str_opt, str_pos, idx, str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_BADQUOTE: */ |
|
| case CFG_ERROR_BADQUOTE: |
case CFG_ERROR_BADQUOTE: |
| sprintf(s, "error in quotations in option '%s' %s %d %s", |
sprintf(s, "error in quotations in option '%s' %s %d %s", |
| str_opt, str_pos, idx, str_type); |
str_opt, str_pos, idx, str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_BADNUMBER: */ |
|
| case CFG_ERROR_BADNUMBER: |
case CFG_ERROR_BADNUMBER: |
| sprintf(s, "argument '%s' for option '%s' could not be converted" |
sprintf(s, "argument '%s' for option '%s' could not be converted" |
| " to appropriate numeric type %s %d %s", |
" to appropriate numeric type %s %d %s", |
| str_arg, str_opt, str_pos, idx, str_type); |
str_arg, str_opt, str_pos, idx, str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_OVERFLOW: */ |
|
| case CFG_ERROR_OVERFLOW: |
case CFG_ERROR_OVERFLOW: |
| sprintf(s, "given number '%s' was too big or too small in option" |
sprintf(s, "given number '%s' was too big or too small in option" |
| " '%s' %s %d %s", |
" '%s' %s %d %s", |
| str_arg, str_opt, str_pos, idx, str_type); |
str_arg, str_opt, str_pos, idx, str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_MULTI: */ |
|
| case CFG_ERROR_MULTI: |
case CFG_ERROR_MULTI: |
| sprintf(s, "multiple arguments used for single option '%s' %s %d %s", |
sprintf(s, "multiple arguments used for single option '%s' %s %d %s", |
| str_opt, str_pos, idx, str_type); |
str_opt, str_pos, idx, str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_NOMEM: */ |
|
| case CFG_ERROR_NOMEM: |
case CFG_ERROR_NOMEM: |
| sprintf(s, "not enough memory"); |
sprintf(s, "not enough memory"); |
| break; |
break; |
| |
|
| /* case CFG_ERR_STOP_STR: */ |
|
| /* case CFG_ERR_STOP_STR_FOUND: */ |
|
| /* case CFG_ERROR_STOP_STR: */ |
|
| case CFG_ERROR_STOP_STR_FOUND: |
case CFG_ERROR_STOP_STR_FOUND: |
| sprintf(s, "stop string '%s' was found %s %d %s", |
sprintf(s, "stop string '%s' was found %s %d %s", |
| str_opt, str_pos, idx, str_type); |
str_opt, str_pos, idx, str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_NOEQUAL: */ |
|
| case CFG_ERROR_NOEQUAL: |
case CFG_ERROR_NOEQUAL: |
| sprintf(s, "no equal sign founded %s %d %s", |
sprintf(s, "no equal sign founded %s %d %s", |
| str_pos, idx, str_type); |
str_pos, idx, str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_UNKNOWN: */ |
|
| case CFG_ERROR_UNKNOWN: |
case CFG_ERROR_UNKNOWN: |
| sprintf(s, "unknown option '%s' %s %d %s", |
sprintf(s, "unknown option '%s' %s %d %s", |
| str_opt, str_pos, idx, str_type); |
str_opt, str_pos, idx, str_type); |
| break; |
break; |
| |
|
| /* case CFG_ERR_FILE_NOT_FOUND: */ |
|
| case CFG_ERROR_FILE_NOT_FOUND: |
case CFG_ERROR_FILE_NOT_FOUND: |
| sprintf(s, "config file '%s' was not found", str_filename); |
sprintf(s, "config file '%s' was not found", str_filename); |
| break; |
break; |
| |
|
| /* case CFG_ERR_SEEK_ERROR: */ |
|
| case CFG_ERROR_SEEK_ERROR: |
case CFG_ERROR_SEEK_ERROR: |
| sprintf(s, "seek error in config file '%s'", str_filename); |
sprintf(s, "seek error in config file '%s'", str_filename); |
| break; |
break; |
| |
|
| /* case CFG_ERR_INTERNAL: */ |
|
| case CFG_ERROR_INTERNAL: |
case CFG_ERROR_INTERNAL: |
| sprintf(s, "libcfg internal error"); |
sprintf(s, "libcfg internal error"); |
| default: |
default: |
| Line 370 cfg_get_static_error_str(errorcode) |
|
| Line 352 cfg_get_static_error_str(errorcode) |
|
| { /* {{{ */ |
{ /* {{{ */ |
| switch (errorcode) { |
switch (errorcode) { |
| |
|
| /* case CFG_ERR_OK: */ |
|
| /* case CFG_ERROR_OK: */ |
|
| case CFG_OK: |
case CFG_OK: |
| return "no error"; |
return "no error"; |
| |
|
| /* case CFG_ERR_NOARG: */ |
|
| case CFG_ERROR_NOARG: |
case CFG_ERROR_NOARG: |
| return "argument is missing for option"; |
return "argument is missing for option"; |
| |
|
| /* case CFG_ERR_NOTALLOWEDARG: */ |
|
| case CFG_ERROR_NOTALLOWEDARG: |
case CFG_ERROR_NOTALLOWEDARG: |
| return "argument is not allowed for option"; |
return "argument is not allowed for option"; |
| |
|
| /* case CFG_ERR_BADOPT: */ |
|
| case CFG_ERROR_BADOPT: |
case CFG_ERROR_BADOPT: |
| return "option's argument could not be parsed"; |
return "option's argument could not be parsed"; |
| |
|
| /* case CFG_ERR_BADQUOTE: */ |
|
| case CFG_ERROR_BADQUOTE: |
case CFG_ERROR_BADQUOTE: |
| return "error in quotations"; |
return "error in quotations"; |
| |
|
| /* case CFG_ERR_BADNUMBER: */ |
|
| case CFG_ERROR_BADNUMBER: |
case CFG_ERROR_BADNUMBER: |
| return "option could not be converted to appropriate numeric type"; |
return "option could not be converted to appropriate numeric type"; |
| |
|
| /* case CFG_ERR_OVERFLOW: */ |
|
| case CFG_ERROR_OVERFLOW: |
case CFG_ERROR_OVERFLOW: |
| return "given number was too big or too small"; |
return "given number was too big or too small"; |
| |
|
| /* case CFG_ERR_MULTI: */ |
|
| case CFG_ERROR_MULTI: |
case CFG_ERROR_MULTI: |
| return "multiple arguments used for single option"; |
return "multiple arguments used for single option"; |
| |
|
| /* case CFG_ERR_NOMEM: */ |
|
| case CFG_ERROR_NOMEM: |
case CFG_ERROR_NOMEM: |
| return "not enough memory"; |
return "not enough memory"; |
| |
|
| /* case CFG_ERR_STOP_STR: */ |
|
| /* case CFG_ERR_STOP_STR_FOUND: */ |
|
| /* case CFG_ERROR_STOP_STR: */ |
|
| case CFG_ERROR_STOP_STR_FOUND: |
case CFG_ERROR_STOP_STR_FOUND: |
| return "stop string was found"; |
return "stop string was found"; |
| |
|
| /* case CFG_ERR_NOEQUAL: */ |
|
| case CFG_ERROR_NOEQUAL: |
case CFG_ERROR_NOEQUAL: |
| return "no equal sign on the line"; |
return "no equal sign on the line"; |
| |
|
| /* case CFG_ERR_UNKNOWN: */ |
|
| case CFG_ERROR_UNKNOWN: |
case CFG_ERROR_UNKNOWN: |
| return "unknown option"; |
return "unknown option"; |
| |
|
| /* case CFG_ERR_FILE_NOT_FOUND: */ |
|
| case CFG_ERROR_FILE_NOT_FOUND: |
case CFG_ERROR_FILE_NOT_FOUND: |
| return "file not found"; |
return "file not found"; |
| |
|
| /* case CFG_ERR_SEEK_ERROR: */ |
|
| case CFG_ERROR_SEEK_ERROR: |
case CFG_ERROR_SEEK_ERROR: |
| return "file seek error"; |
return "file seek error"; |
| |
|
| /* case CFG_ERR_INTERNAL: */ |
|
| case CFG_ERROR_INTERNAL: |
case CFG_ERROR_INTERNAL: |
| return "internal error"; |
return "internal error"; |
| } |
} |