diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-05 17:26:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-04-05 17:26:28 +0100 |
commit | 29bbf526f4e7d6fe31618901a753ee350fbe03d5 (patch) | |
tree | e9daa1dbccbb1789f75bfa8427e6d53f8a4fe20c /src/lua/lua_config.c | |
parent | 5cb2fe96545d019d9a457f9be307eea165790b09 (diff) | |
download | rspamd-29bbf526f4e7d6fe31618901a753ee350fbe03d5.tar.gz rspamd-29bbf526f4e7d6fe31618901a753ee350fbe03d5.zip |
[Feature] Add method to get number of symbols in the cache
Diffstat (limited to 'src/lua/lua_config.c')
-rw-r--r-- | src/lua/lua_config.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index cbf68dd07..aa4327b27 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -404,6 +404,13 @@ LUA_FUNCTION_DEF (config, register_worker_script); */ LUA_FUNCTION_DEF (config, add_on_load); +/*** + * @method rspamd_config:get_symbols_count() + * Returns number of symbols registered in rspamd configuration + * @return {number} number of symbols registered in the configuration + */ +LUA_FUNCTION_DEF (config, get_symbols_count); + static const struct luaL_reg configlib_m[] = { LUA_INTERFACE_DEF (config, get_module_opt), LUA_INTERFACE_DEF (config, get_mempool), @@ -433,6 +440,7 @@ static const struct luaL_reg configlib_m[] = { LUA_INTERFACE_DEF (config, replace_regexp), LUA_INTERFACE_DEF (config, register_worker_script), LUA_INTERFACE_DEF (config, add_on_load), + LUA_INTERFACE_DEF (config, get_symbols_count), {"__tostring", rspamd_lua_class_tostring}, {"__newindex", lua_config_newindex}, {NULL, NULL} @@ -1702,6 +1710,24 @@ lua_config_add_on_load (lua_State *L) return 0; } +static gint +lua_config_get_symbols_count (lua_State *L) +{ + struct rspamd_config *cfg = lua_check_config (L, 1); + guint res = 0; + + if (cfg != NULL) { + res = rspamd_symbols_cache_symbols_count (cfg->cache); + } + else { + return luaL_error (L, "invalid arguments"); + } + + lua_pushnumber (L, res); + + return 1; +} + void luaopen_config (lua_State * L) { |