diff --git a/src/configfile.c b/src/configfile.c
index f93eda02fee007c6a47a559295488ccb030fed40..14b9dfbc4decc2fccfbc8c10efc70d0fcb2868cf 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
#include "libconfig/libconfig.h"
+#include "plugin.h"
#include "configfile.h"
#include "utils_debug.h"
#define ERR_NEEDS_ARG "Section `%s' needs an argument.\n"
#define ERR_NEEDS_SECTION "`%s' can only be used within a section.\n"
+#ifdef HAVE_LIBRRD
+extern int operating_mode;
+#else
+static int operating_mode = MODE_LOCAL;
+#endif
+
typedef struct cf_callback
{
char *type;
for (i = 0; i < cf_cb->keys_num; i++)
{
if (strcasecmp (cf_cb->keys[i], key) == 0)
+ {
ret = (*cf_cb->callback) (key, value);
+ break;
+ }
}
if (i >= cf_cb->keys_num)
for (i = 0; i < keys_num; i++)
{
- if (snprintf (buf, 64, "Module.%s", keys[i]) < 64)
+ if (snprintf (buf, 64, "Plugin.%s", keys[i]) < 64)
{
/* This may be called multiple times for the same
* `key', but apparently `lc_register_*' can handle
if (current_module != NULL)
{
free (current_module);
- current_module == NULL;
+ current_module = NULL;
}
nesting_depth--;
return (LC_CBRET_ERROR);
}
- /*
- * TODO:
- * - Write wrapper around `plugin_load' to resolve path/filename
- * - Call this new, public function here
- */
- DBG ("Implement me, idiot!");
+ if (plugin_load (value))
+ syslog (LOG_ERR, "plugin_load (%s): failed to load plugin", shortvar);
+ /* Return `okay' even if there was an error, because it's not a syntax
+ * problem.. */
return (LC_CBRET_OKAY);
}
lc_register_callback ("Mode", SHORTOPT_NONE, LC_VAR_SECTION,
cf_callback_section_mode, NULL);
- lc_register_callback ("Module", SHORTOPT_NONE, LC_VAR_SECTION,
+ lc_register_callback ("Plugin", SHORTOPT_NONE, LC_VAR_SECTION,
cf_callback_section_module, NULL);
/*
* - Add more directives, such as `DefaultMode', `DataDir', `PIDFile', ...
*/
- lc_register_callback ("Mode.LoadModule", SHORTOPT_NONE,
+ lc_register_callback ("Mode.LoadPlugin", SHORTOPT_NONE,
LC_VAR_STRING, cf_callback_loadmodule,
NULL);
if (lc_process_file ("collectd", filename, LC_CONF_APACHE))
{
- /* FIXME: Use syslog here */
- fprintf (stderr, "Error loading config file `%s': %s\n",
- filename, lc_geterrstr ());
+ syslog (LOG_ERR, "lc_process_file (%s): %s", filename, lc_geterrstr ());
return (-1);
}