diff options
author | Linus Nordberg <linus@nordu.net> | 2011-07-03 10:36:08 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2011-07-03 10:36:08 +0200 |
commit | b2b7fe083115822966eed20b28a07b2fb9de84dd (patch) | |
tree | 1c269b88910ab93862adb987c274ded2da52b8a1 /lib | |
parent | 074f7dfe1934273a2336414c135b2494fda08af3 (diff) |
Handle all libconfuse parse errors.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/conf.c | 21 |
1 files changed, 18 insertions, 3 deletions
@@ -37,10 +37,12 @@ } #endif +/* FIXME: Leaking memory in error cases? */ int rs_context_read_config(struct rs_context *ctx, const char *config_file) { cfg_t *cfg, *cfg_realm, *cfg_server; + int err = 0; int i, j; const char *s; struct rs_config *config = NULL; @@ -74,9 +76,22 @@ rs_context_read_config(struct rs_context *ctx, const char *config_file) cfg = cfg_init (opts, CFGF_NONE); if (cfg == NULL) return rs_err_ctx_push (ctx, RSE_CONFIG, "unable to initialize libconfuse"); - if (cfg_parse (cfg, config_file) == CFG_PARSE_ERROR) - return rs_err_ctx_push (ctx, RSE_CONFIG, "%s: invalid configuration file", - config_file); + err = cfg_parse (cfg, config_file); + switch (err) + { + case CFG_SUCCESS: + break; + case CFG_FILE_ERROR: + return rs_err_ctx_push (ctx, RSE_CONFIG, + "%s: unable to open configuration file", + config_file); + case CFG_PARSE_ERROR: + return rs_err_ctx_push (ctx, RSE_CONFIG, "%s: invalid configuration file", + config_file); + default: + return rs_err_ctx_push (ctx, RSE_CONFIG, "%s: unknown parse error", + config_file); + } config = rs_calloc (ctx, 1, sizeof (*config)); if (config == NULL) |