From 2537bb9d82cf1fffa67541bb6923293d2fc96b9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Wed, 23 Jul 2008 22:33:29 +0200 Subject: [PATCH] Add call_setup function --- src/actions.c | 2 +- src/plugin.c | 16 ++++++++++++++++ src/plugin.h | 4 +++- 3 files changed, 20 insertions(+), 2 deletions(-) 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