diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-19 11:56:10 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-19 13:47:54 +0000 |
commit | 6f854176850ae787ad9bbd6743fa59b671e407a2 (patch) | |
tree | f84704c6a3e6845aefb8c3c0d3ab56c3bbdc07c1 /src/lua | |
parent | 58a48db6784c101572b37ad94d2f6b1e586054a6 (diff) | |
download | rspamd-6f854176850ae787ad9bbd6743fa59b671e407a2.tar.gz rspamd-6f854176850ae787ad9bbd6743fa59b671e407a2.zip |
Add lua-expr:process method.
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_expression.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lua/lua_expression.c b/src/lua/lua_expression.c index 284fccb65..b4ca29602 100644 --- a/src/lua/lua_expression.c +++ b/src/lua/lua_expression.c @@ -62,8 +62,17 @@ LUA_FUNCTION_DEF (expr, create); */ LUA_FUNCTION_DEF (expr, to_string); +/*** + * @method rspamd_expression:process(input) + * Executes the expression and pass input to process atom callbacks + * @param {any} input input data for processing callbacks + * @return {number} result of the expression evaluation + */ +LUA_FUNCTION_DEF (expr, process); + static const struct luaL_reg exprlib_m[] = { LUA_INTERFACE_DEF (expr, to_string), + LUA_INTERFACE_DEF (expr, process), {"__tostring", lua_expr_to_string}, {NULL, NULL} }; @@ -160,6 +169,19 @@ lua_atom_process (gpointer input, rspamd_expression_atom_t *atom) } static gint +lua_expr_process (lua_State *L) +{ + struct lua_expression *e = rspamd_lua_expression (L, 1); + gint res; + + res = rspamd_process_expression (e->expr, GINT_TO_POINTER (2)); + + lua_pushnumber (L, res); + + return 1; +} + +static gint lua_expr_create (lua_State *L) { struct lua_expression *e, **pe; |