summaryrefslogtreecommitdiffstats
path: root/src/libmime
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-09 13:13:38 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-09 13:13:38 +0100
commita36ee5a03288e9fabf82778a4a1a197bf0e69327 (patch)
tree37836a1bd0fc0eda1c4ae7723478917636e27111 /src/libmime
parentc1c8dba96ef13bfc8725a5142d751601c48c6719 (diff)
downloadrspamd-a36ee5a03288e9fabf82778a4a1a197bf0e69327.tar.gz
rspamd-a36ee5a03288e9fabf82778a4a1a197bf0e69327.zip
[Feature] Allow to get mime headers from a task
Diffstat (limited to 'src/libmime')
-rw-r--r--src/libmime/message.c49
-rw-r--r--src/libmime/message.h4
2 files changed, 53 insertions, 0 deletions
diff --git a/src/libmime/message.c b/src/libmime/message.c
index f14c3b185..a7a3f7439 100644
--- a/src/libmime/message.c
+++ b/src/libmime/message.c
@@ -1985,8 +1985,57 @@ rspamd_message_get_header_array (struct rspamd_task *task,
ret = g_ptr_array_sized_new (nelems);
LL_FOREACH (rh, cur) {
+ if (strong) {
+ if (strcmp (rh->name, field) != 0) {
+ continue;
+ }
+ }
+
g_ptr_array_add (ret, cur);
}
return ret;
}
+
+GPtrArray *
+rspamd_message_get_mime_header_array (struct rspamd_task *task,
+ const gchar *field,
+ gboolean strong)
+{
+ GPtrArray *ret;
+ struct raw_header *rh, *cur;
+ guint nelems = 0, i;
+ struct mime_part *mp;
+
+ for (i = 0; i < task->parts->len; i ++) {
+ mp = g_ptr_array_index (task->parts, i);
+ rh = g_hash_table_lookup (mp->raw_headers, field);
+
+ if (rh == NULL) {
+ continue;
+ }
+
+ LL_FOREACH (rh, cur) {
+ nelems ++;
+ }
+ }
+
+ ret = g_ptr_array_sized_new (nelems);
+
+ for (i = 0; i < task->parts->len; i ++) {
+ mp = g_ptr_array_index (task->parts, i);
+ rh = g_hash_table_lookup (mp->raw_headers, field);
+
+ LL_FOREACH (rh, cur) {
+ if (strong) {
+ if (strcmp (rh->name, field) != 0) {
+ continue;
+ }
+ }
+
+ g_ptr_array_add (ret, cur);
+ }
+ }
+
+ return ret;
+}
diff --git a/src/libmime/message.h b/src/libmime/message.h
index 06ff78e7a..d946fa0a4 100644
--- a/src/libmime/message.h
+++ b/src/libmime/message.h
@@ -91,4 +91,8 @@ GPtrArray *rspamd_message_get_header_array (struct rspamd_task *task,
const gchar *field,
gboolean strong);
+GPtrArray *rspamd_message_get_mime_header_array (struct rspamd_task *task,
+ const gchar *field,
+ gboolean strong);
+
#endif