aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-03-18 18:56:33 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-03-18 18:56:33 +0000
commit14c13854d3cae9d93c3d148be30fb72f1eaffe55 (patch)
tree7b1a3e41b75490fac4d45722c90a1847543c6796 /src/plugins
parent6b2b4167187fee09365271cca182866ecb029af3 (diff)
downloadrspamd-14c13854d3cae9d93c3d148be30fb72f1eaffe55.tar.gz
rspamd-14c13854d3cae9d93c3d148be30fb72f1eaffe55.zip
[Rework] Further types conversion (no functional changes)
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/chartable.cxx66
-rw-r--r--src/plugins/dkim_check.c144
-rw-r--r--src/plugins/fuzzy_check.c440
-rw-r--r--src/plugins/regexp.c40
4 files changed, 345 insertions, 345 deletions
diff --git a/src/plugins/chartable.cxx b/src/plugins/chartable.cxx
index 172242ba3..a5c7cb899 100644
--- a/src/plugins/chartable.cxx
+++ b/src/plugins/chartable.cxx
@@ -45,11 +45,11 @@
INIT_LOG_MODULE(chartable)
/* Initialization */
-gint chartable_module_init(struct rspamd_config *cfg, struct module_ctx **ctx);
+int chartable_module_init(struct rspamd_config *cfg, struct module_ctx **ctx);
-gint chartable_module_config(struct rspamd_config *cfg, bool validate);
+int chartable_module_config(struct rspamd_config *cfg, bool validate);
-gint chartable_module_reconfig(struct rspamd_config *cfg);
+int chartable_module_reconfig(struct rspamd_config *cfg);
module_t chartable_module = {
"chartable",
@@ -58,15 +58,15 @@ module_t chartable_module = {
chartable_module_reconfig,
nullptr,
RSPAMD_MODULE_VER,
- (guint) -1,
+ (unsigned int) -1,
};
struct chartable_ctx {
struct module_ctx ctx;
- const gchar *symbol;
- const gchar *url_symbol;
+ const char *symbol;
+ const char *url_symbol;
double threshold;
- guint max_word_len;
+ unsigned int max_word_len;
};
static inline struct chartable_ctx *
@@ -84,7 +84,7 @@ static void chartable_url_symbol_callback(struct rspamd_task *task,
struct rspamd_symcache_dynamic_item *item,
void *unused);
-gint chartable_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
+int chartable_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
{
struct chartable_ctx *chartable_module_ctx;
@@ -98,10 +98,10 @@ gint chartable_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
}
-gint chartable_module_config(struct rspamd_config *cfg, bool _)
+int chartable_module_config(struct rspamd_config *cfg, bool _)
{
const ucl_object_t *value;
- gint res = TRUE;
+ int res = TRUE;
struct chartable_ctx *chartable_module_ctx = chartable_get_context(cfg);
if (!rspamd_config_is_module_enabled(cfg, "chartable")) {
@@ -160,7 +160,7 @@ gint chartable_module_config(struct rspamd_config *cfg, bool _)
return res;
}
-gint chartable_module_reconfig(struct rspamd_config *cfg)
+int chartable_module_reconfig(struct rspamd_config *cfg)
{
return chartable_module_config(cfg, false);
}
@@ -1689,26 +1689,26 @@ static const auto latin_confusable = ankerl::unordered_dense::set<int>{
};
static gboolean
-rspamd_can_alias_latin(gint ch)
+rspamd_can_alias_latin(int ch)
{
return latin_confusable.contains(ch);
}
-static gdouble
+static double
rspamd_chartable_process_word_utf(struct rspamd_task *task,
rspamd_stat_token_t *w,
gboolean is_url,
- guint *ncap,
+ unsigned int *ncap,
struct chartable_ctx *chartable_module_ctx,
gboolean ignore_diacritics)
{
const UChar32 *p, *end;
- gdouble badness = 0.0;
+ double badness = 0.0;
UChar32 uc;
UBlockCode sc;
- guint cat;
- gint last_is_latin = -1;
- guint same_script_count = 0, nsym = 0, nspecial = 0;
+ unsigned int cat;
+ int last_is_latin = -1;
+ unsigned int same_script_count = 0, nsym = 0, nspecial = 0;
enum {
start_process = 0,
got_alpha,
@@ -1773,7 +1773,7 @@ rspamd_chartable_process_word_utf(struct rspamd_task *task,
if (sc != UBLOCK_BASIC_LATIN && last_is_latin) {
if (rspamd_can_alias_latin(uc)) {
- badness += 1.0 / (gdouble) same_script_count;
+ badness += 1.0 / (double) same_script_count;
}
last_is_latin = 0;
@@ -1834,25 +1834,25 @@ rspamd_chartable_process_word_utf(struct rspamd_task *task,
}
msg_debug_chartable("word %*s, badness: %.2f",
- (gint) w->normalized.len, w->normalized.begin,
+ (int) w->normalized.len, w->normalized.begin,
badness);
return badness;
}
-static gdouble
+static double
rspamd_chartable_process_word_ascii(struct rspamd_task *task,
rspamd_stat_token_t *w,
gboolean is_url,
struct chartable_ctx *chartable_module_ctx)
{
- gdouble badness = 0.0;
+ double badness = 0.0;
enum {
ascii = 1,
non_ascii
} sc,
last_sc;
- gint same_script_count = 0, seen_alpha = FALSE;
+ int same_script_count = 0, seen_alpha = FALSE;
enum {
start_process = 0,
got_alpha,
@@ -1884,7 +1884,7 @@ rspamd_chartable_process_word_ascii(struct rspamd_task *task,
if (same_script_count > 0) {
if (sc != last_sc) {
- badness += 1.0 / (gdouble) same_script_count;
+ badness += 1.0 / (double) same_script_count;
last_sc = sc;
same_script_count = 1;
}
@@ -1919,7 +1919,7 @@ rspamd_chartable_process_word_ascii(struct rspamd_task *task,
}
msg_debug_chartable("word %*s, badness: %.2f",
- (gint) w->normalized.len, w->normalized.begin,
+ (int) w->normalized.len, w->normalized.begin,
badness);
return badness;
@@ -1932,8 +1932,8 @@ rspamd_chartable_process_part(struct rspamd_task *task,
gboolean ignore_diacritics)
{
rspamd_stat_token_t *w;
- guint i, ncap = 0;
- gdouble cur_score = 0.0;
+ unsigned int i, ncap = 0;
+ double cur_score = 0.0;
if (part == nullptr || part->utf_words == nullptr ||
part->utf_words->len == 0 || part->nwords == 0) {
@@ -1963,7 +1963,7 @@ rspamd_chartable_process_part(struct rspamd_task *task,
*/
part->capital_letters += ncap;
- cur_score /= (gdouble) part->nwords;
+ cur_score /= (double) part->nwords;
if (cur_score > 1.0) {
cur_score = 1.0;
@@ -1983,7 +1983,7 @@ chartable_symbol_callback(struct rspamd_task *task,
struct rspamd_symcache_dynamic_item *item,
void *_)
{
- guint i;
+ unsigned int i;
struct rspamd_mime_text_part *part;
struct chartable_ctx *chartable_module_ctx = chartable_get_context(task->cfg);
gboolean ignore_diacritics = TRUE, seen_violated_part = FALSE;
@@ -1993,7 +1993,7 @@ chartable_symbol_callback(struct rspamd_task *task,
{
if (part->languages && part->languages->len > 0) {
auto *lang = (struct rspamd_lang_detector_res *) g_ptr_array_index(part->languages, 0);
- gint flags;
+ int flags;
flags = rspamd_language_detector_elt_flags(lang->elt);
@@ -2017,7 +2017,7 @@ chartable_symbol_callback(struct rspamd_task *task,
if (task->meta_words != nullptr && task->meta_words->len > 0) {
rspamd_stat_token_t *w;
- gdouble cur_score = 0;
+ double cur_score = 0;
gsize arlen = task->meta_words->len;
for (i = 0; i < arlen; i++) {
@@ -2026,7 +2026,7 @@ chartable_symbol_callback(struct rspamd_task *task,
nullptr, chartable_module_ctx, ignore_diacritics);
}
- cur_score /= (gdouble) (arlen + 1);
+ cur_score /= (double) (arlen + 1);
if (cur_score > 1.0) {
cur_score = 1.0;
@@ -2059,7 +2059,7 @@ chartable_url_symbol_callback(struct rspamd_task *task,
GHashTableIter it;
gpointer k, v;
rspamd_stat_token_t w;
- gdouble cur_score = 0.0;
+ double cur_score = 0.0;
struct chartable_ctx *chartable_module_ctx = chartable_get_context (task->cfg);
g_hash_table_iter_init (&it, task->urls);
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index 1e1b13c73..b0340738e 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -51,39 +51,39 @@
#define DEFAULT_TIME_JITTER 60
#define DEFAULT_MAX_SIGS 5
-static const gchar *M = "rspamd dkim plugin";
-
-static const gchar default_sign_headers[] = ""
- "(o)from:(x)sender:(o)reply-to:(o)subject:(x)date:(x)message-id:"
- "(o)to:(o)cc:(x)mime-version:(x)content-type:(x)content-transfer-encoding:"
- "resent-to:resent-cc:resent-from:resent-sender:resent-message-id:"
- "(x)in-reply-to:(x)references:list-id:list-help:list-owner:list-unsubscribe:"
- "list-unsubscribe-post:list-subscribe:list-post:(x)openpgp:(x)autocrypt";
-static const gchar default_arc_sign_headers[] = ""
- "(o)from:(x)sender:(o)reply-to:(o)subject:(x)date:(x)message-id:"
- "(o)to:(o)cc:(x)mime-version:(x)content-type:(x)content-transfer-encoding:"
- "resent-to:resent-cc:resent-from:resent-sender:resent-message-id:"
- "(x)in-reply-to:(x)references:list-id:list-help:list-owner:list-unsubscribe:"
- "list-unsubscribe-post:list-subscribe:list-post:dkim-signature:(x)openpgp:"
- "(x)autocrypt";
+static const char *M = "rspamd dkim plugin";
+
+static const char default_sign_headers[] = ""
+ "(o)from:(x)sender:(o)reply-to:(o)subject:(x)date:(x)message-id:"
+ "(o)to:(o)cc:(x)mime-version:(x)content-type:(x)content-transfer-encoding:"
+ "resent-to:resent-cc:resent-from:resent-sender:resent-message-id:"
+ "(x)in-reply-to:(x)references:list-id:list-help:list-owner:list-unsubscribe:"
+ "list-unsubscribe-post:list-subscribe:list-post:(x)openpgp:(x)autocrypt";
+static const char default_arc_sign_headers[] = ""
+ "(o)from:(x)sender:(o)reply-to:(o)subject:(x)date:(x)message-id:"
+ "(o)to:(o)cc:(x)mime-version:(x)content-type:(x)content-transfer-encoding:"
+ "resent-to:resent-cc:resent-from:resent-sender:resent-message-id:"
+ "(x)in-reply-to:(x)references:list-id:list-help:list-owner:list-unsubscribe:"
+ "list-unsubscribe-post:list-subscribe:list-post:dkim-signature:(x)openpgp:"
+ "(x)autocrypt";
struct dkim_ctx {
struct module_ctx ctx;
- const gchar *symbol_reject;
- const gchar *symbol_tempfail;
- const gchar *symbol_allow;
- const gchar *symbol_na;
- const gchar *symbol_permfail;
+ const char *symbol_reject;
+ const char *symbol_tempfail;
+ const char *symbol_allow;
+ const char *symbol_na;
+ const char *symbol_permfail;
struct rspamd_radix_map_helper *whitelist_ip;
struct rspamd_hash_map_helper *dkim_domains;
- guint strict_multiplier;
- guint time_jitter;
+ unsigned int strict_multiplier;
+ unsigned int time_jitter;
rspamd_lru_hash_t *dkim_hash;
rspamd_lru_hash_t *dkim_sign_hash;
- const gchar *sign_headers;
- const gchar *arc_sign_headers;
- guint max_sigs;
+ const char *sign_headers;
+ const char *arc_sign_headers;
+ unsigned int max_sigs;
gboolean trusted_only;
gboolean check_local;
gboolean check_authed;
@@ -94,8 +94,8 @@ struct dkim_check_result {
rspamd_dkim_key_t *key;
struct rspamd_task *task;
struct rspamd_dkim_check_result *res;
- gdouble mult_allow;
- gdouble mult_deny;
+ double mult_allow;
+ double mult_deny;
struct rspamd_symcache_dynamic_item *item;
struct dkim_check_result *next, *prev, *first;
};
@@ -104,14 +104,14 @@ static void dkim_symbol_callback(struct rspamd_task *task,
struct rspamd_symcache_dynamic_item *item,
void *unused);
-static gint lua_dkim_sign_handler(lua_State *L);
-static gint lua_dkim_verify_handler(lua_State *L);
-static gint lua_dkim_canonicalize_handler(lua_State *L);
+static int lua_dkim_sign_handler(lua_State *L);
+static int lua_dkim_verify_handler(lua_State *L);
+static int lua_dkim_canonicalize_handler(lua_State *L);
/* Initialization */
-gint dkim_module_init(struct rspamd_config *cfg, struct module_ctx **ctx);
-gint dkim_module_config(struct rspamd_config *cfg, bool validate);
-gint dkim_module_reconfig(struct rspamd_config *cfg);
+int dkim_module_init(struct rspamd_config *cfg, struct module_ctx **ctx);
+int dkim_module_config(struct rspamd_config *cfg, bool validate);
+int dkim_module_reconfig(struct rspamd_config *cfg);
module_t dkim_module = {
"dkim",
@@ -120,7 +120,7 @@ module_t dkim_module = {
dkim_module_reconfig,
NULL,
RSPAMD_MODULE_VER,
- (guint) -1,
+ (unsigned int) -1,
};
static inline struct dkim_ctx *
@@ -144,7 +144,7 @@ dkim_module_free_list(gpointer k)
g_list_free_full((GList *) k, rspamd_gstring_free_hard);
}
-gint dkim_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
+int dkim_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
{
struct dkim_ctx *dkim_module_ctx;
@@ -304,11 +304,11 @@ gint dkim_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
return 0;
}
-gint dkim_module_config(struct rspamd_config *cfg, bool validate)
+int dkim_module_config(struct rspamd_config *cfg, bool validate)
{
const ucl_object_t *value;
- gint res = TRUE, cb_id = -1;
- guint cache_size, sign_cache_size;
+ int res = TRUE, cb_id = -1;
+ unsigned int cache_size, sign_cache_size;
gboolean got_trusted = FALSE;
struct dkim_ctx *dkim_module_ctx = dkim_get_context(cfg);
@@ -614,11 +614,11 @@ gint dkim_module_config(struct rspamd_config *cfg, bool validate)
rspamd_dkim_sign_key_t *
dkim_module_load_key_format(struct rspamd_task *task,
struct dkim_ctx *dkim_module_ctx,
- const gchar *key, gsize keylen,
+ const char *key, gsize keylen,
enum rspamd_dkim_key_format key_format)
{
- guchar h[rspamd_cryptobox_HASHBYTES],
+ unsigned char h[rspamd_cryptobox_HASHBYTES],
hex_hash[rspamd_cryptobox_HASHBYTES * 2 + 1];
rspamd_dkim_sign_key_t *ret = NULL;
GError *err = NULL;
@@ -691,7 +691,7 @@ dkim_module_load_key_format(struct rspamd_task *task,
return ret;
}
-static gint
+static int
lua_dkim_sign_handler(lua_State *L)
{
struct rspamd_task *task = lua_check_task(L, 1);
@@ -700,9 +700,9 @@ lua_dkim_sign_handler(lua_State *L)
GError *err = NULL;
GString *hdr;
GList *sigs = NULL;
- const gchar *selector = NULL, *domain = NULL, *key = NULL, *rawkey = NULL,
- *headers = NULL, *sign_type_str = NULL, *arc_cv = NULL,
- *pubkey = NULL;
+ const char *selector = NULL, *domain = NULL, *key = NULL, *rawkey = NULL,
+ *headers = NULL, *sign_type_str = NULL, *arc_cv = NULL,
+ *pubkey = NULL;
rspamd_dkim_sign_context_t *ctx;
rspamd_dkim_sign_key_t *dkim_key;
gsize rawlen = 0, keylen = 0;
@@ -895,7 +895,7 @@ lua_dkim_sign_handler(lua_State *L)
return 2;
}
-gint dkim_module_reconfig(struct rspamd_config *cfg)
+int dkim_module_reconfig(struct rspamd_config *cfg)
{
return dkim_module_config(cfg, false);
}
@@ -904,12 +904,12 @@ gint dkim_module_reconfig(struct rspamd_config *cfg)
* Parse strict value for domain in format: 'reject_multiplier:deny_multiplier'
*/
static gboolean
-dkim_module_parse_strict(const gchar *value, gdouble *allow, gdouble *deny)
+dkim_module_parse_strict(const char *value, double *allow, double *deny)
{
- const gchar *colon;
- gchar *err = NULL;
- gdouble val;
- gchar numbuf[64];
+ const char *colon;
+ char *err = NULL;
+ double val;
+ char numbuf[64];
colon = strchr(value, ':');
if (colon) {
@@ -937,7 +937,7 @@ static void
dkim_module_check(struct dkim_check_result *res)
{
gboolean all_done = TRUE;
- const gchar *strict_value;
+ const char *strict_value;
struct dkim_check_result *first, *cur = NULL;
struct dkim_ctx *dkim_module_ctx = dkim_get_context(res->task->cfg);
struct rspamd_task *task = res->task;
@@ -955,7 +955,7 @@ dkim_module_check(struct dkim_check_result *res)
if (dkim_module_ctx->dkim_domains != NULL) {
/* Perform strict check */
- const gchar *domain = rspamd_dkim_get_domain(cur->ctx);
+ const char *domain = rspamd_dkim_get_domain(cur->ctx);
if ((strict_value =
rspamd_match_hash_map(dkim_module_ctx->dkim_domains,
@@ -985,7 +985,7 @@ dkim_module_check(struct dkim_check_result *res)
if (all_done) {
/* Create zero terminated array of results */
struct rspamd_dkim_check_result **pres;
- guint nres = 0, i = 0;
+ unsigned int nres = 0, i = 0;
DL_FOREACH(first, cur)
{
@@ -1001,8 +1001,8 @@ dkim_module_check(struct dkim_check_result *res)
DL_FOREACH(first, cur)
{
- const gchar *symbol = NULL, *trace = NULL;
- gdouble symbol_weight = 1.0;
+ const char *symbol = NULL, *trace = NULL;
+ double symbol_weight = 1.0;
if (cur->ctx == NULL || cur->res == NULL) {
continue;
@@ -1030,10 +1030,10 @@ dkim_module_check(struct dkim_check_result *res)
}
if (symbol != NULL) {
- const gchar *domain = rspamd_dkim_get_domain(cur->ctx);
- const gchar *selector = rspamd_dkim_get_selector(cur->ctx);
+ const char *domain = rspamd_dkim_get_domain(cur->ctx);
+ const char *selector = rspamd_dkim_get_selector(cur->ctx);
gsize tracelen;
- gchar *tracebuf;
+ char *tracebuf;
tracelen = strlen(domain) + strlen(selector) + 4;
tracebuf = rspamd_mempool_alloc(task->task_pool,
@@ -1131,8 +1131,8 @@ dkim_symbol_callback(struct rspamd_task *task,
GError *err = NULL;
struct rspamd_mime_header *rh, *rh_cur;
struct dkim_check_result *res = NULL, *cur;
- guint checked = 0;
- gdouble *dmarc_checks;
+ unsigned int checked = 0;
+ double *dmarc_checks;
struct dkim_ctx *dkim_module_ctx = dkim_get_context(task->cfg);
/* Allow dmarc */
@@ -1223,7 +1223,7 @@ dkim_symbol_callback(struct rspamd_task *task,
else {
/* Get key */
cur->ctx = ctx;
- const gchar *domain = rspamd_dkim_get_domain(cur->ctx);
+ const char *domain = rspamd_dkim_get_domain(cur->ctx);
if (dkim_module_ctx->trusted_only &&
(dkim_module_ctx->dkim_domains == NULL ||
@@ -1290,7 +1290,7 @@ struct rspamd_dkim_lua_verify_cbdata {
struct rspamd_task *task;
lua_State *L;
rspamd_dkim_key_t *key;
- gint cbref;
+ int cbref;
};
static void
@@ -1298,7 +1298,7 @@ dkim_module_lua_push_verify_result(struct rspamd_dkim_lua_verify_cbdata *cbd,
struct rspamd_dkim_check_result *res, GError *err)
{
struct rspamd_task **ptask, *task;
- const gchar *error_str = "unknown error";
+ const char *error_str = "unknown error";
gboolean success = FALSE;
task = cbd->task;
@@ -1474,17 +1474,17 @@ dkim_module_lua_on_key(rspamd_dkim_key_t *key,
dkim_module_lua_push_verify_result(cbd, res, NULL);
}
-static gint
+static int
lua_dkim_verify_handler(lua_State *L)
{
struct rspamd_task *task = lua_check_task(L, 1);
- const gchar *sig = luaL_checkstring(L, 2);
+ const char *sig = luaL_checkstring(L, 2);
rspamd_dkim_context_t *ctx;
struct rspamd_dkim_lua_verify_cbdata *cbd;
rspamd_dkim_key_t *key;
struct rspamd_dkim_check_result *ret;
GError *err = NULL;
- const gchar *type_str = NULL;
+ const char *type_str = NULL;
enum rspamd_dkim_type type = RSPAMD_DKIM_NORMAL;
struct dkim_ctx *dkim_module_ctx;
@@ -1575,15 +1575,15 @@ lua_dkim_verify_handler(lua_State *L)
return 2;
}
-static gint
+static int
lua_dkim_canonicalize_handler(lua_State *L)
{
gsize nlen, vlen;
- const gchar *hname = luaL_checklstring(L, 1, &nlen),
- *hvalue = luaL_checklstring(L, 2, &vlen);
- static gchar st_buf[8192];
- gchar *buf;
- guint inlen;
+ const char *hname = luaL_checklstring(L, 1, &nlen),
+ *hvalue = luaL_checklstring(L, 2, &vlen);
+ static char st_buf[8192];
+ char *buf;
+ unsigned int inlen;
gboolean allocated = FALSE;
goffset r;
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 0bc7bd69d..75968ce84 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -58,28 +58,28 @@
#define RSPAMD_FUZZY_PLUGIN_VERSION RSPAMD_FUZZY_VERSION
-static const gint rspamd_fuzzy_hash_len = 5;
-static const gchar *M = "fuzzy check";
+static const int rspamd_fuzzy_hash_len = 5;
+static const char *M = "fuzzy check";
struct fuzzy_ctx;
struct fuzzy_mapping {
uint64_t fuzzy_flag;
- const gchar *symbol;
+ const char *symbol;
double weight;
};
struct fuzzy_rule {
struct upstream_list *servers;
- const gchar *symbol;
- const gchar *algorithm_str;
- const gchar *name;
+ const char *symbol;
+ const char *algorithm_str;
+ const char *name;
const ucl_object_t *ucl_obj;
enum rspamd_shingle_alg alg;
GHashTable *mappings;
GPtrArray *fuzzy_headers;
GString *hash_key;
GString *shingles_key;
- gdouble io_timeout;
+ double io_timeout;
struct rspamd_cryptobox_keypair *local_key;
struct rspamd_cryptobox_pubkey *peer_key;
double max_score;
@@ -88,11 +88,11 @@ struct fuzzy_rule {
gboolean skip_unknown;
gboolean no_share;
gboolean no_subject;
- gint learn_condition_cb;
+ int learn_condition_cb;
uint32_t retransmits;
struct rspamd_hash_map_helper *skip_map;
struct fuzzy_ctx *ctx;
- gint lua_id;
+ int lua_id;
};
struct fuzzy_ctx {
@@ -100,15 +100,15 @@ struct fuzzy_ctx {
rspamd_mempool_t *fuzzy_pool;
GPtrArray *fuzzy_rules;
struct rspamd_config *cfg;
- const gchar *default_symbol;
+ const char *default_symbol;
struct rspamd_radix_map_helper *whitelist;
struct rspamd_keypair_cache *keypairs_cache;
- guint max_errors;
- gdouble revive_time;
- gdouble io_timeout;
- gint check_mime_part_ref; /* Lua callback */
- gint process_rule_ref; /* Lua callback */
- gint cleanup_rules_ref;
+ unsigned int max_errors;
+ double revive_time;
+ double io_timeout;
+ int check_mime_part_ref; /* Lua callback */
+ int process_rule_ref; /* Lua callback */
+ int cleanup_rules_ref;
uint32_t retransmits;
gboolean enabled;
};
@@ -121,10 +121,10 @@ enum fuzzy_result_type {
};
struct fuzzy_client_result {
- const gchar *symbol;
- gchar *option;
- gdouble score;
- gdouble prob;
+ const char *symbol;
+ char *option;
+ double score;
+ double prob;
enum fuzzy_result_type type;
};
@@ -137,17 +137,17 @@ struct fuzzy_client_session {
struct fuzzy_rule *rule;
struct ev_loop *event_loop;
struct rspamd_io_ev ev;
- gint state;
- gint fd;
- guint retransmits;
+ int state;
+ int fd;
+ unsigned int retransmits;
};
struct fuzzy_learn_session {
GPtrArray *commands;
- gint *saved;
+ int *saved;
struct {
- const gchar *error_message;
- gint error_code;
+ const char *error_message;
+ int error_code;
} err;
struct rspamd_http_connection_entry *http_entry;
struct rspamd_async_session *session;
@@ -156,8 +156,8 @@ struct fuzzy_learn_session {
struct rspamd_task *task;
struct ev_loop *event_loop;
struct rspamd_io_ev ev;
- gint fd;
- guint retransmits;
+ int fd;
+ unsigned int retransmits;
};
#define FUZZY_CMD_FLAG_REPLIED (1 << 0)
@@ -185,18 +185,18 @@ static void fuzzy_symbol_callback(struct rspamd_task *task,
void *unused);
/* Initialization */
-gint fuzzy_check_module_init(struct rspamd_config *cfg,
- struct module_ctx **ctx);
-gint fuzzy_check_module_config(struct rspamd_config *cfg, bool valdate);
-gint fuzzy_check_module_reconfig(struct rspamd_config *cfg);
-static gint fuzzy_attach_controller(struct module_ctx *ctx,
- GHashTable *commands);
-static gint fuzzy_lua_learn_handler(lua_State *L);
-static gint fuzzy_lua_unlearn_handler(lua_State *L);
-static gint fuzzy_lua_gen_hashes_handler(lua_State *L);
-static gint fuzzy_lua_hex_hashes_handler(lua_State *L);
-static gint fuzzy_lua_list_storages(lua_State *L);
-static gint fuzzy_lua_ping_storage(lua_State *L);
+int fuzzy_check_module_init(struct rspamd_config *cfg,
+ struct module_ctx **ctx);
+int fuzzy_check_module_config(struct rspamd_config *cfg, bool valdate);
+int fuzzy_check_module_reconfig(struct rspamd_config *cfg);
+static int fuzzy_attach_controller(struct module_ctx *ctx,
+ GHashTable *commands);
+static int fuzzy_lua_learn_handler(lua_State *L);
+static int fuzzy_lua_unlearn_handler(lua_State *L);
+static int fuzzy_lua_gen_hashes_handler(lua_State *L);
+static int fuzzy_lua_hex_hashes_handler(lua_State *L);
+static int fuzzy_lua_list_storages(lua_State *L);
+static int fuzzy_lua_ping_storage(lua_State *L);
module_t fuzzy_check_module = {
"fuzzy_check",
@@ -205,7 +205,7 @@ module_t fuzzy_check_module = {
fuzzy_check_module_reconfig,
fuzzy_attach_controller,
RSPAMD_MODULE_VER,
- (guint) -1,
+ (unsigned int) -1,
};
static inline struct fuzzy_ctx *
@@ -219,11 +219,11 @@ static void
parse_flags(struct fuzzy_rule *rule,
struct rspamd_config *cfg,
const ucl_object_t *val,
- gint cb_id)
+ int cb_id)
{
const ucl_object_t *elt;
struct fuzzy_mapping *map;
- const gchar *sym = NULL;
+ const char *sym = NULL;
if (val->type == UCL_STRING) {
msg_err_config(
@@ -275,10 +275,10 @@ parse_flags(struct fuzzy_rule *rule,
}
static GPtrArray *
-parse_fuzzy_headers(struct rspamd_config *cfg, const gchar *str)
+parse_fuzzy_headers(struct rspamd_config *cfg, const char *str)
{
- gchar **strvec;
- gint num, i;
+ char **strvec;
+ int num, i;
GPtrArray *res;
strvec = g_strsplit_set(str, ",", 0);
@@ -344,9 +344,9 @@ fuzzy_free_rule(gpointer r)
}
}
-static gint
+static int
fuzzy_parse_rule(struct rspamd_config *cfg, const ucl_object_t *obj,
- const gchar *name, gint cb_id)
+ const char *name, int cb_id)
{
const ucl_object_t *value, *cur;
struct fuzzy_rule *rule;
@@ -389,7 +389,7 @@ fuzzy_parse_rule(struct rspamd_config *cfg, const ucl_object_t *obj,
it = NULL;
while ((cur = ucl_object_iterate(value, &it, value->type == UCL_ARRAY)) != NULL) {
GPtrArray *tmp;
- guint i;
+ unsigned int i;
gpointer ptr;
tmp = parse_fuzzy_headers(cfg, ucl_obj_tostring(cur));
@@ -513,8 +513,8 @@ fuzzy_parse_rule(struct rspamd_config *cfg, const ucl_object_t *obj,
* it allows to configure error_rate threshold and upstream dead timer
*/
rspamd_upstreams_set_limits(rule->servers,
- (gdouble) fuzzy_module_ctx->revive_time, NAN, NAN, NAN,
- (guint) fuzzy_module_ctx->max_errors, 0);
+ (double) fuzzy_module_ctx->revive_time, NAN, NAN, NAN,
+ (unsigned int) fuzzy_module_ctx->max_errors, 0);
rspamd_mempool_add_destructor(cfg->cfg_pool,
(rspamd_mempool_destruct_t) rspamd_upstreams_destroy,
@@ -643,7 +643,7 @@ fuzzy_parse_rule(struct rspamd_config *cfg, const ucl_object_t *obj,
/*
* Process rule in Lua
*/
- gint err_idx, ret;
+ int err_idx, ret;
lua_State *L = (lua_State *) cfg->lua_state;
lua_pushcfunction(L, &rspamd_lua_traceback);
@@ -670,7 +670,7 @@ fuzzy_parse_rule(struct rspamd_config *cfg, const ucl_object_t *obj,
return 0;
}
-gint fuzzy_check_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
+int fuzzy_check_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
{
struct fuzzy_ctx *fuzzy_module_ctx;
@@ -995,11 +995,11 @@ gint fuzzy_check_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
return 0;
}
-gint fuzzy_check_module_config(struct rspamd_config *cfg, bool validate)
+int fuzzy_check_module_config(struct rspamd_config *cfg, bool validate)
{
const ucl_object_t *value, *cur, *elt;
ucl_object_iter_t it;
- gint res = TRUE, cb_id, nrules = 0;
+ int res = TRUE, cb_id, nrules = 0;
lua_State *L = cfg->lua_state;
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context(cfg);
@@ -1240,13 +1240,13 @@ gint fuzzy_check_module_config(struct rspamd_config *cfg, bool validate)
return res;
}
-gint fuzzy_check_module_reconfig(struct rspamd_config *cfg)
+int fuzzy_check_module_reconfig(struct rspamd_config *cfg)
{
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context(cfg);
if (fuzzy_module_ctx->cleanup_rules_ref != -1) {
/* Sync lua_fuzzy rules */
- gint err_idx, ret;
+ int err_idx, ret;
lua_State *L = (lua_State *) cfg->lua_state;
lua_pushcfunction(L, &rspamd_lua_traceback);
@@ -1304,10 +1304,10 @@ fuzzy_preprocess_words(struct rspamd_mime_text_part *part, rspamd_mempool_t *poo
static void
fuzzy_encrypt_cmd(struct fuzzy_rule *rule,
struct rspamd_fuzzy_encrypted_req_hdr *hdr,
- guchar *data, gsize datalen)
+ unsigned char *data, gsize datalen)
{
- const guchar *pk;
- guint pklen;
+ const unsigned char *pk;
+ unsigned int pklen;
g_assert(hdr != NULL);
g_assert(data != NULL);
@@ -1334,7 +1334,7 @@ fuzzy_encrypt_cmd(struct fuzzy_rule *rule,
static struct fuzzy_cmd_io *
fuzzy_cmd_stat(struct fuzzy_rule *rule,
int c,
- gint flag,
+ int flag,
uint32_t weight,
rspamd_mempool_t *pool)
{
@@ -1361,7 +1361,7 @@ fuzzy_cmd_stat(struct fuzzy_rule *rule,
memcpy(&io->cmd, cmd, sizeof(io->cmd));
if (rule->peer_key && enccmd) {
- fuzzy_encrypt_cmd(rule, &enccmd->hdr, (guchar *) cmd, sizeof(*cmd));
+ fuzzy_encrypt_cmd(rule, &enccmd->hdr, (unsigned char *) cmd, sizeof(*cmd));
io->io.iov_base = enccmd;
io->io.iov_len = sizeof(*enccmd);
}
@@ -1414,7 +1414,7 @@ fuzzy_cmd_ping(struct fuzzy_rule *rule,
memcpy(&io->cmd, cmd, sizeof(io->cmd));
if (rule->peer_key && enccmd) {
- fuzzy_encrypt_cmd(rule, &enccmd->hdr, (guchar *) cmd, sizeof(*cmd));
+ fuzzy_encrypt_cmd(rule, &enccmd->hdr, (unsigned char *) cmd, sizeof(*cmd));
io->io.iov_base = enccmd;
io->io.iov_len = sizeof(*enccmd);
}
@@ -1430,7 +1430,7 @@ static struct fuzzy_cmd_io *
fuzzy_cmd_hash(struct fuzzy_rule *rule,
int c,
const rspamd_ftok_t *hash,
- gint flag,
+ int flag,
uint32_t weight,
rspamd_mempool_t *pool)
{
@@ -1471,7 +1471,7 @@ fuzzy_cmd_hash(struct fuzzy_rule *rule,
memcpy(&io->cmd, cmd, sizeof(io->cmd));
if (rule->peer_key && enccmd) {
- fuzzy_encrypt_cmd(rule, &enccmd->hdr, (guchar *) cmd, sizeof(*cmd));
+ fuzzy_encrypt_cmd(rule, &enccmd->hdr, (unsigned char *) cmd, sizeof(*cmd));
io->io.iov_base = enccmd;
io->io.iov_len = sizeof(*enccmd);
}
@@ -1485,9 +1485,9 @@ fuzzy_cmd_hash(struct fuzzy_rule *rule,
struct rspamd_cached_shingles {
struct rspamd_shingle *sh;
- guchar digest[rspamd_cryptobox_HASHBYTES];
- guint additional_length;
- guchar *additional_data;
+ unsigned char digest[rspamd_cryptobox_HASHBYTES];
+ unsigned int additional_length;
+ unsigned char *additional_data;
};
@@ -1496,8 +1496,8 @@ fuzzy_cmd_get_cached(struct fuzzy_rule *rule,
struct rspamd_task *task,
struct rspamd_mime_part *mp)
{
- gchar key[32];
- gint key_part;
+ char key[32];
+ int key_part;
struct rspamd_cached_shingles **cached;
memcpy(&key_part, rule->shingles_key->str, sizeof(key_part));
@@ -1520,8 +1520,8 @@ fuzzy_cmd_set_cached(struct fuzzy_rule *rule,
struct rspamd_mime_part *mp,
struct rspamd_cached_shingles *data)
{
- gchar key[32];
- gint key_part;
+ char key[32];
+ int key_part;
struct rspamd_cached_shingles **cached;
memcpy(&key_part, rule->shingles_key->str, sizeof(key_part));
@@ -1552,10 +1552,10 @@ fuzzy_rule_check_mimepart(struct rspamd_task *task,
{
lua_State *L = (lua_State *) task->cfg->lua_state;
- gint old_top = lua_gettop(L);
+ int old_top = lua_gettop(L);
if (rule->lua_id != -1 && rule->ctx->check_mime_part_ref != -1) {
- gint err_idx, ret;
+ int err_idx, ret;
struct rspamd_task **ptask;
struct rspamd_mime_part **ppart;
@@ -1597,11 +1597,11 @@ fuzzy_rule_check_mimepart(struct rspamd_task *task,
#define MAX_FUZZY_DOMAIN 64
-static guint
+static unsigned int
fuzzy_cmd_extension_length(struct rspamd_task *task,
struct fuzzy_rule *rule)
{
- guint total = 0;
+ unsigned int total = 0;
if (rule->no_share) {
return 0;
@@ -1629,13 +1629,13 @@ fuzzy_cmd_extension_length(struct rspamd_task *task,
return total;
}
-static guint
+static unsigned int
fuzzy_cmd_write_extensions(struct rspamd_task *task,
struct fuzzy_rule *rule,
- guchar *dest,
+ unsigned char *dest,
gsize available)
{
- guint written = 0;
+ unsigned int written = 0;
if (rule->no_share) {
return 0;
@@ -1645,7 +1645,7 @@ fuzzy_cmd_write_extensions(struct rspamd_task *task,
struct rspamd_email_address *addr = g_ptr_array_index(MESSAGE_FIELD(task,
from_mime),
0);
- guint to_write = MIN(MAX_FUZZY_DOMAIN, addr->domain_len) + 2;
+ unsigned int to_write = MIN(MAX_FUZZY_DOMAIN, addr->domain_len) + 2;
if (to_write > 0 && to_write <= available) {
*dest++ = RSPAMD_FUZZY_EXT_SOURCE_DOMAIN;
@@ -1670,8 +1670,8 @@ fuzzy_cmd_write_extensions(struct rspamd_task *task,
if (task->from_addr && rspamd_inet_address_get_af(task->from_addr) == AF_INET) {
if (available >= sizeof(struct in_addr) + 1) {
- guint klen;
- guchar *inet_data = rspamd_inet_address_get_hash_key(task->from_addr, &klen);
+ unsigned int klen;
+ unsigned char *inet_data = rspamd_inet_address_get_hash_key(task->from_addr, &klen);
*dest++ = RSPAMD_FUZZY_EXT_SOURCE_IP4;
@@ -1684,8 +1684,8 @@ fuzzy_cmd_write_extensions(struct rspamd_task *task,
}
else if (task->from_addr && rspamd_inet_address_get_af(task->from_addr) == AF_INET6) {
if (available >= sizeof(struct in6_addr) + 1) {
- guint klen;
- guchar *inet_data = rspamd_inet_address_get_hash_key(task->from_addr, &klen);
+ unsigned int klen;
+ unsigned char *inet_data = rspamd_inet_address_get_hash_key(task->from_addr, &klen);
*dest++ = RSPAMD_FUZZY_EXT_SOURCE_IP6;
@@ -1707,7 +1707,7 @@ static struct fuzzy_cmd_io *
fuzzy_cmd_from_text_part(struct rspamd_task *task,
struct fuzzy_rule *rule,
int c,
- gint flag,
+ int flag,
uint32_t weight,
gboolean short_text,
struct rspamd_mime_text_part *part,
@@ -1719,13 +1719,13 @@ fuzzy_cmd_from_text_part(struct rspamd_task *task,
struct rspamd_fuzzy_encrypted_cmd *enccmd = NULL;
struct rspamd_cached_shingles *cached = NULL;
struct rspamd_shingle *sh = NULL;
- guint i;
+ unsigned int i;
rspamd_cryptobox_hash_state_t st;
rspamd_stat_token_t *word;
GArray *words;
struct fuzzy_cmd_io *io;
- guint additional_length;
- guchar *additional_data;
+ unsigned int additional_length;
+ unsigned char *additional_data;
cached = fuzzy_cmd_get_cached(rule, task, mp);
@@ -1763,7 +1763,7 @@ fuzzy_cmd_from_text_part(struct rspamd_task *task,
memcpy(cmd->digest, cached->digest,
sizeof(cached->digest));
cmd->shingles_count = 0;
- memcpy(((guchar *) enccmd) + sizeof(*enccmd), additional_data,
+ memcpy(((unsigned char *) enccmd) + sizeof(*enccmd), additional_data,
additional_length);
}
else if (cached->sh) {
@@ -1773,7 +1773,7 @@ fuzzy_cmd_from_text_part(struct rspamd_task *task,
memcpy(&shcmd->sgl, cached->sh, sizeof(struct rspamd_shingle));
memcpy(shcmd->basic.digest, cached->digest,
sizeof(cached->digest));
- memcpy(((guchar *) encshcmd) + sizeof(*encshcmd), additional_data,
+ memcpy(((unsigned char *) encshcmd) + sizeof(*encshcmd), additional_data,
additional_length);
shcmd->basic.shingles_count = RSPAMD_SHINGLE_SIZE;
}
@@ -1790,7 +1790,7 @@ fuzzy_cmd_from_text_part(struct rspamd_task *task,
* occasional encryption
*/
cached->additional_length = additional_length;
- cached->additional_data = ((guchar *) cached) + sizeof(*cached);
+ cached->additional_data = ((unsigned char *) cached) + sizeof(*cached);
if (additional_length > 0) {
fuzzy_cmd_write_extensions(task, rule, cached->additional_data,
@@ -1817,7 +1817,7 @@ fuzzy_cmd_from_text_part(struct rspamd_task *task,
memcpy(cached->digest, cmd->digest, sizeof(cached->digest));
cached->sh = NULL;
- additional_data = ((guchar *) enccmd) + sizeof(*enccmd);
+ additional_data = ((unsigned char *) enccmd) + sizeof(*enccmd);
memcpy(additional_data, cached->additional_data, additional_length);
}
else {
@@ -1860,7 +1860,7 @@ fuzzy_cmd_from_text_part(struct rspamd_task *task,
cached->sh = sh;
memcpy(cached->digest, shcmd->basic.digest, sizeof(cached->digest));
- additional_data = ((guchar *) encshcmd) + sizeof(*encshcmd);
+ additional_data = ((unsigned char *) encshcmd) + sizeof(*encshcmd);
memcpy(additional_data, cached->additional_data, additional_length);
}
@@ -1908,13 +1908,13 @@ fuzzy_cmd_from_text_part(struct rspamd_task *task,
if (rule->peer_key) {
/* Encrypt data */
if (!short_text) {
- fuzzy_encrypt_cmd(rule, &encshcmd->hdr, (guchar *) shcmd,
+ fuzzy_encrypt_cmd(rule, &encshcmd->hdr, (unsigned char *) shcmd,
sizeof(*shcmd) + additional_length);
io->io.iov_base = encshcmd;
io->io.iov_len = sizeof(*encshcmd) + additional_length;
}
else {
- fuzzy_encrypt_cmd(rule, &enccmd->hdr, (guchar *) cmd,
+ fuzzy_encrypt_cmd(rule, &enccmd->hdr, (unsigned char *) cmd,
sizeof(*cmd) + additional_length);
io->io.iov_base = enccmd;
io->io.iov_len = sizeof(*enccmd) + additional_length;
@@ -1939,7 +1939,7 @@ fuzzy_cmd_from_text_part(struct rspamd_task *task,
static struct fuzzy_cmd_io *
fuzzy_cmd_from_image_part (struct fuzzy_rule *rule,
int c,
- gint flag,
+ int flag,
uint32_t weight,
struct rspamd_task *task,
struct rspamd_image *img,
@@ -1984,7 +1984,7 @@ fuzzy_cmd_from_image_part (struct fuzzy_rule *rule,
}
rspamd_cryptobox_hash (shcmd->basic.digest,
- (const guchar *)img->dct, RSPAMD_DCT_LEN / NBBY,
+ (const unsigned char *)img->dct, RSPAMD_DCT_LEN / NBBY,
rule->hash_key->str, rule->hash_key->len);
msg_debug_task ("loading shingles of type %s with key %*xs",
@@ -2021,7 +2021,7 @@ fuzzy_cmd_from_image_part (struct fuzzy_rule *rule,
if (rule->peer_key) {
/* Encrypt data */
- fuzzy_encrypt_cmd (rule, &encshcmd->hdr, (guchar *) shcmd, sizeof (*shcmd));
+ fuzzy_encrypt_cmd (rule, &encshcmd->hdr, (unsigned char *) shcmd, sizeof (*shcmd));
io->io.iov_base = encshcmd;
io->io.iov_len = sizeof (*encshcmd);
}
@@ -2037,17 +2037,17 @@ fuzzy_cmd_from_image_part (struct fuzzy_rule *rule,
static struct fuzzy_cmd_io *
fuzzy_cmd_from_data_part(struct fuzzy_rule *rule,
int c,
- gint flag,
+ int flag,
uint32_t weight,
struct rspamd_task *task,
- guchar digest[rspamd_cryptobox_HASHBYTES],
+ unsigned char digest[rspamd_cryptobox_HASHBYTES],
struct rspamd_mime_part *mp)
{
struct rspamd_fuzzy_cmd *cmd;
struct rspamd_fuzzy_encrypted_cmd *enccmd = NULL;
struct fuzzy_cmd_io *io;
- guint additional_length;
- guchar *additional_data;
+ unsigned int additional_length;
+ unsigned char *additional_data;
additional_length = fuzzy_cmd_extension_length(task, rule);
@@ -2055,12 +2055,12 @@ fuzzy_cmd_from_data_part(struct fuzzy_rule *rule,
enccmd = rspamd_mempool_alloc0(task->task_pool,
sizeof(*enccmd) + additional_length);
cmd = &enccmd->cmd;
- additional_data = ((guchar *) enccmd) + sizeof(*enccmd);
+ additional_data = ((unsigned char *) enccmd) + sizeof(*enccmd);
}
else {
cmd = rspamd_mempool_alloc0(task->task_pool,
sizeof(*cmd) + additional_length);
- additional_data = ((guchar *) cmd) + sizeof(*cmd);
+ additional_data = ((unsigned char *) cmd) + sizeof(*cmd);
}
cmd->cmd = c;
@@ -2086,7 +2086,7 @@ fuzzy_cmd_from_data_part(struct fuzzy_rule *rule,
if (rule->peer_key) {
g_assert(enccmd != NULL);
- fuzzy_encrypt_cmd(rule, &enccmd->hdr, (guchar *) cmd,
+ fuzzy_encrypt_cmd(rule, &enccmd->hdr, (unsigned char *) cmd,
sizeof(*cmd) + additional_length);
io->io.iov_base = enccmd;
io->io.iov_len = sizeof(*enccmd) + additional_length;
@@ -2100,7 +2100,7 @@ fuzzy_cmd_from_data_part(struct fuzzy_rule *rule,
}
static gboolean
-fuzzy_cmd_to_wire(gint fd, struct iovec *io)
+fuzzy_cmd_to_wire(int fd, struct iovec *io)
{
struct msghdr msg;
@@ -2119,9 +2119,9 @@ fuzzy_cmd_to_wire(gint fd, struct iovec *io)
}
static gboolean
-fuzzy_cmd_vector_to_wire(gint fd, GPtrArray *v)
+fuzzy_cmd_vector_to_wire(int fd, GPtrArray *v)
{
- guint i;
+ unsigned int i;
gboolean all_sent = TRUE, all_replied = TRUE;
struct fuzzy_cmd_io *io;
gboolean processed = FALSE;
@@ -2166,13 +2166,13 @@ fuzzy_cmd_vector_to_wire(gint fd, GPtrArray *v)
* Read replies one-by-one and remove them from req array
*/
static const struct rspamd_fuzzy_reply *
-fuzzy_process_reply(guchar **pos, gint *r, GPtrArray *req,
+fuzzy_process_reply(unsigned char **pos, int *r, GPtrArray *req,
struct fuzzy_rule *rule, struct rspamd_fuzzy_cmd **pcmd,
struct fuzzy_cmd_io **pio)
{
- guchar *p = *pos;
- gint remain = *r;
- guint i, required_size;
+ unsigned char *p = *pos;
+ int remain = *r;
+ unsigned int i, required_size;
struct fuzzy_cmd_io *io;
const struct rspamd_fuzzy_reply *rep;
struct rspamd_fuzzy_encrypted_reply encrep;
@@ -2185,7 +2185,7 @@ fuzzy_process_reply(guchar **pos, gint *r, GPtrArray *req,
required_size = sizeof(*rep);
}
- if (remain <= 0 || (guint) remain < required_size) {
+ if (remain <= 0 || (unsigned int) remain < required_size) {
return NULL;
}
@@ -2198,7 +2198,7 @@ fuzzy_process_reply(guchar **pos, gint *r, GPtrArray *req,
rspamd_keypair_cache_process(rule->ctx->keypairs_cache,
rule->local_key, rule->peer_key);
- if (!rspamd_cryptobox_decrypt_nm_inplace((guchar *) &encrep.rep,
+ if (!rspamd_cryptobox_decrypt_nm_inplace((unsigned char *) &encrep.rep,
sizeof(encrep.rep),
encrep.hdr.nonce,
rspamd_pubkey_get_nm(rule->peer_key, rule->local_key),
@@ -2254,20 +2254,20 @@ fuzzy_insert_result(struct fuzzy_client_session *session,
const struct rspamd_fuzzy_reply *rep,
struct rspamd_fuzzy_cmd *cmd,
struct fuzzy_cmd_io *io,
- guint flag)
+ unsigned int flag)
{
- const gchar *symbol;
+ const char *symbol;
struct fuzzy_mapping *map;
struct rspamd_task *task = session->task;
double weight;
double nval;
- guchar buf[2048];
- const gchar *type = "bin";
+ unsigned char buf[2048];
+ const char *type = "bin";
struct fuzzy_client_result *res;
gboolean is_fuzzy = FALSE;
- gchar hexbuf[rspamd_cryptobox_HASHBYTES * 2 + 1];
+ char hexbuf[rspamd_cryptobox_HASHBYTES * 2 + 1];
/* Discriminate scores for small images */
- static const guint short_image_limit = 32 * 1024;
+ static const unsigned int short_image_limit = 32 * 1024;
/* Get mapping by flag */
if ((map =
@@ -2332,7 +2332,7 @@ fuzzy_insert_result(struct fuzzy_client_session *session,
if (map != NULL || !session->rule->skip_unknown) {
GList *fuzzy_var;
rspamd_fstring_t *hex_result;
- gchar timebuf[64];
+ char timebuf[64];
struct tm tm_split;
if (session->rule->skip_map) {
@@ -2362,9 +2362,9 @@ fuzzy_insert_result(struct fuzzy_client_session *session,
"%.2f, probability %.2f, in list: %s:%d%s; added on %s",
type,
hexbuf,
- (gint) sizeof(cmd->digest), cmd->digest,
+ (int) sizeof(cmd->digest), cmd->digest,
nval,
- (gdouble) rep->v1.prob,
+ (double) rep->v1.prob,
symbol,
rep->v1.flag,
map == NULL ? "(unknown)" : "",
@@ -2377,7 +2377,7 @@ fuzzy_insert_result(struct fuzzy_client_session *session,
type,
hexbuf,
nval,
- (gdouble) rep->v1.prob,
+ (double) rep->v1.prob,
symbol,
rep->v1.flag,
map == NULL ? "(unknown)" : "",
@@ -2388,7 +2388,7 @@ fuzzy_insert_result(struct fuzzy_client_session *session,
sizeof(buf),
"%d:%*s:%.2f:%s",
rep->v1.flag,
- (gint) MIN(rspamd_fuzzy_hash_len * 2, sizeof(rep->digest) * 2), hexbuf,
+ (int) MIN(rspamd_fuzzy_hash_len * 2, sizeof(rep->digest) * 2), hexbuf,
rep->v1.prob,
type);
res->option = rspamd_mempool_strdup(task->task_pool, buf);
@@ -2416,15 +2416,15 @@ fuzzy_insert_result(struct fuzzy_client_session *session,
}
}
-static gint
+static int
fuzzy_check_try_read(struct fuzzy_client_session *session)
{
struct rspamd_task *task;
const struct rspamd_fuzzy_reply *rep;
struct rspamd_fuzzy_cmd *cmd = NULL;
struct fuzzy_cmd_io *io = NULL;
- gint r, ret;
- guchar buf[2048], *p;
+ int r, ret;
+ unsigned char buf[2048], *p;
task = session->task;
@@ -2510,12 +2510,12 @@ fuzzy_insert_metric_results(struct rspamd_task *task, struct fuzzy_rule *rule,
GPtrArray *results)
{
struct fuzzy_client_result *res;
- guint i;
+ unsigned int i;
gboolean seen_text_hash = FALSE,
seen_img_hash = FALSE,
seen_text_part = FALSE,
seen_long_text = FALSE;
- gdouble prob_txt = 0.0, mult;
+ double prob_txt = 0.0, mult;
struct rspamd_mime_text_part *tp;
/* About 5 words */
@@ -2587,7 +2587,7 @@ fuzzy_insert_metric_results(struct rspamd_task *task, struct fuzzy_rule *rule,
}
}
- gdouble weight = res->score * mult;
+ double weight = res->score * mult;
if (!isnan(rule->weight_threshold)) {
if (weight >= rule->weight_threshold) {
@@ -2610,7 +2610,7 @@ static gboolean
fuzzy_check_session_is_completed(struct fuzzy_client_session *session)
{
struct fuzzy_cmd_io *io;
- guint nreplied = 0, i;
+ unsigned int nreplied = 0, i;
rspamd_upstream_ok(session->server);
@@ -2639,7 +2639,7 @@ fuzzy_check_session_is_completed(struct fuzzy_client_session *session)
/* Fuzzy check timeout callback */
static void
-fuzzy_check_timer_callback(gint fd, short what, void *arg)
+fuzzy_check_timer_callback(int fd, short what, void *arg)
{
struct fuzzy_client_session *session = arg;
struct rspamd_task *task;
@@ -2677,11 +2677,11 @@ fuzzy_check_timer_callback(gint fd, short what, void *arg)
/* Fuzzy check callback */
static void
-fuzzy_check_io_callback(gint fd, short what, void *arg)
+fuzzy_check_io_callback(int fd, short what, void *arg)
{
struct fuzzy_client_session *session = arg;
struct rspamd_task *task;
- gint r;
+ int r;
enum {
return_error = 0,
@@ -2787,7 +2787,7 @@ fuzzy_controller_lua_fin(void *ud)
/* Controller IO */
static void
-fuzzy_controller_timer_callback(gint fd, short what, void *arg)
+fuzzy_controller_timer_callback(int fd, short what, void *arg)
{
struct fuzzy_learn_session *session = arg;
struct rspamd_task *task;
@@ -2843,24 +2843,24 @@ fuzzy_controller_timer_callback(gint fd, short what, void *arg)
}
static void
-fuzzy_controller_io_callback(gint fd, short what, void *arg)
+fuzzy_controller_io_callback(int fd, short what, void *arg)
{
struct fuzzy_learn_session *session = arg;
const struct rspamd_fuzzy_reply *rep;
struct fuzzy_mapping *map;
struct rspamd_task *task;
- guchar buf[2048], *p;
+ unsigned char buf[2048], *p;
struct fuzzy_cmd_io *io;
struct rspamd_fuzzy_cmd *cmd = NULL;
- const gchar *symbol, *ftype;
- gint r;
+ const char *symbol, *ftype;
+ int r;
enum {
return_error = 0,
return_want_more,
return_finished
} ret = return_want_more;
- guint i, nreplied;
- const gchar *op = "process";
+ unsigned int i, nreplied;
+ const char *op = "process";
task = session->task;
@@ -2922,7 +2922,7 @@ fuzzy_controller_io_callback(gint fd, short what, void *arg)
"message <%s>",
op,
ftype,
- (gint) sizeof(rep->digest), rep->digest,
+ (int) sizeof(rep->digest), rep->digest,
symbol,
rep->v1.flag,
MESSAGE_FIELD_CHECK(session->task, message_id));
@@ -2936,7 +2936,7 @@ fuzzy_controller_io_callback(gint fd, short what, void *arg)
ftype,
op,
MESSAGE_FIELD_CHECK(session->task, message_id),
- (gint) sizeof(rep->digest), rep->digest,
+ (int) sizeof(rep->digest), rep->digest,
symbol,
rep->v1.flag);
@@ -2951,7 +2951,7 @@ fuzzy_controller_io_callback(gint fd, short what, void *arg)
ftype,
op,
MESSAGE_FIELD_CHECK(session->task, message_id),
- (gint) sizeof(rep->digest), rep->digest,
+ (int) sizeof(rep->digest), rep->digest,
symbol,
rep->v1.flag,
rep->v1.value);
@@ -3056,7 +3056,7 @@ cleanup:
if (session->http_entry) {
ucl_object_t *reply, *hashes;
- gchar hexbuf[rspamd_cryptobox_HASHBYTES * 2 + 1];
+ char hexbuf[rspamd_cryptobox_HASHBYTES * 2 + 1];
reply = ucl_object_typed_new(UCL_OBJECT);
@@ -3068,7 +3068,7 @@ cleanup:
io = g_ptr_array_index(session->commands, i);
rspamd_snprintf(hexbuf, sizeof(hexbuf), "%*xs",
- (gint) sizeof(io->cmd.digest), io->cmd.digest);
+ (int) sizeof(io->cmd.digest), io->cmd.digest);
ucl_array_append(hashes, ucl_object_fromstring(hexbuf));
}
@@ -3089,13 +3089,13 @@ cleanup:
static GPtrArray *
fuzzy_generate_commands(struct rspamd_task *task, struct fuzzy_rule *rule,
- gint c, gint flag, uint32_t value, guint flags)
+ int c, int flag, uint32_t value, unsigned int flags)
{
struct rspamd_mime_text_part *part;
struct rspamd_mime_part *mime_part;
struct rspamd_image *image;
struct fuzzy_cmd_io *io, *cur;
- guint i, j;
+ unsigned int i, j;
GPtrArray *res = NULL;
gboolean check_part, fuzzy_check;
@@ -3165,7 +3165,7 @@ fuzzy_generate_commands(struct rspamd_task *task, struct fuzzy_rule *rule,
if (lua_spec->type == RSPAMD_LUA_PART_TABLE) {
lua_State *L = (lua_State *) task->cfg->lua_state;
- gint old_top;
+ int old_top;
old_top = lua_gettop(L);
/* Push table */
@@ -3174,11 +3174,11 @@ fuzzy_generate_commands(struct rspamd_task *task, struct fuzzy_rule *rule,
lua_gettable(L, -2);
if (lua_type(L, -1) == LUA_TTABLE) {
- gint tbl_pos = lua_gettop(L);
+ int tbl_pos = lua_gettop(L);
for (lua_pushnil(L); lua_next(L, tbl_pos);
lua_pop(L, 1)) {
- const gchar *h = NULL;
+ const char *h = NULL;
gsize hlen = 0;
if (lua_isstring(L, -1)) {
@@ -3199,7 +3199,7 @@ fuzzy_generate_commands(struct rspamd_task *task, struct fuzzy_rule *rule,
io = fuzzy_cmd_from_data_part(rule, c,
flag, value,
task,
- (guchar *) h,
+ (unsigned char *) h,
mime_part);
if (io) {
@@ -3267,7 +3267,7 @@ register_fuzzy_client_call(struct rspamd_task *task,
struct fuzzy_client_session *session;
struct upstream *selected;
rspamd_inet_addr_t *addr;
- gint sock;
+ int sock;
if (!rspamd_session_blocked(task->s)) {
/* Get upstream */
@@ -3324,7 +3324,7 @@ fuzzy_symbol_callback(struct rspamd_task *task,
void *unused)
{
struct fuzzy_rule *rule;
- guint i;
+ unsigned int i;
GPtrArray *commands;
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context(task->cfg);
@@ -3364,7 +3364,7 @@ fuzzy_symbol_callback(struct rspamd_task *task,
void fuzzy_stat_command(struct rspamd_task *task)
{
struct fuzzy_rule *rule;
- guint i;
+ unsigned int i;
GPtrArray *commands;
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context(task->cfg);
@@ -3381,19 +3381,19 @@ void fuzzy_stat_command(struct rspamd_task *task)
}
}
-static inline gint
+static inline int
register_fuzzy_controller_call(struct rspamd_http_connection_entry *entry,
struct fuzzy_rule *rule,
struct rspamd_task *task,
GPtrArray *commands,
- gint *saved)
+ int *saved)
{
struct fuzzy_learn_session *s;
struct upstream *selected;
rspamd_inet_addr_t *addr;
struct rspamd_controller_session *session = entry->ud;
- gint sock;
- gint ret = -1;
+ int sock;
+ int ret = -1;
/* Get upstream */
@@ -3443,25 +3443,25 @@ register_fuzzy_controller_call(struct rspamd_http_connection_entry *entry,
static void
fuzzy_process_handler(struct rspamd_http_connection_entry *conn_ent,
- struct rspamd_http_message *msg, gint cmd, gint value, gint flag,
- struct fuzzy_ctx *ctx, gboolean is_hash, guint flags)
+ struct rspamd_http_message *msg, int cmd, int value, int flag,
+ struct fuzzy_ctx *ctx, gboolean is_hash, unsigned int flags)
{
struct fuzzy_rule *rule;
struct rspamd_controller_session *session = conn_ent->ud;
struct rspamd_task *task, **ptask;
gboolean processed = FALSE, skip = FALSE;
- gint res = 0;
- guint i;
+ int res = 0;
+ unsigned int i;
GPtrArray *commands;
lua_State *L;
- gint r, *saved, rules = 0, err_idx;
+ int r, *saved, rules = 0, err_idx;
struct fuzzy_ctx *fuzzy_module_ctx;
/* Prepare task */
task = rspamd_task_new(session->wrk, session->cfg, NULL,
session->lang_det, conn_ent->rt->event_loop, FALSE);
task->cfg = ctx->cfg;
- saved = rspamd_mempool_alloc0(session->pool, sizeof(gint));
+ saved = rspamd_mempool_alloc0(session->pool, sizeof(int));
fuzzy_module_ctx = fuzzy_get_context(ctx->cfg);
if (!is_hash) {
@@ -3530,7 +3530,7 @@ fuzzy_process_handler(struct rspamd_http_connection_entry *conn_ent,
msg_info_task("learn condition changed flag from %d to "
"%d",
flag,
- (gint) lua_tonumber(L, err_idx + 2));
+ (int) lua_tonumber(L, err_idx + 2));
flag = lua_tonumber(L, err_idx + 2);
}
}
@@ -3565,7 +3565,7 @@ fuzzy_process_handler(struct rspamd_http_connection_entry *conn_ent,
if (is_hash) {
GPtrArray *args;
const rspamd_ftok_t *arg;
- guint j;
+ unsigned int j;
args = rspamd_http_message_find_header_multiple(msg, "Hash");
@@ -3655,7 +3655,7 @@ fuzzy_process_handler(struct rspamd_http_connection_entry *conn_ent,
static int
fuzzy_controller_handler(struct rspamd_http_connection_entry *conn_ent,
- struct rspamd_http_message *msg, struct module_ctx *ctx, gint cmd,
+ struct rspamd_http_message *msg, struct module_ctx *ctx, int cmd,
gboolean is_hash)
{
const rspamd_ftok_t *arg;
@@ -3700,7 +3700,7 @@ fuzzy_controller_handler(struct rspamd_http_connection_entry *conn_ent,
/* Search flag by symbol */
if (arg) {
struct fuzzy_rule *rule;
- guint i;
+ unsigned int i;
GHashTableIter it;
gpointer k, v;
struct fuzzy_mapping *map;
@@ -3753,17 +3753,17 @@ fuzzy_controller_handler(struct rspamd_http_connection_entry *conn_ent,
return 0;
}
-static inline gint
+static inline int
fuzzy_check_send_lua_learn(struct fuzzy_rule *rule,
struct rspamd_task *task,
GPtrArray *commands,
- gint *saved)
+ int *saved)
{
struct fuzzy_learn_session *s;
struct upstream *selected;
rspamd_inet_addr_t *addr;
- gint sock;
- gint ret = -1;
+ int sock;
+ int ret = -1;
/* Get upstream */
if (!rspamd_session_blocked(task->s)) {
@@ -3814,16 +3814,16 @@ fuzzy_check_send_lua_learn(struct fuzzy_rule *rule,
static gboolean
fuzzy_check_lua_process_learn(struct rspamd_task *task,
- gint cmd, gint value, gint flag, guint send_flags)
+ int cmd, int value, int flag, unsigned int send_flags)
{
struct fuzzy_rule *rule;
gboolean processed = FALSE, res = TRUE;
- guint i;
+ unsigned int i;
GPtrArray *commands;
- gint *saved, rules = 0;
+ int *saved, rules = 0;
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context(task->cfg);
- saved = rspamd_mempool_alloc0(task->task_pool, sizeof(gint));
+ saved = rspamd_mempool_alloc0(task->task_pool, sizeof(int));
PTR_ARRAY_FOREACH(fuzzy_module_ctx->fuzzy_rules, i, rule)
{
@@ -3880,7 +3880,7 @@ fuzzy_check_lua_process_learn(struct rspamd_task *task,
return TRUE;
}
-static gint
+static int
fuzzy_lua_learn_handler(lua_State *L)
{
struct rspamd_task *task = lua_check_task(L, 1);
@@ -3889,8 +3889,8 @@ fuzzy_lua_learn_handler(lua_State *L)
return luaL_error(L, "invalid arguments");
}
- guint flag = 0, weight = 1, send_flags = 0;
- const gchar *symbol;
+ unsigned int flag = 0, weight = 1, send_flags = 0;
+ const char *symbol;
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context(task->cfg);
if (lua_type(L, 2) == LUA_TNUMBER) {
@@ -3898,7 +3898,7 @@ fuzzy_lua_learn_handler(lua_State *L)
}
else if (lua_type(L, 2) == LUA_TSTRING) {
struct fuzzy_rule *rule;
- guint i;
+ unsigned int i;
GHashTableIter it;
gpointer k, v;
struct fuzzy_mapping *map;
@@ -3933,7 +3933,7 @@ fuzzy_lua_learn_handler(lua_State *L)
}
if (lua_type(L, 4) == LUA_TTABLE) {
- const gchar *sf;
+ const char *sf;
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
sf = lua_tostring(L, -1);
@@ -3958,7 +3958,7 @@ fuzzy_lua_learn_handler(lua_State *L)
return 1;
}
-static gint
+static int
fuzzy_lua_unlearn_handler(lua_State *L)
{
struct rspamd_task *task = lua_check_task(L, 1);
@@ -3966,8 +3966,8 @@ fuzzy_lua_unlearn_handler(lua_State *L)
return luaL_error(L, "invalid arguments");
}
- guint flag = 0, weight = 1.0, send_flags = 0;
- const gchar *symbol;
+ unsigned int flag = 0, weight = 1.0, send_flags = 0;
+ const char *symbol;
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context(task->cfg);
if (lua_type(L, 2) == LUA_TNUMBER) {
@@ -3975,7 +3975,7 @@ fuzzy_lua_unlearn_handler(lua_State *L)
}
else if (lua_type(L, 2) == LUA_TSTRING) {
struct fuzzy_rule *rule;
- guint i;
+ unsigned int i;
GHashTableIter it;
gpointer k, v;
struct fuzzy_mapping *map;
@@ -4011,7 +4011,7 @@ fuzzy_lua_unlearn_handler(lua_State *L)
}
if (lua_type(L, 4) == LUA_TTABLE) {
- const gchar *sf;
+ const char *sf;
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
sf = lua_tostring(L, -1);
@@ -4037,7 +4037,7 @@ fuzzy_lua_unlearn_handler(lua_State *L)
return 1;
}
-static gint
+static int
fuzzy_lua_gen_hashes_handler(lua_State *L)
{
struct rspamd_task *task = lua_check_task(L, 1);
@@ -4046,13 +4046,13 @@ fuzzy_lua_gen_hashes_handler(lua_State *L)
return luaL_error(L, "invalid arguments");
}
- guint flag = 0, weight = 1, send_flags = 0;
- const gchar *symbol;
+ unsigned int flag = 0, weight = 1, send_flags = 0;
+ const char *symbol;
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context(task->cfg);
struct fuzzy_rule *rule;
GPtrArray *commands;
- gint cmd = FUZZY_WRITE;
- gint i;
+ int cmd = FUZZY_WRITE;
+ int i;
if (lua_type(L, 2) == LUA_TNUMBER) {
flag = lua_tonumber(L, 2);
@@ -4094,7 +4094,7 @@ fuzzy_lua_gen_hashes_handler(lua_State *L)
/* Flags */
if (lua_type(L, 4) == LUA_TTABLE) {
- const gchar *sf;
+ const char *sf;
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
sf = lua_tostring(L, -1);
@@ -4115,7 +4115,7 @@ fuzzy_lua_gen_hashes_handler(lua_State *L)
/* Type */
if (lua_type(L, 5) == LUA_TSTRING) {
- const gchar *cmd_name = lua_tostring(L, 5);
+ const char *cmd_name = lua_tostring(L, 5);
if (strcmp(cmd_name, "add") == 0 || strcmp(cmd_name, "write") == 0) {
cmd = FUZZY_WRITE;
@@ -4150,7 +4150,7 @@ fuzzy_lua_gen_hashes_handler(lua_State *L)
if (commands != NULL) {
struct fuzzy_cmd_io *io;
- gint j;
+ int j;
lua_pushstring(L, rule->name);
lua_createtable(L, commands->len, 0);
@@ -4171,7 +4171,7 @@ fuzzy_lua_gen_hashes_handler(lua_State *L)
return 1;
}
-static gint
+static int
fuzzy_lua_hex_hashes_handler(lua_State *L)
{
struct rspamd_task *task = lua_check_task(L, 1);
@@ -4180,12 +4180,12 @@ fuzzy_lua_hex_hashes_handler(lua_State *L)
return luaL_error(L, "invalid arguments");
}
- guint flag = 0, weight = 1, send_flags = 0;
- const gchar *symbol;
+ unsigned int flag = 0, weight = 1, send_flags = 0;
+ const char *symbol;
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context(task->cfg);
struct fuzzy_rule *rule;
GPtrArray *commands;
- gint i;
+ int i;
if (lua_type(L, 2) == LUA_TNUMBER) {
flag = lua_tonumber(L, 2);
@@ -4246,7 +4246,7 @@ fuzzy_lua_hex_hashes_handler(lua_State *L)
* get hex hashes
*/
struct rspamd_mime_part *mp;
- gint j, part_idx = 1;
+ int j, part_idx = 1;
PTR_ARRAY_FOREACH(MESSAGE_FIELD(task, parts), j, mp)
{
@@ -4255,9 +4255,9 @@ fuzzy_lua_hex_hashes_handler(lua_State *L)
cached = fuzzy_cmd_get_cached(rule, task, mp);
if (cached) {
- gchar hexbuf[rspamd_cryptobox_HASHBYTES * 2 + 1];
- gint r = rspamd_encode_hex_buf(cached->digest, sizeof(cached->digest), hexbuf,
- sizeof(hexbuf));
+ char hexbuf[rspamd_cryptobox_HASHBYTES * 2 + 1];
+ int r = rspamd_encode_hex_buf(cached->digest, sizeof(cached->digest), hexbuf,
+ sizeof(hexbuf));
lua_pushlstring(L, hexbuf, r);
lua_rawseti(L, -2, part_idx++);
}
@@ -4334,7 +4334,7 @@ fuzzy_attach_controller(struct module_ctx *ctx, GHashTable *commands)
/* TODO: move to a separate unit, as this file is now a bit too hard to read */
static void
-lua_upstream_str_inserter(struct upstream *up, guint idx, void *ud)
+lua_upstream_str_inserter(struct upstream *up, unsigned int idx, void *ud)
{
lua_State *L = (lua_State *) ud;
@@ -4342,7 +4342,7 @@ lua_upstream_str_inserter(struct upstream *up, guint idx, void *ud)
lua_rawseti(L, -2, idx + 1);
}
-static gint
+static int
fuzzy_lua_list_storages(lua_State *L)
{
struct rspamd_config *cfg = lua_check_config(L, 1);
@@ -4353,7 +4353,7 @@ fuzzy_lua_list_storages(lua_State *L)
struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context(cfg);
struct fuzzy_rule *rule;
- guint i;
+ unsigned int i;
lua_createtable(L, 0, fuzzy_module_ctx->fuzzy_rules->len);
PTR_ARRAY_FOREACH(fuzzy_module_ctx->fuzzy_rules, i, rule)
@@ -4398,8 +4398,8 @@ struct fuzzy_lua_session {
GPtrArray *commands;
struct fuzzy_rule *rule;
struct rspamd_io_ev ev;
- gint cbref;
- gint fd;
+ int cbref;
+ int fd;
};
static void
@@ -4419,7 +4419,7 @@ static gboolean
fuzzy_lua_session_is_completed(struct fuzzy_lua_session *session)
{
struct fuzzy_cmd_io *io;
- guint nreplied = 0, i;
+ unsigned int nreplied = 0, i;
for (i = 0; i < session->commands->len; i++) {
@@ -4441,7 +4441,7 @@ fuzzy_lua_session_is_completed(struct fuzzy_lua_session *session)
}
static void
-fuzzy_lua_push_result(struct fuzzy_lua_session *session, gdouble latency)
+fuzzy_lua_push_result(struct fuzzy_lua_session *session, double latency)
{
lua_rawgeti(session->L, LUA_REGISTRYINDEX, session->cbref);
lua_pushboolean(session->L, TRUE);
@@ -4454,11 +4454,11 @@ fuzzy_lua_push_result(struct fuzzy_lua_session *session, gdouble latency)
#ifdef __GNUC__
static void
-fuzzy_lua_push_error(struct fuzzy_lua_session *session, const gchar *err_fmt, ...) __attribute__((format(printf, 2, 3)));
+fuzzy_lua_push_error(struct fuzzy_lua_session *session, const char *err_fmt, ...) __attribute__((format(printf, 2, 3)));
#endif
static void
-fuzzy_lua_push_error(struct fuzzy_lua_session *session, const gchar *err_fmt, ...)
+fuzzy_lua_push_error(struct fuzzy_lua_session *session, const char *err_fmt, ...)
{
va_list v;
@@ -4473,14 +4473,14 @@ fuzzy_lua_push_error(struct fuzzy_lua_session *session, const gchar *err_fmt, ..
lua_pcall(session->L, 3, 0, 0);
}
-static gint
+static int
fuzzy_lua_try_read(struct fuzzy_lua_session *session)
{
const struct rspamd_fuzzy_reply *rep;
struct rspamd_fuzzy_cmd *cmd = NULL;
struct fuzzy_cmd_io *io = NULL;
- gint r, ret;
- guchar buf[2048], *p;
+ int r, ret;
+ unsigned char buf[2048], *p;
if ((r = read(session->fd, buf, sizeof(buf) - 1)) == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
@@ -4520,10 +4520,10 @@ fuzzy_lua_try_read(struct fuzzy_lua_session *session)
/* Fuzzy check callback */
static void
-fuzzy_lua_io_callback(gint fd, short what, void *arg)
+fuzzy_lua_io_callback(int fd, short what, void *arg)
{
struct fuzzy_lua_session *session = arg;
- gint r;
+ int r;
enum {
return_error = 0,
@@ -4598,7 +4598,7 @@ fuzzy_lua_io_callback(gint fd, short what, void *arg)
* @function fuzzy_check.ping_storage(task, callback, rule, timeout[, server_override])
* @return
*/
-static gint
+static int
fuzzy_lua_ping_storage(lua_State *L)
{
struct rspamd_task *task = lua_check_task(L, 1);
@@ -4632,7 +4632,7 @@ fuzzy_lua_ping_storage(lua_State *L)
rspamd_inet_addr_t *addr = NULL;
if (lua_type(L, 5) == LUA_TSTRING) {
- const gchar *server_name = lua_tostring(L, 5);
+ const char *server_name = lua_tostring(L, 5);
enum rspamd_parse_host_port_result res;
GPtrArray *addrs = g_ptr_array_new();
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 510e1f70b..414e1b3a6 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -30,7 +30,7 @@ static const uint64_t rspamd_regexp_cb_magic = 0xca9d9649fc3e2659ULL;
struct regexp_module_item {
uint64_t magic;
struct rspamd_expression *expr;
- const gchar *symbol;
+ const char *symbol;
struct ucl_lua_funcdata *lua_function;
};
@@ -45,9 +45,9 @@ static void process_regexp_item(struct rspamd_task *task,
/* Initialization */
-gint regexp_module_init(struct rspamd_config *cfg, struct module_ctx **ctx);
-gint regexp_module_config(struct rspamd_config *cfg, bool validate);
-gint regexp_module_reconfig(struct rspamd_config *cfg);
+int regexp_module_init(struct rspamd_config *cfg, struct module_ctx **ctx);
+int regexp_module_config(struct rspamd_config *cfg, bool validate);
+int regexp_module_reconfig(struct rspamd_config *cfg);
module_t regexp_module = {
"regexp",
@@ -56,7 +56,7 @@ module_t regexp_module = {
regexp_module_reconfig,
NULL,
RSPAMD_MODULE_VER,
- (guint) -1,
+ (unsigned int) -1,
};
@@ -71,8 +71,8 @@ regexp_get_context(struct rspamd_config *cfg)
static gboolean
read_regexp_expression(rspamd_mempool_t *pool,
struct regexp_module_item *chain,
- const gchar *symbol,
- const gchar *line,
+ const char *symbol,
+ const char *line,
struct rspamd_mime_expr_ud *ud)
{
struct rspamd_expression *e = NULL;
@@ -96,7 +96,7 @@ read_regexp_expression(rspamd_mempool_t *pool,
/* Init function */
-gint regexp_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
+int regexp_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
{
struct regexp_ctx *regexp_module_ctx;
@@ -128,13 +128,13 @@ gint regexp_module_init(struct rspamd_config *cfg, struct module_ctx **ctx)
return 0;
}
-gint regexp_module_config(struct rspamd_config *cfg, bool validate)
+int regexp_module_config(struct rspamd_config *cfg, bool validate)
{
struct regexp_ctx *regexp_module_ctx = regexp_get_context(cfg);
struct regexp_module_item *cur_item = NULL;
const ucl_object_t *sec, *value, *elt;
ucl_object_iter_t it = NULL;
- gint res = TRUE, nre = 0, nlua = 0, nshots = cfg->default_max_shots;
+ int res = TRUE, nre = 0, nlua = 0, nshots = cfg->default_max_shots;
if (!rspamd_config_is_module_enabled(cfg, "regexp")) {
return TRUE;
@@ -203,9 +203,9 @@ gint regexp_module_config(struct rspamd_config *cfg, bool validate)
nlua++;
}
else if (value->type == UCL_OBJECT) {
- const gchar *description = NULL, *group = NULL;
- gdouble score = 0.0;
- guint flags = 0, priority = 0;
+ const char *description = NULL, *group = NULL;
+ double score = 0.0;
+ unsigned int flags = 0, priority = 0;
gboolean is_lua = FALSE, valid_expression = TRUE;
struct rspamd_mime_expr_ud ud;
@@ -456,7 +456,7 @@ gint regexp_module_config(struct rspamd_config *cfg, bool validate)
return res;
}
-gint regexp_module_reconfig(struct rspamd_config *cfg)
+int regexp_module_reconfig(struct rspamd_config *cfg)
{
return regexp_module_config(cfg, false);
}
@@ -464,13 +464,13 @@ gint regexp_module_reconfig(struct rspamd_config *cfg)
static gboolean
rspamd_lua_call_expression_func(struct ucl_lua_funcdata *lua_data,
struct rspamd_task *task,
- GArray *args, gdouble *res,
- const gchar *symbol)
+ GArray *args, double *res,
+ const char *symbol)
{
lua_State *L = lua_data->L;
struct rspamd_task **ptask;
struct expression_argument *arg;
- gint pop = 0, i, nargs = 0;
+ int pop = 0, i, nargs = 0;
lua_rawgeti(L, LUA_REGISTRYINDEX, lua_data->idx);
/* Now we got function in top of stack */
@@ -480,12 +480,12 @@ rspamd_lua_call_expression_func(struct ucl_lua_funcdata *lua_data,
/* Now push all arguments */
if (args) {
- for (i = 0; i < (gint) args->len; i++) {
+ for (i = 0; i < (int) args->len; i++) {
arg = &g_array_index(args, struct expression_argument, i);
if (arg) {
switch (arg->type) {
case EXPRESSION_ARGUMENT_NORMAL:
- lua_pushstring(L, (const gchar *) arg->data);
+ lua_pushstring(L, (const char *) arg->data);
break;
case EXPRESSION_ARGUMENT_BOOL:
lua_pushboolean(L, (gboolean) GPOINTER_TO_SIZE(arg->data));
@@ -533,7 +533,7 @@ process_regexp_item(struct rspamd_task *task,
void *user_data)
{
struct regexp_module_item *item = user_data;
- gdouble res = FALSE;
+ double res = FALSE;
/* Non-threaded version */
if (item->lua_function) {