diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/str_util.c | 24 | ||||
-rw-r--r-- | src/libutil/str_util.h | 2 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c index 4f7aa1c97..f798d9eeb 100644 --- a/src/libutil/str_util.c +++ b/src/libutil/str_util.c @@ -297,18 +297,38 @@ rspamd_ftok_icase_hash (gconstpointer key) } gboolean +rspamd_ftok_equal (gconstpointer v, gconstpointer v2) +{ + const rspamd_ftok_t *f1 = v, *f2 = v2; + + if (f1->len == f2->len && + memcmp (f1->begin, f2->begin, f1->len) == 0) { + return TRUE; + } + + return FALSE; +} + +guint +rspamd_ftok_hash (gconstpointer key) +{ + const rspamd_ftok_t *f = key; + + return t1ha (f->begin, f->len, rspamd_hash_seed ()); +} + +gboolean rspamd_gstring_icase_equal (gconstpointer v, gconstpointer v2) { const GString *f1 = v, *f2 = v2; if (f1->len == f2->len && - rspamd_lc_cmp (f1->str, f2->str, f1->len) == 0) { + rspamd_lc_cmp (f1->str, f2->str, f1->len) == 0) { return TRUE; } return FALSE; } - guint rspamd_gstring_icase_hash (gconstpointer key) { diff --git a/src/libutil/str_util.h b/src/libutil/str_util.h index 73637a62c..100b64b88 100644 --- a/src/libutil/str_util.h +++ b/src/libutil/str_util.h @@ -61,6 +61,8 @@ gboolean rspamd_str_equal (gconstpointer v, gconstpointer v2); */ guint rspamd_ftok_icase_hash (gconstpointer key); gboolean rspamd_ftok_icase_equal (gconstpointer v, gconstpointer v2); +guint rspamd_ftok_hash (gconstpointer key); +gboolean rspamd_ftok_equal (gconstpointer v, gconstpointer v2); guint rspamd_gstring_icase_hash (gconstpointer key); gboolean rspamd_gstring_icase_equal (gconstpointer v, gconstpointer v2); |