diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-11-05 16:22:56 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-11-05 16:22:56 +0300 |
commit | 58fc8c267ac9a619bc3c9cfce108c0d2a0d338fc (patch) | |
tree | 44d029c52f66593c63e2d45bc3a8883231bd19c9 | |
parent | 063ad836a7e2a61192d3a6ca13b07114c4923c09 (diff) | |
download | rspamd-58fc8c267ac9a619bc3c9cfce108c0d2a0d338fc.tar.gz rspamd-58fc8c267ac9a619bc3c9cfce108c0d2a0d338fc.zip |
Add routine to compare an ftok with C string
-rw-r--r-- | src/libutil/fstring.c | 21 | ||||
-rw-r--r-- | src/libutil/fstring.h | 6 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c index 3d5c59061..d75b731fb 100644 --- a/src/libutil/fstring.c +++ b/src/libutil/fstring.c @@ -376,3 +376,24 @@ rspamd_fstring_cstr (const rspamd_fstring_t *s) return result; } + +gboolean +rspamd_ftok_cstr_equal (const rspamd_ftok_t *s, const gchar *pat, + gboolean icase) +{ + gsize slen; + rspamd_ftok_t srch; + + g_assert (s != NULL); + g_assert (pat != NULL); + + slen = strlen (pat); + srch.begin = pat; + srch.len = slen; + + if (icase) { + return (rspamd_ftok_casecmp (s, &srch) == 0); + } + + return (rspamd_ftok_cmp (s, &srch) == 0); +} diff --git a/src/libutil/fstring.h b/src/libutil/fstring.h index d3b51821f..79c96932b 100644 --- a/src/libutil/fstring.h +++ b/src/libutil/fstring.h @@ -134,6 +134,12 @@ gint rspamd_ftok_cmp (const rspamd_ftok_t *s1, const rspamd_ftok_t *s2); /** + * Return TRUE if ftok is equal to specified C string + */ +gboolean rspamd_ftok_cstr_equal (const rspamd_ftok_t *s, + const gchar *pat, gboolean icase); + +/** * Free fstring_t that is mapped to ftok_t * * | len | allocated | <data> -- fstring_t |