diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-19 17:44:57 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-03-19 17:44:57 +0300 |
commit | e1250bcf595973ff46cf7766590a1491eddfe60d (patch) | |
tree | ff5ee21edafb21cb434261c6a0f2d2f153850783 /src/expressions.h | |
parent | 5f4f8d47039fbc366c4d7e34e4870d7d374c2061 (diff) | |
download | rspamd-e1250bcf595973ff46cf7766590a1491eddfe60d.tar.gz rspamd-e1250bcf595973ff46cf7766590a1491eddfe60d.zip |
* Add functions support to rspamd regexps
* Parse expressions with state machine which allows different kinds of arguments in expressions
* Fix test to accord current data
* Add support of fucntions to regexp module
* Move all regexp logic to separate file, describe its API
* Fix descriptors leakage in surbl module
Diffstat (limited to 'src/expressions.h')
-rw-r--r-- | src/expressions.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/expressions.h b/src/expressions.h new file mode 100644 index 000000000..65b555566 --- /dev/null +++ b/src/expressions.h @@ -0,0 +1,69 @@ +/** + * @file expressions.h + * Rspamd expressions API + */ + +#ifndef RSPAMD_EXPRESSIONS_H +#define RSPAMD_EXPRESSIONS_H + +#include "config.h" + +struct worker_task; + +/** + * Rspamd expression function + */ +struct expression_function { + char *name; /**< name of function */ + GList *args; /**< its args */ +}; + +/** + * Function's argument + */ +struct expression_argument { + enum { + EXPRESSION_ARGUMENT_NORMAL, + EXPRESSION_ARGUMENT_FUNCTION + } type; /**< type of argument (text or other function) */ + void *data; /**< pointer to its data */ +}; + +/** + * Logic expression + */ +struct expression { + enum { EXPR_REGEXP, EXPR_OPERATION, EXPR_FUNCTION, EXPR_STR } type; /**< expression type */ + union { + void *operand; + char operation; + } content; /**< union for storing operand or operation code */ + struct expression *next; /**< chain link */ +}; + +/** + * Parse regexp line to regexp structure + * @param pool memory pool to use + * @param line incoming line + * @return regexp structure or NULL in case of error + */ +struct rspamd_regexp* parse_regexp (memory_pool_t *pool, char *line); + +/** + * Parse composites line to composites structure (eg. "SYMBOL1&SYMBOL2|!SYMBOL3") + * @param pool memory pool to use + * @param line incoming line + * @return expression structure or NULL in case of error + */ +struct expression* parse_expression (memory_pool_t *pool, char *line); + +/** + * Call specified fucntion and return boolean result + * @param func function to call + * @param task task object + * @return TRUE or FALSE depending on function result + */ +gboolean call_expression_function (struct expression_function *func, struct worker_task *task); + + +#endif |