diff --git a/src/actions.c b/src/actions.c index c26242c..3a08b96 100644 --- a/src/actions.c +++ b/src/actions.c @@ -32,7 +32,7 @@ action *action_new_function(server *srv, const char *name, option *value) { action_func af; server_action *sa; - if (NULL == (sa = g_hash_table_lookup(srv->actions, name))) { + if (NULL == (sa = (server_action*) g_hash_table_lookup(srv->actions, name))) { ERROR(srv, "Action '%s' doesn't exist", name); return NULL; } diff --git a/src/plugin.c b/src/plugin.c index a03ab47..474b149 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -210,3 +210,19 @@ gboolean plugin_register(server *srv, const gchar *name, PluginInit init) { return TRUE; } + +gboolean call_setup(server *srv, const char *name, option *opt) { + server_setup *ss; + + if (NULL == (ss = (server_setup*) g_hash_table_lookup(srv->actions, name))) { + ERROR(srv, "Setup function '%s' doesn't exist", name); + return FALSE; + } + + if (!ss->setup(srv, ss->p ? ss->p->data : NULL, opt)) { + ERROR(srv, "Setup '%s' failed", name); + return FALSE; + } + + return TRUE; +} diff --git a/src/plugin.h b/src/plugin.h index d40452c..7599b37 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -102,7 +102,9 @@ struct server_setup { LI_API void plugin_free(server *srv, plugin *p); LI_API gboolean plugin_register(server *srv, const gchar *name, PluginInit init); -LI_API gboolean parse_option(server *srv, const char *key, option *opt, option_set *mark); +LI_API gboolean parse_option(server *srv, const char *name, option *opt, option_set *mark); LI_API void release_option(server *srv, option_set *mark); /**< Does not free the option_set memory */ +LI_API gboolean call_setup(server *srv, const char *name, option *opt); + #endif