diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-06-29 19:32:31 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-06-29 19:32:31 +0400 |
commit | 025f2000d515244e085cd82ac089d7f0271fc531 (patch) | |
tree | 1ce03cdd34717418194aaf5fdee6584ad241cc1c /src/cfg_file.y | |
parent | 21a2da8ea3da88fe2e54785189c0a328fcab4a2a (diff) | |
download | rspamd-025f2000d515244e085cd82ac089d7f0271fc531.tar.gz rspamd-025f2000d515244e085cd82ac089d7f0271fc531.zip |
* Add views support (not completely tested yet)
Diffstat (limited to 'src/cfg_file.y')
-rw-r--r-- | src/cfg_file.y | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/cfg_file.y b/src/cfg_file.y index 0062cdeea..17854f22b 100644 --- a/src/cfg_file.y +++ b/src/cfg_file.y @@ -8,6 +8,7 @@ #include "expressions.h" #include "classifiers/classifiers.h" #include "tokenizers/tokenizers.h" +#include "view.h" #ifdef WITH_LUA #include "lua-rspamd.h" #else @@ -25,6 +26,8 @@ struct statfile *cur_statfile = NULL; struct statfile_section *cur_section = NULL; struct worker_conf *cur_worker = NULL; +struct rspamd_view *cur_view = NULL; + %} %union @@ -51,6 +54,7 @@ struct worker_conf *cur_worker = NULL; %token LOG_LEVEL LOG_LEVEL_DEBUG LOG_LEVEL_INFO LOG_LEVEL_WARNING LOG_LEVEL_ERROR LOG_FACILITY LOG_FILENAME %token STATFILE ALIAS PATTERN WEIGHT STATFILE_POOL_SIZE SIZE TOKENIZER CLASSIFIER %token DELIVERY LMTP ENABLED AGENT SECTION LUACODE RAW_MODE PROFILE_FILE COUNT +%token VIEW IP FROM SYMBOLS %type <string> STRING %type <string> VARIABLE @@ -93,6 +97,7 @@ command : | luacode | raw_mode | profile_file + | view ; tempdir : @@ -832,6 +837,62 @@ profile_file: } ; +view: + VIEW OBRACE viewbody EBRACE { + if (cur_view == NULL) { + yyerror ("yyparse: not enough arguments in view definition"); + YYERROR; + } + cfg->views = g_list_prepend (cfg->views, cur_view); + cur_view = NULL; + } + ; + +viewbody: + | viewcmd SEMICOLON + | viewbody viewcmd SEMICOLON + ; + +viewcmd: + | viewip + | viewfrom + | viewsymbols + ; + +viewip: + IP EQSIGN QUOTEDSTRING { + if (cur_view == NULL) { + cur_view = init_view (cfg->cfg_pool); + } + if (!add_view_ip (cur_view, $3)) { + yyerror ("yyparse: invalid ip line in view definition: ip = '%s'", $3); + YYERROR; + } + } + ; + +viewfrom: + FROM EQSIGN QUOTEDSTRING { + if (cur_view == NULL) { + cur_view = init_view (cfg->cfg_pool); + } + if (!add_view_from (cur_view, $3)) { + yyerror ("yyparse: invalid from line in view definition: from = '%s'", $3); + YYERROR; + } + } + ; +viewsymbols: + SYMBOLS EQSIGN QUOTEDSTRING { + if (cur_view == NULL) { + cur_view = init_view (cfg->cfg_pool); + } + if (!add_view_symbols (cur_view, $3)) { + yyerror ("yyparse: invalid symbols line in view definition: symbols = '%s'", $3); + YYERROR; + } + } + ; %% /* * vi:ts=4 |