summaryrefslogtreecommitdiffstats
path: root/src/classifiers
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-11-12 20:38:20 +0300
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-11-12 20:38:20 +0300
commit092a40dcf813accb11a0b6bb600dccea0b35fb1d (patch)
treebc15b37adda2a21575799204dbc528874d2e82c2 /src/classifiers
parent1ad9f1f651ef3f0ee26d69007dd27e60f99f1f12 (diff)
downloadrspamd-092a40dcf813accb11a0b6bb600dccea0b35fb1d.tar.gz
rspamd-092a40dcf813accb11a0b6bb600dccea0b35fb1d.zip
* Write revision and revision time to statfile
* Make some improvements to API (trying to make it more clear)
Diffstat (limited to 'src/classifiers')
-rw-r--r--src/classifiers/classifiers.h4
-rw-r--r--src/classifiers/winnow.c24
2 files changed, 4 insertions, 24 deletions
diff --git a/src/classifiers/classifiers.h b/src/classifiers/classifiers.h
index fcb251da1..cab6eff21 100644
--- a/src/classifiers/classifiers.h
+++ b/src/classifiers/classifiers.h
@@ -20,7 +20,7 @@ struct classifier {
struct classifier_ctx* (*init_func)(memory_pool_t *pool, struct classifier_config *cf);
void (*classify_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task);
void (*learn_func)(struct classifier_ctx* ctx, statfile_pool_t *pool,
- char *symbol, GTree *input, gboolean in_class);
+ stat_file_t *file, GTree *input, gboolean in_class);
};
/* Get classifier structure by name or return NULL if this name is not found */
@@ -29,7 +29,7 @@ struct classifier* get_classifier (char *name);
/* Winnow algorithm */
struct classifier_ctx* winnow_init (memory_pool_t *pool, struct classifier_config *cf);
void winnow_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct worker_task *task);
-void winnow_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, char *symbol, GTree *input, gboolean in_class);
+void winnow_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, stat_file_t *file, GTree *input, gboolean in_class);
/* Array of all defined classifiers */
extern struct classifier classifiers[];
diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c
index cc2a0cc23..8f2b6a6fb 100644
--- a/src/classifiers/winnow.c
+++ b/src/classifiers/winnow.c
@@ -154,15 +154,13 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp
}
void
-winnow_learn (struct classifier_ctx *ctx, statfile_pool_t * pool, char *symbol, GTree * input, int in_class)
+winnow_learn (struct classifier_ctx *ctx, statfile_pool_t *pool, stat_file_t *file, GTree * input, int in_class)
{
struct winnow_callback_data data = {
.file = NULL,
.sum = 0,
.count = 0,
};
- GList *cur;
- struct statfile *st;
g_assert (pool != NULL);
g_assert (ctx != NULL);
@@ -172,25 +170,7 @@ winnow_learn (struct classifier_ctx *ctx, statfile_pool_t * pool, char *symbol,
data.now = time (NULL);
data.ctx = ctx;
- cur = g_list_first (ctx->cfg->statfiles);
- while (cur) {
- st = cur->data;
- if (strcmp (symbol, st->symbol) == 0) {
- if ((data.file = statfile_pool_open (pool, st->path, st->size, FALSE)) == NULL) {
- /* Try to create statfile */
- if (statfile_pool_create (pool, st->path, st->size) == -1) {
- msg_err ("winnow_learn: cannot create statfile %s", st->path);
- return;
- }
- if ((data.file = statfile_pool_open (pool, st->path, st->size, FALSE)) == NULL) {
- msg_err ("winnow_learn: cannot create statfile %s", st->path);
- return;
- }
- }
- break;
- }
- cur = g_list_next (cur);
- }
+ data.file = file;
if (data.file != NULL) {
statfile_pool_lock_file (pool, data.file);