summaryrefslogtreecommitdiffstats
path: root/src/libstat
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/libstat
parent6b2b4167187fee09365271cca182866ecb029af3 (diff)
downloadrspamd-14c13854d3cae9d93c3d148be30fb72f1eaffe55.tar.gz
rspamd-14c13854d3cae9d93c3d148be30fb72f1eaffe55.zip
[Rework] Further types conversion (no functional changes)
Diffstat (limited to 'src/libstat')
-rw-r--r--src/libstat/backends/backends.h12
-rw-r--r--src/libstat/backends/cdb_backend.cxx6
-rw-r--r--src/libstat/backends/http_backend.cxx10
-rw-r--r--src/libstat/backends/mmaped_file.c92
-rw-r--r--src/libstat/backends/redis_backend.cxx56
-rw-r--r--src/libstat/backends/sqlite3_backend.c38
-rw-r--r--src/libstat/classifiers/bayes.c38
-rw-r--r--src/libstat/classifiers/classifiers.h2
-rw-r--r--src/libstat/classifiers/lua_classifier.c12
-rw-r--r--src/libstat/learn_cache/learn_cache.h24
-rw-r--r--src/libstat/learn_cache/redis_cache.cxx20
-rw-r--r--src/libstat/learn_cache/sqlite3_cache.c28
-rw-r--r--src/libstat/stat_api.h12
-rw-r--r--src/libstat/stat_config.c34
-rw-r--r--src/libstat/stat_internal.h26
-rw-r--r--src/libstat/stat_process.c86
-rw-r--r--src/libstat/tokenizers/osb.c28
-rw-r--r--src/libstat/tokenizers/tokenizers.c64
-rw-r--r--src/libstat/tokenizers/tokenizers.h32
19 files changed, 310 insertions, 310 deletions
diff --git a/src/libstat/backends/backends.h b/src/libstat/backends/backends.h
index 4b16950bb..cf7f276ab 100644
--- a/src/libstat/backends/backends.h
+++ b/src/libstat/backends/backends.h
@@ -44,17 +44,17 @@ struct rspamd_stat_backend {
gpointer (*runtime)(struct rspamd_task *task,
struct rspamd_statfile_config *stcf,
gboolean learn, gpointer ctx,
- gint id);
+ int id);
gboolean (*process_tokens)(struct rspamd_task *task, GPtrArray *tokens,
- gint id,
+ int id,
gpointer ctx);
gboolean (*finalize_process)(struct rspamd_task *task,
gpointer runtime, gpointer ctx);
gboolean (*learn_tokens)(struct rspamd_task *task, GPtrArray *tokens,
- gint id,
+ int id,
gpointer ctx);
gulong (*total_learns)(struct rspamd_task *task,
@@ -83,15 +83,15 @@ struct rspamd_stat_backend {
struct rspamd_config *cfg, struct rspamd_statfile *st); \
gpointer rspamd_##name##_runtime(struct rspamd_task *task, \
struct rspamd_statfile_config *stcf, \
- gboolean learn, gpointer ctx, gint id); \
+ gboolean learn, gpointer ctx, int id); \
gboolean rspamd_##name##_process_tokens(struct rspamd_task *task, \
- GPtrArray *tokens, gint id, \
+ GPtrArray *tokens, int id, \
gpointer runtime); \
gboolean rspamd_##name##_finalize_process(struct rspamd_task *task, \
gpointer runtime, \
gpointer ctx); \
gboolean rspamd_##name##_learn_tokens(struct rspamd_task *task, \
- GPtrArray *tokens, gint id, \
+ GPtrArray *tokens, int id, \
gpointer runtime); \
gboolean rspamd_##name##_finalize_learn(struct rspamd_task *task, \
gpointer runtime, \
diff --git a/src/libstat/backends/cdb_backend.cxx b/src/libstat/backends/cdb_backend.cxx
index 81d87f319..7bdbcb394 100644
--- a/src/libstat/backends/cdb_backend.cxx
+++ b/src/libstat/backends/cdb_backend.cxx
@@ -380,7 +380,7 @@ rspamd_cdb_runtime(struct rspamd_task *task,
struct rspamd_statfile_config *stcf,
gboolean learn,
gpointer ctx,
- gint _id)
+ int _id)
{
/* In CDB we don't have any dynamic stuff */
return ctx;
@@ -389,7 +389,7 @@ rspamd_cdb_runtime(struct rspamd_task *task,
gboolean
rspamd_cdb_process_tokens(struct rspamd_task *task,
GPtrArray *tokens,
- gint id,
+ int id,
gpointer runtime)
{
auto *cdbp = CDB_FROM_RAW(runtime);
@@ -431,7 +431,7 @@ rspamd_cdb_finalize_process(struct rspamd_task *task,
gboolean
rspamd_cdb_learn_tokens(struct rspamd_task *task,
GPtrArray *tokens,
- gint id,
+ int id,
gpointer ctx)
{
return false;
diff --git a/src/libstat/backends/http_backend.cxx b/src/libstat/backends/http_backend.cxx
index 075e50870..d71e4b3ad 100644
--- a/src/libstat/backends/http_backend.cxx
+++ b/src/libstat/backends/http_backend.cxx
@@ -91,7 +91,7 @@ public:
auto process_tokens(struct rspamd_task *task,
GPtrArray *tokens,
- gint id,
+ int id,
bool learn) -> bool;
private:
@@ -158,7 +158,7 @@ auto http_backend_runtime::create(struct rspamd_task *task, bool is_learn) -> ht
return new (allocated_runtime) http_backend_runtime{task, is_learn};
}
-auto http_backend_runtime::process_tokens(struct rspamd_task *task, GPtrArray *tokens, gint id, bool learn) -> bool
+auto http_backend_runtime::process_tokens(struct rspamd_task *task, GPtrArray *tokens, int id, bool learn) -> bool
{
if (!learn) {
if (id == seen_statfiles.size() - 1) {
@@ -322,7 +322,7 @@ rspamd_http_runtime(struct rspamd_task *task,
struct rspamd_statfile_config *stcf,
gboolean learn,
gpointer ctx,
- gint id)
+ int id)
{
auto maybe_existing = rspamd_mempool_get_variable(task->task_pool, RSPAMD_MEMPOOL_HTTP_STAT_BACKEND_RUNTIME);
@@ -347,7 +347,7 @@ rspamd_http_runtime(struct rspamd_task *task,
gboolean
rspamd_http_process_tokens(struct rspamd_task *task,
GPtrArray *tokens,
- gint id,
+ int id,
gpointer runtime)
{
auto real_runtime = (rspamd::stat::http::http_backend_runtime *) runtime;
@@ -371,7 +371,7 @@ rspamd_http_finalize_process(struct rspamd_task *task,
gboolean
rspamd_http_learn_tokens(struct rspamd_task *task,
GPtrArray *tokens,
- gint id,
+ int id,
gpointer runtime)
{
auto real_runtime = (rspamd::stat::http::http_backend_runtime *) runtime;
diff --git a/src/libstat/backends/mmaped_file.c b/src/libstat/backends/mmaped_file.c
index f4354d8e1..4430bb9a4 100644
--- a/src/libstat/backends/mmaped_file.c
+++ b/src/libstat/backends/mmaped_file.c
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2016 Vsevolod Stakhov
+/*
+ * Copyright 2024 Vsevolod Stakhov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -69,12 +69,12 @@ struct stat_file {
*/
typedef struct {
#ifdef HAVE_PATH_MAX
- gchar filename[PATH_MAX]; /**< name of file */
+ char filename[PATH_MAX]; /**< name of file */
#else
- gchar filename[MAXPATHLEN]; /**< name of file */
+ char filename[MAXPATHLEN]; /**< name of file */
#endif
rspamd_mempool_t *pool;
- gint fd; /**< descriptor */
+ int fd; /**< descriptor */
void *map; /**< mmaped area */
off_t seek_pos; /**< current seek position */
struct stat_file_section cur_section; /**< current section */
@@ -94,13 +94,13 @@ static void rspamd_mmaped_file_set_block_common(rspamd_mempool_t *pool,
uint32_t h1, uint32_t h2, double value);
rspamd_mmaped_file_t *rspamd_mmaped_file_open(rspamd_mempool_t *pool,
- const gchar *filename, size_t size,
+ const char *filename, size_t size,
struct rspamd_statfile_config *stcf);
-gint rspamd_mmaped_file_create(const gchar *filename, size_t size,
- struct rspamd_statfile_config *stcf,
- rspamd_mempool_t *pool);
-gint rspamd_mmaped_file_close_file(rspamd_mempool_t *pool,
- rspamd_mmaped_file_t *file);
+int rspamd_mmaped_file_create(const char *filename, size_t size,
+ struct rspamd_statfile_config *stcf,
+ rspamd_mempool_t *pool);
+int rspamd_mmaped_file_close_file(rspamd_mempool_t *pool,
+ rspamd_mmaped_file_t *file);
double
rspamd_mmaped_file_get_block(rspamd_mmaped_file_t *file,
@@ -108,7 +108,7 @@ rspamd_mmaped_file_get_block(rspamd_mmaped_file_t *file,
uint32_t h2)
{
struct stat_file_block *block;
- guint i, blocknum;
+ unsigned int i, blocknum;
u_char *c;
if (!file->map) {
@@ -141,7 +141,7 @@ rspamd_mmaped_file_set_block_common(rspamd_mempool_t *pool,
{
struct stat_file_block *block, *to_expire = NULL;
struct stat_file_header *header;
- guint i, blocknum;
+ unsigned int i, blocknum;
u_char *c;
double min = G_MAXDOUBLE;
@@ -327,12 +327,12 @@ rspamd_mmaped_file_get_total(rspamd_mmaped_file_t *file)
}
/* Check whether specified file is statistic file and calculate its len in blocks */
-static gint
+static int
rspamd_mmaped_file_check(rspamd_mempool_t *pool, rspamd_mmaped_file_t *file)
{
struct stat_file *f;
- gchar *c;
- static gchar valid_version[] = RSPAMD_STATFILE_VERSION;
+ char *c;
+ static char valid_version[] = RSPAMD_STATFILE_VERSION;
if (!file || !file->map) {
@@ -388,13 +388,13 @@ rspamd_mmaped_file_check(rspamd_mempool_t *pool, rspamd_mmaped_file_t *file)
static rspamd_mmaped_file_t *
rspamd_mmaped_file_reindex(rspamd_mempool_t *pool,
- const gchar *filename,
+ const char *filename,
size_t old_size,
size_t size,
struct rspamd_statfile_config *stcf)
{
- gchar *backup, *lock;
- gint fd, lock_fd;
+ char *backup, *lock;
+ int fd, lock_fd;
rspamd_mmaped_file_t *new, *old = NULL;
u_char *map, *pos;
struct stat_file_block *block;
@@ -527,12 +527,12 @@ rspamd_mmaped_file_reindex(rspamd_mempool_t *pool,
static void
rspamd_mmaped_file_preload(rspamd_mmaped_file_t *file)
{
- guint8 *pos, *end;
- volatile guint8 t;
+ uint8_t *pos, *end;
+ volatile uint8_t t;
gsize size;
- pos = (guint8 *) file->map;
- end = (guint8 *) file->map + file->len;
+ pos = (uint8_t *) file->map;
+ end = (uint8_t *) file->map + file->len;
if (madvise(pos, end - pos, MADV_SEQUENTIAL) == -1) {
msg_info("madvise failed: %s", strerror(errno));
@@ -554,13 +554,13 @@ rspamd_mmaped_file_preload(rspamd_mmaped_file_t *file)
rspamd_mmaped_file_t *
rspamd_mmaped_file_open(rspamd_mempool_t *pool,
- const gchar *filename, size_t size,
+ const char *filename, size_t size,
struct rspamd_statfile_config *stcf)
{
struct stat st;
rspamd_mmaped_file_t *new_file;
- gchar *lock;
- gint lock_fd;
+ char *lock;
+ int lock_fd;
lock = g_strconcat(filename, ".lock", NULL);
lock_fd = open(lock, O_WRONLY | O_CREAT | O_EXCL, 00600);
@@ -649,8 +649,8 @@ rspamd_mmaped_file_open(rspamd_mempool_t *pool,
return new_file;
}
-gint rspamd_mmaped_file_close_file(rspamd_mempool_t *pool,
- rspamd_mmaped_file_t *file)
+int rspamd_mmaped_file_close_file(rspamd_mempool_t *pool,
+ rspamd_mmaped_file_t *file)
{
if (file->map) {
msg_info_pool("syncing statfile %s", file->filename);
@@ -666,10 +666,10 @@ gint rspamd_mmaped_file_close_file(rspamd_mempool_t *pool,
return 0;
}
-gint rspamd_mmaped_file_create(const gchar *filename,
- size_t size,
- struct rspamd_statfile_config *stcf,
- rspamd_mempool_t *pool)
+int rspamd_mmaped_file_create(const char *filename,
+ size_t size,
+ struct rspamd_statfile_config *stcf,
+ rspamd_mempool_t *pool)
{
struct stat_file_header header = {
.magic = {'r', 's', 'd'},
@@ -683,9 +683,9 @@ gint rspamd_mmaped_file_create(const gchar *filename,
};
struct stat_file_block block = {0, 0, 0};
struct rspamd_stat_tokenizer *tokenizer;
- gint fd, lock_fd;
- guint buflen = 0, nblocks;
- gchar *buf = NULL, *lock;
+ int fd, lock_fd;
+ unsigned int buflen = 0, nblocks;
+ char *buf = NULL, *lock;
struct stat sb;
gpointer tok_conf;
gsize tok_conf_len;
@@ -855,7 +855,7 @@ rspamd_mmaped_file_init(struct rspamd_stat_ctx *ctx,
struct rspamd_statfile_config *stf = st->stcf;
rspamd_mmaped_file_t *mf;
const ucl_object_t *filenameo, *sizeo;
- const gchar *filename;
+ const char *filename;
gsize size;
filenameo = ucl_object_lookup(stf->opts, "filename");
@@ -931,7 +931,7 @@ rspamd_mmaped_file_runtime(struct rspamd_task *task,
struct rspamd_statfile_config *stcf,
gboolean learn,
gpointer p,
- gint _id)
+ int _id)
{
rspamd_mmaped_file_t *mf = p;
@@ -940,21 +940,21 @@ rspamd_mmaped_file_runtime(struct rspamd_task *task,
gboolean
rspamd_mmaped_file_process_tokens(struct rspamd_task *task, GPtrArray *tokens,
- gint id,
+ int id,
gpointer p)
{
rspamd_mmaped_file_t *mf = p;
uint32_t h1, h2;
rspamd_token_t *tok;
- guint i;
+ unsigned int i;
g_assert(tokens != NULL);
g_assert(p != NULL);
for (i = 0; i < tokens->len; i++) {
tok = g_ptr_array_index(tokens, i);
- memcpy(&h1, (guchar *) &tok->data, sizeof(h1));
- memcpy(&h2, ((guchar *) &tok->data) + sizeof(h1), sizeof(h2));
+ memcpy(&h1, (unsigned char *) &tok->data, sizeof(h1));
+ memcpy(&h2, ((unsigned char *) &tok->data) + sizeof(h1), sizeof(h2));
tok->values[id] = rspamd_mmaped_file_get_block(mf, h1, h2);
}
@@ -970,21 +970,21 @@ rspamd_mmaped_file_process_tokens(struct rspamd_task *task, GPtrArray *tokens,
gboolean
rspamd_mmaped_file_learn_tokens(struct rspamd_task *task, GPtrArray *tokens,
- gint id,
+ int id,
gpointer p)
{
rspamd_mmaped_file_t *mf = p;
uint32_t h1, h2;
rspamd_token_t *tok;
- guint i;
+ unsigned int i;
g_assert(tokens != NULL);
g_assert(p != NULL);
for (i = 0; i < tokens->len; i++) {
tok = g_ptr_array_index(tokens, i);
- memcpy(&h1, (guchar *) &tok->data, sizeof(h1));
- memcpy(&h2, ((guchar *) &tok->data) + sizeof(h1), sizeof(h2));
+ memcpy(&h1, (unsigned char *) &tok->data, sizeof(h1));
+ memcpy(&h2, ((unsigned char *) &tok->data) + sizeof(h1), sizeof(h2));
rspamd_mmaped_file_set_block(task->task_pool, mf, h1, h2,
tok->values[id]);
}
diff --git a/src/libstat/backends/redis_backend.cxx b/src/libstat/backends/redis_backend.cxx
index 630c895a2..6abcfa122 100644
--- a/src/libstat/backends/redis_backend.cxx
+++ b/src/libstat/backends/redis_backend.cxx
@@ -169,7 +169,7 @@ public:
#define GET_TASK_ELT(task, elt) (task == nullptr ? nullptr : (task)->elt)
-static const gchar *M = "redis statistics";
+static const char *M = "redis statistics";
static GQuark
rspamd_redis_stat_quark(void)
@@ -180,14 +180,14 @@ rspamd_redis_stat_quark(void)
/*
* Non-static for lua unit testing
*/
-gsize rspamd_redis_expand_object(const gchar *pattern,
+gsize rspamd_redis_expand_object(const char *pattern,
struct redis_stat_ctx *ctx,
struct rspamd_task *task,
- gchar **target)
+ char **target)
{
gsize tlen = 0;
- const gchar *p = pattern, *elt;
- gchar *d, *end;
+ const char *p = pattern, *elt;
+ char *d, *end;
enum {
just_char,
percent_char,
@@ -196,8 +196,8 @@ gsize rspamd_redis_expand_object(const gchar *pattern,
struct rspamd_statfile_config *stcf;
lua_State *L = nullptr;
struct rspamd_task **ptask;
- const gchar *rcpt = nullptr;
- gint err_idx;
+ const char *rcpt = nullptr;
+ int err_idx;
g_assert(ctx != nullptr);
g_assert(task != nullptr);
@@ -315,7 +315,7 @@ gsize rspamd_redis_expand_object(const gchar *pattern,
return -1;
}
- *target = (gchar *) rspamd_mempool_alloc(task->task_pool, tlen + 1);
+ *target = (char *) rspamd_mempool_alloc(task->task_pool, tlen + 1);
d = *target;
end = d + tlen + 1;
d[tlen] = '\0';
@@ -441,7 +441,7 @@ rspamd_redis_parse_classifier_opts(struct redis_stat_ctx *backend,
const ucl_object_t *classifier_obj,
struct rspamd_config *cfg)
{
- const gchar *lua_script;
+ const char *lua_script;
const ucl_object_t *elt, *users_enabled;
auto *L = RSPAMD_LUA_CFG_STATE(cfg);
@@ -590,7 +590,7 @@ rspamd_redis_init(struct rspamd_stat_ctx *ctx,
gpointer
rspamd_redis_runtime(struct rspamd_task *task,
struct rspamd_statfile_config *stcf,
- gboolean learn, gpointer c, gint _id)
+ gboolean learn, gpointer c, int _id)
{
struct redis_stat_ctx *ctx = REDIS_CTX(c);
char *object_expanded = nullptr;
@@ -708,7 +708,7 @@ msgpack_str_len(std::size_t len) -> std::size_t
* Serialise stat tokens to message pack
*/
static char *
-rspamd_redis_serialize_tokens(struct rspamd_task *task, const gchar *prefix, GPtrArray *tokens, gsize *ser_len)
+rspamd_redis_serialize_tokens(struct rspamd_task *task, const char *prefix, GPtrArray *tokens, gsize *ser_len)
{
/* Each token is int64_t that requires 10 bytes (2 int32_t) + 4 bytes array len + 1 byte array magic */
char max_int64_str[] = "18446744073709551615";
@@ -719,16 +719,16 @@ rspamd_redis_serialize_tokens(struct rspamd_task *task, const gchar *prefix, GPt
/* Calculate required length */
req_len += tokens->len * (msgpack_str_len(sizeof(max_int64_str) + prefix_len) + 1);
- auto *buf = (gchar *) rspamd_mempool_alloc(task->task_pool, req_len);
+ auto *buf = (char *) rspamd_mempool_alloc(task->task_pool, req_len);
auto *p = buf;
/* Array */
- *p++ = (gchar) 0xdd;
+ *p++ = (char) 0xdd;
/* Length in big-endian (4 bytes) */
- *p++ = (gchar) ((tokens->len >> 24) & 0xff);
- *p++ = (gchar) ((tokens->len >> 16) & 0xff);
- *p++ = (gchar) ((tokens->len >> 8) & 0xff);
- *p++ = (gchar) (tokens->len & 0xff);
+ *p++ = (char) ((tokens->len >> 24) & 0xff);
+ *p++ = (char) ((tokens->len >> 16) & 0xff);
+ *p++ = (char) ((tokens->len >> 8) & 0xff);
+ *p++ = (char) (tokens->len & 0xff);
int i;
@@ -772,13 +772,13 @@ rspamd_redis_serialize_text_tokens(struct rspamd_task *task, GPtrArray *tokens,
}
}
- auto *buf = (gchar *) rspamd_mempool_alloc(task->task_pool, req_len);
+ auto *buf = (char *) rspamd_mempool_alloc(task->task_pool, req_len);
auto *p = buf;
/* Array */
std::uint32_t nlen = tokens->len * 2;
nlen = GUINT32_TO_BE(nlen);
- *p++ = (gchar) 0xdd;
+ *p++ = (char) 0xdd;
/* Length in big-endian (4 bytes) */
memcpy(p, &nlen, sizeof(nlen));
p += sizeof(nlen);
@@ -807,7 +807,7 @@ rspamd_redis_serialize_text_tokens(struct rspamd_task *task, GPtrArray *tokens,
return buf;
}
-static gint
+static int
rspamd_redis_classified(lua_State *L)
{
const auto *cookie = lua_tostring(L, lua_upvalueindex(1));
@@ -895,7 +895,7 @@ rspamd_redis_classified(lua_State *L)
gboolean
rspamd_redis_process_tokens(struct rspamd_task *task,
GPtrArray *tokens,
- gint id, gpointer p)
+ int id, gpointer p)
{
auto *rt = REDIS_RUNTIME(p);
auto *L = rt->ctx->L;
@@ -918,11 +918,11 @@ rspamd_redis_process_tokens(struct rspamd_task *task,
}
gsize tokens_len;
- gchar *tokens_buf = rspamd_redis_serialize_tokens(task, rt->redis_object_expanded, tokens, &tokens_len);
+ char *tokens_buf = rspamd_redis_serialize_tokens(task, rt->redis_object_expanded, tokens, &tokens_len);
rt->id = id;
lua_pushcfunction(L, &rspamd_lua_traceback);
- gint err_idx = lua_gettop(L);
+ int err_idx = lua_gettop(L);
/* Function arguments */
lua_rawgeti(L, LUA_REGISTRYINDEX, rt->ctx->cbref_classify);
@@ -963,7 +963,7 @@ rspamd_redis_finalize_process(struct rspamd_task *task, gpointer runtime,
}
-static gint
+static int
rspamd_redis_learned(lua_State *L)
{
const auto *cookie = lua_tostring(L, lua_upvalueindex(1));
@@ -994,7 +994,7 @@ rspamd_redis_learned(lua_State *L)
gboolean
rspamd_redis_learn_tokens(struct rspamd_task *task,
GPtrArray *tokens,
- gint id, gpointer p)
+ int id, gpointer p)
{
auto *rt = REDIS_RUNTIME(p);
auto *L = rt->ctx->L;
@@ -1008,19 +1008,19 @@ rspamd_redis_learn_tokens(struct rspamd_task *task,
}
gsize tokens_len;
- gchar *tokens_buf = rspamd_redis_serialize_tokens(task, rt->redis_object_expanded, tokens, &tokens_len);
+ char *tokens_buf = rspamd_redis_serialize_tokens(task, rt->redis_object_expanded, tokens, &tokens_len);
rt->id = id;
gsize text_tokens_len = 0;
- gchar *text_tokens_buf = nullptr;
+ char *text_tokens_buf = nullptr;
if (rt->ctx->store_tokens) {
text_tokens_buf = rspamd_redis_serialize_text_tokens(task, tokens, &text_tokens_len);
}
lua_pushcfunction(L, &rspamd_lua_traceback);
- gint err_idx = lua_gettop(L);
+ int err_idx = lua_gettop(L);
auto nargs = 8;
/* Function arguments */
diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c
index b26c1a86f..973dc30a7 100644
--- a/src/libstat/backends/sqlite3_backend.c
+++ b/src/libstat/backends/sqlite3_backend.c
@@ -28,15 +28,15 @@
struct rspamd_stat_sqlite3_db {
sqlite3 *sqlite;
- gchar *fname;
+ char *fname;
GArray *prstmt;
lua_State *L;
rspamd_mempool_t *pool;
gboolean in_transaction;
gboolean enable_users;
gboolean enable_languages;
- gint cbref_user;
- gint cbref_language;
+ int cbref_user;
+ int cbref_language;
};
struct rspamd_stat_sqlite3_rt {
@@ -161,8 +161,8 @@ rspamd_sqlite3_get_user(struct rspamd_stat_sqlite3_db *db,
struct rspamd_task *task, gboolean learn)
{
int64_t id = 0; /* Default user is 0 */
- gint rc, err_idx;
- const gchar *user = NULL;
+ int rc, err_idx;
+ const char *user = NULL;
struct rspamd_task **ptask;
lua_State *L = db->L;
@@ -220,9 +220,9 @@ rspamd_sqlite3_get_language(struct rspamd_stat_sqlite3_db *db,
struct rspamd_task *task, gboolean learn)
{
int64_t id = 0; /* Default language is 0 */
- gint rc, err_idx;
- guint i;
- const gchar *language = NULL;
+ int rc, err_idx;
+ unsigned int i;
+ const char *language = NULL;
struct rspamd_mime_text_part *tp;
struct rspamd_task **ptask;
lua_State *L = db->L;
@@ -286,7 +286,7 @@ rspamd_sqlite3_get_language(struct rspamd_stat_sqlite3_db *db,
static struct rspamd_stat_sqlite3_db *
rspamd_sqlite3_opendb(rspamd_mempool_t *pool,
struct rspamd_statfile_config *stcf,
- const gchar *path, const ucl_object_t *opts,
+ const char *path, const ucl_object_t *opts,
gboolean create, GError **err)
{
struct rspamd_stat_sqlite3_db *bk;
@@ -294,9 +294,9 @@ rspamd_sqlite3_opendb(rspamd_mempool_t *pool,
gpointer tk_conf;
gsize sz = 0;
int64_t sz64 = 0;
- gchar *tok_conf_encoded;
- gint ret, ntries = 0;
- const gint max_tries = 100;
+ char *tok_conf_encoded;
+ int ret, ntries = 0;
+ const int max_tries = 100;
struct timespec sleep_ts = {
.tv_sec = 0,
.tv_nsec = 1000000};
@@ -375,7 +375,7 @@ rspamd_sqlite3_init(struct rspamd_stat_ctx *ctx,
struct rspamd_classifier_config *clf = st->classifier->cfg;
struct rspamd_statfile_config *stf = st->stcf;
const ucl_object_t *filenameo, *lang_enabled, *users_enabled;
- const gchar *filename, *lua_script;
+ const char *filename, *lua_script;
struct rspamd_stat_sqlite3_db *bk;
GError *err = NULL;
@@ -502,7 +502,7 @@ void rspamd_sqlite3_close(gpointer p)
gpointer
rspamd_sqlite3_runtime(struct rspamd_task *task,
- struct rspamd_statfile_config *stcf, gboolean learn, gpointer p, gint _id)
+ struct rspamd_statfile_config *stcf, gboolean learn, gpointer p, int _id)
{
struct rspamd_stat_sqlite3_rt *rt = NULL;
struct rspamd_stat_sqlite3_db *bk = p;
@@ -522,12 +522,12 @@ rspamd_sqlite3_runtime(struct rspamd_task *task,
gboolean
rspamd_sqlite3_process_tokens(struct rspamd_task *task,
GPtrArray *tokens,
- gint id, gpointer p)
+ int id, gpointer p)
{
struct rspamd_stat_sqlite3_db *bk;
struct rspamd_stat_sqlite3_rt *rt = p;
int64_t iv = 0;
- guint i;
+ unsigned int i;
rspamd_token_t *tok;
g_assert(p != NULL);
@@ -625,12 +625,12 @@ rspamd_sqlite3_finalize_process(struct rspamd_task *task, gpointer runtime,
gboolean
rspamd_sqlite3_learn_tokens(struct rspamd_task *task, GPtrArray *tokens,
- gint id, gpointer p)
+ int id, gpointer p)
{
struct rspamd_stat_sqlite3_db *bk;
struct rspamd_stat_sqlite3_rt *rt = p;
int64_t iv = 0;
- guint i;
+ unsigned int i;
rspamd_token_t *tok;
g_assert(tokens != NULL);
@@ -691,7 +691,7 @@ rspamd_sqlite3_finalize_learn(struct rspamd_task *task, gpointer runtime,
{
struct rspamd_stat_sqlite3_rt *rt = runtime;
struct rspamd_stat_sqlite3_db *bk;
- gint wal_frames, wal_checkpointed, mode;
+ int wal_frames, wal_checkpointed, mode;
g_assert(rt != NULL);
bk = rt->db;
diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c
index abefcd7d9..93b5149da 100644
--- a/src/libstat/classifiers/bayes.c
+++ b/src/libstat/classifiers/bayes.c
@@ -49,11 +49,11 @@ bayes_error_quark(void)
* @param freedom_deg number of degrees of freedom
* @return
*/
-static gdouble
-inv_chi_square(struct rspamd_task *task, gdouble value, gint freedom_deg)
+static double
+inv_chi_square(struct rspamd_task *task, double value, int freedom_deg)
{
double prob, sum, m;
- gint i;
+ int i;
errno = 0;
m = -value;
@@ -85,7 +85,7 @@ inv_chi_square(struct rspamd_task *task, gdouble value, gint freedom_deg)
* from 1.0 (no confidence) to 0.0 (full confidence)
*/
for (i = 1; i < freedom_deg; i++) {
- prob *= m / (gdouble) i;
+ prob *= m / (double) i;
sum += prob;
msg_debug_bayes("i=%d, probability: %g, sum: %g", i, prob, sum);
}
@@ -96,7 +96,7 @@ inv_chi_square(struct rspamd_task *task, gdouble value, gint freedom_deg)
struct bayes_task_closure {
double ham_prob;
double spam_prob;
- gdouble meta_skip_prob;
+ double meta_skip_prob;
uint64_t processed_tokens;
uint64_t total_hits;
uint64_t text_tokens;
@@ -117,12 +117,12 @@ static void
bayes_classify_token(struct rspamd_classifier *ctx,
rspamd_token_t *tok, struct bayes_task_closure *cl)
{
- guint i;
- gint id;
- guint spam_count = 0, ham_count = 0, total_count = 0;
+ unsigned int i;
+ int id;
+ unsigned int spam_count = 0, ham_count = 0, total_count = 0;
struct rspamd_statfile *st;
struct rspamd_task *task;
- const gchar *token_type = "txt";
+ const char *token_type = "txt";
double spam_prob, spam_freq, ham_freq, bayes_spam_prob, bayes_ham_prob,
ham_prob, fw, w, val;
@@ -152,7 +152,7 @@ bayes_classify_token(struct rspamd_classifier *ctx,
}
for (i = 0; i < ctx->statfiles_ids->len; i++) {
- id = g_array_index(ctx->statfiles_ids, gint, i);
+ id = g_array_index(ctx->statfiles_ids, int, i);
st = g_ptr_array_index(ctx->ctx->statfiles, id);
g_assert(st != NULL);
val = tok->values[id];
@@ -269,12 +269,12 @@ bayes_classify(struct rspamd_classifier *ctx,
struct rspamd_task *task)
{
double final_prob, h, s, *pprob;
- gchar sumbuf[32];
+ char sumbuf[32];
struct rspamd_statfile *st = NULL;
struct bayes_task_closure cl;
rspamd_token_t *tok;
- guint i, text_tokens = 0;
- gint id;
+ unsigned int i, text_tokens = 0;
+ int id;
g_assert(ctx != NULL);
g_assert(tokens != NULL);
@@ -340,13 +340,13 @@ bayes_classify(struct rspamd_classifier *ctx,
}
if (ctx->cfg->min_tokens > 0 &&
- cl.text_tokens < (gint) (ctx->cfg->min_tokens * 0.1)) {
+ cl.text_tokens < (int) (ctx->cfg->min_tokens * 0.1)) {
msg_info_bayes("ignore bayes probability since we have "
"found too few text tokens: %uL (of %ud checked), "
"at least %d required",
cl.text_tokens,
text_tokens,
- (gint) (ctx->cfg->min_tokens * 0.1));
+ (int) (ctx->cfg->min_tokens * 0.1));
return TRUE;
}
@@ -413,7 +413,7 @@ bayes_classify(struct rspamd_classifier *ctx,
if (cl.processed_tokens > 0 && fabs(final_prob - 0.5) > 0.05) {
/* Now we can have exactly one HAM and exactly one SPAM statfiles per classifier */
for (i = 0; i < ctx->statfiles_ids->len; i++) {
- id = g_array_index(ctx->statfiles_ids, gint, i);
+ id = g_array_index(ctx->statfiles_ids, int, i);
st = g_ptr_array_index(ctx->ctx->statfiles, id);
if (final_prob > 0.5 && st->stcf->is_spam) {
@@ -468,8 +468,8 @@ bayes_learn_spam(struct rspamd_classifier *ctx,
gboolean unlearn,
GError **err)
{
- guint i, j, total_cnt, spam_cnt, ham_cnt;
- gint id;
+ unsigned int i, j, total_cnt, spam_cnt, ham_cnt;
+ int id;
struct rspamd_statfile *st;
rspamd_token_t *tok;
gboolean incrementing;
@@ -486,7 +486,7 @@ bayes_learn_spam(struct rspamd_classifier *ctx,
tok = g_ptr_array_index(tokens, i);
for (j = 0; j < ctx->statfiles_ids->len; j++) {
- id = g_array_index(ctx->statfiles_ids, gint, j);
+ id = g_array_index(ctx->statfiles_ids, int, j);
st = g_ptr_array_index(ctx->ctx->statfiles, id);
g_assert(st != NULL);
diff --git a/src/libstat/classifiers/classifiers.h b/src/libstat/classifiers/classifiers.h
index 949408c6b..22978e673 100644
--- a/src/libstat/classifiers/classifiers.h
+++ b/src/libstat/classifiers/classifiers.h
@@ -91,7 +91,7 @@ gboolean lua_classifier_learn_spam(struct rspamd_classifier *ctx,
gboolean unlearn,
GError **err);
-extern gint rspamd_bayes_log_id;
+extern int rspamd_bayes_log_id;
#define msg_debug_bayes(...) rspamd_conditional_debug_fast(NULL, task->from_addr, \
rspamd_bayes_log_id, "bayes", task->task_pool->tag.uid, \
G_STRFUNC, \
diff --git a/src/libstat/classifiers/lua_classifier.c b/src/libstat/classifiers/lua_classifier.c
index 88ab015d6..d30de01a9 100644
--- a/src/libstat/classifiers/lua_classifier.c
+++ b/src/libstat/classifiers/lua_classifier.c
@@ -20,9 +20,9 @@
#include "lua/lua_common.h"
struct rspamd_lua_classifier_ctx {
- gchar *name;
- gint classify_ref;
- gint learn_ref;
+ char *name;
+ int classify_ref;
+ int learn_ref;
};
static GHashTable *lua_classifiers = NULL;
@@ -53,7 +53,7 @@ lua_classifier_init(struct rspamd_config *cfg,
{
struct rspamd_lua_classifier_ctx *ctx;
lua_State *L = cl->ctx->cfg->lua_state;
- gint cb_classify = -1, cb_learn = -1;
+ int cb_classify = -1, cb_learn = -1;
if (lua_classifiers == NULL) {
lua_classifiers = g_hash_table_new_full(rspamd_strcase_hash,
@@ -135,7 +135,7 @@ lua_classifier_classify(struct rspamd_classifier *cl,
struct rspamd_classifier_config **pcfg;
lua_State *L;
rspamd_token_t *tok;
- guint i;
+ unsigned int i;
uint64_t v;
ctx = g_hash_table_lookup(lua_classifiers, cl->subrs->name);
@@ -190,7 +190,7 @@ lua_classifier_learn_spam(struct rspamd_classifier *cl,
struct rspamd_classifier_config **pcfg;
lua_State *L;
rspamd_token_t *tok;
- guint i;
+ unsigned int i;
uint64_t v;
ctx = g_hash_table_lookup(lua_classifiers, cl->subrs->name);
diff --git a/src/libstat/learn_cache/learn_cache.h b/src/libstat/learn_cache/learn_cache.h
index 11a66fc09..9aea31218 100644
--- a/src/libstat/learn_cache/learn_cache.h
+++ b/src/libstat/learn_cache/learn_cache.h
@@ -41,13 +41,13 @@ struct rspamd_stat_cache {
gpointer (*runtime)(struct rspamd_task *task,
gpointer ctx, gboolean learn);
- gint (*check)(struct rspamd_task *task,
- gboolean is_spam,
- gpointer runtime);
+ int (*check)(struct rspamd_task *task,
+ gboolean is_spam,
+ gpointer runtime);
- gint (*learn)(struct rspamd_task *task,
- gboolean is_spam,
- gpointer runtime);
+ int (*learn)(struct rspamd_task *task,
+ gboolean is_spam,
+ gpointer runtime);
void (*close)(gpointer ctx);
@@ -61,12 +61,12 @@ struct rspamd_stat_cache {
const ucl_object_t *cf); \
gpointer rspamd_stat_cache_##name##_runtime(struct rspamd_task *task, \
gpointer ctx, gboolean learn); \
- gint rspamd_stat_cache_##name##_check(struct rspamd_task *task, \
- gboolean is_spam, \
- gpointer runtime); \
- gint rspamd_stat_cache_##name##_learn(struct rspamd_task *task, \
- gboolean is_spam, \
- gpointer runtime); \
+ int rspamd_stat_cache_##name##_check(struct rspamd_task *task, \
+ gboolean is_spam, \
+ gpointer runtime); \
+ int rspamd_stat_cache_##name##_learn(struct rspamd_task *task, \
+ gboolean is_spam, \
+ gpointer runtime); \
void rspamd_stat_cache_##name##_close(gpointer ctx)
RSPAMD_STAT_CACHE_DEF(sqlite3);
diff --git a/src/libstat/learn_cache/redis_cache.cxx b/src/libstat/learn_cache/redis_cache.cxx
index 0be56bccd..15dccf141 100644
--- a/src/libstat/learn_cache/redis_cache.cxx
+++ b/src/libstat/learn_cache/redis_cache.cxx
@@ -68,7 +68,7 @@ rspamd_stat_cache_redis_generate_id(struct rspamd_task *task)
sizeof(tok->data));
}
- guchar out[rspamd_cryptobox_HASHBYTES];
+ unsigned char out[rspamd_cryptobox_HASHBYTES];
rspamd_cryptobox_hash_final(&st, out);
auto *b32out = rspamd_mempool_alloc_array_type(task->task_pool,
@@ -152,7 +152,7 @@ rspamd_stat_cache_redis_runtime(struct rspamd_task *task,
return (void *) ctx;
}
-static gint
+static int
rspamd_stat_cache_checked(lua_State *L)
{
auto *task = lua_check_task(L, 1);
@@ -181,9 +181,9 @@ rspamd_stat_cache_checked(lua_State *L)
return 0;
}
-gint rspamd_stat_cache_redis_check(struct rspamd_task *task,
- gboolean is_spam,
- gpointer runtime)
+int rspamd_stat_cache_redis_check(struct rspamd_task *task,
+ gboolean is_spam,
+ gpointer runtime)
{
auto *ctx = (struct rspamd_redis_cache_ctx *) runtime;
auto *h = (char *) rspamd_mempool_get_variable(task->task_pool, "words_hash");
@@ -195,7 +195,7 @@ gint rspamd_stat_cache_redis_check(struct rspamd_task *task,
auto *L = ctx->L;
lua_pushcfunction(L, &rspamd_lua_traceback);
- gint err_idx = lua_gettop(L);
+ int err_idx = lua_gettop(L);
/* Function arguments */
lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->check_ref);
@@ -214,9 +214,9 @@ gint rspamd_stat_cache_redis_check(struct rspamd_task *task,
return RSPAMD_LEARN_OK;
}
-gint rspamd_stat_cache_redis_learn(struct rspamd_task *task,
- gboolean is_spam,
- gpointer runtime)
+int rspamd_stat_cache_redis_learn(struct rspamd_task *task,
+ gboolean is_spam,
+ gpointer runtime)
{
auto *ctx = (struct rspamd_redis_cache_ctx *) runtime;
@@ -229,7 +229,7 @@ gint rspamd_stat_cache_redis_learn(struct rspamd_task *task,
auto *L = ctx->L;
lua_pushcfunction(L, &rspamd_lua_traceback);
- gint err_idx = lua_gettop(L);
+ int err_idx = lua_gettop(L);
/* Function arguments */
lua_rawgeti(L, LUA_REGISTRYINDEX, ctx->learn_ref);
diff --git a/src/libstat/learn_cache/sqlite3_cache.c b/src/libstat/learn_cache/sqlite3_cache.c
index 36e9382cd..9a070aa14 100644
--- a/src/libstat/learn_cache/sqlite3_cache.c
+++ b/src/libstat/learn_cache/sqlite3_cache.c
@@ -104,8 +104,8 @@ rspamd_stat_cache_sqlite3_init(struct rspamd_stat_ctx *ctx,
{
struct rspamd_stat_sqlite3_ctx *new = NULL;
const ucl_object_t *elt;
- gchar dbpath[PATH_MAX];
- const gchar *path = SQLITE_CACHE_PATH;
+ char dbpath[PATH_MAX];
+ const char *path = SQLITE_CACHE_PATH;
sqlite3 *sqlite;
GError *err = NULL;
@@ -154,17 +154,17 @@ rspamd_stat_cache_sqlite3_runtime(struct rspamd_task *task,
return ctx;
}
-gint rspamd_stat_cache_sqlite3_check(struct rspamd_task *task,
- gboolean is_spam,
- gpointer runtime)
+int rspamd_stat_cache_sqlite3_check(struct rspamd_task *task,
+ gboolean is_spam,
+ gpointer runtime)
{
struct rspamd_stat_sqlite3_ctx *ctx = runtime;
rspamd_cryptobox_hash_state_t st;
rspamd_token_t *tok;
- guchar *out;
- gchar *user = NULL;
- guint i;
- gint rc;
+ unsigned char *out;
+ char *user = NULL;
+ unsigned int i;
+ int rc;
int64_t flag;
if (task->tokens == NULL || task->tokens->len == 0) {
@@ -184,7 +184,7 @@ gint rspamd_stat_cache_sqlite3_check(struct rspamd_task *task,
for (i = 0; i < task->tokens->len; i++) {
tok = g_ptr_array_index(task->tokens, i);
- rspamd_cryptobox_hash_update(&st, (guchar *) &tok->data,
+ rspamd_cryptobox_hash_update(&st, (unsigned char *) &tok->data,
sizeof(tok->data));
}
@@ -219,13 +219,13 @@ gint rspamd_stat_cache_sqlite3_check(struct rspamd_task *task,
return RSPAMD_LEARN_OK;
}
-gint rspamd_stat_cache_sqlite3_learn(struct rspamd_task *task,
- gboolean is_spam,
- gpointer runtime)
+int rspamd_stat_cache_sqlite3_learn(struct rspamd_task *task,
+ gboolean is_spam,
+ gpointer runtime)
{
struct rspamd_stat_sqlite3_ctx *ctx = runtime;
gboolean unlearn = !!(task->flags & RSPAMD_TASK_FLAG_UNLEARN);
- guchar *h;
+ unsigned char *h;
int64_t flag;
h = rspamd_mempool_get_variable(task->task_pool, "words_hash");
diff --git a/src/libstat/stat_api.h b/src/libstat/stat_api.h
index af3cdc8b9..f28922588 100644
--- a/src/libstat/stat_api.h
+++ b/src/libstat/stat_api.h
@@ -50,14 +50,14 @@ typedef struct rspamd_stat_token_s {
rspamd_ftok_unicode_t unicode; /* array of unicode characters, normalized, lowercased */
rspamd_ftok_t normalized; /* normalized and lowercased utf8 */
rspamd_ftok_t stemmed; /* stemmed utf8 */
- guint flags;
+ unsigned int flags;
} rspamd_stat_token_t;
#define RSPAMD_TOKEN_VALUE_TYPE float
typedef struct token_node_s {
uint64_t data;
- guint window_idx;
- guint flags;
+ unsigned int window_idx;
+ unsigned int flags;
rspamd_stat_token_t *t1;
rspamd_stat_token_t *t2;
RSPAMD_TOKEN_VALUE_TYPE values[0];
@@ -104,7 +104,7 @@ void rspamd_stat_process_tokenize(struct rspamd_stat_ctx *st_ctx,
* @return TRUE if task has been classified
*/
rspamd_stat_result_t rspamd_stat_classify(struct rspamd_task *task,
- lua_State *L, guint stage, GError **err);
+ lua_State *L, unsigned int stage, GError **err);
/**
@@ -124,8 +124,8 @@ gboolean rspamd_stat_check_autolearn(struct rspamd_task *task);
* @return TRUE if task has been learned
*/
rspamd_stat_result_t rspamd_stat_learn(struct rspamd_task *task,
- gboolean spam, lua_State *L, const gchar *classifier,
- guint stage,
+ gboolean spam, lua_State *L, const char *classifier,
+ unsigned int stage,
GError **err);
/**
diff --git a/src/libstat/stat_config.c b/src/libstat/stat_config.c
index 0e1ae5432..8a5313df2 100644
--- a/src/libstat/stat_config.c
+++ b/src/libstat/stat_config.c
@@ -118,9 +118,9 @@ void rspamd_stat_init(struct rspamd_config *cfg, struct ev_loop *ev_base)
struct rspamd_statfile *st;
struct rspamd_classifier *cl;
const ucl_object_t *cache_obj = NULL, *cache_name_obj;
- const gchar *cache_name = NULL;
+ const char *cache_name = NULL;
lua_State *L = cfg->lua_state;
- guint lua_classifiers_cnt = 0, i;
+ unsigned int lua_classifiers_cnt = 0, i;
gboolean skip_cache = FALSE;
if (stat_ctx == NULL) {
@@ -205,7 +205,7 @@ void rspamd_stat_init(struct rspamd_config *cfg, struct ev_loop *ev_base)
}
else {
/* Call this function to obtain closure */
- gint err_idx, ret;
+ int err_idx, ret;
struct rspamd_config **pcfg;
lua_pushcfunction(L, &rspamd_lua_traceback);
@@ -248,7 +248,7 @@ void rspamd_stat_init(struct rspamd_config *cfg, struct ev_loop *ev_base)
cl = g_malloc0(sizeof(*cl));
cl->cfg = clf;
cl->ctx = stat_ctx;
- cl->statfiles_ids = g_array_new(FALSE, FALSE, sizeof(gint));
+ cl->statfiles_ids = g_array_new(FALSE, FALSE, sizeof(int));
cl->subrs = rspamd_stat_get_classifier(clf->classifier);
if (cl->subrs == NULL) {
@@ -391,8 +391,8 @@ void rspamd_stat_close(void)
struct rspamd_stat_ctx *st_ctx;
struct rspamd_stat_async_elt *aelt;
GList *cur;
- guint i, j;
- gint id;
+ unsigned int i, j;
+ int id;
st_ctx = rspamd_stat_get_ctx();
g_assert(st_ctx != NULL);
@@ -401,7 +401,7 @@ void rspamd_stat_close(void)
cl = g_ptr_array_index(st_ctx->classifiers, i);
for (j = 0; j < cl->statfiles_ids->len; j++) {
- id = g_array_index(cl->statfiles_ids, gint, j);
+ id = g_array_index(cl->statfiles_ids, int, j);
st = g_ptr_array_index(st_ctx->statfiles, id);
if (!(st->classifier->cfg->flags & RSPAMD_FLAG_CLASSIFIER_NO_BACKEND)) {
st->backend->close(st->bkcf);
@@ -454,9 +454,9 @@ rspamd_stat_get_ctx(void)
}
struct rspamd_stat_classifier *
-rspamd_stat_get_classifier(const gchar *name)
+rspamd_stat_get_classifier(const char *name)
{
- guint i;
+ unsigned int i;
if (name == NULL || name[0] == '\0') {
name = RSPAMD_DEFAULT_CLASSIFIER;
@@ -474,9 +474,9 @@ rspamd_stat_get_classifier(const gchar *name)
}
struct rspamd_stat_backend *
-rspamd_stat_get_backend(const gchar *name)
+rspamd_stat_get_backend(const char *name)
{
- guint i;
+ unsigned int i;
if (name == NULL || name[0] == '\0') {
name = RSPAMD_DEFAULT_BACKEND;
@@ -494,9 +494,9 @@ rspamd_stat_get_backend(const gchar *name)
}
struct rspamd_stat_tokenizer *
-rspamd_stat_get_tokenizer(const gchar *name)
+rspamd_stat_get_tokenizer(const char *name)
{
- guint i;
+ unsigned int i;
if (name == NULL || name[0] == '\0') {
name = RSPAMD_DEFAULT_TOKENIZER;
@@ -514,9 +514,9 @@ rspamd_stat_get_tokenizer(const gchar *name)
}
struct rspamd_stat_cache *
-rspamd_stat_get_cache(const gchar *name)
+rspamd_stat_get_cache(const char *name)
{
- guint i;
+ unsigned int i;
if (name == NULL || name[0] == '\0') {
name = RSPAMD_DEFAULT_CACHE;
@@ -548,7 +548,7 @@ static void
rspamd_async_elt_on_timer(EV_P_ ev_timer *w, int revents)
{
struct rspamd_stat_async_elt *elt = (struct rspamd_stat_async_elt *) w->data;
- gdouble jittered_time;
+ double jittered_time;
if (elt->enabled) {
@@ -564,7 +564,7 @@ struct rspamd_stat_async_elt *
rspamd_stat_ctx_register_async(rspamd_stat_async_handler handler,
rspamd_stat_async_cleanup cleanup,
gpointer d,
- gdouble timeout)
+ double timeout)
{
struct rspamd_stat_async_elt *elt;
struct rspamd_stat_ctx *st_ctx;
diff --git a/src/libstat/stat_internal.h b/src/libstat/stat_internal.h
index 604a2af91..96d67cbf6 100644
--- a/src/libstat/stat_internal.h
+++ b/src/libstat/stat_internal.h
@@ -43,14 +43,14 @@ struct rspamd_classifier {
gpointer cachecf;
gulong spam_learns;
gulong ham_learns;
- gint autolearn_cbref;
+ int autolearn_cbref;
struct rspamd_classifier_config *cfg;
struct rspamd_stat_classifier *subrs;
gpointer specific;
};
struct rspamd_statfile {
- gint id;
+ int id;
struct rspamd_statfile_config *stcf;
struct rspamd_classifier *classifier;
struct rspamd_stat_backend *backend;
@@ -70,7 +70,7 @@ struct rspamd_stat_async_elt {
rspamd_stat_async_cleanup cleanup;
struct ev_loop *event_loop;
ev_timer timer_ev;
- gdouble timeout;
+ double timeout;
gboolean enabled;
gpointer ud;
ref_entry_t ref;
@@ -79,13 +79,13 @@ struct rspamd_stat_async_elt {
struct rspamd_stat_ctx {
/* Subroutines for all objects */
struct rspamd_stat_classifier *classifiers_subrs;
- guint classifiers_count;
+ unsigned int classifiers_count;
struct rspamd_stat_tokenizer *tokenizers_subrs;
- guint tokenizers_count;
+ unsigned int tokenizers_count;
struct rspamd_stat_backend *backends_subrs;
- guint backends_count;
+ unsigned int backends_count;
struct rspamd_stat_cache *caches_subrs;
- guint caches_count;
+ unsigned int caches_count;
/* Runtime configuration */
GPtrArray *statfiles; /* struct rspamd_statfile */
@@ -93,7 +93,7 @@ struct rspamd_stat_ctx {
GQueue *async_elts; /* struct rspamd_stat_async_elt */
struct rspamd_config *cfg;
- gint lua_stat_tokens_ref;
+ int lua_stat_tokens_ref;
/* Global tokenizer */
struct rspamd_stat_tokenizer *tokenizer;
@@ -110,17 +110,17 @@ typedef enum rspamd_learn_cache_result {
struct rspamd_stat_ctx *rspamd_stat_get_ctx(void);
-struct rspamd_stat_classifier *rspamd_stat_get_classifier(const gchar *name);
+struct rspamd_stat_classifier *rspamd_stat_get_classifier(const char *name);
-struct rspamd_stat_backend *rspamd_stat_get_backend(const gchar *name);
+struct rspamd_stat_backend *rspamd_stat_get_backend(const char *name);
-struct rspamd_stat_tokenizer *rspamd_stat_get_tokenizer(const gchar *name);
+struct rspamd_stat_tokenizer *rspamd_stat_get_tokenizer(const char *name);
-struct rspamd_stat_cache *rspamd_stat_get_cache(const gchar *name);
+struct rspamd_stat_cache *rspamd_stat_get_cache(const char *name);
struct rspamd_stat_async_elt *rspamd_stat_ctx_register_async(
rspamd_stat_async_handler handler, rspamd_stat_async_cleanup cleanup,
- gpointer d, gdouble timeout);
+ gpointer d, double timeout);
static GQuark rspamd_stat_quark(void)
{
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c
index c15c32bf0..7f62d4e2a 100644
--- a/src/libstat/stat_process.c
+++ b/src/libstat/stat_process.c
@@ -30,7 +30,7 @@
#define RSPAMD_LEARN_OP 1
#define RSPAMD_UNLEARN_OP 2
-static const gdouble similarity_threshold = 80.0;
+static const double similarity_threshold = 80.0;
static void
rspamd_stat_tokenize_parts_metadata(struct rspamd_stat_ctx *st_ctx,
@@ -38,7 +38,7 @@ rspamd_stat_tokenize_parts_metadata(struct rspamd_stat_ctx *st_ctx,
{
GArray *ar;
rspamd_stat_token_t elt;
- guint i;
+ unsigned int i;
lua_State *L = task->cfg->lua_state;
ar = g_array_sized_new(FALSE, FALSE, sizeof(elt), 16);
@@ -46,7 +46,7 @@ rspamd_stat_tokenize_parts_metadata(struct rspamd_stat_ctx *st_ctx,
elt.flags = RSPAMD_STAT_TOKEN_FLAG_META;
if (st_ctx->lua_stat_tokens_ref != -1) {
- gint err_idx, ret;
+ int err_idx, ret;
struct rspamd_task **ptask;
lua_pushcfunction(L, &rspamd_lua_traceback);
@@ -69,7 +69,7 @@ rspamd_stat_tokenize_parts_metadata(struct rspamd_stat_ctx *st_ctx,
lua_typename(L, lua_type(L, -1)));
}
else {
- guint vlen;
+ unsigned int vlen;
rspamd_ftok_t tok;
vlen = rspamd_lua_table_size(L, -1);
@@ -121,10 +121,10 @@ void rspamd_stat_process_tokenize(struct rspamd_stat_ctx *st_ctx,
struct rspamd_mime_text_part *part;
rspamd_cryptobox_hash_state_t hst;
rspamd_token_t *st_tok;
- guint i, reserved_len = 0;
- gdouble *pdiff;
- guchar hout[rspamd_cryptobox_HASHBYTES];
- gchar *b32_hout;
+ unsigned int i, reserved_len = 0;
+ double *pdiff;
+ unsigned char hout[rspamd_cryptobox_HASHBYTES];
+ char *b32_hout;
if (st_ctx == NULL) {
st_ctx = rspamd_stat_get_ctx();
@@ -179,7 +179,7 @@ void rspamd_stat_process_tokenize(struct rspamd_stat_ctx *st_ctx,
PTR_ARRAY_FOREACH(task->tokens, i, st_tok)
{
- rspamd_cryptobox_hash_update(&hst, (guchar *) &st_tok->data,
+ rspamd_cryptobox_hash_update(&hst, (unsigned char *) &st_tok->data,
sizeof(st_tok->data));
}
@@ -203,9 +203,9 @@ rspamd_stat_classifier_is_skipped(struct rspamd_task *task,
gboolean ret = FALSE;
while (cur) {
- gint cb_ref = GPOINTER_TO_INT(cur->data);
- gint old_top = lua_gettop(L);
- gint nargs;
+ int cb_ref = GPOINTER_TO_INT(cur->data);
+ int old_top = lua_gettop(L);
+ int nargs;
lua_rawgeti(L, LUA_REGISTRYINDEX, cb_ref);
/* Push task and two booleans: is_spam and is_unlearn */
@@ -269,7 +269,7 @@ static void
rspamd_stat_preprocess(struct rspamd_stat_ctx *st_ctx,
struct rspamd_task *task, gboolean is_learn, gboolean is_spam)
{
- guint i;
+ unsigned int i;
struct rspamd_statfile *st;
gpointer bk_run;
@@ -303,7 +303,7 @@ rspamd_stat_preprocess(struct rspamd_stat_ctx *st_ctx,
if (skip_classifier) {
/* Set NULL for all statfiles indexed by id */
for (int j = 0; j < cl->statfiles_ids->len; j++) {
- int id = g_array_index(cl->statfiles_ids, gint, j);
+ int id = g_array_index(cl->statfiles_ids, int, j);
g_ptr_array_index(task->stat_runtimes, id) = NULL;
}
}
@@ -347,7 +347,7 @@ static void
rspamd_stat_backends_process(struct rspamd_stat_ctx *st_ctx,
struct rspamd_task *task)
{
- guint i;
+ unsigned int i;
struct rspamd_statfile *st;
gpointer bk_run;
@@ -367,7 +367,7 @@ static void
rspamd_stat_classifiers_process(struct rspamd_stat_ctx *st_ctx,
struct rspamd_task *task)
{
- guint i, j, id;
+ unsigned int i, j, id;
struct rspamd_classifier *cl;
struct rspamd_statfile *st;
gpointer bk_run;
@@ -429,7 +429,7 @@ rspamd_stat_classifiers_process(struct rspamd_stat_ctx *st_ctx,
/* Do not process classifiers on backend failures */
for (j = 0; j < cl->statfiles_ids->len; j++) {
- id = g_array_index(cl->statfiles_ids, gint, j);
+ id = g_array_index(cl->statfiles_ids, int, j);
bk_run = g_ptr_array_index(task->stat_runtimes, id);
st = g_ptr_array_index(st_ctx->statfiles, id);
@@ -444,7 +444,7 @@ rspamd_stat_classifiers_process(struct rspamd_stat_ctx *st_ctx,
/* Ensure that all symbols enabled */
if (!skip && !(cl->cfg->flags & RSPAMD_FLAG_CLASSIFIER_NO_BACKEND)) {
for (j = 0; j < cl->statfiles_ids->len; j++) {
- id = g_array_index(cl->statfiles_ids, gint, j);
+ id = g_array_index(cl->statfiles_ids, int, j);
bk_run = g_ptr_array_index(task->stat_runtimes, id);
st = g_ptr_array_index(st_ctx->statfiles, id);
@@ -483,7 +483,7 @@ rspamd_stat_classifiers_process(struct rspamd_stat_ctx *st_ctx,
}
rspamd_stat_result_t
-rspamd_stat_classify(struct rspamd_task *task, lua_State *L, guint stage,
+rspamd_stat_classify(struct rspamd_task *task, lua_State *L, unsigned int stage,
GError **err)
{
struct rspamd_stat_ctx *st_ctx;
@@ -518,14 +518,14 @@ rspamd_stat_classify(struct rspamd_task *task, lua_State *L, guint stage,
static gboolean
rspamd_stat_cache_check(struct rspamd_stat_ctx *st_ctx,
struct rspamd_task *task,
- const gchar *classifier,
+ const char *classifier,
gboolean spam,
GError **err)
{
rspamd_learn_t learn_res = RSPAMD_LEARN_OK;
struct rspamd_classifier *cl, *sel = NULL;
gpointer rt;
- guint i;
+ unsigned int i;
/* Check whether we have learned that file */
for (i = 0; i < st_ctx->classifiers->len; i++) {
@@ -579,12 +579,12 @@ rspamd_stat_cache_check(struct rspamd_stat_ctx *st_ctx,
static gboolean
rspamd_stat_classifiers_learn(struct rspamd_stat_ctx *st_ctx,
struct rspamd_task *task,
- const gchar *classifier,
+ const char *classifier,
gboolean spam,
GError **err)
{
struct rspamd_classifier *cl, *sel = NULL;
- guint i;
+ unsigned int i;
gboolean learned = FALSE, too_small = FALSE, too_large = FALSE;
if ((task->flags & RSPAMD_TASK_FLAG_ALREADY_LEARNED) && err != NULL &&
@@ -680,15 +680,15 @@ rspamd_stat_classifiers_learn(struct rspamd_stat_ctx *st_ctx,
static gboolean
rspamd_stat_backends_learn(struct rspamd_stat_ctx *st_ctx,
struct rspamd_task *task,
- const gchar *classifier,
+ const char *classifier,
gboolean spam,
GError **err)
{
struct rspamd_classifier *cl, *sel = NULL;
struct rspamd_statfile *st;
gpointer bk_run;
- guint i, j;
- gint id;
+ unsigned int i, j;
+ int id;
gboolean res = FALSE, backend_found = FALSE;
for (i = 0; i < st_ctx->classifiers->len; i++) {
@@ -708,7 +708,7 @@ rspamd_stat_backends_learn(struct rspamd_stat_ctx *st_ctx,
sel = cl;
for (j = 0; j < cl->statfiles_ids->len; j++) {
- id = g_array_index(cl->statfiles_ids, gint, j);
+ id = g_array_index(cl->statfiles_ids, int, j);
st = g_ptr_array_index(st_ctx->statfiles, id);
bk_run = g_ptr_array_index(task->stat_runtimes, id);
@@ -802,15 +802,15 @@ end:
static gboolean
rspamd_stat_backends_post_learn(struct rspamd_stat_ctx *st_ctx,
struct rspamd_task *task,
- const gchar *classifier,
+ const char *classifier,
gboolean spam,
GError **err)
{
struct rspamd_classifier *cl;
struct rspamd_statfile *st;
gpointer bk_run, cache_run;
- guint i, j;
- gint id;
+ unsigned int i, j;
+ int id;
gboolean res = TRUE;
for (i = 0; i < st_ctx->classifiers->len; i++) {
@@ -828,7 +828,7 @@ rspamd_stat_backends_post_learn(struct rspamd_stat_ctx *st_ctx,
}
for (j = 0; j < cl->statfiles_ids->len; j++) {
- id = g_array_index(cl->statfiles_ids, gint, j);
+ id = g_array_index(cl->statfiles_ids, int, j);
st = g_ptr_array_index(st_ctx->statfiles, id);
bk_run = g_ptr_array_index(task->stat_runtimes, id);
@@ -857,7 +857,7 @@ rspamd_stat_backends_post_learn(struct rspamd_stat_ctx *st_ctx,
rspamd_stat_result_t
rspamd_stat_learn(struct rspamd_task *task,
- gboolean spam, lua_State *L, const gchar *classifier, guint stage,
+ gboolean spam, lua_State *L, const char *classifier, unsigned int stage,
GError **err)
{
struct rspamd_stat_ctx *st_ctx;
@@ -925,8 +925,8 @@ rspamd_stat_has_classifier_symbols(struct rspamd_task *task,
struct rspamd_scan_result *mres,
struct rspamd_classifier *cl)
{
- guint i;
- gint id;
+ unsigned int i;
+ int id;
struct rspamd_statfile *st;
struct rspamd_stat_ctx *st_ctx;
gboolean is_spam;
@@ -939,7 +939,7 @@ rspamd_stat_has_classifier_symbols(struct rspamd_task *task,
is_spam = !!(task->flags & RSPAMD_TASK_FLAG_LEARN_SPAM);
for (i = 0; i < cl->statfiles_ids->len; i++) {
- id = g_array_index(cl->statfiles_ids, gint, i);
+ id = g_array_index(cl->statfiles_ids, int, i);
st = g_ptr_array_index(st_ctx->statfiles, id);
if (rspamd_task_find_symbol_result(task, st->stcf->symbol, NULL)) {
@@ -965,11 +965,11 @@ rspamd_stat_check_autolearn(struct rspamd_task *task)
struct rspamd_scan_result *mres = NULL;
struct rspamd_task **ptask;
lua_State *L;
- guint i;
- gint err_idx;
+ unsigned int i;
+ int err_idx;
gboolean ret = FALSE;
- gdouble ham_score, spam_score;
- const gchar *lua_script, *lua_ret;
+ double ham_score, spam_score;
+ const char *lua_script, *lua_ret;
g_assert(RSPAMD_TASK_IS_CLASSIFIED(task));
st_ctx = rspamd_stat_get_ctx();
@@ -1025,7 +1025,7 @@ rspamd_stat_check_autolearn(struct rspamd_task *task)
spam_score = ucl_object_todouble(elt2);
if (ham_score > spam_score) {
- gdouble t;
+ double t;
t = ham_score;
ham_score = spam_score;
@@ -1198,8 +1198,8 @@ rspamd_stat_statistics(struct rspamd_task *task,
gpointer backend_runtime;
ucl_object_t *res = NULL, *elt;
uint64_t learns = 0;
- guint i, j;
- gint id;
+ unsigned int i, j;
+ int id;
st_ctx = rspamd_stat_get_ctx();
g_assert(st_ctx != NULL);
@@ -1214,7 +1214,7 @@ rspamd_stat_statistics(struct rspamd_task *task,
}
for (j = 0; j < cl->statfiles_ids->len; j++) {
- id = g_array_index(cl->statfiles_ids, gint, j);
+ id = g_array_index(cl->statfiles_ids, int, j);
st = g_ptr_array_index(st_ctx->statfiles, id);
backend_runtime = st->backend->runtime(task, st->stcf, FALSE,
st->bkcf, id);
diff --git a/src/libstat/tokenizers/osb.c b/src/libstat/tokenizers/osb.c
index 3f770c69e..039ead231 100644
--- a/src/libstat/tokenizers/osb.c
+++ b/src/libstat/tokenizers/osb.c
@@ -49,7 +49,7 @@ static const int primes[] = {
3277,
};
-static const guchar osb_tokenizer_magic[] = {'o', 's', 'b', 't', 'o', 'k', 'v', '2'};
+static const unsigned char osb_tokenizer_magic[] = {'o', 's', 'b', 't', 'o', 'k', 'v', '2'};
enum rspamd_osb_hash_type {
RSPAMD_OSB_HASH_COMPAT = 0,
@@ -58,7 +58,7 @@ enum rspamd_osb_hash_type {
};
struct rspamd_osb_tokenizer_config {
- guchar magic[8];
+ unsigned char magic[8];
gshort version;
gshort window_size;
enum rspamd_osb_hash_type ht;
@@ -92,7 +92,7 @@ rspamd_tokenizer_osb_config_from_ucl(rspamd_mempool_t *pool,
{
const ucl_object_t *elt;
struct rspamd_osb_tokenizer_config *cf, *def;
- guchar *key = NULL;
+ unsigned char *key = NULL;
gsize keylen;
@@ -266,12 +266,12 @@ struct token_pipe_entry {
rspamd_stat_token_t *t;
};
-gint rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx,
- struct rspamd_task *task,
- GArray *words,
- gboolean is_utf,
- const gchar *prefix,
- GPtrArray *result)
+int rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx,
+ struct rspamd_task *task,
+ GArray *words,
+ gboolean is_utf,
+ const char *prefix,
+ GPtrArray *result)
{
rspamd_token_t *new_tok = NULL;
rspamd_stat_token_t *token;
@@ -280,7 +280,7 @@ gint rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx,
struct token_pipe_entry *hashpipe;
uint32_t h1, h2;
gsize token_size;
- guint processed = 0, i, w, window_size, token_flags = 0;
+ unsigned int processed = 0, i, w, window_size, token_flags = 0;
if (words == NULL) {
return FALSE;
@@ -309,7 +309,7 @@ gint rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx,
for (w = 0; w < words->len; w++) {
token = &g_array_index(words, rspamd_stat_token_t, w);
token_flags = token->flags;
- const gchar *begin;
+ const char *begin;
gsize len;
if (token->flags &
@@ -341,7 +341,7 @@ gint rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx,
begin, len, osb_cf->seed);
}
else {
- rspamd_cryptobox_siphash((guchar *) &cur, begin,
+ rspamd_cryptobox_siphash((unsigned char *) &cur, begin,
len, osb_cf->sk);
if (prefix) {
@@ -373,8 +373,8 @@ gint rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx,
((uint32_t) hashpipe[i].h) * primes[i << 1]; \
h2 = ((uint32_t) hashpipe[0].h) * primes[1] + \
((uint32_t) hashpipe[i].h) * primes[(i << 1) - 1]; \
- memcpy((guchar *) &new_tok->data, &h1, sizeof(h1)); \
- memcpy(((guchar *) &new_tok->data) + sizeof(h1), &h2, sizeof(h2)); \
+ memcpy((unsigned char *) &new_tok->data, &h1, sizeof(h1)); \
+ memcpy(((unsigned char *) &new_tok->data) + sizeof(h1), &h2, sizeof(h2)); \
} \
else { \
new_tok->data = hashpipe[0].h * primes[0] + hashpipe[i].h * primes[i << 1]; \
diff --git a/src/libstat/tokenizers/tokenizers.c b/src/libstat/tokenizers/tokenizers.c
index 702668142..0ea1bcfc6 100644
--- a/src/libstat/tokenizers/tokenizers.c
+++ b/src/libstat/tokenizers/tokenizers.c
@@ -35,11 +35,11 @@
#include <math.h>
-typedef gboolean (*token_get_function)(rspamd_stat_token_t *buf, gchar const **pos,
+typedef gboolean (*token_get_function)(rspamd_stat_token_t *buf, char const **pos,
rspamd_stat_token_t *token,
GList **exceptions, gsize *rl, gboolean check_signature);
-const gchar t_delimiters[256] = {
+const char t_delimiters[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -70,11 +70,11 @@ const gchar t_delimiters[256] = {
/* Get next word from specified f_str_t buf */
static gboolean
rspamd_tokenizer_get_word_raw(rspamd_stat_token_t *buf,
- gchar const **cur, rspamd_stat_token_t *token,
+ char const **cur, rspamd_stat_token_t *token,
GList **exceptions, gsize *rl, gboolean unused)
{
gsize remain, pos;
- const gchar *p;
+ const char *p;
struct rspamd_process_exception *ex = NULL;
if (buf == NULL) {
@@ -127,11 +127,11 @@ rspamd_tokenizer_get_word_raw(rspamd_stat_token_t *buf,
pos++;
p++;
remain--;
- } while (remain > 0 && t_delimiters[(guchar) *p]);
+ } while (remain > 0 && t_delimiters[(unsigned char) *p]);
token->original.begin = p;
- while (remain > 0 && !t_delimiters[(guchar) *p]) {
+ while (remain > 0 && !t_delimiters[(unsigned char) *p]) {
if (ex != NULL && ex->pos == pos) {
*exceptions = g_list_next(*exceptions);
*cur = p + ex->len;
@@ -160,15 +160,15 @@ rspamd_tokenizer_get_word_raw(rspamd_stat_token_t *buf,
static inline gboolean
rspamd_tokenize_check_limit(gboolean decay,
- guint word_decay,
- guint nwords,
+ unsigned int word_decay,
+ unsigned int nwords,
uint64_t *hv,
uint64_t *prob,
const rspamd_stat_token_t *token,
gssize remain,
gssize total)
{
- static const gdouble avg_word_len = 6.0;
+ static const double avg_word_len = 6.0;
if (!decay) {
if (token->original.len >= sizeof(uint64_t)) {
@@ -180,12 +180,12 @@ rspamd_tokenize_check_limit(gboolean decay,
/* Check for decay */
if (word_decay > 0 && nwords > word_decay && remain < (gssize) total) {
/* Start decay */
- gdouble decay_prob;
+ double decay_prob;
*hv = mum_hash_finish(*hv);
/* We assume that word is 6 symbols length in average */
- decay_prob = (gdouble) word_decay / ((total - (remain)) / avg_word_len) * 10;
+ decay_prob = (double) word_decay / ((total - (remain)) / avg_word_len) * 10;
decay_prob = floor(decay_prob) / 10.0;
if (decay_prob >= 1.0) {
@@ -212,10 +212,10 @@ rspamd_tokenize_check_limit(gboolean decay,
}
static inline gboolean
-rspamd_utf_word_valid(const guchar *text, const guchar *end,
+rspamd_utf_word_valid(const unsigned char *text, const unsigned char *end,
int32_t start, int32_t finish)
{
- const guchar *st = text + start, *fin = text + finish;
+ const unsigned char *st = text + start, *fin = text + finish;
UChar32 c;
if (st >= end || fin > end || st >= fin) {
@@ -278,7 +278,7 @@ rspamd_tokenize_exception(struct rspamd_process_exception *ex, GArray *res)
GArray *
-rspamd_tokenize_text(const gchar *text, gsize len,
+rspamd_tokenize_text(const char *text, gsize len,
const UText *utxt,
enum rspamd_tokenize_type how,
struct rspamd_config *cfg,
@@ -288,11 +288,11 @@ rspamd_tokenize_text(const gchar *text, gsize len,
rspamd_mempool_t *pool)
{
rspamd_stat_token_t token, buf;
- const gchar *pos = NULL;
+ const char *pos = NULL;
gsize l = 0;
GArray *res;
GList *cur = exceptions;
- guint min_len = 0, max_len = 0, word_decay = 0, initial_size = 128;
+ unsigned int min_len = 0, max_len = 0, word_decay = 0, initial_size = 128;
uint64_t hv = 0;
gboolean decay = FALSE, long_text_mode = FALSE;
uint64_t prob = 0;
@@ -429,7 +429,7 @@ rspamd_tokenize_text(const gchar *text, gsize len,
msg_warn_pool_check(
"tokenization reversed back on position %d,"
"%d new position (%d backward), likely libicu bug!",
- (gint) (p), (gint) (old_p), old_p - p);
+ (int) (p), (int) (old_p), old_p - p);
goto end;
}
@@ -468,7 +468,7 @@ rspamd_tokenize_text(const gchar *text, gsize len,
msg_warn_pool_check(
"tokenization reversed back on position %d,"
"%d new position (%d backward), likely libicu bug!",
- (gint) (p), (gint) (old_p), old_p - p);
+ (int) (p), (int) (old_p), old_p - p);
goto end;
}
@@ -573,7 +573,7 @@ rspamd_tokenize_text(const gchar *text, gsize len,
if (p != UBRK_DONE && p <= last) {
msg_warn_pool_check("tokenization reversed back on position %d,"
"%d new position (%d backward), likely libicu bug!",
- (gint) (p), (gint) (last), last - p);
+ (int) (p), (int) (last), last - p);
goto end;
}
@@ -595,12 +595,12 @@ end:
#undef SHIFT_EX
static void
-rspamd_add_metawords_from_str(const gchar *beg, gsize len,
+rspamd_add_metawords_from_str(const char *beg, gsize len,
struct rspamd_task *task)
{
UText utxt = UTEXT_INITIALIZER;
UErrorCode uc_err = U_ZERO_ERROR;
- guint i = 0;
+ unsigned int i = 0;
UChar32 uc;
gboolean valid_utf = TRUE;
@@ -649,7 +649,7 @@ rspamd_add_metawords_from_str(const gchar *beg, gsize len,
void rspamd_tokenize_meta_words(struct rspamd_task *task)
{
- guint i = 0;
+ unsigned int i = 0;
rspamd_stat_token_t *tok;
if (MESSAGE_FIELD(task, subject)) {
@@ -668,7 +668,7 @@ void rspamd_tokenize_meta_words(struct rspamd_task *task)
}
if (task->meta_words != NULL) {
- const gchar *language = NULL;
+ const char *language = NULL;
if (MESSAGE_FIELD(task, text_parts) &&
MESSAGE_FIELD(task, text_parts)->len > 0) {
@@ -736,9 +736,9 @@ static inline void
rspamd_ucs32_to_normalised(rspamd_stat_token_t *tok,
rspamd_mempool_t *pool)
{
- guint i, doff = 0;
+ unsigned int i, doff = 0;
gsize utflen = 0;
- gchar *dest;
+ char *dest;
UChar32 t;
for (i = 0; i < tok->unicode.len; i++) {
@@ -822,7 +822,7 @@ void rspamd_normalize_single_word(rspamd_stat_token_t *tok, rspamd_mempool_t *po
if (!U_SUCCESS(uc_err)) {
if (uc_err != U_BUFFER_OVERFLOW_ERROR) {
msg_warn_pool_check("cannot normalise text '%*s': %s",
- (gint) tok->original.len, tok->original.begin,
+ (int) tok->original.len, tok->original.begin,
u_errorName(uc_err));
rspamd_uchars_to_ucs32(tmpbuf, ulen, tok, pool);
rspamd_ucs32_to_normalised(tok, pool);
@@ -847,7 +847,7 @@ void rspamd_normalize_single_word(rspamd_stat_token_t *tok, rspamd_mempool_t *po
else {
if (tok->flags & RSPAMD_STAT_TOKEN_FLAG_TEXT) {
/* Simple lowercase */
- gchar *dest;
+ char *dest;
dest = rspamd_mempool_alloc(pool, tok->original.len + 1);
rspamd_strlcpy(dest, tok->original.begin, tok->original.len + 1);
@@ -861,7 +861,7 @@ void rspamd_normalize_single_word(rspamd_stat_token_t *tok, rspamd_mempool_t *po
void rspamd_normalize_words(GArray *words, rspamd_mempool_t *pool)
{
rspamd_stat_token_t *tok;
- guint i;
+ unsigned int i;
for (i = 0; i < words->len; i++) {
tok = &g_array_index(words, rspamd_stat_token_t, i);
@@ -870,14 +870,14 @@ void rspamd_normalize_words(GArray *words, rspamd_mempool_t *pool)
}
void rspamd_stem_words(GArray *words, rspamd_mempool_t *pool,
- const gchar *language,
+ const char *language,
struct rspamd_lang_detector *lang_detector)
{
static GHashTable *stemmers = NULL;
struct sb_stemmer *stem = NULL;
- guint i;
+ unsigned int i;
rspamd_stat_token_t *tok;
- gchar *dest;
+ char *dest;
gsize dlen;
if (!stemmers) {
@@ -914,7 +914,7 @@ void rspamd_stem_words(GArray *words, rspamd_mempool_t *pool,
if (tok->flags & RSPAMD_STAT_TOKEN_FLAG_UTF) {
if (stem) {
- const gchar *stemmed = NULL;
+ const char *stemmed = NULL;
stemmed = sb_stemmer_stem(stem,
tok->normalized.begin, tok->normalized.len);
diff --git a/src/libstat/tokenizers/tokenizers.h b/src/libstat/tokenizers/tokenizers.h
index ff5c530c5..d4a8824a8 100644
--- a/src/libstat/tokenizers/tokenizers.h
+++ b/src/libstat/tokenizers/tokenizers.h
@@ -36,17 +36,17 @@ struct rspamd_stat_ctx;
/* Common tokenizer structure */
struct rspamd_stat_tokenizer {
- gchar *name;
+ char *name;
gpointer (*get_config)(rspamd_mempool_t *pool,
struct rspamd_tokenizer_config *cf, gsize *len);
- gint (*tokenize_func)(struct rspamd_stat_ctx *ctx,
- struct rspamd_task *task,
- GArray *words,
- gboolean is_utf,
- const gchar *prefix,
- GPtrArray *result);
+ int (*tokenize_func)(struct rspamd_stat_ctx *ctx,
+ struct rspamd_task *task,
+ GArray *words,
+ gboolean is_utf,
+ const char *prefix,
+ GPtrArray *result);
};
enum rspamd_tokenize_type {
@@ -56,11 +56,11 @@ enum rspamd_tokenize_type {
};
/* Compare two token nodes */
-gint token_node_compare_func(gconstpointer a, gconstpointer b);
+int token_node_compare_func(gconstpointer a, gconstpointer b);
/* Tokenize text into array of words (rspamd_stat_token_t type) */
-GArray *rspamd_tokenize_text(const gchar *text, gsize len,
+GArray *rspamd_tokenize_text(const char *text, gsize len,
const UText *utxt,
enum rspamd_tokenize_type how,
struct rspamd_config *cfg,
@@ -70,12 +70,12 @@ GArray *rspamd_tokenize_text(const gchar *text, gsize len,
rspamd_mempool_t *pool);
/* OSB tokenize function */
-gint rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx,
- struct rspamd_task *task,
- GArray *words,
- gboolean is_utf,
- const gchar *prefix,
- GPtrArray *result);
+int rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx,
+ struct rspamd_task *task,
+ GArray *words,
+ gboolean is_utf,
+ const char *prefix,
+ GPtrArray *result);
gpointer rspamd_tokenizer_osb_get_config(rspamd_mempool_t *pool,
struct rspamd_tokenizer_config *cf,
@@ -88,7 +88,7 @@ void rspamd_normalize_single_word(rspamd_stat_token_t *tok, rspamd_mempool_t *po
void rspamd_normalize_words(GArray *words, rspamd_mempool_t *pool);
void rspamd_stem_words(GArray *words, rspamd_mempool_t *pool,
- const gchar *language,
+ const char *language,
struct rspamd_lang_detector *lang_detector);
void rspamd_tokenize_meta_words(struct rspamd_task *task);