Code

plugin: Manage all context information in the core.
[sysdb.git] / src / daemon / config.c
index 03bc2b857caad19d8151c46b3cb35e00db896ec0..d15081f469446ee1f3b3214b6dbe8efcdf6e7253 100644 (file)
@@ -89,15 +89,40 @@ daemon_set_interval(oconfig_item_t *ci)
 } /* daemon_set_interval */
 
 static int
-daemon_load_backend(oconfig_item_t *ci)
+daemon_load_plugin(oconfig_item_t *ci)
 {
-       char  plugin_name[1024];
        char *name;
+       int 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;
+       }
+
+       return sdb_plugin_load(name, NULL);
+} /* daemon_load_plugin */
+
+static int
+daemon_load_backend(oconfig_item_t *ci)
+{
        sdb_plugin_ctx_t ctx = SDB_PLUGIN_CTX_INIT;
-       sdb_plugin_ctx_t old_ctx;
 
-       int status, i;
+       char  plugin_name[1024];
+       char *name;
+
+       int i;
 
        ctx.interval = default_interval;
 
@@ -125,10 +150,7 @@ daemon_load_backend(oconfig_item_t *ci)
                }
        }
 
-       old_ctx = sdb_plugin_set_ctx(ctx);
-       status = sdb_plugin_load(plugin_name);
-       sdb_plugin_set_ctx(old_ctx);
-       return status;
+       return sdb_plugin_load(plugin_name, &ctx);
 } /* daemon_load_backend */
 
 static int
@@ -151,6 +173,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 },