From 576108c64c01901848010673efc53b46a24dbc92 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 10 Dec 2015 15:38:34 +0000 Subject: Add special flag to disable hyperscan for particular expressions --- src/libutil/regexp.c | 16 ++++++++++++---- src/libutil/regexp.h | 9 +++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/libutil') diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c index 39ff5ebf2..5b3fca551 100644 --- a/src/libutil/regexp.c +++ b/src/libutil/regexp.c @@ -33,10 +33,6 @@ typedef guchar regexp_id_t[rspamd_cryptobox_HASHBYTES]; -#define RSPAMD_REGEXP_FLAG_RAW (1 << 1) -#define RSPAMD_REGEXP_FLAG_NOOPT (1 << 2) -#define RSPAMD_REGEXP_FLAG_FULL_MATCH (1 << 3) - struct rspamd_regexp_s { gdouble exec_time; gchar *pattern; @@ -493,6 +489,18 @@ rspamd_regexp_get_pattern (rspamd_regexp_t *re) return re->pattern; } +guint +rspamd_regexp_set_flags (rspamd_regexp_t *re, guint new_flags) +{ + guint old_flags; + + g_assert (re != NULL); + old_flags = re->flags; + re->flags = new_flags; + + return old_flags; +} + guint rspamd_regexp_get_flags (rspamd_regexp_t *re) { diff --git a/src/libutil/regexp.h b/src/libutil/regexp.h index 0b585ceec..bf88035e2 100644 --- a/src/libutil/regexp.h +++ b/src/libutil/regexp.h @@ -28,6 +28,10 @@ #include "config.h" #define RSPAMD_INVALID_ID ((guint64)-1LL) +#define RSPAMD_REGEXP_FLAG_RAW (1 << 1) +#define RSPAMD_REGEXP_FLAG_NOOPT (1 << 2) +#define RSPAMD_REGEXP_FLAG_FULL_MATCH (1 << 3) +#define RSPAMD_REGEXP_FLAG_PCRE_ONLY (1 << 4) typedef struct rspamd_regexp_s rspamd_regexp_t; struct rspamd_regexp_cache; @@ -121,6 +125,11 @@ guint rspamd_regexp_get_pcre_flags (rspamd_regexp_t *re); */ guint rspamd_regexp_get_flags (rspamd_regexp_t *re); +/** + * Set rspamd flags for the regexp + */ +guint rspamd_regexp_set_flags (rspamd_regexp_t *re, guint new_flags); + /** * Set regexp maximum hits */ -- cgit v1.2.3