diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-12-16 20:06:29 +0300 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2009-12-16 20:06:29 +0300 |
commit | 1b1bcd6966f47a2568acee011dd4b9f18195d765 (patch) | |
tree | 219073936a703bd001699bc0ca4c70014068c26c /src/classifiers | |
parent | b7046a0e6667e9c840b83acaf08f9ac117508eaa (diff) | |
download | rspamd-1b1bcd6966f47a2568acee011dd4b9f18195d765.tar.gz rspamd-1b1bcd6966f47a2568acee011dd4b9f18195d765.zip |
* Implement pre and post classify callbacks for checking specific statfiles for this task
TODO:
- add properties to get all parameters of input task
- add properties to statfile object
- add some normalization function for calling from classify process
- document changes
Diffstat (limited to 'src/classifiers')
-rw-r--r-- | src/classifiers/winnow.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c index 4b1bd5549..34e3dc209 100644 --- a/src/classifiers/winnow.c +++ b/src/classifiers/winnow.c @@ -30,6 +30,9 @@ #include "../main.h" #include "../filter.h" #include "../cfg_file.h" +#ifdef WITH_LUA +#include "../lua/lua_common.h" +#endif #define WINNOW_PROMOTION 1.23 #define WINNOW_DEMOTION 0.83 @@ -135,8 +138,20 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp data.count = 0; data.now = time (NULL); data.ctx = ctx; - - cur = ctx->cfg->statfiles; + + if (ctx->cfg->pre_callbacks) { +#ifdef WITH_LUA + cur = call_classifier_pre_callbacks (ctx->cfg, task); + if (cur) { + memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_list_free, cur); + } +#else + cur = ctx->cfg->statfiles; +#endif + } + else { + cur = ctx->cfg->statfiles; + } while (cur) { st = cur->data; if ((data.file = statfile_pool_is_open (pool, st->path)) == NULL) { @@ -170,7 +185,10 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp sumbuf = memory_pool_alloc (task->task_pool, 32); snprintf (sumbuf, 32, "%.2f", max); cur = g_list_prepend (NULL, sumbuf); - insert_result (task, ctx->cfg->metric, sel->symbol, 1, cur); +#ifdef WITH_LUA + max = call_classifier_post_callbacks (ctx->cfg, task, max); +#endif + insert_result (task, ctx->cfg->metric, sel->symbol, max, cur); } } |