diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-03 13:22:43 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-01-03 13:22:43 +0000 |
commit | 0ba131089412a41c632703109903185d1e057aff (patch) | |
tree | 9ef31256b246bc66163d7ce0b6ce2edb47dc6d7c /src | |
parent | 16c8c89c354a62aae901c63a43688a164b4d9ea0 (diff) | |
download | rspamd-0ba131089412a41c632703109903185d1e057aff.tar.gz rspamd-0ba131089412a41c632703109903185d1e057aff.zip |
[Minor] Move common functions from libmime
Diffstat (limited to 'src')
-rw-r--r-- | src/libmime/filter.c | 85 | ||||
-rw-r--r-- | src/libmime/filter.h | 11 | ||||
-rw-r--r-- | src/libserver/cfg_file.h | 11 | ||||
-rw-r--r-- | src/libserver/cfg_utils.c | 85 |
4 files changed, 96 insertions, 96 deletions
diff --git a/src/libmime/filter.c b/src/libmime/filter.c index 97c8d9df7..d116ccb45 100644 --- a/src/libmime/filter.c +++ b/src/libmime/filter.c @@ -287,91 +287,6 @@ rspamd_task_add_result_option (struct rspamd_task *task, return ret; } -gboolean -rspamd_action_from_str (const gchar *data, gint *result) -{ - guint64 h; - - h = rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH64, - data, strlen (data), 0xdeadbabe); - - switch (h) { - case 0x9917BFDB46332B8CULL: /* reject */ - *result = METRIC_ACTION_REJECT; - break; - case 0x7130EE37D07B3715ULL: /* greylist */ - *result = METRIC_ACTION_GREYLIST; - break; - case 0xCA6087E05480C60CULL: /* add_header */ - case 0x87A3D27783B16241ULL: /* add header */ - *result = METRIC_ACTION_ADD_HEADER; - break; - case 0x4963374ED8B90449ULL: /* rewrite_subject */ - case 0x5C9FC4679C025948ULL: /* rewrite subject */ - *result = METRIC_ACTION_REWRITE_SUBJECT; - break; - case 0xFC7D6502EE71FDD9ULL: /* soft reject */ - case 0x73576567C262A82DULL: /* soft_reject */ - *result = METRIC_ACTION_SOFT_REJECT; - break; - case 0x207091B927D1EC0DULL: /* no action */ - case 0xB7D92D002CD46325ULL: /* no_action */ - case 0x167C0DF4BAA9BCECULL: /* accept */ - *result = METRIC_ACTION_NOACTION; - break; - default: - return FALSE; - } - - return TRUE; -} - -const gchar * -rspamd_action_to_str (enum rspamd_metric_action action) -{ - switch (action) { - case METRIC_ACTION_REJECT: - return "reject"; - case METRIC_ACTION_SOFT_REJECT: - return "soft reject"; - case METRIC_ACTION_REWRITE_SUBJECT: - return "rewrite subject"; - case METRIC_ACTION_ADD_HEADER: - return "add header"; - case METRIC_ACTION_GREYLIST: - return "greylist"; - case METRIC_ACTION_NOACTION: - return "no action"; - case METRIC_ACTION_MAX: - return "invalid max action"; - } - - return "unknown action"; -} - -const gchar * -rspamd_action_to_str_alt (enum rspamd_metric_action action) -{ - switch (action) { - case METRIC_ACTION_REJECT: - return "reject"; - case METRIC_ACTION_SOFT_REJECT: - return "soft_reject"; - case METRIC_ACTION_REWRITE_SUBJECT: - return "rewrite_subject"; - case METRIC_ACTION_ADD_HEADER: - return "add_header"; - case METRIC_ACTION_GREYLIST: - return "greylist"; - case METRIC_ACTION_NOACTION: - return "no action"; - case METRIC_ACTION_MAX: - return "invalid max action"; - } - - return "unknown action"; -} - enum rspamd_metric_action rspamd_check_action_metric (struct rspamd_task *task, struct rspamd_metric_result *mres) { diff --git a/src/libmime/filter.h b/src/libmime/filter.h index e947dbd44..a221960ac 100644 --- a/src/libmime/filter.h +++ b/src/libmime/filter.h @@ -95,17 +95,6 @@ double rspamd_factor_consolidation_func (struct rspamd_task *task, /* - * Get action from a string - */ -gboolean rspamd_action_from_str (const gchar *data, gint *result); - -/* - * Return textual representation of action enumeration - */ -const gchar * rspamd_action_to_str (enum rspamd_metric_action action); -const gchar * rspamd_action_to_str_alt (enum rspamd_metric_action action); - -/* * Get action for specific metric */ enum rspamd_metric_action rspamd_check_action_metric (struct rspamd_task *task, diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h index 80bf86f03..4da641953 100644 --- a/src/libserver/cfg_file.h +++ b/src/libserver/cfg_file.h @@ -628,6 +628,17 @@ gboolean rspamd_config_set_action_score (struct rspamd_config *cfg, gboolean rspamd_config_is_module_enabled (struct rspamd_config *cfg, const gchar *module_name); +/* + * Get action from a string + */ +gboolean rspamd_action_from_str (const gchar *data, gint *result); + +/* + * Return textual representation of action enumeration + */ +const gchar * rspamd_action_to_str (enum rspamd_metric_action action); +const gchar * rspamd_action_to_str_alt (enum rspamd_metric_action action); + /** * Parse radix tree or radix map from ucl object * @param cfg configuration object diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index fe8f2ef8a..306965df8 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -1723,3 +1723,88 @@ rspamd_config_radix_from_ucl (struct rspamd_config *cfg, return TRUE; } + +gboolean +rspamd_action_from_str (const gchar *data, gint *result) +{ + guint64 h; + + h = rspamd_cryptobox_fast_hash_specific (RSPAMD_CRYPTOBOX_XXHASH64, + data, strlen (data), 0xdeadbabe); + + switch (h) { + case 0x9917BFDB46332B8CULL: /* reject */ + *result = METRIC_ACTION_REJECT; + break; + case 0x7130EE37D07B3715ULL: /* greylist */ + *result = METRIC_ACTION_GREYLIST; + break; + case 0xCA6087E05480C60CULL: /* add_header */ + case 0x87A3D27783B16241ULL: /* add header */ + *result = METRIC_ACTION_ADD_HEADER; + break; + case 0x4963374ED8B90449ULL: /* rewrite_subject */ + case 0x5C9FC4679C025948ULL: /* rewrite subject */ + *result = METRIC_ACTION_REWRITE_SUBJECT; + break; + case 0xFC7D6502EE71FDD9ULL: /* soft reject */ + case 0x73576567C262A82DULL: /* soft_reject */ + *result = METRIC_ACTION_SOFT_REJECT; + break; + case 0x207091B927D1EC0DULL: /* no action */ + case 0xB7D92D002CD46325ULL: /* no_action */ + case 0x167C0DF4BAA9BCECULL: /* accept */ + *result = METRIC_ACTION_NOACTION; + break; + default: + return FALSE; + } + + return TRUE; +} + +const gchar * +rspamd_action_to_str (enum rspamd_metric_action action) +{ + switch (action) { + case METRIC_ACTION_REJECT: + return "reject"; + case METRIC_ACTION_SOFT_REJECT: + return "soft reject"; + case METRIC_ACTION_REWRITE_SUBJECT: + return "rewrite subject"; + case METRIC_ACTION_ADD_HEADER: + return "add header"; + case METRIC_ACTION_GREYLIST: + return "greylist"; + case METRIC_ACTION_NOACTION: + return "no action"; + case METRIC_ACTION_MAX: + return "invalid max action"; + } + + return "unknown action"; +} + +const gchar * +rspamd_action_to_str_alt (enum rspamd_metric_action action) +{ + switch (action) { + case METRIC_ACTION_REJECT: + return "reject"; + case METRIC_ACTION_SOFT_REJECT: + return "soft_reject"; + case METRIC_ACTION_REWRITE_SUBJECT: + return "rewrite_subject"; + case METRIC_ACTION_ADD_HEADER: + return "add_header"; + case METRIC_ACTION_GREYLIST: + return "greylist"; + case METRIC_ACTION_NOACTION: + return "no action"; + case METRIC_ACTION_MAX: + return "invalid max action"; + } + + return "unknown action"; +} |