]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Add auxiliary functions for symbols cache
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 29 Jul 2017 14:08:03 +0000 (15:08 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 29 Jul 2017 14:08:03 +0000 (15:08 +0100)
src/libserver/symbols_cache.c
src/libserver/symbols_cache.h

index 0728d0ee66b57afdcd4bf408cd4e7d587b39c285..46f1b3fc62624e2ac6a3fb48bc1fe0e4b6852e86 100644 (file)
@@ -2462,3 +2462,16 @@ rspamd_symbols_cache_is_symbol_enabled (struct rspamd_task *task,
 
        return ret;
 }
+
+void
+rspamd_symbols_cache_foreach (struct symbols_cache *cache,
+               void (*func)(gint , const gchar *, gint , gpointer ),
+               gpointer ud)
+{
+       guint i;
+       struct cache_item *item;
+
+       PTR_ARRAY_FOREACH (cache->items_by_id, i, item) {
+               func (item->id, item->symbol, item->type, ud);
+       }
+}
index dedcda4e612d03ca11e020f4290994b336ead09f..f717b39b9ed8be2a5f1425d084482f394159ba5a 100644 (file)
@@ -40,6 +40,7 @@ enum rspamd_symbol_type {
        SYMBOL_TYPE_EMPTY = (1 << 8), /* Allow execution on empty tasks */
        SYMBOL_TYPE_PREFILTER = (1 << 9),
        SYMBOL_TYPE_POSTFILTER = (1 << 10),
+       SYMBOL_TYPE_NONSTAT = (1 << 11), /* Skip as statistical symbol */
 };
 
 /**
@@ -290,4 +291,15 @@ guint64 rspamd_symbols_cache_get_cksum (struct symbols_cache *cache);
  */
 gboolean rspamd_symbols_cache_is_symbol_enabled (struct rspamd_task *task,
                struct symbols_cache *cache, const gchar *symbol);
+/**
+ * Process specific function for each cache element (in order they are added)
+ * @param cache
+ * @param func
+ * @param ud
+ */
+void rspamd_symbols_cache_foreach (struct symbols_cache *cache,
+               void (*func)(gint /* id */, const gchar * /* name */,
+                               gint /* flags */, gpointer /* userdata */),
+               gpointer ud);
+
 #endif