]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Refactor config API.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 30 Apr 2014 12:26:51 +0000 (13:26 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 30 Apr 2014 12:26:51 +0000 (13:26 +0100)
64 files changed:
src/classifiers/bayes.c
src/classifiers/classifiers.h
src/classifiers/winnow.c
src/controller.c
src/fuzzy_storage.c
src/kvstorage_config.c
src/libmime/filter.c
src/libmime/filter.h
src/libmime/protocol.c
src/libmime/smtp_utils.c
src/libserver/binlog.c
src/libserver/binlog.h
src/libserver/cfg_file.h
src/libserver/cfg_rcl.c
src/libserver/cfg_rcl.h
src/libserver/cfg_utils.c
src/libserver/dns.c
src/libserver/dns.h
src/libserver/dynamic_cfg.c
src/libserver/dynamic_cfg.h
src/libserver/settings.c
src/libserver/settings.h
src/libserver/statfile.c
src/libserver/statfile.h
src/libserver/statfile_sync.c
src/libserver/statfile_sync.h
src/libserver/symbols_cache.c
src/libserver/symbols_cache.h
src/libserver/task.h
src/libserver/worker_util.c
src/libserver/worker_util.h
src/libutil/logger.c
src/libutil/logger.h
src/libutil/map.c
src/libutil/map.h
src/libutil/util.c
src/libutil/util.h
src/lua/lua_cfg_file.c
src/lua/lua_classifier.c
src/lua/lua_common.c
src/lua/lua_common.h
src/lua/lua_config.c
src/lua/lua_dns.c
src/lua/lua_task.c
src/lua/lua_upstream.c
src/lua_worker.c
src/main.c
src/main.h
src/plugins/chartable.c
src/plugins/custom/ipmark/ipmark.c
src/plugins/custom/regmark/regmark.c
src/plugins/dkim_check.c
src/plugins/fuzzy_check.c
src/plugins/regexp.c
src/plugins/spf.c
src/plugins/surbl.c
src/smtp.c
src/smtp.h
src/smtp_proxy.c
src/webui.c
src/worker.c
test/rspamd_dkim_test.c
test/rspamd_dns_test.c
test/rspamd_test_suite.c

index 9c81b237039f36d7538fae702b2e83e3ffcb908e..a8a18f5fff9d1b6e4eae35dde9462d9adda5cb6e 100644 (file)
@@ -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 {
index 3f7b755f41d7e9279d57b0fdeeccaf651fe9558f..2b36d8c020398fb507294c80ebf875bba37023cb 100644 (file)
 /* 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);
index 91d06aaf4f679a9ed532883a06f083b87532fe76..1fe8f16d2caeda6a7f46c6448af6124e4558c78b 100644 (file)
@@ -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;
index 4665e4718b8457a9d5ce2ae5fdc7302f1be9018d..05b1794cd9522cc71e7168ee1ded9e2d5ab376cf 100644 (file)
@@ -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);
index 555e1d19649d8b342d69234542f65ee2dd69e9af..7fca37566f2852d4d4ce9e0c7bb31aea6a2f175d 100644 (file)
@@ -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);
                        }
                }
index d7bb8cedd2b1c52696b4a324ed44e7b5dd8631ba..362a47f490d581ab3fa87ed5c42a7ae3d996c4e2 100644 (file)
@@ -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) {
index 8144439e095a836060418bb61edf244abb945214..9932b814d1a05aa729a87e344c8e162ccfef50bc 100644 (file)
@@ -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;
index 258bd9447f5b069afd72c1a3b6b3fa592b01109c..7c3f3e51edc1736f7448eb95170613ac00f1c26c 100644 (file)
@@ -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
index 1b7bdf42fb2c5d3caa491e1fd35e0b004e705553..57ef9fe42bcaf67342ed63cd95612ccb50183cec 100644 (file)
@@ -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);
index 5178de9dd0a216b4ca76f6cbdf5f9432b3e15fd0..5d8f94f64075769d4a006438b024d082c253208b 100644 (file)
@@ -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;
                        }
index f085a7de06e6ee61c7efa425734db292ac28d4ee..ec191eac7b4ad51d756b54bde9215bd066c997f2 100644 (file)
@@ -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;
 
index 9e1a786d3d7357d774eed3e91ef8743d281b00f8..6b77a7613117aa25e076ec31732eca5372e8f584 100644 (file)
@@ -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
index 6ecb441fd091920b897eb9ad5a20aa785f21989d..ae809ea257ac80740e44377c77e61dc5bb816fa1 100644 (file)
@@ -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 */
 /* 
index 37b554dec877a99b56d8aa14a53e9e9a69f0e41e..be9f635937645113143ad46416be419f08ab2e8b 100644 (file)
@@ -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;
index 99839d1ea61451bc15db7ac2f28fea7e08644621..6db0b0d81b1405c397292b69bb410c4f04710b6a 100644 (file)
@@ -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_ */
index 920de94e41a8758bb294ef94364bc97ba4891f55..120128f5ec41573b3870bdeb02afd3dbea10607c 100644 (file)
@@ -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;
index e20cca9df52cde7e7caede07da24540485e729e0..8d18ffc06abe2f8eac32154cc28e01432e452846 100644 (file)
@@ -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;
index 26ae71387c22bf76e0e9c9716fab143e33fef4fd..7b3bbd208828d4317781b180e6c78f50324196ef 100644 (file)
@@ -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
index 7f5e8530d64cd3cd7563b2a3634a69947d759cf4..d0dabef679171fc6a6cedbb557be34ba49160d23 100644 (file)
@@ -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;
index b65d7aa9a2af3fefedbd50efb43038f7fafb0a7f..a8cb02ae50d0a2f71dfa053f525bd4d9d878f114 100644 (file)
  * 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_ */
index c3292c8ab66c604c2d964e6a44e9a8f77d43a37a..ca6a9c7739a45ac8184ec9e291a3ce8258f67c0c 100644 (file)
@@ -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);
index 3617000943d31ed6e9db53cadd9902518fad3b25..6bdba9f4a63085abd321c69310f3525bd131aed7 100644 (file)
@@ -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
index 4c1cc13fb6532cbadead1cbcc310a07d2d7941ec..a993fd1168e77bf07bee783c3ad8a60fca0574a7 100644 (file)
@@ -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;
index 5786c4927fc6b8cd387946784f11cb57b990c15c..3ad5f13210dbd804bdaded3abf2e3fe34cf1ae72 100644 (file)
@@ -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
index 6b545af17044a982951ce34b67f1851e430f7af2..1121658fa96253d70d9efe3afcff53c251a8aa9b 100644 (file)
@@ -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
index b3abb8b9166e67ec62b9b3a7933e494434e76f62..bcaeb3bb5dc852e106145112419751dfa8e8a52d 100644 (file)
@@ -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
index dfca57c669f20e292c33252646ad05187781eab0..b0ce7d872b287f062133fa17424e122c057b9f7a 100644 (file)
@@ -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;
index bb2100fc1c40d5db41cca9f2a08144c96feb7403..b3835824dc83af09c8f470113c46b2912372c84e 100644 (file)
@@ -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
index 0891dc6e236b360041aa2c4c6c56dcecf517c107..1d2b299ec2c6416a47df4a7973606ce4df7c7b0c 100644 (file)
@@ -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                                                       */
index 5507cdb7c8a748f4ae1744be402e73f979b9d364..e8c97f20a0c8fb5e797b21c5ecc37f1aa681c8ce 100644 (file)
@@ -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;
index d88b93a8ac6223dc70cc03dc0464dcebcbae752a..67ad9e83cd4fa952d252eddc85949890e3f90705 100644 (file)
  * @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_ */
index 01814d24dd55eb8cc1b02b77d7189219e4b8eea8..47e308ecd5b0c99b7c94d775cffc418019341075 100644 (file)
@@ -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;
index b0766b938fc3f9bfee7f8985bc386829ba63a457..4b1c7441096b1db0be5ed2e4f7aafa1b3d81bff5 100644 (file)
@@ -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
  */
index 703622585a16a7b3471beee86e9dff53f049d288..ffe3a1e6f78ff11bb25005d37439d30d5b12988c 100644 (file)
@@ -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;
index 1f34cdcc0ec41312819f30e752ed5d90040f7af0..ddb9882e4d966d54fb7d376002c11bd05d84e2ff 100644 (file)
@@ -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);
 
index 03b38e087f306177967e186161b0fa55240adaf6..ec63cabb97581e22598c4a694513c0efa67a649b 100644 (file)
@@ -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];
index dfa34a458e5fc267a65aafa6138fae03448a07c6..a142f15fbf39cb6f46f1c63d1e351c486856214a 100644 (file)
@@ -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
index 8325db1072a64ccd8a6d57fb7e44032701a4f36e..fb65f1d376b86f40e41c71baa11d51e32a108806 100644 (file)
@@ -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;
index 1e33f704d180a9a89905a6f9f913b31994afe6e0..d227fc5da409eed3e14946186f86251af5ae02fb 100644 (file)
@@ -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;
 }
 
 
index f7912a722286385edff93d1fa6d808ade1a09d31..349cf09b5f37e95026d4c98312ad9b6fa2526bdd 100644 (file)
@@ -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;
index f9d97724443c161ab16517aa652450b5476b054e..7f0f12f4253e722b188ea35084fbefaec824fbef 100644 (file)
@@ -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);
index d922cac471b387b21c6124bbe735331daf1ff81c..0f047d3b198bd24eaab5b2d483690ce23d78faca 100644 (file)
@@ -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;
index 1944f0a205a381dd83a96a46eef089fac3f2635a..49ed205dabaa206db494437d12b0323d44a9b54b 100644 (file)
@@ -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 */
index 3d58e6a656cd50c5536b216dcbd4c31573c9ff16..0572226be6489941df36615490a6e9bd7095dace 100644 (file)
@@ -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;
 
index 855e9ff4accfbc06853b598043339d7d7260e81e..ee06fe2c1fc6257e3f64deef2bd06daec5bffa58 100644 (file)
@@ -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) {
index f661241295267f8c9e078641d0213ade2cb861ef..3bb3621e5b404b7d09ec3b48eccc23425caca128 100644 (file)
@@ -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;
index 0dea14d62fe82f35d9d197850ff32dc0615655fa..1c8f7fd411bab604791680c292719b1855388b86 100644 (file)
@@ -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);
 
index d93c00e09c71e75231feb32cb395fca8ae0e438e..9b4aebe38ea0911281d71d62f43e29772c850d7b 100644 (file)
@@ -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                                                       */
@@ -178,14 +178,6 @@ struct module_ctx {
        gint (*filter)(struct rspamd_task *task);                                       /**< pointer to headers process function                        */
 };
 
-/**
- * Common structure for C module
- */
-struct c_module {
-       const gchar *name;                                                                                      /**< name                                                                                       */
-       struct module_ctx *ctx;                                                                         /**< pointer to context                                                         */
-};
-
 /**
  * Register custom controller function
  */
index e330520638116e460736b3dd49fef9a66a1c27ef..c40f3e8e210c1b2c5dfc5ca58f4179994ad54104 100644 (file)
@@ -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);
index a40a945828a6fcc3b7bd1cf8e6c8ea7939e91017..1b4eb7f6ca98216033a5d83639418fa4ab59f21a 100644 (file)
@@ -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);
        }
        
index 35901f9aa0240c02dd050a8c71cc788f4ec371bf..6b3374f67cefaa16f2c118f3bbd92c601ac353a9 100644 (file)
@@ -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);
        }
        
index ac12c090932ed55b2798720efe97198f9f1b032c..073fc890d6a2e78b9541a199a2bd11b807e9e0c1 100644 (file)
@@ -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);
index 4f7a4c3d7ee2721c49c020fc3cad99576f8a4d4d..5dfd1881afa3665df27a429d6e7e8106b07cfa19 100644 (file)
@@ -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);
 
index ddc03db38efb98175dcc920ea62f9c8fe56fe870..55ea910bd07c6458d1d37aaa715abd029760b96d 100644 (file)
@@ -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 ());
index 19aaa44e55d9c93aff6472cce6711086ca2677c3..32558f3a118633d76a13d6b55932e337074741d4 100644 (file)
@@ -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);
index 59c13b4502094c9a307d64b474073dcabe9914ef..41873e15d41f405f92f3f91241f53d4cd35bb3bb 100644 (file)
@@ -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);
index 166b4eba4fc9c54bdb5d6ab7ade8cac1e52518bd..dc3ff6089aca1bb0c59d177492aba1a7859b4eb1 100644 (file)
@@ -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)) {
index 0f47cf0ee1d75d0bf1692a79c71aee72c620e03f..482f5243d4571215d276f91b70a1225a30df879a 100644 (file)
@@ -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;
index 0a3475795adf5380b5cc5e2aabe2e30b7cb30185..f5f7856a1cd4936d84cc11bfee156ba36ed6c05f 100644 (file)
@@ -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)) {
index 9a53cb05b50b5afb287f1a75878dba785379e3a9..852cf2e1141eb2cf9128563c95789068b5ddb32b 100644 (file)
@@ -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);
                        }
                }
index 4ed990fb05ab57ab006a3f9d392cb55577281765..aca667a680687898ec98521c87fef3d3fb79af3e 100644 (file)
@@ -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);
index a0c6332e41dfba6d74de65059f394b69758ca2e8..bd2508262bb321c48e66c38a1b0bd6eb7e54db30 100644 (file)
@@ -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;
index 897ed4253d8a537b14ded5aafb35d17315654c70..781b39503bd23e7823d1eb5252505e6bacf253e3 100644 (file)
@@ -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;
index fedcfd3eb529382e77f995f0a802eea68ce5ee64..7bd86d4835f714c0b331ee89e1c743aa97a09295 100644 (file)
@@ -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 ();