diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-17 14:13:45 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-17 14:13:45 +0000 |
commit | fb236b262fab5adb864b2766910a80590c12611a (patch) | |
tree | 50b9a28dd9b79402cc6937b488229391b3b11674 /src/libutil/expression.h | |
parent | 2020bd22fff005ac5ba32dda3b4f848f3027640c (diff) | |
download | rspamd-fb236b262fab5adb864b2766910a80590c12611a.tar.gz rspamd-fb236b262fab5adb864b2766910a80590c12611a.zip |
[Feature] Save operation node for expressions atoms
Diffstat (limited to 'src/libutil/expression.h')
-rw-r--r-- | src/libutil/expression.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/libutil/expression.h b/src/libutil/expression.h index 97cbfec4b..82c0c60c1 100644 --- a/src/libutil/expression.h +++ b/src/libutil/expression.h @@ -24,19 +24,36 @@ #define RSPAMD_EXPRESSION_FLAG_NOOPT (1 << 0) +enum rspamd_expression_op { + OP_INVALID = 0, + OP_PLUS, /* || or + */ + OP_MULT, /* && or * */ + OP_OR, /* || or | */ + OP_AND, /* && or & */ + OP_NOT, /* ! */ + OP_LT, /* < */ + OP_GT, /* > */ + OP_LE, /* <= */ + OP_GE, /* >= */ + OP_OBRACE, /* ( */ + OP_CBRACE /* ) */ +}; + typedef struct rspamd_expression_atom_s { + /* Parent node */ + GNode *parent; /* Opaque userdata */ gpointer data; /* String representation of atom */ const gchar *str; /* Length of the string representation of atom */ gsize len; - /* Relative priority */ - gint priority; /* Average execution time (in ticks) */ gdouble avg_ticks; /* Amount of positive triggers */ guint hits; + /* Relative priority */ + gint priority; } rspamd_expression_atom_t; struct rspamd_atom_subr { @@ -101,4 +118,12 @@ typedef void (*rspamd_expression_atom_foreach_cb) (const rspamd_ftok_t *atom, void rspamd_expression_atom_foreach (struct rspamd_expression *expr, rspamd_expression_atom_foreach_cb cb, gpointer cbdata); +/** + * Checks if a specified node in AST is the specified operation + * @param node AST node packed in GNode container + * @param op operation to check + * @return TRUE if node is operation node and is exactly the specified option + */ +gboolean rspamd_expression_node_is_op (GNode *node, enum rspamd_expression_op op); + #endif /* SRC_LIBUTIL_EXPRESSION_H_ */ |