diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-05-17 14:30:03 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-05-17 14:30:03 +0100 |
commit | 29a3b94f4dc310b1f8b77ec982b9062f80192424 (patch) | |
tree | 6716ed6a3a94a07670db4f8b8d8f3862bb587d4f /src/libutil/expression.h | |
parent | c912d5d7daaf3ba8c4d419b5f32138077dea980a (diff) | |
download | rspamd-29a3b94f4dc310b1f8b77ec982b9062f80192424.tar.gz rspamd-29a3b94f4dc310b1f8b77ec982b9062f80192424.zip |
[Minor] Allow to execute expressions with process closures
Diffstat (limited to 'src/libutil/expression.h')
-rw-r--r-- | src/libutil/expression.h | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/libutil/expression.h b/src/libutil/expression.h index 7f7cb2dda..4f16812e6 100644 --- a/src/libutil/expression.h +++ b/src/libutil/expression.h @@ -56,6 +56,11 @@ typedef struct rspamd_expression_atom_s { gint priority; } rspamd_expression_atom_t; +struct rspamd_expr_process_data; + +typedef gdouble (*rspamd_expression_process_cb)(struct rspamd_expr_process_data *process_data, + rspamd_expression_atom_t *atom); + struct rspamd_expr_process_data { /* Current Lua state to run atom processing */ struct lua_State *L; @@ -66,6 +71,7 @@ struct rspamd_expr_process_data { GPtrArray *trace; struct composites_data *cd; struct rspamd_task *task; + rspamd_expression_process_cb process_closure; }; struct rspamd_atom_subr { @@ -73,7 +79,7 @@ struct rspamd_atom_subr { rspamd_expression_atom_t * (*parse)(const gchar *line, gsize len, rspamd_mempool_t *pool, gpointer ud, GError **err); /* Process atom via the opaque pointer (e.g. struct rspamd_task *) */ - gdouble (*process) (struct rspamd_expr_process_data *process_data, rspamd_expression_atom_t *atom); + rspamd_expression_process_cb process; /* Calculates the relative priority of the expression */ gint (*priority) (rspamd_expression_atom_t *atom); void (*destroy) (rspamd_expression_atom_t *atom); @@ -119,6 +125,16 @@ gdouble rspamd_process_expression_track (struct rspamd_expression *expr, struct rspamd_expr_process_data *process_data); /** + * Process the expression with the custom processor + * @param expr + * @param cb + * @param process_data + * @return + */ +gdouble rspamd_process_expression_closure (struct rspamd_expression *expr, + rspamd_expression_process_cb cb, + struct rspamd_expr_process_data *process_data); +/** * Shows string representation of an expression * @param expr expression to show * @return freshly allocated string with expression |