diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-03-18 17:20:35 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2011-03-18 17:20:35 +0300 |
commit | c3314fe19509cf9e237c1ae3ba9383d692f71c00 (patch) | |
tree | 39ddda15dfcd5ca3c3e3e8305cb8e2c84767c405 /src/lua | |
parent | 9309c11521c7a93357f1160edf9693f8b50f4441 (diff) | |
download | rspamd-c3314fe19509cf9e237c1ae3ba9383d692f71c00.tar.gz rspamd-c3314fe19509cf9e237c1ae3ba9383d692f71c00.zip |
* Add strict priority rules
* Improve and fix multimap module
* Add rspamd_config object to stage of early configure of rspamd
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_common.h | 2 | ||||
-rw-r--r-- | src/lua/lua_config.c | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index 9b0c356f3..47d6956b0 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -16,7 +16,7 @@ extern const luaL_reg null_reg[]; -#define RSPAMD_LUA_API_VERSION 3 +#define RSPAMD_LUA_API_VERSION 4 /* Common utility functions */ void lua_newclass (lua_State *L, const gchar *classname, const struct luaL_reg *func); diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 62ea849f5..d69036e09 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -42,6 +42,7 @@ LUA_FUNCTION_DEF (config, get_classifier); LUA_FUNCTION_DEF (config, register_symbol); LUA_FUNCTION_DEF (config, register_virtual_symbol); LUA_FUNCTION_DEF (config, register_callback_symbol); +LUA_FUNCTION_DEF (config, register_callback_symbol_priority); LUA_FUNCTION_DEF (config, register_post_filter); LUA_FUNCTION_DEF (config, register_module_option); LUA_FUNCTION_DEF (config, get_api_version); @@ -56,6 +57,7 @@ static const struct luaL_reg configlib_m[] = { LUA_INTERFACE_DEF (config, register_symbol), LUA_INTERFACE_DEF (config, register_virtual_symbol), LUA_INTERFACE_DEF (config, register_callback_symbol), + LUA_INTERFACE_DEF (config, register_callback_symbol_priority), LUA_INTERFACE_DEF (config, register_module_option), LUA_INTERFACE_DEF (config, register_post_filter), LUA_INTERFACE_DEF (config, get_api_version), @@ -573,6 +575,32 @@ lua_config_register_callback_symbol (lua_State * L) return 1; } +static gint +lua_config_register_callback_symbol_priority (lua_State * L) +{ + struct config_file *cfg = lua_check_config (L); + const gchar *name, *callback; + double weight; + gint priority; + struct lua_callback_data *cd; + + if (cfg) { + name = memory_pool_strdup (cfg->cfg_pool, luaL_checkstring (L, 2)); + weight = luaL_checknumber (L, 3); + priority = luaL_checknumber (L, 4); + callback = luaL_checkstring (L, 5); + + if (name) { + cd = g_malloc (sizeof (struct lua_callback_data)); + cd->name = g_strdup (callback); + cd->L = L; + register_callback_symbol_priority (&cfg->cache, name, weight, priority, lua_metric_symbol_callback, cd); + } + } + return 1; +} + + /* Radix and hash table functions */ static gint lua_radix_get_key (lua_State * L) |