diff --git a/src/daemon/config.c b/src/daemon/config.c
index d15081f469446ee1f3b3214b6dbe8efcdf6e7253..91746b10267cab4e304f0f1eb3a98b64a6c8eb0d 100644 (file)
--- a/src/daemon/config.c
+++ b/src/daemon/config.c
#include <assert.h>
#include <strings.h>
+/*
+ * Parser error values:
+ * - Values less than zero indicate an error in the daemon or libsysdb.
+ * - Zero indicates success.
+ * - Any other values indicate parsing errors.
+ */
+
+enum {
+ ERR_UNKNOWN_OPTION = 1,
+ ERR_UNKNOWN_ARG = 2,
+ ERR_INVALID_ARG = 3,
+ ERR_PARSE_FAILED = 4,
+};
+
/*
* private variables
*/
sdb_log(SDB_LOG_ERR, "config: Interval requires "
"a single numeric argument\n"
"\tUsage: Interval SECONDS");
- return -1;
+ return ERR_INVALID_ARG;
}
if (interval_dbl <= 0.0) {
sdb_log(SDB_LOG_ERR, "config: Invalid interval: %f\n"
"\tInterval may not be less than or equal to zero.",
interval_dbl);
- return -1;
+ return ERR_INVALID_ARG;
}
*interval = DOUBLE_TO_SDB_TIME(interval_dbl);
sdb_log(SDB_LOG_ERR, "config: LoadPlugin requires a single "
"string argument\n"
"\tUsage: LoadPlugin PLUGIN");
- return -1;
+ return ERR_INVALID_ARG;
}
for (i = 0; i < ci->children_num; ++i) {
continue;
}
+ /* returns a negative value on error */
return sdb_plugin_load(name, NULL);
} /* daemon_load_plugin */
sdb_log(SDB_LOG_ERR, "config: LoadBackend requires a single "
"string argument\n"
"\tUsage: LoadBackend BACKEND");
- return -1;
+ return ERR_INVALID_ARG;
}
snprintf(plugin_name, sizeof(plugin_name), "backend::%s", name);
if (! strcasecmp(child->key, "Interval")) {
if (config_get_interval(child, &ctx.interval))
- return -1;
+ return ERR_INVALID_ARG;
}
else {
sdb_log(SDB_LOG_WARNING, "config: Unknown option '%s' "
"string argument\n"
"\tUsage: LoadBackend BACKEND",
ci->key);
- return -1;
+ return ERR_INVALID_ARG;
}
return sdb_plugin_configure(name, ci);
ci = oconfig_parse_file(filename);
if (! ci)
- return -1;
+ return ERR_PARSE_FAILED;
for (i = 0; i < ci->children_num; ++i) {
oconfig_item_t *child = ci->children + i;
- int status = 1, j;
+ int status = ERR_UNKNOWN_OPTION, j;
for (j = 0; token_parser_list[j].name; ++j) {
if (! strcasecmp(token_parser_list[j].name, child->key))
if (status) {
sdb_error_set("config: Failed to parse option '%s'\n",
child->key);
- if (status > 0)
+ if (status == ERR_UNKNOWN_OPTION)
sdb_error_append("\tUnknown option '%s' -- "
"see the documentation for details\n",
child->key);
sdb_error_chomp();
sdb_error_log(SDB_LOG_ERR);
- retval = -1;
+ retval = status;
}
}
return retval;