return item->symbol;
}
+guint
+rspamd_symbols_cache_symbols_count (struct symbols_cache *cache)
+{
+ g_assert (cache != NULL);
+
+ return cache->items_by_id->len;
+}
+
void
rspamd_symbols_cache_disable_symbol (struct rspamd_task *task,
struct symbols_cache *cache, const gchar *symbol)
const gchar * rspamd_symbols_cache_symbol_by_id (struct symbols_cache *cache,
gint id);
+/**
+ * Returns number of symbols registered in symbols cache
+ * @param cache
+ * @return number of symbols in the cache
+ */
+guint rspamd_symbols_cache_symbols_count (struct symbols_cache *cache);
+
/**
* Call function for cached symbol using saved callback
* @param task task object
*/
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),
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}
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)
{