aboutsummaryrefslogtreecommitdiffstats
path: root/src/expressions.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-04-08 19:24:36 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-04-08 19:24:36 +0400
commit01e37900750a8bf7aaf7c52057ea73c4d7c6aa2a (patch)
tree1eb7dade443d154c4827ffa6a354228340201a34 /src/expressions.c
parentda502b854015fe2053689249323e1228afd1460b (diff)
downloadrspamd-01e37900750a8bf7aaf7c52057ea73c4d7c6aa2a.tar.gz
rspamd-01e37900750a8bf7aaf7c52057ea73c4d7c6aa2a.zip
* Call lua functions like C functions in expressions
Diffstat (limited to 'src/expressions.c')
-rw-r--r--src/expressions.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/expressions.c b/src/expressions.c
index 34e7b0e28..e52745541 100644
--- a/src/expressions.c
+++ b/src/expressions.c
@@ -30,6 +30,7 @@
#include "fuzzy.h"
#include "expressions.h"
#include "html.h"
+#include "lua/lua_common.h"
gboolean rspamd_compare_encoding (struct worker_task *task, GList * args, void *unused);
gboolean rspamd_header_exists (struct worker_task *task, GList * args, void *unused);
@@ -721,13 +722,26 @@ gboolean
call_expression_function (struct expression_function * func, struct worker_task * task)
{
struct _fl *selected, key;
+#ifdef RSPAMD_MAIN
+ gboolean res;
+#endif
key.name = func->name;
selected = bsearch (&key, list_ptr, functions_number, sizeof (struct _fl), fl_cmp);
if (selected == NULL) {
- msg_warn ("call to undefined function %s", key.name);
+ /* Try to check lua function */
+#ifdef RSPAMD_MAIN
+ if (! lua_call_expression_func (func->name, task, func->args, &res)) {
+ msg_warn ("call to undefined function %s", key.name);
+ return FALSE;
+ }
+ else {
+ return res;
+ }
+#else
return FALSE;
+#endif
}
return selected->func (task, func->args, selected->user_data);