2
0
Fork 0

merged from lp

personal/stbuehler/wip
Thomas Porzelt 2008-08-04 23:17:44 +02:00
commit 4ae1c04b55
5 changed files with 21 additions and 10 deletions

View File

@ -44,12 +44,7 @@ void action_acquire(action *a) {
a->refcount++;
}
action *action_new_setting(server *srv, const gchar *name, option *value) {
option_set setting;
if (!parse_option(srv, name, value, &setting)) {
return NULL;
}
action *action_new_setting(option_set setting) {
action *a = g_slice_new(action);
a->refcount = 1;

View File

@ -74,7 +74,7 @@ LI_API action_result action_execute(server *srv, connection *con);
LI_API void action_release(server *srv, action *a);
LI_API void action_acquire(action *a);
/* create new action */
LI_API action *action_new_setting(server *srv, const gchar *name, option *value);
LI_API action *action_new_setting(option_set setting);
LI_API action *action_new_function(ActionFunc func, ActionFree free, gpointer param);
LI_API action *action_new_list();
LI_API action *action_new_condition(condition *cond, action *target);

View File

@ -138,7 +138,7 @@ static action* action_from_lua(server *srv, lua_State *L) {
lua_pushstring(L, "missing config value");
lua_error(L);
}
a = action_new_setting(srv, optname, value);
a = option_action(srv, optname, value);
if (!a) {
option_free(value);
lua_pushstring(L, "couldn't create action from setting");

View File

@ -217,6 +217,16 @@ void release_option(server *srv, option_set *mark) { /** Does not free the optio
mark->value = NULL;
}
action* option_action(server *srv, const gchar *name, option *value) {
option_set setting;
if (!parse_option(srv, name, value, &setting)) {
return NULL;
}
return action_new_setting(setting);
}
action* create_action(server *srv, const gchar *name, option *value) {
action *a;
server_action *sa;

View File

@ -99,14 +99,20 @@ struct server_setup {
PluginSetup setup;
};
LI_API void plugin_free(server *srv, plugin *p);
/* Needed my modules to register their plugin(s) */
LI_API gboolean plugin_register(server *srv, const gchar *name, PluginInit init);
LI_API void plugin_free(server *srv, plugin *p);
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 */
/* Needed for config frontends */
/** For parsing 'somemod.option = "somevalue"' */
LI_API action* option_action(server *srv, const gchar *name, option *value);
/** For parsing 'somemod.action value', e.g. 'rewrite "/url" => "/destination"' */
LI_API action* create_action(server *srv, const gchar *name, option *value);
/** For setup function, e.g. 'listen "127.0.0.1:8080"' */
LI_API gboolean call_setup(server *srv, const char *name, option *opt);
#endif