]> source.dussan.org Git - rspamd.git/commitdiff
Refactor and unify function names.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 27 May 2015 16:33:56 +0000 (17:33 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 27 May 2015 16:33:56 +0000 (17:33 +0100)
15 files changed:
src/libmime/filter.c
src/libserver/cfg_rcl.c
src/libserver/cfg_utils.c
src/libserver/symbols_cache.c
src/libserver/symbols_cache.h
src/lua/lua_cfg_file.c
src/lua/lua_config.c
src/lua/lua_util.c
src/main.c
src/plugins/chartable.c
src/plugins/dkim_check.c
src/plugins/fuzzy_check.c
src/plugins/regexp.c
src/plugins/spf.c
src/plugins/surbl.c

index 3a76232b9ee78573718e615fa2c3b880c88a6c4c..b939a1785d354e0c29342c1fe8435998332f17fc 100644 (file)
@@ -414,7 +414,7 @@ rspamd_process_filters (struct rspamd_task *task)
        }
 
        /* Process metrics symbols */
-       while (call_symbol_callback (task, task->cfg->cache, &item)) {
+       while (rspamd_symbols_cache_process_symbol (task, task->cfg->cache, &item)) {
                /* Check reject actions */
                cur = task->cfg->metrics_list;
                while (cur) {
index 3686fde0629176cd20ee23233d8425009f660072..3e8e639e07e27925311fdbde13bead5b1e7f759f 100644 (file)
@@ -1136,7 +1136,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
                composite);
 
        if (new) {
-               register_virtual_symbol (cfg->cache, composite_name, 1);
+               rspamd_symbols_cache_add_symbol_virtual (cfg->cache, composite_name, 1);
        }
 
        return TRUE;
index 12199436cc27ea8ab3f2123562e1ce2efc937486..fe7b47b30d820dd063a6ab7121263e9be22f85de 100644 (file)
@@ -680,7 +680,7 @@ symbols_classifiers_callback (gpointer key, gpointer value, gpointer ud)
 {
        struct rspamd_config *cfg = ud;
 
-       register_virtual_symbol (cfg->cache, key, 1.0);
+       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, key, 1.0);
 }
 
 void
index 25bccc6e951f25b88065da54ffceaa5055d3f6d4..be7ef98d97609daa463886f521ece389d433fd40 100644 (file)
@@ -306,7 +306,7 @@ rspamd_symbols_cache_save_items (struct symbols_cache *cache, const gchar *name)
 }
 
 void
-register_symbol_common (struct symbols_cache *cache,
+rspamd_symbols_cache_add_symbol (struct symbols_cache *cache,
        const gchar *name,
        double weight,
        gint priority,
@@ -352,10 +352,10 @@ register_symbol_common (struct symbols_cache *cache,
 }
 
 void
-register_symbol (struct symbols_cache *cache, const gchar *name, double weight,
+rspamd_symbols_cache_add_symbol_normal (struct symbols_cache *cache, const gchar *name, double weight,
        symbol_func_t func, gpointer user_data)
 {
-       register_symbol_common (cache,
+       rspamd_symbols_cache_add_symbol (cache,
                name,
                weight,
                0,
@@ -365,11 +365,11 @@ register_symbol (struct symbols_cache *cache, const gchar *name, double weight,
 }
 
 void
-register_virtual_symbol (struct symbols_cache *cache,
+rspamd_symbols_cache_add_symbol_virtual (struct symbols_cache *cache,
        const gchar *name,
        double weight)
 {
-       register_symbol_common (cache,
+       rspamd_symbols_cache_add_symbol (cache,
                name,
                weight,
                0,
@@ -379,13 +379,13 @@ register_virtual_symbol (struct symbols_cache *cache,
 }
 
 void
-register_callback_symbol (struct symbols_cache *cache,
+rspamd_symbols_cache_add_symbol_callback (struct symbols_cache *cache,
        const gchar *name,
        double weight,
        symbol_func_t func,
        gpointer user_data)
 {
-       register_symbol_common (cache,
+       rspamd_symbols_cache_add_symbol (cache,
                name,
                weight,
                0,
@@ -395,14 +395,14 @@ register_callback_symbol (struct symbols_cache *cache,
 }
 
 void
-register_callback_symbol_priority (struct symbols_cache *cache,
+rspamd_symbols_cache_add_symbol_callback_prio (struct symbols_cache *cache,
        const gchar *name,
        double weight,
        gint priority,
        symbol_func_t func,
        gpointer user_data)
 {
-       register_symbol_common (cache,
+       rspamd_symbols_cache_add_symbol (cache,
                name,
                weight,
                priority,
@@ -448,7 +448,7 @@ rspamd_symbols_cache_new (void)
 }
 
 gboolean
-init_symbols_cache (struct symbols_cache* cache,
+rspamd_symbols_cache_init (struct symbols_cache* cache,
                struct rspamd_config *cfg)
 {
        gboolean res;
@@ -563,7 +563,7 @@ rspamd_symbols_cache_metric_validate_cb (gpointer k, gpointer v, gpointer ud)
 }
 
 gboolean
-validate_cache (struct symbols_cache *cache,
+rspamd_symbols_cache_validate (struct symbols_cache *cache,
        struct rspamd_config *cfg,
        gboolean strict)
 {
@@ -611,7 +611,7 @@ validate_cache (struct symbols_cache *cache,
 }
 
 gboolean
-call_symbol_callback (struct rspamd_task * task,
+rspamd_symbols_cache_process_symbol (struct rspamd_task * task,
        struct symbols_cache * cache,
        gpointer *save)
 {
index 8eee4e690c3a35191e80d05313c6a09ba6255e99..c0b43ee6b68e6589ebb64d1bed6e0e9ff09e00bd 100644 (file)
@@ -59,7 +59,7 @@ void rspamd_symbols_cache_destroy (struct symbols_cache *cache);
 /**
  * Load symbols cache from file, must be called _after_ init_symbols_cache
  */
-gboolean init_symbols_cache (struct symbols_cache* cache,
+gboolean rspamd_symbols_cache_init (struct symbols_cache* cache,
        struct rspamd_config *cfg);
 
 /**
@@ -68,7 +68,7 @@ gboolean init_symbols_cache (struct symbols_cache* cache,
  * @param func pointer to handler
  * @param user_data pointer to user_data
  */
-void register_symbol (struct symbols_cache *cache,
+void rspamd_symbols_cache_add_symbol_normal (struct symbols_cache *cache,
        const gchar *name,
        double weight,
        symbol_func_t func,
@@ -79,7 +79,7 @@ void register_symbol (struct symbols_cache *cache,
  * Register virtual symbol
  * @param name name of symbol
  */
-void register_virtual_symbol (struct symbols_cache *cache,
+void rspamd_symbols_cache_add_symbol_virtual (struct symbols_cache *cache,
        const gchar *name,
        double weight);
 
@@ -89,7 +89,7 @@ void register_virtual_symbol (struct symbols_cache *cache,
  * @param func pointer to handler
  * @param user_data pointer to user_data
  */
-void register_callback_symbol (struct symbols_cache *cache,
+void rspamd_symbols_cache_add_symbol_callback (struct symbols_cache *cache,
        const gchar *name,
        double weight,
        symbol_func_t func,
@@ -101,7 +101,7 @@ void register_callback_symbol (struct symbols_cache *cache,
  * @param func pointer to handler
  * @param user_data pointer to user_data
  */
-void register_callback_symbol_priority (struct symbols_cache *cache,
+void rspamd_symbols_cache_add_symbol_callback_prio (struct symbols_cache *cache,
        const gchar *name,
        double weight,
        gint priority,
@@ -118,8 +118,7 @@ void register_callback_symbol_priority (struct symbols_cache *cache,
  * @param user_data
  * @param type
  */
-void
-register_symbol_common (struct symbols_cache *cache,
+void rspamd_symbols_cache_add_symbol (struct symbols_cache *cache,
        const gchar *name,
        double weight,
        gint priority,
@@ -133,23 +132,17 @@ register_symbol_common (struct symbols_cache *cache,
  * @param cache symbols cache
  * @param saved_item pointer to currently saved item
  */
-gboolean call_symbol_callback (struct rspamd_task *task,
+gboolean rspamd_symbols_cache_process_symbol (struct rspamd_task *task,
        struct symbols_cache *cache,
        gpointer *save);
 
-/**
- * Remove all dynamic rules from cache
- * @param cache symbols cache
- */
-void remove_dynamic_rules (struct symbols_cache *cache);
-
 /**
  * Validate cache items agains theirs weights defined in metrics
  * @param cache symbols cache
  * @param cfg configuration
  * @param strict do strict checks - symbols MUST be described in metrics
  */
-gboolean validate_cache (struct symbols_cache *cache,
+gboolean rspamd_symbols_cache_validate (struct symbols_cache *cache,
        struct rspamd_config *cfg,
        gboolean strict);
 
index aae50ea3e820c6c4ee514f82a8feba1b656d989b..750f1f382ec063e8f6d7defd02df7a226a3dc9f7 100644 (file)
@@ -212,7 +212,7 @@ rspamd_lua_post_load_config (struct rspamd_config *cfg)
                                }
                                else {
                                        g_hash_table_insert (cfg->composite_symbols, sym, expr);
-                                       register_virtual_symbol (cfg->cache, sym, 1);
+                                       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, sym, 1);
                                }
                        }
                }
index cb12c970b72fecafb84244f1ab1f71b01d1061e1..247805f984a04fa454c388a8a4b5716e230a73f5 100644 (file)
@@ -867,7 +867,7 @@ rspamd_register_symbol_fromlua (lua_State *L,
                cd->L = L;
                cd->symbol = rspamd_mempool_strdup (cfg->cfg_pool, name);
 
-               register_symbol_common (cfg->cache,
+               rspamd_symbols_cache_add_symbol (cfg->cache,
                                name,
                                weight,
                                priority,
@@ -957,7 +957,7 @@ lua_config_register_symbols (lua_State *L)
                                        lua_pushvalue (L, -2);
                                        sym = rspamd_mempool_strdup (cfg->cfg_pool,
                                                        luaL_checkstring (L, -2));
-                                       register_virtual_symbol (cfg->cache, sym, weight);
+                                       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, sym, weight);
                                        lua_pop (L, 2);
                                }
                                lua_pop (L, 1);
@@ -965,7 +965,7 @@ lua_config_register_symbols (lua_State *L)
                        else if (lua_type (L, i) == LUA_TSTRING) {
                                sym = rspamd_mempool_strdup (cfg->cfg_pool,
                                                luaL_checkstring (L, i));
-                               register_virtual_symbol (cfg->cache, sym, weight);
+                               rspamd_symbols_cache_add_symbol_virtual (cfg->cache, sym, weight);
                        }
                }
        }
@@ -984,7 +984,7 @@ lua_config_register_virtual_symbol (lua_State * L)
                name = rspamd_mempool_strdup (cfg->cfg_pool, luaL_checkstring (L, 2));
                weight = luaL_checknumber (L, 3);
                if (name) {
-                       register_virtual_symbol (cfg->cache, name, weight);
+                       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, name, weight);
                }
        }
        return 0;
@@ -1157,7 +1157,7 @@ lua_config_add_composite (lua_State * L)
                                                composite);
 
                                if (new) {
-                                       register_virtual_symbol (cfg->cache, name, 1);
+                                       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, name, 1);
                                }
 
                                ret = TRUE;
index 297ee406dae0463d216782f8f2205e07e3d0fe0c..ac0c5f18a0fb9d4a16c6a5a96973908a7fcbea84 100644 (file)
@@ -112,7 +112,7 @@ lua_util_load_rspamd_config (lua_State *L)
                }
                else {
                        rspamd_config_post_load (cfg);
-                       init_symbols_cache (cfg->cache, cfg);
+                       rspamd_symbols_cache_init (cfg->cache, cfg);
                        pcfg = lua_newuserdata (L, sizeof (struct rspamd_config *));
                        rspamd_lua_setclass (L, "rspamd{config}", -1);
                        *pcfg = cfg;
@@ -147,7 +147,7 @@ lua_util_config_from_ucl (lua_State *L)
                }
                else {
                        rspamd_config_post_load (cfg);
-                       init_symbols_cache (cfg->cache, cfg);
+                       rspamd_symbols_cache_init (cfg->cache, cfg);
                        pcfg = lua_newuserdata (L, sizeof (struct rspamd_config *));
                        rspamd_lua_setclass (L, "rspamd{config}", -1);
                        *pcfg = cfg;
index 3b5b115f48bff91e60237f6208d861be1cb27487..27e8c9ce7f8d57d81a538fd7cd32bd015dbf037b 100644 (file)
@@ -391,7 +391,7 @@ reread_config (struct rspamd_main *rspamd)
                }
 
                rspamd_init_filters (rspamd->cfg, TRUE);
-               init_symbols_cache (rspamd->cfg->cache, rspamd->cfg);
+               rspamd_symbols_cache_init (rspamd->cfg->cache, rspamd->cfg);
                msg_info ("config has been reread successfully");
        }
 }
@@ -1138,7 +1138,7 @@ main (gint argc, gchar **argv, gchar **env)
                /* Insert classifiers symbols */
                (void)rspamd_config_insert_classify_symbols (rspamd_main->cfg);
 
-               if (!validate_cache (rspamd_main->cfg->cache, rspamd_main->cfg,
+               if (!rspamd_symbols_cache_validate (rspamd_main->cfg->cache, rspamd_main->cfg,
                        FALSE)) {
                        res = FALSE;
                }
@@ -1197,10 +1197,10 @@ main (gint argc, gchar **argv, gchar **env)
        setproctitle ("main process");
 
        /* Init config cache */
-       init_symbols_cache (rspamd_main->cfg->cache, rspamd_main->cfg);
+       rspamd_symbols_cache_init (rspamd_main->cfg->cache, rspamd_main->cfg);
 
        /* Validate cache */
-       (void)validate_cache (rspamd_main->cfg->cache, rspamd_main->cfg, FALSE);
+       (void)rspamd_symbols_cache_validate (rspamd_main->cfg->cache, rspamd_main->cfg, FALSE);
 
        /* Flush log */
        rspamd_log_flush (rspamd_main->logger);
index 7c4372a13165b88bed5051d75d94c19d39b8cac8..cbf23c33616bc17260c194cd46477c2c888f61b9 100644 (file)
@@ -100,7 +100,7 @@ chartable_module_config (struct rspamd_config *cfg)
                chartable_module_ctx->threshold = DEFAULT_THRESHOLD;
        }
 
-       register_symbol (cfg->cache,
+       rspamd_symbols_cache_add_symbol_normal (cfg->cache,
                chartable_module_ctx->symbol,
                1,
                chartable_symbol_callback,
index 7e430f5a66ab1b7b2fd402d631f687749229ec80..9a7fc3323d64f2d991fdfc3fd6b56ab45ea6883c 100644 (file)
@@ -223,15 +223,15 @@ dkim_module_config (struct rspamd_config *cfg)
                        "trusted_only option is set and no trusted domains are defined; disabling dkim module completely as it is useless in this case");
        }
        else {
-               register_symbol (cfg->cache,
+               rspamd_symbols_cache_add_symbol_normal (cfg->cache,
                        dkim_module_ctx->symbol_reject,
                        1,
                        dkim_symbol_callback,
                        NULL);
-               register_virtual_symbol (cfg->cache,
+               rspamd_symbols_cache_add_symbol_virtual (cfg->cache,
                        dkim_module_ctx->symbol_tempfail,
                        1);
-               register_virtual_symbol (cfg->cache,
+               rspamd_symbols_cache_add_symbol_virtual (cfg->cache,
                        dkim_module_ctx->symbol_allow,
                        1);
 
index c1556fa4dd65a4c0afd01965b851ef794ffb400f..8233fb43ba811fa2610e951a674601b6aea76aff 100644 (file)
@@ -174,7 +174,7 @@ parse_flags (struct fuzzy_rule *rule,
                                /* Add flag to hash table */
                                g_hash_table_insert (rule->mappings,
                                        GINT_TO_POINTER (map->fuzzy_flag), map);
-                               register_virtual_symbol (cfg->cache, map->symbol, 1.0);
+                               rspamd_symbols_cache_add_symbol_virtual (cfg->cache, map->symbol, 1.0);
                        }
                        else {
                                msg_err ("fuzzy_map parameter has no flag definition");
@@ -383,7 +383,7 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj)
                        fuzzy_module_ctx->fuzzy_rules,
                        rule);
                if (rule->symbol != fuzzy_module_ctx->default_symbol) {
-                       register_virtual_symbol (cfg->cache, rule->symbol, 1.0);
+                       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, rule->symbol, 1.0);
                }
        }
 
@@ -484,7 +484,7 @@ fuzzy_check_module_config (struct rspamd_config *cfg)
        }
 
        if (fuzzy_module_ctx->fuzzy_rules != NULL) {
-               register_callback_symbol (cfg->cache, fuzzy_module_ctx->default_symbol,
+               rspamd_symbols_cache_add_symbol_callback (cfg->cache, fuzzy_module_ctx->default_symbol,
                        1.0, fuzzy_symbol_callback, NULL);
        }
        else {
index 2a9229b090efa9e8e119dba8d95020fd3e1f6fa7..da2caab4ade8354d6631b2c8c45d39b6c5ea4636 100644 (file)
@@ -142,7 +142,7 @@ regexp_module_config (struct rspamd_config *cfg)
                                res = FALSE;
                        }
                        else {
-                               register_symbol (cfg->cache,
+                               rspamd_symbols_cache_add_symbol_normal (cfg->cache,
                                                cur_item->symbol,
                                                1,
                                                process_regexp_item,
@@ -154,7 +154,7 @@ regexp_module_config (struct rspamd_config *cfg)
                                        sizeof (struct regexp_module_item));
                        cur_item->symbol = ucl_object_key (value);
                        cur_item->lua_function = ucl_object_toclosure (value);
-                       register_symbol (cfg->cache,
+                       rspamd_symbols_cache_add_symbol_normal (cfg->cache,
                                cur_item->symbol,
                                1,
                                process_regexp_item,
index f3c8226e40e50a866313eb6615c1da2054b3f26a..8c477cca9cc7931e0ac39b8e967d738f2e1e0178 100644 (file)
@@ -151,14 +151,14 @@ spf_module_config (struct rspamd_config *cfg)
                }
        }
 
-       register_symbol (cfg->cache,
+       rspamd_symbols_cache_add_symbol_normal (cfg->cache,
                spf_module_ctx->symbol_fail,
                1,
                spf_symbol_callback,
                NULL);
-       register_virtual_symbol (cfg->cache, spf_module_ctx->symbol_softfail, 1);
-       register_virtual_symbol (cfg->cache, spf_module_ctx->symbol_neutral,  1);
-       register_virtual_symbol (cfg->cache, spf_module_ctx->symbol_allow,         1);
+       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, spf_module_ctx->symbol_softfail, 1);
+       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, spf_module_ctx->symbol_neutral,  1);
+       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, spf_module_ctx->symbol_allow,         1);
 
        spf_module_ctx->spf_hash = rspamd_lru_hash_new (
                        cache_size,
index bd87dc944f003d4f38594a062abaf752cce66154..48b0bba325996f5a9887d6ab158ddb0553ab79a6 100644 (file)
@@ -314,18 +314,18 @@ register_bit_symbols (struct rspamd_config *cfg, struct suffix_item *suffix)
 
                while (g_hash_table_iter_next (&it, &k, &v)) {
                        bit = v;
-                       register_virtual_symbol (cfg->cache, bit->symbol, 1);
+                       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, bit->symbol, 1);
                        msg_debug ("bit: %d", bit->bit);
                }
        }
        else if (suffix->bits != NULL) {
                for (i = 0; i < suffix->bits->len; i++) {
                        bit = &g_array_index (suffix->bits, struct surbl_bit_item, i);
-                       register_virtual_symbol (cfg->cache, bit->symbol, 1);
+                       rspamd_symbols_cache_add_symbol_virtual (cfg->cache, bit->symbol, 1);
                }
        }
        else {
-               register_virtual_symbol (cfg->cache, suffix->symbol, 1);
+               rspamd_symbols_cache_add_symbol_virtual (cfg->cache, suffix->symbol, 1);
        }
 }
 
@@ -361,7 +361,7 @@ surbl_module_config (struct rspamd_config *cfg)
                rspamd_config_get_module_opt (cfg, "surbl",
                "redirector_symbol")) != NULL) {
                surbl_module_ctx->redirector_symbol = ucl_obj_tostring (value);
-               register_virtual_symbol (cfg->cache,
+               rspamd_symbols_cache_add_symbol_virtual (cfg->cache,
                        surbl_module_ctx->redirector_symbol,
                        1.0);
        }
@@ -553,7 +553,7 @@ surbl_module_config (struct rspamd_config *cfg)
                        surbl_module_ctx->suffixes = g_list_prepend (
                                surbl_module_ctx->suffixes,
                                new_suffix);
-                       register_callback_symbol (cfg->cache,
+                       rspamd_symbols_cache_add_symbol_callback (cfg->cache,
                                new_suffix->symbol,
                                1,
                                surbl_test_url,