aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-07-24 18:39:11 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-07-24 18:39:11 +0100
commit03bba7bf399390e13c6f871794d24d0de885277e (patch)
treeb83ed223975f32946864f2dfb95485e024448d80 /src
parent92b92556c64aa427d2b2e022e2ce61e728ab9923 (diff)
downloadrspamd-03bba7bf399390e13c6f871794d24d0de885277e.tar.gz
rspamd-03bba7bf399390e13c6f871794d24d0de885277e.zip
[Project] Add helpers
Diffstat (limited to 'src')
-rw-r--r--src/libmime/filter.c33
-rw-r--r--src/libmime/filter.h19
2 files changed, 52 insertions, 0 deletions
diff --git a/src/libmime/filter.c b/src/libmime/filter.c
index f9901da7c..8677ef8a1 100644
--- a/src/libmime/filter.c
+++ b/src/libmime/filter.c
@@ -419,3 +419,36 @@ rspamd_check_action_metric (struct rspamd_task *task, struct rspamd_metric_resul
return METRIC_ACTION_NOACTION;
}
+
+struct rspamd_symbol_result*
+rspamd_task_find_symbol_result (struct rspamd_task *task, const char *sym)
+{
+ struct rspamd_symbol_result *res = NULL;
+ khiter_t k;
+
+
+ if (task->result) {
+ k = kh_get (rspamd_symbols_hash, task->result->symbols, sym);
+
+ if (k != kh_end (task->result->symbols)) {
+ res = &kh_value (task->result->symbols, k);
+ }
+ }
+
+ return res;
+}
+
+void
+rspamd_task_symbol_result_foreach (struct rspamd_task *task,
+ GHFunc func,
+ gpointer ud)
+{
+ const gchar *kk;
+ struct rspamd_symbol_result res;
+
+ if (func && task->result) {
+ kh_foreach (task->result->symbols, kk, res, {
+ func ((gpointer)kk, (gpointer)&res, ud);
+ });
+ }
+} \ No newline at end of file
diff --git a/src/libmime/filter.h b/src/libmime/filter.h
index 4f75cc192..de8cb57b8 100644
--- a/src/libmime/filter.h
+++ b/src/libmime/filter.h
@@ -105,6 +105,25 @@ gboolean rspamd_task_add_result_option (struct rspamd_task *task,
struct rspamd_symbol_result *s, const gchar *opt);
/**
+ * Finds symbol result
+ * @param task
+ * @param sym
+ * @return
+ */
+struct rspamd_symbol_result* rspamd_task_find_symbol_result (
+ struct rspamd_task *task, const char *sym);
+
+/**
+ * Compatibility function to iterate on symbols hash
+ * @param task
+ * @param func
+ * @param ud
+ */
+void rspamd_task_symbol_result_foreach (struct rspamd_task *task,
+ GHFunc func,
+ gpointer ud);
+
+/**
* Default consolidation function for metric, it get all symbols and multiply symbol
* weight by some factor that is specified in config. Default factor is 1.
* @param task worker's task that present message from user