aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-27 17:33:56 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-05-27 17:33:56 +0100
commit6e00dea760aca106de1021e5a9740b9511a6e0b2 (patch)
treedc5f5a67564d419f67ae03e63db45c8b81b822be /src
parentce9a26d98932473c449e5d4bf39dbb93a6d7a924 (diff)
downloadrspamd-6e00dea760aca106de1021e5a9740b9511a6e0b2.tar.gz
rspamd-6e00dea760aca106de1021e5a9740b9511a6e0b2.zip
Refactor and unify function names.
Diffstat (limited to 'src')
-rw-r--r--src/libmime/filter.c2
-rw-r--r--src/libserver/cfg_rcl.c2
-rw-r--r--src/libserver/cfg_utils.c2
-rw-r--r--src/libserver/symbols_cache.c24
-rw-r--r--src/libserver/symbols_cache.h23
-rw-r--r--src/lua/lua_cfg_file.c2
-rw-r--r--src/lua/lua_config.c10
-rw-r--r--src/lua/lua_util.c4
-rw-r--r--src/main.c8
-rw-r--r--src/plugins/chartable.c2
-rw-r--r--src/plugins/dkim_check.c6
-rw-r--r--src/plugins/fuzzy_check.c6
-rw-r--r--src/plugins/regexp.c4
-rw-r--r--src/plugins/spf.c8
-rw-r--r--src/plugins/surbl.c10
15 files changed, 53 insertions, 60 deletions
diff --git a/src/libmime/filter.c b/src/libmime/filter.c
index 3a76232b9..b939a1785 100644
--- a/src/libmime/filter.c
+++ b/src/libmime/filter.c
@@ -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) {
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 3686fde06..3e8e639e0 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -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;
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 12199436c..fe7b47b30 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -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
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index 25bccc6e9..be7ef98d9 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -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)
{
diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h
index 8eee4e690..c0b43ee6b 100644
--- a/src/libserver/symbols_cache.h
+++ b/src/libserver/symbols_cache.h
@@ -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);
diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c
index aae50ea3e..750f1f382 100644
--- a/src/lua/lua_cfg_file.c
+++ b/src/lua/lua_cfg_file.c
@@ -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);
}
}
}
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index cb12c970b..247805f98 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -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;
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 297ee406d..ac0c5f18a 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -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;
diff --git a/src/main.c b/src/main.c
index 3b5b115f4..27e8c9ce7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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);
diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c
index 7c4372a13..cbf23c336 100644
--- a/src/plugins/chartable.c
+++ b/src/plugins/chartable.c
@@ -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,
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index 7e430f5a6..9a7fc3323 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -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);
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index c1556fa4d..8233fb43b 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -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 {
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 2a9229b09..da2caab4a 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -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,
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index f3c8226e4..8c477cca9 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -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,
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index bd87dc944..48b0bba32 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -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,