Code

config: Added support for (generic) LoadPlugin.
authorSebastian Harl <sh@tokkee.org>
Wed, 10 Jul 2013 14:54:39 +0000 (16:54 +0200)
committerSebastian Harl <sh@tokkee.org>
Wed, 10 Jul 2013 14:54:39 +0000 (16:54 +0200)
src/daemon/config.c

index 03bc2b857caad19d8151c46b3cb35e00db896ec0..76955050837b2714011252e74e6dda78e7b660bc 100644 (file)
@@ -88,6 +88,39 @@ daemon_set_interval(oconfig_item_t *ci)
        return config_get_interval(ci, &default_interval);
 } /* daemon_set_interval */
 
+static int
+daemon_load_plugin(oconfig_item_t *ci)
+{
+       char *name;
+
+       sdb_plugin_ctx_t ctx = SDB_PLUGIN_CTX_INIT;
+       sdb_plugin_ctx_t old_ctx;
+
+       int status, i;
+
+       if (oconfig_get_string(ci, &name)) {
+               sdb_log(SDB_LOG_ERR, "config: LoadPlugin requires a single "
+                               "string argument\n"
+                               "\tUsage: LoadPlugin PLUGIN");
+               return -1;
+       }
+
+       for (i = 0; i < ci->children_num; ++i) {
+               oconfig_item_t *child = ci->children + i;
+
+               /* we don't currently support any options */
+               sdb_log(SDB_LOG_WARNING, "config: Unknown option '%s' "
+                               "inside 'LoadPlugin' -- see the documentation for "
+                               "details.", child->key);
+               continue;
+       }
+
+       old_ctx = sdb_plugin_set_ctx(ctx);
+       status = sdb_plugin_load(name);
+       sdb_plugin_set_ctx(old_ctx);
+       return status;
+} /* daemon_load_plugin */
+
 static int
 daemon_load_backend(oconfig_item_t *ci)
 {
@@ -151,6 +184,7 @@ daemon_configure_plugin(oconfig_item_t *ci)
 
 static token_parser_t token_parser_list[] = {
        { "Interval", daemon_set_interval },
+       { "LoadPlugin", daemon_load_plugin },
        { "LoadBackend", daemon_load_backend },
        { "Backend", daemon_configure_plugin },
        { "Plugin", daemon_configure_plugin },