aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_buffer.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-25 13:17:21 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-25 13:17:21 +0100
commitc2765b3eb3c3beb3d9f42dc061761df2e300904c (patch)
tree0f5924f4fd821b16a258465d9dcb0068e5332bf2 /src/lua/lua_buffer.c
parenta1be94b4c4b59de216e0b8b721a951b2325f7215 (diff)
downloadrspamd-c2765b3eb3c3beb3d9f42dc061761df2e300904c.tar.gz
rspamd-c2765b3eb3c3beb3d9f42dc061761df2e300904c.zip
Use modules preload for lua.
Diffstat (limited to 'src/lua/lua_buffer.c')
-rw-r--r--src/lua/lua_buffer.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/lua/lua_buffer.c b/src/lua/lua_buffer.c
index 97598e606..ee64a84ab 100644
--- a/src/lua/lua_buffer.c
+++ b/src/lua/lua_buffer.c
@@ -26,7 +26,7 @@
/* Public prototypes */
struct rspamd_io_dispatcher_s * lua_check_io_dispatcher (lua_State * L);
-gint luaopen_io_dispatcher (lua_State * L);
+void luaopen_io_dispatcher (lua_State * L);
/* Lua bindings */
LUA_FUNCTION_DEF (io_dispatcher, create);
@@ -344,8 +344,17 @@ lua_io_dispatcher_destroy (lua_State *L)
return 1;
}
+static gint
+lua_load_dispatcher (lua_State *L)
+{
+ lua_newtable (L);
+ luaL_register (L, NULL, io_dispatcherlib_f);
+
+ return 1;
+}
-gint
+
+void
luaopen_io_dispatcher (lua_State * L)
{
luaL_newmetatable (L, "rspamd{io_dispatcher}");
@@ -358,14 +367,11 @@ luaopen_io_dispatcher (lua_State * L)
lua_rawset (L, -3);
luaL_register (L, NULL, io_dispatcherlib_m);
- luaL_register (L, "rspamd_io_dispatcher", io_dispatcherlib_f);
-
lua_pop (L, 1); /* remove metatable from stack */
+ rspamd_lua_add_preload (L, "rspamd_io_dispatcher", lua_load_dispatcher);
/* Simple event class */
rspamd_lua_new_class (L, "rspamd{ev_base}", null_reg);
- luaL_register (L, "rspamd_ev_base", null_reg);
-
lua_pop (L, 1); /* remove metatable from stack */
/* Set buffer types globals */
@@ -375,5 +381,4 @@ luaopen_io_dispatcher (lua_State * L)
lua_setglobal (L, "IO_BUFFER_CHARACTER");
lua_pushnumber (L, BUFFER_ANY);
lua_setglobal (L, "IO_BUFFER_ANY");
- return 1;
}