diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-17 19:12:57 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-12-17 19:12:57 +0000 |
commit | 6f7fe30ec66cb7bb062424c515679c1bad50f3dc (patch) | |
tree | 2757419acdf68c02ac05535056376f08acc7e9bb /src/libutil/fstring.h | |
parent | 2fc53bab7cad105fca67f3d4b24e48001b7ea655 (diff) | |
download | rspamd-6f7fe30ec66cb7bb062424c515679c1bad50f3dc.tar.gz rspamd-6f7fe30ec66cb7bb062424c515679c1bad50f3dc.zip |
[Minor] Add macro to assing rspamd_ftok_t from c string
Diffstat (limited to 'src/libutil/fstring.h')
-rw-r--r-- | src/libutil/fstring.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libutil/fstring.h b/src/libutil/fstring.h index c1b205817..ac69b01df 100644 --- a/src/libutil/fstring.h +++ b/src/libutil/fstring.h @@ -179,4 +179,15 @@ gchar *rspamd_ftokdup (const rspamd_ftok_t *src) G_GNUC_WARN_UNUSED_RESULT; gchar *rspamd_fstringdup (const rspamd_fstring_t *src) G_GNUC_WARN_UNUSED_RESULT; #define RSPAMD_FTOK_ASSIGN(t, lit) do { (t)->begin = (lit); (t)->len = sizeof(lit) - 1; } while (0) +#define RSPAMD_FTOK_FROM_STR(t, str) do { \ + if (G_LIKELY(str)) { \ + (t)->begin = (const char*)(str); \ + (t)->len = strlen (str); \ + } \ + else { \ + (t)->begin = NULL; \ + (t)->len = 0; \ + } \ +} while (0) + #endif |