aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-10-14 15:15:36 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-10-14 15:15:36 +0100
commit88e8dc5fcb2a501728c0558501ed2345aff7a94f (patch)
treeb9ba5b3283762d14c295d91e087cb6ad0d1ba0ec
parent943a36c4a6f3ce6f3e37ddd52422094d1e47d23b (diff)
downloadrspamd-88e8dc5fcb2a501728c0558501ed2345aff7a94f.tar.gz
rspamd-88e8dc5fcb2a501728c0558501ed2345aff7a94f.zip
[Minor] Add method to get count of the headers
-rw-r--r--src/libmime/mime_headers.c10
-rw-r--r--src/libmime/mime_headers.h7
2 files changed, 17 insertions, 0 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c
index 88675a629..3deb26a08 100644
--- a/src/libmime/mime_headers.c
+++ b/src/libmime/mime_headers.c
@@ -948,6 +948,16 @@ rspamd_message_get_header_array (struct rspamd_task *task, const gchar *field,
field, need_modified);
}
+gsize
+rspamd_mime_headers_count (struct rspamd_mime_headers_table *hdrs)
+{
+ if (hdrs) {
+ return kh_size (&hdrs->htb);
+ }
+
+ return 0;
+}
+
static void
rspamd_message_headers_dtor (struct rspamd_mime_headers_table *hdrs)
{
diff --git a/src/libmime/mime_headers.h b/src/libmime/mime_headers.h
index 07a64c31e..7174f9e8f 100644
--- a/src/libmime/mime_headers.h
+++ b/src/libmime/mime_headers.h
@@ -161,6 +161,13 @@ struct rspamd_mime_headers_table * rspamd_message_headers_ref (struct rspamd_mim
struct rspamd_mime_headers_table* rspamd_message_headers_new (void);
/**
+ * Returns size for a headers table
+ * @param hdrs
+ * @return
+ */
+gsize rspamd_mime_headers_count (struct rspamd_mime_headers_table *hdrs);
+
+/**
* Strip rfc822 CFWS sequences from a string in place
* @param input input
* @param len length of the input