aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/fuzzy_backend
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-03-18 14:56:16 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-03-18 14:56:16 +0000
commit6b2b4167187fee09365271cca182866ecb029af3 (patch)
treea085717bc896b25ff4280eb86abecca0d5c36767 /src/libserver/fuzzy_backend
parent47bcfc8360dfa1754474580e779314b8d6a78da6 (diff)
downloadrspamd-6b2b4167187fee09365271cca182866ecb029af3.tar.gz
rspamd-6b2b4167187fee09365271cca182866ecb029af3.zip
[Rework] Remove some of the GLib types in lieu of standard ones
This types have constant conflicts with the system ones especially on OSX.
Diffstat (limited to 'src/libserver/fuzzy_backend')
-rw-r--r--src/libserver/fuzzy_backend/fuzzy_backend.c4
-rw-r--r--src/libserver/fuzzy_backend/fuzzy_backend.h4
-rw-r--r--src/libserver/fuzzy_backend/fuzzy_backend_redis.c4
-rw-r--r--src/libserver/fuzzy_backend/fuzzy_backend_sqlite.c42
-rw-r--r--src/libserver/fuzzy_backend/fuzzy_backend_sqlite.h10
5 files changed, 32 insertions, 32 deletions
diff --git a/src/libserver/fuzzy_backend/fuzzy_backend.c b/src/libserver/fuzzy_backend/fuzzy_backend.c
index 9099f38dd..607a92e85 100644
--- a/src/libserver/fuzzy_backend/fuzzy_backend.c
+++ b/src/libserver/fuzzy_backend/fuzzy_backend.c
@@ -215,7 +215,7 @@ rspamd_fuzzy_backend_count_sqlite(struct rspamd_fuzzy_backend *bk,
void *subr_ud)
{
struct rspamd_fuzzy_backend_sqlite *sq = subr_ud;
- guint64 nhashes;
+ uint64_t nhashes;
nhashes = rspamd_fuzzy_backend_sqlite_count(sq);
@@ -231,7 +231,7 @@ rspamd_fuzzy_backend_version_sqlite(struct rspamd_fuzzy_backend *bk,
void *subr_ud)
{
struct rspamd_fuzzy_backend_sqlite *sq = subr_ud;
- guint64 rev;
+ uint64_t rev;
rev = rspamd_fuzzy_backend_sqlite_version(sq, src);
diff --git a/src/libserver/fuzzy_backend/fuzzy_backend.h b/src/libserver/fuzzy_backend/fuzzy_backend.h
index a1b74bcd0..11b60abb3 100644
--- a/src/libserver/fuzzy_backend/fuzzy_backend.h
+++ b/src/libserver/fuzzy_backend/fuzzy_backend.h
@@ -39,9 +39,9 @@ typedef void (*rspamd_fuzzy_update_cb)(gboolean success,
guint nignored,
void *ud);
-typedef void (*rspamd_fuzzy_version_cb)(guint64 rev, void *ud);
+typedef void (*rspamd_fuzzy_version_cb)(uint64_t rev, void *ud);
-typedef void (*rspamd_fuzzy_count_cb)(guint64 count, void *ud);
+typedef void (*rspamd_fuzzy_count_cb)(uint64_t count, void *ud);
typedef gboolean (*rspamd_fuzzy_periodic_cb)(void *ud);
diff --git a/src/libserver/fuzzy_backend/fuzzy_backend_redis.c b/src/libserver/fuzzy_backend/fuzzy_backend_redis.c
index 7ab7ca63e..e1f24dd1a 100644
--- a/src/libserver/fuzzy_backend/fuzzy_backend_redis.c
+++ b/src/libserver/fuzzy_backend/fuzzy_backend_redis.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2023 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.
@@ -1094,7 +1094,7 @@ rspamd_fuzzy_update_append_command(struct rspamd_fuzzy_backend *bk,
g_string_append(key, session->backend->redis_object);
g_string_append_len(key, cmd->digest, sizeof(cmd->digest));
value = g_string_sized_new(sizeof("18446744073709551616"));
- rspamd_printf_gstring(value, "%L", (gint64) rspamd_get_calendar_ticks());
+ rspamd_printf_gstring(value, "%L", (int64_t) rspamd_get_calendar_ticks());
session->argv[cur_shift] = g_strdup("HSETNX");
session->argv_lens[cur_shift++] = sizeof("HSETNX") - 1;
session->argv[cur_shift] = key->str;
diff --git a/src/libserver/fuzzy_backend/fuzzy_backend_sqlite.c b/src/libserver/fuzzy_backend/fuzzy_backend_sqlite.c
index 9ec448ebc..df91c65b0 100644
--- a/src/libserver/fuzzy_backend/fuzzy_backend_sqlite.c
+++ b/src/libserver/fuzzy_backend/fuzzy_backend_sqlite.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,
@@ -303,7 +303,7 @@ rspamd_fuzzy_backend_sqlite_run_stmt(struct rspamd_fuzzy_backend_sqlite *backend
SQLITE_STATIC);
break;
case 'I':
- sqlite3_bind_int64(stmt, i + 1, va_arg(ap, gint64));
+ sqlite3_bind_int64(stmt, i + 1, va_arg(ap, int64_t));
break;
case 'S':
sqlite3_bind_int(stmt, i + 1, va_arg(ap, gint));
@@ -454,20 +454,20 @@ rspamd_fuzzy_backend_sqlite_open(const gchar *path,
static gint
rspamd_fuzzy_backend_sqlite_int64_cmp(const void *a, const void *b)
{
- gint64 ia = *(gint64 *) a, ib = *(gint64 *) b;
+ int64_t ia = *(int64_t *) a, ib = *(int64_t *) b;
return (ia - ib);
}
struct rspamd_fuzzy_reply
rspamd_fuzzy_backend_sqlite_check(struct rspamd_fuzzy_backend_sqlite *backend,
- const struct rspamd_fuzzy_cmd *cmd, gint64 expire)
+ const struct rspamd_fuzzy_cmd *cmd, int64_t expire)
{
struct rspamd_fuzzy_reply rep;
const struct rspamd_fuzzy_shingle_cmd *shcmd;
int rc;
- gint64 timestamp;
- gint64 shingle_values[RSPAMD_SHINGLE_SIZE], i, sel_id, cur_id,
+ int64_t timestamp;
+ int64_t shingle_values[RSPAMD_SHINGLE_SIZE], i, sel_id, cur_id,
cur_cnt, max_cnt;
memset(&rep, 0, sizeof(rep));
@@ -524,7 +524,7 @@ rspamd_fuzzy_backend_sqlite_check(struct rspamd_fuzzy_backend_sqlite *backend,
rspamd_fuzzy_backend_sqlite_cleanup_stmt(backend,
RSPAMD_FUZZY_BACKEND_CHECK_SHINGLE);
- qsort(shingle_values, RSPAMD_SHINGLE_SIZE, sizeof(gint64),
+ qsort(shingle_values, RSPAMD_SHINGLE_SIZE, sizeof(int64_t),
rspamd_fuzzy_backend_sqlite_int64_cmp);
sel_id = -1;
cur_id = -1;
@@ -630,7 +630,7 @@ rspamd_fuzzy_backend_sqlite_add(struct rspamd_fuzzy_backend_sqlite *backend,
const struct rspamd_fuzzy_cmd *cmd)
{
int rc, i;
- gint64 id, flag;
+ int64_t id, flag;
const struct rspamd_fuzzy_shingle_cmd *shcmd;
if (backend == NULL) {
@@ -652,7 +652,7 @@ rspamd_fuzzy_backend_sqlite_add(struct rspamd_fuzzy_backend_sqlite *backend,
/* We need to increase weight */
rc = rspamd_fuzzy_backend_sqlite_run_stmt(backend, TRUE,
RSPAMD_FUZZY_BACKEND_UPDATE,
- (gint64) cmd->value,
+ (int64_t) cmd->value,
cmd->digest);
if (rc != SQLITE_OK) {
msg_warn_fuzzy_backend("cannot update hash to %d -> "
@@ -667,8 +667,8 @@ rspamd_fuzzy_backend_sqlite_add(struct rspamd_fuzzy_backend_sqlite *backend,
rc = rspamd_fuzzy_backend_sqlite_run_stmt(backend, TRUE,
RSPAMD_FUZZY_BACKEND_UPDATE_FLAG,
- (gint64) cmd->value,
- (gint64) cmd->flag,
+ (int64_t) cmd->value,
+ (int64_t) cmd->flag,
cmd->digest);
if (rc != SQLITE_OK) {
@@ -686,7 +686,7 @@ rspamd_fuzzy_backend_sqlite_add(struct rspamd_fuzzy_backend_sqlite *backend,
RSPAMD_FUZZY_BACKEND_INSERT,
(gint) cmd->flag,
cmd->digest,
- (gint64) cmd->value);
+ (int64_t) cmd->value);
if (rc == SQLITE_OK) {
if (cmd->shingles_count > 0) {
@@ -696,7 +696,7 @@ rspamd_fuzzy_backend_sqlite_add(struct rspamd_fuzzy_backend_sqlite *backend,
for (i = 0; i < RSPAMD_SHINGLE_SIZE; i++) {
rc = rspamd_fuzzy_backend_sqlite_run_stmt(backend, TRUE,
RSPAMD_FUZZY_BACKEND_INSERT_SHINGLE,
- shcmd->sgl.hashes[i], (gint64) i, id);
+ shcmd->sgl.hashes[i], (int64_t) i, id);
msg_debug_fuzzy_backend("add shingle %d -> %L: %L",
i,
shcmd->sgl.hashes[i],
@@ -740,7 +740,7 @@ rspamd_fuzzy_backend_sqlite_finish_update(struct rspamd_fuzzy_backend_sqlite *ba
rc = rspamd_fuzzy_backend_sqlite_run_stmt(backend, TRUE,
RSPAMD_FUZZY_BACKEND_SET_VERSION,
- (gint64) ver, (gint64) time(NULL), source);
+ (int64_t) ver, (int64_t) time(NULL), source);
}
if (rc == SQLITE_OK) {
@@ -815,18 +815,18 @@ rspamd_fuzzy_backend_sqlite_del(struct rspamd_fuzzy_backend_sqlite *backend,
gboolean
rspamd_fuzzy_backend_sqlite_sync(struct rspamd_fuzzy_backend_sqlite *backend,
- gint64 expire,
+ int64_t expire,
gboolean clean_orphaned)
{
struct orphaned_shingle_elt {
- gint64 value;
- gint64 number;
+ int64_t value;
+ int64_t number;
};
/* Do not do more than 5k ops per step */
- const guint64 max_changes = 5000;
+ const uint64_t max_changes = 5000;
gboolean ret = FALSE;
- gint64 expire_lim, expired;
+ int64_t expire_lim, expired;
gint rc, i, orphaned_cnt = 0;
GError *err = NULL;
static const gchar orphaned_shingles[] = "SELECT shingles.value,shingles.number "
diff --git a/src/libserver/fuzzy_backend/fuzzy_backend_sqlite.h b/src/libserver/fuzzy_backend/fuzzy_backend_sqlite.h
index 766f7c9d2..62c028f3d 100644
--- a/src/libserver/fuzzy_backend/fuzzy_backend_sqlite.h
+++ b/src/libserver/fuzzy_backend/fuzzy_backend_sqlite.h
@@ -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,
@@ -44,7 +44,7 @@ struct rspamd_fuzzy_backend_sqlite *rspamd_fuzzy_backend_sqlite_open(const gchar
struct rspamd_fuzzy_reply rspamd_fuzzy_backend_sqlite_check(
struct rspamd_fuzzy_backend_sqlite *backend,
const struct rspamd_fuzzy_cmd *cmd,
- gint64 expire);
+ int64_t expire);
/**
* Prepare storage for updates (by starting transaction)
@@ -83,7 +83,7 @@ gboolean rspamd_fuzzy_backend_sqlite_finish_update(struct rspamd_fuzzy_backend_s
* @return
*/
gboolean rspamd_fuzzy_backend_sqlite_sync(struct rspamd_fuzzy_backend_sqlite *backend,
- gint64 expire,
+ int64_t expire,
gboolean clean_orphaned);
/**