summaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-11-12 16:32:58 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-11-12 16:32:58 +0000
commit55abc1e4fd53a5eb9bfcb89661ba2ae4308deb5a (patch)
tree484ffe2a0a3cd42e5869dd5d9e7fbb4626207b74 /src/lua
parent552b125a0c1769cd7c98fcdb6432b0a5609585aa (diff)
downloadrspamd-55abc1e4fd53a5eb9bfcb89661ba2ae4308deb5a.tar.gz
rspamd-55abc1e4fd53a5eb9bfcb89661ba2ae4308deb5a.zip
Rework calling of lua functions from regexp module.
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_common.c55
-rw-r--r--src/lua/lua_common.h4
2 files changed, 0 insertions, 59 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index a4ae97590..8df878585 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -476,61 +476,6 @@ rspamd_lua_call_chain_filter (const gchar *function,
return result;
}
-/* Call custom lua function in rspamd expression */
-gboolean
-rspamd_lua_call_expression_func (gpointer lua_data,
- struct rspamd_task *task, GList *args, gboolean *res)
-{
- lua_State *L = task->cfg->lua_state;
- struct rspamd_task **ptask;
- GList *cur;
- struct expression_argument *arg;
- int nargs = 1, pop = 0;
-
- lua_rawgeti (L, LUA_REGISTRYINDEX, GPOINTER_TO_INT (lua_data));
- /* Now we got function in top of stack */
- ptask = lua_newuserdata (L, sizeof (struct rspamd_task *));
- rspamd_lua_setclass (L, "rspamd{task}", -1);
- *ptask = task;
-
- /* Now push all arguments */
- cur = args;
- while (cur) {
- arg = get_function_arg (cur->data, task, FALSE);
- if (arg) {
- switch (arg->type) {
- case EXPRESSION_ARGUMENT_NORMAL:
- lua_pushstring (L, (const gchar *)arg->data);
- break;
- case EXPRESSION_ARGUMENT_BOOL:
- lua_pushboolean (L, (gboolean) GPOINTER_TO_SIZE (arg->data));
- break;
- default:
- msg_err ("cannot pass custom params to lua function");
- return FALSE;
- }
- }
- nargs++;
- cur = g_list_next (cur);
- }
-
- if (lua_pcall (L, nargs, 1, 0) != 0) {
- msg_info ("call to lua function failed: %s", lua_tostring (L, -1));
- return FALSE;
- }
- pop++;
-
- if (!lua_isboolean (L, -1)) {
- lua_pop (L, pop);
- msg_info ("lua function must return a boolean");
- return FALSE;
- }
- *res = lua_toboolean (L, -1);
- lua_pop (L, pop);
-
- return TRUE;
-}
-
/*
* LUA custom consolidation function
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h
index afcfcdcdb..cbcdf5b68 100644
--- a/src/lua/lua_common.h
+++ b/src/lua/lua_common.h
@@ -182,10 +182,6 @@ gint rspamd_lua_call_chain_filter (const gchar *function,
double rspamd_lua_consolidation_func (struct rspamd_task *task,
const gchar *metric_name,
const gchar *function_name);
-gboolean rspamd_lua_call_expression_func (gpointer lua_data,
- struct rspamd_task *task,
- GList *args,
- gboolean *res);
void rspamd_lua_call_post_filters (struct rspamd_task *task);
void rspamd_lua_call_pre_filters (struct rspamd_task *task);
void rspamd_lua_dostring (const gchar *line);