aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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