aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-09-22 12:48:41 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-09-22 12:48:41 +0100
commit17aa61dfba1e34b9fdbb5e5278e3de1376a67006 (patch)
tree4eb9c683782782d9ae234749d447e2045de5032b
parent93afc2d45f6dde78372a29537bf2fbfd10ceb532 (diff)
downloadrspamd-17aa61dfba1e34b9fdbb5e5278e3de1376a67006.tar.gz
rspamd-17aa61dfba1e34b9fdbb5e5278e3de1376a67006.zip
[Feature] Add ffi friendly version of process_regexp function
-rw-r--r--src/libmime/mime_expressions.c2
-rw-r--r--src/libserver/re_cache.c25
-rw-r--r--src/libserver/re_cache.h7
-rw-r--r--src/lua/lua_task.c2
4 files changed, 30 insertions, 6 deletions
diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c
index 647e43f0e..bdf5644fd 100644
--- a/src/libmime/mime_expressions.c
+++ b/src/libmime/mime_expressions.c
@@ -806,7 +806,6 @@ rspamd_mime_expr_process_regexp (struct rspamd_regexp_atom *re,
if (re->type == RSPAMD_RE_HEADER || re->type == RSPAMD_RE_RAWHEADER) {
ret = rspamd_re_cache_process (task,
- task->re_rt,
re->regexp,
re->type,
re->header,
@@ -815,7 +814,6 @@ rspamd_mime_expr_process_regexp (struct rspamd_regexp_atom *re,
}
else {
ret = rspamd_re_cache_process (task,
- task->re_rt,
re->regexp,
re->type,
NULL,
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index 9719558f0..c2ade15c5 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -22,6 +22,7 @@
#include "libserver/cfg_file.h"
#include "libutil/util.h"
#include "libutil/regexp.h"
+#include "lua/lua_common.h"
#ifdef WITH_HYPERSCAN
#include "hs.h"
#include "unix-std.h"
@@ -1050,7 +1051,6 @@ rspamd_re_cache_exec_re (struct rspamd_task *task,
gint
rspamd_re_cache_process (struct rspamd_task *task,
- struct rspamd_re_runtime *rt,
rspamd_regexp_t *re,
enum rspamd_re_type type,
gpointer type_data,
@@ -1060,9 +1060,11 @@ rspamd_re_cache_process (struct rspamd_task *task,
guint64 re_id;
struct rspamd_re_class *re_class;
struct rspamd_re_cache *cache;
+ struct rspamd_re_runtime *rt;
- g_assert (rt != NULL);
g_assert (task != NULL);
+ rt = task->re_rt;
+ g_assert (rt != NULL);
g_assert (re != NULL);
cache = rt->cache;
@@ -1096,6 +1098,25 @@ rspamd_re_cache_process (struct rspamd_task *task,
return 0;
}
+int
+rspamd_re_cache_process_ffi (void *ptask,
+ void *pre,
+ int type,
+ void *type_data,
+ int is_strong)
+{
+ struct rspamd_lua_regexp **lua_re = pre;
+ struct rspamd_task **real_task = ptask;
+ gsize typelen = 0;
+
+ if (type_data) {
+ typelen = strlen (type_data);
+ }
+
+ return rspamd_re_cache_process (*real_task, (*lua_re)->re,
+ type, type_data, typelen, is_strong);
+}
+
void
rspamd_re_cache_runtime_destroy (struct rspamd_re_runtime *rt)
{
diff --git a/src/libserver/re_cache.h b/src/libserver/re_cache.h
index 6b82fa736..a138bcb4b 100644
--- a/src/libserver/re_cache.h
+++ b/src/libserver/re_cache.h
@@ -109,13 +109,18 @@ const struct rspamd_re_cache_stat *
* @param is_strong use case sensitive match when looking for headers
*/
gint rspamd_re_cache_process (struct rspamd_task *task,
- struct rspamd_re_runtime *rt,
rspamd_regexp_t *re,
enum rspamd_re_type type,
gpointer type_data,
gsize datalen,
gboolean is_strong);
+int rspamd_re_cache_process_ffi (void *ptask,
+ void *pre,
+ int type,
+ void *type_data,
+ int is_strong);
+
/**
* Destroy runtime data
*/
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 0c37f9e11..8c6a3473c 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -3072,7 +3072,7 @@ lua_task_process_regexp (lua_State *L)
"header argument is mandatory for header/rawheader regexps");
}
else {
- ret = rspamd_re_cache_process (task, task->re_rt, re->re, type,
+ ret = rspamd_re_cache_process (task, re->re, type,
(gpointer) header_str, header_len, strong);
}
}