diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-01-25 23:22:46 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-01-25 23:22:46 +0000 |
commit | b1eed8e17a5e7a97533a0836e0c2f091bb1c9393 (patch) | |
tree | 8a281330ca30f1cee5a74155f03196776f3387f9 /src | |
parent | 68344f63fc1b44920b63db1596517ed3184b0cae (diff) | |
download | rspamd-b1eed8e17a5e7a97533a0836e0c2f091bb1c9393.tar.gz rspamd-b1eed8e17a5e7a97533a0836e0c2f091bb1c9393.zip |
Add tokens processing.
Diffstat (limited to 'src')
-rw-r--r-- | src/libstat/stat_internal.h | 1 | ||||
-rw-r--r-- | src/libstat/stat_process.c | 32 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/libstat/stat_internal.h b/src/libstat/stat_internal.h index 54f7e13d9..985472d2c 100644 --- a/src/libstat/stat_internal.h +++ b/src/libstat/stat_internal.h @@ -31,6 +31,7 @@ struct rspamd_statfile_runtime { struct rspamd_statfile_config *st; + struct rspamd_stat_backend *backend; gpointer backend_runtime; guint64 hits; guint64 total_hits; diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index fcc068e5b..0151bb979 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -46,11 +46,40 @@ preprocess_init_stat_token (gpointer k, gpointer v, gpointer d) { rspamd_token_t *t = (rspamd_token_t *)v; struct preprocess_cb_data *cbdata = (struct preprocess_cb_data *)d; + struct rspamd_statfile_runtime *st_runtime; + struct rspamd_classifier_runtime *cl_runtime; + struct rspamd_token_result *res; + GList *cur, *curst; + gint i = 0; t->results = g_array_sized_new (FALSE, TRUE, sizeof (struct rspamd_token_result), cbdata->results_count); - /* TODO: add filling of results array */ + cur = g_list_first (cbdata->classifier_runtimes); + + while (cur) { + cl_runtime = (struct rspamd_classifier_runtime *)cur->data; + res = &g_array_index (t->results, struct rspamd_token_result, i); + + curst = res->cl_runtime->st_runtime; + + while (curst) { + st_runtime = (struct rspamd_statfile_runtime *)curst->data; + + res->cl_runtime = cl_runtime; + res->st_runtime = st_runtime; + + if (st_runtime->backend->process_token (t, res, + st_runtime->backend->ctx)) { + cl_runtime->processed_tokens ++; + } + + i ++; + curst = g_list_next (curst); + } + cur = g_list_next (cur); + } + return FALSE; } @@ -120,6 +149,7 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx, sizeof (*st_runtime)); st_runtime->st = stcf; st_runtime->backend_runtime = backend_runtime; + st_runtime->backend = bk; cl_runtime->st_runtime = g_list_prepend (cl_runtime->st_runtime, st_runtime); |