Add plugin init-lua hook

personal/stbuehler/wip
Stefan Bühler 13 years ago
parent 4afebee1c7
commit c2271c15c3
  1. 8
      include/lighttpd/plugin.h
  2. 2
      src/main/core_lua.c
  3. 14
      src/main/plugin.c

@ -24,6 +24,10 @@ typedef void (*liPluginHandleCloseCB) (liConnection *con, liPlugin *p);
typedef liHandlerResult(*liPluginHandleVRequestCB)(liVRequest *vr, liPlugin *p);
typedef void (*liPluginHandleVRCloseCB) (liVRequest *vr, liPlugin *p);
struct lua_State;
typedef void (*liPluginInitLua)(struct lua_State *L, liServer *srv, liWorker *wrk, liPlugin *p);
struct liPlugin {
size_t version;
const gchar *name; /**< name of the plugin */
@ -50,6 +54,8 @@ struct liPlugin {
/* server state machine hooks */
liPluginServerState handle_prepare, handle_start_listen, handle_stop_listen, handle_start_log, handle_stop_log;
liPluginInitLua handle_init_lua;
const liPluginOption *options;
const liPluginOptionPtr *optionptrs;
const liPluginAction *actions;
@ -189,6 +195,8 @@ LI_API gboolean li_call_setup(liServer *srv, const char *name, liValue *val);
/** free val after call */
LI_API gboolean li_plugin_set_default_option(liServer *srv, const gchar* name, liValue *val);
LI_API void li_plugins_init_lua(struct lua_State *L, liServer *srv, liWorker *wrk);
extern liOptionPtrValue li_option_ptr_zero;
/* needs vrequest *vr and plugin *p */

@ -297,6 +297,8 @@ void li_lua_init(lua_State *L, liServer *srv, liWorker *wrk) {
lua_setfield(L, LUA_GLOBALSINDEX, "lighty");
li_lua_store_globals(L);
li_plugins_init_lua(L, srv, wrk);
}
void li_lua_restore_globals(lua_State *L) {

@ -685,3 +685,17 @@ void li_plugins_stop_log(liServer *srv) { /* "suspend now" */
}
}
}
void li_plugins_init_lua(struct lua_State *L, liServer *srv, liWorker *wrk) {
GHashTableIter iter;
liPlugin *p;
gpointer v;
g_hash_table_iter_init(&iter, srv->plugins);
while (g_hash_table_iter_next(&iter, NULL, &v)) {
p = (liPlugin*) v;
if (p->handle_init_lua) {
p->handle_init_lua(L, srv, wrk, p);
}
}
}

Loading…
Cancel
Save