diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-09 08:31:26 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-11-09 08:31:26 +0000 |
commit | 63ee3e00db2982e8053e2e7450cf05b268b92506 (patch) | |
tree | 86df076eddfd06f53f9e56a358086490bb254a34 /src/libutil/fstring.c | |
parent | 6d87018738712b7d01120ad3584b5db225255ce8 (diff) | |
download | rspamd-63ee3e00db2982e8053e2e7450cf05b268b92506.tar.gz rspamd-63ee3e00db2982e8053e2e7450cf05b268b92506.zip |
[Minor] Add routine to convert an ftok_t to a C string
Diffstat (limited to 'src/libutil/fstring.c')
-rw-r--r-- | src/libutil/fstring.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/libutil/fstring.c b/src/libutil/fstring.c index fac3b364b..2cfbd7bf8 100644 --- a/src/libutil/fstring.c +++ b/src/libutil/fstring.c @@ -223,8 +223,6 @@ rspamd_fstring_erase (rspamd_fstring_t *str, gsize pos, gsize len) } } -char *rspamd_fstring_cstr (const rspamd_fstring_t *str); - /* Compat code */ static guint32 fstrhash_c (gchar c, guint32 hval) @@ -418,6 +416,22 @@ rspamd_fstring_cstr (const rspamd_fstring_t *s) return result; } +char * +rspamd_ftok_cstr (const rspamd_ftok_t *s) +{ + char *result; + + if (s == NULL) { + return NULL; + } + + result = g_malloc (s->len + 1); + memcpy (result, s->begin, s->len); + result[s->len] = '\0'; + + return result; +} + gboolean rspamd_ftok_cstr_equal (const rspamd_ftok_t *s, const gchar *pat, gboolean icase) |