aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/fstring.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/fstring.h')
-rw-r--r--src/libutil/fstring.h11
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