diff options
Diffstat (limited to 'src/libmime/expressions.h')
-rw-r--r-- | src/libmime/expressions.h | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/src/libmime/expressions.h b/src/libmime/expressions.h index 954cc74f7..1ba02d956 100644 --- a/src/libmime/expressions.h +++ b/src/libmime/expressions.h @@ -16,8 +16,8 @@ struct rspamd_regexp; * Rspamd expression function */ struct expression_function { - gchar *name; /**< name of function */ - GList *args; /**< its args */ + gchar *name; /**< name of function */ + GList *args; /**< its args */ }; /** @@ -28,30 +28,31 @@ struct expression_argument { EXPRESSION_ARGUMENT_NORMAL, EXPRESSION_ARGUMENT_BOOL, EXPRESSION_ARGUMENT_EXPR, - } type; /**< type of argument (text or other function) */ - void *data; /**< pointer to its data */ + } type; /**< type of argument (text or other function) */ + void *data; /**< pointer to its data */ }; -/** - * Logic expression +/** + * Logic expression */ struct expression { - enum { + enum { EXPR_REGEXP, - EXPR_OPERATION, - EXPR_FUNCTION, - EXPR_STR, + EXPR_OPERATION, + EXPR_FUNCTION, + EXPR_STR, EXPR_REGEXP_PARSED, - } type; /**< expression type */ + } type; /**< expression type */ union { void *operand; gchar operation; - } content; /**< union for storing operand or operation code */ - const gchar *orig; /**< original line */ - struct expression *next; /**< chain link */ + } content; /**< union for storing operand or operation code */ + const gchar *orig; /**< original line */ + struct expression *next; /**< chain link */ }; -typedef gboolean (*rspamd_internal_func_t)(struct rspamd_task *, GList *args, void *user_data); +typedef gboolean (*rspamd_internal_func_t)(struct rspamd_task *, GList *args, + void *user_data); /** * Parse regexp line to regexp structure @@ -59,7 +60,9 @@ typedef gboolean (*rspamd_internal_func_t)(struct rspamd_task *, GList *args, vo * @param line incoming line * @return regexp structure or NULL in case of error */ -struct rspamd_regexp* parse_regexp (rspamd_mempool_t *pool, const gchar *line, gboolean raw_mode); +struct rspamd_regexp * parse_regexp (rspamd_mempool_t *pool, + const gchar *line, + gboolean raw_mode); /** * Parse composites line to composites structure (eg. "SYMBOL1&SYMBOL2|!SYMBOL3") @@ -67,7 +70,7 @@ struct rspamd_regexp* parse_regexp (rspamd_mempool_t *pool, const gchar *line, g * @param line incoming line * @return expression structure or NULL in case of error */ -struct expression* parse_expression (rspamd_mempool_t *pool, gchar *line); +struct expression * parse_expression (rspamd_mempool_t *pool, gchar *line); /** * Call specified fucntion and return boolean result @@ -76,14 +79,18 @@ struct expression* parse_expression (rspamd_mempool_t *pool, gchar *line); * @param L lua specific state * @return TRUE or FALSE depending on function result */ -gboolean call_expression_function (struct expression_function *func, struct rspamd_task *task, lua_State *L); +gboolean call_expression_function (struct expression_function *func, + struct rspamd_task *task, + lua_State *L); /** * Register specified function to rspamd internal functions list * @param name name of function * @param func pointer to function */ -void register_expression_function (const gchar *name, rspamd_internal_func_t func, void *user_data); +void register_expression_function (const gchar *name, + rspamd_internal_func_t func, + void *user_data); /** * Add regexp to regexp cache @@ -111,7 +118,9 @@ void re_cache_del (const gchar *line, rspamd_mempool_t *pool); * @param pointer regexp data * @param result numeric result of this regexp */ -void task_cache_add (struct rspamd_task *task, struct rspamd_regexp *re, gint32 result); +void task_cache_add (struct rspamd_task *task, + struct rspamd_regexp *re, + gint32 result); /** * Check regexp in cache @@ -128,6 +137,8 @@ gint32 task_cache_check (struct rspamd_task *task, struct rspamd_regexp *re); * @param want_string return NULL if argument is not a string * @return expression argument structure or NULL if failed */ -struct expression_argument *get_function_arg (struct expression *expr, struct rspamd_task *task, gboolean want_string); +struct expression_argument * get_function_arg (struct expression *expr, + struct rspamd_task *task, + gboolean want_string); #endif |