aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-03 09:24:59 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-03 09:24:59 +0000
commita752628025143687ee60f6f1cf94ad483023d1db (patch)
treea13100aac1d0c28ca11dacf9cbfd447af305141e
parent588f6414939fa8f4116eb3dad0fa287962037e83 (diff)
downloadrspamd-a752628025143687ee60f6f1cf94ad483023d1db.tar.gz
rspamd-a752628025143687ee60f6f1cf94ad483023d1db.zip
Add cache id support for regexp
-rw-r--r--src/libutil/regexp.c22
-rw-r--r--src/libutil/regexp.h12
2 files changed, 34 insertions, 0 deletions
diff --git a/src/libutil/regexp.c b/src/libutil/regexp.c
index 2ddfa694d..eaea894c0 100644
--- a/src/libutil/regexp.c
+++ b/src/libutil/regexp.c
@@ -51,6 +51,7 @@ struct rspamd_regexp_s {
regexp_id_t id;
ref_entry_t ref;
gpointer ud;
+ guint64 cache_id;
gint flags;
gint ncaptures;
gint nbackref;
@@ -245,6 +246,7 @@ fin:
REF_INIT_RETAIN (res, rspamd_regexp_dtor);
res->flags = rspamd_flags;
res->pattern = real_pattern;
+ res->cache_id = RSPAMD_INVALID_ID;
if (rspamd_flags & RSPAMD_REGEXP_FLAG_RAW) {
res->raw_re = r;
@@ -502,6 +504,26 @@ rspamd_regexp_get_ncaptures (rspamd_regexp_t *re)
return re->ncaptures;
}
+guint64
+rspamd_regexp_get_cache_id (rspamd_regexp_t *re)
+{
+ g_assert (re != NULL);
+
+ return re->cache_id;
+}
+
+guint64
+rspamd_regexp_set_cache_id (rspamd_regexp_t *re, guint64 id)
+{
+ guint64 old;
+
+ g_assert (re != NULL);
+ old = re->cache_id;
+ re->cache_id = id;
+
+ return old;
+}
+
gboolean
rspamd_regexp_match (rspamd_regexp_t *re, const gchar *text, gsize len,
gboolean raw)
diff --git a/src/libutil/regexp.h b/src/libutil/regexp.h
index 2c33f780d..cf012668a 100644
--- a/src/libutil/regexp.h
+++ b/src/libutil/regexp.h
@@ -27,6 +27,8 @@
#include "config.h"
+#define RSPAMD_INVALID_ID ((guint64)-1LL)
+
typedef struct rspamd_regexp_s rspamd_regexp_t;
struct rspamd_regexp_cache;
struct rspamd_re_capture {
@@ -121,6 +123,16 @@ gint rspamd_regexp_get_nbackrefs (rspamd_regexp_t *re);
gint rspamd_regexp_get_ncaptures (rspamd_regexp_t *re);
/**
+ * Returns cache id for a regexp
+ */
+guint64 rspamd_regexp_get_cache_id (rspamd_regexp_t *re);
+
+/**
+ * Sets cache id for a regexp
+ */
+guint64 rspamd_regexp_set_cache_id (rspamd_regexp_t *re, guint64 id);
+
+/**
* Create new regexp cache
* @return
*/