summaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-17 18:14:31 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-17 18:14:31 +0100
commit1f0f66e32c037b922edffd4e8c66ae93cd988691 (patch)
tree1c577517c34ed03adb1cc28f751ad3546a73302b /src/libserver
parent00de10fa6d82fd3f0c2794aaa60772f785dffc84 (diff)
downloadrspamd-1f0f66e32c037b922edffd4e8c66ae93cd988691.tar.gz
rspamd-1f0f66e32c037b922edffd4e8c66ae93cd988691.zip
Rework adding symbols from lua.
It is now possible to use something like: rspamd_config.SYMBOL = function(task) ... end or even rspamd_config.SYMBOL = { callback = function(task) ... end, weight = '1.0', --optional priority = '0', --optional type = 'callback' --optional }
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/symbols_cache.c8
-rw-r--r--src/libserver/symbols_cache.h24
2 files changed, 25 insertions, 7 deletions
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index 185b1e105..823af39f5 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -281,13 +281,7 @@ create_cache_file (struct symbols_cache *cache,
return mmap_cache_file (cache, fd, pool);
}
-enum rspamd_symbol_type {
- SYMBOL_TYPE_NORMAL,
- SYMBOL_TYPE_VIRTUAL,
- SYMBOL_TYPE_CALLBACK
-};
-
-static void
+void
register_symbol_common (struct symbols_cache **cache,
const gchar *name,
double weight,
diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h
index 36128460d..fd9da2ef7 100644
--- a/src/libserver/symbols_cache.h
+++ b/src/libserver/symbols_cache.h
@@ -49,6 +49,11 @@ struct cache_item {
gdouble metric_weight;
};
+enum rspamd_symbol_type {
+ SYMBOL_TYPE_NORMAL,
+ SYMBOL_TYPE_VIRTUAL,
+ SYMBOL_TYPE_CALLBACK
+};
struct symbols_cache {
/* Normal cache items */
@@ -147,6 +152,25 @@ void register_dynamic_symbol (rspamd_mempool_t *pool,
GList *networks);
/**
+ * Generic function to register a symbol
+ * @param cache
+ * @param name
+ * @param weight
+ * @param priority
+ * @param func
+ * @param user_data
+ * @param type
+ */
+void
+register_symbol_common (struct symbols_cache **cache,
+ const gchar *name,
+ double weight,
+ gint priority,
+ symbol_func_t func,
+ gpointer user_data,
+ enum rspamd_symbol_type type);
+
+/**
* Call function for cached symbol using saved callback
* @param task task object
* @param cache symbols cache