diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-14 17:57:08 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-10-14 17:57:08 +0100 |
commit | d325b95656c091b75e0520d71ac865eb7bb047eb (patch) | |
tree | a2991edc39bb66f130afd7686dd3797c516f262b | |
parent | 88e8dc5fcb2a501728c0558501ed2345aff7a94f (diff) | |
download | rspamd-d325b95656c091b75e0520d71ac865eb7bb047eb.tar.gz rspamd-d325b95656c091b75e0520d71ac865eb7bb047eb.zip |
[Minor] Add method to iterate through all headers
-rw-r--r-- | src/libmime/mime_headers.c | 16 | ||||
-rw-r--r-- | src/libmime/mime_headers.h | 10 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/libmime/mime_headers.c b/src/libmime/mime_headers.c index 3deb26a08..76ae1770a 100644 --- a/src/libmime/mime_headers.c +++ b/src/libmime/mime_headers.c @@ -958,6 +958,22 @@ rspamd_mime_headers_count (struct rspamd_mime_headers_table *hdrs) return 0; } +bool +rspamd_mime_headers_foreach(const struct rspamd_mime_headers_table *hdrs, + rspamd_hdr_traverse_func_t func, void *ud) +{ + const gchar *name; + struct rspamd_mime_header *hdr; + + kh_foreach(&hdrs->htb, name, hdr, { + if (!func(name, hdr, ud)) { + return false; + } + }); + + return true; +} + 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 7174f9e8f..43dd26e87 100644 --- a/src/libmime/mime_headers.h +++ b/src/libmime/mime_headers.h @@ -167,6 +167,16 @@ struct rspamd_mime_headers_table* rspamd_message_headers_new (void); */ gsize rspamd_mime_headers_count (struct rspamd_mime_headers_table *hdrs); +typedef bool(rspamd_hdr_traverse_func_t)(const gchar *, const struct rspamd_mime_header *, void *); +/** + * Traverse all headers in a table + * @param func + * @param ud + * @return + */ +bool rspamd_mime_headers_foreach(const struct rspamd_mime_headers_table *, + rspamd_hdr_traverse_func_t func, void *ud); + /** * Strip rfc822 CFWS sequences from a string in place * @param input input |