commit d4d921a: [Rework] Rename filter.h to a more sane name
Vsevolod Stakhov
vsevolod at highsecure.ru
Mon Aug 12 12:56:04 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-08-12 12:35:13 +0100
URL: https://github.com/rspamd/rspamd/commit/d4d921a97e5a8548fb506ed8bc747d9a2bc37561
[Rework] Rename filter.h to a more sane name
---
src/libmime/CMakeLists.txt | 2 +-
src/libmime/{filter.c => scan_result.c} | 22 +++++++++++-----------
src/libmime/{filter.h => scan_result.h} | 12 ++++++------
.../{filter_private.h => scan_result_private.h} | 8 ++++----
src/libserver/cfg_utils.c | 2 +-
src/libserver/composites.c | 6 +++---
src/libserver/dynamic_cfg.c | 2 +-
src/libserver/milter.c | 2 +-
src/libserver/protocol.c | 12 ++++++------
src/libserver/protocol.h | 2 +-
src/libserver/roll_history.c | 2 +-
src/libserver/rspamd_symcache.c | 4 ++--
src/libserver/task.c | 8 ++++----
src/libserver/task.h | 6 +++---
src/libstat/stat_process.c | 4 ++--
src/lua/lua_task.c | 22 +++++++++++-----------
16 files changed, 58 insertions(+), 58 deletions(-)
diff --git a/src/libmime/CMakeLists.txt b/src/libmime/CMakeLists.txt
index 81d75d382..a011dff07 100644
--- a/src/libmime/CMakeLists.txt
+++ b/src/libmime/CMakeLists.txt
@@ -2,7 +2,7 @@
SET(LIBRSPAMDMIMESRC
${CMAKE_CURRENT_SOURCE_DIR}/email_addr.c
${CMAKE_CURRENT_SOURCE_DIR}/mime_expressions.c
- ${CMAKE_CURRENT_SOURCE_DIR}/filter.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/scan_result.c
${CMAKE_CURRENT_SOURCE_DIR}/images.c
${CMAKE_CURRENT_SOURCE_DIR}/message.c
${CMAKE_CURRENT_SOURCE_DIR}/archives.c
diff --git a/src/libmime/filter.c b/src/libmime/scan_result.c
similarity index 97%
rename from src/libmime/filter.c
rename to src/libmime/scan_result.c
index a193f5f78..428a2da71 100644
--- a/src/libmime/filter.c
+++ b/src/libmime/scan_result.c
@@ -15,12 +15,12 @@
*/
#include "config.h"
#include "mem_pool.h"
-#include "filter.h"
+#include "scan_result.h"
#include "rspamd.h"
#include "message.h"
#include "lua/lua_common.h"
#include "libserver/cfg_file_private.h"
-#include "libmime/filter_private.h"
+#include "libmime/scan_result_private.h"
#include <math.h>
#include "contrib/uthash/utlist.h"
@@ -35,9 +35,9 @@ INIT_LOG_MODULE(metric)
static struct rspamd_counter_data symbols_count;
static void
-rspamd_metric_result_dtor (gpointer d)
+rspamd_scan_result_dtor (gpointer d)
{
- struct rspamd_metric_result *r = (struct rspamd_metric_result *)d;
+ struct rspamd_scan_result *r = (struct rspamd_scan_result *)d;
struct rspamd_symbol_result sres;
rspamd_set_counter_ema (&symbols_count, kh_size (r->symbols), 0.5);
@@ -51,10 +51,10 @@ rspamd_metric_result_dtor (gpointer d)
kh_destroy (rspamd_symbols_group_hash, r->sym_groups);
}
-struct rspamd_metric_result *
+struct rspamd_scan_result *
rspamd_create_metric_result (struct rspamd_task *task)
{
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
guint i;
metric_res = task->result;
@@ -64,7 +64,7 @@ rspamd_create_metric_result (struct rspamd_task *task)
}
metric_res = rspamd_mempool_alloc0 (task->task_pool,
- sizeof (struct rspamd_metric_result));
+ sizeof (struct rspamd_scan_result));
metric_res->symbols = kh_init (rspamd_symbols_hash);
metric_res->sym_groups = kh_init (rspamd_symbols_group_hash);
@@ -98,7 +98,7 @@ rspamd_create_metric_result (struct rspamd_task *task)
}
rspamd_mempool_add_destructor (task->task_pool,
- rspamd_metric_result_dtor,
+ rspamd_scan_result_dtor,
metric_res);
return metric_res;
@@ -120,7 +120,7 @@ rspamd_add_passthrough_result (struct rspamd_task *task,
const gchar *module,
guint flags)
{
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
struct rspamd_passthrough_result *pr;
metric_res = task->result;
@@ -185,7 +185,7 @@ insert_metric_result (struct rspamd_task *task,
const gchar *opt,
enum rspamd_symbol_insert_flags flags)
{
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
struct rspamd_symbol_result *s = NULL;
gdouble final_score, *gr_score = NULL, next_gf = 1.0, diff;
struct rspamd_symbol *sdef;
@@ -560,7 +560,7 @@ rspamd_check_action_metric (struct rspamd_task *task)
struct rspamd_passthrough_result *pr;
double max_score = -(G_MAXDOUBLE), sc;
int i;
- struct rspamd_metric_result *mres = task->result;
+ struct rspamd_scan_result *mres = task->result;
gboolean seen_least = FALSE;
if (mres->passthrough_result != NULL) {
diff --git a/src/libmime/filter.h b/src/libmime/scan_result.h
similarity index 95%
rename from src/libmime/filter.h
rename to src/libmime/scan_result.h
index 8245f8c53..b5f76baf7 100644
--- a/src/libmime/filter.h
+++ b/src/libmime/scan_result.h
@@ -1,10 +1,10 @@
/**
- * @file filter.h
- * Filters logic implementation
+ * @file scan_result.h
+ * Scan result holder
*/
-#ifndef RSPAMD_FILTER_H
-#define RSPAMD_FILTER_H
+#ifndef RSPAMD_SCAN_RESULT_H
+#define RSPAMD_SCAN_RESULT_H
#include "config.h"
#include "rspamd_symcache.h"
@@ -70,7 +70,7 @@ struct kh_rspamd_symbols_hash_s;
struct kh_rspamd_symbols_group_hash_s;
-struct rspamd_metric_result {
+struct rspamd_scan_result {
double score; /**< total score */
double grow_factor; /**< current grow factor */
struct rspamd_passthrough_result *passthrough_result;
@@ -89,7 +89,7 @@ struct rspamd_metric_result {
* @param task task object
* @return metric result or NULL if metric `name` has not been found
*/
-struct rspamd_metric_result *rspamd_create_metric_result (struct rspamd_task *task);
+struct rspamd_scan_result *rspamd_create_metric_result (struct rspamd_task *task);
/**
* Adds a new passthrough result to a task
diff --git a/src/libmime/filter_private.h b/src/libmime/scan_result_private.h
similarity index 83%
rename from src/libmime/filter_private.h
rename to src/libmime/scan_result_private.h
index 31def75e2..aa90430e1 100644
--- a/src/libmime/filter_private.h
+++ b/src/libmime/scan_result_private.h
@@ -2,10 +2,10 @@
// Created by Vsevolod Stakhov on 2019-01-14.
//
-#ifndef RSPAMD_FILTER_PRIVATE_H
-#define RSPAMD_FILTER_PRIVATE_H
+#ifndef RSPAMD_SCAN_RESULT_PRIVATE_H
+#define RSPAMD_SCAN_RESULT_PRIVATE_H
-#include "filter.h"
+#include "scan_result.h"
#include "contrib/libucl/khash.h"
#ifdef __cplusplus
@@ -36,4 +36,4 @@ KHASH_INIT (rspamd_symbols_group_hash,
}
#endif
-#endif //RSPAMD_FILTER_PRIVATE_H
+#endif //RSPAMD_SCAN_RESULT_PRIVATE_H
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index cec8c6f67..1872a68ec 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -18,7 +18,7 @@
#include "cfg_file.h"
#include "rspamd.h"
#include "cfg_file_private.h"
-#include "filter.h"
+#include "scan_result.h"
#include "lua/lua_common.h"
#include "lua/lua_thread_pool.h"
#include "map.h"
diff --git a/src/libserver/composites.c b/src/libserver/composites.c
index 4d8329376..92ccd4f15 100644
--- a/src/libserver/composites.c
+++ b/src/libserver/composites.c
@@ -18,7 +18,7 @@
#include "expression.h"
#include "task.h"
#include "utlist.h"
-#include "filter.h"
+#include "scan_result.h"
#include "composites.h"
#include <math.h>
@@ -46,7 +46,7 @@ INIT_LOG_MODULE(composites)
struct composites_data {
struct rspamd_task *task;
struct rspamd_composite *composite;
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
GHashTable *symbols_to_remove;
guint8 *checked;
};
@@ -540,7 +540,7 @@ composites_remove_symbols (gpointer key, gpointer value, gpointer data)
}
static void
-composites_metric_callback (struct rspamd_metric_result *metric_res,
+composites_metric_callback (struct rspamd_scan_result *metric_res,
struct rspamd_task *task)
{
struct composites_data *cd =
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c
index 984a26697..45c6838ec 100644
--- a/src/libserver/dynamic_cfg.c
+++ b/src/libserver/dynamic_cfg.c
@@ -16,7 +16,7 @@
#include "config.h"
#include "rspamd.h"
#include "map.h"
-#include "filter.h"
+#include "scan_result.h"
#include "dynamic_cfg.h"
#include "unix-std.h"
#include "lua/lua_common.h"
diff --git a/src/libserver/milter.c b/src/libserver/milter.c
index 28e0df1c7..2dfe7a53b 100644
--- a/src/libserver/milter.c
+++ b/src/libserver/milter.c
@@ -26,7 +26,7 @@
#include "libutil/http_private.h"
#include "libserver/protocol_internal.h"
#include "libserver/cfg_file_private.h"
-#include "libmime/filter.h"
+#include "libmime/scan_result.h"
#include "libserver/worker_util.h"
#include "utlist.h"
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index dd840284a..e62333262 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -20,7 +20,7 @@
#include "http_private.h"
#include "worker_private.h"
#include "libserver/cfg_file_private.h"
-#include "libmime/filter_private.h"
+#include "libmime/scan_result_private.h"
#include "contrib/zstd/zstd.h"
#include "lua/lua_common.h"
#include "unix-std.h"
@@ -1126,8 +1126,8 @@ rspamd_metric_symbol_ucl (struct rspamd_task *task, struct rspamd_symbol_result
}
static ucl_object_t *
-rspamd_metric_result_ucl (struct rspamd_task *task,
- struct rspamd_metric_result *mres, ucl_object_t *top)
+rspamd_scan_result_ucl (struct rspamd_task *task,
+ struct rspamd_scan_result *mres, ucl_object_t *top)
{
struct rspamd_symbol_result *sym;
gboolean is_spam;
@@ -1349,7 +1349,7 @@ rspamd_protocol_write_ucl (struct rspamd_task *task,
(rspamd_mempool_destruct_t)ucl_object_unref, top);
if (flags & RSPAMD_PROTOCOL_METRICS) {
- rspamd_metric_result_ucl (task, task->result, top);
+ rspamd_scan_result_ucl (task, task->result, top);
}
if (flags & RSPAMD_PROTOCOL_MESSAGES) {
@@ -1488,7 +1488,7 @@ void
rspamd_protocol_http_reply (struct rspamd_http_message *msg,
struct rspamd_task *task, ucl_object_t **pobj)
{
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
const struct rspamd_re_cache_stat *restat;
ucl_object_t *top = NULL;
@@ -1723,7 +1723,7 @@ rspamd_protocol_write_log_pipe (struct rspamd_task *task)
struct rspamd_worker_log_pipe *lp;
struct rspamd_protocol_log_message_sum *ls;
lua_State *L = task->cfg->lua_state;
- struct rspamd_metric_result *mres;
+ struct rspamd_scan_result *mres;
struct rspamd_symbol_result *sym;
gint id, i;
guint32 n = 0, nextra = 0;
diff --git a/src/libserver/protocol.h b/src/libserver/protocol.h
index 280ceedcb..2ba10e926 100644
--- a/src/libserver/protocol.h
+++ b/src/libserver/protocol.h
@@ -7,7 +7,7 @@
#define RSPAMD_PROTOCOL_H
#include "config.h"
-#include "filter.h"
+#include "scan_result.h"
#include "http_connection.h"
#include "task.h"
diff --git a/src/libserver/roll_history.c b/src/libserver/roll_history.c
index ceed8d04f..1a742a441 100644
--- a/src/libserver/roll_history.c
+++ b/src/libserver/roll_history.c
@@ -101,7 +101,7 @@ rspamd_roll_history_update (struct roll_history *history,
{
guint row_num;
struct roll_history_row *row;
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
struct history_metric_callback_data cbdata;
struct rspamd_action *action;
diff --git a/src/libserver/rspamd_symcache.c b/src/libserver/rspamd_symcache.c
index bba4db617..ad5bd4e1c 100644
--- a/src/libserver/rspamd_symcache.c
+++ b/src/libserver/rspamd_symcache.c
@@ -225,7 +225,7 @@ struct cache_savepoint {
gboolean profile;
gdouble profile_start;
- struct rspamd_metric_result *rs;
+ struct rspamd_scan_result *rs;
gdouble lim;
struct rspamd_symcache_item *cur_item;
@@ -1417,7 +1417,7 @@ static gboolean
rspamd_symcache_metric_limit (struct rspamd_task *task,
struct cache_savepoint *cp)
{
- struct rspamd_metric_result *res;
+ struct rspamd_scan_result *res;
double ms;
if (task->flags & RSPAMD_TASK_FLAG_PASS_ALL) {
diff --git a/src/libserver/task.c b/src/libserver/task.c
index e14ce5c5f..acec922a7 100644
--- a/src/libserver/task.c
+++ b/src/libserver/task.c
@@ -15,7 +15,7 @@
*/
#include "task.h"
#include "rspamd.h"
-#include "filter.h"
+#include "scan_result.h"
#include "libserver/protocol.h"
#include "libserver/protocol_internal.h"
#include "message.h"
@@ -29,7 +29,7 @@
#include "libserver/mempool_vars_internal.h"
#include "libserver/cfg_file_private.h"
#include "libmime/lang_detection.h"
-#include "libmime/filter_private.h"
+#include "libmime/scan_result_private.h"
#ifdef WITH_JEMALLOC
#include <jemalloc/jemalloc.h>
@@ -1041,7 +1041,7 @@ rspamd_task_log_metric_res (struct rspamd_task *task,
{
static gchar scorebuf[32];
rspamd_ftok_t res = {.begin = NULL, .len = 0};
- struct rspamd_metric_result *mres;
+ struct rspamd_scan_result *mres;
gboolean first = TRUE;
rspamd_fstring_t *symbuf;
struct rspamd_symbol_result *sym;
@@ -1555,7 +1555,7 @@ rspamd_task_write_log (struct rspamd_task *task)
}
gdouble
-rspamd_task_get_required_score (struct rspamd_task *task, struct rspamd_metric_result *m)
+rspamd_task_get_required_score (struct rspamd_task *task, struct rspamd_scan_result *m)
{
gint i;
diff --git a/src/libserver/task.h b/src/libserver/task.h
index 39d6d9b76..9086578d7 100644
--- a/src/libserver/task.h
+++ b/src/libserver/task.h
@@ -178,7 +178,7 @@ struct rspamd_task {
struct rspamd_task_data_storage msg; /**< message buffer */
struct rspamd_http_connection *http_conn; /**< HTTP server connection */
struct rspamd_async_session *s; /**< async session object */
- struct rspamd_metric_result *result; /**< Metric result */
+ struct rspamd_scan_result *result; /**< Metric result */
GHashTable *lua_cache; /**< cache of lua objects */
GPtrArray *tokens; /**< statistics tokens */
GArray *meta_words; /**< rspamd_stat_token_t produced from meta headers
@@ -301,10 +301,10 @@ gboolean rspamd_learn_task_spam (struct rspamd_task *task,
* @param m
* @return
*/
-struct rspamd_metric_result;
+struct rspamd_scan_result;
gdouble rspamd_task_get_required_score (struct rspamd_task *task,
- struct rspamd_metric_result *m);
+ struct rspamd_scan_result *m);
/**
* Returns the first header as value for a header
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c
index 9fe90a20e..486a9069f 100644
--- a/src/libstat/stat_process.c
+++ b/src/libstat/stat_process.c
@@ -873,7 +873,7 @@ rspamd_stat_learn (struct rspamd_task *task,
static gboolean
rspamd_stat_has_classifier_symbols (struct rspamd_task *task,
- struct rspamd_metric_result *mres,
+ struct rspamd_scan_result *mres,
struct rspamd_classifier *cl)
{
guint i;
@@ -912,7 +912,7 @@ rspamd_stat_check_autolearn (struct rspamd_task *task)
struct rspamd_stat_ctx *st_ctx;
struct rspamd_classifier *cl;
const ucl_object_t *obj, *elt1, *elt2;
- struct rspamd_metric_result *mres = NULL;
+ struct rspamd_scan_result *mres = NULL;
struct rspamd_task **ptask;
lua_State *L;
guint i;
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index 092e7fcb9..f91ce124b 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -24,7 +24,7 @@
#include "libserver/dkim.h"
#include "libserver/task.h"
#include "libserver/cfg_file_private.h"
-#include "libmime/filter_private.h"
+#include "libmime/scan_result_private.h"
#include "libstat/stat_api.h"
#include "libutil/map_helpers.h"
@@ -1878,7 +1878,7 @@ lua_task_adjust_result (lua_State * L)
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
const gchar *symbol_name, *param;
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
struct rspamd_symbol_result *s = NULL;
double weight;
gint i, top;
@@ -4128,7 +4128,7 @@ lua_push_symbol_result (lua_State *L,
gboolean add_metric,
gboolean add_name)
{
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
struct rspamd_symbol_result *s = NULL;
struct rspamd_symbol_option *opt;
struct rspamd_symbols_group *sym_group;
@@ -4306,7 +4306,7 @@ lua_task_get_symbols (lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
- struct rspamd_metric_result *mres;
+ struct rspamd_scan_result *mres;
gint i = 1;
struct rspamd_symbol_result *s;
@@ -4344,7 +4344,7 @@ lua_task_get_symbols_all (lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
- struct rspamd_metric_result *mres;
+ struct rspamd_scan_result *mres;
struct rspamd_symbol_result *s;
gboolean found = FALSE;
gint i = 1;
@@ -4379,7 +4379,7 @@ lua_task_get_symbols_numeric (lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
- struct rspamd_metric_result *mres;
+ struct rspamd_scan_result *mres;
gint i = 1, id;
struct rspamd_symbol_result *s;
@@ -5010,7 +5010,7 @@ lua_task_set_settings (lua_State *L)
ucl_object_t *settings;
const ucl_object_t *act, *metric_elt, *vars, *cur;
ucl_object_iter_t it = NULL;
- struct rspamd_metric_result *mres;
+ struct rspamd_scan_result *mres;
guint i;
settings = ucl_object_lua_import (L, 2);
@@ -5472,7 +5472,7 @@ lua_task_get_metric_result (lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
struct rspamd_action *action;
if (task) {
@@ -5534,7 +5534,7 @@ lua_task_get_metric_score (lua_State *L)
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
gdouble rs;
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
if (task) {
if ((metric_res = task->result) != NULL) {
@@ -5561,7 +5561,7 @@ lua_task_get_metric_action (lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
struct rspamd_action *action;
if (task) {
@@ -5582,7 +5582,7 @@ lua_task_set_metric_score (lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task (L, 1);
- struct rspamd_metric_result *metric_res;
+ struct rspamd_scan_result *metric_res;
gdouble nscore;
if (lua_isnumber (L, 2)) {
More information about the Commits
mailing list