From: Sebastian Harl Date: Wed, 10 Jul 2013 14:54:39 +0000 (+0200) Subject: config: Added support for (generic) LoadPlugin. X-Git-Tag: sysdb-0.1.0~407 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=59a2f80e79dedcd985c52b84cc0f5025bf455492;p=sysdb.git config: Added support for (generic) LoadPlugin. --- diff --git a/src/daemon/config.c b/src/daemon/config.c index 03bc2b8..7695505 100644 --- a/src/daemon/config.c +++ b/src/daemon/config.c @@ -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 },