diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-12-22 18:08:14 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-12-22 18:08:14 +0300 |
commit | 29c3237009537015e66875ab9ce1fbe3e101576b (patch) | |
tree | ae47f0223ed9f5c133f60580d9ffc4d811b47fdf /src/lua | |
parent | 501f1465ff2e985def4159ab32de267e7b111624 (diff) | |
download | rspamd-29c3237009537015e66875ab9ce1fbe3e101576b.tar.gz rspamd-29c3237009537015e66875ab9ce1fbe3e101576b.zip |
* Add versions to lua API
* Provide compatibility for lua plugins for old versions of rspamd
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_common.h | 2 | ||||
-rw-r--r-- | src/lua/lua_config.c | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index 823056316..3e0fbed88 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -16,6 +16,8 @@ extern const luaL_reg null_reg[]; +#define RSPAMD_LUA_API_VERSION 1 + /* Common utility functions */ void lua_newclass (lua_State *L, const gchar *classname, const struct luaL_reg *func); void lua_setclass (lua_State *L, const gchar *classname, gint objidx); diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index e05545355..b77c97bfc 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -44,6 +44,7 @@ LUA_FUNCTION_DEF (config, register_virtual_symbol); LUA_FUNCTION_DEF (config, register_callback_symbol); LUA_FUNCTION_DEF (config, register_post_filter); LUA_FUNCTION_DEF (config, register_module_option); +LUA_FUNCTION_DEF (config, get_api_version); static const struct luaL_reg configlib_m[] = { LUA_INTERFACE_DEF (config, get_module_opt), @@ -57,6 +58,7 @@ static const struct luaL_reg configlib_m[] = { LUA_INTERFACE_DEF (config, register_callback_symbol), LUA_INTERFACE_DEF (config, register_module_option), LUA_INTERFACE_DEF (config, register_post_filter), + LUA_INTERFACE_DEF (config, get_api_version), {"__tostring", lua_class_tostring}, {NULL, NULL} }; @@ -129,6 +131,13 @@ lua_check_trie (lua_State * L) /*** Config functions ***/ static gint +lua_config_get_api_version (lua_State *L) +{ + lua_pushinteger (L, RSPAMD_LUA_API_VERSION); + return 1; +} + +static gint lua_config_get_module_opt (lua_State * L) { struct config_file *cfg = lua_check_config (L); |