diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-15 14:47:18 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-15 14:47:18 +0000 |
commit | f4d3c21d16cd1c71f7a4bb7772e77e768a7ab8d1 (patch) | |
tree | 84b5d411e9192dfb3a003f115faf58ba89afacbc /src/libutil | |
parent | 3dadbb5159db3a59342834082144690588aa61db (diff) | |
download | rspamd-f4d3c21d16cd1c71f7a4bb7772e77e768a7ab8d1.tar.gz rspamd-f4d3c21d16cd1c71f7a4bb7772e77e768a7ab8d1.zip |
[Feature] Store stop words and allow to query them
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); |