diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-09-25 21:24:37 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-09-25 21:24:37 +0400 |
commit | e1fea1e66d0f1111e934bb0e86bd2ce25da6df6e (patch) | |
tree | bdb01f8536955fb802068ac39eb18e2a727afa16 /src | |
parent | 71b43d966af50b69605fd91453e90eb3c67a3203 (diff) | |
download | rspamd-e1fea1e66d0f1111e934bb0e86bd2ce25da6df6e.tar.gz rspamd-e1fea1e66d0f1111e934bb0e86bd2ce25da6df6e.zip |
* Make composites working
* Document using of composites
Diffstat (limited to 'src')
-rw-r--r-- | src/cfg_file.l | 2 | ||||
-rw-r--r-- | src/cfg_file.y | 2 | ||||
-rw-r--r-- | src/expressions.c | 13 | ||||
-rw-r--r-- | src/filter.c | 5 |
4 files changed, 19 insertions, 3 deletions
diff --git a/src/cfg_file.l b/src/cfg_file.l index e1314905c..7646c87cf 100644 --- a/src/cfg_file.l +++ b/src/cfg_file.l @@ -36,7 +36,7 @@ extern struct config_file *cfg; .module BEGIN(module_lex_state); .lua BEGIN(lua_lex_state); worker BEGIN(worker_lex_state); return WORKER; -composites return COMPOSITES; +composites BEGIN(module_lex_state);return COMPOSITES; tempdir return TEMPDIR; pidfile return PIDFILE; diff --git a/src/cfg_file.y b/src/cfg_file.y index 84a0a1000..7d9316b60 100644 --- a/src/cfg_file.y +++ b/src/cfg_file.y @@ -520,7 +520,7 @@ compositesbody: ; compositescmd: - QUOTEDSTRING EQSIGN QUOTEDSTRING { + PARAM EQSIGN QUOTEDSTRING { struct expression *expr; if ((expr = parse_expression (cfg->cfg_pool, $3)) == NULL) { yyerror ("yyparse: cannot parse composite expression: %s", $3); diff --git a/src/expressions.c b/src/expressions.c index 83bceae7a..8ea4ebc50 100644 --- a/src/expressions.c +++ b/src/expressions.c @@ -446,6 +446,19 @@ parse_expression (memory_pool_t *pool, char *line) } state = READ_OPERATOR; } + else if (*(p + 1) == '\0') { + /* In fact it is not function, but symbol */ + p ++; + if (c != p) { + str = memory_pool_alloc (pool, p - c + 1); + g_strlcpy (str, c, (p - c + 1)); + g_strstrip (str); + if (strlen (str) > 0) { + insert_expression (pool, &expr, EXPR_STR, 0, str); + } + } + state = SKIP_SPACES; + } else { p ++; } diff --git a/src/filter.c b/src/filter.c index e03d169e0..86df617df 100644 --- a/src/filter.c +++ b/src/filter.c @@ -338,7 +338,7 @@ composites_foreach_callback (gpointer key, gpointer value, void *data) stack = g_queue_new (); while (expr) { - if (expr->type == EXPR_REGEXP) { + if (expr->type == EXPR_STR) { /* Find corresponding symbol */ if (g_hash_table_lookup (cd->metric_res->symbols, expr->content.operand) == NULL) { cur = 0; @@ -486,6 +486,8 @@ void make_composites (struct worker_task *task) { g_hash_table_foreach (task->results, composites_metric_callback, task); + /* Process all metrics */ + g_hash_table_foreach (task->results, metric_process_callback_forced, task); } @@ -561,6 +563,7 @@ process_statfiles (struct worker_task *task) g_hash_table_destroy (cd.tokens); /* Process results */ + make_composites (task); task->state = WRITE_REPLY; } |