aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-05 13:27:46 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-05 13:27:46 +0000
commitda4453ce4c343f76c069078b89307f3bde62884e (patch)
tree5c3167a191c994d7e0c52a5f906dfc188227d3fb /src/libserver
parent022977e0b7c160e6e33ec07f2c41f60707d43cb6 (diff)
downloadrspamd-da4453ce4c343f76c069078b89307f3bde62884e.tar.gz
rspamd-da4453ce4c343f76c069078b89307f3bde62884e.zip
[Rework] Refactor struct names
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/cfg_file.h14
-rw-r--r--src/libserver/cfg_rcl.c20
-rw-r--r--src/libserver/cfg_utils.c24
-rw-r--r--src/libserver/composites.c18
-rw-r--r--src/libserver/dynamic_cfg.c2
-rw-r--r--src/libserver/protocol.c28
-rw-r--r--src/libserver/protocol.h2
-rw-r--r--src/libserver/roll_history.c4
-rw-r--r--src/libserver/symbols_cache.c18
-rw-r--r--src/libserver/task.c10
-rw-r--r--src/libserver/task.h4
11 files changed, 72 insertions, 72 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index ea75622f8..ccd1d41ed 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -85,7 +85,7 @@ enum lua_var_type {
/**
* Symbols group
*/
-struct rspamd_symbol_def;
+struct rspamd_symbol;
struct rspamd_symbols_group {
gchar *name;
GHashTable *symbols;
@@ -101,7 +101,7 @@ struct rspamd_symbols_group {
/**
* Symbol definition
*/
-struct rspamd_symbol_def {
+struct rspamd_symbol {
gchar *name;
gchar *description;
gdouble *weight_ptr;
@@ -258,7 +258,7 @@ struct metric_action {
/**
* Common definition of metric
*/
-struct metric {
+struct rspamd_metric {
const gchar *name; /**< name of metric */
gchar *func_name; /**< name of consolidation function */
gboolean accept_unknown_symbols; /**< if true unknown symbols are registered here */
@@ -370,7 +370,7 @@ struct rspamd_config {
struct symbols_cache *cache; /**< symbols cache object */
gchar *cache_filename; /**< filename of cache file */
- struct metric *default_metric; /**< default metric */
+ struct rspamd_metric *default_metric; /**< default metric */
gchar * checksum; /**< real checksum of config file */
gchar * dump_checksum; /**< dump checksum of config file */
@@ -524,14 +524,14 @@ struct rspamd_worker_conf * rspamd_config_new_worker (struct rspamd_config *cfg,
/*
* Return a new metric structure, setting default and non-conflicting attributes
*/
-struct metric * rspamd_config_new_metric (struct rspamd_config *cfg,
- struct metric *c, const gchar *name);
+struct rspamd_metric * rspamd_config_new_metric (struct rspamd_config *cfg,
+ struct rspamd_metric *c, const gchar *name);
/*
* Return new symbols group definition
*/
struct rspamd_symbols_group * rspamd_config_new_group (
- struct rspamd_config *cfg, struct metric *metric,
+ struct rspamd_config *cfg, struct rspamd_metric *metric,
const gchar *name);
/*
* Return a new statfile structure, setting default and non-conflicting attributes
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 7737b7b96..282ae7469 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -275,7 +275,7 @@ rspamd_rcl_options_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
}
struct rspamd_rcl_symbol_data {
- struct metric *metric;
+ struct rspamd_metric *metric;
struct rspamd_symbols_group *gr;
struct rspamd_config *cfg;
};
@@ -286,7 +286,7 @@ rspamd_rcl_group_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_symbol_data *sd = ud;
- struct metric *metric;
+ struct rspamd_metric *metric;
struct rspamd_symbols_group *gr;
const ucl_object_t *val, *cur;
struct rspamd_rcl_section *subsection;
@@ -331,7 +331,7 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_symbol_data *sd = ud;
- struct metric *metric;
+ struct rspamd_metric *metric;
struct rspamd_config *cfg;
const ucl_object_t *elt;
const gchar *description = NULL;
@@ -393,7 +393,7 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
struct metric_actions_cbdata {
struct rspamd_config *cfg;
- struct metric *metric;
+ struct rspamd_metric *metric;
};
static gboolean
@@ -406,7 +406,7 @@ rspamd_rcl_actions_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
gint action_value;
const ucl_object_t *cur;
ucl_object_iter_t it = NULL;
- struct metric *metric;
+ struct rspamd_metric *metric;
struct rspamd_config *cfg;
metric = cbdata->metric;
@@ -440,10 +440,10 @@ rspamd_rcl_metric_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
const ucl_object_t *val, *cur, *elt;
ucl_object_iter_t it;
struct rspamd_config *cfg = ud;
- struct metric *metric;
+ struct rspamd_metric *metric;
struct rspamd_rcl_section *subsection;
struct rspamd_rcl_symbol_data sd;
- struct rspamd_symbol_def *sym_def;
+ struct rspamd_symbol *sym_def;
struct metric_actions_cbdata acts_cbdata;
g_assert (key != NULL);
@@ -2117,13 +2117,13 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
rspamd_rcl_add_default_handler (sub,
"unknown_weight",
rspamd_rcl_parse_struct_double,
- G_STRUCT_OFFSET (struct metric, unknown_weight),
+ G_STRUCT_OFFSET (struct rspamd_metric, unknown_weight),
0,
"Accept unknown symbols with the specified weight");
rspamd_rcl_add_default_handler (sub,
"grow_factor",
rspamd_rcl_parse_struct_double,
- G_STRUCT_OFFSET (struct metric, grow_factor),
+ G_STRUCT_OFFSET (struct rspamd_metric, grow_factor),
0,
"Multiply the subsequent symbols by this number "
"(does not affect symbols with score less or "
@@ -2131,7 +2131,7 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
rspamd_rcl_add_default_handler (sub,
"subject",
rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct metric, subject),
+ G_STRUCT_OFFSET (struct rspamd_metric, subject),
0,
"Rewrite subject with this value");
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 46b574ac8..24b5568b9 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -647,7 +647,7 @@ rspamd_config_post_load (struct rspamd_config *cfg,
#ifdef HAVE_CLOCK_GETTIME
struct timespec ts;
#endif
- struct metric *def_metric;
+ struct rspamd_metric *def_metric;
gboolean ret = TRUE;
#ifdef HAVE_CLOCK_GETTIME
@@ -894,14 +894,14 @@ rspamd_config_new_statfile (struct rspamd_config *cfg,
return c;
}
-struct metric *
-rspamd_config_new_metric (struct rspamd_config *cfg, struct metric *c,
+struct rspamd_metric *
+rspamd_config_new_metric (struct rspamd_config *cfg, struct rspamd_metric *c,
const gchar *name)
{
int i;
if (c == NULL) {
- c = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct metric));
+ c = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_metric));
c->grow_factor = 1.0;
c->symbols = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
c->groups = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
@@ -933,7 +933,7 @@ rspamd_config_new_metric (struct rspamd_config *cfg, struct metric *c,
}
struct rspamd_symbols_group *
-rspamd_config_new_group (struct rspamd_config *cfg, struct metric *metric,
+rspamd_config_new_group (struct rspamd_config *cfg, struct rspamd_metric *metric,
const gchar *name)
{
struct rspamd_symbols_group *gr;
@@ -1408,17 +1408,17 @@ rspamd_init_filters (struct rspamd_config *cfg, bool reconfig)
static void
rspamd_config_new_metric_symbol (struct rspamd_config *cfg,
- struct metric *metric, const gchar *symbol,
+ struct rspamd_metric *metric, const gchar *symbol,
gdouble score, const gchar *description, const gchar *group,
guint flags, guint priority)
{
struct rspamd_symbols_group *sym_group;
- struct rspamd_symbol_def *sym_def;
+ struct rspamd_symbol *sym_def;
GList *metric_list;
gdouble *score_ptr;
sym_def =
- rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_symbol_def));
+ rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_symbol));
score_ptr = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (gdouble));
*score_ptr = score;
@@ -1474,8 +1474,8 @@ rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
gdouble score, const gchar *description, const gchar *group,
guint flags, guint priority)
{
- struct rspamd_symbol_def *sym_def;
- struct metric *metric;
+ struct rspamd_symbol *sym_def;
+ struct rspamd_metric *metric;
g_assert (cfg != NULL);
g_assert (symbol != NULL);
@@ -1544,7 +1544,7 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg,
const gchar *module_name)
{
gboolean is_c = FALSE;
- struct metric *metric;
+ struct rspamd_metric *metric;
const ucl_object_t *conf, *enabled;
GList *cur;
struct rspamd_symbols_group *gr;
@@ -1630,7 +1630,7 @@ rspamd_config_set_action_score (struct rspamd_config *cfg,
guint priority)
{
struct metric_action *act;
- struct metric *metric;
+ struct rspamd_metric *metric;
gint act_num;
g_assert (cfg != NULL);
diff --git a/src/libserver/composites.c b/src/libserver/composites.c
index d0cf26a95..3ad724887 100644
--- a/src/libserver/composites.c
+++ b/src/libserver/composites.c
@@ -24,7 +24,7 @@
struct composites_data {
struct rspamd_task *task;
struct rspamd_composite *composite;
- struct metric_result *metric_res;
+ struct rspamd_metric_result *metric_res;
GHashTable *symbols_to_remove;
guint8 *checked;
};
@@ -37,7 +37,7 @@ enum rspamd_composite_action {
};
struct symbol_remove_data {
- struct symbol *ms;
+ struct rspamd_symbol_result *ms;
struct rspamd_composite *comp;
GNode *parent;
guint action;
@@ -92,9 +92,9 @@ rspamd_composite_expr_parse (const gchar *line, gsize len,
static gint
rspamd_composite_process_single_symbol (struct composites_data *cd,
- const gchar *sym, struct symbol **pms)
+ const gchar *sym, struct rspamd_symbol_result **pms)
{
- struct symbol *ms = NULL;
+ struct rspamd_symbol_result *ms = NULL;
gint rc = 0;
struct rspamd_composite *ncomp;
@@ -139,10 +139,10 @@ rspamd_composite_expr_process (gpointer input, rspamd_expression_atom_t *atom)
const gchar *beg = atom->data, *sym = NULL;
gchar t;
struct symbol_remove_data *rd, *nrd;
- struct symbol *ms;
+ struct rspamd_symbol_result *ms;
struct rspamd_symbols_group *gr;
- struct rspamd_symbol_def *sdef;
- struct metric *metric;
+ struct rspamd_symbol *sdef;
+ struct rspamd_metric *metric;
GHashTableIter it;
gpointer k, v;
gint rc = 0;
@@ -371,10 +371,10 @@ composites_metric_callback (gpointer key, gpointer value, gpointer data)
struct rspamd_task *task = (struct rspamd_task *)data;
struct composites_data *cd =
rspamd_mempool_alloc (task->task_pool, sizeof (struct composites_data));
- struct metric_result *metric_res = (struct metric_result *)value;
+ struct rspamd_metric_result *metric_res = (struct rspamd_metric_result *)value;
cd->task = task;
- cd->metric_res = (struct metric_result *)metric_res;
+ cd->metric_res = (struct rspamd_metric_result *)metric_res;
cd->symbols_to_remove = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cd->checked =
rspamd_mempool_alloc0 (task->task_pool,
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c
index ffb5963a5..b74b0a8f9 100644
--- a/src/libserver/dynamic_cfg.c
+++ b/src/libserver/dynamic_cfg.c
@@ -37,7 +37,7 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
gint test_act;
const ucl_object_t *cur_elt, *cur_nm, *it_val;
ucl_object_iter_t it = NULL;
- struct metric *real_metric;
+ struct rspamd_metric *real_metric;
const gchar *name;
gdouble nscore;
static const guint priority = 3;
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index ace286dbf..a1a1ae8fe 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -766,7 +766,7 @@ rspamd_emails_tree_ucl (GHashTable *input, struct rspamd_task *task)
/* Write new subject */
static const gchar *
-make_rewritten_subject (struct metric *metric, struct rspamd_task *task)
+make_rewritten_subject (struct rspamd_metric *metric, struct rspamd_task *task)
{
static gchar subj_buf[1024];
gchar *p = subj_buf, *end, *res;
@@ -825,14 +825,14 @@ rspamd_str_hash_ucl (GHashTable *ht)
}
static ucl_object_t *
-rspamd_metric_symbol_ucl (struct rspamd_task *task, struct metric *m,
- struct symbol *sym)
+rspamd_metric_symbol_ucl (struct rspamd_task *task, struct rspamd_metric *m,
+ struct rspamd_symbol_result *sym)
{
ucl_object_t *obj = NULL;
const gchar *description = NULL;
- if (sym->def != NULL) {
- description = sym->def->description;
+ if (sym->sym != NULL) {
+ description = sym->sym->description;
}
obj = ucl_object_typed_new (UCL_OBJECT);
@@ -854,11 +854,11 @@ rspamd_metric_symbol_ucl (struct rspamd_task *task, struct metric *m,
static ucl_object_t *
rspamd_metric_result_ucl (struct rspamd_task *task,
- struct metric_result *mres)
+ struct rspamd_metric_result *mres)
{
GHashTableIter hiter;
- struct symbol *sym;
- struct metric *m;
+ struct rspamd_symbol_result *sym;
+ struct rspamd_metric *m;
gboolean is_spam;
enum rspamd_metric_action action = METRIC_ACTION_NOACTION;
ucl_object_t *obj = NULL, *sobj;;
@@ -903,7 +903,7 @@ rspamd_metric_result_ucl (struct rspamd_task *task,
/* Now handle symbols */
g_hash_table_iter_init (&hiter, mres->symbols);
while (g_hash_table_iter_next (&hiter, &h, &v)) {
- sym = (struct symbol *)v;
+ sym = (struct rspamd_symbol_result *)v;
sobj = rspamd_metric_symbol_ucl (task, m, sym);
ucl_object_insert_key (obj, sobj, h, 0, false);
}
@@ -1010,7 +1010,7 @@ rspamd_ucl_tospamc_output (const ucl_object_t *top,
ucl_object_t *
rspamd_protocol_write_ucl (struct rspamd_task *task)
{
- struct metric_result *metric_res;
+ struct rspamd_metric_result *metric_res;
ucl_object_t *top = NULL, *obj;
GHashTableIter hiter;
GString *dkim_sig;
@@ -1021,7 +1021,7 @@ rspamd_protocol_write_ucl (struct rspamd_task *task)
top = ucl_object_typed_new (UCL_OBJECT);
/* Convert results to an ucl object */
while (g_hash_table_iter_next (&hiter, &h, &v)) {
- metric_res = (struct metric_result *)v;
+ metric_res = (struct rspamd_metric_result *)v;
obj = rspamd_metric_result_ucl (task, metric_res);
ucl_object_insert_key (top, obj, h, 0, false);
}
@@ -1069,7 +1069,7 @@ void
rspamd_protocol_http_reply (struct rspamd_http_message *msg,
struct rspamd_task *task)
{
- struct metric_result *metric_res;
+ struct rspamd_metric_result *metric_res;
GHashTableIter hiter;
const struct rspamd_re_cache_stat *restat;
gpointer h, v;
@@ -1224,10 +1224,10 @@ rspamd_protocol_write_log_pipe (struct rspamd_worker_ctx *ctx,
struct rspamd_worker_log_pipe *lp;
struct rspamd_protocol_log_message_sum *ls;
lua_State *L = task->cfg->lua_state;
- struct metric_result *mres;
+ struct rspamd_metric_result *mres;
GHashTableIter it;
gpointer k, v;
- struct symbol *sym;
+ struct rspamd_symbol_result *sym;
gint id, i;
guint32 *sid, n = 0, nextra = 0;
gsize sz;
diff --git a/src/libserver/protocol.h b/src/libserver/protocol.h
index a38be7652..164a53d2f 100644
--- a/src/libserver/protocol.h
+++ b/src/libserver/protocol.h
@@ -31,7 +31,7 @@ struct rspamd_protocol_log_message_sum {
struct rspamd_protocol_log_symbol_result results[];
};
-struct metric;
+struct rspamd_metric;
/**
* Process headers into HTTP message and set appropriate task fields
diff --git a/src/libserver/roll_history.c b/src/libserver/roll_history.c
index 620397f38..c6d59dc9d 100644
--- a/src/libserver/roll_history.c
+++ b/src/libserver/roll_history.c
@@ -52,7 +52,7 @@ static void
roll_history_symbols_callback (gpointer key, gpointer value, void *user_data)
{
struct history_metric_callback_data *cb = user_data;
- struct symbol *s = value;
+ struct rspamd_symbol_result *s = value;
guint wr;
if (cb->remain > 0) {
@@ -73,7 +73,7 @@ rspamd_roll_history_update (struct roll_history *history,
{
guint row_num;
struct roll_history_row *row;
- struct metric_result *metric_res;
+ struct rspamd_metric_result *metric_res;
struct history_metric_callback_data cbdata;
/* First of all obtain check and obtain row number */
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index e57a45ce6..396512cf7 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -147,7 +147,7 @@ struct cache_savepoint {
RSPAMD_CACHE_PASS_DONE,
} pass;
guint version;
- struct metric_result *rs;
+ struct rspamd_metric_result *rs;
gdouble lim;
GPtrArray *waitq;
struct symbols_cache_order *order;
@@ -907,8 +907,8 @@ rspamd_symbols_cache_validate_cb (gpointer k, gpointer v, gpointer ud)
struct cache_item *item = v, *parent;
struct symbols_cache *cache = (struct symbols_cache *)ud;
GList *cur;
- struct metric *m;
- struct rspamd_symbol_def *s;
+ struct rspamd_metric *m;
+ struct rspamd_symbol *s;
gboolean skipped, ghost;
gint p1, p2;
@@ -992,7 +992,7 @@ rspamd_symbols_cache_metric_validate_cb (gpointer k, gpointer v, gpointer ud)
{
struct symbols_cache *cache = (struct symbols_cache *)ud;
const gchar *sym = k;
- struct rspamd_symbol_def *s = (struct rspamd_symbol_def *)v;
+ struct rspamd_symbol *s = (struct rspamd_symbol *)v;
gdouble weight;
struct cache_item *item;
@@ -1013,8 +1013,8 @@ rspamd_symbols_cache_validate (struct symbols_cache *cache,
GHashTableIter it;
GList *cur;
gpointer k, v;
- struct rspamd_symbol_def *sym_def;
- struct metric *metric;
+ struct rspamd_symbol *sym_def;
+ struct rspamd_metric *metric;
gboolean ignore_symbol = FALSE, ret = TRUE;
if (cache == NULL) {
@@ -1074,9 +1074,9 @@ static gboolean
rspamd_symbols_cache_metric_limit (struct rspamd_task *task,
struct cache_savepoint *cp)
{
- struct metric_result *res;
+ struct rspamd_metric_result *res;
GList *cur;
- struct metric *metric;
+ struct rspamd_metric *metric;
double ms;
if (task->flags & RSPAMD_TASK_FLAG_PASS_ALL) {
@@ -1397,7 +1397,7 @@ rspamd_symbols_cache_process_settings (struct rspamd_task *task,
struct symbols_cache *cache)
{
const ucl_object_t *wl, *cur, *disabled, *enabled;
- struct metric *def;
+ struct rspamd_metric *def;
struct rspamd_symbols_group *gr;
GHashTableIter gr_it;
ucl_object_iter_t it = NULL;
diff --git a/src/libserver/task.c b/src/libserver/task.c
index 6cf7532fd..51d4da1e5 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -961,8 +961,8 @@ rspamd_task_log_check_condition (struct rspamd_task *task,
static gint
rspamd_task_compare_log_sym (gconstpointer a, gconstpointer b)
{
- const struct symbol *s1 = *(const struct symbol **)a,
- *s2 = *(const struct symbol **)b;
+ const struct rspamd_symbol_result *s1 = *(const struct rspamd_symbol_result **)a,
+ *s2 = *(const struct rspamd_symbol_result **)b;
gdouble w1, w2;
@@ -982,12 +982,12 @@ rspamd_task_log_metric_res (struct rspamd_task *task,
{
static gchar scorebuf[32];
rspamd_ftok_t res = {.begin = NULL, .len = 0};
- struct metric_result *mres;
+ struct rspamd_metric_result *mres;
GHashTableIter it;
gboolean first = TRUE;
gpointer k, v;
rspamd_fstring_t *symbuf;
- struct symbol *sym;
+ struct rspamd_symbol_result *sym;
GPtrArray *sorted_symbols;
guint i, j;
@@ -1417,7 +1417,7 @@ rspamd_task_write_log (struct rspamd_task *task)
}
gdouble
-rspamd_task_get_required_score (struct rspamd_task *task, struct metric_result *m)
+rspamd_task_get_required_score (struct rspamd_task *task, struct rspamd_metric_result *m)
{
guint i;
diff --git a/src/libserver/task.h b/src/libserver/task.h
index f46e09379..341edcc7d 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -276,9 +276,9 @@ gboolean rspamd_learn_task_spam (struct rspamd_task *task,
* @param m
* @return
*/
-struct metric_result;
+struct rspamd_metric_result;
gdouble rspamd_task_get_required_score (struct rspamd_task *task,
- struct metric_result *m);
+ struct rspamd_metric_result *m);
/**
* Returns the first header as value for a header