summaryrefslogtreecommitdiffstats
path: root/src/libstat/stat_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstat/stat_internal.h')
-rw-r--r--src/libstat/stat_internal.h69
1 files changed, 29 insertions, 40 deletions
diff --git a/src/libstat/stat_internal.h b/src/libstat/stat_internal.h
index 640196788..591c47381 100644
--- a/src/libstat/stat_internal.h
+++ b/src/libstat/stat_internal.h
@@ -30,20 +30,6 @@
#include "backends/backends.h"
#include "learn_cache/learn_cache.h"
-enum stat_process_stage {
- RSPAMD_STAT_STAGE_PRE = 0,
- RSPAMD_STAT_STAGE_POST
-};
-
-struct rspamd_tokenizer_runtime {
- GTree *tokens;
- const gchar *name;
- struct rspamd_stat_tokenizer *tokenizer;
- struct rspamd_tokenizer_config *tkcf;
- gpointer config;
- gsize conf_len;
-};
-
struct rspamd_statfile_runtime {
struct rspamd_statfile_config *st;
gpointer backend_runtime;
@@ -51,28 +37,24 @@ struct rspamd_statfile_runtime {
guint64 total_hits;
};
-struct rspamd_classifier_runtime {
- struct rspamd_classifier_config *clcf;
- struct classifier_ctx *clctx;
- struct rspamd_stat_classifier *cl;
- struct rspamd_stat_backend *backend;
- struct rspamd_tokenizer_runtime *tok;
- double ham_prob;
- double spam_prob;
- enum stat_process_stage stage;
- guint64 total_spam;
- guint64 total_ham;
- guint64 processed_tokens;
- GList *st_runtime;
- guint start_pos;
- guint end_pos;
- gboolean skipped;
+/* Common classifier structure */
+struct rspamd_classifier {
+ struct rspamd_stat_ctx *ctx;
+ struct rspamd_stat_cache *cache;
+ gpointer cachecf;
+ GArray *statfiles_ids;
+ gulong spam_learns;
+ gulong ham_learns;
+ struct rspamd_classifier_config *cfg;
+ struct rspamd_stat_classifier *subrs;
};
-struct rspamd_token_result {
- double value;
- struct rspamd_statfile_runtime *st_runtime;
- struct rspamd_classifier_runtime *cl_runtime;
+struct rspamd_statfile {
+ gint id;
+ struct rspamd_statfile_config *stcf;
+ struct rspamd_classifier *classifier;
+ struct rspamd_stat_backend *backend;
+ gpointer bkcf;
};
#define RSPAMD_MAX_TOKEN_LEN 16
@@ -80,21 +62,27 @@ typedef struct token_node_s {
guchar data[RSPAMD_MAX_TOKEN_LEN];
guint window_idx;
guint datalen;
- GArray *results;
+ gdouble values[];
} rspamd_token_t;
struct rspamd_stat_ctx {
- struct rspamd_stat_classifier *classifiers;
+ /* Subroutines for all objects */
+ struct rspamd_stat_classifier *classifiers_subrs;
guint classifiers_count;
- struct rspamd_stat_tokenizer *tokenizers;
+ struct rspamd_stat_tokenizer *tokenizers_subrs;
guint tokenizers_count;
- struct rspamd_stat_backend *backends;
+ struct rspamd_stat_backend *backends_subrs;
guint backends_count;
- struct rspamd_stat_cache *caches;
+ struct rspamd_stat_cache *caches_subrs;
guint caches_count;
- guint statfiles;
+ /* Runtime configuration */
+ GPtrArray *statfiles; /* struct rspamd_statfile */
+ GPtrArray *classifiers; /* struct rspamd_classifier */
struct rspamd_config *cfg;
+ /* Global tokenizer */
+ struct rspamd_stat_tokenizer *tokenizer;
+ gpointer tkcf;
};
typedef enum rspamd_learn_cache_result {
@@ -107,6 +95,7 @@ struct rspamd_stat_ctx * rspamd_stat_get_ctx (void);
struct rspamd_stat_classifier * rspamd_stat_get_classifier (const gchar *name);
struct rspamd_stat_backend * rspamd_stat_get_backend (const gchar *name);
struct rspamd_stat_tokenizer * rspamd_stat_get_tokenizer (const gchar *name);
+struct rspamd_stat_cache * rspamd_stat_get_cache (const gchar *name);
static GQuark rspamd_stat_quark (void)
{