aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_cdb.c8
-rw-r--r--src/lua/lua_common.c18
-rw-r--r--src/lua/lua_common.h4
-rw-r--r--src/lua/lua_config.c34
-rw-r--r--src/lua/lua_cryptobox.c24
-rw-r--r--src/lua/lua_ip.c2
-rw-r--r--src/lua/lua_kann.c8
-rw-r--r--src/lua/lua_map.c2
-rw-r--r--src/lua/lua_mempool.c12
-rw-r--r--src/lua/lua_mimepart.c8
-rw-r--r--src/lua/lua_redis.c16
-rw-r--r--src/lua/lua_regexp.c8
-rw-r--r--src/lua/lua_sqlite3.c10
-rw-r--r--src/lua/lua_task.c4
-rw-r--r--src/lua/lua_tcp.c12
-rw-r--r--src/lua/lua_text.c24
-rw-r--r--src/lua/lua_url.h2
-rw-r--r--src/lua/lua_util.c46
-rw-r--r--src/lua/lua_worker.c16
19 files changed, 129 insertions, 129 deletions
diff --git a/src/lua/lua_cdb.c b/src/lua/lua_cdb.c
index 6831cdabe..780672420 100644
--- a/src/lua/lua_cdb.c
+++ b/src/lua/lua_cdb.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,
@@ -144,7 +144,7 @@ lua_cdb_get_input(lua_State *L, int pos, gsize *olen)
p = rspamd_lua_check_udata_maybe(L, pos, rspamd_int64_classname);
if (p) {
- static char numbuf[sizeof(gint64)];
+ static char numbuf[sizeof(int64_t)];
memcpy(numbuf, p, sizeof(numbuf));
*olen = sizeof(numbuf);
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index cf4ca8023..18aa4cd4c 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -471,7 +471,7 @@ set:
static int
rspamd_lua_rspamd_version_numeric(lua_State *L)
{
- static gint64 version_num = RSPAMD_VERSION_NUM;
+ static int64_t version_num = RSPAMD_VERSION_NUM;
const gchar *type;
if (lua_gettop(L) >= 2 && lua_type(L, 1) == LUA_TSTRING) {
@@ -1428,15 +1428,15 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos,
case 'I':
if (t == LUA_TNUMBER) {
- *(va_arg(ap, gint64 *)) = lua_tointeger(L, idx);
+ *(va_arg(ap, int64_t *)) = lua_tointeger(L, idx);
}
else if (t == LUA_TNIL || t == LUA_TNONE) {
failed = TRUE;
if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
- *(va_arg(ap, gint64 *)) = 0;
+ *(va_arg(ap, int64_t *)) = 0;
}
else {
- (void) va_arg(ap, gint64 *);
+ (void) va_arg(ap, int64_t *);
}
}
else {
@@ -1460,15 +1460,15 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos,
case 'i':
if (t == LUA_TNUMBER) {
- *(va_arg(ap, gint32 *)) = lua_tointeger(L, idx);
+ *(va_arg(ap, int32_t *)) = lua_tointeger(L, idx);
}
else if (t == LUA_TNIL || t == LUA_TNONE) {
failed = TRUE;
if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) {
- *(va_arg(ap, gint32 *)) = 0;
+ *(va_arg(ap, int32_t *)) = 0;
}
else {
- (void) va_arg(ap, gint32 *);
+ (void) va_arg(ap, int32_t *);
}
}
else {
@@ -2575,7 +2575,7 @@ bool rspamd_lua_universal_pcall(lua_State *L, gint cbref, const gchar *strloc,
}
/*
* Possible arguments
- * - i - lua_integer, argument - gint64
+ * - i - lua_integer, argument - int64_t
* - n - lua_number, argument - gdouble
* - s - lua_string, argument - const gchar * (zero terminated)
* - l - lua_lstring, argument - (size_t + const gchar *) pair
@@ -2587,7 +2587,7 @@ bool rspamd_lua_universal_pcall(lua_State *L, gint cbref, const gchar *strloc,
while (*argp) {
switch (*argp) {
case 'i':
- lua_pushinteger(L, va_arg(ap, gint64));
+ lua_pushinteger(L, va_arg(ap, int64_t));
nargs++;
break;
case 'n':
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h
index 31a8c2fac..03465cc90 100644
--- a/src/lua/lua_common.h
+++ b/src/lua/lua_common.h
@@ -464,7 +464,7 @@ enum rspamd_lua_parse_arguments_flags {
* Extract an arguments from lua table according to format string. Supported arguments are:
* [*]key=S|I|N|B|V|U{a-z};[key=...]
* - S - const char *
-* - I - gint64_t
+* - I - int64_t_t
* - i - int32_t
* - N - double
* - B - gboolean
@@ -654,7 +654,7 @@ gchar *rspamd_lua_get_module_name(lua_State *L);
/**
* Call Lua function in a universal way. Arguments string:
-* - i - lua_integer, argument - gint64
+* - i - lua_integer, argument - int64_t
* - n - lua_number, argument - gdouble
* - s - lua_string, argument - const gchar * (zero terminated)
* - l - lua_lstring, argument - (size_t + const gchar *) pair
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index ad8a6d0bf..1a3c1db20 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -942,7 +942,7 @@ static const struct luaL_reg monitoredlib_m[] = {
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}};
-static const guint64 rspamd_lua_callback_magic = 0x32c118af1e3263c7ULL;
+static const uint64_t rspamd_lua_callback_magic = 0x32c118af1e3263c7ULL;
struct rspamd_config *
lua_check_config(lua_State *L, gint pos)
@@ -1171,7 +1171,7 @@ lua_config_get_classifier(lua_State *L)
}
struct lua_callback_data {
- guint64 magic;
+ uint64_t magic;
lua_State *L;
gchar *symbol;
@@ -1513,10 +1513,10 @@ rspamd_process_id_list(const gchar *entries)
sym_elts = g_strsplit_set(entries, ",;", -1);
guint nids = g_strv_length(sym_elts);
- ret = g_array_sized_new(FALSE, FALSE, sizeof(guint32), nids);
+ ret = g_array_sized_new(FALSE, FALSE, sizeof(uint32_t), nids);
for (guint i = 0; i < nids; i++) {
- guint32 v = rspamd_config_name_to_id(sym_elts[i], strlen(sym_elts[i]));
+ uint32_t v = rspamd_config_name_to_id(sym_elts[i], strlen(sym_elts[i]));
g_array_append_val(ret, v);
}
@@ -1613,12 +1613,12 @@ rspamd_register_symbol_fromlua(lua_State *L,
if (allowed_ids) {
rspamd_symcache_set_allowed_settings_ids(cfg->cache, name,
- &g_array_index(allowed_ids, guint32, 0), allowed_ids->len);
+ &g_array_index(allowed_ids, uint32_t, 0), allowed_ids->len);
}
if (forbidden_ids) {
rspamd_symcache_set_forbidden_settings_ids(cfg->cache, name,
- &g_array_index(forbidden_ids, guint32, 0), forbidden_ids->len);
+ &g_array_index(forbidden_ids, uint32_t, 0), forbidden_ids->len);
}
return ret;
@@ -1968,7 +1968,7 @@ lua_config_register_symbol(lua_State *L)
gboolean one_shot = FALSE;
gint ret = -1, cbref = -1;
guint type = 0, flags = 0;
- gint64 parent = 0, priority = 0, nshots = 0;
+ int64_t parent = 0, priority = 0, nshots = 0;
GArray *allowed_ids = NULL, *forbidden_ids = NULL;
GError *err = NULL;
int prev_top = lua_gettop(L);
@@ -2007,10 +2007,10 @@ lua_config_register_symbol(lua_State *L)
allowed_ids = rspamd_process_id_list(lua_tostring(L, -1));
}
else if (lua_type(L, -1) == LUA_TTABLE) {
- allowed_ids = g_array_sized_new(FALSE, FALSE, sizeof(guint32),
+ allowed_ids = g_array_sized_new(FALSE, FALSE, sizeof(uint32_t),
rspamd_lua_table_size(L, -1));
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
- guint32 v = lua_tointeger(L, -1);
+ uint32_t v = lua_tointeger(L, -1);
g_array_append_val(allowed_ids, v);
}
}
@@ -2022,10 +2022,10 @@ lua_config_register_symbol(lua_State *L)
forbidden_ids = rspamd_process_id_list(lua_tostring(L, -1));
}
else if (lua_type(L, -1) == LUA_TTABLE) {
- forbidden_ids = g_array_sized_new(FALSE, FALSE, sizeof(guint32),
+ forbidden_ids = g_array_sized_new(FALSE, FALSE, sizeof(uint32_t),
rspamd_lua_table_size(L, -1));
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
- guint32 v = lua_tointeger(L, -1);
+ uint32_t v = lua_tointeger(L, -1);
g_array_append_val(forbidden_ids, v);
}
}
@@ -2396,7 +2396,7 @@ lua_config_set_metric_symbol(lua_State *L)
GError *err = NULL;
gdouble priority = 0.0;
guint flags = 0;
- gint64 nshots = 0;
+ int64_t nshots = 0;
if (cfg) {
@@ -2754,10 +2754,10 @@ lua_config_newindex(lua_State *L)
allowed_ids = rspamd_process_id_list(lua_tostring(L, -1));
}
else if (lua_type(L, -1) == LUA_TTABLE) {
- allowed_ids = g_array_sized_new(FALSE, FALSE, sizeof(guint32),
+ allowed_ids = g_array_sized_new(FALSE, FALSE, sizeof(uint32_t),
rspamd_lua_table_size(L, -1));
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
- guint32 v = lua_tointeger(L, -1);
+ uint32_t v = lua_tointeger(L, -1);
g_array_append_val(allowed_ids, v);
}
}
@@ -2769,10 +2769,10 @@ lua_config_newindex(lua_State *L)
forbidden_ids = rspamd_process_id_list(lua_tostring(L, -1));
}
else if (lua_type(L, -1) == LUA_TTABLE) {
- forbidden_ids = g_array_sized_new(FALSE, FALSE, sizeof(guint32),
+ forbidden_ids = g_array_sized_new(FALSE, FALSE, sizeof(uint32_t),
rspamd_lua_table_size(L, -1));
for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 1)) {
- guint32 v = lua_tointeger(L, -1);
+ uint32_t v = lua_tointeger(L, -1);
g_array_append_val(forbidden_ids, v);
}
}
@@ -3521,7 +3521,7 @@ lua_config_get_symbols_cksum(lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_config *cfg = lua_check_config(L, 1);
- guint64 res = 0, *pres;
+ uint64_t res = 0, *pres;
if (cfg != NULL) {
res = rspamd_symcache_get_cksum(cfg->cache);
diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c
index 5e81229ac..35f5986f1 100644
--- a/src/lua/lua_cryptobox.c
+++ b/src/lua/lua_cryptobox.c
@@ -1124,35 +1124,35 @@ rspamd_lua_hash_create(const gchar *type, const gchar *key, gsize keylen)
h->content.fh = rspamd_cryptobox_fast_hash_new();
rspamd_cryptobox_fast_hash_init_specific(h->content.fh,
RSPAMD_CRYPTOBOX_XXHASH64, 0);
- h->out_len = sizeof(guint64);
+ h->out_len = sizeof(uint64_t);
}
else if (g_ascii_strcasecmp(type, "xxh32") == 0) {
h->type = LUA_CRYPTOBOX_HASH_XXHASH32;
h->content.fh = rspamd_cryptobox_fast_hash_new();
rspamd_cryptobox_fast_hash_init_specific(h->content.fh,
RSPAMD_CRYPTOBOX_XXHASH32, 0);
- h->out_len = sizeof(guint32);
+ h->out_len = sizeof(uint32_t);
}
else if (g_ascii_strcasecmp(type, "xxh3") == 0) {
h->type = LUA_CRYPTOBOX_HASH_XXHASH3;
h->content.fh = rspamd_cryptobox_fast_hash_new();
rspamd_cryptobox_fast_hash_init_specific(h->content.fh,
RSPAMD_CRYPTOBOX_XXHASH3, 0);
- h->out_len = sizeof(guint64);
+ h->out_len = sizeof(uint64_t);
}
else if (g_ascii_strcasecmp(type, "mum") == 0) {
h->type = LUA_CRYPTOBOX_HASH_MUM;
h->content.fh = rspamd_cryptobox_fast_hash_new();
rspamd_cryptobox_fast_hash_init_specific(h->content.fh,
RSPAMD_CRYPTOBOX_MUMHASH, 0);
- h->out_len = sizeof(guint64);
+ h->out_len = sizeof(uint64_t);
}
else if (g_ascii_strcasecmp(type, "t1ha") == 0) {
h->type = LUA_CRYPTOBOX_HASH_T1HA;
h->content.fh = rspamd_cryptobox_fast_hash_new();
rspamd_cryptobox_fast_hash_init_specific(h->content.fh,
RSPAMD_CRYPTOBOX_T1HA, 0);
- h->out_len = sizeof(guint64);
+ h->out_len = sizeof(uint64_t);
}
else if (g_ascii_strcasecmp(type, "blake2") == 0) {
rspamd_lua_hash_init_default(h, key, keylen);
@@ -1500,7 +1500,7 @@ lua_cryptobox_hash_reset(lua_State *L)
static void
lua_cryptobox_hash_finish(struct rspamd_lua_cryptobox_hash *h)
{
- guint64 ll;
+ uint64_t ll;
guchar out[rspamd_cryptobox_HASHBYTES];
guint ssl_outlen = sizeof(out);
@@ -2288,7 +2288,7 @@ lua_cryptobox_encrypt_cookie(lua_State *L)
guchar nonce[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE];
guchar aes_key[RSPAMD_CRYPTOBOX_AES_KEYSIZE];
guchar result[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE * 2];
- guint32 ts;
+ uint32_t ts;
const gchar *sk, *cookie;
gsize sklen, cookie_len;
@@ -2315,10 +2315,10 @@ lua_cryptobox_encrypt_cookie(lua_State *L)
}
/* Fill nonce */
- ottery_rand_bytes(nonce, sizeof(guint64) + sizeof(guint32));
- ts = (guint32) rspamd_get_calendar_ticks();
+ ottery_rand_bytes(nonce, sizeof(uint64_t) + sizeof(uint32_t));
+ ts = (uint32_t) rspamd_get_calendar_ticks();
ts = GUINT32_TO_LE(ts);
- memcpy(nonce + sizeof(guint64) + sizeof(guint32), &ts, sizeof(ts));
+ memcpy(nonce + sizeof(uint64_t) + sizeof(uint32_t), &ts, sizeof(ts));
/* Prepare padded cookie */
memset(padded_cookie, 0, sizeof(padded_cookie));
@@ -2379,7 +2379,7 @@ lua_cryptobox_decrypt_cookie(lua_State *L)
guchar nonce[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE];
guchar aes_key[RSPAMD_CRYPTOBOX_AES_KEYSIZE];
guchar *src;
- guint32 ts;
+ uint32_t ts;
const gchar *sk, *cookie;
gsize sklen, cookie_len;
@@ -2420,7 +2420,7 @@ lua_cryptobox_decrypt_cookie(lua_State *L)
EVP_CIPHER_CTX_set_padding(ctx, 0);
/* Copy time */
- memcpy(&ts, src + sizeof(guint64) + sizeof(guint32), sizeof(ts));
+ memcpy(&ts, src + sizeof(uint64_t) + sizeof(uint32_t), sizeof(ts));
ts = GUINT32_FROM_LE(ts);
bklen = sizeof(nonce);
blk = nonce;
diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c
index 6c0dcb069..5b547b3b6 100644
--- a/src/lua/lua_ip.c
+++ b/src/lua/lua_ip.c
@@ -402,7 +402,7 @@ lua_ip_to_number(lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_lua_ip *ip = lua_check_ip(L, 1);
- guint32 c;
+ uint32_t c;
guint max, i;
guchar *ptr;
diff --git a/src/lua/lua_kann.c b/src/lua/lua_kann.c
index 9e033b40e..09228387a 100644
--- a/src/lua/lua_kann.c
+++ b/src/lua/lua_kann.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.
@@ -1052,9 +1052,9 @@ lua_kann_train1(lua_State *L)
/* Default train params */
double lr = 0.001;
- gint64 mini_size = 64;
- gint64 max_epoch = 25;
- gint64 max_drop_streak = 10;
+ int64_t mini_size = 64;
+ int64_t max_epoch = 25;
+ int64_t max_drop_streak = 10;
double frac_val = 0.1;
gint cbref = -1;
diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c
index cf4275038..b68665b3c 100644
--- a/src/lua/lua_map.c
+++ b/src/lua/lua_map.c
@@ -878,7 +878,7 @@ lua_map_get_key(lua_State *L)
const gchar *key, *value = NULL;
gpointer ud;
gsize len;
- guint32 key_num = 0;
+ uint32_t key_num = 0;
gboolean ret = FALSE;
if (map) {
diff --git a/src/lua/lua_mempool.c b/src/lua/lua_mempool.c
index bb855710f..f272b5173 100644
--- a/src/lua/lua_mempool.c
+++ b/src/lua/lua_mempool.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,
@@ -452,10 +452,10 @@ lua_mempool_get_variable(lua_State *L)
}
else if (len == sizeof("int64") - 1 &&
g_ascii_strncasecmp(pt, "int64", len) == 0) {
- gint64 num;
- memcpy(&num, pv, sizeof(gint64));
+ int64_t num;
+ memcpy(&num, pv, sizeof(int64_t));
lua_pushinteger(L, num);
- pv += sizeof(gint64);
+ pv += sizeof(int64_t);
}
else if (len == sizeof("bool") - 1 &&
g_ascii_strncasecmp(pt, "bool", len) == 0) {
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index 6c38a1275..41609848a 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -1183,7 +1183,7 @@ lua_textpart_get_languages(lua_State *L)
}
struct lua_shingle_data {
- guint64 hash;
+ uint64_t hash;
rspamd_ftok_t t1;
rspamd_ftok_t t2;
rspamd_ftok_t t3;
@@ -1203,11 +1203,11 @@ struct lua_shingle_filter_cbdata {
} \
} while (0)
-static guint64
-lua_shingles_filter(guint64 *input, gsize count,
+static uint64_t
+lua_shingles_filter(uint64_t *input, gsize count,
gint shno, const guchar *key, gpointer ud)
{
- guint64 minimal = G_MAXUINT64;
+ uint64_t minimal = G_MAXUINT64;
gsize i, min_idx = 0;
struct lua_shingle_data *sd;
rspamd_stat_token_t *word;
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index 761aa5f94..a6a23ce05 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.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,
@@ -110,9 +110,9 @@ struct lua_redis_userdata {
};
#define msg_debug_lua_redis(...) rspamd_conditional_debug_fast(NULL, NULL, \
- rspamd_lua_redis_log_id, "lua_redis", ud->log_tag, \
- G_STRFUNC, \
- __VA_ARGS__)
+ rspamd_lua_redis_log_id, "lua_redis", ud->log_tag, \
+ G_STRFUNC, \
+ __VA_ARGS__)
INIT_LOG_MODULE(lua_redis)
#define LUA_REDIS_SPECIFIC_REPLIED (1 << 0)
@@ -830,9 +830,9 @@ lua_redis_parse_args(lua_State *L, gint idx, const gchar *cmd,
gint r;
gchar numbuf[64];
- if (val == (gdouble) ((gint64) val)) {
+ if (val == (gdouble) ((int64_t) val)) {
r = rspamd_snprintf(numbuf, sizeof(numbuf), "%L",
- (gint64) val);
+ (int64_t) val);
}
else {
r = rspamd_snprintf(numbuf, sizeof(numbuf), "%f",
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c
index 3623b7dd2..889e0aad8 100644
--- a/src/lua/lua_regexp.c
+++ b/src/lua/lua_regexp.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,
@@ -393,7 +393,7 @@ lua_regexp_set_limit(lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_lua_regexp *re = lua_check_regexp(L, 1);
- gint64 lim;
+ int64_t lim;
lim = lua_tointeger(L, 2);
diff --git a/src/lua/lua_sqlite3.c b/src/lua/lua_sqlite3.c
index dde39bd2e..6926f8081 100644
--- a/src/lua/lua_sqlite3.c
+++ b/src/lua/lua_sqlite3.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,
@@ -133,7 +133,7 @@ lua_sqlite3_bind_statements(lua_State *L, gint start, gint end,
case LUA_TNUMBER:
n = lua_tonumber(L, i);
- if (n == (gdouble) ((gint64) n)) {
+ if (n == (gdouble) ((int64_t) n)) {
sqlite3_bind_int64(stmt, num, n);
}
else {
@@ -214,7 +214,7 @@ lua_sqlite3_push_row(lua_State *L, sqlite3_stmt *stmt)
{
const gchar *str;
gsize slen;
- gint64 num;
+ int64_t num;
gchar numbuf[32];
gint nresults, i, type;
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index cada9f952..bb2f71faf 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -3356,7 +3356,7 @@ lua_task_str_to_get_type(lua_State *L, struct rspamd_task *task, gint pos, gint
{
const gchar *type = NULL;
gint ret = LUA_ADDRESS_ANY;
- guint64 h;
+ uint64_t h;
gsize sz;
/* Get what value */
@@ -5982,7 +5982,7 @@ lua_task_set_settings_id(lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_task *task = lua_check_task(L, 1);
- guint32 id = lua_tointeger(L, 2);
+ uint32_t id = lua_tointeger(L, 2);
if (task != NULL && id != 0) {
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c
index 7040e9f43..e0595c5c4 100644
--- a/src/lua/lua_tcp.c
+++ b/src/lua/lua_tcp.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,
@@ -1539,7 +1539,7 @@ lua_tcp_request(lua_State *L)
struct iovec *iov = NULL;
struct upstream *up = NULL;
guint niov = 0, total_out;
- guint64 h;
+ uint64_t h;
gdouble timeout = default_tcp_timeout;
gboolean partial = FALSE, do_shutdown = FALSE, do_read = TRUE,
ssl = FALSE, ssl_noverify = FALSE;
@@ -1973,11 +1973,11 @@ lua_tcp_connect_sync(lua_State *L)
LUA_TRACE_POINT;
GError *err = NULL;
- gint64 port = -1;
+ int64_t port = -1;
gdouble timeout = default_tcp_timeout;
const gchar *host = NULL;
gint ret;
- guint64 h;
+ uint64_t h;
struct rspamd_task *task = NULL;
struct rspamd_async_session *session = NULL;
diff --git a/src/lua/lua_text.c b/src/lua/lua_text.c
index d05eee268..92dfadce6 100644
--- a/src/lua/lua_text.c
+++ b/src/lua/lua_text.c
@@ -1,11 +1,11 @@
-/*-
- * Copyright 2019 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,
@@ -667,7 +667,7 @@ lua_text_span(lua_State *L)
{
LUA_TRACE_POINT;
struct rspamd_lua_text *t = lua_check_text(L, 1);
- gint64 start = lua_tointeger(L, 2), len = -1;
+ int64_t start = lua_tointeger(L, 2), len = -1;
if (t && start >= 1 && start <= t->len) {
if (lua_isnumber(L, 3)) {
@@ -760,16 +760,16 @@ lua_text_sub(lua_State *L)
return 1;
}
-static gint64
+static int64_t
rspamd_lua_text_push_line(lua_State *L,
struct rspamd_lua_text *t,
- gint64 start_offset,
+ int64_t start_offset,
const gchar *sep_pos,
gboolean stringify)
{
const gchar *start;
gsize len;
- gint64 ret;
+ int64_t ret;
start = t->start + start_offset;
len = sep_pos ? (sep_pos - start) : (t->len - start_offset);
@@ -806,7 +806,7 @@ rspamd_lua_text_readline(lua_State *L)
{
struct rspamd_lua_text *t = lua_touserdata(L, lua_upvalueindex(1));
gboolean stringify = lua_toboolean(L, lua_upvalueindex(2));
- gint64 pos = lua_tointeger(L, lua_upvalueindex(3));
+ int64_t pos = lua_tointeger(L, lua_upvalueindex(3));
if (pos < 0) {
return luaL_error(L, "invalid pos: %d", (gint) pos);
@@ -878,7 +878,7 @@ rspamd_lua_text_regexp_split(lua_State *L)
struct rspamd_lua_regexp *re = *(struct rspamd_lua_regexp **)
lua_touserdata(L, lua_upvalueindex(2));
gboolean stringify = lua_toboolean(L, lua_upvalueindex(3));
- gint64 pos = lua_tointeger(L, lua_upvalueindex(4));
+ int64_t pos = lua_tointeger(L, lua_upvalueindex(4));
gboolean matched;
if (pos < 0) {
@@ -1447,7 +1447,7 @@ lua_text_find(lua_State *L)
}
#define BITOP(a, b, op) \
- ((a)[(guint64) (b) / (8u * sizeof *(a))] op(guint64) 1 << ((guint64) (b) % (8u * sizeof *(a))))
+ ((a)[(uint64_t) (b) / (8u * sizeof *(a))] op(uint64_t) 1 << ((uint64_t) (b) % (8u * sizeof *(a))))
static gint
lua_text_exclude_chars(lua_State *L)
@@ -1457,7 +1457,7 @@ lua_text_exclude_chars(lua_State *L)
gssize patlen;
const gchar *pat = lua_tolstring(L, 2, &patlen), *p, *end;
gchar *dest, *d;
- guint64 byteset[32 / sizeof(guint64)]; /* Bitset for ascii */
+ uint64_t byteset[32 / sizeof(uint64_t)]; /* Bitset for ascii */
gboolean copy = TRUE;
guint *plen;
@@ -1569,7 +1569,7 @@ lua_text_oneline(lua_State *L)
struct rspamd_lua_text *t = lua_check_text(L, 1);
const gchar *p, *end;
gchar *dest, *d;
- guint64 byteset[32 / sizeof(guint64)]; /* Bitset for ascii */
+ uint64_t byteset[32 / sizeof(uint64_t)]; /* Bitset for ascii */
gboolean copy = TRUE, seen_8bit = FALSE;
guint *plen;
diff --git a/src/lua/lua_url.h b/src/lua/lua_url.h
index a78dffac6..930b4f553 100644
--- a/src/lua/lua_url.h
+++ b/src/lua/lua_url.h
@@ -37,7 +37,7 @@ struct lua_tree_cb_data {
gboolean sort;
gsize max_urls;
gdouble skip_prob;
- guint64 random_seed;
+ uint64_t random_seed;
};
void lua_tree_url_callback(gpointer key, gpointer value, gpointer ud);
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 612017d51..11e45b723 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -760,12 +760,12 @@ static const struct luaL_reg ev_baselib_m[] = {
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}};
-static gint64
+static int64_t
lua_check_int64(lua_State *L, gint pos)
{
void *ud = rspamd_lua_check_udata(L, pos, rspamd_int64_classname);
luaL_argcheck(L, ud != NULL, pos, "'int64' expected");
- return ud ? *((gint64 *) ud) : 0LL;
+ return ud ? *((int64_t *) ud) : 0LL;
}
@@ -1419,7 +1419,7 @@ static gint
lua_util_is_uppercase(lua_State *L)
{
LUA_TRACE_POINT;
- gint32 i = 0;
+ int32_t i = 0;
UChar32 uc;
guint nlc = 0, nuc = 0;
@@ -1455,7 +1455,7 @@ static gint
lua_util_humanize_number(lua_State *L)
{
LUA_TRACE_POINT;
- gint64 number = luaL_checkinteger(L, 1);
+ int64_t number = luaL_checkinteger(L, 1);
gchar numbuf[32];
@@ -1543,7 +1543,7 @@ lua_util_strlen_utf8(lua_State *L)
t = lua_check_text_or_string(L, 1);
if (t) {
- gint32 i = 0, nchars = 0;
+ int32_t i = 0, nchars = 0;
UChar32 uc;
while (i < t->len) {
@@ -1569,7 +1569,7 @@ lua_util_lower_utf8(lua_State *L)
gchar *dst;
UChar32 uc;
UBool err = 0;
- gint32 i = 0, j = 0;
+ int32_t i = 0, j = 0;
t = lua_check_text_or_string(L, 1);
@@ -2057,9 +2057,9 @@ static gint
lua_util_caseless_hash(lua_State *L)
{
LUA_TRACE_POINT;
- guint64 seed = 0xdeadbabe, h;
+ uint64_t seed = 0xdeadbabe, h;
struct rspamd_lua_text *t = NULL;
- gint64 *r;
+ int64_t *r;
t = lua_check_text_or_string(L, 1);
@@ -2086,10 +2086,10 @@ static gint
lua_util_caseless_hash_fast(lua_State *L)
{
LUA_TRACE_POINT;
- guint64 seed = 0xdeadbabe, h;
+ uint64_t seed = 0xdeadbabe, h;
struct rspamd_lua_text *t = NULL;
union {
- guint64 i;
+ uint64_t i;
double d;
} u;
@@ -2293,8 +2293,8 @@ lua_util_is_utf_outside_range(lua_State *L)
LUA_TRACE_POINT;
gint ret;
struct rspamd_lua_text *t = lua_check_text_or_string(L, 1);
- guint32 range_start = lua_tointeger(L, 2);
- guint32 range_end = lua_tointeger(L, 3);
+ uint32_t range_start = lua_tointeger(L, 2);
+ uint32_t range_end = lua_tointeger(L, 3);
static rspamd_lru_hash_t *validators;
@@ -2303,7 +2303,7 @@ lua_util_is_utf_outside_range(lua_State *L)
}
if (t) {
- guint64 hash_key = (guint64) range_end << 32 || range_start;
+ uint64_t hash_key = (uint64_t) range_end << 32 || range_start;
USpoofChecker *validator = rspamd_lru_hash_lookup(validators, &hash_key, 0);
@@ -2311,7 +2311,7 @@ lua_util_is_utf_outside_range(lua_State *L)
if (validator == NULL) {
USet *allowed_chars;
- guint64 *creation_hash_key = g_malloc(sizeof(guint64));
+ uint64_t *creation_hash_key = g_malloc(sizeof(uint64_t));
*creation_hash_key = hash_key;
validator = uspoof_open(&uc_err);
@@ -2344,7 +2344,7 @@ lua_util_is_utf_outside_range(lua_State *L)
0, 0);
}
- gint32 pos = 0;
+ int32_t pos = 0;
ret = uspoof_checkUTF8(validator, t->start, t->len, &pos,
&uc_err);
}
@@ -2439,7 +2439,7 @@ static gint
lua_util_has_obscured_unicode(lua_State *L)
{
LUA_TRACE_POINT;
- gint32 i = 0, prev_i;
+ int32_t i = 0, prev_i;
UChar32 uc;
struct rspamd_lua_text *t = lua_check_text_or_string(L, 1);
@@ -3411,7 +3411,7 @@ lua_util_unpack(lua_State *L)
static int
lua_util_btc_polymod(lua_State *L)
{
- guint64 c = 1;
+ uint64_t c = 1;
if (lua_type(L, 1) != LUA_TTABLE) {
return luaL_error(L, "invalid arguments");
@@ -3419,7 +3419,7 @@ lua_util_btc_polymod(lua_State *L)
for (lua_pushnil(L); lua_next(L, 1); lua_pop(L, 1)) {
guint8 c0 = c >> 35;
- guint64 d = lua_tointeger(L, -1);
+ uint64_t d = lua_tointeger(L, -1);
c = ((c & 0x07ffffffff) << 5) ^ d;
@@ -3479,7 +3479,7 @@ void luaopen_util(lua_State *L)
static int
lua_int64_tostring(lua_State *L)
{
- gint64 n = lua_check_int64(L, 1);
+ int64_t n = lua_check_int64(L, 1);
gchar buf[32];
bool is_signed = false;
@@ -3504,7 +3504,7 @@ lua_int64_fromstring(lua_State *L)
struct rspamd_lua_text *t = lua_check_text_or_string(L, 1);
if (t && t->len > 0) {
- guint64 u64;
+ uint64_t u64;
const char *p = t->start;
gsize len = t->len;
bool neg = false;
@@ -3529,7 +3529,7 @@ lua_int64_fromstring(lua_State *L)
return 2;
}
- gint64 *i64_p = lua_newuserdata(L, sizeof(gint64));
+ int64_t *i64_p = lua_newuserdata(L, sizeof(int64_t));
rspamd_lua_setclass(L, rspamd_int64_classname, -1);
memcpy(i64_p, &u64, sizeof(u64));
@@ -3546,7 +3546,7 @@ lua_int64_fromstring(lua_State *L)
static int
lua_int64_tonumber(lua_State *L)
{
- gint64 n = lua_check_int64(L, 1);
+ int64_t n = lua_check_int64(L, 1);
gdouble d;
d = n;
@@ -3558,7 +3558,7 @@ lua_int64_tonumber(lua_State *L)
static int
lua_int64_hex(lua_State *L)
{
- gint64 n = lua_check_int64(L, 1);
+ int64_t n = lua_check_int64(L, 1);
gchar buf[32];
rspamd_snprintf(buf, sizeof(buf), "%XL", n);
diff --git a/src/lua/lua_worker.c b/src/lua/lua_worker.c
index 9bf2a2469..2b9856b08 100644
--- a/src/lua/lua_worker.c
+++ b/src/lua/lua_worker.c
@@ -78,7 +78,7 @@ lua_worker_get_stat(lua_State *L)
struct rspamd_stat *stat, stat_copy;
ucl_object_t *top, *sub;
gint i;
- guint64 spam = 0, ham = 0;
+ uint64_t spam = 0, ham = 0;
memset(&mem_st, 0, sizeof(mem_st));
rspamd_mempool_stat(&mem_st);
@@ -481,7 +481,7 @@ struct rspamd_lua_process_cbdata {
gboolean is_error;
pid_t cpid;
lua_State *L;
- guint64 sz;
+ uint64_t sz;
GString *io_buf;
GString *out_buf;
goffset out_pos;
@@ -495,7 +495,7 @@ rspamd_lua_execute_lua_subprocess(lua_State *L,
struct rspamd_lua_process_cbdata *cbdata)
{
gint err_idx, r;
- guint64 wlen = 0;
+ uint64_t wlen = 0;
lua_pushcfunction(L, &rspamd_lua_traceback);
err_idx = lua_gettop(L);
@@ -639,12 +639,12 @@ rspamd_lua_subprocess_io(EV_P_ ev_io *w, int revents)
(struct rspamd_lua_process_cbdata *) w->data;
gssize r;
- if (cbdata->sz == (guint64) -1) {
- guint64 sz;
+ if (cbdata->sz == (uint64_t) -1) {
+ uint64_t sz;
/* We read size of reply + flags first */
r = read(cbdata->sp[0], cbdata->io_buf->str + cbdata->io_buf->len,
- sizeof(guint64) - cbdata->io_buf->len);
+ sizeof(uint64_t) - cbdata->io_buf->len);
if (r == 0) {
ev_io_stop(cbdata->event_loop, &cbdata->ev);
@@ -672,7 +672,7 @@ rspamd_lua_subprocess_io(EV_P_ ev_io *w, int revents)
cbdata->io_buf->len += r;
- if (cbdata->io_buf->len == sizeof(guint64)) {
+ if (cbdata->io_buf->len == sizeof(uint64_t)) {
memcpy((guchar *) &sz, cbdata->io_buf->str, sizeof(sz));
if (sz & (1ULL << 63)) {
@@ -790,7 +790,7 @@ lua_worker_spawn_process(lua_State *L)
cbdata->wrk = w;
cbdata->L = L;
cbdata->event_loop = actx->event_loop;
- cbdata->sz = (guint64) -1;
+ cbdata->sz = (uint64_t) -1;
pid = fork();