aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/classifiers/bayes.c16
-rw-r--r--src/classifiers/classifiers.h10
-rw-r--r--src/classifiers/winnow.c8
-rw-r--r--src/controller.c30
-rw-r--r--src/fuzzy_storage.c10
-rw-r--r--src/kvstorage_config.c12
-rw-r--r--src/libmime/filter.c14
-rw-r--r--src/libmime/filter.h4
-rw-r--r--src/libmime/protocol.c2
-rw-r--r--src/libmime/smtp_utils.c2
-rw-r--r--src/libserver/binlog.c4
-rw-r--r--src/libserver/binlog.h6
-rw-r--r--src/libserver/cfg_file.h80
-rw-r--r--src/libserver/cfg_rcl.c148
-rw-r--r--src/libserver/cfg_rcl.h26
-rw-r--r--src/libserver/cfg_utils.c78
-rw-r--r--src/libserver/dns.c2
-rw-r--r--src/libserver/dns.h2
-rw-r--r--src/libserver/dynamic_cfg.c12
-rw-r--r--src/libserver/dynamic_cfg.h8
-rw-r--r--src/libserver/settings.c4
-rw-r--r--src/libserver/settings.h4
-rw-r--r--src/libserver/statfile.c4
-rw-r--r--src/libserver/statfile.h8
-rw-r--r--src/libserver/statfile_sync.c10
-rw-r--r--src/libserver/statfile_sync.h2
-rw-r--r--src/libserver/symbols_cache.c12
-rw-r--r--src/libserver/symbols_cache.h8
-rw-r--r--src/libserver/task.h2
-rw-r--r--src/libserver/worker_util.c10
-rw-r--r--src/libserver/worker_util.h8
-rw-r--r--src/libutil/logger.c4
-rw-r--r--src/libutil/logger.h2
-rw-r--r--src/libutil/map.c6
-rw-r--r--src/libutil/map.h10
-rw-r--r--src/libutil/util.c2
-rw-r--r--src/libutil/util.h8
-rw-r--r--src/lua/lua_cfg_file.c8
-rw-r--r--src/lua/lua_classifier.c54
-rw-r--r--src/lua/lua_common.c14
-rw-r--r--src/lua/lua_common.h20
-rw-r--r--src/lua/lua_config.c40
-rw-r--r--src/lua/lua_dns.c2
-rw-r--r--src/lua/lua_task.c10
-rw-r--r--src/lua/lua_upstream.c4
-rw-r--r--src/lua_worker.c10
-rw-r--r--src/main.c66
-rw-r--r--src/main.h20
-rw-r--r--src/plugins/chartable.c16
-rw-r--r--src/plugins/custom/ipmark/ipmark.c10
-rw-r--r--src/plugins/custom/regmark/regmark.c10
-rw-r--r--src/plugins/dkim_check.c34
-rw-r--r--src/plugins/fuzzy_check.c34
-rw-r--r--src/plugins/regexp.c16
-rw-r--r--src/plugins/spf.c24
-rw-r--r--src/plugins/surbl.c38
-rw-r--r--src/smtp.c6
-rw-r--r--src/smtp.h2
-rw-r--r--src/smtp_proxy.c6
-rw-r--r--src/webui.c24
-rw-r--r--src/worker.c6
-rw-r--r--test/rspamd_dkim_test.c6
-rw-r--r--test/rspamd_dns_test.c6
-rw-r--r--test/rspamd_test_suite.c6
64 files changed, 535 insertions, 535 deletions
diff --git a/src/classifiers/bayes.c b/src/classifiers/bayes.c
index 9c81b2370..a8a18f5ff 100644
--- a/src/classifiers/bayes.c
+++ b/src/classifiers/bayes.c
@@ -45,7 +45,7 @@ struct bayes_statfile_data {
guint64 hits;
guint64 total_hits;
double value;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
stat_file_t *file;
};
@@ -190,7 +190,7 @@ bayes_classify_callback (gpointer key, gpointer value, gpointer data)
}
struct classifier_ctx*
-bayes_init (rspamd_mempool_t *pool, struct classifier_config *cfg)
+bayes_init (rspamd_mempool_t *pool, struct rspamd_classifier_config *cfg)
{
struct classifier_ctx *ctx = rspamd_mempool_alloc (pool, sizeof (struct classifier_ctx));
@@ -210,7 +210,7 @@ bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input,
gint minnodes;
guint64 maxhits = 0, rev;
double final_prob, h, s;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
stat_file_t *file;
GList *cur;
char *sumbuf;
@@ -249,7 +249,7 @@ bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input,
data.total_ham = 0;
data.total_spam = 0;
if (ctx->cfg->opts && (value = g_hash_table_lookup (ctx->cfg->opts, "max_tokens")) != NULL) {
- minnodes = parse_limit (value, -1);
+ minnodes = rspamd_config_parse_limit (value, -1);
data.max_tokens = minnodes;
}
else {
@@ -334,7 +334,7 @@ bayes_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symb
gchar *value;
gint nodes;
gint minnodes;
- struct statfile *st, *sel_st = NULL;
+ struct rspamd_statfile_config *st, *sel_st = NULL;
stat_file_t *to_learn;
GList *cur;
@@ -366,7 +366,7 @@ bayes_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symb
data.processed_tokens = 0;
data.processed_tokens = 0;
if (ctx->cfg->opts && (value = g_hash_table_lookup (ctx->cfg->opts, "max_tokens")) != NULL) {
- minnodes = parse_limit (value, -1);
+ minnodes = rspamd_config_parse_limit (value, -1);
data.max_tokens = minnodes;
}
else {
@@ -434,7 +434,7 @@ bayes_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool,
gchar *value;
gint nodes;
gint minnodes;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
stat_file_t *file;
GList *cur;
gboolean skip_labels;
@@ -476,7 +476,7 @@ bayes_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool,
data.processed_tokens = 0;
if (ctx->cfg->opts && (value = g_hash_table_lookup (ctx->cfg->opts, "max_tokens")) != NULL) {
- minnodes = parse_limit (value, -1);
+ minnodes = rspamd_config_parse_limit (value, -1);
data.max_tokens = minnodes;
}
else {
diff --git a/src/classifiers/classifiers.h b/src/classifiers/classifiers.h
index 3f7b755f4..2b36d8c02 100644
--- a/src/classifiers/classifiers.h
+++ b/src/classifiers/classifiers.h
@@ -10,14 +10,14 @@
/* Consider this value as 0 */
#define ALPHA 0.0001
-struct classifier_config;
+struct rspamd_classifier_config;
struct rspamd_task;
struct classifier_ctx {
rspamd_mempool_t *pool;
GHashTable *results;
gboolean debug;
- struct classifier_config *cfg;
+ struct rspamd_classifier_config *cfg;
};
struct classify_weight {
@@ -28,7 +28,7 @@ struct classify_weight {
/* Common classifier structure */
struct classifier {
char *name;
- struct classifier_ctx* (*init_func)(rspamd_mempool_t *pool, struct classifier_config *cf);
+ struct classifier_ctx* (*init_func)(rspamd_mempool_t *pool, struct rspamd_classifier_config *cf);
gboolean (*classify_func)(struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task, lua_State *L);
gboolean (*learn_func)(struct classifier_ctx* ctx, statfile_pool_t *pool,
const char *symbol, GTree *input, gboolean in_class,
@@ -42,7 +42,7 @@ struct classifier {
struct classifier* get_classifier (const char *name);
/* Winnow algorithm */
-struct classifier_ctx* winnow_init (rspamd_mempool_t *pool, struct classifier_config *cf);
+struct classifier_ctx* winnow_init (rspamd_mempool_t *pool, struct rspamd_classifier_config *cf);
gboolean winnow_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task, lua_State *L);
gboolean winnow_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symbol, GTree *input,
gboolean in_class, double *sum, double multiplier, GError **err);
@@ -51,7 +51,7 @@ gboolean winnow_learn_spam (struct classifier_ctx* ctx, statfile_pool_t *pool,
GList *winnow_weights (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task);
/* Bayes algorithm */
-struct classifier_ctx* bayes_init (rspamd_mempool_t *pool, struct classifier_config *cf);
+struct classifier_ctx* bayes_init (rspamd_mempool_t *pool, struct rspamd_classifier_config *cf);
gboolean bayes_classify (struct classifier_ctx* ctx, statfile_pool_t *pool, GTree *input, struct rspamd_task *task, lua_State *L);
gboolean bayes_learn (struct classifier_ctx* ctx, statfile_pool_t *pool, const char *symbol, GTree *input,
gboolean in_class, double *sum, double multiplier, GError **err);
diff --git a/src/classifiers/winnow.c b/src/classifiers/winnow.c
index 91d06aaf4..1fe8f16d2 100644
--- a/src/classifiers/winnow.c
+++ b/src/classifiers/winnow.c
@@ -182,7 +182,7 @@ winnow_learn_callback (gpointer key, gpointer value, gpointer data)
}
struct classifier_ctx *
-winnow_init (rspamd_mempool_t * pool, struct classifier_config *cfg)
+winnow_init (rspamd_mempool_t * pool, struct rspamd_classifier_config *cfg)
{
struct classifier_ctx *ctx = rspamd_mempool_alloc (pool, sizeof (struct classifier_ctx));
@@ -199,7 +199,7 @@ winnow_classify (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inp
char *sumbuf, *value;
long double res = 0., max = 0.;
GList *cur;
- struct statfile *st, *sel = NULL;
+ struct rspamd_statfile_config *st, *sel = NULL;
int nodes, minnodes;
g_assert (pool != NULL);
@@ -287,7 +287,7 @@ winnow_weights (struct classifier_ctx *ctx, statfile_pool_t * pool, GTree * inpu
struct winnow_callback_data data;
long double res = 0.;
GList *cur, *resl = NULL;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
struct classify_weight *w;
char *value;
int nodes, minnodes;
@@ -360,7 +360,7 @@ winnow_learn (struct classifier_ctx *ctx, statfile_pool_t *pool, const char *sym
};
char *value;
int nodes, minnodes, iterations = 0;
- struct statfile *st, *sel_st = NULL;
+ struct rspamd_statfile_config *st, *sel_st = NULL;
stat_file_t *sel = NULL, *to_learn;
long double res = 0., max = 0., start_value = 0., end_value = 0.;
double learn_threshold = 0.0;
diff --git a/src/controller.c b/src/controller.c
index 4665e4718..05b1794cd 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -49,7 +49,7 @@
#define CONTROLLER_RRD_STEP 60
/* Init functions */
-gpointer init_controller (struct config_file *cfg);
+gpointer init_controller (struct rspamd_config *cfg);
void start_controller (struct rspamd_worker *worker);
worker_t controller_worker = {
@@ -246,10 +246,10 @@ check_auth (struct controller_command *cmd, struct controller_session *session)
}
static gboolean
-write_whole_statfile (struct controller_session *session, gchar *symbol, struct classifier_config *ccf)
+write_whole_statfile (struct controller_session *session, gchar *symbol, struct rspamd_classifier_config *ccf)
{
stat_file_t *statfile;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
gchar out_buf[BUFSIZ];
guint i;
guint64 rev, ti, len, pos, blocks;
@@ -307,8 +307,8 @@ process_sync_command (struct controller_session *session, gchar **args)
gchar out_buf[BUFSIZ], *arg, *err_str, *symbol;
gint r;
guint64 rev, time;
- struct statfile *st = NULL;
- struct classifier_config *ccf;
+ struct rspamd_statfile_config *st = NULL;
+ struct rspamd_classifier_config *ccf;
GList *cur;
struct rspamd_binlog *binlog;
GByteArray *data = NULL;
@@ -453,9 +453,9 @@ process_stat_command (struct controller_session *session, gboolean do_reset)
guint64 used, total, rev, ham = 0, spam = 0;
time_t ti;
rspamd_mempool_stat_t mem_st;
- struct classifier_config *ccf;
+ struct rspamd_classifier_config *ccf;
stat_file_t *statfile;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
GList *cur_cl, *cur_st;
struct rspamd_stat *stat, stat_copy;
@@ -550,7 +550,7 @@ process_stat_command (struct controller_session *session, gboolean do_reset)
static gboolean
process_dynamic_conf_command (gchar **cmd_args, struct controller_session *session, gboolean is_action)
{
- struct config_file *cfg = session->cfg;
+ struct rspamd_config *cfg = session->cfg;
gchar *arg, *metric, *name, *err_str;
gdouble value;
gboolean res;
@@ -669,7 +669,7 @@ process_command (struct controller_command *cmd, gchar **cmd_args, struct contro
gint r = 0, days, hours, minutes;
time_t uptime;
guint32 size = 0;
- struct classifier_config *cl;
+ struct rspamd_classifier_config *cl;
struct rspamd_controller_ctx *ctx = session->worker->ctx;
switch (cmd->type) {
@@ -819,7 +819,7 @@ process_command (struct controller_command *cmd, gchar **cmd_args, struct contro
}
return TRUE;
}
- cl = find_classifier_conf (session->cfg, *cmd_args);
+ cl = rspamd_config_find_classifier (session->cfg, *cmd_args);
}
else {
if ((arg = g_hash_table_lookup (session->kwargs, "classifier")) == NULL) {
@@ -831,7 +831,7 @@ process_command (struct controller_command *cmd, gchar **cmd_args, struct contro
return TRUE;
}
else {
- cl = find_classifier_conf (session->cfg, arg);
+ cl = rspamd_config_find_classifier (session->cfg, arg);
}
if ((arg = g_hash_table_lookup (session->kwargs, "content-length")) == NULL) {
msg_debug ("no size specified in learn command");
@@ -891,7 +891,7 @@ process_command (struct controller_command *cmd, gchar **cmd_args, struct contro
}
return TRUE;
}
- cl = find_classifier_conf (session->cfg, *cmd_args);
+ cl = rspamd_config_find_classifier (session->cfg, *cmd_args);
}
else {
if ((arg = g_hash_table_lookup (session->kwargs, "classifier")) == NULL) {
@@ -903,7 +903,7 @@ process_command (struct controller_command *cmd, gchar **cmd_args, struct contro
return TRUE;
}
else {
- cl = find_classifier_conf (session->cfg, arg);
+ cl = rspamd_config_find_classifier (session->cfg, arg);
}
if ((arg = g_hash_table_lookup (session->kwargs, "content-length")) == NULL) {
msg_debug ("no size specified in learn command");
@@ -1845,7 +1845,7 @@ controller_update_rrd (gint fd, short what, void *arg)
}
gpointer
-init_controller (struct config_file *cfg)
+init_controller (struct rspamd_config *cfg)
{
struct rspamd_controller_ctx *ctx;
GQuark type;
@@ -1875,7 +1875,7 @@ start_controller (struct rspamd_worker *worker)
GError *err = NULL;
struct timeval tv;
- ctx->ev_base = prepare_worker (worker, "controller", accept_socket);
+ ctx->ev_base = rspamd_prepare_worker (worker, "controller", accept_socket);
g_mime_init (0);
start_time = time (NULL);
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 555e1d196..7fca37566 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -61,7 +61,7 @@
#define INVALID_NODE_TIME (guint64)-1
/* Init functions */
-gpointer init_fuzzy (struct config_file *cfg);
+gpointer init_fuzzy (struct rspamd_config *cfg);
void start_fuzzy (struct rspamd_worker *worker);
worker_t fuzzy_worker = {
@@ -364,7 +364,7 @@ sigusr2_handler (gint fd, short what, void *arg)
tv.tv_usec = 0;
event_del (&worker->sig_ev_usr1);
event_del (&worker->sig_ev_usr2);
- worker_stop_accept (worker);
+ rspamd_worker_stop_accept (worker);
msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
rspamd_mutex_lock (ctx->update_mtx);
mods = ctx->max_mods + 1;
@@ -907,7 +907,7 @@ sync_callback (gint fd, short what, void *arg)
}
gpointer
-init_fuzzy (struct config_file *cfg)
+init_fuzzy (struct rspamd_config *cfg)
{
struct rspamd_fuzzy_storage_ctx *ctx;
GQuark type;
@@ -967,7 +967,7 @@ start_fuzzy (struct rspamd_worker *worker)
GError *err = NULL;
gint i;
- ctx->ev_base = prepare_worker (worker, "controller", accept_fuzzy_socket);
+ ctx->ev_base = rspamd_prepare_worker (worker, "controller", accept_fuzzy_socket);
server_stat = worker->srv->stat;
/* Custom SIGUSR2 handler */
@@ -1012,7 +1012,7 @@ start_fuzzy (struct rspamd_worker *worker)
if (ctx->update_map != NULL) {
if (!add_map (worker->srv->cfg, ctx->update_map, "Allow fuzzy updates from specified addresses",
read_radix_list, fin_radix_list, (void **)&ctx->update_ips)) {
- if (!rspamd_parse_ip_list (ctx->update_map, &ctx->update_ips)) {
+ if (!rspamd_config_parse_ip_list (ctx->update_map, &ctx->update_ips)) {
msg_warn ("cannot load or parse ip list from '%s'", ctx->update_map);
}
}
diff --git a/src/kvstorage_config.c b/src/kvstorage_config.c
index d7bb8cedd..362a47f49 100644
--- a/src/kvstorage_config.c
+++ b/src/kvstorage_config.c
@@ -380,13 +380,13 @@ void kvstorage_xml_text (GMarkupParseContext *context,
rspamd_strlcpy (kv_parser->current_storage->name, text, text_len + 1);
break;
case KVSTORAGE_STATE_CACHE_MAX_ELTS:
- kv_parser->current_storage->cache.max_elements = parse_limit (text, text_len);
+ kv_parser->current_storage->cache.max_elements = rspamd_config_parse_limit (text, text_len);
break;
case KVSTORAGE_STATE_CACHE_MAX_MEM:
- kv_parser->current_storage->cache.max_memory = parse_limit (text, text_len);
+ kv_parser->current_storage->cache.max_memory = rspamd_config_parse_limit (text, text_len);
break;
case KVSTORAGE_STATE_CACHE_NO_OVERWRITE:
- kv_parser->current_storage->cache.no_overwrite = parse_flag (text);
+ kv_parser->current_storage->cache.no_overwrite = rspamd_config_parse_flag (text);
break;
case KVSTORAGE_STATE_CACHE_TYPE:
if (g_ascii_strncasecmp (text, "hash", MIN (text_len, sizeof ("hash") - 1)) == 0) {
@@ -436,13 +436,13 @@ void kvstorage_xml_text (GMarkupParseContext *context,
rspamd_strlcpy (kv_parser->current_storage->backend.filename, text, text_len + 1);
break;
case KVSTORAGE_STATE_BACKEND_SYNC_OPS:
- kv_parser->current_storage->backend.sync_ops = parse_limit (text, text_len);
+ kv_parser->current_storage->backend.sync_ops = rspamd_config_parse_limit (text, text_len);
break;
case KVSTORAGE_STATE_BACKEND_DO_FSYNC:
- kv_parser->current_storage->backend.do_fsync = parse_flag (text);
+ kv_parser->current_storage->backend.do_fsync = rspamd_config_parse_flag (text);
break;
case KVSTORAGE_STATE_BACKEND_DO_REF:
- kv_parser->current_storage->backend.do_ref = parse_flag (text);
+ kv_parser->current_storage->backend.do_ref = rspamd_config_parse_flag (text);
break;
case KVSTORAGE_STATE_EXPIRE_TYPE:
if (g_ascii_strncasecmp (text, "lru", MIN (text_len, sizeof ("lru") - 1)) == 0) {
diff --git a/src/libmime/filter.c b/src/libmime/filter.c
index 8144439e0..9932b814d 100644
--- a/src/libmime/filter.c
+++ b/src/libmime/filter.c
@@ -503,10 +503,10 @@ check_autolearn (struct statfile_autolearn_params *params, struct rspamd_task *t
}
void
-process_autolearn (struct statfile *st, struct rspamd_task *task, GTree * tokens, struct classifier *classifier, gchar *filename, struct classifier_ctx *ctx)
+process_autolearn (struct rspamd_statfile_config *st, struct rspamd_task *task, GTree * tokens, struct classifier *classifier, gchar *filename, struct classifier_ctx *ctx)
{
stat_file_t *statfile;
- struct statfile *unused;
+ struct rspamd_statfile_config *unused;
if (check_autolearn (st->autolearn, task)) {
if (tokens) {
@@ -582,10 +582,10 @@ classifiers_callback (gpointer value, void *arg)
{
struct classifiers_cbdata *cbdata = arg;
struct rspamd_task *task;
- struct classifier_config *cl = value;
+ struct rspamd_classifier_config *cl = value;
struct classifier_ctx *ctx;
struct mime_text_part *text_part, *p1, *p2;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
GTree *tokens = NULL;
GList *cur;
f_str_t c;
@@ -872,12 +872,12 @@ gboolean
learn_task (const gchar *statfile, struct rspamd_task *task, GError **err)
{
GList *cur, *ex;
- struct classifier_config *cl;
+ struct rspamd_classifier_config *cl;
struct classifier_ctx *cls_ctx;
gchar *s;
f_str_t c;
GTree *tokens = NULL;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
stat_file_t *stf;
gdouble sum;
struct mime_text_part *part, *p1, *p2;
@@ -997,7 +997,7 @@ learn_task (const gchar *statfile, struct rspamd_task *task, GError **err)
}
gboolean
-learn_task_spam (struct classifier_config *cl, struct rspamd_task *task, gboolean is_spam, GError **err)
+learn_task_spam (struct rspamd_classifier_config *cl, struct rspamd_task *task, gboolean is_spam, GError **err)
{
GList *cur, *ex;
struct classifier_ctx *cls_ctx;
diff --git a/src/libmime/filter.h b/src/libmime/filter.h
index 258bd9447..7c3f3e51e 100644
--- a/src/libmime/filter.h
+++ b/src/libmime/filter.h
@@ -12,7 +12,7 @@
struct rspamd_task;
struct rspamd_settings;
-struct classifier_config;
+struct rspamd_classifier_config;
typedef double (*metric_cons_func)(struct rspamd_task *task, const gchar *metric_name, const gchar *func_name);
typedef void (*filter_func)(struct rspamd_task *task);
@@ -147,7 +147,7 @@ gboolean learn_task (const gchar *statfile, struct rspamd_task *task, GError **e
* @param err pointer to GError
* @return true if learn succeed
*/
-gboolean learn_task_spam (struct classifier_config *cl, struct rspamd_task *task, gboolean is_spam, GError **err);
+gboolean learn_task_spam (struct rspamd_classifier_config *cl, struct rspamd_task *task, gboolean is_spam, GError **err);
/*
* Get action from a string
diff --git a/src/libmime/protocol.c b/src/libmime/protocol.c
index 1b7bdf42f..57ef9fe42 100644
--- a/src/libmime/protocol.c
+++ b/src/libmime/protocol.c
@@ -274,7 +274,7 @@ rspamd_protocol_handle_headers (struct rspamd_task *task, struct rspamd_http_mes
case 'j':
case 'J':
if (g_ascii_strcasecmp (headern, JSON_HEADER) == 0) {
- task->is_json = parse_flag (h->value->str);
+ task->is_json = rspamd_config_parse_flag (h->value->str);
}
else {
debug_task ("wrong header: %s", headern);
diff --git a/src/libmime/smtp_utils.c b/src/libmime/smtp_utils.c
index 5178de9dd..5d8f94f64 100644
--- a/src/libmime/smtp_utils.c
+++ b/src/libmime/smtp_utils.c
@@ -348,7 +348,7 @@ parse_upstreams_line (rspamd_mempool_t *pool, struct smtp_upstream *upstreams, c
(*count) ++;
}
else {
- if (! parse_host_port (pool, p, &cur->addr, &cur->port)) {
+ if (! rspamd_parse_host_port (pool, p, &cur->addr, &cur->port)) {
g_strfreev (strv);
return FALSE;
}
diff --git a/src/libserver/binlog.c b/src/libserver/binlog.c
index f085a7de0..ec191eac7 100644
--- a/src/libserver/binlog.c
+++ b/src/libserver/binlog.c
@@ -518,7 +518,7 @@ maybe_init_static (void)
}
gboolean
-maybe_write_binlog (struct classifier_config *ccf, struct statfile *st, stat_file_t *file, GTree *nodes)
+maybe_write_binlog (struct rspamd_classifier_config *ccf, struct rspamd_statfile_config *st, stat_file_t *file, GTree *nodes)
{
struct rspamd_binlog *log;
@@ -554,7 +554,7 @@ maybe_write_binlog (struct classifier_config *ccf, struct statfile *st, stat_fil
}
struct rspamd_binlog*
-get_binlog_by_statfile (struct statfile *st)
+get_binlog_by_statfile (struct rspamd_statfile_config *st)
{
struct rspamd_binlog *log;
diff --git a/src/libserver/binlog.h b/src/libserver/binlog.h
index 9e1a786d3..6b77a7613 100644
--- a/src/libserver/binlog.h
+++ b/src/libserver/binlog.h
@@ -53,7 +53,7 @@ struct rspamd_binlog {
struct rspamd_index_block *cur_idx;
};
-struct classifier_config;
+struct rspamd_classifier_config;
/*
* Open binlog at specified path with specified rotate params
@@ -63,7 +63,7 @@ struct rspamd_binlog* binlog_open (rspamd_mempool_t *pool, const gchar *path, ti
/*
* Get and open binlog for specified statfile
*/
-struct rspamd_binlog* get_binlog_by_statfile (struct statfile *st);
+struct rspamd_binlog* get_binlog_by_statfile (struct rspamd_statfile_config *st);
/*
* Close binlog
@@ -88,6 +88,6 @@ gboolean binlog_sync (struct rspamd_binlog *log, guint64 from_rev, guint64 *from
/*
* Conditional write to a binlog for specified statfile
*/
-gboolean maybe_write_binlog (struct classifier_config *ccf, struct statfile *st, stat_file_t *file, GTree *nodes);
+gboolean maybe_write_binlog (struct rspamd_classifier_config *ccf, struct rspamd_statfile_config *st, stat_file_t *file, GTree *nodes);
#endif
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 6ecb441fd..ae809ea25 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -119,7 +119,7 @@ enum lua_var_type {
/**
* Module option
*/
-struct module_opt {
+struct rspamd_module_opt {
gchar *param; /**< parameter name */
gchar *value; /**< parameter value */
gchar *description; /**< parameter description */
@@ -129,15 +129,10 @@ struct module_opt {
enum lua_var_type lua_type; /**< type of lua variable */
};
-struct module_meta_opt {
- gchar *name; /**< Name of meta option */
- GList *options; /**< List of struct module_opt */
-};
-
/**
* Symbol definition
*/
-struct symbol_def {
+struct rspamd_symbol_def {
gchar *name;
gchar *description;
gdouble *weight_ptr;
@@ -146,7 +141,7 @@ struct symbol_def {
/**
* Symbols group
*/
-struct symbols_group {
+struct rspamd_symbols_group {
gchar *name;
GList *symbols;
};
@@ -154,7 +149,7 @@ struct symbols_group {
/**
* Statfile section definition
*/
-struct statfile_section {
+struct rspamd_statfile_section {
guint32 code; /**< section's code */
guint64 size; /**< size of section */
double weight; /**< weight coefficient for section */
@@ -189,12 +184,12 @@ struct statfile_binlog_params {
guint16 master_port;
};
-typedef double (*statfile_normalize_func)(struct config_file *cfg, long double score, void *params);
+typedef double (*statfile_normalize_func)(struct rspamd_config *cfg, long double score, void *params);
/**
* Statfile config definition
*/
-struct statfile {
+struct rspamd_statfile_config {
gchar *symbol; /**< symbol of statfile */
gchar *path; /**< filesystem pattern (with %r or %f) */
gchar *label; /**< label of this statfile */
@@ -212,7 +207,7 @@ struct statfile {
/**
* Classifier config definition
*/
-struct classifier_config {
+struct rspamd_classifier_config {
GList *statfiles; /**< statfiles list */
GHashTable *labels; /**< statfiles with labels */
gchar *metric; /**< metric of this classifier */
@@ -249,7 +244,7 @@ struct rspamd_worker_cfg_parser {
/**
* Config params for rspamd worker
*/
-struct worker_conf {
+struct rspamd_worker_conf {
worker_t *worker; /**< pointer to worker type */
GQuark type; /**< type of worker */
struct rspamd_worker_bind_conf *bind_conf; /**< bind configuration */
@@ -267,7 +262,7 @@ struct worker_conf {
/**
* Structure that stores all config data
*/
-struct config_file {
+struct rspamd_config {
gchar *rspamd_user; /**< user to run as */
gchar *rspamd_group; /**< group to run as */
rspamd_mempool_t *cfg_pool; /**< memory pool for config */
@@ -379,7 +374,8 @@ struct config_file {
* @param priority priority
* @return TRUE if string was parsed
*/
-gboolean parse_host_port_priority (rspamd_mempool_t *pool, const gchar *str, gchar **addr, guint16 *port, guint *priority);
+gboolean rspamd_parse_host_port_priority (rspamd_mempool_t *pool,
+ const gchar *str, gchar **addr, guint16 *port, guint *priority);
/**
* Parse host:port line
@@ -387,7 +383,8 @@ gboolean parse_host_port_priority (rspamd_mempool_t *pool, const gchar *str, gch
* @param port port
* @return TRUE if string was parsed
*/
-gboolean parse_host_port (rspamd_mempool_t *pool, const gchar *str, gchar **addr, guint16 *port);
+gboolean rspamd_parse_host_port (rspamd_mempool_t *pool, const gchar *str,
+ gchar **addr, guint16 *port);
/**
* Parse host:priority line
@@ -395,7 +392,8 @@ gboolean parse_host_port (rspamd_mempool_t *pool, const gchar *str, gchar **addr
* @param priority priority
* @return TRUE if string was parsed
*/
-gboolean parse_host_priority (rspamd_mempool_t *pool, const gchar *str, gchar **addr, guint *priority);
+gboolean rspamd_parse_host_priority (rspamd_mempool_t *pool, const gchar *str,
+ gchar **addr, guint *priority);
/**
* Parse bind credits
@@ -404,19 +402,20 @@ gboolean parse_host_priority (rspamd_mempool_t *pool, const gchar *str, gchar **
* @param type type of credits
* @return 1 if line was successfully parsed and 0 in case of error
*/
-gboolean parse_bind_line (struct config_file *cfg, struct worker_conf *cf, const gchar *str);
+gboolean rspamd_parse_bind_line (struct rspamd_config *cfg,
+ struct rspamd_worker_conf *cf, const gchar *str);
/**
* Init default values
* @param cfg config file
*/
-void init_defaults (struct config_file *cfg);
+void rspamd_config_defaults (struct rspamd_config *cfg);
/**
* Free memory used by config structure
* @param cfg config file
*/
-void free_config (struct config_file *cfg);
+void rspamd_config_free (struct rspamd_config *cfg);
/**
* Gets module option with specified name
@@ -425,7 +424,8 @@ void free_config (struct config_file *cfg);
* @param opt_name name of option to get
* @return module value or NULL if option does not defined
*/
-const ucl_object_t* get_module_opt (struct config_file *cfg, const gchar *module_name,
+const ucl_object_t* rspamd_config_get_module_opt (struct rspamd_config *cfg,
+ const gchar *module_name,
const gchar *opt_name);
/**
@@ -433,82 +433,90 @@ const ucl_object_t* get_module_opt (struct config_file *cfg, const gchar *module
* @param limit string representation of limit (eg. 1M)
* @return numeric value of limit
*/
-guint64 parse_limit (const gchar *limit, guint len);
+guint64 rspamd_config_parse_limit (const gchar *limit, guint len);
/**
* Parse flag
* @param str string representation of flag (eg. 'on')
* @return numeric value of flag (0 or 1)
*/
-gchar parse_flag (const gchar *str);
+gchar rspamd_config_parse_flag (const gchar *str);
/**
* Do post load actions for config
* @param cfg config file
*/
-void post_load_config (struct config_file *cfg);
+void rspamd_config_post_load (struct rspamd_config *cfg);
/**
* Calculate checksum for config file
* @param cfg config file
*/
-gboolean get_config_checksum (struct config_file *cfg);
+gboolean rspamd_config_calculate_checksum (struct rspamd_config *cfg);
/**
* Replace all \" with a single " in given string
* @param line input string
*/
-void unescape_quotes (gchar *line);
+void rspamd_config_unescape_quotes (gchar *line);
/*
* Convert comma separated string to a list of strings
*/
-GList* parse_comma_list (rspamd_mempool_t *pool, const gchar *line);
+GList* rspamd_config_parse_comma_list (rspamd_mempool_t *pool,
+ const gchar *line);
/*
* Return a new classifier_config structure, setting default and non-conflicting attributes
*/
-struct classifier_config* check_classifier_conf (struct config_file *cfg, struct classifier_config *c);
+struct rspamd_classifier_config* rspamd_config_new_classifier (struct rspamd_config *cfg,
+ struct rspamd_classifier_config *c);
/*
* Return a new worker_conf structure, setting default and non-conflicting attributes
*/
-struct worker_conf* check_worker_conf (struct config_file *cfg, struct worker_conf *c);
+struct rspamd_worker_conf* rspamd_config_new_worker (struct rspamd_config *cfg,
+ struct rspamd_worker_conf *c);
/*
* Return a new metric structure, setting default and non-conflicting attributes
*/
-struct metric* check_metric_conf (struct config_file *cfg, struct metric *c);
+struct metric* rspamd_config_new_metric (struct rspamd_config *cfg,
+ struct metric *c);
/*
* Return a new statfile structure, setting default and non-conflicting attributes
*/
-struct statfile* check_statfile_conf (struct config_file *cfg, struct statfile *c);
+struct rspamd_statfile_config* rspamd_config_new_statfile (struct rspamd_config *cfg,
+ struct rspamd_statfile_config *c);
/*
* Read XML configuration file
*/
-gboolean read_rspamd_config (struct config_file *cfg,
+gboolean rspamd_config_read (struct rspamd_config *cfg,
const gchar *filename, const gchar *convert_to,
rspamd_rcl_section_fin_t logger_fin, gpointer logger_ud);
/*
* Register symbols of classifiers inside metrics
*/
-void insert_classifier_symbols (struct config_file *cfg);
+void rspamd_config_insert_classify_symbols (struct rspamd_config *cfg);
/*
* Check statfiles inside a classifier
*/
-gboolean check_classifier_statfiles (struct classifier_config *cf);
+gboolean rspamd_config_check_statfiles (struct rspamd_classifier_config *cf);
/*
* Find classifier config by name
*/
-struct classifier_config* find_classifier_conf (struct config_file *cfg, const gchar *name);
+struct rspamd_classifier_config* rspamd_config_find_classifier (
+ struct rspamd_config *cfg,
+ const gchar *name);
/*
* Parse input `ip_list` to radix tree `tree`. Now supports only IPv4 addresses.
*/
-gboolean rspamd_parse_ip_list (const gchar *ip_list, radix_tree_t **tree);
+gboolean rspamd_config_parse_ip_list (const gchar *ip_list,
+ radix_tree_t **tree);
#endif /* ifdef CFG_FILE_H */
/*
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 37b554dec..be9f63593 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -34,7 +34,7 @@
* Common section handlers
*/
static gboolean
-rspamd_rcl_logging_handler (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_logging_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
const ucl_object_t *val;
@@ -154,7 +154,7 @@ rspamd_rcl_logging_handler (struct config_file *cfg, const ucl_object_t *obj,
}
static gboolean
-rspamd_rcl_options_handler (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_options_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
const ucl_object_t *val;
@@ -185,7 +185,7 @@ rspamd_rcl_options_handler (struct config_file *cfg, const ucl_object_t *obj,
static gint
rspamd_symbols_group_find_func (gconstpointer a, gconstpointer b)
{
- const struct symbols_group *gr = a;
+ const struct rspamd_symbols_group *gr = a;
const gchar *uv = b;
return g_ascii_strcasecmp (gr->name, uv);
@@ -200,14 +200,14 @@ rspamd_symbols_group_find_func (gconstpointer a, gconstpointer b)
* @return
*/
static gboolean
-rspamd_rcl_insert_symbol (struct config_file *cfg, struct metric *metric,
+rspamd_rcl_insert_symbol (struct rspamd_config *cfg, struct metric *metric,
const ucl_object_t *obj, gboolean is_legacy, GError **err)
{
const gchar *group = "ungrouped", *description = NULL, *sym_name;
gdouble symbol_score, *score_ptr;
const ucl_object_t *val;
- struct symbols_group *sym_group;
- struct symbol_def *sym_def;
+ struct rspamd_symbols_group *sym_group;
+ struct rspamd_symbol_def *sym_def;
GList *metric_list, *group_list;
/*
@@ -254,7 +254,7 @@ rspamd_rcl_insert_symbol (struct config_file *cfg, struct metric *metric,
return FALSE;
}
- sym_def = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (struct symbol_def));
+ sym_def = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (struct rspamd_symbol_def));
score_ptr = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (gdouble));
*score_ptr = symbol_score;
@@ -280,7 +280,7 @@ rspamd_rcl_insert_symbol (struct config_file *cfg, struct metric *metric,
group_list = g_list_find_custom (cfg->symbols_groups, group, rspamd_symbols_group_find_func);
if (group_list == NULL) {
/* Create new group */
- sym_group = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (struct symbols_group));
+ sym_group = rspamd_mempool_alloc (cfg->cfg_pool, sizeof (struct rspamd_symbols_group));
sym_group->name = rspamd_mempool_strdup (cfg->cfg_pool, group);
sym_group->symbols = NULL;
cfg->symbols_groups = g_list_prepend (cfg->symbols_groups, sym_group);
@@ -295,7 +295,7 @@ rspamd_rcl_insert_symbol (struct config_file *cfg, struct metric *metric,
}
static gboolean
-rspamd_rcl_metric_handler (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_metric_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
const ucl_object_t *val, *cur;
@@ -314,7 +314,7 @@ rspamd_rcl_metric_handler (struct config_file *cfg, const ucl_object_t *obj,
metric = g_hash_table_lookup (cfg->metrics, metric_name);
if (metric == NULL) {
- metric = check_metric_conf (cfg, metric);
+ metric = rspamd_config_new_metric (cfg, metric);
metric->name = metric_name;
}
else {
@@ -430,14 +430,14 @@ rspamd_rcl_metric_handler (struct config_file *cfg, const ucl_object_t *obj,
}
static gboolean
-rspamd_rcl_worker_handler (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_worker_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
const ucl_object_t *val, *cur;
ucl_object_iter_t it = NULL;
const gchar *worker_type, *worker_bind;
GQuark qtype;
- struct worker_conf *wrk;
+ struct rspamd_worker_conf *wrk;
struct rspamd_worker_cfg_parser *wparser;
struct rspamd_worker_param_parser *whandler;
@@ -445,8 +445,8 @@ rspamd_rcl_worker_handler (struct config_file *cfg, const ucl_object_t *obj,
if (val != NULL && ucl_object_tostring_safe (val, &worker_type)) {
qtype = g_quark_try_string (worker_type);
if (qtype != 0) {
- wrk = check_worker_conf (cfg, NULL);
- wrk->worker = get_worker_by_type (qtype);
+ wrk = rspamd_config_new_worker (cfg, NULL);
+ wrk->worker = rspamd_get_worker_by_type (qtype);
if (wrk->worker == NULL) {
g_set_error (err, CFG_RCL_ERROR, EINVAL, "unknown worker type: %s", worker_type);
return FALSE;
@@ -475,7 +475,7 @@ rspamd_rcl_worker_handler (struct config_file *cfg, const ucl_object_t *obj,
if (!ucl_object_tostring_safe (cur, &worker_bind)) {
continue;
}
- if (!parse_bind_line (cfg, wrk, worker_bind)) {
+ if (!rspamd_parse_bind_line (cfg, wrk, worker_bind)) {
g_set_error (err, CFG_RCL_ERROR, EINVAL, "cannot parse bind line: %s", worker_bind);
return FALSE;
}
@@ -512,9 +512,9 @@ rspamd_rcl_worker_handler (struct config_file *cfg, const ucl_object_t *obj,
}
static void
-rspamd_rcl_set_lua_globals (struct config_file *cfg, lua_State *L)
+rspamd_rcl_set_lua_globals (struct rspamd_config *cfg, lua_State *L)
{
- struct config_file **pcfg;
+ struct rspamd_config **pcfg;
/* First check for global variable 'config' */
lua_getglobal (L, "config");
@@ -542,7 +542,7 @@ rspamd_rcl_set_lua_globals (struct config_file *cfg, lua_State *L)
lua_setglobal (L, "classifiers");
}
- pcfg = lua_newuserdata (L, sizeof (struct config_file *));
+ pcfg = lua_newuserdata (L, sizeof (struct rspamd_config *));
lua_setclass (L, "rspamd{config}", -1);
*pcfg = cfg;
lua_setglobal (L, "rspamd_config");
@@ -552,7 +552,7 @@ rspamd_rcl_set_lua_globals (struct config_file *cfg, lua_State *L)
}
static gboolean
-rspamd_rcl_lua_handler (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_lua_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
const gchar *lua_src = rspamd_mempool_strdup (cfg->cfg_pool, ucl_object_tostring (obj));
@@ -621,7 +621,7 @@ rspamd_rcl_lua_handler (struct config_file *cfg, const ucl_object_t *obj,
}
static gboolean
-rspamd_rcl_add_module_path (struct config_file *cfg, const gchar *path, GError **err)
+rspamd_rcl_add_module_path (struct rspamd_config *cfg, const gchar *path, GError **err)
{
struct stat st;
struct script_module *cur_mod;
@@ -668,7 +668,7 @@ rspamd_rcl_add_module_path (struct config_file *cfg, const gchar *path, GError *
}
static gboolean
-rspamd_rcl_modules_handler (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_modules_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
const ucl_object_t *val, *cur;
@@ -699,17 +699,17 @@ rspamd_rcl_modules_handler (struct config_file *cfg, const ucl_object_t *obj,
}
static gboolean
-rspamd_rcl_statfile_handler (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_statfile_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
- struct classifier_config *ccf = ud;
+ struct rspamd_classifier_config *ccf = ud;
const ucl_object_t *val;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
const gchar *data;
gdouble binlog_rotate;
GList *labels;
- st = check_statfile_conf (cfg, NULL);
+ st = rspamd_config_new_statfile (cfg, NULL);
val = ucl_object_find_key (obj, "binlog");
if (val != NULL && ucl_object_tostring_safe (val, &data)) {
@@ -732,7 +732,7 @@ rspamd_rcl_statfile_handler (struct config_file *cfg, const ucl_object_t *obj,
}
val = ucl_object_find_key (obj, "binlog_master");
if (val != NULL && ucl_object_tostring_safe (val, &data)) {
- if (!parse_host_port (cfg->cfg_pool, data, &st->binlog->master_addr, &st->binlog->master_port)) {
+ if (!rspamd_parse_host_port (cfg->cfg_pool, data, &st->binlog->master_addr, &st->binlog->master_port)) {
msg_err ("cannot parse master address: %s", data);
return FALSE;
}
@@ -789,13 +789,13 @@ rspamd_rcl_statfile_handler (struct config_file *cfg, const ucl_object_t *obj,
}
static gboolean
-rspamd_rcl_classifier_handler (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_classifier_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
const ucl_object_t *val, *cur;
ucl_object_iter_t it = NULL;
const gchar *key, *type;
- struct classifier_config *ccf, *found = NULL;
+ struct rspamd_classifier_config *ccf, *found = NULL;
gboolean res = TRUE;
struct rspamd_rcl_section *stat_section;
GList *cur_cl;
@@ -817,7 +817,7 @@ rspamd_rcl_classifier_handler (struct config_file *cfg, const ucl_object_t *obj,
}
if (found == NULL) {
- ccf = check_classifier_conf (cfg, NULL);
+ ccf = rspamd_config_new_classifier (cfg, NULL);
ccf->classifier = get_classifier (type);
}
else {
@@ -859,7 +859,7 @@ rspamd_rcl_classifier_handler (struct config_file *cfg, const ucl_object_t *obj,
}
static gboolean
-rspamd_rcl_composite_handler (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_composite_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
const ucl_object_t *val;
@@ -907,7 +907,7 @@ rspamd_rcl_composite_handler (struct config_file *cfg, const ucl_object_t *obj,
* for default handlers
*/
static gboolean
-rspamd_rcl_empty_handler (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_empty_handler (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
return rspamd_rcl_section_parse_defaults (section, cfg, obj, cfg, err);
@@ -978,60 +978,60 @@ rspamd_rcl_config_init (void)
FALSE, TRUE);
/* Default handlers */
rspamd_rcl_add_default_handler (sub, "log_buffer", rspamd_rcl_parse_struct_integer,
- G_STRUCT_OFFSET (struct config_file, log_buf_size), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, log_buf_size), 0);
rspamd_rcl_add_default_handler (sub, "log_urls", rspamd_rcl_parse_struct_boolean,
- G_STRUCT_OFFSET (struct config_file, log_urls), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, log_urls), 0);
rspamd_rcl_add_default_handler (sub, "debug_ip", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct config_file, debug_ip_map), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, debug_ip_map), 0);
rspamd_rcl_add_default_handler (sub, "debug_symbols", rspamd_rcl_parse_struct_string_list,
- G_STRUCT_OFFSET (struct config_file, debug_symbols), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, debug_symbols), 0);
rspamd_rcl_add_default_handler (sub, "log_color", rspamd_rcl_parse_struct_boolean,
- G_STRUCT_OFFSET (struct config_file, log_color), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, log_color), 0);
/**
* Options section
*/
sub = rspamd_rcl_add_section (&new, "options", rspamd_rcl_options_handler, UCL_OBJECT,
FALSE, TRUE);
rspamd_rcl_add_default_handler (sub, "cache_file", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct config_file, cache_filename), RSPAMD_CL_FLAG_STRING_PATH);
+ G_STRUCT_OFFSET (struct rspamd_config, cache_filename), RSPAMD_CL_FLAG_STRING_PATH);
rspamd_rcl_add_default_handler (sub, "dns_nameserver", rspamd_rcl_parse_struct_string_list,
- G_STRUCT_OFFSET (struct config_file, nameservers), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, nameservers), 0);
rspamd_rcl_add_default_handler (sub, "dns_timeout", rspamd_rcl_parse_struct_time,
- G_STRUCT_OFFSET (struct config_file, dns_timeout), RSPAMD_CL_FLAG_TIME_FLOAT);
+ G_STRUCT_OFFSET (struct rspamd_config, dns_timeout), RSPAMD_CL_FLAG_TIME_FLOAT);
rspamd_rcl_add_default_handler (sub, "dns_retransmits", rspamd_rcl_parse_struct_integer,
- G_STRUCT_OFFSET (struct config_file, dns_retransmits), RSPAMD_CL_FLAG_INT_32);
+ G_STRUCT_OFFSET (struct rspamd_config, dns_retransmits), RSPAMD_CL_FLAG_INT_32);
rspamd_rcl_add_default_handler (sub, "dns_sockets", rspamd_rcl_parse_struct_integer,
- G_STRUCT_OFFSET (struct config_file, dns_io_per_server), RSPAMD_CL_FLAG_INT_32);
+ G_STRUCT_OFFSET (struct rspamd_config, dns_io_per_server), RSPAMD_CL_FLAG_INT_32);
rspamd_rcl_add_default_handler (sub, "raw_mode", rspamd_rcl_parse_struct_boolean,
- G_STRUCT_OFFSET (struct config_file, raw_mode), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, raw_mode), 0);
rspamd_rcl_add_default_handler (sub, "one_shot", rspamd_rcl_parse_struct_boolean,
- G_STRUCT_OFFSET (struct config_file, one_shot_mode), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, one_shot_mode), 0);
rspamd_rcl_add_default_handler (sub, "check_attachements", rspamd_rcl_parse_struct_boolean,
- G_STRUCT_OFFSET (struct config_file, check_text_attachements), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, check_text_attachements), 0);
rspamd_rcl_add_default_handler (sub, "tempdir", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct config_file, temp_dir), RSPAMD_CL_FLAG_STRING_PATH);
+ G_STRUCT_OFFSET (struct rspamd_config, temp_dir), RSPAMD_CL_FLAG_STRING_PATH);
rspamd_rcl_add_default_handler (sub, "pidfile", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct config_file, pid_file), RSPAMD_CL_FLAG_STRING_PATH);
+ G_STRUCT_OFFSET (struct rspamd_config, pid_file), RSPAMD_CL_FLAG_STRING_PATH);
rspamd_rcl_add_default_handler (sub, "filters", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct config_file, filters_str), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, filters_str), 0);
rspamd_rcl_add_default_handler (sub, "sync_interval", rspamd_rcl_parse_struct_time,
- G_STRUCT_OFFSET (struct config_file, statfile_sync_interval), RSPAMD_CL_FLAG_TIME_INTEGER);
+ G_STRUCT_OFFSET (struct rspamd_config, statfile_sync_interval), RSPAMD_CL_FLAG_TIME_INTEGER);
rspamd_rcl_add_default_handler (sub, "sync_timeout", rspamd_rcl_parse_struct_time,
- G_STRUCT_OFFSET (struct config_file, statfile_sync_timeout), RSPAMD_CL_FLAG_TIME_INTEGER);
+ G_STRUCT_OFFSET (struct rspamd_config, statfile_sync_timeout), RSPAMD_CL_FLAG_TIME_INTEGER);
rspamd_rcl_add_default_handler (sub, "max_diff", rspamd_rcl_parse_struct_integer,
- G_STRUCT_OFFSET (struct config_file, max_diff), RSPAMD_CL_FLAG_INT_SIZE);
+ G_STRUCT_OFFSET (struct rspamd_config, max_diff), RSPAMD_CL_FLAG_INT_SIZE);
rspamd_rcl_add_default_handler (sub, "map_watch_interval", rspamd_rcl_parse_struct_time,
- G_STRUCT_OFFSET (struct config_file, map_timeout), RSPAMD_CL_FLAG_TIME_FLOAT);
+ G_STRUCT_OFFSET (struct rspamd_config, map_timeout), RSPAMD_CL_FLAG_TIME_FLOAT);
rspamd_rcl_add_default_handler (sub, "dynamic_conf", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct config_file, dynamic_conf), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, dynamic_conf), 0);
rspamd_rcl_add_default_handler (sub, "rrd", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct config_file, rrd_file), RSPAMD_CL_FLAG_STRING_PATH);
+ G_STRUCT_OFFSET (struct rspamd_config, rrd_file), RSPAMD_CL_FLAG_STRING_PATH);
rspamd_rcl_add_default_handler (sub, "history_file", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct config_file, history_file), RSPAMD_CL_FLAG_STRING_PATH);
+ G_STRUCT_OFFSET (struct rspamd_config, history_file), RSPAMD_CL_FLAG_STRING_PATH);
rspamd_rcl_add_default_handler (sub, "use_mlock", rspamd_rcl_parse_struct_boolean,
- G_STRUCT_OFFSET (struct config_file, mlock_statfile_pool), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, mlock_statfile_pool), 0);
rspamd_rcl_add_default_handler (sub, "strict_protocol_headers", rspamd_rcl_parse_struct_boolean,
- G_STRUCT_OFFSET (struct config_file, strict_protocol_headers), 0);
+ G_STRUCT_OFFSET (struct rspamd_config, strict_protocol_headers), 0);
/**
* Metric section
@@ -1045,11 +1045,11 @@ rspamd_rcl_config_init (void)
sub = rspamd_rcl_add_section (&new, "worker", rspamd_rcl_worker_handler, UCL_OBJECT,
FALSE, TRUE);
rspamd_rcl_add_default_handler (sub, "count", rspamd_rcl_parse_struct_integer,
- G_STRUCT_OFFSET (struct worker_conf, count), RSPAMD_CL_FLAG_INT_16);
+ G_STRUCT_OFFSET (struct rspamd_worker_conf, count), RSPAMD_CL_FLAG_INT_16);
rspamd_rcl_add_default_handler (sub, "max_files", rspamd_rcl_parse_struct_integer,
- G_STRUCT_OFFSET (struct worker_conf, rlimit_nofile), RSPAMD_CL_FLAG_INT_32);
+ G_STRUCT_OFFSET (struct rspamd_worker_conf, rlimit_nofile), RSPAMD_CL_FLAG_INT_32);
rspamd_rcl_add_default_handler (sub, "max_core", rspamd_rcl_parse_struct_integer,
- G_STRUCT_OFFSET (struct worker_conf, rlimit_maxcore), RSPAMD_CL_FLAG_INT_32);
+ G_STRUCT_OFFSET (struct rspamd_worker_conf, rlimit_maxcore), RSPAMD_CL_FLAG_INT_32);
/**
* Lua handler
@@ -1071,15 +1071,15 @@ rspamd_rcl_config_init (void)
ssub = rspamd_rcl_add_section (&sub->subsections, "statfile", rspamd_rcl_statfile_handler,
UCL_OBJECT, TRUE, TRUE);
rspamd_rcl_add_default_handler (ssub, "symbol", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct statfile, symbol), 0);
+ G_STRUCT_OFFSET (struct rspamd_statfile_config, symbol), 0);
rspamd_rcl_add_default_handler (ssub, "path", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct statfile, path), RSPAMD_CL_FLAG_STRING_PATH);
+ G_STRUCT_OFFSET (struct rspamd_statfile_config, path), RSPAMD_CL_FLAG_STRING_PATH);
rspamd_rcl_add_default_handler (ssub, "label", rspamd_rcl_parse_struct_string,
- G_STRUCT_OFFSET (struct statfile, label), 0);
+ G_STRUCT_OFFSET (struct rspamd_statfile_config, label), 0);
rspamd_rcl_add_default_handler (ssub, "size", rspamd_rcl_parse_struct_integer,
- G_STRUCT_OFFSET (struct statfile, size), RSPAMD_CL_FLAG_INT_SIZE);
+ G_STRUCT_OFFSET (struct rspamd_statfile_config, size), RSPAMD_CL_FLAG_INT_SIZE);
rspamd_rcl_add_default_handler (ssub, "spam", rspamd_rcl_parse_struct_boolean,
- G_STRUCT_OFFSET (struct statfile, is_spam), 0);
+ G_STRUCT_OFFSET (struct rspamd_statfile_config, is_spam), 0);
/**
* Composites handler
@@ -1126,7 +1126,7 @@ rspamd_rcl_config_get_section (struct rspamd_rcl_section *top,
gboolean
rspamd_read_rcl_config (struct rspamd_rcl_section *top,
- struct config_file *cfg, const ucl_object_t *obj, GError **err)
+ struct rspamd_config *cfg, const ucl_object_t *obj, GError **err)
{
const ucl_object_t *found, *cur_obj;
struct rspamd_rcl_section *cur, *tmp;
@@ -1170,7 +1170,7 @@ rspamd_read_rcl_config (struct rspamd_rcl_section *top,
}
gboolean rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section,
- struct config_file *cfg, const ucl_object_t *obj, gpointer ptr,
+ struct rspamd_config *cfg, const ucl_object_t *obj, gpointer ptr,
GError **err)
{
const ucl_object_t *found;
@@ -1195,7 +1195,7 @@ gboolean rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section,
}
gboolean
-rspamd_rcl_parse_struct_string (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_parse_struct_string (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
@@ -1228,7 +1228,7 @@ rspamd_rcl_parse_struct_string (struct config_file *cfg, const ucl_object_t *obj
}
gboolean
-rspamd_rcl_parse_struct_integer (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_parse_struct_integer (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
@@ -1286,7 +1286,7 @@ rspamd_rcl_parse_struct_integer (struct config_file *cfg, const ucl_object_t *ob
}
gboolean
-rspamd_rcl_parse_struct_double (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_parse_struct_double (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
@@ -1303,7 +1303,7 @@ rspamd_rcl_parse_struct_double (struct config_file *cfg, const ucl_object_t *obj
}
gboolean
-rspamd_rcl_parse_struct_time (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_parse_struct_time (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
@@ -1352,7 +1352,7 @@ rspamd_rcl_parse_struct_time (struct config_file *cfg, const ucl_object_t *obj,
}
gboolean
-rspamd_rcl_parse_struct_string_list (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_parse_struct_string_list (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
@@ -1400,7 +1400,7 @@ rspamd_rcl_parse_struct_string_list (struct config_file *cfg, const ucl_object_t
}
gboolean
-rspamd_rcl_parse_struct_boolean (struct config_file *cfg, const ucl_object_t *obj,
+rspamd_rcl_parse_struct_boolean (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_struct_parser *pd = ud;
@@ -1423,7 +1423,7 @@ rspamd_rcl_parse_struct_boolean (struct config_file *cfg, const ucl_object_t *ob
}
void
-rspamd_rcl_register_worker_option (struct config_file *cfg, gint type, const gchar *name,
+rspamd_rcl_register_worker_option (struct rspamd_config *cfg, gint type, const gchar *name,
rspamd_rcl_handler_t handler, gpointer target, gsize offset, gint flags)
{
struct rspamd_worker_param_parser *nhandler;
@@ -1454,7 +1454,7 @@ rspamd_rcl_register_worker_option (struct config_file *cfg, gint type, const gch
void
-rspamd_rcl_register_worker_parser (struct config_file *cfg, gint type,
+rspamd_rcl_register_worker_parser (struct rspamd_config *cfg, gint type,
gboolean (*func)(ucl_object_t *, gpointer), gpointer ud)
{
struct rspamd_worker_cfg_parser *nparser;
diff --git a/src/libserver/cfg_rcl.h b/src/libserver/cfg_rcl.h
index 99839d1ea..6db0b0d81 100644
--- a/src/libserver/cfg_rcl.h
+++ b/src/libserver/cfg_rcl.h
@@ -36,7 +36,7 @@ cfg_rcl_error_quark (void)
}
struct rspamd_rcl_section;
-struct config_file;
+struct rspamd_config;
struct rspamd_rcl_struct_parser {
gpointer user_struct;
@@ -63,7 +63,7 @@ struct rspamd_rcl_struct_parser {
* @param err error object
* @return TRUE if a section has been parsed
*/
-typedef gboolean (*rspamd_rcl_handler_t) (struct config_file *cfg, const ucl_object_t *obj,
+typedef gboolean (*rspamd_rcl_handler_t) (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
@@ -71,7 +71,7 @@ typedef gboolean (*rspamd_rcl_handler_t) (struct config_file *cfg, const ucl_obj
* @param cfg configuration
* @param ud user data
*/
-typedef void (*rspamd_rcl_section_fin_t)(struct config_file *cfg, gpointer ud);
+typedef void (*rspamd_rcl_section_fin_t)(struct rspamd_config *cfg, gpointer ud);
struct rspamd_rcl_default_handler_data {
struct rspamd_rcl_struct_parser pd;
@@ -116,7 +116,7 @@ struct rspamd_rcl_section *rspamd_rcl_config_get_section (struct rspamd_rcl_sect
* @return TRUE if an object can be parsed
*/
gboolean rspamd_read_rcl_config (struct rspamd_rcl_section *top,
- struct config_file *cfg, const ucl_object_t *obj, GError **err);
+ struct rspamd_config *cfg, const ucl_object_t *obj, GError **err);
/**
@@ -129,7 +129,7 @@ gboolean rspamd_read_rcl_config (struct rspamd_rcl_section *top,
* @return TRUE if the object has been parsed
*/
gboolean rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section,
- struct config_file *cfg, const ucl_object_t *obj, gpointer ptr,
+ struct rspamd_config *cfg, const ucl_object_t *obj, gpointer ptr,
GError **err);
/**
* Here is a section of common handlers that accepts rcl_struct_parser
@@ -146,7 +146,7 @@ gboolean rspamd_rcl_section_parse_defaults (struct rspamd_rcl_section *section,
* @param err error pointer
* @return TRUE if a string value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_string (struct config_file *cfg, const ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_string (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
@@ -158,7 +158,7 @@ gboolean rspamd_rcl_parse_struct_string (struct config_file *cfg, const ucl_obje
* @param err error pointer
* @return TRUE if a value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_integer (struct config_file *cfg, const ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_integer (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
@@ -171,7 +171,7 @@ gboolean rspamd_rcl_parse_struct_integer (struct config_file *cfg, const ucl_obj
* @param err error pointer
* @return TRUE if a value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_double (struct config_file *cfg, const ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_double (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
@@ -183,7 +183,7 @@ gboolean rspamd_rcl_parse_struct_double (struct config_file *cfg, const ucl_obje
* @param err error pointer
* @return TRUE if a value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_time (struct config_file *cfg, const ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_time (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
@@ -195,7 +195,7 @@ gboolean rspamd_rcl_parse_struct_time (struct config_file *cfg, const ucl_object
* @param err error pointer
* @return TRUE if a value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_string_list (struct config_file *cfg, const ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_string_list (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
@@ -207,7 +207,7 @@ gboolean rspamd_rcl_parse_struct_string_list (struct config_file *cfg, const ucl
* @param err error pointer
* @return TRUE if a value has been successfully parsed
*/
-gboolean rspamd_rcl_parse_struct_boolean (struct config_file *cfg, const ucl_object_t *obj,
+gboolean rspamd_rcl_parse_struct_boolean (struct rspamd_config *cfg, const ucl_object_t *obj,
gpointer ud, struct rspamd_rcl_section *section, GError **err);
/**
@@ -223,7 +223,7 @@ gboolean rspamd_rcl_parse_struct_boolean (struct config_file *cfg, const ucl_obj
* @param target opaque target structure
* @param offset offset inside a structure
*/
-void rspamd_rcl_register_worker_option (struct config_file *cfg, gint type, const gchar *name,
+void rspamd_rcl_register_worker_option (struct rspamd_config *cfg, gint type, const gchar *name,
rspamd_rcl_handler_t handler, gpointer target, gsize offset, gint flags);
/**
@@ -233,6 +233,6 @@ void rspamd_rcl_register_worker_option (struct config_file *cfg, gint type, cons
* @param func handler function
* @param ud userdata for handler function
*/
-void rspamd_rcl_register_worker_parser (struct config_file *cfg, gint type,
+void rspamd_rcl_register_worker_parser (struct rspamd_config *cfg, gint type,
gboolean (*func)(ucl_object_t *, gpointer), gpointer ud);
#endif /* CFG_RCL_H_ */
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 920de94e4..120128f5e 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -42,7 +42,7 @@
#define DEFAULT_MAP_TIMEOUT 10
struct rspamd_ucl_map_cbdata {
- struct config_file *cfg;
+ struct rspamd_config *cfg;
GString *buf;
};
static gchar* rspamd_ucl_read_cb (rspamd_mempool_t * pool, gchar * chunk, gint len, struct map_cb_data *data);
@@ -162,7 +162,7 @@ err:
}
gboolean
-parse_host_port_priority (rspamd_mempool_t *pool, const gchar *str, gchar **addr, guint16 *port, guint *priority)
+rspamd_parse_host_port_priority (rspamd_mempool_t *pool, const gchar *str, gchar **addr, guint16 *port, guint *priority)
{
gchar **tokens;
gboolean ret;
@@ -180,19 +180,19 @@ parse_host_port_priority (rspamd_mempool_t *pool, const gchar *str, gchar **addr
}
gboolean
-parse_host_port (rspamd_mempool_t *pool, const gchar *str, gchar **addr, guint16 *port)
+rspamd_parse_host_port (rspamd_mempool_t *pool, const gchar *str, gchar **addr, guint16 *port)
{
- return parse_host_port_priority (pool, str, addr, port, NULL);
+ return rspamd_parse_host_port_priority (pool, str, addr, port, NULL);
}
gboolean
-parse_host_priority (rspamd_mempool_t *pool, const gchar *str, gchar **addr, guint *priority)
+rspamd_parse_host_priority (rspamd_mempool_t *pool, const gchar *str, gchar **addr, guint *priority)
{
- return parse_host_port_priority (pool, str, addr, NULL, priority);
+ return rspamd_parse_host_port_priority (pool, str, addr, NULL, priority);
}
gboolean
-parse_bind_line (struct config_file *cfg, struct worker_conf *cf, const gchar *str)
+rspamd_parse_bind_line (struct rspamd_config *cfg, struct rspamd_worker_conf *cf, const gchar *str)
{
struct rspamd_worker_bind_conf *cnf;
gchar **tokens, *tmp, *err;
@@ -259,7 +259,7 @@ parse_bind_line (struct config_file *cfg, struct worker_conf *cf, const gchar *s
}
void
-init_defaults (struct config_file *cfg)
+rspamd_config_defaults (struct rspamd_config *cfg)
{
cfg->memcached_error_time = DEFAULT_UPSTREAM_ERROR_TIME;
@@ -298,10 +298,10 @@ init_defaults (struct config_file *cfg)
}
void
-free_config (struct config_file *cfg)
+rspamd_config_free (struct rspamd_config *cfg)
{
GList *cur;
- struct symbols_group *gr;
+ struct rspamd_symbols_group *gr;
remove_all_maps (cfg);
ucl_obj_unref (cfg->rcl_obj);
@@ -337,7 +337,7 @@ free_config (struct config_file *cfg)
}
const ucl_object_t *
-get_module_opt (struct config_file *cfg, const gchar *module_name, const gchar *opt_name)
+rspamd_config_get_module_opt (struct rspamd_config *cfg, const gchar *module_name, const gchar *opt_name)
{
const ucl_object_t *res = NULL, *sec;
@@ -350,7 +350,7 @@ get_module_opt (struct config_file *cfg, const gchar *module_name, const gchar *
}
guint64
-parse_limit (const gchar *limit, guint len)
+rspamd_config_parse_limit (const gchar *limit, guint len)
{
guint64 result = 0;
const gchar *err_str;
@@ -385,7 +385,7 @@ parse_limit (const gchar *limit, guint len)
}
gchar
-parse_flag (const gchar *str)
+rspamd_config_parse_flag (const gchar *str)
{
guint len;
gchar c;
@@ -438,7 +438,7 @@ parse_flag (const gchar *str)
}
gboolean
-get_config_checksum (struct config_file *cfg)
+rspamd_config_calculate_checksum (struct rspamd_config *cfg)
{
gint fd;
void *map;
@@ -472,7 +472,7 @@ get_config_checksum (struct config_file *cfg)
* Perform post load actions
*/
void
-post_load_config (struct config_file *cfg)
+rspamd_config_post_load (struct rspamd_config *cfg)
{
#ifdef HAVE_CLOCK_GETTIME
struct timespec ts;
@@ -501,7 +501,7 @@ post_load_config (struct config_file *cfg)
#endif
if ((def_metric = g_hash_table_lookup (cfg->metrics, DEFAULT_METRIC)) == NULL) {
- def_metric = check_metric_conf (cfg, NULL);
+ def_metric = rspamd_config_new_metric (cfg, NULL);
def_metric->name = DEFAULT_METRIC;
def_metric->actions[METRIC_ACTION_REJECT].score = DEFAULT_SCORE;
cfg->metrics_list = g_list_prepend (cfg->metrics_list, def_metric);
@@ -552,7 +552,7 @@ parse_warn (const gchar *fmt, ...)
#endif
void
-unescape_quotes (gchar *line)
+rspamd_config_unescape_quotes (gchar *line)
{
gchar *c = line, *t;
@@ -569,7 +569,7 @@ unescape_quotes (gchar *line)
}
GList *
-parse_comma_list (rspamd_mempool_t * pool, const gchar *line)
+rspamd_config_parse_comma_list (rspamd_mempool_t * pool, const gchar *line)
{
GList *res = NULL;
const gchar *c, *p;
@@ -597,11 +597,11 @@ parse_comma_list (rspamd_mempool_t * pool, const gchar *line)
return res;
}
-struct classifier_config *
-check_classifier_conf (struct config_file *cfg, struct classifier_config *c)
+struct rspamd_classifier_config *
+rspamd_config_new_classifier (struct rspamd_config *cfg, struct rspamd_classifier_config *c)
{
if (c == NULL) {
- c = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct classifier_config));
+ c = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_classifier_config));
}
if (c->opts == NULL) {
c->opts = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
@@ -615,18 +615,18 @@ check_classifier_conf (struct config_file *cfg, struct classifier_config *c)
return c;
}
-struct statfile*
-check_statfile_conf (struct config_file *cfg, struct statfile *c)
+struct rspamd_statfile_config*
+rspamd_config_new_statfile (struct rspamd_config *cfg, struct rspamd_statfile_config *c)
{
if (c == NULL) {
- c = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct statfile));
+ c = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_statfile_config));
}
return c;
}
struct metric *
-check_metric_conf (struct config_file *cfg, struct metric *c)
+rspamd_config_new_metric (struct rspamd_config *cfg, struct metric *c)
{
int i;
if (c == NULL) {
@@ -644,11 +644,11 @@ check_metric_conf (struct config_file *cfg, struct metric *c)
return c;
}
-struct worker_conf *
-check_worker_conf (struct config_file *cfg, struct worker_conf *c)
+struct rspamd_worker_conf *
+rspamd_config_new_worker (struct rspamd_config *cfg, struct rspamd_worker_conf *c)
{
if (c == NULL) {
- c = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct worker_conf));
+ c = rspamd_mempool_alloc0 (cfg->cfg_pool, sizeof (struct rspamd_worker_conf));
c->params = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
c->active_workers = g_queue_new ();
rspamd_mempool_add_destructor (cfg->cfg_pool, (rspamd_mempool_destruct_t)g_hash_table_destroy, c->params);
@@ -669,7 +669,7 @@ check_worker_conf (struct config_file *cfg, struct worker_conf *c)
static bool
rspamd_include_map_handler (const guchar *data, gsize len, void* ud)
{
- struct config_file *cfg = (struct config_file *)ud;
+ struct rspamd_config *cfg = (struct rspamd_config *)ud;
struct rspamd_ucl_map_cbdata *cbdata, **pcbdata;
gchar *map_line;
@@ -719,13 +719,13 @@ rspamd_ucl_add_conf_variables (struct ucl_parser *parser)
}
static void
-rspamd_ucl_add_conf_macros (struct ucl_parser *parser, struct config_file *cfg)
+rspamd_ucl_add_conf_macros (struct ucl_parser *parser, struct rspamd_config *cfg)
{
ucl_parser_register_macro (parser, "include_map", rspamd_include_map_handler, cfg);
}
gboolean
-read_rspamd_config (struct config_file *cfg, const gchar *filename,
+rspamd_config_read (struct rspamd_config *cfg, const gchar *filename,
const gchar *convert_to, rspamd_rcl_section_fin_t logger_fin,
gpointer logger_ud)
{
@@ -792,22 +792,22 @@ read_rspamd_config (struct config_file *cfg, const gchar *filename,
static void
symbols_classifiers_callback (gpointer key, gpointer value, gpointer ud)
{
- struct config_file *cfg = ud;
+ struct rspamd_config *cfg = ud;
register_virtual_symbol (&cfg->cache, key, 1.0);
}
void
-insert_classifier_symbols (struct config_file *cfg)
+rspamd_config_insert_classify_symbols (struct rspamd_config *cfg)
{
g_hash_table_foreach (cfg->classifiers_symbols, symbols_classifiers_callback, cfg);
}
-struct classifier_config*
-find_classifier_conf (struct config_file *cfg, const gchar *name)
+struct rspamd_classifier_config*
+rspamd_config_find_classifier (struct rspamd_config *cfg, const gchar *name)
{
GList *cur;
- struct classifier_config *cf;
+ struct rspamd_classifier_config *cf;
if (name == NULL) {
return NULL;
@@ -828,9 +828,9 @@ find_classifier_conf (struct config_file *cfg, const gchar *name)
}
gboolean
-check_classifier_statfiles (struct classifier_config *cf)
+rspamd_config_check_statfiles (struct rspamd_classifier_config *cf)
{
- struct statfile *st;
+ struct rspamd_statfile_config *st;
gboolean has_other = FALSE, res = FALSE, cur_class;
GList *cur;
@@ -943,7 +943,7 @@ rspamd_ucl_fin_cb (rspamd_mempool_t * pool, struct map_cb_data *data)
}
gboolean
-rspamd_parse_ip_list (const gchar *ip_list, radix_tree_t **tree)
+rspamd_config_parse_ip_list (const gchar *ip_list, radix_tree_t **tree)
{
gchar **strvec, **cur;
struct in_addr ina;
diff --git a/src/libserver/dns.c b/src/libserver/dns.c
index e20cca9df..8d18ffc06 100644
--- a/src/libserver/dns.c
+++ b/src/libserver/dns.c
@@ -94,7 +94,7 @@ make_dns_request (struct rspamd_dns_resolver *resolver,
struct rspamd_dns_resolver *
-dns_resolver_init (rspamd_logger_t *logger, struct event_base *ev_base, struct config_file *cfg)
+dns_resolver_init (rspamd_logger_t *logger, struct event_base *ev_base, struct rspamd_config *cfg)
{
GList *cur;
struct rspamd_dns_resolver *new;
diff --git a/src/libserver/dns.h b/src/libserver/dns.h
index 26ae71387..7b3bbd208 100644
--- a/src/libserver/dns.h
+++ b/src/libserver/dns.h
@@ -40,7 +40,7 @@ struct rspamd_dns_resolver;
* Init DNS resolver, params are obtained from a config file or system file /etc/resolv.conf
*/
struct rspamd_dns_resolver *dns_resolver_init (rspamd_logger_t *logger,
- struct event_base *ev_base, struct config_file *cfg);
+ struct event_base *ev_base, struct rspamd_config *cfg);
/**
* Make a DNS request
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c
index 7f5e8530d..d0dabef67 100644
--- a/src/libserver/dynamic_cfg.c
+++ b/src/libserver/dynamic_cfg.c
@@ -48,7 +48,7 @@ struct config_json_buf {
gchar *buf;
gchar *pos;
size_t buflen;
- struct config_file *cfg;
+ struct rspamd_config *cfg;
GList *config_metrics;
};
@@ -89,7 +89,7 @@ dynamic_cfg_free (GList *conf_metrics)
* @param cfg
*/
static void
-apply_dynamic_conf (GList *conf_metrics, struct config_file *cfg)
+apply_dynamic_conf (GList *conf_metrics, struct rspamd_config *cfg)
{
GList *cur, *cur_elt;
struct dynamic_cfg_metric *metric;
@@ -312,7 +312,7 @@ json_config_fin_cb (rspamd_mempool_t * pool, struct map_cb_data *data)
* @param cfg config file
*/
void
-init_dynamic_config (struct config_file *cfg)
+init_dynamic_config (struct rspamd_config *cfg)
{
struct config_json_buf *jb, **pjb;
@@ -412,7 +412,7 @@ dump_dynamic_list (gint fd, GList *rules)
* @return
*/
gboolean
-dump_dynamic_config (struct config_file *cfg)
+dump_dynamic_config (struct rspamd_config *cfg)
{
struct stat st;
gchar *dir, pathbuf[PATH_MAX];
@@ -490,7 +490,7 @@ dump_dynamic_config (struct config_file *cfg)
* @return
*/
gboolean
-add_dynamic_symbol (struct config_file *cfg, const gchar *metric_name, const gchar *symbol, gdouble value)
+add_dynamic_symbol (struct rspamd_config *cfg, const gchar *metric_name, const gchar *symbol, gdouble value)
{
GList *cur;
struct dynamic_cfg_metric *metric = NULL;
@@ -560,7 +560,7 @@ add_dynamic_symbol (struct config_file *cfg, const gchar *metric_name, const gch
* @return
*/
gboolean
-add_dynamic_action (struct config_file *cfg, const gchar *metric_name, guint action, gdouble value)
+add_dynamic_action (struct rspamd_config *cfg, const gchar *metric_name, guint action, gdouble value)
{
GList *cur;
struct dynamic_cfg_metric *metric = NULL;
diff --git a/src/libserver/dynamic_cfg.h b/src/libserver/dynamic_cfg.h
index b65d7aa9a..a8cb02ae5 100644
--- a/src/libserver/dynamic_cfg.h
+++ b/src/libserver/dynamic_cfg.h
@@ -32,14 +32,14 @@
* Init dynamic configuration using map logic and specific configuration
* @param cfg config file
*/
-void init_dynamic_config (struct config_file *cfg);
+void init_dynamic_config (struct rspamd_config *cfg);
/**
* Dump dynamic configuration to the disk
* @param cfg
* @return
*/
-gboolean dump_dynamic_config (struct config_file *cfg);
+gboolean dump_dynamic_config (struct rspamd_config *cfg);
/**
* Add symbol for specified metric
@@ -49,7 +49,7 @@ gboolean dump_dynamic_config (struct config_file *cfg);
* @param value value of symbol
* @return
*/
-gboolean add_dynamic_symbol (struct config_file *cfg, const gchar *metric, const gchar *symbol, gdouble value);
+gboolean add_dynamic_symbol (struct rspamd_config *cfg, const gchar *metric, const gchar *symbol, gdouble value);
/**
@@ -60,7 +60,7 @@ gboolean add_dynamic_symbol (struct config_file *cfg, const gchar *metric, const
* @param value value of symbol
* @return
*/
-gboolean add_dynamic_action (struct config_file *cfg, const gchar *metric, guint action, gdouble value);
+gboolean add_dynamic_action (struct rspamd_config *cfg, const gchar *metric, guint action, gdouble value);
#endif /* DYNAMIC_CFG_H_ */
diff --git a/src/libserver/settings.c b/src/libserver/settings.c
index c3292c8ab..ca6a9c773 100644
--- a/src/libserver/settings.c
+++ b/src/libserver/settings.c
@@ -353,7 +353,7 @@ json_fin_cb (rspamd_mempool_t * pool, struct map_cb_data *data)
}
gboolean
-read_settings (const gchar *path, const gchar *description, struct config_file *cfg, GHashTable * table)
+read_settings (const gchar *path, const gchar *description, struct rspamd_config *cfg, GHashTable * table)
{
struct json_buf *jb = g_malloc (sizeof (struct json_buf)), **pjb;
@@ -372,7 +372,7 @@ read_settings (const gchar *path, const gchar *description, struct config_file *
}
void
-init_settings (struct config_file *cfg)
+init_settings (struct rspamd_config *cfg)
{
cfg->domain_settings = g_hash_table_new_full (rspamd_strcase_hash, rspamd_strcase_equal,
g_free, (GDestroyNotify)settings_unref);
diff --git a/src/libserver/settings.h b/src/libserver/settings.h
index 361700094..6bdba9f4a 100644
--- a/src/libserver/settings.h
+++ b/src/libserver/settings.h
@@ -20,12 +20,12 @@ struct rspamd_settings {
/*
* Read settings from specified path
*/
-gboolean read_settings (const gchar *path, const gchar *description, struct config_file *cfg, GHashTable *table);
+gboolean read_settings (const gchar *path, const gchar *description, struct rspamd_config *cfg, GHashTable *table);
/*
* Init configuration structures for settings
*/
-void init_settings (struct config_file *cfg);
+void init_settings (struct rspamd_config *cfg);
/*
* Check scores settings
diff --git a/src/libserver/statfile.c b/src/libserver/statfile.c
index 4c1cc13fb..a993fd116 100644
--- a/src/libserver/statfile.c
+++ b/src/libserver/statfile.c
@@ -862,8 +862,8 @@ statfile_pool_plan_invalidate (statfile_pool_t *pool, time_t seconds, time_t jit
stat_file_t *
-get_statfile_by_symbol (statfile_pool_t *pool, struct classifier_config *ccf,
- const gchar *symbol, struct statfile **st, gboolean try_create)
+get_statfile_by_symbol (statfile_pool_t *pool, struct rspamd_classifier_config *ccf,
+ const gchar *symbol, struct rspamd_statfile_config **st, gboolean try_create)
{
stat_file_t *res = NULL;
GList *cur;
diff --git a/src/libserver/statfile.h b/src/libserver/statfile.h
index 5786c4927..3ad5f1321 100644
--- a/src/libserver/statfile.h
+++ b/src/libserver/statfile.h
@@ -96,8 +96,8 @@ typedef struct statfile_pool_s {
} statfile_pool_t;
/* Forwarded declarations */
-struct classifier_config;
-struct statfile;
+struct rspamd_classifier_config;
+struct rspamd_statfile_config;
/**
* Create new statfile pool
@@ -278,7 +278,7 @@ void statfile_pool_plan_invalidate (statfile_pool_t *pool, time_t seconds, time_
* @param st statfile to get
* @param try_create whether we need to create statfile if it is absent
*/
-stat_file_t* get_statfile_by_symbol (statfile_pool_t *pool, struct classifier_config *ccf,
- const gchar *symbol, struct statfile **st, gboolean try_create);
+stat_file_t* get_statfile_by_symbol (statfile_pool_t *pool, struct rspamd_classifier_config *ccf,
+ const gchar *symbol, struct rspamd_statfile_config **st, gboolean try_create);
#endif
diff --git a/src/libserver/statfile_sync.c b/src/libserver/statfile_sync.c
index 6b545af17..1121658fa 100644
--- a/src/libserver/statfile_sync.c
+++ b/src/libserver/statfile_sync.c
@@ -40,7 +40,7 @@ enum rspamd_sync_state {
/* Context of sync process */
struct rspamd_sync_ctx {
- struct statfile *st;
+ struct rspamd_statfile_config *st;
stat_file_t *real_statfile;
statfile_pool_t *pool;
rspamd_io_dispatcher_t *dispatcher;
@@ -280,7 +280,7 @@ sync_timer_callback (gint fd, short what, void *ud)
}
static gboolean
-add_statfile_watch (statfile_pool_t *pool, struct statfile *st, struct config_file *cfg, struct event_base *ev_base)
+add_statfile_watch (statfile_pool_t *pool, struct rspamd_statfile_config *st, struct rspamd_config *cfg, struct event_base *ev_base)
{
struct rspamd_sync_ctx *ctx;
guint32 jittered_interval;
@@ -320,11 +320,11 @@ add_statfile_watch (statfile_pool_t *pool, struct statfile *st, struct config_fi
}
gboolean
-start_statfile_sync (statfile_pool_t *pool, struct config_file *cfg, struct event_base *ev_base)
+start_statfile_sync (statfile_pool_t *pool, struct rspamd_config *cfg, struct event_base *ev_base)
{
GList *cur, *l;
- struct classifier_config *cl;
- struct statfile *st;
+ struct rspamd_classifier_config *cl;
+ struct rspamd_statfile_config *st;
/*
* First of all walk through all classifiers and find those statfiles
diff --git a/src/libserver/statfile_sync.h b/src/libserver/statfile_sync.h
index b3abb8b91..bcaeb3bb5 100644
--- a/src/libserver/statfile_sync.h
+++ b/src/libserver/statfile_sync.h
@@ -9,6 +9,6 @@
/*
* Start synchronization of statfiles. Must be called after event_init as it adds events
*/
-gboolean start_statfile_sync (statfile_pool_t *pool, struct config_file *cfg, struct event_base *ev_base);
+gboolean start_statfile_sync (statfile_pool_t *pool, struct rspamd_config *cfg, struct event_base *ev_base);
#endif
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index dfca57c66..b0ce7d872 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -332,7 +332,7 @@ register_symbol_common (struct symbols_cache **cache, const gchar *name, double
pcache->used_items++;
g_hash_table_insert (pcache->items_by_symbol, item->s->symbol, item);
msg_debug ("used items: %d, added symbol: %s", (*cache)->used_items, name);
- set_counter (item->s->symbol, 0);
+ rspamd_set_counter (item->s->symbol, 0);
*target = g_list_prepend (*target, item);
}
@@ -401,7 +401,7 @@ register_dynamic_symbol (rspamd_mempool_t *dynamic_pool, struct symbols_cache **
pcache->used_items++;
msg_debug ("used items: %d, added symbol: %s", (*cache)->used_items, name);
- set_counter (item->s->symbol, 0);
+ rspamd_set_counter (item->s->symbol, 0);
g_hash_table_insert (pcache->items_by_symbol, item->s->symbol, item);
@@ -521,7 +521,7 @@ free_cache (gpointer arg)
}
gboolean
-init_symbols_cache (rspamd_mempool_t * pool, struct symbols_cache *cache, struct config_file *cfg,
+init_symbols_cache (rspamd_mempool_t * pool, struct symbols_cache *cache, struct rspamd_config *cfg,
const gchar *filename, gboolean ignore_checksum)
{
struct stat st;
@@ -691,7 +691,7 @@ check_negative_dynamic_item (struct rspamd_task *task, struct symbols_cache *cac
}
static gboolean
-check_debug_symbol (struct config_file *cfg, const gchar *symbol)
+check_debug_symbol (struct rspamd_config *cfg, const gchar *symbol)
{
GList *cur;
@@ -736,7 +736,7 @@ rspamd_symbols_cache_metric_cb (gpointer k, gpointer v, gpointer ud)
}
gboolean
-validate_cache (struct symbols_cache *cache, struct config_file *cfg, gboolean strict)
+validate_cache (struct symbols_cache *cache, struct rspamd_config *cfg, gboolean strict)
{
struct cache_item *item;
GList *cur, *p, *metric_symbols;
@@ -1045,7 +1045,7 @@ call_symbol_callback (struct rspamd_task * task, struct symbols_cache * cache, g
#else
diff = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
#endif
- item->s->avg_time = set_counter (item->s->symbol, diff);
+ item->s->avg_time = rspamd_set_counter (item->s->symbol, diff);
}
s->saved_item = item;
diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h
index bb2100fc1..b3835824d 100644
--- a/src/libserver/symbols_cache.h
+++ b/src/libserver/symbols_cache.h
@@ -7,7 +7,7 @@
#define MAX_SYMBOL 128
struct rspamd_task;
-struct config_file;
+struct rspamd_config;
typedef void (*symbol_func_t)(struct rspamd_task *task, gpointer user_data);
@@ -71,13 +71,13 @@ struct symbols_cache {
guint uses;
gpointer map;
rspamd_mempool_rwlock_t *lock;
- struct config_file *cfg;
+ struct rspamd_config *cfg;
};
/**
* Load symbols cache from file, must be called _after_ init_symbols_cache
*/
-gboolean init_symbols_cache (rspamd_mempool_t *pool, struct symbols_cache *cache, struct config_file *cfg,
+gboolean init_symbols_cache (rspamd_mempool_t *pool, struct symbols_cache *cache, struct rspamd_config *cfg,
const gchar *filename, gboolean ignore_checksum);
/**
@@ -144,7 +144,7 @@ void remove_dynamic_rules (struct symbols_cache *cache);
* @param cfg configuration
* @param strict do strict checks - symbols MUST be described in metrics
*/
-gboolean validate_cache (struct symbols_cache *cache, struct config_file *cfg, gboolean strict);
+gboolean validate_cache (struct symbols_cache *cache, struct rspamd_config *cfg, gboolean strict);
#endif
diff --git a/src/libserver/task.h b/src/libserver/task.h
index 0891dc6e2..1d2b299ec 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -112,7 +112,7 @@ struct rspamd_task {
* pointer */
GList *messages; /**< list of messages that would be reported */
GHashTable *re_cache; /**< cache for matched or not matched regexps */
- struct config_file *cfg; /**< pointer to config object */
+ struct rspamd_config *cfg; /**< pointer to config object */
gchar *last_error; /**< last error */
gint error_code; /**< code of last error */
rspamd_mempool_t *task_pool; /**< memory pool for task */
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 5507cdb7c..e8c97f20a 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -34,7 +34,7 @@ extern struct rspamd_main *rspamd_main;
* @return worker's control structure or NULL
*/
worker_t*
-get_worker_by_type (GQuark type)
+rspamd_get_worker_by_type (GQuark type)
{
worker_t **cur;
@@ -50,7 +50,7 @@ get_worker_by_type (GQuark type)
}
double
-set_counter (const gchar *name, guint32 value)
+rspamd_set_counter (const gchar *name, guint32 value)
{
struct counter_data *cd;
double alpha;
@@ -122,7 +122,7 @@ worker_sigusr2_handler (gint fd, short what, void *arg)
tv.tv_usec = 0;
event_del (&worker->sig_ev_usr1);
event_del (&worker->sig_ev_usr2);
- worker_stop_accept (worker);
+ rspamd_worker_stop_accept (worker);
msg_info ("worker's shutdown is pending in %d sec", SOFT_SHUTDOWN_TIME);
event_loopexit (&tv);
}
@@ -143,7 +143,7 @@ worker_sigusr1_handler (gint fd, short what, void *arg)
}
struct event_base *
-prepare_worker (struct rspamd_worker *worker, const char *name,
+rspamd_prepare_worker (struct rspamd_worker *worker, const char *name,
void (*accept_handler)(int, short, void *))
{
struct event_base *ev_base;
@@ -197,7 +197,7 @@ prepare_worker (struct rspamd_worker *worker, const char *name,
}
void
-worker_stop_accept (struct rspamd_worker *worker)
+rspamd_worker_stop_accept (struct rspamd_worker *worker)
{
GList *cur;
struct event *event;
diff --git a/src/libserver/worker_util.h b/src/libserver/worker_util.h
index d88b93a8a..67ad9e83c 100644
--- a/src/libserver/worker_util.h
+++ b/src/libserver/worker_util.h
@@ -31,12 +31,12 @@
* @param type
* @return worker's control structure or NULL
*/
-worker_t* get_worker_by_type (GQuark type);
+worker_t* rspamd_get_worker_by_type (GQuark type);
/**
* Set counter for a symbol
*/
-double set_counter (const gchar *name, guint32 value);
+double rspamd_set_counter (const gchar *name, guint32 value);
#ifndef HAVE_SA_SIGINFO
typedef void (*rspamd_sig_handler_t) (gint);
@@ -55,13 +55,13 @@ struct rspamd_worker;
* @return event base suitable for a worker
*/
struct event_base *
-prepare_worker (struct rspamd_worker *worker, const char *name,
+rspamd_prepare_worker (struct rspamd_worker *worker, const char *name,
void (*accept_handler)(int, short, void *));
/**
* Stop accepting new connections for a worker
* @param worker
*/
-void worker_stop_accept (struct rspamd_worker *worker);
+void rspamd_worker_stop_accept (struct rspamd_worker *worker);
#endif /* WORKER_UTIL_H_ */
diff --git a/src/libutil/logger.c b/src/libutil/logger.c
index 01814d24d..47e308ecd 100644
--- a/src/libutil/logger.c
+++ b/src/libutil/logger.c
@@ -39,7 +39,7 @@
*/
struct rspamd_logger_s {
rspamd_log_func_t log_func;
- struct config_file *cfg;
+ struct rspamd_config *cfg;
struct {
guint32 size;
guint32 used;
@@ -275,7 +275,7 @@ reopen_log (rspamd_logger_t *logger)
* Setup logger
*/
void
-rspamd_set_logger (struct config_file *cfg, GQuark ptype, struct rspamd_main *rspamd)
+rspamd_set_logger (struct rspamd_config *cfg, GQuark ptype, struct rspamd_main *rspamd)
{
gchar **strvec, *p, *err;
gint num, i, k;
diff --git a/src/libutil/logger.h b/src/libutil/logger.h
index b0766b938..4b1c74410 100644
--- a/src/libutil/logger.h
+++ b/src/libutil/logger.h
@@ -15,7 +15,7 @@ typedef struct rspamd_logger_s rspamd_logger_t;
/**
* Init logger
*/
-void rspamd_set_logger (struct config_file *cfg, GQuark ptype, struct rspamd_main *main);
+void rspamd_set_logger (struct rspamd_config *cfg, GQuark ptype, struct rspamd_main *main);
/**
* Open log file or initialize other structures
*/
diff --git a/src/libutil/map.c b/src/libutil/map.c
index 703622585..ffe3a1e6f 100644
--- a/src/libutil/map.c
+++ b/src/libutil/map.c
@@ -943,7 +943,7 @@ http_callback (gint fd, short what, void *ud)
/* Start watching event for all maps */
void
-start_map_watch (struct config_file *cfg, struct event_base *ev_base)
+start_map_watch (struct rspamd_config *cfg, struct event_base *ev_base)
{
GList *cur = cfg->maps;
struct rspamd_map *map;
@@ -983,7 +983,7 @@ start_map_watch (struct config_file *cfg, struct event_base *ev_base)
}
void
-remove_all_maps (struct config_file *cfg)
+remove_all_maps (struct rspamd_config *cfg)
{
g_list_free (cfg->maps);
cfg->maps = NULL;
@@ -1022,7 +1022,7 @@ check_map_proto (const gchar *map_line, gint *res, const gchar **pos)
}
gboolean
-add_map (struct config_file *cfg, const gchar *map_line, const gchar *description,
+add_map (struct rspamd_config *cfg, const gchar *map_line, const gchar *description,
map_cb_t read_callback, map_fin_cb_t fin_callback, void **user_data)
{
struct rspamd_map *new_map;
diff --git a/src/libutil/map.h b/src/libutil/map.h
index 1f34cdcc0..ddb9882e4 100644
--- a/src/libutil/map.h
+++ b/src/libutil/map.h
@@ -51,10 +51,10 @@ typedef void (*map_fin_cb_t)(rspamd_mempool_t *pool, struct map_cb_data *data);
/**
* Common map object
*/
-struct config_file;
+struct rspamd_config;
struct rspamd_map {
rspamd_mempool_t *pool;
- struct config_file *cfg;
+ struct rspamd_config *cfg;
enum fetch_proto protocol;
map_cb_t read_callback;
map_fin_cb_t fin_callback;
@@ -89,18 +89,18 @@ gboolean check_map_proto (const gchar *map_line, gint *res, const gchar **pos);
/**
* Add map from line
*/
-gboolean add_map (struct config_file *cfg, const gchar *map_line, const gchar *description,
+gboolean add_map (struct rspamd_config *cfg, const gchar *map_line, const gchar *description,
map_cb_t read_callback, map_fin_cb_t fin_callback, void **user_data);
/**
* Start watching of maps by adding events to libevent event loop
*/
-void start_map_watch (struct config_file *cfg, struct event_base *ev_base);
+void start_map_watch (struct rspamd_config *cfg, struct event_base *ev_base);
/**
* Remove all maps watched (remove events)
*/
-void remove_all_maps (struct config_file *cfg);
+void remove_all_maps (struct rspamd_config *cfg);
typedef void (*insert_func) (gpointer st, gconstpointer key, gconstpointer value);
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 03b38e087..ec63cabb9 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1147,7 +1147,7 @@ fstr_strcase_hash (gconstpointer key)
}
void
-gperf_profiler_init (struct config_file *cfg, const gchar *descr)
+gperf_profiler_init (struct rspamd_config *cfg, const gchar *descr)
{
#if defined(WITH_GPERF_TOOLS)
gchar prof_path[PATH_MAX];
diff --git a/src/libutil/util.h b/src/libutil/util.h
index dfa34a458..a142f15fb 100644
--- a/src/libutil/util.h
+++ b/src/libutil/util.h
@@ -8,11 +8,11 @@
#include "fstring.h"
#include "ucl.h"
-struct config_file;
+struct rspamd_config;
struct rspamd_main;
struct workq;
-struct statfile;
-struct classifier_config;
+struct rspamd_statfile_config;
+struct rspamd_classifier_config;
/**
* Union that is used for storing sockaddrs
@@ -188,7 +188,7 @@ gboolean fstr_strcase_equal (gconstpointer v, gconstpointer v2);
/*
* Google perf-tools initialization function
*/
-void gperf_profiler_init (struct config_file *cfg, const gchar *descr);
+void gperf_profiler_init (struct rspamd_config *cfg, const gchar *descr);
/*
* Workarounds for older versions of glib
diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c
index 8325db107..fb65f1d37 100644
--- a/src/lua/lua_cfg_file.c
+++ b/src/lua/lua_cfg_file.c
@@ -35,7 +35,7 @@
/* Process a single item in 'metrics' table */
static void
-lua_process_metric (lua_State *L, const gchar *name, struct config_file *cfg)
+lua_process_metric (lua_State *L, const gchar *name, struct rspamd_config *cfg)
{
GList *metric_list;
gchar *symbol, *old_desc;
@@ -45,7 +45,7 @@ lua_process_metric (lua_State *L, const gchar *name, struct config_file *cfg)
/* Get module opt structure */
if ((metric = g_hash_table_lookup (cfg->metrics, name)) == NULL) {
- metric = check_metric_conf (cfg, metric);
+ metric = rspamd_config_new_metric (cfg, metric);
metric->name = rspamd_mempool_strdup (cfg->cfg_pool, name);
}
@@ -119,7 +119,7 @@ lua_process_metric (lua_State *L, const gchar *name, struct config_file *cfg)
/* Do post load initialization based on lua */
void
-lua_post_load_config (struct config_file *cfg)
+lua_post_load_config (struct rspamd_config *cfg)
{
lua_State *L = cfg->lua_state;
const gchar *name, *val;
@@ -204,7 +204,7 @@ lua_handle_param (struct rspamd_task *task, gchar *mname, gchar *optname, enum l
#define FAKE_RES_VAR "rspamd_res"
gboolean
-lua_check_condition (struct config_file *cfg, const gchar *condition)
+lua_check_condition (struct rspamd_config *cfg, const gchar *condition)
{
lua_State *L = cfg->lua_state;
gchar *hostbuf, *condbuf;
diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c
index 1e33f704d..d227fc5da 100644
--- a/src/lua/lua_classifier.c
+++ b/src/lua/lua_classifier.c
@@ -66,29 +66,29 @@ struct classifier_callback_data {
const gchar *name;
};
-static struct statfile* lua_check_statfile (lua_State * L);
+static struct rspamd_statfile_config* lua_check_statfile (lua_State * L);
/* Classifier implementation */
-static struct classifier_config *
+static struct rspamd_classifier_config *
lua_check_classifier (lua_State * L)
{
void *ud = luaL_checkudata (L, 1, "rspamd{classifier}");
luaL_argcheck (L, ud != NULL, 1, "'classifier' expected");
- return ud ? *((struct classifier_config **)ud) : NULL;
+ return ud ? *((struct rspamd_classifier_config **)ud) : NULL;
}
static GList *
-call_classifier_pre_callback (struct classifier_config *ccf, struct rspamd_task *task,
+call_classifier_pre_callback (struct rspamd_classifier_config *ccf, struct rspamd_task *task,
lua_State *L, gboolean is_learn, gboolean is_spam)
{
- struct classifier_config **pccf;
+ struct rspamd_classifier_config **pccf;
struct rspamd_task **ptask;
- struct statfile **pst;
+ struct rspamd_statfile_config **pst;
GList *res = NULL;
- pccf = lua_newuserdata (L, sizeof (struct classifier_config *));
+ pccf = lua_newuserdata (L, sizeof (struct rspamd_classifier_config *));
lua_setclass (L, "rspamd{classifier}", -1);
*pccf = ccf;
@@ -120,7 +120,7 @@ call_classifier_pre_callback (struct classifier_config *ccf, struct rspamd_task
/* Return list of statfiles that should be checked for this message */
GList *
-call_classifier_pre_callbacks (struct classifier_config *ccf, struct rspamd_task *task,
+call_classifier_pre_callbacks (struct rspamd_classifier_config *ccf, struct rspamd_task *task,
gboolean is_learn, gboolean is_spam, lua_State *L)
{
GList *res = NULL, *cur;
@@ -158,10 +158,10 @@ call_classifier_pre_callbacks (struct classifier_config *ccf, struct rspamd_task
/* Return result mark for statfile */
double
-call_classifier_post_callbacks (struct classifier_config *ccf, struct rspamd_task *task, double in, lua_State *L)
+call_classifier_post_callbacks (struct rspamd_classifier_config *ccf, struct rspamd_task *task, double in, lua_State *L)
{
struct classifier_callback_data *cd;
- struct classifier_config **pccf;
+ struct rspamd_classifier_config **pccf;
struct rspamd_task **ptask;
double out = in;
GList *cur;
@@ -172,7 +172,7 @@ call_classifier_post_callbacks (struct classifier_config *ccf, struct rspamd_tas
cd = cur->data;
lua_getglobal (L, cd->name);
- pccf = lua_newuserdata (L, sizeof (struct classifier_config *));
+ pccf = lua_newuserdata (L, sizeof (struct rspamd_classifier_config *));
lua_setclass (L, "rspamd{classifier}", -1);
*pccf = ccf;
@@ -202,7 +202,7 @@ call_classifier_post_callbacks (struct classifier_config *ccf, struct rspamd_tas
static gint
lua_classifier_register_pre_callback (lua_State *L)
{
- struct classifier_config *ccf = lua_check_classifier (L);
+ struct rspamd_classifier_config *ccf = lua_check_classifier (L);
struct classifier_callback_data *cd;
const gchar *name;
@@ -223,7 +223,7 @@ lua_classifier_register_pre_callback (lua_State *L)
static gint
lua_classifier_register_post_callback (lua_State *L)
{
- struct classifier_config *ccf = lua_check_classifier (L);
+ struct rspamd_classifier_config *ccf = lua_check_classifier (L);
struct classifier_callback_data *cd;
const gchar *name;
@@ -244,9 +244,9 @@ lua_classifier_register_post_callback (lua_State *L)
static gint
lua_classifier_get_statfiles (lua_State *L)
{
- struct classifier_config *ccf = lua_check_classifier (L);
+ struct rspamd_classifier_config *ccf = lua_check_classifier (L);
GList *cur;
- struct statfile *st, **pst;
+ struct rspamd_statfile_config *st, **pst;
gint i;
if (ccf) {
@@ -255,7 +255,7 @@ lua_classifier_get_statfiles (lua_State *L)
i = 1;
while (cur) {
st = cur->data;
- pst = lua_newuserdata (L, sizeof (struct statfile *));
+ pst = lua_newuserdata (L, sizeof (struct rspamd_statfile_config *));
lua_setclass (L, "rspamd{statfile}", -1);
*pst = st;
lua_rawseti (L, -2, i++);
@@ -274,8 +274,8 @@ lua_classifier_get_statfiles (lua_State *L)
static gint
lua_classifier_get_statfile_by_label (lua_State *L)
{
- struct classifier_config *ccf = lua_check_classifier (L);
- struct statfile *st, **pst;
+ struct rspamd_classifier_config *ccf = lua_check_classifier (L);
+ struct rspamd_statfile_config *st, **pst;
const gchar *label;
GList *cur;
gint i;
@@ -288,7 +288,7 @@ lua_classifier_get_statfile_by_label (lua_State *L)
i = 1;
while (cur) {
st = cur->data;
- pst = lua_newuserdata (L, sizeof (struct statfile *));
+ pst = lua_newuserdata (L, sizeof (struct rspamd_statfile_config *));
lua_setclass (L, "rspamd{statfile}", -1);
*pst = st;
lua_rawseti (L, -2, i++);
@@ -305,7 +305,7 @@ lua_classifier_get_statfile_by_label (lua_State *L)
static gint
lua_statfile_get_symbol (lua_State *L)
{
- struct statfile *st = lua_check_statfile (L);
+ struct rspamd_statfile_config *st = lua_check_statfile (L);
if (st != NULL) {
lua_pushstring (L, st->symbol);
@@ -320,7 +320,7 @@ lua_statfile_get_symbol (lua_State *L)
static gint
lua_statfile_get_label (lua_State *L)
{
- struct statfile *st = lua_check_statfile (L);
+ struct rspamd_statfile_config *st = lua_check_statfile (L);
if (st != NULL && st->label != NULL) {
lua_pushstring (L, st->label);
@@ -335,7 +335,7 @@ lua_statfile_get_label (lua_State *L)
static gint
lua_statfile_get_path (lua_State *L)
{
- struct statfile *st = lua_check_statfile (L);
+ struct rspamd_statfile_config *st = lua_check_statfile (L);
if (st != NULL) {
lua_pushstring (L, st->path);
@@ -350,7 +350,7 @@ lua_statfile_get_path (lua_State *L)
static gint
lua_statfile_get_size (lua_State *L)
{
- struct statfile *st = lua_check_statfile (L);
+ struct rspamd_statfile_config *st = lua_check_statfile (L);
if (st != NULL) {
lua_pushinteger (L, st->size);
@@ -365,7 +365,7 @@ lua_statfile_get_size (lua_State *L)
static gint
lua_statfile_is_spam (lua_State *L)
{
- struct statfile *st = lua_check_statfile (L);
+ struct rspamd_statfile_config *st = lua_check_statfile (L);
if (st != NULL) {
lua_pushboolean (L, st->is_spam);
@@ -380,7 +380,7 @@ lua_statfile_is_spam (lua_State *L)
static gint
lua_statfile_get_param (lua_State *L)
{
- struct statfile *st = lua_check_statfile (L);
+ struct rspamd_statfile_config *st = lua_check_statfile (L);
const gchar *param;
const ucl_object_t *value;
@@ -398,12 +398,12 @@ lua_statfile_get_param (lua_State *L)
return 1;
}
-static struct statfile *
+static struct rspamd_statfile_config *
lua_check_statfile (lua_State * L)
{
void *ud = luaL_checkudata (L, 1, "rspamd{statfile}");
luaL_argcheck (L, ud != NULL, 1, "'statfile' expected");
- return ud ? *((struct statfile **)ud) : NULL;
+ return ud ? *((struct rspamd_statfile_config **)ud) : NULL;
}
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index f7912a722..349cf09b5 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -264,7 +264,7 @@ lua_add_actions_global (lua_State *L)
}
lua_State *
-init_lua (struct config_file *cfg)
+init_lua (struct rspamd_config *cfg)
{
lua_State *L;
@@ -306,7 +306,7 @@ init_lua (struct config_file *cfg)
* Initialize new locked lua_State structure
*/
struct lua_locked_state*
-init_lua_locked (struct config_file *cfg)
+init_lua_locked (struct rspamd_config *cfg)
{
struct lua_locked_state *new;
@@ -334,12 +334,12 @@ free_lua_locked (struct lua_locked_state *st)
}
gboolean
-init_lua_filters (struct config_file *cfg)
+init_lua_filters (struct rspamd_config *cfg)
{
- struct config_file **pcfg;
+ struct rspamd_config **pcfg;
GList *cur, *tmp;
struct script_module *module;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
lua_State *L = cfg->lua_state;
cur = g_list_first (cfg->script_modules);
@@ -353,7 +353,7 @@ init_lua_filters (struct config_file *cfg)
}
/* Initialize config structure */
- pcfg = lua_newuserdata (L, sizeof (struct config_file *));
+ pcfg = lua_newuserdata (L, sizeof (struct rspamd_config *));
lua_setclass (L, "rspamd{config}", -1);
*pcfg = cfg;
lua_setglobal (L, "rspamd_config");
@@ -563,7 +563,7 @@ lua_consolidation_func (struct rspamd_task *task, const gchar *metric_name, cons
}
double
-lua_normalizer_func (struct config_file *cfg, long double score, void *params)
+lua_normalizer_func (struct rspamd_config *cfg, long double score, void *params)
{
GList *p = params;
long double res = score;
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h
index f9d977244..7f0f12f42 100644
--- a/src/lua/lua_common.h
+++ b/src/lua/lua_common.h
@@ -93,17 +93,17 @@ gpointer lua_check_class (lua_State *L, gint index, const gchar *name);
/**
* Initialize lua and bindings
*/
-lua_State* init_lua (struct config_file *cfg);
+lua_State* init_lua (struct rspamd_config *cfg);
/**
* Load and initialize lua plugins
*/
-gboolean init_lua_filters (struct config_file *cfg);
+gboolean init_lua_filters (struct rspamd_config *cfg);
/**
* Initialize new locked lua_State structure
*/
-struct lua_locked_state* init_lua_locked (struct config_file *cfg);
+struct lua_locked_state* init_lua_locked (struct rspamd_config *cfg);
/**
* Free locked state structure
*/
@@ -184,18 +184,18 @@ void lua_call_pre_filters (struct rspamd_task *task);
void add_luabuf (const gchar *line);
/* Classify functions */
-GList *call_classifier_pre_callbacks (struct classifier_config *ccf, struct rspamd_task *task, gboolean is_learn, gboolean is_spam, lua_State *L);
-double call_classifier_post_callbacks (struct classifier_config *ccf, struct rspamd_task *task, double in, lua_State *L);
+GList *call_classifier_pre_callbacks (struct rspamd_classifier_config *ccf, struct rspamd_task *task, gboolean is_learn, gboolean is_spam, lua_State *L);
+double call_classifier_post_callbacks (struct rspamd_classifier_config *ccf, struct rspamd_task *task, double in, lua_State *L);
-double lua_normalizer_func (struct config_file *cfg, long double score, void *params);
+double lua_normalizer_func (struct rspamd_config *cfg, long double score, void *params);
/* Config file functions */
-void lua_post_load_config (struct config_file *cfg);
-void lua_process_element (struct config_file *cfg, const gchar *name,
- const gchar *module_name, struct module_opt *opt, gint idx, gboolean allow_meta);
+void lua_post_load_config (struct rspamd_config *cfg);
+void lua_process_element (struct rspamd_config *cfg, const gchar *name,
+ const gchar *module_name, struct rspamd_module_opt *opt, gint idx, gboolean allow_meta);
gboolean lua_handle_param (struct rspamd_task *task, gchar *mname, gchar *optname,
enum lua_var_type expected_type, gpointer *res);
-gboolean lua_check_condition (struct config_file *cfg, const gchar *condition);
+gboolean lua_check_condition (struct rspamd_config *cfg, const gchar *condition);
void lua_dumpstack (lua_State *L);
struct memory_pool_s *lua_check_mempool (lua_State * L);
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index d922cac47..0f047d3b1 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -109,12 +109,12 @@ static const struct luaL_reg trielib_f[] = {
{NULL, NULL}
};
-static struct config_file *
+static struct rspamd_config *
lua_check_config (lua_State * L)
{
void *ud = luaL_checkudata (L, 1, "rspamd{config}");
luaL_argcheck (L, ud != NULL, 1, "'config' expected");
- return ud ? *((struct config_file **)ud) : NULL;
+ return ud ? *((struct rspamd_config **)ud) : NULL;
}
static radix_tree_t *
@@ -153,7 +153,7 @@ lua_config_get_api_version (lua_State *L)
static gint
lua_config_get_module_opt (lua_State * L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
const gchar *mname, *optname;
const ucl_object_t *obj;
@@ -162,7 +162,7 @@ lua_config_get_module_opt (lua_State * L)
optname = luaL_checkstring (L, 3);
if (mname && optname) {
- obj = get_module_opt (cfg, mname, optname);
+ obj = rspamd_config_get_module_opt (cfg, mname, optname);
if (obj) {
return lua_rcl_obj_push (L, obj, TRUE);
}
@@ -176,7 +176,7 @@ static int
lua_config_get_mempool (lua_State * L)
{
rspamd_mempool_t **ppool;
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
if (cfg != NULL) {
ppool = lua_newuserdata (L, sizeof (rspamd_mempool_t *));
@@ -189,7 +189,7 @@ lua_config_get_mempool (lua_State * L)
static gint
lua_config_get_all_opt (lua_State * L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
const gchar *mname;
const ucl_object_t *obj;
@@ -211,8 +211,8 @@ lua_config_get_all_opt (lua_State * L)
static gint
lua_config_get_classifier (lua_State * L)
{
- struct config_file *cfg = lua_check_config (L);
- struct classifier_config *clc = NULL, **pclc = NULL;
+ struct rspamd_config *cfg = lua_check_config (L);
+ struct rspamd_classifier_config *clc = NULL, **pclc = NULL;
const gchar *name;
GList *cur;
@@ -229,7 +229,7 @@ lua_config_get_classifier (lua_State * L)
cur = g_list_next (cur);
}
if (pclc) {
- pclc = lua_newuserdata (L, sizeof (struct classifier_config *));
+ pclc = lua_newuserdata (L, sizeof (struct rspamd_classifier_config *));
lua_setclass (L, "rspamd{classifier}", -1);
*pclc = clc;
return 1;
@@ -311,7 +311,7 @@ lua_config_function_callback (struct rspamd_task *task, GList *args, void *user_
static gint
lua_config_register_function (lua_State *L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
gchar *name;
struct lua_callback_data *cd;
@@ -376,7 +376,7 @@ lua_call_post_filters (struct rspamd_task *task)
static gint
lua_config_register_post_filter (lua_State *L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
struct lua_callback_data *cd;
if (cfg) {
@@ -429,7 +429,7 @@ lua_call_pre_filters (struct rspamd_task *task)
static gint
lua_config_register_pre_filter (lua_State *L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
struct lua_callback_data *cd;
if (cfg) {
@@ -454,7 +454,7 @@ lua_config_register_pre_filter (lua_State *L)
static gint
lua_config_add_radix_map (lua_State *L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
const gchar *map_line, *description;
radix_tree_t **r, ***ud;
@@ -484,7 +484,7 @@ lua_config_add_radix_map (lua_State *L)
static gint
lua_config_add_hash_map (lua_State *L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
const gchar *map_line, *description;
GHashTable **r, ***ud;
@@ -515,7 +515,7 @@ lua_config_add_hash_map (lua_State *L)
static gint
lua_config_add_kv_map (lua_State *L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
const gchar *map_line, *description;
GHashTable **r, ***ud;
@@ -571,7 +571,7 @@ lua_metric_symbol_callback (struct rspamd_task *task, gpointer ud)
static gint
lua_config_register_symbol (lua_State * L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
gchar *name;
double weight;
struct lua_callback_data *cd;
@@ -603,7 +603,7 @@ lua_config_register_symbol (lua_State * L)
static gint
lua_config_register_symbols (lua_State *L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
struct lua_callback_data *cd;
gint i, top;
gchar *sym;
@@ -648,7 +648,7 @@ lua_config_register_symbols (lua_State *L)
static gint
lua_config_register_virtual_symbol (lua_State * L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
gchar *name;
double weight;
@@ -665,7 +665,7 @@ lua_config_register_virtual_symbol (lua_State * L)
static gint
lua_config_register_callback_symbol (lua_State * L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
gchar *name;
double weight;
struct lua_callback_data *cd;
@@ -697,7 +697,7 @@ lua_config_register_callback_symbol (lua_State * L)
static gint
lua_config_register_callback_symbol_priority (lua_State * L)
{
- struct config_file *cfg = lua_check_config (L);
+ struct rspamd_config *cfg = lua_check_config (L);
gchar *name;
double weight;
gint priority;
diff --git a/src/lua/lua_dns.c b/src/lua/lua_dns.c
index 1944f0a20..49ed205da 100644
--- a/src/lua/lua_dns.c
+++ b/src/lua/lua_dns.c
@@ -169,7 +169,7 @@ static int
lua_dns_resolver_init (lua_State *L)
{
struct rspamd_dns_resolver *resolver, **presolver;
- struct config_file *cfg, **pcfg;
+ struct rspamd_config *cfg, **pcfg;
struct event_base *base, **pbase;
/* Check args */
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 3d58e6a65..0572226be 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -39,8 +39,8 @@
#include "statfile_sync.h"
#include "diff.h"
-extern stat_file_t* get_statfile_by_symbol (statfile_pool_t *pool, struct classifier_config *ccf,
- const gchar *symbol, struct statfile **st, gboolean try_create);
+extern stat_file_t* get_statfile_by_symbol (statfile_pool_t *pool, struct rspamd_classifier_config *ccf,
+ const gchar *symbol, struct rspamd_statfile_config **st, gboolean try_create);
/* Task creation */
LUA_FUNCTION_DEF (task, create_empty);
@@ -318,7 +318,7 @@ lua_task_set_cfg (lua_State *L)
void *ud = luaL_checkudata (L, 2, "rspamd{config}");
luaL_argcheck (L, ud != NULL, 1, "'config' expected");
- task->cfg = ud ? *((struct config_file **)ud) : NULL;
+ task->cfg = ud ? *((struct rspamd_config **)ud) : NULL;
return 0;
}
@@ -1281,9 +1281,9 @@ lua_task_learn_statfile (lua_State *L)
{
struct rspamd_task *task = lua_check_task (L);
const gchar *symbol;
- struct classifier_config *cl;
+ struct rspamd_classifier_config *cl;
GTree *tokens;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
stat_file_t *statfile;
struct classifier_ctx *ctx;
diff --git a/src/lua/lua_upstream.c b/src/lua/lua_upstream.c
index 855e9ff4a..ee06fe2c1 100644
--- a/src/lua/lua_upstream.c
+++ b/src/lua/lua_upstream.c
@@ -114,7 +114,7 @@ lua_upstream_create (lua_State *L)
new = g_slice_alloc0 (sizeof (struct lua_upstream));
new->def = g_strdup (def);
new->addr = g_malloc (INET6_ADDRSTRLEN);
- if (!parse_host_port_priority (NULL, new->def, &new->addr, &new->port, &new->up.priority)) {
+ if (!rspamd_parse_host_port_priority (NULL, new->def, &new->addr, &new->port, &new->up.priority)) {
g_free (new->def);
g_slice_free1 (sizeof (struct lua_upstream), new);
lua_pushnil (L);
@@ -322,7 +322,7 @@ lua_upstream_list_create (lua_State *L)
for (i = 0; i < new->count; i ++) {
cur = &new->upstreams[i];
cur->addr = g_malloc (INET6_ADDRSTRLEN);
- if (!parse_host_port_priority (NULL, tokens[i], &cur->addr, &cur->port, &cur->up.priority)) {
+ if (!rspamd_parse_host_port_priority (NULL, tokens[i], &cur->addr, &cur->port, &cur->up.priority)) {
goto err;
}
if (cur->port == 0) {
diff --git a/src/lua_worker.c b/src/lua_worker.c
index f66124129..3bb3621e5 100644
--- a/src/lua_worker.c
+++ b/src/lua_worker.c
@@ -42,7 +42,7 @@
/* 60 seconds for worker's IO */
#define DEFAULT_WORKER_IO_TIMEOUT 60000
-gpointer init_lua_worker (struct config_file *cfg);
+gpointer init_lua_worker (struct rspamd_config *cfg);
void start_lua_worker (struct rspamd_worker *worker);
worker_t lua_worker = {
@@ -75,7 +75,7 @@ struct rspamd_lua_worker_ctx {
/* Callback for finishing */
gint cbref_fin;
/* Config file */
- struct config_file *cfg;
+ struct rspamd_config *cfg;
/* The rest options */
ucl_object_t *opts;
};
@@ -236,7 +236,7 @@ static int
lua_worker_get_cfg (lua_State *L)
{
struct rspamd_lua_worker_ctx *ctx = lua_check_lua_worker (L);
- struct config_file **pcfg;
+ struct rspamd_config **pcfg;
if (ctx) {
pcfg = lua_newuserdata (L, sizeof (gpointer));
@@ -307,7 +307,7 @@ rspamd_lua_worker_parser (ucl_object_t *obj, gpointer ud)
}
gpointer
-init_lua_worker (struct config_file *cfg)
+init_lua_worker (struct rspamd_config *cfg)
{
struct rspamd_lua_worker_ctx *ctx;
GQuark type;
@@ -341,7 +341,7 @@ start_lua_worker (struct rspamd_worker *worker)
monstartup ((u_long) & _start, (u_long) & etext);
#endif
- ctx->ev_base = prepare_worker (worker, "lua_worker", lua_accept_socket);
+ ctx->ev_base = rspamd_prepare_worker (worker, "lua_worker", lua_accept_socket);
L = worker->srv->cfg->lua_state;
ctx->L = L;
diff --git a/src/main.c b/src/main.c
index 0dea14d62..1c8f7fd41 100644
--- a/src/main.c
+++ b/src/main.c
@@ -52,9 +52,9 @@
/* 10 seconds after getting termination signal to terminate all workers with SIGKILL */
#define HARD_TERMINATION_TIME 10
-static struct rspamd_worker *fork_worker (struct rspamd_main *, struct worker_conf *);
-static gboolean load_rspamd_config (struct config_file *cfg, gboolean init_modules);
-static void init_cfg_cache (struct config_file *cfg);
+static struct rspamd_worker *fork_worker (struct rspamd_main *, struct rspamd_worker_conf *);
+static gboolean load_rspamd_config (struct rspamd_config *cfg, gboolean init_modules);
+static void init_cfg_cache (struct rspamd_config *cfg);
sig_atomic_t do_restart = 0;
sig_atomic_t do_reopen_log = 0;
@@ -188,7 +188,7 @@ print_signals_info (void)
static void
-read_cmd_line (gint argc, gchar **argv, struct config_file *cfg)
+read_cmd_line (gint argc, gchar **argv, struct rspamd_config *cfg)
{
GError *error = NULL;
GOptionContext *context;
@@ -300,7 +300,7 @@ drop_priv (struct rspamd_main *rspamd)
}
static void
-config_logger (struct config_file *cfg, gpointer ud)
+config_logger (struct rspamd_config *cfg, gpointer ud)
{
struct rspamd_main *rm = ud;
@@ -317,7 +317,7 @@ config_logger (struct config_file *cfg, gpointer ud)
}
static void
-parse_filters_str (struct config_file *cfg, const gchar *str)
+parse_filters_str (struct rspamd_config *cfg, const gchar *str)
{
gchar **strvec, **p;
struct filter *cur;
@@ -365,16 +365,16 @@ parse_filters_str (struct config_file *cfg, const gchar *str)
static void
reread_config (struct rspamd_main *rspamd)
{
- struct config_file *tmp_cfg;
+ struct rspamd_config *tmp_cfg;
gchar *cfg_file;
GList *l;
struct filter *filt;
- tmp_cfg = (struct config_file *)g_malloc (sizeof (struct config_file));
+ tmp_cfg = (struct rspamd_config *)g_malloc (sizeof (struct rspamd_config));
if (tmp_cfg) {
- bzero (tmp_cfg, sizeof (struct config_file));
+ bzero (tmp_cfg, sizeof (struct rspamd_config));
tmp_cfg->cfg_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
- init_defaults (tmp_cfg);
+ rspamd_config_defaults (tmp_cfg);
cfg_file = rspamd_mempool_strdup (tmp_cfg->cfg_pool, rspamd->cfg->cfg_name);
/* Save some variables */
tmp_cfg->cfg_name = cfg_file;
@@ -384,11 +384,11 @@ reread_config (struct rspamd_main *rspamd)
if (! load_rspamd_config (tmp_cfg, FALSE)) {
rspamd_set_logger (rspamd_main->cfg, g_quark_try_string ("main"), rspamd_main);
msg_err ("cannot parse new config file, revert to old one");
- free_config (tmp_cfg);
+ rspamd_config_free (tmp_cfg);
}
else {
msg_debug ("replacing config");
- free_config (rspamd->cfg);
+ rspamd_config_free (rspamd->cfg);
close_log (rspamd->logger);
g_free (rspamd->cfg);
rspamd->cfg = tmp_cfg;
@@ -420,7 +420,7 @@ reread_config (struct rspamd_main *rspamd)
}
static void
-set_worker_limits (struct worker_conf *cf)
+set_worker_limits (struct rspamd_worker_conf *cf)
{
struct rlimit rlmt;
@@ -444,7 +444,7 @@ set_worker_limits (struct worker_conf *cf)
}
static struct rspamd_worker *
-fork_worker (struct rspamd_main *rspamd, struct worker_conf *cf)
+fork_worker (struct rspamd_main *rspamd, struct rspamd_worker_conf *cf)
{
struct rspamd_worker *cur;
/* Starting worker process */
@@ -454,8 +454,8 @@ fork_worker (struct rspamd_main *rspamd, struct worker_conf *cf)
cur->srv = rspamd;
cur->type = cf->type;
cur->pid = fork ();
- cur->cf = g_malloc (sizeof (struct worker_conf));
- memcpy (cur->cf, cf, sizeof (struct worker_conf));
+ cur->cf = g_malloc (sizeof (struct rspamd_worker_conf));
+ memcpy (cur->cf, cf, sizeof (struct rspamd_worker_conf));
cur->pending = FALSE;
cur->ctx = cf->ctx;
switch (cur->pid) {
@@ -521,7 +521,7 @@ set_alarm (guint seconds)
}
static void
-delay_fork (struct worker_conf *cf)
+delay_fork (struct rspamd_worker_conf *cf)
{
workers_pending = g_list_prepend (workers_pending, cf);
set_alarm (SOFT_FORK_TIME);
@@ -594,7 +594,7 @@ static void
fork_delayed (struct rspamd_main *rspamd)
{
GList *cur;
- struct worker_conf *cf;
+ struct rspamd_worker_conf *cf;
while (workers_pending != NULL) {
cur = workers_pending;
@@ -622,7 +622,7 @@ static void
spawn_workers (struct rspamd_main *rspamd)
{
GList *cur, *ls;
- struct worker_conf *cf;
+ struct rspamd_worker_conf *cf;
gint i, key;
gpointer p;
struct rspamd_worker_bind_conf *bcf;
@@ -739,8 +739,8 @@ reopen_log_handler (gpointer key, gpointer value, gpointer unused)
static void
preload_statfiles (struct rspamd_main *rspamd)
{
- struct classifier_config *cf;
- struct statfile *st;
+ struct rspamd_classifier_config *cf;
+ struct rspamd_statfile_config *st;
stat_file_t *stf;
GList *cur_cl, *cur_st;
@@ -764,13 +764,13 @@ preload_statfiles (struct rspamd_main *rspamd)
}
static gboolean
-load_rspamd_config (struct config_file *cfg, gboolean init_modules)
+load_rspamd_config (struct rspamd_config *cfg, gboolean init_modules)
{
GList *l;
struct filter *filt;
struct module_ctx *cur_module = NULL;
- if (! read_rspamd_config (cfg, cfg->cfg_name, NULL,
+ if (! rspamd_config_read (cfg, cfg->cfg_name, NULL,
config_logger, rspamd_main)) {
return FALSE;
}
@@ -787,7 +787,7 @@ load_rspamd_config (struct config_file *cfg, gboolean init_modules)
}
/* Do post-load actions */
- post_load_config (cfg);
+ rspamd_config_post_load (cfg);
parse_filters_str (cfg, cfg->filters_str);
if (init_modules) {
@@ -810,7 +810,7 @@ load_rspamd_config (struct config_file *cfg, gboolean init_modules)
}
static void
-init_cfg_cache (struct config_file *cfg)
+init_cfg_cache (struct rspamd_config *cfg)
{
if (!init_symbols_cache (cfg->cfg_pool, cfg->cache, cfg, cfg->cache_filename, FALSE)) {
@@ -819,7 +819,7 @@ init_cfg_cache (struct config_file *cfg)
}
static void
-print_symbols_cache (struct config_file *cfg)
+print_symbols_cache (struct rspamd_config *cfg)
{
GList *cur;
struct cache_item *item;
@@ -859,7 +859,7 @@ print_symbols_cache (struct config_file *cfg)
}
static gint
-perform_lua_tests (struct config_file *cfg)
+perform_lua_tests (struct rspamd_config *cfg)
{
gint i, tests_num, res = EXIT_SUCCESS;
gchar *cur_script;
@@ -1054,7 +1054,7 @@ main (gint argc, gchar **argv, gchar **env)
rspamd_main = (struct rspamd_main *)g_malloc (sizeof (struct rspamd_main));
memset (rspamd_main, 0, sizeof (struct rspamd_main));
rspamd_main->server_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
- rspamd_main->cfg = (struct config_file *)g_malloc (sizeof (struct config_file));
+ rspamd_main->cfg = (struct rspamd_config *)g_malloc (sizeof (struct rspamd_config));
if (!rspamd_main || !rspamd_main->cfg) {
fprintf (stderr, "Cannot allocate memory\n");
@@ -1068,9 +1068,9 @@ main (gint argc, gchar **argv, gchar **env)
rspamd_main->stat = rspamd_mempool_alloc_shared (rspamd_main->server_pool, sizeof (struct rspamd_stat));
memset (rspamd_main->stat, 0, sizeof (struct rspamd_stat));
- memset (rspamd_main->cfg, 0, sizeof (struct config_file));
+ memset (rspamd_main->cfg, 0, sizeof (struct rspamd_config));
rspamd_main->cfg->cfg_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
- init_defaults (rspamd_main->cfg);
+ rspamd_config_defaults (rspamd_main->cfg);
memset (&signals, 0, sizeof (struct sigaction));
@@ -1178,7 +1178,7 @@ main (gint argc, gchar **argv, gchar **env)
l = g_list_next (l);
}
/* Insert classifiers symbols */
- (void)insert_classifier_symbols (rspamd_main->cfg);
+ (void)rspamd_config_insert_classify_symbols (rspamd_main->cfg);
if (! validate_cache (rspamd_main->cfg->cache, rspamd_main->cfg, FALSE)) {
res = FALSE;
@@ -1238,7 +1238,7 @@ main (gint argc, gchar **argv, gchar **env)
/* Insert classifiers symbols */
- (void)insert_classifier_symbols (rspamd_main->cfg);
+ (void)rspamd_config_insert_classify_symbols (rspamd_main->cfg);
/* Perform modules configuring */
l = g_list_first (rspamd_main->cfg->filters);
@@ -1369,7 +1369,7 @@ main (gint argc, gchar **argv, gchar **env)
close_log (rspamd_main->logger);
- free_config (rspamd_main->cfg);
+ rspamd_config_free (rspamd_main->cfg);
g_free (rspamd_main->cfg);
g_free (rspamd_main);
diff --git a/src/main.h b/src/main.h
index d93c00e09..9b4aebe38 100644
--- a/src/main.h
+++ b/src/main.h
@@ -57,7 +57,7 @@ struct rspamd_worker {
struct event sig_ev_usr1; /**< signals event */
struct event sig_ev_usr2; /**< signals event */
GList *accept_events; /**< socket events */
- struct worker_conf *cf; /**< worker config data */
+ struct rspamd_worker_conf *cf; /**< worker config data */
gpointer ctx; /**< worker's specific data */
};
@@ -66,10 +66,10 @@ struct rspamd_worker {
*/
struct pidfh;
-struct config_file;
+struct rspamd_config;
struct tokenizer;
struct classifier;
-struct classifier_config;
+struct rspamd_classifier_config;
struct mime_part;
struct rspamd_dns_resolver;
struct rspamd_task;
@@ -91,7 +91,7 @@ struct rspamd_stat {
* Struct that determine main server object (for logging purposes)
*/
struct rspamd_main {
- struct config_file *cfg; /**< pointer to config structure */
+ struct rspamd_config *cfg; /**< pointer to config structure */
pid_t pid; /**< main pid */
/* Pid file structure */
rspamd_pidfh_t *pfh; /**< struct pidfh for pidfile */
@@ -151,10 +151,10 @@ struct controller_session {
GHashTable *kwargs; /**< keyword arguments for restful command */
struct controller_command *cmd; /**< real command */
rspamd_mempool_t *session_pool; /**< memory pool for session */
- struct config_file *cfg; /**< pointer to config file */
+ struct rspamd_config *cfg; /**< pointer to config file */
gchar *learn_rcpt; /**< recipient for learning */
gchar *learn_from; /**< from address for learning */
- struct classifier_config *learn_classifier;
+ struct rspamd_classifier_config *learn_classifier;
gchar *learn_symbol; /**< symbol to train */
double learn_multiplier; /**< multiplier for learning */
rspamd_io_dispatcher_t *dispatcher; /**< IO dispatcher object */
@@ -179,14 +179,6 @@ struct module_ctx {
};
/**
- * Common structure for C module
- */
-struct c_module {
- const gchar *name; /**< name */
- struct module_ctx *ctx; /**< pointer to context */
-};
-
-/**
* Register custom controller function
*/
void register_custom_controller_command (const gchar *name, controller_func_t handler, gboolean privilleged, gboolean require_message);
diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c
index e33052063..c40f3e8e2 100644
--- a/src/plugins/chartable.c
+++ b/src/plugins/chartable.c
@@ -41,9 +41,9 @@
#define DEFAULT_THRESHOLD 0.1
/* Initialization */
-gint chartable_module_init (struct config_file *cfg, struct module_ctx **ctx);
-gint chartable_module_config (struct config_file *cfg);
-gint chartable_module_reconfig (struct config_file *cfg);
+gint chartable_module_init (struct rspamd_config *cfg, struct module_ctx **ctx);
+gint chartable_module_config (struct rspamd_config *cfg);
+gint chartable_module_reconfig (struct rspamd_config *cfg);
module_t chartable_module = {
"chartable",
@@ -66,7 +66,7 @@ static gint chartable_mime_filter (struct rspamd_task *task
static void chartable_symbol_callback (struct rspamd_task *task, void *unused);
gint
-chartable_module_init (struct config_file *cfg, struct module_ctx **ctx)
+chartable_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
chartable_module_ctx = g_malloc (sizeof (struct chartable_ctx));
@@ -80,18 +80,18 @@ chartable_module_init (struct config_file *cfg, struct module_ctx **ctx)
gint
-chartable_module_config (struct config_file *cfg)
+chartable_module_config (struct rspamd_config *cfg)
{
const ucl_object_t *value;
gint res = TRUE;
- if ((value = get_module_opt (cfg, "chartable", "symbol")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "chartable", "symbol")) != NULL) {
chartable_module_ctx->symbol = ucl_obj_tostring (value);
}
else {
chartable_module_ctx->symbol = DEFAULT_SYMBOL;
}
- if ((value = get_module_opt (cfg, "chartable", "threshold")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "chartable", "threshold")) != NULL) {
if (!ucl_obj_todouble_safe (value, &chartable_module_ctx->threshold)) {
msg_warn ("invalid numeric value");
chartable_module_ctx->threshold = DEFAULT_THRESHOLD;
@@ -107,7 +107,7 @@ chartable_module_config (struct config_file *cfg)
}
gint
-chartable_module_reconfig (struct config_file *cfg)
+chartable_module_reconfig (struct rspamd_config *cfg)
{
rspamd_mempool_delete (chartable_module_ctx->chartable_pool);
chartable_module_ctx->chartable_pool = rspamd_mempool_new (1024);
diff --git a/src/plugins/custom/ipmark/ipmark.c b/src/plugins/custom/ipmark/ipmark.c
index a40a94582..1b4eb7f6c 100644
--- a/src/plugins/custom/ipmark/ipmark.c
+++ b/src/plugins/custom/ipmark/ipmark.c
@@ -47,7 +47,7 @@ enum ipmark_command {
};
/* Exported functions */
-void module_init (struct config_file *cfg);
+void module_init (struct rspamd_config *cfg);
void* before_connect (void);
gboolean parse_line (const char *line, size_t len, char **output, void *user_data);
void after_connect (char **output, char **log_line, void *user_data);
@@ -60,10 +60,10 @@ static radix_tree_t *radix = NULL;
/* Implementation */
char *
-get_module_opt (struct config_file *cfg, char *module_name, char *opt_name)
+rspamd_config_get_module_opt (struct rspamd_config *cfg, char *module_name, char *opt_name)
{
GList *cur_opt;
- struct module_opt *cur;
+ struct rspamd_module_opt *cur;
cur_opt = g_hash_table_lookup (cfg->modules_opts, module_name);
if (cur_opt == NULL) {
@@ -216,11 +216,11 @@ write_radix_file (void)
}
void
-module_init (struct config_file *cfg)
+module_init (struct rspamd_config *cfg)
{
char *value;
- if (cfg && (value = get_module_opt (cfg, "ipmark", "file")) != NULL) {
+ if (cfg && (value = rspamd_config_get_module_opt (cfg, "ipmark", "file")) != NULL) {
filename = g_strdup (value);
}
diff --git a/src/plugins/custom/regmark/regmark.c b/src/plugins/custom/regmark/regmark.c
index 35901f9aa..6b3374f67 100644
--- a/src/plugins/custom/regmark/regmark.c
+++ b/src/plugins/custom/regmark/regmark.c
@@ -54,7 +54,7 @@
#define MAX_LEVELS 32
/* Exported functions */
-void module_init (struct config_file *cfg);
+void module_init (struct rspamd_config *cfg);
void* before_connect (void);
gboolean parse_line (const char *line, size_t len, char **output, void *user_data);
void after_connect (char **output, char **log_line, void *user_data);
@@ -67,10 +67,10 @@ static prefix_tree_t *tree = NULL;
/* Implementation */
char *
-get_module_opt (struct config_file *cfg, char *module_name, char *opt_name)
+rspamd_config_get_module_opt (struct rspamd_config *cfg, char *module_name, char *opt_name)
{
GList *cur_opt;
- struct module_opt *cur;
+ struct rspamd_module_opt *cur;
cur_opt = g_hash_table_lookup (cfg->modules_opts, module_name);
if (cur_opt == NULL) {
@@ -89,11 +89,11 @@ get_module_opt (struct config_file *cfg, char *module_name, char *opt_name)
}
void
-module_init (struct config_file *cfg)
+module_init (struct rspamd_config *cfg)
{
char *value;
- if (cfg && (value = get_module_opt (cfg, "ipmark", "file")) != NULL) {
+ if (cfg && (value = rspamd_config_get_module_opt (cfg, "ipmark", "file")) != NULL) {
filename = g_strdup (value);
}
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index ac12c0909..073fc890d 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -75,9 +75,9 @@ static struct dkim_ctx *dkim_module_ctx = NULL;
static void dkim_symbol_callback (struct rspamd_task *task, void *unused);
/* Initialization */
-gint dkim_module_init (struct config_file *cfg, struct module_ctx **ctx);
-gint dkim_module_config (struct config_file *cfg);
-gint dkim_module_reconfig (struct config_file *cfg);
+gint dkim_module_init (struct rspamd_config *cfg, struct module_ctx **ctx);
+gint dkim_module_config (struct rspamd_config *cfg);
+gint dkim_module_reconfig (struct rspamd_config *cfg);
module_t dkim_module = {
"dkim",
@@ -87,7 +87,7 @@ module_t dkim_module = {
};
gint
-dkim_module_init (struct config_file *cfg, struct module_ctx **ctx)
+dkim_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
dkim_module_ctx = g_malloc0 (sizeof (struct dkim_ctx));
@@ -99,7 +99,7 @@ dkim_module_init (struct config_file *cfg, struct module_ctx **ctx)
}
gint
-dkim_module_config (struct config_file *cfg)
+dkim_module_config (struct rspamd_config *cfg)
{
const ucl_object_t *value;
gint res = TRUE;
@@ -108,50 +108,50 @@ dkim_module_config (struct config_file *cfg)
dkim_module_ctx->whitelist_ip = radix_tree_create ();
- if ((value = get_module_opt (cfg, "dkim", "symbol_reject")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "symbol_reject")) != NULL) {
dkim_module_ctx->symbol_reject = ucl_obj_tostring (value);
}
else {
dkim_module_ctx->symbol_reject = DEFAULT_SYMBOL_REJECT;
}
- if ((value = get_module_opt (cfg, "dkim", "symbol_tempfail")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "symbol_tempfail")) != NULL) {
dkim_module_ctx->symbol_tempfail = ucl_obj_tostring (value);
}
else {
dkim_module_ctx->symbol_tempfail = DEFAULT_SYMBOL_TEMPFAIL;
}
- if ((value = get_module_opt (cfg, "dkim", "symbol_allow")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "symbol_allow")) != NULL) {
dkim_module_ctx->symbol_allow = ucl_obj_tostring (value);
}
else {
dkim_module_ctx->symbol_allow = DEFAULT_SYMBOL_ALLOW;
}
- if ((value = get_module_opt (cfg, "dkim", "dkim_cache_size")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "dkim_cache_size")) != NULL) {
cache_size = ucl_obj_toint (value);
}
else {
cache_size = DEFAULT_CACHE_SIZE;
}
- if ((value = get_module_opt (cfg, "dkim", "dkim_cache_expire")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "dkim_cache_expire")) != NULL) {
cache_expire = ucl_obj_todouble (value);
}
else {
cache_expire = DEFAULT_CACHE_MAXAGE;
}
- if ((value = get_module_opt (cfg, "dkim", "time_jitter")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "time_jitter")) != NULL) {
dkim_module_ctx->time_jitter = ucl_obj_todouble (value);
}
else {
dkim_module_ctx->time_jitter = DEFAULT_TIME_JITTER;
}
- if ((value = get_module_opt (cfg, "dkim", "whitelist")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "whitelist")) != NULL) {
if (! add_map (cfg, ucl_obj_tostring (value),
"DKIM whitelist", read_radix_list, fin_radix_list,
(void **)&dkim_module_ctx->whitelist_ip)) {
msg_warn ("cannot load whitelist from %s", ucl_obj_tostring (value));
}
}
- if ((value = get_module_opt (cfg, "dkim", "domains")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "domains")) != NULL) {
if (! add_map (cfg, ucl_obj_tostring (value),
"DKIM domains", read_kv_list, fin_kv_list,
(void **)&dkim_module_ctx->dkim_domains)) {
@@ -161,19 +161,19 @@ dkim_module_config (struct config_file *cfg)
got_trusted = TRUE;
}
}
- if ((value = get_module_opt (cfg, "dkim", "strict_multiplier")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "strict_multiplier")) != NULL) {
dkim_module_ctx->strict_multiplier = ucl_obj_toint (value);
}
else {
dkim_module_ctx->strict_multiplier = 1;
}
- if ((value = get_module_opt (cfg, "dkim", "trusted_only")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "trusted_only")) != NULL) {
dkim_module_ctx->trusted_only = ucl_obj_toboolean (value);
}
else {
dkim_module_ctx->trusted_only = FALSE;
}
- if ((value = get_module_opt (cfg, "dkim", "skip_multi")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "dkim", "skip_multi")) != NULL) {
dkim_module_ctx->skip_multi = ucl_obj_toboolean (value);
}
else {
@@ -201,7 +201,7 @@ dkim_module_config (struct config_file *cfg)
}
gint
-dkim_module_reconfig (struct config_file *cfg)
+dkim_module_reconfig (struct rspamd_config *cfg)
{
rspamd_mempool_delete (dkim_module_ctx->dkim_pool);
radix_tree_free (dkim_module_ctx->whitelist_ip);
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 4f7a4c3d7..5dfd1881a 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -135,9 +135,9 @@ static gboolean fuzzy_delete_handler (gchar **args,
struct controller_session *session);
/* Initialization */
-gint fuzzy_check_module_init (struct config_file *cfg, struct module_ctx **ctx);
-gint fuzzy_check_module_config (struct config_file *cfg);
-gint fuzzy_check_module_reconfig (struct config_file *cfg);
+gint fuzzy_check_module_init (struct rspamd_config *cfg, struct module_ctx **ctx);
+gint fuzzy_check_module_config (struct rspamd_config *cfg);
+gint fuzzy_check_module_reconfig (struct rspamd_config *cfg);
module_t fuzzy_check_module = {
"fuzzy_check",
@@ -147,7 +147,7 @@ module_t fuzzy_check_module = {
};
static void
-parse_flags (struct fuzzy_rule *rule, struct config_file *cfg, const ucl_object_t *val)
+parse_flags (struct fuzzy_rule *rule, struct rspamd_config *cfg, const ucl_object_t *val)
{
const ucl_object_t *elt;
struct fuzzy_mapping *map;
@@ -255,7 +255,7 @@ parse_servers_string (struct fuzzy_rule *rule, const gchar *str)
g_strstrip (strvec[i]);
cur = &rule->servers[rule->servers_num];
- if (parse_host_port (fuzzy_module_ctx->fuzzy_pool, strvec[i], &cur->addr, &cur->port)) {
+ if (rspamd_parse_host_port (fuzzy_module_ctx->fuzzy_pool, strvec[i], &cur->addr, &cur->port)) {
if (cur->port == 0) {
cur->port = DEFAULT_PORT;
}
@@ -323,7 +323,7 @@ fuzzy_rule_new (const char *default_symbol, rspamd_mempool_t *pool)
}
static gint
-fuzzy_parse_rule (struct config_file *cfg, const ucl_object_t *obj)
+fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj)
{
const ucl_object_t *value, *cur;
struct fuzzy_rule *rule;
@@ -388,7 +388,7 @@ fuzzy_parse_rule (struct config_file *cfg, const ucl_object_t *obj)
}
gint
-fuzzy_check_module_init (struct config_file *cfg, struct module_ctx **ctx)
+fuzzy_check_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
fuzzy_module_ctx = g_malloc0 (sizeof (struct fuzzy_ctx));
@@ -400,50 +400,50 @@ fuzzy_check_module_init (struct config_file *cfg, struct module_ctx **ctx)
}
gint
-fuzzy_check_module_config (struct config_file *cfg)
+fuzzy_check_module_config (struct rspamd_config *cfg)
{
const ucl_object_t *value, *cur;
gint res = TRUE;
- if ((value = get_module_opt (cfg, "fuzzy_check", "symbol")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "fuzzy_check", "symbol")) != NULL) {
fuzzy_module_ctx->default_symbol = ucl_obj_tostring (value);
}
else {
fuzzy_module_ctx->default_symbol = DEFAULT_SYMBOL;
}
- if ((value = get_module_opt (cfg, "fuzzy_check", "min_length")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "fuzzy_check", "min_length")) != NULL) {
fuzzy_module_ctx->min_hash_len = ucl_obj_toint (value);
}
else {
fuzzy_module_ctx->min_hash_len = 0;
}
- if ((value = get_module_opt (cfg, "fuzzy_check", "min_bytes")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "fuzzy_check", "min_bytes")) != NULL) {
fuzzy_module_ctx->min_bytes = ucl_obj_toint (value);
}
else {
fuzzy_module_ctx->min_bytes = 0;
}
- if ((value = get_module_opt (cfg, "fuzzy_check", "min_height")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "fuzzy_check", "min_height")) != NULL) {
fuzzy_module_ctx->min_height = ucl_obj_toint (value);
}
else {
fuzzy_module_ctx->min_height = 0;
}
- if ((value = get_module_opt (cfg, "fuzzy_check", "min_width")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "fuzzy_check", "min_width")) != NULL) {
fuzzy_module_ctx->min_width = ucl_obj_toint (value);
}
else {
fuzzy_module_ctx->min_width = 0;
}
- if ((value = get_module_opt (cfg, "fuzzy_check", "timeout")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "fuzzy_check", "timeout")) != NULL) {
fuzzy_module_ctx->io_timeout = ucl_obj_todouble (value) * 1000;
}
else {
fuzzy_module_ctx->io_timeout = DEFAULT_IO_TIMEOUT;
}
- if ((value = get_module_opt (cfg, "fuzzy_check", "whitelist")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "fuzzy_check", "whitelist")) != NULL) {
fuzzy_module_ctx->whitelist = radix_tree_create ();
if (!add_map (cfg, ucl_obj_tostring (value),
"Fuzzy whitelist", read_radix_list, fin_radix_list,
@@ -455,7 +455,7 @@ fuzzy_check_module_config (struct config_file *cfg)
fuzzy_module_ctx->whitelist = NULL;
}
- if ((value = get_module_opt (cfg, "fuzzy_check", "rule")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "fuzzy_check", "rule")) != NULL) {
LL_FOREACH (value, cur) {
if (fuzzy_parse_rule (cfg, cur) == -1) {
return -1;
@@ -478,7 +478,7 @@ fuzzy_check_module_config (struct config_file *cfg)
}
gint
-fuzzy_check_module_reconfig (struct config_file *cfg)
+fuzzy_check_module_reconfig (struct rspamd_config *cfg)
{
rspamd_mempool_delete (fuzzy_module_ctx->fuzzy_pool);
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index ddc03db38..55ea910bd 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -68,7 +68,7 @@ struct regexp_json_buf {
gchar *buf;
gchar *pos;
size_t buflen;
- struct config_file *cfg;
+ struct rspamd_config *cfg;
};
/* Lua regexp module for checking rspamd regexps */
@@ -99,9 +99,9 @@ static void process_regexp_item (struct rspamd_task *task, vo
/* Initialization */
-gint regexp_module_init (struct config_file *cfg, struct module_ctx **ctx);
-gint regexp_module_config (struct config_file *cfg);
-gint regexp_module_reconfig (struct config_file *cfg);
+gint regexp_module_init (struct rspamd_config *cfg, struct module_ctx **ctx);
+gint regexp_module_config (struct rspamd_config *cfg);
+gint regexp_module_reconfig (struct rspamd_config *cfg);
module_t regexp_module = {
"regexp",
@@ -505,7 +505,7 @@ json_regexp_fin_cb (rspamd_mempool_t * pool, struct map_cb_data *data)
/* Init function */
gint
-regexp_module_init (struct config_file *cfg, struct module_ctx **ctx)
+regexp_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
regexp_module_ctx = g_malloc (sizeof (struct regexp_ctx));
@@ -537,7 +537,7 @@ regexp_module_init (struct config_file *cfg, struct module_ctx **ctx)
* SYMBOL:statfile:weight
*/
void
-parse_autolearn_param (const gchar *param, const gchar *value, struct config_file *cfg)
+parse_autolearn_param (const gchar *param, const gchar *value, struct rspamd_config *cfg)
{
struct autolearn_data *d;
gchar *p;
@@ -564,7 +564,7 @@ parse_autolearn_param (const gchar *param, const gchar *value, struct config_fil
}
gint
-regexp_module_config (struct config_file *cfg)
+regexp_module_config (struct rspamd_config *cfg)
{
struct regexp_module_item *cur_item;
const ucl_object_t *sec, *value;
@@ -629,7 +629,7 @@ regexp_module_config (struct config_file *cfg)
}
gint
-regexp_module_reconfig (struct config_file *cfg)
+regexp_module_reconfig (struct rspamd_config *cfg)
{
rspamd_mempool_delete (regexp_module_ctx->regexp_pool);
regexp_module_ctx->regexp_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index 19aaa44e5..32558f3a1 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -66,9 +66,9 @@ static GList * spf_record_copy (GList *addrs);
static void spf_record_destroy (gpointer list);
/* Initialization */
-gint spf_module_init (struct config_file *cfg, struct module_ctx **ctx);
-gint spf_module_config (struct config_file *cfg);
-gint spf_module_reconfig (struct config_file *cfg);
+gint spf_module_init (struct rspamd_config *cfg, struct module_ctx **ctx);
+gint spf_module_config (struct rspamd_config *cfg);
+gint spf_module_reconfig (struct rspamd_config *cfg);
module_t spf_module = {
"spf",
@@ -78,7 +78,7 @@ module_t spf_module = {
};
gint
-spf_module_init (struct config_file *cfg, struct module_ctx **ctx)
+spf_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
spf_module_ctx = g_malloc (sizeof (struct spf_ctx));
@@ -91,7 +91,7 @@ spf_module_init (struct config_file *cfg, struct module_ctx **ctx)
gint
-spf_module_config (struct config_file *cfg)
+spf_module_config (struct rspamd_config *cfg)
{
const ucl_object_t *value;
gint res = TRUE;
@@ -99,37 +99,37 @@ spf_module_config (struct config_file *cfg)
spf_module_ctx->whitelist_ip = radix_tree_create ();
- if ((value = get_module_opt (cfg, "spf", "symbol_fail")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "spf", "symbol_fail")) != NULL) {
spf_module_ctx->symbol_fail = ucl_obj_tostring (value);
}
else {
spf_module_ctx->symbol_fail = DEFAULT_SYMBOL_FAIL;
}
- if ((value = get_module_opt (cfg, "spf", "symbol_softfail")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "spf", "symbol_softfail")) != NULL) {
spf_module_ctx->symbol_softfail = ucl_obj_tostring (value);
}
else {
spf_module_ctx->symbol_softfail = DEFAULT_SYMBOL_SOFTFAIL;
}
- if ((value = get_module_opt (cfg, "spf", "symbol_allow")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "spf", "symbol_allow")) != NULL) {
spf_module_ctx->symbol_allow = ucl_obj_tostring (value);
}
else {
spf_module_ctx->symbol_allow = DEFAULT_SYMBOL_ALLOW;
}
- if ((value = get_module_opt (cfg, "spf", "spf_cache_size")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "spf", "spf_cache_size")) != NULL) {
cache_size = ucl_obj_toint (value);
}
else {
cache_size = DEFAULT_CACHE_SIZE;
}
- if ((value = get_module_opt (cfg, "spf", "spf_cache_expire")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "spf", "spf_cache_expire")) != NULL) {
cache_expire = ucl_obj_toint (value);
}
else {
cache_expire = DEFAULT_CACHE_MAXAGE;
}
- if ((value = get_module_opt (cfg, "spf", "whitelist")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "spf", "whitelist")) != NULL) {
if (! add_map (cfg, ucl_obj_tostring (value),
"SPF whitelist", read_radix_list, fin_radix_list,
(void **)&spf_module_ctx->whitelist_ip)) {
@@ -148,7 +148,7 @@ spf_module_config (struct config_file *cfg)
}
gint
-spf_module_reconfig (struct config_file *cfg)
+spf_module_reconfig (struct rspamd_config *cfg)
{
rspamd_mempool_delete (spf_module_ctx->spf_pool);
radix_tree_free (spf_module_ctx->whitelist_ip);
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 59c13b450..41873e15d 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -74,9 +74,9 @@ surbl_error_quark (void)
}
/* Initialization */
-gint surbl_module_init (struct config_file *cfg, struct module_ctx **ctx);
-gint surbl_module_config (struct config_file *cfg);
-gint surbl_module_reconfig (struct config_file *cfg);
+gint surbl_module_init (struct rspamd_config *cfg, struct module_ctx **ctx);
+gint surbl_module_config (struct rspamd_config *cfg);
+gint surbl_module_reconfig (struct rspamd_config *cfg);
module_t surbl_module = {
"surbl",
@@ -207,7 +207,7 @@ fin_redirectors_list (rspamd_mempool_t * pool, struct map_cb_data *data)
}
gint
-surbl_module_init (struct config_file *cfg, struct module_ctx **ctx)
+surbl_module_init (struct rspamd_config *cfg, struct module_ctx **ctx)
{
surbl_module_ctx = g_malloc (sizeof (struct surbl_ctx));
@@ -241,7 +241,7 @@ surbl_module_init (struct config_file *cfg, struct module_ctx **ctx)
* Register virtual symbols for suffixes with bit wildcard
*/
static void
-register_bit_symbols (struct config_file *cfg, struct suffix_item *suffix)
+register_bit_symbols (struct rspamd_config *cfg, struct suffix_item *suffix)
{
GList *cur;
struct surbl_bit_item *bit;
@@ -261,7 +261,7 @@ register_bit_symbols (struct config_file *cfg, struct suffix_item *suffix)
}
gint
-surbl_module_config (struct config_file *cfg)
+surbl_module_config (struct rspamd_config *cfg)
{
GList *cur_opt;
struct suffix_item *new_suffix, *cur_suffix = NULL;
@@ -274,7 +274,7 @@ surbl_module_config (struct config_file *cfg)
gint i, idx;
- if ((value = get_module_opt (cfg, "surbl", "redirector")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "surbl", "redirector")) != NULL) {
i = 0;
LL_FOREACH (value, cur) {
i ++;
@@ -285,7 +285,7 @@ surbl_module_config (struct config_file *cfg)
LL_FOREACH (value, cur) {
redir_val = ucl_obj_tostring (cur);
surbl_module_ctx->redirectors[idx].up.priority = 100;
- if (! parse_host_port_priority (surbl_module_ctx->surbl_pool,
+ if (! rspamd_parse_host_port_priority (surbl_module_ctx->surbl_pool,
redir_val, &surbl_module_ctx->redirectors[idx].addr,
&surbl_module_ctx->redirectors[idx].port,
&surbl_module_ctx->redirectors[idx].up.priority)) {
@@ -304,50 +304,50 @@ surbl_module_config (struct config_file *cfg)
surbl_module_ctx->redirectors_number = idx;
surbl_module_ctx->use_redirector = (surbl_module_ctx->redirectors_number != 0);
}
- if ((value = get_module_opt (cfg, "surbl", "redirector_symbol")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "surbl", "redirector_symbol")) != NULL) {
surbl_module_ctx->redirector_symbol = ucl_obj_tostring (value);
register_virtual_symbol (&cfg->cache, surbl_module_ctx->redirector_symbol, 1.0);
}
else {
surbl_module_ctx->redirector_symbol = NULL;
}
- if ((value = get_module_opt (cfg, "surbl", "weight")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "surbl", "weight")) != NULL) {
surbl_module_ctx->weight = ucl_obj_toint (value);
}
else {
surbl_module_ctx->weight = DEFAULT_SURBL_WEIGHT;
}
- if ((value = get_module_opt (cfg, "surbl", "url_expire")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "surbl", "url_expire")) != NULL) {
surbl_module_ctx->url_expire = ucl_obj_todouble (value);
}
else {
surbl_module_ctx->url_expire = DEFAULT_SURBL_URL_EXPIRE;
}
- if ((value = get_module_opt (cfg, "surbl", "redirector_connect_timeout")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "surbl", "redirector_connect_timeout")) != NULL) {
surbl_module_ctx->connect_timeout = ucl_obj_todouble (value);
}
else {
surbl_module_ctx->connect_timeout = DEFAULT_REDIRECTOR_CONNECT_TIMEOUT;
}
- if ((value = get_module_opt (cfg, "surbl", "redirector_read_timeout")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "surbl", "redirector_read_timeout")) != NULL) {
surbl_module_ctx->read_timeout = ucl_obj_todouble (value);
}
else {
surbl_module_ctx->read_timeout = DEFAULT_REDIRECTOR_READ_TIMEOUT;
}
- if ((value = get_module_opt (cfg, "surbl", "redirector_hosts_map")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "surbl", "redirector_hosts_map")) != NULL) {
add_map (cfg, ucl_obj_tostring (value),
"SURBL redirectors list", read_redirectors_list, fin_redirectors_list,
(void **)&surbl_module_ctx->redirector_hosts);
}
- if ((value = get_module_opt (cfg, "surbl", "max_urls")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "surbl", "max_urls")) != NULL) {
surbl_module_ctx->max_urls = ucl_obj_toint (value);
}
else {
surbl_module_ctx->max_urls = DEFAULT_SURBL_MAX_URLS;
}
- if ((value = get_module_opt (cfg, "surbl", "exceptions")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "surbl", "exceptions")) != NULL) {
if (add_map (cfg, ucl_obj_tostring (value),
"SURBL exceptions list", read_exceptions_list, fin_exceptions_list,
(void **)&surbl_module_ctx->exceptions)) {
@@ -355,7 +355,7 @@ surbl_module_config (struct config_file *cfg)
ucl_obj_tostring (value) + sizeof ("file://") - 1);
}
}
- if ((value = get_module_opt (cfg, "surbl", "whitelist")) != NULL) {
+ if ((value = rspamd_config_get_module_opt (cfg, "surbl", "whitelist")) != NULL) {
if (add_map (cfg, ucl_obj_tostring (value),
"SURBL whitelist", read_host_list, fin_host_list,
(void **)&surbl_module_ctx->whitelist)) {
@@ -364,7 +364,7 @@ surbl_module_config (struct config_file *cfg)
}
}
- value = get_module_opt (cfg, "surbl", "rule");
+ value = rspamd_config_get_module_opt (cfg, "surbl", "rule");
if (value != NULL && value->type == UCL_OBJECT) {
LL_FOREACH (value, cur_rule) {
cur = ucl_obj_get_key (cur_rule, "suffix");
@@ -439,7 +439,7 @@ surbl_module_config (struct config_file *cfg)
}
gint
-surbl_module_reconfig (struct config_file *cfg)
+surbl_module_reconfig (struct rspamd_config *cfg)
{
/* Delete pool and objects */
rspamd_mempool_delete (surbl_module_ctx->surbl_pool);
diff --git a/src/smtp.c b/src/smtp.c
index 166b4eba4..dc3ff6089 100644
--- a/src/smtp.c
+++ b/src/smtp.c
@@ -49,7 +49,7 @@
static gboolean smtp_write_socket (void *arg);
/* Init functions */
-gpointer init_smtp (struct config_file *cfg);
+gpointer init_smtp (struct rspamd_config *cfg);
void start_smtp (struct rspamd_worker *worker);
worker_t smtp_worker = {
@@ -801,7 +801,7 @@ make_capabilities (struct smtp_worker_ctx *ctx, const gchar *line)
}
gpointer
-init_smtp (struct config_file *cfg)
+init_smtp (struct rspamd_config *cfg)
{
struct smtp_worker_ctx *ctx;
GQuark type;
@@ -904,7 +904,7 @@ start_smtp (struct rspamd_worker *worker)
{
struct smtp_worker_ctx *ctx = worker->ctx;
- ctx->ev_base = prepare_worker (worker, "smtp_worker", accept_socket);
+ ctx->ev_base = rspamd_prepare_worker (worker, "smtp_worker", accept_socket);
/* Set smtp options */
if ( !config_smtp_worker (worker)) {
diff --git a/src/smtp.h b/src/smtp.h
index 0f47cf0ee..482f5243d 100644
--- a/src/smtp.h
+++ b/src/smtp.h
@@ -67,7 +67,7 @@ enum rspamd_smtp_state {
struct smtp_session {
struct smtp_worker_ctx *ctx;
- struct config_file *cfg;
+ struct rspamd_config *cfg;
rspamd_mempool_t *pool;
enum rspamd_smtp_state state;
diff --git a/src/smtp_proxy.c b/src/smtp_proxy.c
index 0a3475795..f5f7856a1 100644
--- a/src/smtp_proxy.c
+++ b/src/smtp_proxy.c
@@ -50,7 +50,7 @@
/* Init functions */
-gpointer init_smtp_proxy (struct config_file *cfg);
+gpointer init_smtp_proxy (struct rspamd_config *cfg);
void start_smtp_proxy (struct rspamd_worker *worker);
worker_t smtp_proxy_worker = {
@@ -894,7 +894,7 @@ accept_socket (gint fd, short what, void *arg)
}
gpointer
-init_smtp_proxy (struct config_file *cfg)
+init_smtp_proxy (struct rspamd_config *cfg)
{
struct smtp_proxy_ctx *ctx;
GQuark type;
@@ -980,7 +980,7 @@ start_smtp_proxy (struct rspamd_worker *worker)
{
struct smtp_proxy_ctx *ctx = worker->ctx;
- ctx->ev_base = prepare_worker (worker, "smtp_proxy", accept_socket);
+ ctx->ev_base = rspamd_prepare_worker (worker, "smtp_proxy", accept_socket);
/* Set smtp options */
if ( !config_smtp_proxy_worker (worker)) {
diff --git a/src/webui.c b/src/webui.c
index 9a53cb05b..852cf2e11 100644
--- a/src/webui.c
+++ b/src/webui.c
@@ -70,7 +70,7 @@
#define COLOR_REJECT "#CB4B4B"
#define COLOR_TOTAL "#9440ED"
-gpointer init_webui_worker (struct config_file *cfg);
+gpointer init_webui_worker (struct rspamd_config *cfg);
void start_webui_worker (struct rspamd_worker *worker);
worker_t webui_worker = {
@@ -106,7 +106,7 @@ struct rspamd_webui_worker_ctx {
/* Main server */
struct rspamd_main *srv;
/* Configuration */
- struct config_file *cfg;
+ struct rspamd_config *cfg;
/* SSL cert */
gchar *ssl_cert;
/* SSL private key */
@@ -126,7 +126,7 @@ struct rspamd_webui_session {
struct rspamd_webui_worker_ctx *ctx;
rspamd_mempool_t *pool;
struct rspamd_task *task;
- struct classifier_config *cl;
+ struct rspamd_classifier_config *cl;
rspamd_inet_addr_t from_addr;
gboolean is_spam;
};
@@ -331,8 +331,8 @@ rspamd_webui_handle_symbols (struct rspamd_http_connection_entry *conn_ent,
{
struct rspamd_webui_session *session = conn_ent->ud;
GList *cur_gr, *cur_sym;
- struct symbols_group *gr;
- struct symbol_def *sym;
+ struct rspamd_symbols_group *gr;
+ struct rspamd_symbol_def *sym;
ucl_object_t *obj, *top, *sym_obj;
if (!rspamd_webui_check_password (conn_ent, session, msg, FALSE)) {
@@ -870,7 +870,7 @@ rspamd_webui_handle_learn_common (struct rspamd_http_connection_entry *conn_ent,
{
struct rspamd_webui_session *session = conn_ent->ud;
struct rspamd_webui_worker_ctx *ctx;
- struct classifier_config *cl;
+ struct rspamd_classifier_config *cl;
struct rspamd_task *task;
const gchar *classifier;
@@ -890,7 +890,7 @@ rspamd_webui_handle_learn_common (struct rspamd_http_connection_entry *conn_ent,
classifier = "bayes";
}
- cl = find_classifier_conf (ctx->cfg, classifier);
+ cl = rspamd_config_find_classifier (ctx->cfg, classifier);
if (cl == NULL) {
rspamd_webui_send_error (conn_ent, 400, "Classifier not found");
return 0;
@@ -1304,9 +1304,9 @@ rspamd_webui_handle_stat_common (struct rspamd_http_connection_entry *conn_ent,
guint64 used, total, rev, ham = 0, spam = 0;
time_t ti;
rspamd_mempool_stat_t mem_st;
- struct classifier_config *ccf;
+ struct rspamd_classifier_config *ccf;
stat_file_t *statfile;
- struct statfile *st;
+ struct rspamd_statfile_config *st;
GList *cur_cl, *cur_st;
struct rspamd_stat *stat, stat_copy;
@@ -1563,7 +1563,7 @@ rspamd_webui_accept_socket (gint fd, short what, void *arg)
}
gpointer
-init_webui_worker (struct config_file *cfg)
+init_webui_worker (struct rspamd_config *cfg)
{
struct rspamd_webui_worker_ctx *ctx;
GQuark type;
@@ -1616,7 +1616,7 @@ start_webui_worker (struct rspamd_worker *worker)
{
struct rspamd_webui_worker_ctx *ctx = worker->ctx;
- ctx->ev_base = prepare_worker (worker, "controller", rspamd_webui_accept_socket);
+ ctx->ev_base = rspamd_prepare_worker (worker, "controller", rspamd_webui_accept_socket);
msec_to_tv (ctx->timeout, &ctx->io_tv);
ctx->start_time = time (NULL);
@@ -1626,7 +1626,7 @@ start_webui_worker (struct rspamd_worker *worker)
if (ctx->secure_ip != NULL) {
if (!add_map (worker->srv->cfg, ctx->secure_ip, "Allow webui access from the specified IP",
read_radix_list, fin_radix_list, (void **)&ctx->secure_map)) {
- if (!rspamd_parse_ip_list (ctx->secure_ip, &ctx->secure_map)) {
+ if (!rspamd_config_parse_ip_list (ctx->secure_ip, &ctx->secure_map)) {
msg_warn ("cannot load or parse ip list from '%s'", ctx->secure_ip);
}
}
diff --git a/src/worker.c b/src/worker.c
index 4ed990fb0..aca667a68 100644
--- a/src/worker.c
+++ b/src/worker.c
@@ -46,7 +46,7 @@
/* 60 seconds for worker's IO */
#define DEFAULT_WORKER_IO_TIMEOUT 60000
-gpointer init_worker (struct config_file *cfg);
+gpointer init_worker (struct rspamd_config *cfg);
void start_worker (struct rspamd_worker *worker);
worker_t normal_worker = {
@@ -234,7 +234,7 @@ accept_socket (gint fd, short what, void *arg)
}
gpointer
-init_worker (struct config_file *cfg)
+init_worker (struct rspamd_config *cfg)
{
struct rspamd_worker_ctx *ctx;
GQuark type;
@@ -288,7 +288,7 @@ start_worker (struct rspamd_worker *worker)
GError *err = NULL;
struct lua_locked_state *nL;
- ctx->ev_base = prepare_worker (worker, "normal", accept_socket);
+ ctx->ev_base = rspamd_prepare_worker (worker, "normal", accept_socket);
msec_to_tv (ctx->timeout, &ctx->io_tv);
start_map_watch (worker->srv->cfg, ctx->ev_base);
diff --git a/test/rspamd_dkim_test.c b/test/rspamd_dkim_test.c
index a0c6332e4..bd2508262 100644
--- a/test/rspamd_dkim_test.c
+++ b/test/rspamd_dkim_test.c
@@ -65,12 +65,12 @@ rspamd_dkim_test_func ()
rspamd_dkim_key_t *key;
rspamd_mempool_t *pool;
struct rspamd_dns_resolver *resolver;
- struct config_file *cfg;
+ struct rspamd_config *cfg;
GError *err = NULL;
struct rspamd_async_session *s;
- cfg = (struct config_file *)g_malloc (sizeof (struct config_file));
- bzero (cfg, sizeof (struct config_file));
+ cfg = (struct rspamd_config *)g_malloc (sizeof (struct rspamd_config));
+ bzero (cfg, sizeof (struct rspamd_config));
cfg->cfg_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
cfg->dns_retransmits = 10;
cfg->dns_timeout = 1000;
diff --git a/test/rspamd_dns_test.c b/test/rspamd_dns_test.c
index 897ed4253..781b39503 100644
--- a/test/rspamd_dns_test.c
+++ b/test/rspamd_dns_test.c
@@ -66,13 +66,13 @@ void
rspamd_dns_test_func ()
{
struct rspamd_dns_resolver *resolver;
- struct config_file *cfg;
+ struct rspamd_config *cfg;
rspamd_mempool_t *pool;
struct rspamd_async_session *s;
struct in_addr ina;
- cfg = (struct config_file *)g_malloc (sizeof (struct config_file));
- bzero (cfg, sizeof (struct config_file));
+ cfg = (struct rspamd_config *)g_malloc (sizeof (struct rspamd_config));
+ bzero (cfg, sizeof (struct rspamd_config));
cfg->cfg_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
cfg->dns_retransmits = 10;
cfg->dns_timeout = 1000;
diff --git a/test/rspamd_test_suite.c b/test/rspamd_test_suite.c
index fedcfd3eb..7bd86d483 100644
--- a/test/rspamd_test_suite.c
+++ b/test/rspamd_test_suite.c
@@ -11,7 +11,7 @@ worker_t *workers[] = { NULL };
int
main (int argc, char **argv)
{
- struct config_file *cfg;
+ struct rspamd_config *cfg;
g_test_init (&argc, &argv, NULL);
@@ -25,9 +25,9 @@ main (int argc, char **argv)
memset (rspamd_main, 0, sizeof (struct rspamd_main));
rspamd_main->server_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
- rspamd_main->cfg = (struct config_file *)g_malloc (sizeof (struct config_file));
+ rspamd_main->cfg = (struct rspamd_config *)g_malloc (sizeof (struct rspamd_config));
cfg = rspamd_main->cfg;
- bzero (cfg, sizeof (struct config_file));
+ bzero (cfg, sizeof (struct rspamd_config));
cfg->cfg_pool = rspamd_mempool_new (rspamd_mempool_suggest_size ());
base = event_init ();