From 051363b21bd238d1f3e4b292dab59a14b538948d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 3 Feb 2014 14:55:55 +0000 Subject: [PATCH] Remove deprecated code. Reported by: Andrey Vohmyanin --- src/cfg_file.h | 5 --- src/cfg_utils.c | 100 ------------------------------------------------ 2 files changed, 105 deletions(-) diff --git a/src/cfg_file.h b/src/cfg_file.h index a1b3db8ed..6f3489455 100644 --- a/src/cfg_file.h +++ b/src/cfg_file.h @@ -483,11 +483,6 @@ struct metric* check_metric_conf (struct config_file *cfg, struct metric *c); */ struct statfile* check_statfile_conf (struct config_file *cfg, struct statfile *c); -/* - * XXX: Depreciated function, now it is used for - */ -gboolean parse_normalizer (struct config_file *cfg, struct statfile *st, const gchar *line); - /* * Read XML configuration file */ diff --git a/src/cfg_utils.c b/src/cfg_utils.c index 9216fb6ef..eb2bfdd9d 100644 --- a/src/cfg_utils.c +++ b/src/cfg_utils.c @@ -657,106 +657,6 @@ check_worker_conf (struct config_file *cfg, struct worker_conf *c) return c; } -static double -internal_normalizer_func (struct config_file *cfg, long double score, void *data) -{ - long double max = *(double *)data; - - if (score < 0) { - return score; - } -#ifdef HAVE_TANHL - return max * tanhl (score / max); -#elif defined(HAVE_TANHL) - /* - * As some implementations of libm does not support tanhl, try to use - * tanh - */ - return max * tanh ((double) (score / max)); -#else - return score < max ? score / max : max; -#endif -} - -static gboolean -parse_internal_normalizer (struct config_file *cfg, struct statfile *st, const gchar *line) -{ - double *max; - gchar *err; - - /* Line contains maximum value for internal normalizer */ - max = memory_pool_alloc (cfg->cfg_pool, sizeof (double)); - - errno = 0; - *max = strtod (line, &err); - - if (errno != 0 || *err != '\0') { - msg_err ("cannot parse max number for internal normalizer"); - return FALSE; - } - - st->normalizer = internal_normalizer_func; - st->normalizer_data = (void *)max; - return TRUE; -} - -#ifdef WITH_LUA -static gboolean -parse_lua_normalizer (struct config_file *cfg, struct statfile *st, const gchar *line) -{ - gchar *code_begin; - GList *params = NULL; - gint len; - - code_begin = strchr (line, ':'); - - if (code_begin == NULL) { - /* Just function name without code */ - params = g_list_prepend (g_list_prepend (NULL, NULL), memory_pool_strdup (cfg->cfg_pool, line)); - } - else { - /* Postpone actual code load as lua libraries are not loaded */ - /* Put code to list */ - params = g_list_prepend (NULL, code_begin + 1); - /* Put function name */ - len = code_begin - line; - code_begin = memory_pool_alloc (cfg->cfg_pool, len + 1); - rspamd_strlcpy (code_begin, line, len + 1); - params = g_list_prepend (params, code_begin); - } - memory_pool_add_destructor (cfg->cfg_pool, (pool_destruct_func)g_list_free, params); - st->normalizer = lua_normalizer_func; - st->normalizer_data = params; - return TRUE; -} -#endif - - -gboolean -parse_normalizer (struct config_file *cfg, struct statfile *st, const gchar *line) -{ - gchar *params_begin; - - params_begin = strchr (line, ':'); - if (params_begin == NULL) { - msg_err ("no parameters are specified for normalizer %s", line); - return FALSE; - } - - /* Try to guess normalizer */ - if (g_ascii_strncasecmp (line, "internal", sizeof ("points")) == 0) { - return parse_internal_normalizer (cfg, st, params_begin + 1); - } -#ifdef WITH_LUA - else if (g_ascii_strncasecmp (line, "points", sizeof ("points")) == 0) { - return parse_lua_normalizer (cfg, st, params_begin + 1); - } -#endif - - msg_err ("unknown normalizer %s", line); - return FALSE; -} - static GMarkupParser xml_parser = { .start_element = rspamd_xml_start_element, .end_element = rspamd_xml_end_element, -- 2.39.5