Add userdata to action-create, setup and plugin-init callbacks
This commit is contained in:
parent
881669d96a
commit
b4c3e2ba02
|
@ -12,12 +12,12 @@
|
|||
size_t id; \
|
||||
ssize_t option_base_ndx
|
||||
|
||||
typedef void (*liPluginInitCB) (liServer *srv, liPlugin *p);
|
||||
typedef void (*liPluginInitCB) (liServer *srv, liPlugin *p, gpointer userdata);
|
||||
typedef void (*liPluginFreeCB) (liServer *srv, liPlugin *p);
|
||||
typedef gboolean (*liPluginParseOptionCB) (liServer *srv, liPlugin *p, size_t ndx, liValue *val, liOptionValue *oval);
|
||||
typedef void (*liPluginFreeOptionCB) (liServer *srv, liPlugin *p, size_t ndx, liOptionValue oval);
|
||||
typedef liAction*(*liPluginCreateActionCB) (liServer *srv, liPlugin *p, liValue *val);
|
||||
typedef gboolean (*liPluginSetupCB) (liServer *srv, liPlugin *p, liValue *val);
|
||||
typedef liAction*(*liPluginCreateActionCB) (liServer *srv, liPlugin *p, liValue *val, gpointer userdata);
|
||||
typedef gboolean (*liPluginSetupCB) (liServer *srv, liPlugin *p, liValue *val, gpointer userdata);
|
||||
typedef void (*liPluginAngelCB) (liServer *srv, liPlugin *p, gint32 id, GString *data);
|
||||
|
||||
typedef void (*liPluginHandleCloseCB) (liConnection *con, liPlugin *p);
|
||||
|
@ -65,11 +65,13 @@ struct liPluginOption {
|
|||
struct liPluginAction {
|
||||
const gchar *name;
|
||||
liPluginCreateActionCB li_create_action;
|
||||
gpointer userdata;
|
||||
};
|
||||
|
||||
struct liPluginSetup {
|
||||
const gchar *name;
|
||||
liPluginSetupCB setup;
|
||||
gpointer userdata;
|
||||
};
|
||||
|
||||
struct liPluginAngel {
|
||||
|
@ -111,15 +113,17 @@ struct liServerOption {
|
|||
struct liServerAction {
|
||||
liPlugin *p;
|
||||
liPluginCreateActionCB li_create_action;
|
||||
gpointer userdata;
|
||||
};
|
||||
|
||||
struct liServerSetup {
|
||||
liPlugin *p;
|
||||
liPluginSetupCB setup;
|
||||
gpointer userdata;
|
||||
};
|
||||
|
||||
/* Needed by modules to register their plugin(s) */
|
||||
LI_API liPlugin *li_plugin_register(liServer *srv, const gchar *name, liPluginInitCB init);
|
||||
LI_API liPlugin *li_plugin_register(liServer *srv, const gchar *name, liPluginInitCB init, gpointer userdata);
|
||||
|
||||
/* Internal needed functions */
|
||||
LI_API void li_plugin_free(liServer *srv, liPlugin *p);
|
||||
|
|
|
@ -28,6 +28,6 @@ enum liCoreOptions {
|
|||
#define CORE_OPTION(idx) _CORE_OPTION(vr, idx)
|
||||
#define _CORE_OPTION(vr, idx) _OPTION_ABS(vr, idx)
|
||||
|
||||
LI_API void li_plugin_core_init(liServer *srv, liPlugin *p);
|
||||
LI_API void li_plugin_core_init(liServer *srv, liPlugin *p, gpointer userdata);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -147,7 +147,7 @@ static int handle_server_action(liServer *srv, lua_State *L, gpointer _sa) {
|
|||
li_lua_unlock(srv);
|
||||
|
||||
/* TRACE(srv, "%s", "Creating action"); */
|
||||
a = sa->li_create_action(srv, sa->p, val);
|
||||
a = sa->li_create_action(srv, sa->p, val, sa->userdata);
|
||||
li_value_free(val);
|
||||
|
||||
li_lua_lock(srv);
|
||||
|
@ -170,7 +170,7 @@ static int handle_server_setup(liServer *srv, lua_State *L, gpointer _ss) {
|
|||
|
||||
li_lua_unlock(srv);
|
||||
/* TRACE(srv, "%s", "Calling setup"); */
|
||||
res = ss->setup(srv, ss->p, val);
|
||||
res = ss->setup(srv, ss->p, val, ss->userdata);
|
||||
li_lua_lock(srv);
|
||||
|
||||
if (!res) {
|
||||
|
|
|
@ -83,7 +83,7 @@ int main(int argc, char *argv[]) {
|
|||
li_server_loop_init(srv);
|
||||
|
||||
/* load core plugin */
|
||||
srv->core_plugin = li_plugin_register(srv, "core", li_plugin_core_init);
|
||||
srv->core_plugin = li_plugin_register(srv, "core", li_plugin_core_init, NULL);
|
||||
if (use_angel) {
|
||||
li_angel_setup(srv);
|
||||
}
|
||||
|
|
|
@ -100,12 +100,12 @@ void li_server_plugins_free(liServer *srv) {
|
|||
g_hash_table_destroy(srv->setups);
|
||||
}
|
||||
|
||||
liPlugin *li_plugin_register(liServer *srv, const gchar *name, liPluginInitCB init) {
|
||||
liPlugin *li_plugin_register(liServer *srv, const gchar *name, liPluginInitCB init, gpointer userdata) {
|
||||
liPlugin *p;
|
||||
liServerState s;
|
||||
|
||||
if (!init) {
|
||||
ERROR(srv, "Module '%s' needs an init function", name);
|
||||
ERROR(srv, "Plugin '%s' needs an init function", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ liPlugin *li_plugin_register(liServer *srv, const gchar *name, liPluginInitCB in
|
|||
}
|
||||
|
||||
if (g_hash_table_lookup(srv->plugins, name)) {
|
||||
ERROR(srv, "Module '%s' already registered", name);
|
||||
ERROR(srv, "Plugin '%s' already registered", name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ liPlugin *li_plugin_register(liServer *srv, const gchar *name, liPluginInitCB in
|
|||
p->id = g_hash_table_size(srv->plugins);
|
||||
g_hash_table_insert(srv->plugins, (gchar*) p->name, p);
|
||||
|
||||
init(srv, p);
|
||||
init(srv, p, userdata);
|
||||
p->opt_base_index = g_hash_table_size(srv->options);
|
||||
|
||||
if (p->options) {
|
||||
|
@ -171,6 +171,7 @@ liPlugin *li_plugin_register(liServer *srv, const gchar *name, liPluginInitCB in
|
|||
sa = g_slice_new0(liServerAction);
|
||||
sa->li_create_action = pa->li_create_action;
|
||||
sa->p = p;
|
||||
sa->userdata = pa->userdata;
|
||||
g_hash_table_insert(srv->actions, (gchar*) pa->name, sa);
|
||||
}
|
||||
}
|
||||
|
@ -192,6 +193,7 @@ liPlugin *li_plugin_register(liServer *srv, const gchar *name, liPluginInitCB in
|
|||
ss = g_slice_new0(liServerSetup);
|
||||
ss->setup = ps->setup;
|
||||
ss->p = p;
|
||||
ss->userdata = ps->userdata;
|
||||
g_hash_table_insert(srv->setups, (gchar*) ps->name, ss);
|
||||
}
|
||||
}
|
||||
|
@ -298,7 +300,7 @@ liAction* li_create_action(liServer *srv, const gchar *name, liValue *val) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (NULL == (a = sa->li_create_action(srv, sa->p, val))) {
|
||||
if (NULL == (a = sa->li_create_action(srv, sa->p, val, sa->userdata))) {
|
||||
ERROR(srv, "Action '%s' creation failed", name);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -314,7 +316,7 @@ gboolean li_call_setup(liServer *srv, const char *name, liValue *val) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!ss->setup(srv, ss->p, val)) {
|
||||
if (!ss->setup(srv, ss->p, val, ss->userdata)) {
|
||||
ERROR(srv, "Setup '%s' failed", name);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
static liAction* core_list(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_list(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liAction *a;
|
||||
guint i;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val) {
|
||||
ERROR(srv, "%s", "need parameter");
|
||||
|
@ -46,10 +46,10 @@ static liAction* core_list(liServer *srv, liPlugin* p, liValue *val) {
|
|||
return a;
|
||||
}
|
||||
|
||||
static liAction* core_when(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_when(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liValue *val_cond, *val_act, *val_act_else;
|
||||
liAction *a, *act = NULL, *act_else = NULL;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val) {
|
||||
ERROR(srv, "%s", "need parameter");
|
||||
|
@ -100,10 +100,10 @@ static liAction* core_when(liServer *srv, liPlugin* p, liValue *val) {
|
|||
return a;
|
||||
}
|
||||
|
||||
static liAction* core_set(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_set(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liValue *val_val, *val_name;
|
||||
liAction *a;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val) {
|
||||
ERROR(srv, "%s", "need parameter");
|
||||
|
@ -127,9 +127,9 @@ static liAction* core_set(liServer *srv, liPlugin* p, liValue *val) {
|
|||
return a;
|
||||
}
|
||||
|
||||
static gboolean core_setup_set(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static gboolean core_setup_set(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liValue *val_val, *val_name;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val) {
|
||||
ERROR(srv, "%s", "need parameter");
|
||||
|
@ -181,8 +181,8 @@ static void core_docroot_free(liServer *srv, gpointer param) {
|
|||
g_string_free(param, TRUE);
|
||||
}
|
||||
|
||||
static liAction* core_docroot(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(p);
|
||||
static liAction* core_docroot(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
if (!val || val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "docroot action expects a string parameter");
|
||||
return NULL;
|
||||
|
@ -251,11 +251,11 @@ static void core_alias_free(liServer *srv, gpointer _param) {
|
|||
g_array_free(param, TRUE);
|
||||
}
|
||||
|
||||
static liAction* core_alias(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_alias(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *a = NULL;
|
||||
GArray *vl, *vl1;
|
||||
core_alias_config ac;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "%s", "unexpected or no parameter for alias action");
|
||||
|
@ -391,11 +391,11 @@ static void core_index_free(liServer *srv, gpointer param) {
|
|||
g_array_free(files, TRUE);
|
||||
}
|
||||
|
||||
static liAction* core_index(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_index(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *files;
|
||||
guint i;
|
||||
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "%s", "index action expects a list of strings as parameter");
|
||||
|
@ -604,8 +604,8 @@ static liHandlerResult core_handle_static(liVRequest *vr, gpointer param, gpoint
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_static(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(p);
|
||||
static liAction* core_static(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "static action doesn't have parameters");
|
||||
return NULL;
|
||||
|
@ -658,8 +658,8 @@ next_round:
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_pathinfo(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(p);
|
||||
static liAction* core_pathinfo(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "pathinfo action doesn't have parameters");
|
||||
return NULL;
|
||||
|
@ -677,10 +677,10 @@ static liHandlerResult core_handle_status(liVRequest *vr, gpointer param, gpoint
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_status(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_status(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
gpointer ptr;
|
||||
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_NUMBER) {
|
||||
ERROR(srv, "%s", "set_status action expects a number as parameter");
|
||||
|
@ -708,8 +708,8 @@ static liHandlerResult core_handle_log_write(liVRequest *vr, gpointer param, gpo
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_log_write(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(p);
|
||||
static liAction* core_log_write(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
if (!val || val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "log.write expects a string parameter");
|
||||
return NULL;
|
||||
|
@ -730,8 +730,8 @@ static liHandlerResult core_handle_blank(liVRequest *vr, gpointer param, gpointe
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_blank(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(p);
|
||||
static liAction* core_blank(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "'blank' action doesn't have parameters");
|
||||
|
@ -752,8 +752,8 @@ static liHandlerResult core_handle_profile_mem(liVRequest *vr, gpointer param, g
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_profile_mem(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(p);
|
||||
static liAction* core_profile_mem(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "'profile_mem' action doesn't have parameters");
|
||||
|
@ -763,9 +763,9 @@ static liAction* core_profile_mem(liServer *srv, liPlugin* p, liValue *val) {
|
|||
return li_action_new_function(core_handle_profile_mem, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static gboolean core_listen(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static gboolean core_listen(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GString *ipstr;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "listen expects a string as parameter");
|
||||
|
@ -779,9 +779,9 @@ static gboolean core_listen(liServer *srv, liPlugin* p, liValue *val) {
|
|||
}
|
||||
|
||||
|
||||
static gboolean core_workers(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static gboolean core_workers(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
gint workers;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
workers = val->data.number;
|
||||
if (val->type != LI_VALUE_NUMBER || workers < 1) {
|
||||
|
@ -796,10 +796,10 @@ static gboolean core_workers(liServer *srv, liPlugin* p, liValue *val) {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean core_module_load(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static gboolean core_module_load(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liValue *mods = li_value_new_list();
|
||||
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!g_module_supported()) {
|
||||
ERROR(srv, "%s", "module loading not supported on this platform");
|
||||
|
@ -850,8 +850,8 @@ static gboolean core_module_load(liServer *srv, liPlugin* p, liValue *val) {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean core_io_timeout(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(p);
|
||||
static gboolean core_io_timeout(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_NUMBER || val->data.number < 1) {
|
||||
ERROR(srv, "%s", "io.timeout expects a positive number as parameter");
|
||||
|
@ -863,8 +863,8 @@ static gboolean core_io_timeout(liServer *srv, liPlugin* p, liValue *val) {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean core_stat_cache_ttl(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(p);
|
||||
static gboolean core_stat_cache_ttl(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_NUMBER || val->data.number < 1) {
|
||||
ERROR(srv, "%s", "stat_cache.ttl expects a positive number as parameter");
|
||||
|
@ -1104,9 +1104,9 @@ static void core_header_free(liServer *srv, gpointer param) {
|
|||
li_value_list_free(param);
|
||||
}
|
||||
|
||||
static liAction* core_header_add(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_header_add(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *l;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "'header.add' action expects a string tuple as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1141,9 +1141,9 @@ static liHandlerResult core_handle_header_append(liVRequest *vr, gpointer param,
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_header_append(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_header_append(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *l;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "'header.append' action expects a string tuple as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1178,9 +1178,9 @@ static liHandlerResult core_handle_header_overwrite(liVRequest *vr, gpointer par
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_header_overwrite(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_header_overwrite(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *l;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "'header.overwrite' action expects a string tuple as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1217,8 +1217,8 @@ static liHandlerResult core_handle_header_remove(liVRequest *vr, gpointer param,
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_header_remove(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(p);
|
||||
static liAction* core_header_remove(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "'header.remove' action expects a string as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1238,9 +1238,9 @@ static liHandlerResult core_handle_buffer_out(liVRequest *vr, gpointer param, gp
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_buffer_out(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_buffer_out(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
gint64 limit;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_NUMBER) {
|
||||
ERROR(srv, "'io.buffer_out' action expects an integer as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1271,9 +1271,9 @@ static liHandlerResult core_handle_buffer_in(liVRequest *vr, gpointer param, gpo
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_buffer_in(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_buffer_in(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
gint64 limit;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_NUMBER) {
|
||||
ERROR(srv, "'io.buffer_in' action expects an integer as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1326,13 +1326,13 @@ static liHandlerResult core_handle_throttle_pool(liVRequest *vr, gpointer param,
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_throttle_pool(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_throttle_pool(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GString *name;
|
||||
guint i;
|
||||
liThrottlePool *pool = NULL;
|
||||
gint64 rate;
|
||||
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_STRING && val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "'io.throttle_pool' action expects a string or a string-number tuple as parameter, %s given", li_value_type_string(val->type));
|
||||
|
@ -1420,9 +1420,9 @@ static liHandlerResult core_handle_throttle_connection(liVRequest *vr, gpointer
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* core_throttle_connection(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* core_throttle_connection(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
liThrottleParam *param;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type == LI_VALUE_LIST && val->data.list->len == 2) {
|
||||
liValue *v1 = g_array_index(val->data.list, liValue*, 0);
|
||||
|
@ -1510,46 +1510,46 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "list", core_list },
|
||||
{ "when", core_when },
|
||||
{ "set", core_set },
|
||||
{ "list", core_list, NULL },
|
||||
{ "when", core_when, NULL },
|
||||
{ "set", core_set, NULL },
|
||||
|
||||
{ "docroot", core_docroot },
|
||||
{ "alias", core_alias },
|
||||
{ "index", core_index },
|
||||
{ "static", core_static },
|
||||
{ "pathinfo", core_pathinfo },
|
||||
{ "docroot", core_docroot, NULL },
|
||||
{ "alias", core_alias, NULL },
|
||||
{ "index", core_index, NULL },
|
||||
{ "static", core_static, NULL },
|
||||
{ "pathinfo", core_pathinfo, NULL },
|
||||
|
||||
{ "set_status", core_status },
|
||||
{ "set_status", core_status, NULL },
|
||||
|
||||
{ "log.write", core_log_write },
|
||||
{ "log.write", core_log_write, NULL },
|
||||
|
||||
{ "blank", core_blank },
|
||||
{ "profile_mem", core_profile_mem },
|
||||
{ "blank", core_blank, NULL },
|
||||
{ "profile_mem", core_profile_mem, NULL },
|
||||
|
||||
{ "header.add", core_header_add },
|
||||
{ "header.append", core_header_append },
|
||||
{ "header.overwrite", core_header_overwrite },
|
||||
{ "header.remove", core_header_remove },
|
||||
{ "header.add", core_header_add, NULL },
|
||||
{ "header.append", core_header_append, NULL },
|
||||
{ "header.overwrite", core_header_overwrite, NULL },
|
||||
{ "header.remove", core_header_remove, NULL },
|
||||
|
||||
{ "io.buffer_out", core_buffer_out },
|
||||
{ "io.buffer_in", core_buffer_in },
|
||||
{ "io.throttle", core_throttle_connection },
|
||||
{ "io.throttle_pool", core_throttle_pool },
|
||||
/*{ "io.throttle_ip", core_throttle_ip },*/
|
||||
{ "io.buffer_out", core_buffer_out, NULL },
|
||||
{ "io.buffer_in", core_buffer_in, NULL },
|
||||
{ "io.throttle", core_throttle_connection, NULL },
|
||||
{ "io.throttle_pool", core_throttle_pool, NULL },
|
||||
/*{ "io.throttle_ip", core_throttle_ip, NULL },*/
|
||||
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ "set_default", core_setup_set },
|
||||
{ "listen", core_listen },
|
||||
{ "workers", core_workers },
|
||||
{ "module_load", core_module_load },
|
||||
{ "io.timeout", core_io_timeout },
|
||||
{ "stat_cache.ttl", core_stat_cache_ttl },
|
||||
{ "set_default", core_setup_set, NULL },
|
||||
{ "listen", core_listen, NULL },
|
||||
{ "workers", core_workers, NULL },
|
||||
{ "module_load", core_module_load, NULL },
|
||||
{ "io.timeout", core_io_timeout, NULL },
|
||||
{ "stat_cache.ttl", core_stat_cache_ttl, NULL },
|
||||
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginAngel angelcbs[] = {
|
||||
|
@ -1560,8 +1560,8 @@ static const liPluginAngel angelcbs[] = {
|
|||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
void li_plugin_core_init(liServer *srv, liPlugin *p) {
|
||||
UNUSED(srv);
|
||||
void li_plugin_core_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
|
|
@ -107,7 +107,7 @@ static void access_check_free(liServer *srv, gpointer param) {
|
|||
g_slice_free(access_check_data, acd);
|
||||
}
|
||||
|
||||
static liAction* access_check_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* access_check_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
GArray *arr;
|
||||
liValue *v, *ip;
|
||||
guint i, j;
|
||||
|
@ -116,6 +116,7 @@ static liAction* access_check_create(liServer *srv, liPlugin* p, liValue *val) {
|
|||
access_check_data *acd = NULL;
|
||||
|
||||
UNUSED(srv);
|
||||
UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_LIST || (val->data.list->len != 1 && val->data.list->len != 2)) {
|
||||
ERROR(srv, "%s", "access_check expects a list of one or two string,list tuples as parameter");
|
||||
|
@ -219,9 +220,8 @@ static liHandlerResult access_deny(liVRequest *vr, gpointer param, gpointer *con
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* access_deny_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
|
||||
UNUSED(srv);
|
||||
static liAction* access_deny_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "access.deny doesn't expect any parameters");
|
||||
|
@ -240,19 +240,19 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "access.check", access_check_create },
|
||||
{ "access.deny", access_deny_create },
|
||||
{ "access.check", access_check_create, NULL },
|
||||
{ "access.deny", access_deny_create, NULL },
|
||||
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
static void plugin_access_init(liServer *srv, liPlugin *p) {
|
||||
UNUSED(srv);
|
||||
static void plugin_access_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
@ -265,7 +265,7 @@ gboolean mod_access_init(liModules *mods, liModule *mod) {
|
|||
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(mods->main, "mod_access", plugin_access_init);
|
||||
mod->config = li_plugin_register(mods->main, "mod_access", plugin_access_init, NULL);
|
||||
|
||||
return mod->config != NULL;
|
||||
}
|
||||
|
|
|
@ -489,11 +489,11 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
|
@ -503,10 +503,10 @@ static void plugin_accesslog_free(liServer *srv, liPlugin *p) {
|
|||
g_slice_free(al_data, p->data);
|
||||
}
|
||||
|
||||
static void plugin_accesslog_init(liServer *srv, liPlugin *p) {
|
||||
static void plugin_accesslog_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
al_data *ald;
|
||||
|
||||
UNUSED(srv);
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->free = plugin_accesslog_free;
|
||||
p->options = options;
|
||||
|
@ -525,7 +525,7 @@ LI_API gboolean mod_accesslog_init(liModules *mods, liModule *mod) {
|
|||
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(mods->main, "mod_accesslog", plugin_accesslog_init);
|
||||
mod->config = li_plugin_register(mods->main, "mod_accesslog", plugin_accesslog_init, NULL);
|
||||
|
||||
/* set default accesslog format */
|
||||
str = g_string_new_len(CONST_STR_LEN("%h %V %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""));
|
||||
|
|
|
@ -447,15 +447,18 @@ static liAction* auth_generic_create(liServer *srv, liPlugin* p, liValue *val, c
|
|||
}
|
||||
|
||||
|
||||
static liAction* auth_plain_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* auth_plain_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(userdata);
|
||||
return auth_generic_create(srv, p, val, "auth.plain", auth_backend_plain, FALSE);
|
||||
}
|
||||
|
||||
static liAction* auth_htpasswd_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* auth_htpasswd_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(userdata);
|
||||
return auth_generic_create(srv, p, val, "auth.htpasswd", auth_backend_htpasswd, FALSE);
|
||||
}
|
||||
|
||||
static liAction* auth_htdigest_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* auth_htdigest_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(userdata);
|
||||
return auth_generic_create(srv, p, val, "auth.htdigest", auth_backend_htdigest, TRUE);
|
||||
}
|
||||
|
||||
|
@ -483,9 +486,10 @@ static liHandlerResult auth_handle_deny(liVRequest *vr, gpointer param, gpointer
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* auth_deny(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* auth_deny(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv);
|
||||
UNUSED(p);
|
||||
UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "'auth.deny' action doesn't have parameters");
|
||||
|
@ -502,21 +506,22 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "auth.plain", auth_plain_create },
|
||||
{ "auth.htpasswd", auth_htpasswd_create },
|
||||
{ "auth.htdigest", auth_htdigest_create },
|
||||
{ "auth.plain", auth_plain_create, NULL },
|
||||
{ "auth.htpasswd", auth_htpasswd_create, NULL },
|
||||
{ "auth.htdigest", auth_htdigest_create, NULL },
|
||||
|
||||
{ "auth.deny", auth_deny },
|
||||
{ "auth.deny", auth_deny, NULL },
|
||||
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static void plugin_auth_init(liServer *srv, liPlugin *p) {
|
||||
static void plugin_auth_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
UNUSED(srv);
|
||||
UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
@ -529,7 +534,7 @@ gboolean mod_auth_init(liModules *mods, liModule *mod) {
|
|||
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(mods->main, "mod_auth", plugin_auth_init);
|
||||
mod->config = li_plugin_register(mods->main, "mod_auth", plugin_auth_init, NULL);
|
||||
|
||||
return mod->config != NULL;
|
||||
}
|
||||
|
|
|
@ -158,10 +158,10 @@ static void balancer_act_free(liServer *srv, gpointer param) {
|
|||
balancer_free(srv, (balancer*) param);
|
||||
}
|
||||
|
||||
static liAction* balancer_rr(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* balancer_rr(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
balancer *b;
|
||||
liAction *a;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val) {
|
||||
ERROR(srv, "%s", "need parameter");
|
||||
|
@ -184,17 +184,17 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "balancer.rr", balancer_rr },
|
||||
{ NULL, NULL }
|
||||
{ "balancer.rr", balancer_rr, NULL },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
static void plugin_init(liServer *srv, liPlugin *p) {
|
||||
UNUSED(srv);
|
||||
static void plugin_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
@ -205,7 +205,7 @@ static void plugin_init(liServer *srv, liPlugin *p) {
|
|||
gboolean mod_balancer_init(liModules *mods, liModule *mod) {
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(mods->main, "mod_balancer", plugin_init);
|
||||
mod->config = li_plugin_register(mods->main, "mod_balancer", plugin_init, NULL);
|
||||
|
||||
return mod->config != NULL;
|
||||
}
|
||||
|
|
|
@ -305,9 +305,9 @@ static void cache_etag_free(liServer *srv, gpointer param) {
|
|||
g_slice_free(cache_etag_context, ctx);
|
||||
}
|
||||
|
||||
static liAction* cache_etag_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* cache_etag_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
cache_etag_context *ctx;
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "cache.disk.etag expects a string as parameter");
|
||||
|
@ -325,16 +325,16 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "cache.disk.etag", cache_etag_create },
|
||||
{ NULL, NULL }
|
||||
{ "cache.disk.etag", cache_etag_create, NULL },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static void plugin_init(liServer *srv, liPlugin *p) {
|
||||
UNUSED(srv);
|
||||
static void plugin_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
@ -344,7 +344,7 @@ static void plugin_init(liServer *srv, liPlugin *p) {
|
|||
gboolean mod_cache_disk_etag_init(liModules *mods, liModule *mod) {
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(mods->main, "mod_cache_disk_etag", plugin_init);
|
||||
mod->config = li_plugin_register(mods->main, "mod_cache_disk_etag", plugin_init, NULL);
|
||||
|
||||
return mod->config != NULL;
|
||||
}
|
||||
|
|
|
@ -295,8 +295,8 @@ static liHandlerResult debug_show_connections(liVRequest *vr, gpointer param, gp
|
|||
return (*context) ? LI_HANDLER_WAIT_FOR_EVENT : LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* debug_show_connections_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(srv); UNUSED(p);
|
||||
static liAction* debug_show_connections_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (val) {
|
||||
ERROR(srv, "%s", "debug.show_connections doesn't expect any parameters");
|
||||
|
@ -312,18 +312,18 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "debug.show_connections", debug_show_connections_create },
|
||||
{ "debug.show_connections", debug_show_connections_create, NULL },
|
||||
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
static void plugin_debug_init(liServer *srv, liPlugin *p) {
|
||||
UNUSED(srv);
|
||||
static void plugin_debug_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
@ -336,7 +336,7 @@ gboolean mod_debug_init(liModules *mods, liModule *mod) {
|
|||
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(mods->main, "mod_debug", plugin_debug_init);
|
||||
mod->config = li_plugin_register(mods->main, "mod_debug", plugin_debug_init, NULL);
|
||||
|
||||
return mod->config != NULL;
|
||||
}
|
||||
|
|
|
@ -658,11 +658,9 @@ static const GString
|
|||
don_outputbuffer = { CONST_STR_LEN("output-buffer"), 0 }
|
||||
;
|
||||
|
||||
static liAction* deflate_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* deflate_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
deflate_config *conf;
|
||||
UNUSED(srv);
|
||||
UNUSED(p);
|
||||
UNUSED(val);
|
||||
UNUSED(userdata);
|
||||
|
||||
if (val && val->type != LI_VALUE_HASH) {
|
||||
ERROR(srv, "%s", "deflate expects an optional hash of options");
|
||||
|
@ -724,17 +722,17 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "deflate", deflate_create },
|
||||
{ NULL, NULL }
|
||||
{ "deflate", deflate_create, NULL },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
static void plugin_init(liServer *srv, liPlugin *p) {
|
||||
UNUSED(srv);
|
||||
static void plugin_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
@ -744,7 +742,7 @@ static void plugin_init(liServer *srv, liPlugin *p) {
|
|||
gboolean mod_deflate_init(liModules *mods, liModule *mod) {
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(mods->main, "mod_deflate", plugin_init);
|
||||
mod->config = li_plugin_register(mods->main, "mod_deflate", plugin_init, NULL);
|
||||
|
||||
return mod->config != NULL;
|
||||
}
|
||||
|
|
|
@ -609,12 +609,13 @@ static void dirlist_free(liServer *srv, gpointer param) {
|
|||
g_slice_free(dirlist_data, data);
|
||||
}
|
||||
|
||||
static liAction* dirlist_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* dirlist_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
dirlist_data *data;
|
||||
guint i;
|
||||
guint j;
|
||||
liValue *v, *tmpval;
|
||||
GString *k;
|
||||
UNUSED(userdata);
|
||||
|
||||
if (val && val->type != LI_VALUE_LIST) {
|
||||
ERROR(srv, "%s", "dirlist expects an optional list of string-value pairs");
|
||||
|
@ -786,13 +787,13 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "dirlist", dirlist_create },
|
||||
{ "dirlist", dirlist_create, NULL },
|
||||
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
|
@ -806,10 +807,10 @@ static void plugin_dirlist_free(liServer *srv, liPlugin *p) {
|
|||
}
|
||||
|
||||
|
||||
static void plugin_dirlist_init(liServer *srv, liPlugin *p) {
|
||||
static void plugin_dirlist_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
dirlist_plugin_data *pd;
|
||||
|
||||
UNUSED(srv);
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
@ -826,7 +827,7 @@ gboolean mod_dirlist_init(liModules *mods, liModule *mod) {
|
|||
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(mods->main, "mod_dirlist", plugin_dirlist_init);
|
||||
mod->config = li_plugin_register(mods->main, "mod_dirlist", plugin_dirlist_init, NULL);
|
||||
|
||||
return mod->config != NULL;
|
||||
}
|
||||
|
|
|
@ -131,12 +131,11 @@ static void expire_free(liServer *srv, gpointer param) {
|
|||
g_slice_free(expire_rule, param);
|
||||
}
|
||||
|
||||
static liAction* expire_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* expire_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
expire_rule *rule;
|
||||
gchar *str;
|
||||
|
||||
UNUSED(srv);
|
||||
UNUSED(p);
|
||||
UNUSED(p); UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "expire expects a string as parameter");
|
||||
|
@ -241,18 +240,18 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "expire", expire_create },
|
||||
{ "expire", expire_create, NULL },
|
||||
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
static void plugin_expire_init(liServer *srv, liPlugin *p) {
|
||||
UNUSED(srv);
|
||||
static void plugin_expire_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
@ -265,7 +264,7 @@ gboolean mod_expire_init(liModules *mods, liModule *mod) {
|
|||
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(mods->main, "mod_expire", plugin_expire_init);
|
||||
mod->config = li_plugin_register(mods->main, "mod_expire", plugin_expire_init, NULL);
|
||||
|
||||
return mod->config != NULL;
|
||||
}
|
||||
|
|
|
@ -768,9 +768,11 @@ static void fastcgi_free(liServer *srv, gpointer param) {
|
|||
fastcgi_context_release(ctx);
|
||||
}
|
||||
|
||||
static liAction* fastcgi_create(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static liAction* fastcgi_create(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
fastcgi_context *ctx;
|
||||
|
||||
UNUSED(userdata);
|
||||
|
||||
if (val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "%s", "fastcgi expects a string as parameter");
|
||||
return FALSE;
|
||||
|
@ -789,17 +791,17 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "fastcgi", fastcgi_create },
|
||||
{ NULL, NULL }
|
||||
{ "fastcgi", fastcgi_create, NULL },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
static void plugin_init(liServer *srv, liPlugin *p) {
|
||||
UNUSED(srv);
|
||||
static void plugin_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
@ -813,7 +815,7 @@ static void plugin_init(liServer *srv, liPlugin *p) {
|
|||
gboolean mod_fastcgi_init(liModules *mods, liModule *mod) {
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(mods->main, "mod_fastcgi", plugin_init);
|
||||
mod->config = li_plugin_register(mods->main, "mod_fastcgi", plugin_init, NULL);
|
||||
|
||||
return mod->config != NULL;
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@ static liHandlerResult fortune_header_handle(liVRequest *vr, gpointer param, gpo
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* fortune_header(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(srv); UNUSED(val);
|
||||
static liAction* fortune_header(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(val); UNUSED(userdata);
|
||||
return li_action_new_function(fortune_header_handle, NULL, NULL, p->data);
|
||||
}
|
||||
|
||||
|
@ -87,18 +87,19 @@ static liHandlerResult fortune_page_handle(liVRequest *vr, gpointer param, gpoin
|
|||
return LI_HANDLER_GO_ON;
|
||||
}
|
||||
|
||||
static liAction* fortune_page(liServer *srv, liPlugin* p, liValue *val) {
|
||||
UNUSED(srv); UNUSED(val);
|
||||
static liAction* fortune_page(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
UNUSED(srv); UNUSED(val); UNUSED(userdata);
|
||||
return li_action_new_function(fortune_page_handle, NULL, NULL, p->data);
|
||||
}
|
||||
|
||||
static gboolean fortune_load(liServer *srv, liPlugin* p, liValue *val) {
|
||||
static gboolean fortune_load(liServer *srv, liPlugin* p, liValue *val, gpointer userdata) {
|
||||
gchar *file;
|
||||
GError *err = NULL;
|
||||
gchar *data;
|
||||
gsize len;
|
||||
guint count = 0;
|
||||
fortune_data *fd = p->data;
|
||||
UNUSED(userdata);
|
||||
|
||||
if (!val || val->type != LI_VALUE_STRING) {
|
||||
ERROR(srv, "fortune.load takes a string as parameter, %s given", val ? li_value_type_string(val->type) : "none");
|
||||
|
@ -148,15 +149,16 @@ static const liPluginOption options[] = {
|
|||
};
|
||||
|
||||
static const liPluginAction actions[] = {
|
||||
{ "fortune.header", fortune_header },
|
||||
{ "fortune.page", fortune_page },
|
||||
{ "fortune.header", fortune_header, NULL },
|
||||
{ "fortune.page", fortune_page, NULL },
|
||||
|
||||
{ NULL, NULL }
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static const liPluginSetup setups[] = {
|
||||
{ "fortune.load", fortune_load },
|
||||
{ NULL, NULL }
|
||||
{ "fortune.load", fortune_load, NULL },
|
||||
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
|
@ -175,9 +177,9 @@ static void plugin_fortune_free(liServer *srv, liPlugin *p) {
|
|||
g_slice_free(fortune_data, fd);
|
||||
}
|
||||
|
||||
static void plugin_fortune_init(liServer *srv, liPlugin *p) {
|
||||
static void plugin_fortune_init(liServer *srv, liPlugin *p, gpointer userdata) {
|
||||
fortune_data *fd;
|
||||
UNUSED(srv);
|
||||
UNUSED(srv); UNUSED(userdata);
|
||||
|
||||
p->options = options;
|
||||
p->actions = actions;
|
||||
|
@ -196,7 +198,7 @@ gboolean mod_fortune_init(liModules *mods, liModule *mod) {
|
|||
|
||||
MODULE_VERSION_CHECK(mods);
|
||||
|
||||
mod->config = li_plugin_register(srv, "mod_fortune", plugin_fortune_init);
|
||||
mod->config = li_plugin_register(srv, "mod_fortune", plugin_fortune_init, NULL);
|
||||
|
||||
if (!mod->config)
|
||||
return FALSE;
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
* none
|
||||
* Actions:
|
||||
* lua.handler filename, [ "ttl": 300 ]
|
||||
* - Basically the same as include_lua, but loads the script in a worker
|
||||
* specific lua_State, so it doesn't use the server wide lua lock.
|
||||
* - Basically the same as include_lua (no setup.* calls allowed), but loads the script
|
||||
* in a worker specific lua_State, so it doesn't use the server wide lua lock.
|
||||
* - You can give a ttl, after which the file is checked for modifications
|
||||
* and reloaded. The default value 0 disables reloading.
|
||||
*
|
||||
|
@ -139,11 +139,11 @@ static const GString /* lua option names */
|
|||
lon_ttl = { CONST_STR_LEN("ttl"), 0 }
|
||||
;
|
||||
|
||||
static liAction* lua_handler_create( |