aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-28 23:00:11 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-03-28 23:00:11 +0000
commitb303477f7addbc15365aeae4d0cdeadf60fa21b1 (patch)
treef8a952e27c1334476b181db32e3b64bcbef7e475
parent86ae36d19ff7291784e1a638fe192a66a160d538 (diff)
downloadrspamd-b303477f7addbc15365aeae4d0cdeadf60fa21b1.tar.gz
rspamd-b303477f7addbc15365aeae4d0cdeadf60fa21b1.zip
Add flags to expressions processing and noopt flag.
-rw-r--r--src/libutil/expression.c15
-rw-r--r--src/libutil/expression.h5
2 files changed, 13 insertions, 7 deletions
diff --git a/src/libutil/expression.c b/src/libutil/expression.c
index d9f1a1260..b2655b518 100644
--- a/src/libutil/expression.c
+++ b/src/libutil/expression.c
@@ -806,7 +806,7 @@ rspamd_ast_do_op (struct rspamd_expression_elt *elt, gint val, gint acc)
}
static gint
-rspamd_ast_process_node (struct rspamd_expression *expr, GNode *node,
+rspamd_ast_process_node (struct rspamd_expression *expr, gint flags, GNode *node,
gpointer data)
{
struct rspamd_expression_elt *elt, *celt, *parelt;
@@ -846,7 +846,7 @@ rspamd_ast_process_node (struct rspamd_expression *expr, GNode *node,
celt = cld->data;
/* Save limit if we've found it */
- val = rspamd_ast_process_node (expr, cld, data);
+ val = rspamd_ast_process_node (expr, flags, cld, data);
if (acc == G_MININT) {
acc = val;
@@ -854,8 +854,10 @@ rspamd_ast_process_node (struct rspamd_expression *expr, GNode *node,
acc = rspamd_ast_do_op (elt, val, acc);
- if (rspamd_ast_node_done (elt, parelt, acc, lim)) {
- return acc;
+ if (!(flags & RSPAMD_EXPRESSION_FLAG_NOOPT)) {
+ if (rspamd_ast_node_done (elt, parelt, acc, lim)) {
+ return acc;
+ }
}
}
break;
@@ -876,7 +878,8 @@ rspamd_ast_cleanup_traverse (GNode *n, gpointer d)
}
gint
-rspamd_process_expression (struct rspamd_expression *expr, gpointer data)
+rspamd_process_expression (struct rspamd_expression *expr, gint flags,
+ gpointer data)
{
gint ret = 0;
@@ -884,7 +887,7 @@ rspamd_process_expression (struct rspamd_expression *expr, gpointer data)
/* Ensure that stack is empty at this point */
g_assert (expr->expression_stack->len == 0);
- ret = rspamd_ast_process_node (expr, expr->ast, data);
+ ret = rspamd_ast_process_node (expr, flags, expr->ast, data);
/* Cleanup */
g_node_traverse (expr->ast, G_IN_ORDER, G_TRAVERSE_ALL, -1,
diff --git a/src/libutil/expression.h b/src/libutil/expression.h
index 924dbb45b..866542165 100644
--- a/src/libutil/expression.h
+++ b/src/libutil/expression.h
@@ -30,6 +30,8 @@
#define RSPAMD_EXPRESSION_MAX_PRIORITY 1024
+#define RSPAMD_EXPRESSION_FLAG_NOOPT (1 << 0)
+
typedef struct rspamd_expression_atom_s {
/* Opaque userdata */
gpointer data;
@@ -77,7 +79,8 @@ gboolean rspamd_parse_expression (const gchar *line, gsize len,
* @param data opaque data pointer for all the atoms
* @return the value of expression
*/
-gint rspamd_process_expression (struct rspamd_expression *expr, gpointer data);
+gint rspamd_process_expression (struct rspamd_expression *expr, gint flags,
+ gpointer data);
/**
* Shows string representation of an expression