diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-03-18 18:56:33 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-03-18 18:56:33 +0000 |
commit | 14c13854d3cae9d93c3d148be30fb72f1eaffe55 (patch) | |
tree | 7b1a3e41b75490fac4d45722c90a1847543c6796 /src/lua | |
parent | 6b2b4167187fee09365271cca182866ecb029af3 (diff) | |
download | rspamd-14c13854d3cae9d93c3d148be30fb72f1eaffe55.tar.gz rspamd-14c13854d3cae9d93c3d148be30fb72f1eaffe55.zip |
[Rework] Further types conversion (no functional changes)
Diffstat (limited to 'src/lua')
42 files changed, 2093 insertions, 2093 deletions
diff --git a/src/lua/lua_cdb.c b/src/lua/lua_cdb.c index 780672420..66f811cc0 100644 --- a/src/lua/lua_cdb.c +++ b/src/lua/lua_cdb.c @@ -158,12 +158,12 @@ lua_cdb_get_input(lua_State *L, int pos, gsize *olen) return NULL; } -static gint +static int lua_cdb_create(lua_State *L) { struct cdb *cdb, **pcdb; - const gchar *filename; - gint fd; + const char *filename; + int fd; struct ev_loop *ev_base = NULL; @@ -218,7 +218,7 @@ lua_cdb_create(lua_State *L) return 1; } -static gint +static int lua_cdb_get_name(lua_State *L) { struct cdb *cdb = lua_check_cdb(L, 1); @@ -231,12 +231,12 @@ lua_cdb_get_name(lua_State *L) return 1; } -static gint +static int lua_cdb_lookup(lua_State *L) { struct cdb *cdb = lua_check_cdb(L, 1); gsize klen; - const gchar *what = lua_cdb_get_input(L, 2, &klen); + const char *what = lua_cdb_get_input(L, 2, &klen); if (!cdb || what == NULL) { return lua_error(L); @@ -253,7 +253,7 @@ lua_cdb_lookup(lua_State *L) return 1; } -static gint +static int lua_cdb_destroy(lua_State *L) { struct cdb *cdb = lua_check_cdb(L, 1); @@ -270,7 +270,7 @@ lua_cdb_destroy(lua_State *L) return 0; } -static gint +static int lua_cdb_build(lua_State *L) { const char *filename = luaL_checkstring(L, 1); @@ -306,7 +306,7 @@ lua_cdb_build(lua_State *L) return 1; } -static gint +static int lua_cdb_builder_add(lua_State *L) { struct cdb_make *cdbm = lua_check_cdb_builder(L, 1); @@ -330,7 +330,7 @@ lua_cdb_builder_add(lua_State *L) return 1; } -static gint +static int lua_cdb_builder_finalize(lua_State *L) { struct cdb_make *cdbm = lua_check_cdb_builder(L, 1); @@ -354,7 +354,7 @@ lua_cdb_builder_finalize(lua_State *L) return 1; } -static gint +static int lua_cdb_builder_dtor(lua_State *L) { struct cdb_make *cdbm = lua_check_cdb_builder(L, 1); @@ -372,7 +372,7 @@ lua_cdb_builder_dtor(lua_State *L) return 0; } -static gint +static int lua_load_cdb(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c index 75bc3806d..b92e8ba45 100644 --- a/src/lua/lua_cfg_file.c +++ b/src/lua/lua_cfg_file.c @@ -23,11 +23,11 @@ /* Process a single item in 'metrics' table */ static void -lua_process_metric(lua_State *L, const gchar *name, struct rspamd_config *cfg) +lua_process_metric(lua_State *L, const char *name, struct rspamd_config *cfg) { - gchar *symbol; - const gchar *desc = NULL; - gdouble *score; + char *symbol; + const char *desc = NULL; + double *score; struct rspamd_symbol *s; /* Now iterate through module table */ @@ -91,7 +91,7 @@ lua_process_metric(lua_State *L, const gchar *name, struct rspamd_config *cfg) void rspamd_lua_post_load_config(struct rspamd_config *cfg) { lua_State *L = cfg->lua_state; - const gchar *name; + const char *name; ucl_object_t *obj; gsize keylen, i; @@ -104,7 +104,7 @@ void rspamd_lua_post_load_config(struct rspamd_config *cfg) g_free); for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { - gchar *tmp; + char *tmp; lua_pushvalue(L, -2); name = luaL_checklstring(L, -1, &keylen); diff --git a/src/lua/lua_classifier.c b/src/lua/lua_classifier.c index eb50f1950..0e64ca5ab 100644 --- a/src/lua/lua_classifier.c +++ b/src/lua/lua_classifier.c @@ -54,13 +54,13 @@ lua_check_classifier(lua_State *L) } /* Return table of statfiles indexed by name */ -static gint +static int lua_classifier_get_statfiles(lua_State *L) { struct rspamd_classifier_config *ccf = lua_check_classifier(L); GList *cur; struct rspamd_statfile_config *st, **pst; - gint i; + int i; if (ccf) { lua_newtable(L); @@ -83,11 +83,11 @@ lua_classifier_get_statfiles(lua_State *L) return 1; } -static gint +static int lua_classifier_get_param(lua_State *L) { struct rspamd_classifier_config *ccf = lua_check_classifier(L); - const gchar *param; + const char *param; const ucl_object_t *value; param = luaL_checkstring(L, 2); @@ -107,14 +107,14 @@ lua_classifier_get_param(lua_State *L) } /* Get statfile with specified label */ -static gint +static int lua_classifier_get_statfile_by_label(lua_State *L) { struct rspamd_classifier_config *ccf = lua_check_classifier(L); struct rspamd_statfile_config *st, **pst; - const gchar *label; + const char *label; GList *cur; - gint i; + int i; label = luaL_checkstring(L, 2); if (ccf && label) { @@ -140,7 +140,7 @@ lua_classifier_get_statfile_by_label(lua_State *L) } /* Statfile functions */ -static gint +static int lua_statfile_get_symbol(lua_State *L) { struct rspamd_statfile_config *st = lua_check_statfile(L); @@ -155,7 +155,7 @@ lua_statfile_get_symbol(lua_State *L) return 1; } -static gint +static int lua_statfile_get_label(lua_State *L) { struct rspamd_statfile_config *st = lua_check_statfile(L); @@ -170,7 +170,7 @@ lua_statfile_get_label(lua_State *L) return 1; } -static gint +static int lua_statfile_is_spam(lua_State *L) { struct rspamd_statfile_config *st = lua_check_statfile(L); @@ -185,11 +185,11 @@ lua_statfile_is_spam(lua_State *L) return 1; } -static gint +static int lua_statfile_get_param(lua_State *L) { struct rspamd_statfile_config *st = lua_check_statfile(L); - const gchar *param; + const char *param; const ucl_object_t *value; param = luaL_checkstring(L, 2); diff --git a/src/lua/lua_classnames.c b/src/lua/lua_classnames.c index 7041a8ca1..7ce2f8abc 100644 --- a/src/lua/lua_classnames.c +++ b/src/lua/lua_classnames.c @@ -139,7 +139,7 @@ RSPAMD_CONSTRUCTOR(rspamd_lua_init_classnames) } const char * -rspamd_lua_static_classname(const char *name, guint len) +rspamd_lua_static_classname(const char *name, unsigned int len) { khiter_t k; diff --git a/src/lua/lua_classnames.h b/src/lua/lua_classnames.h index 2563249b5..53db5f8c2 100644 --- a/src/lua/lua_classnames.h +++ b/src/lua/lua_classnames.h @@ -77,6 +77,6 @@ extern const char *rspamd_zstd_decompress_classname; /* * Return a static class name for a given name (only for known classes) or NULL */ -const char *rspamd_lua_static_classname(const char *name, guint len); +const char *rspamd_lua_static_classname(const char *name, unsigned int len); #endif//RSPAMD_LUA_CLASSNAMES_H diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 18aa4cd4c..d79efc308 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -80,11 +80,11 @@ rspamd_lua_ctx_by_state(lua_State *L) * @param func table of class methods */ void rspamd_lua_new_class(lua_State *L, - const gchar *classname, + const char *classname, const struct luaL_reg *methods) { khiter_t k; - gint r, nmethods = 0; + int r, nmethods = 0; gboolean seen_index = false; struct rspamd_lua_context *ctx = rspamd_lua_ctx_by_state(L); @@ -128,12 +128,12 @@ void rspamd_lua_new_class(lua_State *L, /* MT is left on stack ! */ } -static const gchar * -rspamd_lua_class_tostring_buf(lua_State *L, gboolean print_pointer, gint pos) +static const char * +rspamd_lua_class_tostring_buf(lua_State *L, gboolean print_pointer, int pos) { - static gchar buf[64]; - const gchar *ret = NULL; - gint pop = 0; + static char buf[64]; + const char *ret = NULL; + int pop = 0; if (!lua_getmetatable(L, pos)) { goto err; @@ -164,9 +164,9 @@ err: return ret; } -gint rspamd_lua_class_tostring(lua_State *L) +int rspamd_lua_class_tostring(lua_State *L) { - const gchar *p; + const char *p; p = rspamd_lua_class_tostring_buf(L, TRUE, 1); @@ -181,7 +181,7 @@ gint rspamd_lua_class_tostring(lua_State *L) } -void rspamd_lua_setclass(lua_State *L, const gchar *classname, gint objidx) +void rspamd_lua_setclass(lua_State *L, const char *classname, int objidx) { khiter_t k; struct rspamd_lua_context *ctx = rspamd_lua_ctx_by_state(L); @@ -197,7 +197,7 @@ void rspamd_lua_setclass(lua_State *L, const gchar *classname, gint objidx) lua_setmetatable(L, objidx); } -void rspamd_lua_class_metatable(lua_State *L, const gchar *classname) +void rspamd_lua_class_metatable(lua_State *L, const char *classname) { khiter_t k; struct rspamd_lua_context *ctx = rspamd_lua_ctx_by_state(L); @@ -208,7 +208,7 @@ void rspamd_lua_class_metatable(lua_State *L, const gchar *classname) lua_rawgeti(L, LUA_REGISTRYINDEX, kh_value(ctx->classes, k)); } -void rspamd_lua_add_metamethod(lua_State *L, const gchar *classname, +void rspamd_lua_add_metamethod(lua_State *L, const char *classname, luaL_Reg *meth) { khiter_t k; @@ -225,7 +225,7 @@ void rspamd_lua_add_metamethod(lua_State *L, const gchar *classname, } /* assume that table is at the top */ -void rspamd_lua_table_set(lua_State *L, const gchar *index, const gchar *value) +void rspamd_lua_table_set(lua_State *L, const char *index, const char *value) { lua_pushstring(L, index); if (value) { @@ -237,10 +237,10 @@ void rspamd_lua_table_set(lua_State *L, const gchar *index, const gchar *value) lua_settable(L, -3); } -const gchar * -rspamd_lua_table_get(lua_State *L, const gchar *index) +const char * +rspamd_lua_table_get(lua_State *L, const char *index) { - const gchar *result; + const char *result; lua_pushstring(L, index); lua_gettable(L, -2); @@ -255,7 +255,7 @@ rspamd_lua_table_get(lua_State *L, const gchar *index) static void lua_add_actions_global(lua_State *L) { - gint i; + int i; lua_newtable(L); @@ -276,14 +276,14 @@ lua_add_actions_global(lua_State *L) void rspamd_lua_set_path(lua_State *L, const ucl_object_t *cfg_obj, GHashTable *vars) { - const gchar *old_path, *additional_path = NULL; + const char *old_path, *additional_path = NULL; const ucl_object_t *opts = NULL; - const gchar *rulesdir = RSPAMD_RULESDIR, - *lualibdir = RSPAMD_LUALIBDIR, - *libdir = RSPAMD_LIBDIR; - const gchar *t; + const char *rulesdir = RSPAMD_RULESDIR, + *lualibdir = RSPAMD_LUALIBDIR, + *libdir = RSPAMD_LIBDIR; + const char *t; - gchar path_buf[PATH_MAX]; + char path_buf[PATH_MAX]; lua_getglobal(L, "package"); lua_getfield(L, -1, "path"); @@ -408,10 +408,10 @@ void rspamd_lua_set_path(lua_State *L, const ucl_object_t *cfg_obj, GHashTable * lua_pop(L, 1); } -static gint -rspamd_lua_cmp_version_components(const gchar *comp1, const gchar *comp2) +static int +rspamd_lua_cmp_version_components(const char *comp1, const char *comp2) { - guint v1, v2; + unsigned int v1, v2; v1 = strtoul(comp1, NULL, 10); v2 = strtoul(comp2, NULL, 10); @@ -422,9 +422,9 @@ rspamd_lua_cmp_version_components(const gchar *comp1, const gchar *comp2) static int rspamd_lua_rspamd_version_cmp(lua_State *L) { - const gchar *ver; - gchar **components; - gint ret = 0; + const char *ver; + char **components; + int ret = 0; if (lua_type(L, 2) == LUA_TSTRING) { ver = lua_tostring(L, 2); @@ -472,7 +472,7 @@ static int rspamd_lua_rspamd_version_numeric(lua_State *L) { static int64_t version_num = RSPAMD_VERSION_NUM; - const gchar *type; + const char *type; if (lua_gettop(L) >= 2 && lua_type(L, 1) == LUA_TSTRING) { type = lua_tostring(L, 1); @@ -505,7 +505,7 @@ rspamd_lua_rspamd_version_numeric(lua_State *L) static int rspamd_lua_rspamd_version(lua_State *L) { - const gchar *result = NULL, *type; + const char *result = NULL, *type; if (lua_gettop(L) == 0) { result = RVERSION; @@ -547,9 +547,9 @@ rspamd_lua_rspamd_version(lua_State *L) } static gboolean -rspamd_lua_load_env(lua_State *L, const char *fname, gint tbl_pos, GError **err) +rspamd_lua_load_env(lua_State *L, const char *fname, int tbl_pos, GError **err) { - gint orig_top = lua_gettop(L), err_idx; + int orig_top = lua_gettop(L), err_idx; gboolean ret = TRUE; lua_pushcfunction(L, &rspamd_lua_traceback); @@ -594,24 +594,24 @@ rspamd_lua_load_env(lua_State *L, const char *fname, gint tbl_pos, GError **err) gboolean rspamd_lua_set_env(lua_State *L, GHashTable *vars, char **lua_env, GError **err) { - gint orig_top = lua_gettop(L); - gchar **env = g_get_environ(); + int orig_top = lua_gettop(L); + char **env = g_get_environ(); /* Set known paths as rspamd_paths global */ lua_getglobal(L, "rspamd_paths"); if (lua_isnil(L, -1)) { - const gchar *confdir = RSPAMD_CONFDIR, - *local_confdir = RSPAMD_LOCAL_CONFDIR, - *rundir = RSPAMD_RUNDIR, - *dbdir = RSPAMD_DBDIR, - *logdir = RSPAMD_LOGDIR, - *wwwdir = RSPAMD_WWWDIR, - *pluginsdir = RSPAMD_PLUGINSDIR, - *rulesdir = RSPAMD_RULESDIR, - *lualibdir = RSPAMD_LUALIBDIR, - *prefix = RSPAMD_PREFIX, - *sharedir = RSPAMD_SHAREDIR; - const gchar *t; + const char *confdir = RSPAMD_CONFDIR, + *local_confdir = RSPAMD_LOCAL_CONFDIR, + *rundir = RSPAMD_RUNDIR, + *dbdir = RSPAMD_DBDIR, + *logdir = RSPAMD_LOGDIR, + *wwwdir = RSPAMD_WWWDIR, + *pluginsdir = RSPAMD_PLUGINSDIR, + *rulesdir = RSPAMD_RULESDIR, + *lualibdir = RSPAMD_LUALIBDIR, + *prefix = RSPAMD_PREFIX, + *sharedir = RSPAMD_SHAREDIR; + const char *t; /* Try environment */ t = g_environ_getenv(env, "SHAREDIR"); @@ -749,7 +749,7 @@ rspamd_lua_set_env(lua_State *L, GHashTable *vars, char **lua_env, GError **err) } } - gint hostlen = sysconf(_SC_HOST_NAME_MAX); + int hostlen = sysconf(_SC_HOST_NAME_MAX); if (hostlen <= 0) { hostlen = 256; @@ -758,7 +758,7 @@ rspamd_lua_set_env(lua_State *L, GHashTable *vars, char **lua_env, GError **err) hostlen++; } - gchar *hostbuf = g_alloca(hostlen); + char *hostbuf = g_alloca(hostlen); memset(hostbuf, 0, hostlen); gethostname(hostbuf, hostlen - 1); @@ -773,12 +773,12 @@ rspamd_lua_set_env(lua_State *L, GHashTable *vars, char **lua_env, GError **err) lua_settable(L, -3); if (env) { - gint lim = g_strv_length(env); + int lim = g_strv_length(env); - for (gint i = 0; i < lim; i++) { + for (int i = 0; i < lim; i++) { if (RSPAMD_LEN_CHECK_STARTS_WITH(env[i], strlen(env[i]), "RSPAMD_")) { const char *var = env[i] + sizeof("RSPAMD_") - 1, *value; - gint varlen; + int varlen; varlen = strcspn(var, "="); value = var + varlen; @@ -795,9 +795,9 @@ rspamd_lua_set_env(lua_State *L, GHashTable *vars, char **lua_env, GError **err) } if (lua_env) { - gint lim = g_strv_length(lua_env); + int lim = g_strv_length(lua_env); - for (gint i = 0; i < lim; i++) { + for (int i = 0; i < lim; i++) { if (!rspamd_lua_load_env(L, lua_env[i], lua_gettop(L), err)) { return FALSE; } @@ -816,7 +816,7 @@ rspamd_lua_set_env(lua_State *L, GHashTable *vars, char **lua_env, GError **err) void rspamd_lua_set_globals(struct rspamd_config *cfg, lua_State *L) { struct rspamd_config **pcfg; - gint orig_top = lua_gettop(L); + int orig_top = lua_gettop(L); /* First check for global variable 'config' */ lua_getglobal(L, "config"); @@ -867,7 +867,7 @@ void rspamd_lua_set_globals(struct rspamd_config *cfg, lua_State *L) } #ifdef WITH_LUA_TRACE -static gint +static int lua_push_trace_data(lua_State *L) { if (lua_traces) { @@ -1092,8 +1092,8 @@ void rspamd_lua_start_gc(struct rspamd_config *cfg) } -void rspamd_plugins_table_push_elt(lua_State *L, const gchar *field_name, - const gchar *new_elt) +void rspamd_plugins_table_push_elt(lua_State *L, const char *field_name, + const char *new_elt) { lua_getglobal(L, rspamd_modules_state_global); @@ -1122,7 +1122,7 @@ rspamd_init_lua_filters(struct rspamd_config *cfg, bool force_load, bool strict) struct rspamd_config **pcfg; struct script_module *module; lua_State *L = cfg->lua_state; - gint err_idx, i; + int err_idx, i; pcfg = lua_newuserdata(L, sizeof(struct rspamd_config *)); rspamd_lua_setclass(L, rspamd_config_classname, -1); @@ -1142,10 +1142,10 @@ rspamd_init_lua_filters(struct rspamd_config *cfg, bool force_load, bool strict) err_idx = lua_gettop(L); gsize fsize; - guint8 *data = rspamd_file_xmap(module->path, - PROT_READ, &fsize, TRUE); - guchar digest[rspamd_cryptobox_HASHBYTES]; - gchar *lua_fname; + uint8_t *data = rspamd_file_xmap(module->path, + PROT_READ, &fsize, TRUE); + unsigned char digest[rspamd_cryptobox_HASHBYTES]; + char *lua_fname; if (data == NULL) { msg_err_config("cannot mmap %s failed: %s", module->path, @@ -1225,9 +1225,9 @@ rspamd_init_lua_filters(struct rspamd_config *cfg, bool force_load, bool strict) void rspamd_lua_dumpstack(lua_State *L) { - gint i, t, r = 0; - gint top = lua_gettop(L); - gchar buf[BUFSIZ]; + int i, t, r = 0; + int top = lua_gettop(L); + char buf[BUFSIZ]; r += rspamd_snprintf(buf + r, sizeof(buf) - r, "lua stack: "); for (i = 1; i <= top; i++) { /* repeat for each level */ @@ -1269,7 +1269,7 @@ void rspamd_lua_dumpstack(lua_State *L) } gpointer -rspamd_lua_check_class(lua_State *L, gint index, const gchar *name) +rspamd_lua_check_class(lua_State *L, int index, const char *name) { gpointer p; khiter_t k; @@ -1309,7 +1309,7 @@ int rspamd_lua_typerror(lua_State *L, int narg, const char *tname) } -void rspamd_lua_add_preload(lua_State *L, const gchar *name, lua_CFunction func) +void rspamd_lua_add_preload(lua_State *L, const char *name, lua_CFunction func) { lua_getglobal(L, "package"); lua_pushstring(L, "preload"); @@ -1321,12 +1321,12 @@ void rspamd_lua_add_preload(lua_State *L, const gchar *name, lua_CFunction func) gboolean -rspamd_lua_parse_table_arguments(lua_State *L, gint pos, +rspamd_lua_parse_table_arguments(lua_State *L, int pos, GError **err, enum rspamd_lua_parse_arguments_flags how, - const gchar *extraction_pattern, ...) + const char *extraction_pattern, ...) { - const gchar *p, *key = NULL, *end, *cls; + const char *p, *key = NULL, *end, *cls; va_list ap; gboolean required = FALSE, failed = FALSE, is_table; enum { @@ -1337,7 +1337,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, read_semicolon } state = read_key; gsize keylen = 0, *valuelen, clslen; - gint idx = 0, t, direct_userdata = 0; + int idx = 0, t, direct_userdata = 0; g_assert(extraction_pattern != NULL); @@ -1395,16 +1395,16 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, switch (*p) { case 'S': if (t == LUA_TSTRING) { - *(va_arg(ap, const gchar **)) = lua_tostring(L, idx); + *(va_arg(ap, const char **)) = lua_tostring(L, idx); } else if (t == LUA_TNIL || t == LUA_TNONE) { failed = TRUE; if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) { - *(va_arg(ap, const gchar **)) = NULL; + *(va_arg(ap, const char **)) = NULL; } else { - (void) va_arg(ap, gchar **); + (void) va_arg(ap, char **); } } else { @@ -1413,7 +1413,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 1, "bad type for key:" " %.*s: '%s', '%s' is expected", - (gint) keylen, + (int) keylen, key, lua_typename(L, lua_type(L, idx)), "string"); va_end(ap); @@ -1445,7 +1445,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 1, "bad type for key:" " %.*s: '%s', '%s' is expected", - (gint) keylen, + (int) keylen, key, lua_typename(L, lua_type(L, idx)), "int64"); @@ -1477,7 +1477,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 1, "bad type for key:" " %.*s: '%s', '%s' is expected", - (gint) keylen, + (int) keylen, key, lua_typename(L, lua_type(L, idx)), "int64"); @@ -1496,16 +1496,16 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, lua_pushvalue(L, idx); } - *(va_arg(ap, gint *)) = luaL_ref(L, LUA_REGISTRYINDEX); + *(va_arg(ap, int *)) = luaL_ref(L, LUA_REGISTRYINDEX); } else if (t == LUA_TNIL || t == LUA_TNONE) { failed = TRUE; if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) { - *(va_arg(ap, gint *)) = -1; + *(va_arg(ap, int *)) = -1; } else { - (void) va_arg(ap, gint *); + (void) va_arg(ap, int *); } if (is_table) { @@ -1518,7 +1518,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 1, "bad type for key:" " %.*s: '%s', '%s' is expected", - (gint) keylen, + (int) keylen, key, lua_typename(L, lua_type(L, idx)), "function"); @@ -1550,7 +1550,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 1, "bad type for key:" " %.*s: '%s', '%s' is expected", - (gint) keylen, + (int) keylen, key, lua_typename(L, lua_type(L, idx)), "bool"); @@ -1566,16 +1566,16 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, case 'N': if (t == LUA_TNUMBER) { - *(va_arg(ap, gdouble *)) = lua_tonumber(L, idx); + *(va_arg(ap, double *)) = lua_tonumber(L, idx); } else if (t == LUA_TNIL || t == LUA_TNONE) { failed = TRUE; if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) { - *(va_arg(ap, gdouble *)) = 0; + *(va_arg(ap, double *)) = 0; } else { - (void) va_arg(ap, gdouble *); + (void) va_arg(ap, double *); } } else { @@ -1584,7 +1584,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 1, "bad type for key:" " %.*s: '%s', '%s' is expected", - (gint) keylen, + (int) keylen, key, lua_typename(L, lua_type(L, idx)), "double"); @@ -1600,16 +1600,16 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, case 'D': if (t == LUA_TNUMBER) { - *(va_arg(ap, gdouble *)) = lua_tonumber(L, idx); + *(va_arg(ap, double *)) = lua_tonumber(L, idx); } else if (t == LUA_TNIL || t == LUA_TNONE) { failed = TRUE; if (how != RSPAMD_LUA_PARSE_ARGUMENTS_IGNORE_MISSING) { - *(va_arg(ap, gdouble *)) = NAN; + *(va_arg(ap, double *)) = NAN; } else { - (void) va_arg(ap, gdouble *); + (void) va_arg(ap, double *); } } else { @@ -1618,7 +1618,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 1, "bad type for key:" " %.*s: '%s', '%s' is expected", - (gint) keylen, + (int) keylen, key, lua_typename(L, lua_type(L, idx)), "double"); @@ -1636,8 +1636,8 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, valuelen = va_arg(ap, gsize *); if (t == LUA_TSTRING) { - *(va_arg(ap, const gchar **)) = lua_tolstring(L, idx, - valuelen); + *(va_arg(ap, const char **)) = lua_tolstring(L, idx, + valuelen); } else if (t == LUA_TNIL || t == LUA_TNONE) { failed = TRUE; @@ -1656,7 +1656,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 1, "bad type for key:" " %.*s: '%s', '%s' is expected", - (gint) keylen, + (int) keylen, key, lua_typename(L, lua_type(L, idx)), "string"); @@ -1706,7 +1706,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 1, "bad type for key:" " %.*s: '%s', '%s' is expected", - (gint) keylen, + (int) keylen, key, lua_typename(L, lua_type(L, idx)), "int64"); @@ -1738,7 +1738,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 1, "bad type for key:" " %.*s: '%s', '%s' is expected", - (gint) keylen, + (int) keylen, key, lua_typename(L, lua_type(L, idx)), "int64"); @@ -1761,7 +1761,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, if (failed && required) { g_set_error(err, lua_error_quark(), 2, "required parameter " "%.*s is missing", - (gint) keylen, key); + (int) keylen, key); va_end(ap); return FALSE; @@ -1792,7 +1792,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, g_set_error(err, lua_error_quark(), 2, "missing classname for " "%.*s", - (gint) keylen, key); + (int) keylen, key); va_end(ap); return FALSE; @@ -1813,7 +1813,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 2, "empty classname for " "%*.s", - (gint) keylen, + (int) keylen, key); va_end(ap); @@ -1843,7 +1843,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, lua_error_quark(), 2, "invalid class for key %.*s, expected %s, got %s", - (gint) keylen, + (int) keylen, key, static_cls, rspamd_lua_class_tostring_buf(L, FALSE, idx)); @@ -1866,7 +1866,7 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, 2, "required parameter " "%.*s is missing", - (gint) keylen, + (int) keylen, key); va_end(ap); @@ -1912,9 +1912,9 @@ rspamd_lua_parse_table_arguments(lua_State *L, gint pos, static void rspamd_lua_traceback_string(lua_State *L, luaL_Buffer *buf) { - gint i = 1, r; + int i = 1, r; lua_Debug d; - gchar tmp[256]; + char tmp[256]; while (lua_getstack(L, i++, &d)) { lua_getinfo(L, "nSl", &d); @@ -1925,7 +1925,7 @@ rspamd_lua_traceback_string(lua_State *L, luaL_Buffer *buf) } } -gint rspamd_lua_traceback(lua_State *L) +int rspamd_lua_traceback(lua_State *L) { luaL_Buffer b; @@ -1938,7 +1938,7 @@ gint rspamd_lua_traceback(lua_State *L) void rspamd_lua_get_traceback_string(lua_State *L, luaL_Buffer *buf) { - const gchar *msg = lua_tostring(L, -1); + const char *msg = lua_tostring(L, -1); if (msg) { luaL_addstring(buf, msg); @@ -1952,9 +1952,9 @@ void rspamd_lua_get_traceback_string(lua_State *L, luaL_Buffer *buf) rspamd_lua_traceback_string(L, buf); } -guint rspamd_lua_table_size(lua_State *L, gint tbl_pos) +unsigned int rspamd_lua_table_size(lua_State *L, int tbl_pos) { - guint tbl_size = 0; + unsigned int tbl_size = 0; if (!lua_istable(L, tbl_pos)) { return 0; @@ -1970,11 +1970,11 @@ guint rspamd_lua_table_size(lua_State *L, gint tbl_pos) } static void * -rspamd_lua_check_udata_common(lua_State *L, gint pos, const gchar *classname, +rspamd_lua_check_udata_common(lua_State *L, int pos, const char *classname, gboolean fatal) { void *p = lua_touserdata(L, pos); - gint i, top = lua_gettop(L); + int i, top = lua_gettop(L); if (p == NULL) { goto err; @@ -2008,7 +2008,7 @@ rspamd_lua_check_udata_common(lua_State *L, gint pos, const gchar *classname, err: if (fatal) { - const gchar *actual_classname = NULL; + const char *actual_classname = NULL; if (lua_type(L, pos) == LUA_TUSERDATA && lua_getmetatable(L, pos)) { lua_pushstring(L, "__index"); @@ -2022,8 +2022,8 @@ err: } luaL_Buffer buf; - gchar tmp[512]; - gint r; + char tmp[512]; + int r; luaL_buffinit(L, &buf); r = rspamd_snprintf(tmp, sizeof(tmp), @@ -2071,19 +2071,19 @@ err: } void * -rspamd_lua_check_udata(lua_State *L, gint pos, const gchar *classname) +rspamd_lua_check_udata(lua_State *L, int pos, const char *classname) { return rspamd_lua_check_udata_common(L, pos, classname, TRUE); } void * -rspamd_lua_check_udata_maybe(lua_State *L, gint pos, const gchar *classname) +rspamd_lua_check_udata_maybe(lua_State *L, int pos, const char *classname) { return rspamd_lua_check_udata_common(L, pos, classname, FALSE); } struct rspamd_async_session * -lua_check_session(lua_State *L, gint pos) +lua_check_session(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_session_classname); luaL_argcheck(L, ud != NULL, pos, "'session' expected"); @@ -2091,7 +2091,7 @@ lua_check_session(lua_State *L, gint pos) } struct ev_loop * -lua_check_ev_base(lua_State *L, gint pos) +lua_check_ev_base(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_ev_base_classname); luaL_argcheck(L, ud != NULL, pos, "'event_base' expected"); @@ -2141,7 +2141,7 @@ void rspamd_lua_run_config_post_init(lua_State *L, struct rspamd_config *cfg) LL_FOREACH(cfg->post_init_scripts, sc) { lua_pushcfunction(L, &rspamd_lua_traceback); - gint err_idx = lua_gettop(L); + int err_idx = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, sc->cbref); pcfg = lua_newuserdata(L, sizeof(*pcfg)); @@ -2166,7 +2166,7 @@ void rspamd_lua_run_config_unload(lua_State *L, struct rspamd_config *cfg) LL_FOREACH(cfg->config_unload_scripts, sc) { lua_pushcfunction(L, &rspamd_lua_traceback); - gint err_idx = lua_gettop(L); + int err_idx = lua_gettop(L); lua_rawgeti(L, LUA_REGISTRYINDEX, sc->cbref); pcfg = lua_newuserdata(L, sizeof(*pcfg)); @@ -2193,7 +2193,7 @@ rspamd_lua_run_postloads_error(struct thread_entry *thread, int ret, const char struct rspamd_lua_ref_cbdata { lua_State *L; - gint cbref; + int cbref; }; static void @@ -2205,7 +2205,7 @@ rspamd_lua_ref_dtor(gpointer p) } void rspamd_lua_add_ref_dtor(lua_State *L, rspamd_mempool_t *pool, - gint ref) + int ref) { struct rspamd_lua_ref_cbdata *cbdata; @@ -2219,10 +2219,10 @@ void rspamd_lua_add_ref_dtor(lua_State *L, rspamd_mempool_t *pool, } gboolean -rspamd_lua_require_function(lua_State *L, const gchar *modname, - const gchar *funcname) +rspamd_lua_require_function(lua_State *L, const char *modname, + const char *funcname) { - gint table_pos, err_pos; + int table_pos, err_pos; lua_pushcfunction(L, &rspamd_lua_traceback); err_pos = lua_gettop(L); @@ -2291,10 +2291,10 @@ rspamd_lua_require_function(lua_State *L, const gchar *modname, } } -gint rspamd_lua_function_ref_from_str(lua_State *L, const gchar *str, gsize slen, - const gchar *modname, GError **err) +int rspamd_lua_function_ref_from_str(lua_State *L, const char *str, gsize slen, + const char *modname, GError **err) { - gint err_idx, ref_idx; + int err_idx, ref_idx; lua_pushcfunction(L, &rspamd_lua_traceback); err_idx = lua_gettop(L); @@ -2347,9 +2347,9 @@ gint rspamd_lua_function_ref_from_str(lua_State *L, const gchar *str, gsize slen gboolean rspamd_lua_try_load_redis(lua_State *L, const ucl_object_t *obj, - struct rspamd_config *cfg, gint *ref_id) + struct rspamd_config *cfg, int *ref_id) { - gint err_idx; + int err_idx; struct rspamd_config **pcfg; lua_pushcfunction(L, &rspamd_lua_traceback); @@ -2402,7 +2402,7 @@ rspamd_lua_try_load_redis(lua_State *L, const ucl_object_t *obj, void rspamd_lua_push_full_word(lua_State *L, rspamd_stat_token_t *w) { - gint fl_cnt; + int fl_cnt; lua_createtable(L, 4, 0); @@ -2477,11 +2477,11 @@ void rspamd_lua_push_full_word(lua_State *L, rspamd_stat_token_t *w) lua_rawseti(L, -2, 4); } -gint rspamd_lua_push_words(lua_State *L, GArray *words, - enum rspamd_lua_words_type how) +int rspamd_lua_push_words(lua_State *L, GArray *words, + enum rspamd_lua_words_type how) { rspamd_stat_token_t *w; - guint i, cnt; + unsigned int i, cnt; lua_createtable(L, words->len, 0); @@ -2520,12 +2520,12 @@ gint rspamd_lua_push_words(lua_State *L, GArray *words, return 1; } -gchar * +char * rspamd_lua_get_module_name(lua_State *L) { lua_Debug d; - gchar *p; - gchar func_buf[128]; + char *p; + char func_buf[128]; if (lua_getstack(L, 1, &d) == 1) { (void) lua_getinfo(L, "Sl", &d); @@ -2551,12 +2551,12 @@ rspamd_lua_get_module_name(lua_State *L) return NULL; } -bool rspamd_lua_universal_pcall(lua_State *L, gint cbref, const gchar *strloc, - gint nret, const gchar *args, GError **err, ...) +bool rspamd_lua_universal_pcall(lua_State *L, int cbref, const char *strloc, + int nret, const char *args, GError **err, ...) { va_list ap; - const gchar *argp = args, *classname; - gint err_idx, nargs = 0; + const char *argp = args, *classname; + int err_idx, nargs = 0; gpointer *cls_ptr; gsize sz; @@ -2576,9 +2576,9 @@ bool rspamd_lua_universal_pcall(lua_State *L, gint cbref, const gchar *strloc, /* * Possible arguments * - 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 + * - n - lua_number, argument - double + * - s - lua_string, argument - const char * (zero terminated) + * - l - lua_lstring, argument - (size_t + const char *) pair * - u - lua_userdata, argument - (const char * + void *) - classname + pointer * - b - lua_boolean, argument - gboolean (not bool due to varargs promotion) * - f - lua_function, argument - int - position of the function on stack (not lua_registry) @@ -2591,16 +2591,16 @@ bool rspamd_lua_universal_pcall(lua_State *L, gint cbref, const gchar *strloc, nargs++; break; case 'n': - lua_pushnumber(L, va_arg(ap, gdouble)); + lua_pushnumber(L, va_arg(ap, double)); nargs++; break; case 's': - lua_pushstring(L, va_arg(ap, const gchar *)); + lua_pushstring(L, va_arg(ap, const char *)); nargs++; break; case 'l': sz = va_arg(ap, gsize); - lua_pushlstring(L, va_arg(ap, const gchar *), sz); + lua_pushlstring(L, va_arg(ap, const char *), sz); nargs++; break; case 'b': @@ -2608,7 +2608,7 @@ bool rspamd_lua_universal_pcall(lua_State *L, gint cbref, const gchar *strloc, nargs++; break; case 'u': - classname = va_arg(ap, const gchar *); + classname = va_arg(ap, const char *); cls_ptr = (gpointer *) lua_newuserdata(L, sizeof(gpointer)); *cls_ptr = va_arg(ap, gpointer); rspamd_lua_setclass(L, classname, -1); @@ -2616,7 +2616,7 @@ bool rspamd_lua_universal_pcall(lua_State *L, gint cbref, const gchar *strloc, break; case 'f': case 't': - lua_pushvalue(L, va_arg(ap, gint)); + lua_pushvalue(L, va_arg(ap, int)); nargs++; break; default: @@ -2649,7 +2649,7 @@ bool rspamd_lua_universal_pcall(lua_State *L, gint cbref, const gchar *strloc, } #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502 -gint rspamd_lua_geti(lua_State *L, int pos, int i) +int rspamd_lua_geti(lua_State *L, int pos, int i) { pos = lua_absindex(L, pos); lua_pushinteger(L, i); diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index 03465cc90..198735c66 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -62,7 +62,7 @@ extern "C" { #if LUA_VERSION_NUM > 501 && !defined LUA_COMPAT_MODULE static inline void -luaL_register(lua_State *L, const gchar *name, const struct luaL_reg *methods) +luaL_register(lua_State *L, const char *name, const struct luaL_reg *methods) { if (name != NULL) { lua_newtable(L); @@ -114,9 +114,9 @@ struct rspamd_lua_ip { #define RSPAMD_TEXT_FLAG_FAKE (1u << 4u) #define RSPAMD_TEXT_FLAG_BINARY (1u << 5u) struct rspamd_lua_text { - const gchar *start; - guint len; - guint flags; + const char *start; + unsigned int len; + unsigned int flags; }; struct rspamd_lua_url { @@ -125,9 +125,9 @@ struct rspamd_lua_url { struct rspamd_lua_regexp { rspamd_regexp_t *re; - gchar *module; - gchar *re_pattern; - gint re_flags; + char *module; + char *re_pattern; + int re_flags; }; struct rspamd_map; @@ -149,7 +149,7 @@ enum rspamd_lua_map_type { struct rspamd_lua_map { struct rspamd_map *map; enum rspamd_lua_map_type type; - guint flags; + unsigned int flags; union { struct rspamd_radix_map_helper *radix; @@ -162,7 +162,7 @@ struct rspamd_lua_map { struct rspamd_lua_upstream { struct upstream *up; - gint upref; + int upref; }; /* Common utility functions */ @@ -171,7 +171,7 @@ struct rspamd_lua_upstream { * Create and register new class */ void rspamd_lua_new_class(lua_State *L, - const gchar *classname, + const char *classname, const struct luaL_reg *methods); /** @@ -179,14 +179,14 @@ void rspamd_lua_new_class(lua_State *L, * @param L * @param classname **MUST BE STATIC**, direct address is used for comparisons! */ -void rspamd_lua_setclass(lua_State *L, const gchar *classname, gint objidx); +void rspamd_lua_setclass(lua_State *L, const char *classname, int objidx); /** * Pushes the metatable for specific class on top of the stack * @param L * @param classname */ -void rspamd_lua_class_metatable(lua_State *L, const gchar *classname); +void rspamd_lua_class_metatable(lua_State *L, const char *classname); /** * Adds a new field to the class (metatable) identified by `classname` @@ -194,28 +194,28 @@ void rspamd_lua_class_metatable(lua_State *L, const gchar *classname); * @param classname * @param meth */ -void rspamd_lua_add_metamethod(lua_State *L, const gchar *classname, +void rspamd_lua_add_metamethod(lua_State *L, const char *classname, luaL_Reg *meth); /** * Set index of table to value (like t['index'] = value) */ -void rspamd_lua_table_set(lua_State *L, const gchar *index, const gchar *value); +void rspamd_lua_table_set(lua_State *L, const char *index, const char *value); /** * Get string value of index in a table (return t['index']) */ -const gchar *rspamd_lua_table_get(lua_State *L, const gchar *index); +const char *rspamd_lua_table_get(lua_State *L, const char *index); /** * Convert classname to string */ -gint rspamd_lua_class_tostring(lua_State *L); +int rspamd_lua_class_tostring(lua_State *L); /** * Check whether the argument at specified index is of the specified class */ -gpointer rspamd_lua_check_class(lua_State *L, gint index, const gchar *name); +gpointer rspamd_lua_check_class(lua_State *L, int index, const char *name); /** * Initialize lua and bindings @@ -237,8 +237,8 @@ void rspamd_lua_start_gc(struct rspamd_config *cfg); * @param field_name * @param new_elt */ -void rspamd_plugins_table_push_elt(lua_State *L, const gchar *field_name, - const gchar *new_elt); +void rspamd_plugins_table_push_elt(lua_State *L, const char *field_name, + const char *new_elt); /** * Load and initialize lua plugins @@ -260,9 +260,9 @@ void rspamd_lua_task_push(lua_State *L, struct rspamd_task *task); /** * Return lua ip structure at the specified address */ -struct rspamd_lua_ip *lua_check_ip(lua_State *L, gint pos); +struct rspamd_lua_ip *lua_check_ip(lua_State *L, int pos); -struct rspamd_lua_text *lua_check_text(lua_State *L, gint pos); +struct rspamd_lua_text *lua_check_text(lua_State *L, int pos); /** * Checks for a text or a string. In case of string a pointer to static structure is returned. * So it should not be reused or placed to Lua stack anyhow! @@ -271,7 +271,7 @@ struct rspamd_lua_text *lua_check_text(lua_State *L, gint pos); * @param pos * @return */ -struct rspamd_lua_text *lua_check_text_or_string(lua_State *L, gint pos); +struct rspamd_lua_text *lua_check_text_or_string(lua_State *L, int pos); /** * Create new text object * @param L @@ -280,7 +280,7 @@ struct rspamd_lua_text *lua_check_text_or_string(lua_State *L, gint pos); * @param own * @return */ -struct rspamd_lua_text *lua_new_text(lua_State *L, const gchar *start, +struct rspamd_lua_text *lua_new_text(lua_State *L, const char *start, gsize len, gboolean own); /** * Create new text object from task pool if allocation is needed @@ -292,7 +292,7 @@ struct rspamd_lua_text *lua_new_text(lua_State *L, const gchar *start, * @return */ struct rspamd_lua_text *lua_new_text_task(lua_State *L, struct rspamd_task *task, - const gchar *start, gsize len, gboolean own); + const char *start, gsize len, gboolean own); /** * Checks if a text has binary characters (non ascii and non-utf8 characters) * @param t @@ -300,7 +300,7 @@ struct rspamd_lua_text *lua_new_text_task(lua_State *L, struct rspamd_task *task */ bool lua_is_text_binary(struct rspamd_lua_text *t); -struct rspamd_lua_regexp *lua_check_regexp(lua_State *L, gint pos); +struct rspamd_lua_regexp *lua_check_regexp(lua_State *L, int pos); struct rspamd_lua_upstream *lua_check_upstream(lua_State *L, int pos); @@ -312,32 +312,32 @@ enum rspamd_lua_task_header_type { RSPAMD_TASK_HEADER_PUSH_HAS, }; -gint rspamd_lua_push_header(lua_State *L, - struct rspamd_mime_header *h, - enum rspamd_lua_task_header_type how); +int rspamd_lua_push_header(lua_State *L, + struct rspamd_mime_header *h, + enum rspamd_lua_task_header_type how); /** * Push specific header to lua */ -gint rspamd_lua_push_header_array(lua_State *L, - const gchar *name, - struct rspamd_mime_header *rh, - enum rspamd_lua_task_header_type how, - gboolean strong); +int rspamd_lua_push_header_array(lua_State *L, + const char *name, + struct rspamd_mime_header *rh, + enum rspamd_lua_task_header_type how, + gboolean strong); /** * Check for task at the specified position */ -struct rspamd_task *lua_check_task(lua_State *L, gint pos); +struct rspamd_task *lua_check_task(lua_State *L, int pos); -struct rspamd_task *lua_check_task_maybe(lua_State *L, gint pos); +struct rspamd_task *lua_check_task_maybe(lua_State *L, int pos); -struct rspamd_lua_map *lua_check_map(lua_State *L, gint pos); +struct rspamd_lua_map *lua_check_map(lua_State *L, int pos); /** * Push ip address from a string (nil is pushed if a string cannot be converted) */ -void rspamd_lua_ip_push_fromstring(lua_State *L, const gchar *ip_str); +void rspamd_lua_ip_push_fromstring(lua_State *L, const char *ip_str); /** * Create type error @@ -350,7 +350,7 @@ int rspamd_lua_typerror(lua_State *L, int narg, const char *tname); /** * Add preload function */ -void rspamd_lua_add_preload(lua_State *L, const gchar *name, lua_CFunction func); +void rspamd_lua_add_preload(lua_State *L, const char *name, lua_CFunction func); void luaopen_task(lua_State *L); @@ -422,7 +422,7 @@ void luaopen_tensor(lua_State *L); void luaopen_parsers(lua_State *L); -void rspamd_lua_dostring(const gchar *line); +void rspamd_lua_dostring(const char *line); double rspamd_lua_normalize(struct rspamd_config *cfg, long double score, @@ -443,17 +443,17 @@ gboolean rspamd_lua_set_env(lua_State *L, GHashTable *vars, char **lua_env, void rspamd_lua_set_globals(struct rspamd_config *cfg, lua_State *L); -struct memory_pool_s *rspamd_lua_check_mempool(lua_State *L, gint pos); +struct memory_pool_s *rspamd_lua_check_mempool(lua_State *L, int pos); -struct rspamd_config *lua_check_config(lua_State *L, gint pos); +struct rspamd_config *lua_check_config(lua_State *L, int pos); -struct rspamd_async_session *lua_check_session(lua_State *L, gint pos); +struct rspamd_async_session *lua_check_session(lua_State *L, int pos); -struct ev_loop *lua_check_ev_base(lua_State *L, gint pos); +struct ev_loop *lua_check_ev_base(lua_State *L, int pos); -struct rspamd_dns_resolver *lua_check_dns_resolver(lua_State *L, gint pos); +struct rspamd_dns_resolver *lua_check_dns_resolver(lua_State *L, int pos); -struct rspamd_lua_url *lua_check_url(lua_State *L, gint pos); +struct rspamd_lua_url *lua_check_url(lua_State *L, int pos); enum rspamd_lua_parse_arguments_flags { RSPAMD_LUA_PARSE_ARGUMENTS_DEFAULT = 0, @@ -483,13 +483,13 @@ enum rspamd_lua_parse_arguments_flags { * @param extraction_pattern static pattern * @return TRUE if a table has been parsed */ -gboolean rspamd_lua_parse_table_arguments(lua_State *L, gint pos, +gboolean rspamd_lua_parse_table_arguments(lua_State *L, int pos, GError **err, enum rspamd_lua_parse_arguments_flags how, - const gchar *extraction_pattern, ...); + const char *extraction_pattern, ...); -gint rspamd_lua_traceback(lua_State *L); +int rspamd_lua_traceback(lua_State *L); /** * Returns stack trace as a string. Caller should clear memory. @@ -501,7 +501,7 @@ void rspamd_lua_get_traceback_string(lua_State *L, luaL_Buffer *buf); /** * Returns size of table at position `tbl_pos` */ -guint rspamd_lua_table_size(lua_State *L, gint tbl_pos); +unsigned int rspamd_lua_table_size(lua_State *L, int tbl_pos); void lua_push_emails_address_list(lua_State *L, GPtrArray *addrs, int flags); @@ -509,7 +509,7 @@ void lua_push_emails_address_list(lua_State *L, GPtrArray *addrs, int flags); #define TRACE_POINTS 6 struct lua_logger_trace { - gint cur_level; + int cur_level; gconstpointer traces[TRACE_POINTS]; }; @@ -531,7 +531,7 @@ enum lua_logger_escape_type { * @param len * @return */ -gsize lua_logger_out_type(lua_State *L, gint pos, gchar *outbuf, +gsize lua_logger_out_type(lua_State *L, int pos, char *outbuf, gsize len, struct lua_logger_trace *trace, enum lua_logger_escape_type esc_type); @@ -541,7 +541,7 @@ gsize lua_logger_out_type(lua_State *L, gint pos, gchar *outbuf, * @param pos * @param classname **MUST BE STATIC**, direct address is used for comparisons! */ -void *rspamd_lua_check_udata(lua_State *L, gint pos, const gchar *classname); +void *rspamd_lua_check_udata(lua_State *L, int pos, const char *classname); #define RSPAMD_LUA_CHECK_UDATA_PTR_OR_RETURN(L, pos, classname, type, dest) \ do { \ @@ -558,7 +558,7 @@ void *rspamd_lua_check_udata(lua_State *L, gint pos, const gchar *classname); * @param pos * @param classname **MUST BE STATIC**, direct address is used for comparisons! */ -void *rspamd_lua_check_udata_maybe(lua_State *L, gint pos, const gchar *classname); +void *rspamd_lua_check_udata_maybe(lua_State *L, int pos, const char *classname); /** * Call finishing script with the specified task @@ -588,7 +588,7 @@ void rspamd_lua_run_config_unload(lua_State *L, struct rspamd_config *cfg); * @param ref */ void rspamd_lua_add_ref_dtor(lua_State *L, rspamd_mempool_t *pool, - gint ref); + int ref); /** * Returns a lua reference from a function like string, e.g. `return function(...) end` @@ -596,8 +596,8 @@ void rspamd_lua_add_ref_dtor(lua_State *L, rspamd_mempool_t *pool, * @param str * @return */ -gint rspamd_lua_function_ref_from_str(lua_State *L, const gchar *str, gsize slen, - const gchar *modname, GError **err); +int rspamd_lua_function_ref_from_str(lua_State *L, const char *str, gsize slen, + const char *modname, GError **err); /** * Tries to load some module using `require` and get some method from it @@ -606,8 +606,8 @@ gint rspamd_lua_function_ref_from_str(lua_State *L, const gchar *str, gsize slen * @param funcname * @return TRUE if function exists in that module, the function is pushed in stack, otherwise stack is unchanged and FALSE is returned */ -gboolean rspamd_lua_require_function(lua_State *L, const gchar *modname, - const gchar *funcname); +gboolean rspamd_lua_require_function(lua_State *L, const char *modname, + const char *funcname); /** * Tries to load redis server definition from ucl object specified @@ -617,7 +617,7 @@ gboolean rspamd_lua_require_function(lua_State *L, const gchar *modname, * @return */ gboolean rspamd_lua_try_load_redis(lua_State *L, const ucl_object_t *obj, - struct rspamd_config *cfg, gint *ref_id); + struct rspamd_config *cfg, int *ref_id); struct rspamd_stat_token_s; @@ -642,22 +642,22 @@ enum rspamd_lua_words_type { * @param words * @param how */ -gint rspamd_lua_push_words(lua_State *L, GArray *words, - enum rspamd_lua_words_type how); +int rspamd_lua_push_words(lua_State *L, GArray *words, + enum rspamd_lua_words_type how); /** * Returns newly allocated name for caller module name * @param L * @return */ -gchar *rspamd_lua_get_module_name(lua_State *L); +char *rspamd_lua_get_module_name(lua_State *L); /** * Call Lua function in a universal way. Arguments string: * - 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 +* - n - lua_number, argument - double +* - s - lua_string, argument - const char * (zero terminated) +* - l - lua_lstring, argument - (size_t + const char *) pair * - u - lua_userdata, argument - (const char * + void *) - classname + pointer * - b - lua_boolean, argument - gboolean (not bool due to varargs promotion) * - f - lua_function, argument - int - position of the function on stack (not lua_registry) @@ -671,8 +671,8 @@ gchar *rspamd_lua_get_module_name(lua_State *L); * @param ... arguments * @return true of pcall returned 0, false + err otherwise */ -bool rspamd_lua_universal_pcall(lua_State *L, gint cbref, const gchar *strloc, - gint nret, const gchar *args, GError **err, ...); +bool rspamd_lua_universal_pcall(lua_State *L, int cbref, const char *strloc, + int nret, const char *args, GError **err, ...); /** * Returns true if lua is initialised @@ -688,7 +688,7 @@ bool rspamd_lua_is_initialised(void); * @return */ #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM <= 502 -gint rspamd_lua_geti(lua_State *L, int index, int i); +int rspamd_lua_geti(lua_State *L, int index, int i); #else #define rspamd_lua_geti lua_geti #endif diff --git a/src/lua/lua_compress.c b/src/lua/lua_compress.c index 39776ccf6..4a348404c 100644 --- a/src/lua/lua_compress.c +++ b/src/lua/lua_compress.c @@ -67,7 +67,7 @@ static const struct luaL_reg zstd_decompress_lib_m[] = { {NULL, NULL}}; static ZSTD_CStream * -lua_check_zstd_compress_ctx(lua_State *L, gint pos) +lua_check_zstd_compress_ctx(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_zstd_compress_classname); luaL_argcheck(L, ud != NULL, pos, "'zstd_compress' expected"); @@ -75,7 +75,7 @@ lua_check_zstd_compress_ctx(lua_State *L, gint pos) } static ZSTD_DStream * -lua_check_zstd_decompress_ctx(lua_State *L, gint pos) +lua_check_zstd_decompress_ctx(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_zstd_decompress_classname); luaL_argcheck(L, ud != NULL, pos, "'zstd_decompress' expected"); @@ -90,12 +90,12 @@ int lua_zstd_push_error(lua_State *L, int err) return 2; } -gint lua_compress_zstd_compress(lua_State *L) +int lua_compress_zstd_compress(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t = NULL, *res; gsize sz, r; - gint comp_level = 1; + int comp_level = 1; t = lua_check_text_or_string(L, 1); @@ -135,7 +135,7 @@ gint lua_compress_zstd_compress(lua_State *L) return 1; } -gint lua_compress_zstd_decompress(lua_State *L) +int lua_compress_zstd_decompress(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t = NULL, *res; @@ -143,7 +143,7 @@ gint lua_compress_zstd_decompress(lua_State *L) ZSTD_DStream *zstream; ZSTD_inBuffer zin; ZSTD_outBuffer zout; - gchar *out; + char *out; t = lua_check_text_or_string(L, 1); @@ -200,14 +200,14 @@ gint lua_compress_zstd_decompress(lua_State *L) return 2; } -gint lua_compress_zlib_decompress(lua_State *L, bool is_gzip) +int lua_compress_zlib_decompress(lua_State *L, bool is_gzip) { LUA_TRACE_POINT; struct rspamd_lua_text *t = NULL, *res; gsize sz; z_stream strm; - gint rc; - guchar *p; + int rc; + unsigned char *p; gsize remain; gssize size_limit = -1; @@ -249,14 +249,14 @@ gint lua_compress_zlib_decompress(lua_State *L, bool is_gzip) } strm.avail_in = t->len; - strm.next_in = (guchar *) t->start; + strm.next_in = (unsigned char *) t->start; res = lua_newuserdata(L, sizeof(*res)); res->start = g_malloc(sz); res->flags = RSPAMD_TEXT_FLAG_OWN; rspamd_lua_setclass(L, rspamd_text_classname, -1); - p = (guchar *) res->start; + p = (unsigned char *) res->start; remain = sz; while (strm.avail_in != 0) { @@ -298,7 +298,7 @@ gint lua_compress_zlib_decompress(lua_State *L, bool is_gzip) remain = res->len; res->start = g_realloc((gpointer) res->start, res->len * 2); sz = res->len * 2; - p = (guchar *) res->start + remain; + p = (unsigned char *) res->start + remain; remain = sz - remain; } } @@ -309,14 +309,14 @@ gint lua_compress_zlib_decompress(lua_State *L, bool is_gzip) return 1; } -gint lua_compress_zlib_compress(lua_State *L) +int lua_compress_zlib_compress(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t = NULL, *res; gsize sz; z_stream strm; - gint rc, comp_level = Z_DEFAULT_COMPRESSION; - guchar *p; + int rc, comp_level = Z_DEFAULT_COMPRESSION; + unsigned char *p; gsize remain; t = lua_check_text_or_string(L, 1); @@ -346,14 +346,14 @@ gint lua_compress_zlib_compress(lua_State *L) sz = deflateBound(&strm, t->len); strm.avail_in = t->len; - strm.next_in = (guchar *) t->start; + strm.next_in = (unsigned char *) t->start; res = lua_newuserdata(L, sizeof(*res)); res->start = g_malloc(sz); res->flags = RSPAMD_TEXT_FLAG_OWN; rspamd_lua_setclass(L, rspamd_text_classname, -1); - p = (guchar *) res->start; + p = (unsigned char *) res->start; remain = sz; while (strm.avail_in != 0) { @@ -384,7 +384,7 @@ gint lua_compress_zlib_compress(lua_State *L) remain = res->len; res->start = g_realloc((gpointer) res->start, strm.avail_in + sz); sz = strm.avail_in + sz; - p = (guchar *) res->start + remain; + p = (unsigned char *) res->start + remain; remain = sz - remain; } } @@ -404,7 +404,7 @@ static const char *const zstd_stream_op[] = { "end", NULL}; -static gint +static int lua_zstd_compress_ctx(lua_State *L) { ZSTD_CCtx *ctx, **pctx; @@ -421,7 +421,7 @@ lua_zstd_compress_ctx(lua_State *L) return 1; } -static gint +static int lua_zstd_compress_dtor(lua_State *L) { ZSTD_CCtx *ctx = lua_check_zstd_compress_ctx(L, 1); @@ -433,7 +433,7 @@ lua_zstd_compress_dtor(lua_State *L) return 0; } -static gint +static int lua_zstd_compress_reset(lua_State *L) { ZSTD_CCtx *ctx = lua_check_zstd_compress_ctx(L, 1); @@ -448,7 +448,7 @@ lua_zstd_compress_reset(lua_State *L) return 0; } -static gint +static int lua_zstd_compress_stream(lua_State *L) { ZSTD_CStream *ctx = lua_check_zstd_compress_ctx(L, 1); @@ -509,7 +509,7 @@ lua_zstd_compress_stream(lua_State *L) return 1; } -static gint +static int lua_zstd_decompress_dtor(lua_State *L) { ZSTD_DStream *ctx = lua_check_zstd_decompress_ctx(L, 1); @@ -522,7 +522,7 @@ lua_zstd_decompress_dtor(lua_State *L) } -static gint +static int lua_zstd_decompress_ctx(lua_State *L) { ZSTD_DStream *ctx, **pctx; @@ -539,7 +539,7 @@ lua_zstd_decompress_ctx(lua_State *L) return 1; } -static gint +static int lua_zstd_decompress_stream(lua_State *L) { ZSTD_DStream *ctx = lua_check_zstd_decompress_ctx(L, 1); @@ -603,7 +603,7 @@ lua_zstd_decompress_stream(lua_State *L) return 1; } -static gint +static int lua_load_zstd(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_compress.h b/src/lua/lua_compress.h index 34234de34..47e733d6d 100644 --- a/src/lua/lua_compress.h +++ b/src/lua/lua_compress.h @@ -23,10 +23,10 @@ extern "C" { #endif -gint lua_compress_zstd_compress(lua_State *L); -gint lua_compress_zstd_decompress(lua_State *L); -gint lua_compress_zlib_compress(lua_State *L); -gint lua_compress_zlib_decompress(lua_State *L, bool is_gzip); +int lua_compress_zstd_compress(lua_State *L); +int lua_compress_zstd_decompress(lua_State *L); +int lua_compress_zlib_compress(lua_State *L); +int lua_compress_zlib_decompress(lua_State *L, bool is_gzip); void luaopen_compress(lua_State *L); diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 1a3c1db20..f9a79eef1 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -945,7 +945,7 @@ static const struct luaL_reg monitoredlib_m[] = { static const uint64_t rspamd_lua_callback_magic = 0x32c118af1e3263c7ULL; struct rspamd_config * -lua_check_config(lua_State *L, gint pos) +lua_check_config(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_config_classname); luaL_argcheck(L, ud != NULL, pos, "'config' expected"); @@ -953,7 +953,7 @@ lua_check_config(lua_State *L, gint pos) } static struct rspamd_monitored * -lua_check_monitored(lua_State *L, gint pos) +lua_check_monitored(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_monitored_classname); luaL_argcheck(L, ud != NULL, pos, "'monitored' expected"); @@ -961,7 +961,7 @@ lua_check_monitored(lua_State *L, gint pos) } /*** Config functions ***/ -static gint +static int lua_config_get_api_version(lua_State *L) { msg_warn("get_api_version is deprecated, do not use it"); @@ -970,12 +970,12 @@ lua_config_get_api_version(lua_State *L) return 1; } -static gint +static int lua_config_get_module_opt(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *mname, *optname; + const char *mname, *optname; const ucl_object_t *obj; if (cfg) { @@ -1030,15 +1030,15 @@ lua_config_get_resolver(lua_State *L) return 1; } -static gint +static int lua_config_get_all_opt(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *mname; + const char *mname; const ucl_object_t *obj, *cur, *cur_elt; ucl_object_iter_t it = NULL; - gint i; + int i; if (cfg) { mname = luaL_checkstring(L, 2); @@ -1089,7 +1089,7 @@ lua_config_get_all_opt(lua_State *L) struct rspamd_lua_cached_config { lua_State *L; - gint ref; + int ref; }; static void @@ -1100,7 +1100,7 @@ lua_config_ucl_dtor(gpointer p) luaL_unref(cached->L, LUA_REGISTRYINDEX, cached->ref); } -static gint +static int lua_config_get_ucl(lua_State *L) { LUA_TRACE_POINT; @@ -1136,13 +1136,13 @@ lua_config_get_ucl(lua_State *L) } -static gint +static int lua_config_get_classifier(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); struct rspamd_classifier_config *clc = NULL, **pclc = NULL; - const gchar *name; + const char *name; GList *cur; if (cfg) { @@ -1173,17 +1173,17 @@ lua_config_get_classifier(lua_State *L) struct lua_callback_data { uint64_t magic; lua_State *L; - gchar *symbol; + char *symbol; union { - gchar *name; - gint ref; + char *name; + int ref; } callback; gboolean cb_is_ref; /* Dynamic data */ - gint stack_level; - gint order; + int stack_level; + int order; struct rspamd_symcache_dynamic_item *item; }; @@ -1201,13 +1201,13 @@ lua_destroy_cfg_symbol(gpointer ud) } } -static gint +static int lua_config_register_module_option(lua_State *L) { return 0; } -static gint +static int rspamd_compare_order_func(gconstpointer a, gconstpointer b) { const struct lua_callback_data *cb1 = a, *cb2 = b; @@ -1223,7 +1223,7 @@ lua_metric_symbol_callback(struct rspamd_task *task, { struct lua_callback_data *cd = ud; struct rspamd_task **ptask; - gint level = lua_gettop(cd->L), nresults, err_idx, ret; + int level = lua_gettop(cd->L), nresults, err_idx, ret; lua_State *L = cd->L; struct rspamd_symbol_result *s; @@ -1255,10 +1255,10 @@ lua_metric_symbol_callback(struct rspamd_task *task, if (nresults >= 1) { /* Function returned boolean, so maybe we need to insert result? */ - gint res = 0; - gint i; - gdouble flag = 1.0; - gint type; + int res = 0; + int i; + double flag = 1.0; + int type; type = lua_type(cd->L, level + 1); @@ -1280,7 +1280,7 @@ lua_metric_symbol_callback(struct rspamd_task *task, } if (res) { - gint first_opt = 2; + int first_opt = 2; if (lua_type(L, level + 2) == LUA_TNUMBER) { flag = lua_tonumber(L, level + 2); @@ -1294,7 +1294,7 @@ lua_metric_symbol_callback(struct rspamd_task *task, s = rspamd_task_insert_result(task, cd->symbol, flag, NULL); if (s) { - guint last_pos = lua_gettop(L); + unsigned int last_pos = lua_gettop(L); for (i = level + first_opt; i <= last_pos; i++) { if (lua_type(L, i) == LUA_TSTRING) { @@ -1314,7 +1314,7 @@ lua_metric_symbol_callback(struct rspamd_task *task, else if (lua_type(L, i) == LUA_TTABLE) { gsize objlen = rspamd_lua_table_size(L, i); - for (guint j = 1; j <= objlen; j++) { + for (unsigned int j = 1; j <= objlen; j++) { lua_rawgeti(L, i, j); if (lua_type(L, -1) == LUA_TSTRING) { @@ -1419,10 +1419,10 @@ lua_metric_symbol_callback_return(struct thread_entry *thread_entry, int ret) if (nresults >= 1) { /* Function returned boolean, so maybe we need to insert result? */ - gint res = 0; - gint i; - gdouble flag = 1.0; - gint type; + int res = 0; + int i; + double flag = 1.0; + int type; type = lua_type(L, cd->stack_level + 1); @@ -1437,7 +1437,7 @@ lua_metric_symbol_callback_return(struct thread_entry *thread_entry, int ret) } if (res) { - gint first_opt = 2; + int first_opt = 2; if (lua_type(L, cd->stack_level + 2) == LUA_TNUMBER) { flag = lua_tonumber(L, cd->stack_level + 2); @@ -1451,7 +1451,7 @@ lua_metric_symbol_callback_return(struct thread_entry *thread_entry, int ret) s = rspamd_task_insert_result(task, cd->symbol, flag, NULL); if (s) { - guint last_pos = lua_gettop(L); + unsigned int last_pos = lua_gettop(L); for (i = cd->stack_level + first_opt; i <= last_pos; i++) { if (lua_type(L, i) == LUA_TSTRING) { @@ -1471,7 +1471,7 @@ lua_metric_symbol_callback_return(struct thread_entry *thread_entry, int ret) else if (lua_type(L, i) == LUA_TTABLE) { gsize objlen = rspamd_lua_table_size(L, i); - for (guint j = 1; j <= objlen; j++) { + for (unsigned int j = 1; j <= objlen; j++) { lua_rawgeti(L, i, j); if (lua_type(L, -1) == LUA_TSTRING) { @@ -1506,16 +1506,16 @@ lua_metric_symbol_callback_return(struct thread_entry *thread_entry, int ret) } static GArray * -rspamd_process_id_list(const gchar *entries) +rspamd_process_id_list(const char *entries) { - gchar **sym_elts; + char **sym_elts; GArray *ret; sym_elts = g_strsplit_set(entries, ",;", -1); - guint nids = g_strv_length(sym_elts); + unsigned int nids = g_strv_length(sym_elts); ret = g_array_sized_new(FALSE, FALSE, sizeof(uint32_t), nids); - for (guint i = 0; i < nids; i++) { + for (unsigned int i = 0; i < nids; i++) { uint32_t v = rspamd_config_name_to_id(sym_elts[i], strlen(sym_elts[i])); g_array_append_val(ret, v); } @@ -1525,21 +1525,21 @@ rspamd_process_id_list(const gchar *entries) return ret; } -static gint +static int rspamd_register_symbol_fromlua(lua_State *L, struct rspamd_config *cfg, - const gchar *name, - gint ref, - gdouble weight, - gint priority, + const char *name, + int ref, + double weight, + int priority, enum rspamd_symbol_type type, - gint parent, + int parent, GArray *allowed_ids, GArray *forbidden_ids, gboolean optional) { struct lua_callback_data *cd; - gint ret = -1; + int ret = -1; if (priority == 0 && weight < 0) { priority = 1; @@ -1624,12 +1624,12 @@ rspamd_register_symbol_fromlua(lua_State *L, return ret; } -static gint +static int lua_config_register_post_filter(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - gint order = 0, cbref, ret; + int order = 0, cbref, ret; if (cfg) { if (lua_type(L, 3) == LUA_TNUMBER) { @@ -1669,12 +1669,12 @@ lua_config_register_post_filter(lua_State *L) return 1; } -static gint +static int lua_config_register_pre_filter(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - gint order = 0, cbref, ret; + int order = 0, cbref, ret; if (cfg) { if (lua_type(L, 3) == LUA_TNUMBER) { @@ -1714,12 +1714,12 @@ lua_config_register_pre_filter(lua_State *L) return 1; } -static gint +static int lua_config_get_key(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *name; + const char *name; size_t namelen; const ucl_object_t *val; @@ -1740,10 +1740,10 @@ lua_config_get_key(lua_State *L) return 1; } -static guint -lua_parse_symbol_flags(const gchar *str) +static unsigned int +lua_parse_symbol_flags(const char *str) { - guint ret = 0; + unsigned int ret = 0; if (str) { if (strstr(str, "fine") != NULL) { @@ -1790,12 +1790,12 @@ lua_parse_symbol_flags(const gchar *str) return ret; } -static guint -lua_parse_symbol_type(const gchar *str) +static unsigned int +lua_parse_symbol_type(const char *str) { - guint ret = SYMBOL_TYPE_NORMAL; - gchar **vec; - guint i, l; + unsigned int ret = SYMBOL_TYPE_NORMAL; + char **vec; + unsigned int i, l; if (str) { vec = g_strsplit_set(str, ",;", -1); @@ -1837,7 +1837,7 @@ lua_parse_symbol_type(const gchar *str) SYMBOL_TYPE_IDEMPOTENT | SYMBOL_TYPE_CALLBACK; } else { - gint fl = 0; + int fl = 0; fl = lua_parse_symbol_flags(str); @@ -1879,9 +1879,9 @@ enum lua_push_symbol_flags_opts { } while (0) static void -lua_push_symbol_flags(lua_State *L, guint flags, enum lua_push_symbol_flags_opts fl) +lua_push_symbol_flags(lua_State *L, unsigned int flags, enum lua_push_symbol_flags_opts fl) { - guint i = 1; + unsigned int i = 1; if (LUA_SYMOPT_IS_CREATE(fl)) { lua_newtable(L); @@ -1932,12 +1932,12 @@ lua_push_symbol_flags(lua_State *L, guint flags, enum lua_push_symbol_flags_opts } } -static gint +static int lua_config_get_symbol_flags(lua_State *L) { struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *name = luaL_checkstring(L, 2); - guint flags; + const char *name = luaL_checkstring(L, 2); + unsigned int flags; if (cfg && name) { flags = rspamd_symcache_get_symbol_flags(cfg->cache, @@ -1957,17 +1957,17 @@ lua_config_get_symbol_flags(lua_State *L) return 1; } -static gint +static int lua_config_register_symbol(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *name = NULL, *type_str = NULL, - *description = NULL, *group = NULL; + const char *name = NULL, *type_str = NULL, + *description = NULL, *group = NULL; double weight = 0, score = NAN, parent_float = NAN; gboolean one_shot = FALSE; - gint ret = -1, cbref = -1; - guint type = 0, flags = 0; + int ret = -1, cbref = -1; + unsigned int type = 0, flags = 0; int64_t parent = 0, priority = 0, nshots = 0; GArray *allowed_ids = NULL, *forbidden_ids = NULL; GError *err = NULL; @@ -2163,14 +2163,14 @@ lua_config_register_symbol(lua_State *L) return 1; } -static gint +static int lua_config_register_symbols(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - gint i, top, idx, ret = -1; - const gchar *sym; - gdouble weight = 1.0; + int i, top, idx, ret = -1; + const char *sym; + double weight = 1.0; if (lua_gettop(L) < 3) { if (cfg) { @@ -2237,14 +2237,14 @@ lua_config_register_symbols(lua_State *L) return 1; } -static gint +static int lua_config_register_virtual_symbol(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *name; + const char *name; double weight; - gint ret = -1, parent = -1; + int ret = -1, parent = -1; if (cfg) { name = luaL_checkstring(L, 2); @@ -2266,14 +2266,14 @@ lua_config_register_virtual_symbol(lua_State *L) return 1; } -static gint +static int lua_config_register_callback_symbol(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *name = NULL; + const char *name = NULL; double weight; - gint ret = -1, top = 2; + int ret = -1, top = 2; if (cfg) { if (lua_type(L, 2) == LUA_TSTRING) { @@ -2307,14 +2307,14 @@ lua_config_register_callback_symbol(lua_State *L) return 1; } -static gint +static int lua_config_register_callback_symbol_priority(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *name = NULL; + const char *name = NULL; double weight; - gint priority, ret = -1, top = 2; + int priority, ret = -1, top = 2; if (cfg) { if (lua_type(L, 2) == LUA_TSTRING) { @@ -2351,13 +2351,13 @@ lua_config_register_callback_symbol_priority(lua_State *L) } -static gint +static int lua_config_register_dependency(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *parent = NULL, *child = NULL; - gint child_id; + const char *parent = NULL, *child = NULL; + int child_id; if (cfg == NULL) { lua_error(L); @@ -2384,18 +2384,18 @@ lua_config_register_dependency(lua_State *L) return 0; } -static gint +static int lua_config_set_metric_symbol(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *description = NULL, - *group = NULL, *name = NULL, *flags_str = NULL; + const char *description = NULL, + *group = NULL, *name = NULL, *flags_str = NULL; double score; gboolean one_shot = FALSE, one_param = FALSE; GError *err = NULL; - gdouble priority = 0.0; - guint flags = 0; + double priority = 0.0; + unsigned int flags = 0; int64_t nshots = 0; if (cfg) { @@ -2457,7 +2457,7 @@ lua_config_set_metric_symbol(lua_State *L) } rspamd_config_add_symbol(cfg, name, - score, description, group, flags, (guint) priority, nshots); + score, description, group, flags, (unsigned int) priority, nshots); if (lua_type(L, 2) == LUA_TTABLE) { @@ -2486,15 +2486,15 @@ lua_config_set_metric_symbol(lua_State *L) return 0; } -static gint +static int lua_config_set_metric_action(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *name = NULL; + const char *name = NULL; double threshold = NAN; GError *err = NULL; - gdouble priority = 0.0; + double priority = 0.0; ucl_object_t *obj_tbl = NULL; if (cfg) { @@ -2551,12 +2551,12 @@ lua_config_set_metric_action(lua_State *L) return 0; } -static gint +static int lua_config_get_metric_action(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *act_name = luaL_checkstring(L, 2); + const char *act_name = luaL_checkstring(L, 2); struct rspamd_action *act; if (cfg && act_name) { @@ -2593,7 +2593,7 @@ lua_config_actions_cb(struct rspamd_action *act, void *cbd) } } -static gint +static int lua_config_get_all_actions(lua_State *L) { LUA_TRACE_POINT; @@ -2610,13 +2610,13 @@ lua_config_get_all_actions(lua_State *L) return 1; } -static gint +static int lua_config_add_composite(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - gchar *name; - const gchar *expr_str; + char *name; + const char *expr_str; struct rspamd_composite *composite; gboolean ret = FALSE; @@ -2641,15 +2641,15 @@ lua_config_add_composite(lua_State *L) return 1; } -static gint +static int lua_config_newindex(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *name; + const char *name; GArray *allowed_ids = NULL, *forbidden_ids = NULL; - gint id, nshots; - guint flags = 0; + int id, nshots; + unsigned int flags = 0; gboolean optional = FALSE; name = luaL_checkstring(L, 2); @@ -2671,9 +2671,9 @@ lua_config_newindex(lua_State *L) FALSE); } else if (lua_type(L, 3) == LUA_TTABLE) { - guint type = SYMBOL_TYPE_NORMAL, priority = 0; - gint idx; - gdouble weight = 1.0, score = NAN; + unsigned int type = SYMBOL_TYPE_NORMAL, priority = 0; + int idx; + double weight = 1.0, score = NAN; const char *type_str, *group = NULL, *description = NULL; /* @@ -2803,7 +2803,7 @@ lua_config_newindex(lua_State *L) lua_gettable(L, -2); if (lua_type(L, -1) == LUA_TFUNCTION) { - gint condref; + int condref; /* Here we pop function from the stack, so no lua_pop is required */ condref = luaL_ref(L, LUA_REGISTRYINDEX); @@ -2965,14 +2965,14 @@ lua_config_newindex(lua_State *L) return 0; } -static gint +static int lua_config_add_condition(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *sym = luaL_checkstring(L, 2); + const char *sym = luaL_checkstring(L, 2); gboolean ret = FALSE; - gint condref; + int condref; if (cfg && sym && lua_type(L, 3) == LUA_TFUNCTION) { lua_pushvalue(L, 3); @@ -2990,12 +2990,12 @@ lua_config_add_condition(lua_State *L) return 1; } -static gint +static int lua_config_set_peak_cb(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - gint condref; + int condref; if (cfg && lua_type(L, 2) == LUA_TFUNCTION) { lua_pushvalue(L, 2); @@ -3007,7 +3007,7 @@ lua_config_set_peak_cb(lua_State *L) return 0; } -static gint +static int lua_config_enable_symbol(lua_State *L) { struct rspamd_config *cfg = lua_check_config(L, 1); @@ -3022,7 +3022,7 @@ lua_config_enable_symbol(lua_State *L) return 0; } -static gint +static int lua_config_disable_symbol(lua_State *L) { struct rspamd_config *cfg = lua_check_config(L, 1); @@ -3037,14 +3037,14 @@ lua_config_disable_symbol(lua_State *L) return 0; } -static gint +static int lua_config_register_regexp(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); struct rspamd_lua_regexp *re = NULL; rspamd_regexp_t *cache_re; - const gchar *type_str = NULL, *header_str = NULL; + const char *type_str = NULL, *header_str = NULL; gsize header_len = 0; GError *err = NULL; enum rspamd_re_type type = RSPAMD_RE_BODY; @@ -3125,7 +3125,7 @@ lua_config_register_regexp(lua_State *L) return 0; } -static gint +static int lua_config_replace_regexp(lua_State *L) { LUA_TRACE_POINT; @@ -3139,8 +3139,8 @@ lua_config_replace_regexp(lua_State *L) RSPAMD_LUA_PARSE_ARGUMENTS_DEFAULT, "*old_re=U{regexp};*new_re=U{regexp};pcre_only=B", &old_re, &new_re, &pcre_only)) { - gint ret = luaL_error(L, "cannot get parameters list: %s", - err ? err->message : "invalid arguments"); + int ret = luaL_error(L, "cannot get parameters list: %s", + err ? err->message : "invalid arguments"); if (err) { g_error_free(err); @@ -3162,12 +3162,12 @@ lua_config_replace_regexp(lua_State *L) return 0; } -static gint +static int lua_config_register_worker_script(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *worker_type = luaL_checkstring(L, 2), *wtype; + const char *worker_type = luaL_checkstring(L, 2), *wtype; struct rspamd_worker_conf *cf; GList *cur; struct rspamd_worker_lua_script *sc; @@ -3195,7 +3195,7 @@ lua_config_register_worker_script(lua_State *L) return 1; } -static gint +static int lua_config_add_on_load(lua_State *L) { LUA_TRACE_POINT; @@ -3222,15 +3222,15 @@ rspamd_post_init_sc_sort(const struct rspamd_config_cfg_lua_script *pra, return prb->priority - pra->priority; } -static gint +static int lua_config_add_post_init(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); struct rspamd_config_cfg_lua_script *sc; - guint priority = 0; + unsigned int priority = 0; lua_Debug d; - gchar tmp[256], *p; + char tmp[256], *p; if (cfg == NULL || lua_type(L, 2) != LUA_TFUNCTION) { return luaL_error(L, "invalid arguments"); @@ -3270,14 +3270,14 @@ lua_config_add_post_init(lua_State *L) return 0; } -static gint +static int lua_config_add_config_unload(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); struct rspamd_config_cfg_lua_script *sc; lua_Debug d; - gchar tmp[256], *p; + char tmp[256], *p; if (cfg == NULL || lua_type(L, 2) != LUA_TFUNCTION) { return luaL_error(L, "invalid arguments"); @@ -3318,11 +3318,11 @@ static void lua_periodic_callback_error(struct thread_entry *thread, int ret, co struct rspamd_lua_periodic { struct ev_loop *event_loop; struct rspamd_config *cfg; - gchar *lua_src_pos; + char *lua_src_pos; lua_State *L; - gdouble timeout; + double timeout; ev_timer ev; - gint cbref; + int cbref; gboolean need_jitter; ref_entry_t ref; }; @@ -3378,7 +3378,7 @@ lua_periodic_callback_finish(struct thread_entry *thread, int ret) lua_State *L; struct rspamd_lua_periodic *periodic = thread->cd; gboolean plan_more = FALSE; - gdouble timeout = 0.0; + double timeout = 0.0; L = thread->lua_state; @@ -3433,17 +3433,17 @@ lua_periodic_callback_error(struct thread_entry *thread, int ret, const char *ms } -static gint +static int lua_config_add_periodic(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); struct ev_loop *ev_base = lua_check_ev_base(L, 2); - gdouble timeout = lua_tonumber(L, 3); + double timeout = lua_tonumber(L, 3); struct rspamd_lua_periodic *periodic; gboolean need_jitter = FALSE; lua_Debug d; - gchar tmp[256], *p; + char tmp[256], *p; if (cfg == NULL || timeout < 0 || lua_type(L, 4) != LUA_TFUNCTION) { return luaL_error(L, "invalid arguments"); @@ -3497,12 +3497,12 @@ lua_config_add_periodic(lua_State *L) return 0; } -static gint +static int lua_config_get_symbols_count(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - guint res = 0; + unsigned int res = 0; if (cfg != NULL) { res = rspamd_symcache_stats_symbols_count(cfg->cache); @@ -3516,7 +3516,7 @@ lua_config_get_symbols_count(lua_State *L) return 1; } -static gint +static int lua_config_get_symbols_cksum(lua_State *L) { LUA_TRACE_POINT; @@ -3537,7 +3537,7 @@ lua_config_get_symbols_cksum(lua_State *L) return 1; } -static gint +static int lua_config_get_symbols_counters(lua_State *L) { LUA_TRACE_POINT; @@ -3567,10 +3567,10 @@ lua_metric_symbol_inserter(gpointer k, gpointer v, gpointer ud) { struct lua_metric_symbols_cbdata *cbd = (struct lua_metric_symbols_cbdata *) ud; lua_State *L; - const gchar *sym = k; + const char *sym = k; struct rspamd_symbol *s = (struct rspamd_symbol *) v; struct rspamd_symbols_group *gr; - gint i; + int i; L = cbd->L; @@ -3611,13 +3611,13 @@ lua_metric_symbol_inserter(gpointer k, gpointer v, gpointer ud) } if (s->cache_item) { - guint sflags = rspamd_symcache_get_symbol_flags(cbd->cfg->cache, sym); + unsigned int sflags = rspamd_symcache_get_symbol_flags(cbd->cfg->cache, sym); lua_push_symbol_flags(L, sflags, LUA_SYMOPT_FLAG_USE_MAP); - guint nids; - const guint *allowed_ids = rspamd_symcache_get_allowed_settings_ids(cbd->cfg->cache, - sym, &nids); + unsigned int nids; + const unsigned int *allowed_ids = rspamd_symcache_get_allowed_settings_ids(cbd->cfg->cache, + sym, &nids); if (allowed_ids && nids > 0) { lua_createtable(L, nids, 0); @@ -3630,7 +3630,7 @@ lua_metric_symbol_inserter(gpointer k, gpointer v, gpointer ud) lua_setfield(L, -2, "allowed_ids"); } - const guint *forbidden_ids = rspamd_symcache_get_forbidden_settings_ids( + const unsigned int *forbidden_ids = rspamd_symcache_get_forbidden_settings_ids( cbd->cfg->cache, sym, &nids); @@ -3680,7 +3680,7 @@ lua_metric_symbol_inserter(gpointer k, gpointer v, gpointer ud) } } -static gint +static int lua_config_get_symbols(lua_State *L) { LUA_TRACE_POINT; @@ -3705,12 +3705,12 @@ lua_config_get_symbols(lua_State *L) return 1; } -static gint +static int lua_config_get_symbol(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *sym_name = luaL_checkstring(L, 2); + const char *sym_name = luaL_checkstring(L, 2); if (cfg != NULL && sym_name != NULL) { struct lua_metric_symbols_cbdata cbd; @@ -3734,12 +3734,12 @@ lua_config_get_symbol(lua_State *L) return 1; } -static gint +static int lua_config_get_symbol_callback(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *sym = luaL_checkstring(L, 2); + const char *sym = luaL_checkstring(L, 2); struct rspamd_abstract_callback_data *abs_cbdata; struct lua_callback_data *cbd; @@ -3767,12 +3767,12 @@ lua_config_get_symbol_callback(lua_State *L) return 1; } -static gint +static int lua_config_set_symbol_callback(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *sym = luaL_checkstring(L, 2); + const char *sym = luaL_checkstring(L, 2); struct rspamd_abstract_callback_data *abs_cbdata; struct lua_callback_data *cbd; @@ -3804,14 +3804,14 @@ lua_config_set_symbol_callback(lua_State *L) return 1; } -static gint +static int lua_config_get_symbol_stat(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *sym = luaL_checkstring(L, 2); - gdouble freq, stddev, tm; - guint hits; + const char *sym = luaL_checkstring(L, 2); + double freq, stddev, tm; + unsigned int hits; if (cfg != NULL && sym != NULL) { if (!rspamd_symcache_stat_symbol(cfg->cache, sym, &freq, @@ -3841,12 +3841,12 @@ lua_config_get_symbol_stat(lua_State *L) return 1; } -static gint +static int lua_config_get_symbol_parent(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *sym = luaL_checkstring(L, 2), *parent; + const char *sym = luaL_checkstring(L, 2), *parent; if (cfg != NULL && sym != NULL) { parent = rspamd_symcache_get_parent(cfg->cache, sym); @@ -3865,12 +3865,12 @@ lua_config_get_symbol_parent(lua_State *L) return 1; } -static gint +static int lua_config_get_group_symbols(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *gr_name = luaL_checkstring(L, 2); + const char *gr_name = luaL_checkstring(L, 2); if (cfg != NULL && gr_name != NULL) { struct rspamd_symbols_group *group; @@ -3881,7 +3881,7 @@ lua_config_get_group_symbols(lua_State *L) lua_pushnil(L); } else { - guint i = 1; + unsigned int i = 1; gpointer k, v; GHashTableIter it; @@ -3902,7 +3902,7 @@ lua_config_get_group_symbols(lua_State *L) return 1; } -static gint +static int lua_config_get_groups(lua_State *L) { LUA_TRACE_POINT; @@ -3949,7 +3949,7 @@ lua_config_get_groups(lua_State *L) return 1; } -static gint +static int lua_config_register_finish_script(lua_State *L) { LUA_TRACE_POINT; @@ -3993,12 +3993,12 @@ rspamd_lua_config_check_settings_symbols_object(const ucl_object_t *obj) return false; } -static gint +static int lua_config_register_settings_id(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *settings_name = luaL_checkstring(L, 2); + const char *settings_name = luaL_checkstring(L, 2); if (cfg != NULL && settings_name) { ucl_object_t *sym_enabled, *sym_disabled; @@ -4023,7 +4023,7 @@ lua_config_register_settings_id(lua_State *L) /* Check policy */ if (lua_isstring(L, 5)) { - const gchar *policy_str = lua_tostring(L, 5); + const char *policy_str = lua_tostring(L, 5); if (strcmp(policy_str, "default") == 0) { policy = RSPAMD_SETTINGS_POLICY_DEFAULT; @@ -4063,13 +4063,13 @@ lua_config_register_settings_id(lua_State *L) return 0; } -static gint +static int lua_config_register_monitored(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); struct rspamd_monitored *m, **pm; - const gchar *url, *type; + const char *url, *type; ucl_object_t *params = NULL; url = lua_tostring(L, 2); @@ -4115,13 +4115,13 @@ lua_config_register_monitored(lua_State *L) return 1; } -static gint +static int lua_config_add_doc(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg; - const gchar *path = NULL, *option, *doc_string; - const gchar *type_str = NULL, *default_value = NULL; + const char *path = NULL, *option, *doc_string; + const char *type_str = NULL, *default_value = NULL; ucl_type_t type = UCL_NULL; gboolean required = FALSE; GError *err = NULL; @@ -4165,12 +4165,12 @@ lua_config_add_doc(lua_State *L) return 0; } -static gint +static int lua_config_add_example(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg; - const gchar *path = NULL, *option, *doc_string, *example; + const char *path = NULL, *option, *doc_string, *example; gsize example_len; cfg = lua_check_config(L, 1); @@ -4195,7 +4195,7 @@ lua_config_add_example(lua_State *L) return 0; } -static gint +static int lua_config_get_cpu_flags(lua_State *L) { LUA_TRACE_POINT; @@ -4249,7 +4249,7 @@ lua_config_get_cpu_flags(lua_State *L) return 1; } -static gint +static int lua_config_has_torch(lua_State *L) { msg_warn("use of the obsoleted `has_torch` function"); @@ -4258,7 +4258,7 @@ lua_config_has_torch(lua_State *L) return 1; } -static gint +static int lua_config_experimental_enabled(lua_State *L) { LUA_TRACE_POINT; @@ -4276,7 +4276,7 @@ lua_config_experimental_enabled(lua_State *L) struct rspamd_lua_include_trace_cbdata { lua_State *L; - gint cbref; + int cbref; }; static void @@ -4289,7 +4289,7 @@ lua_include_trace_cb(struct ucl_parser *parser, { struct rspamd_lua_include_trace_cbdata *cbdata = (struct rspamd_lua_include_trace_cbdata *) user_data; - gint err_idx; + int err_idx; lua_State *L; L = cbdata->L; @@ -4333,11 +4333,11 @@ lua_include_trace_cb(struct ucl_parser *parser, lua_pop(L, 1); \ } while (0) -static gint +static int lua_config_load_ucl(lua_State *L) { struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *filename; + const char *filename; GHashTable *paths = g_hash_table_new_full(rspamd_str_hash, rspamd_str_equal, NULL, g_free); GError *err = NULL; @@ -4415,7 +4415,7 @@ lua_config_load_ucl(lua_State *L) #undef IDX_TO_HASH -static gint +static int lua_config_parse_rcl(lua_State *L) { LUA_TRACE_POINT; @@ -4460,7 +4460,7 @@ lua_config_parse_rcl(lua_State *L) return 1; } -static gint +static int lua_config_init_modules(lua_State *L) { LUA_TRACE_POINT; @@ -4477,14 +4477,14 @@ lua_config_init_modules(lua_State *L) return 1; } -static gint +static int lua_config_init_subsystem(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *subsystem = luaL_checkstring(L, 2); - gchar **parts; - guint nparts, i; + const char *subsystem = luaL_checkstring(L, 2); + char **parts; + unsigned int nparts, i; if (cfg != NULL && subsystem != NULL) { parts = g_strsplit_set(subsystem, ";,", -1); @@ -4540,16 +4540,16 @@ lua_config_init_subsystem(lua_State *L) return 0; } -static gint +static int lua_config_register_re_selector(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *name = luaL_checkstring(L, 2); - const gchar *selector_str = luaL_checkstring(L, 3); - const gchar *delimiter = ""; + const char *name = luaL_checkstring(L, 2); + const char *selector_str = luaL_checkstring(L, 3); + const char *delimiter = ""; bool flatten = false; - gint top = lua_gettop(L); + int top = lua_gettop(L); bool res = false; if (cfg && name && selector_str) { @@ -4581,7 +4581,7 @@ lua_config_register_re_selector(lua_State *L) lua_typename(L, lua_type(L, -1))); } else { - gint err_idx, ret; + int err_idx, ret; struct rspamd_config **pcfg; lua_pushcfunction(L, &rspamd_lua_traceback); @@ -4635,7 +4635,7 @@ lua_config_register_re_selector(lua_State *L) return 1; } -static gint +static int lua_config_get_tld_path(lua_State *L) { LUA_TRACE_POINT; @@ -4651,7 +4651,7 @@ lua_config_get_tld_path(lua_State *L) return 1; } -static gint +static int lua_config_get_dns_max_requests(lua_State *L) { LUA_TRACE_POINT; @@ -4667,7 +4667,7 @@ lua_config_get_dns_max_requests(lua_State *L) return 1; } -static gint +static int lua_config_get_dns_timeout(lua_State *L) { LUA_TRACE_POINT; @@ -4683,7 +4683,7 @@ lua_config_get_dns_timeout(lua_State *L) return 1; } -static gint +static int lua_monitored_alive(lua_State *L) { LUA_TRACE_POINT; @@ -4699,7 +4699,7 @@ lua_monitored_alive(lua_State *L) return 1; } -static gint +static int lua_monitored_offline(lua_State *L) { LUA_TRACE_POINT; @@ -4715,7 +4715,7 @@ lua_monitored_offline(lua_State *L) return 1; } -static gint +static int lua_monitored_total_offline(lua_State *L) { LUA_TRACE_POINT; @@ -4731,7 +4731,7 @@ lua_monitored_total_offline(lua_State *L) return 1; } -static gint +static int lua_monitored_latency(lua_State *L) { LUA_TRACE_POINT; diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c index 35f5986f1..bad7d7024 100644 --- a/src/lua/lua_cryptobox.c +++ b/src/lua/lua_cryptobox.c @@ -204,7 +204,7 @@ static const struct luaL_reg cryptoboxsecretboxlib_m[] = { }; struct rspamd_lua_cryptobox_secretbox { - guchar sk[crypto_secretbox_KEYBYTES]; + unsigned char sk[crypto_secretbox_KEYBYTES]; }; static struct rspamd_cryptobox_pubkey * @@ -260,15 +260,15 @@ lua_check_cryptobox_secretbox(lua_State *L, int pos) * @param {string} alg optional 'default' or 'nist' for curve25519/nistp256 keys * @return {cryptobox_pubkey} new public key */ -static gint +static int lua_cryptobox_pubkey_load(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_pubkey *pkey = NULL, **ppkey; - const gchar *filename, *arg; - gint type = RSPAMD_KEYPAIR_SIGN; - gint alg = RSPAMD_CRYPTOBOX_MODE_25519; - guchar *map; + const char *filename, *arg; + int type = RSPAMD_KEYPAIR_SIGN; + int alg = RSPAMD_CRYPTOBOX_MODE_25519; + unsigned char *map; gsize len; filename = luaL_checkstring(L, 1); @@ -336,15 +336,15 @@ lua_cryptobox_pubkey_load(lua_State *L) * @param {string} alg optional 'default' or 'nist' for curve25519/nistp256 keys * @return {cryptobox_pubkey} new public key */ -static gint +static int lua_cryptobox_pubkey_create(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_pubkey *pkey = NULL, **ppkey; - const gchar *buf, *arg; + const char *buf, *arg; gsize len; - gint type = RSPAMD_KEYPAIR_SIGN; - gint alg = RSPAMD_CRYPTOBOX_MODE_25519; + int type = RSPAMD_KEYPAIR_SIGN; + int alg = RSPAMD_CRYPTOBOX_MODE_25519; buf = luaL_checklstring(L, 1, &len); if (buf != NULL) { @@ -390,7 +390,7 @@ lua_cryptobox_pubkey_create(lua_State *L) return 1; } -static gint +static int lua_cryptobox_pubkey_gc(lua_State *L) { LUA_TRACE_POINT; @@ -409,12 +409,12 @@ lua_cryptobox_pubkey_gc(lua_State *L) * @param {string} file filename to load * @return {cryptobox_keypair} new keypair */ -static gint +static int lua_cryptobox_keypair_load(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_keypair *kp, **pkp; - const gchar *buf; + const char *buf; gsize len; struct ucl_parser *parser; ucl_object_t *obj; @@ -480,7 +480,7 @@ lua_cryptobox_keypair_load(lua_State *L) * @param {string} alg algorithm of keypair: 'curve25519' (default) or 'nist' * @return {cryptobox_keypair} new keypair */ -static gint +static int lua_cryptobox_keypair_create(lua_State *L) { LUA_TRACE_POINT; @@ -489,7 +489,7 @@ lua_cryptobox_keypair_create(lua_State *L) enum rspamd_cryptobox_mode alg = RSPAMD_CRYPTOBOX_MODE_25519; if (lua_isstring(L, 1)) { - const gchar *str = lua_tostring(L, 1); + const char *str = lua_tostring(L, 1); if (strcmp(str, "sign") == 0) { type = RSPAMD_KEYPAIR_SIGN; @@ -503,7 +503,7 @@ lua_cryptobox_keypair_create(lua_State *L) } if (lua_isstring(L, 2)) { - const gchar *str = lua_tostring(L, 2); + const char *str = lua_tostring(L, 2); if (strcmp(str, "nist") == 0 || strcmp(str, "openssl") == 0) { alg = RSPAMD_CRYPTOBOX_MODE_NIST; @@ -525,7 +525,7 @@ lua_cryptobox_keypair_create(lua_State *L) return 1; } -static gint +static int lua_cryptobox_keypair_gc(lua_State *L) { LUA_TRACE_POINT; @@ -542,14 +542,14 @@ lua_cryptobox_keypair_gc(lua_State *L) * @method keypair:totable([hex=false]]) * Converts keypair to table (not very safe due to memory leftovers) */ -static gint +static int lua_cryptobox_keypair_totable(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_keypair *kp = lua_check_cryptobox_keypair(L, 1); ucl_object_t *obj; gboolean hex = FALSE; - gint ret = 1; + int ret = 1; if (kp != NULL) { @@ -573,7 +573,7 @@ lua_cryptobox_keypair_totable(lua_State *L) * Returns type of keypair as a string: 'encryption' or 'sign' * @return {string} type of keypair as a string */ -static gint +static int lua_cryptobox_keypair_get_type(lua_State *L) { LUA_TRACE_POINT; @@ -599,7 +599,7 @@ lua_cryptobox_keypair_get_type(lua_State *L) * Returns algorithm of keypair as a string: 'encryption' or 'sign' * @return {string} type of keypair as a string */ -static gint +static int lua_cryptobox_keypair_get_alg(lua_State *L) { LUA_TRACE_POINT; @@ -625,14 +625,14 @@ lua_cryptobox_keypair_get_alg(lua_State *L) * Returns pubkey for a specific keypair * @return {rspamd_pubkey} pubkey for a keypair */ -static gint +static int lua_cryptobox_keypair_get_pk(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_keypair *kp = lua_check_cryptobox_keypair(L, 1); struct rspamd_cryptobox_pubkey *pk, **ppk; - const guchar *data; - guint dlen; + const unsigned char *data; + unsigned int dlen; if (kp) { data = rspamd_keypair_component(kp, RSPAMD_KEYPAIR_COMPONENT_PK, &dlen); @@ -659,12 +659,12 @@ lua_cryptobox_keypair_get_pk(lua_State *L) * @param {string} file filename to load * @return {cryptobox_signature} new signature */ -static gint +static int lua_cryptobox_signature_load(lua_State *L) { LUA_TRACE_POINT; rspamd_fstring_t *sig, **psig; - const gchar *filename; + const char *filename; gpointer data; int fd; struct stat st; @@ -687,7 +687,7 @@ lua_cryptobox_signature_load(lua_State *L) } else { if (lua_isstring(L, 2)) { - const gchar *str = lua_tostring(L, 2); + const char *str = lua_tostring(L, 2); if (strcmp(str, "nist") == 0 || strcmp(str, "openssl") == 0) { alg = RSPAMD_CRYPTOBOX_MODE_NIST; @@ -733,13 +733,13 @@ lua_cryptobox_signature_load(lua_State *L) * @param {string} file filename to use * @return {boolean} true if signature has been saved */ -static gint +static int lua_cryptobox_signature_save(lua_State *L) { LUA_TRACE_POINT; rspamd_fstring_t *sig; - gint fd, flags; - const gchar *filename; + int fd, flags; + const char *filename; gboolean forced = FALSE, res = TRUE; sig = lua_check_cryptobox_sign(L, 1); @@ -797,13 +797,13 @@ lua_cryptobox_signature_save(lua_State *L) * @param {data} raw signature data * @return {cryptobox_signature} signature object */ -static gint +static int lua_cryptobox_signature_create(lua_State *L) { LUA_TRACE_POINT; rspamd_fstring_t *sig, **psig; struct rspamd_lua_text *t; - const gchar *data; + const char *data; gsize dlen; if (lua_isuserdata(L, 1)) { @@ -840,12 +840,12 @@ lua_cryptobox_signature_create(lua_State *L) * Return hex encoded signature string * @return {string} raw value of signature */ -static gint +static int lua_cryptobox_signature_hex(lua_State *L) { LUA_TRACE_POINT; rspamd_fstring_t *sig = lua_check_cryptobox_sign(L, 1); - gchar *encoded; + char *encoded; if (sig) { encoded = rspamd_encode_hex(sig->str, sig->len); @@ -865,12 +865,12 @@ lua_cryptobox_signature_hex(lua_State *L) * @param {string} b32type base32 type (default, bleach, rfc) * @return {string} raw value of signature */ -static gint +static int lua_cryptobox_signature_base32(lua_State *L) { LUA_TRACE_POINT; rspamd_fstring_t *sig = lua_check_cryptobox_sign(L, 1); - gchar *encoded; + char *encoded; enum rspamd_base32_type btype = RSPAMD_BASE32_DEFAULT; if (lua_type(L, 2) == LUA_TSTRING) { @@ -898,13 +898,13 @@ lua_cryptobox_signature_base32(lua_State *L) * Return base64 encoded signature string * @return {string} raw value of signature */ -static gint +static int lua_cryptobox_signature_base64(lua_State *L) { LUA_TRACE_POINT; rspamd_fstring_t *sig = lua_check_cryptobox_sign(L, 1); gsize dlen; - gchar *encoded; + char *encoded; if (sig) { encoded = rspamd_encode_base64(sig->str, sig->len, 0, &dlen); @@ -923,7 +923,7 @@ lua_cryptobox_signature_base64(lua_State *L) * Return raw signature string * @return {string} raw value of signature */ -static gint +static int lua_cryptobox_signature_bin(lua_State *L) { LUA_TRACE_POINT; @@ -939,7 +939,7 @@ lua_cryptobox_signature_bin(lua_State *L) return 1; } -static gint +static int lua_cryptobox_signature_gc(lua_State *L) { LUA_TRACE_POINT; @@ -1011,7 +1011,7 @@ lua_cryptobox_hash_dtor(struct rspamd_lua_cryptobox_hash *h) static inline void rspamd_lua_hash_init_default(struct rspamd_lua_cryptobox_hash *h, - const gchar *key, gsize keylen) + const char *key, gsize keylen) { h->type = LUA_CRYPTOBOX_HASH_BLAKE2; if (posix_memalign((void **) &h->content.h, @@ -1044,7 +1044,7 @@ rspamd_lua_ssl_hash_create(struct rspamd_lua_cryptobox_hash *h, const EVP_MD *ht static void rspamd_lua_ssl_hmac_create(struct rspamd_lua_cryptobox_hash *h, const EVP_MD *htype, - const gchar *key, gsize keylen, + const char *key, gsize keylen, bool insecure) { h->type = LUA_CRYPTOBOX_HASH_HMAC; @@ -1070,7 +1070,7 @@ rspamd_lua_ssl_hmac_create(struct rspamd_lua_cryptobox_hash *h, const EVP_MD *ht } static struct rspamd_lua_cryptobox_hash * -rspamd_lua_hash_create(const gchar *type, const gchar *key, gsize keylen) +rspamd_lua_hash_create(const char *type, const char *key, gsize keylen) { struct rspamd_lua_cryptobox_hash *h; @@ -1177,12 +1177,12 @@ rspamd_lua_hash_create(const gchar *type, const gchar *key, gsize keylen) * @param {string} data optional string to hash * @return {cryptobox_hash} hash object */ -static gint +static int lua_cryptobox_hash_create(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_cryptobox_hash *h, **ph; - const gchar *s = NULL; + const char *s = NULL; struct rspamd_lua_text *t; gsize len = 0; @@ -1221,12 +1221,12 @@ lua_cryptobox_hash_create(lua_State *L) * @param {string} string initial data * @return {cryptobox_hash} hash object */ -static gint +static int lua_cryptobox_hash_create_specific(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_cryptobox_hash *h, **ph; - const gchar *s = NULL, *type = luaL_checkstring(L, 1); + const char *s = NULL, *type = luaL_checkstring(L, 1); gsize len = 0; struct rspamd_lua_text *t; @@ -1272,12 +1272,12 @@ lua_cryptobox_hash_create_specific(lua_State *L) * @param {string} key key * @return {cryptobox_hash} hash object */ -static gint +static int lua_cryptobox_hash_create_keyed(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_cryptobox_hash *h, **ph; - const gchar *key, *s = NULL; + const char *key, *s = NULL; struct rspamd_lua_text *t; gsize len = 0; gsize keylen; @@ -1323,12 +1323,12 @@ lua_cryptobox_hash_create_keyed(lua_State *L) * @param {string} key key * @return {cryptobox_hash} hash object */ -static gint +static int lua_cryptobox_hash_create_specific_keyed(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_cryptobox_hash *h, **ph; - const gchar *key, *s = NULL, *type = luaL_checkstring(L, 2); + const char *key, *s = NULL, *type = luaL_checkstring(L, 2); struct rspamd_lua_text *t; gsize len = 0; gsize keylen; @@ -1378,12 +1378,12 @@ lua_cryptobox_hash_create_specific_keyed(lua_State *L) * Updates hash with the specified data (hash should not be finalized using `hex` or `bin` methods) * @param {string} data data to hash */ -static gint +static int lua_cryptobox_hash_update(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_cryptobox_hash *h = lua_check_cryptobox_hash(L, 1), **ph; - const gchar *data; + const char *data; struct rspamd_lua_text *t; gsize len; @@ -1436,7 +1436,7 @@ lua_cryptobox_hash_update(lua_State *L) * @method cryptobox_hash:reset() * Resets hash to the initial state */ -static gint +static int lua_cryptobox_hash_reset(lua_State *L) { LUA_TRACE_POINT; @@ -1501,8 +1501,8 @@ static void lua_cryptobox_hash_finish(struct rspamd_lua_cryptobox_hash *h) { uint64_t ll; - guchar out[rspamd_cryptobox_HASHBYTES]; - guint ssl_outlen = sizeof(out); + unsigned char out[rspamd_cryptobox_HASHBYTES]; + unsigned int ssl_outlen = sizeof(out); switch (h->type) { case LUA_CRYPTOBOX_HASH_BLAKE2: @@ -1541,13 +1541,13 @@ lua_cryptobox_hash_finish(struct rspamd_lua_cryptobox_hash *h) * Finalizes hash and return it as hex string * @return {string} hex value of hash */ -static gint +static int lua_cryptobox_hash_hex(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_cryptobox_hash *h = lua_check_cryptobox_hash(L, 1); - guchar out_hex[rspamd_cryptobox_HASHBYTES * 2 + 1], *r; - guint dlen; + unsigned char out_hex[rspamd_cryptobox_HASHBYTES * 2 + 1], *r; + unsigned int dlen; if (h) { if (!h->is_finished) { @@ -1559,7 +1559,7 @@ lua_cryptobox_hash_hex(lua_State *L) dlen = h->out_len; if (lua_isnumber(L, 2)) { - guint lim = lua_tonumber(L, 2); + unsigned int lim = lua_tonumber(L, 2); if (lim < dlen) { r += dlen - lim; @@ -1583,13 +1583,13 @@ lua_cryptobox_hash_hex(lua_State *L) * @param {string} b32type base32 type (default, bleach, rfc) * @return {string} base32 value of hash */ -static gint +static int lua_cryptobox_hash_base32(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_cryptobox_hash *h = lua_check_cryptobox_hash(L, 1); - guchar out_b32[rspamd_cryptobox_HASHBYTES * 2], *r; - guint dlen; + unsigned char out_b32[rspamd_cryptobox_HASHBYTES * 2], *r; + unsigned int dlen; if (h) { enum rspamd_base32_type btype = RSPAMD_BASE32_DEFAULT; @@ -1611,7 +1611,7 @@ lua_cryptobox_hash_base32(lua_State *L) dlen = h->out_len; if (lua_isnumber(L, 2)) { - guint lim = lua_tonumber(L, 2); + unsigned int lim = lua_tonumber(L, 2); if (lim < dlen) { r += dlen - lim; @@ -1634,14 +1634,14 @@ lua_cryptobox_hash_base32(lua_State *L) * Finalizes hash and return it as base64 string * @return {string} base64 value of hash */ -static gint +static int lua_cryptobox_hash_base64(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_cryptobox_hash *h = lua_check_cryptobox_hash(L, 1); - guchar *b64, *r; + unsigned char *b64, *r; gsize len; - guint dlen; + unsigned int dlen; if (h) { if (!h->is_finished) { @@ -1652,7 +1652,7 @@ lua_cryptobox_hash_base64(lua_State *L) dlen = h->out_len; if (lua_isnumber(L, 2)) { - guint lim = lua_tonumber(L, 2); + unsigned int lim = lua_tonumber(L, 2); if (lim < dlen) { r += dlen - lim; @@ -1676,13 +1676,13 @@ lua_cryptobox_hash_base64(lua_State *L) * Finalizes hash and return it as raw string * @return {string} raw value of hash */ -static gint +static int lua_cryptobox_hash_bin(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_cryptobox_hash *h = lua_check_cryptobox_hash(L, 1); - guchar *r; - guint dlen; + unsigned char *r; + unsigned int dlen; if (h) { if (!h->is_finished) { @@ -1693,7 +1693,7 @@ lua_cryptobox_hash_bin(lua_State *L) dlen = h->out_len; if (lua_isnumber(L, 2)) { - guint lim = lua_tonumber(L, 2); + unsigned int lim = lua_tonumber(L, 2); if (lim < dlen) { r += dlen - lim; @@ -1711,7 +1711,7 @@ lua_cryptobox_hash_bin(lua_State *L) return 1; } -static gint +static int lua_cryptobox_hash_gc(lua_State *L) { LUA_TRACE_POINT; @@ -1730,17 +1730,17 @@ lua_cryptobox_hash_gc(lua_State *L) * @param {string} data data to check signature against * @return {boolean} `true` - if string matches cryptobox signature */ -static gint +static int lua_cryptobox_verify_memory(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_pubkey *pk; rspamd_fstring_t *signature; struct rspamd_lua_text *t; - const gchar *data; + const char *data; enum rspamd_cryptobox_mode alg = RSPAMD_CRYPTOBOX_MODE_25519; gsize len; - gint ret; + int ret; pk = lua_check_cryptobox_pubkey(L, 1); signature = lua_check_cryptobox_sign(L, 2); @@ -1760,7 +1760,7 @@ lua_cryptobox_verify_memory(lua_State *L) } if (lua_isstring(L, 4)) { - const gchar *str = lua_tostring(L, 4); + const char *str = lua_tostring(L, 4); if (strcmp(str, "nist") == 0 || strcmp(str, "openssl") == 0) { alg = RSPAMD_CRYPTOBOX_MODE_NIST; @@ -1799,24 +1799,24 @@ lua_cryptobox_verify_memory(lua_State *L) * @param {string} file to load data from * @return {boolean} `true` - if string matches cryptobox signature */ -static gint +static int lua_cryptobox_verify_file(lua_State *L) { LUA_TRACE_POINT; - const gchar *fname; + const char *fname; struct rspamd_cryptobox_pubkey *pk; rspamd_fstring_t *signature; - guchar *map = NULL; + unsigned char *map = NULL; enum rspamd_cryptobox_mode alg = RSPAMD_CRYPTOBOX_MODE_25519; gsize len; - gint ret; + int ret; pk = lua_check_cryptobox_pubkey(L, 1); signature = lua_check_cryptobox_sign(L, 2); fname = luaL_checkstring(L, 3); if (lua_isstring(L, 4)) { - const gchar *str = lua_tostring(L, 4); + const char *str = lua_tostring(L, 4); if (strcmp(str, "nist") == 0 || strcmp(str, "openssl") == 0) { alg = RSPAMD_CRYPTOBOX_MODE_NIST; @@ -1865,12 +1865,12 @@ lua_cryptobox_verify_file(lua_State *L) * @param {string} data * @return {cryptobox_signature} signature object */ -static gint +static int lua_cryptobox_sign_memory(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_keypair *kp; - const gchar *data; + const char *data; struct rspamd_lua_text *t; gsize len = 0; rspamd_fstring_t *sig, **psig; @@ -1918,13 +1918,13 @@ lua_cryptobox_sign_memory(lua_State *L) * @param {string} filename * @return {cryptobox_signature} signature object */ -static gint +static int lua_cryptobox_sign_file(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_keypair *kp; - const gchar *filename; - gchar *data; + const char *filename; + char *data; gsize len = 0; rspamd_fstring_t *sig, **psig; @@ -1967,14 +1967,14 @@ lua_cryptobox_sign_file(lua_State *L) * @param {string|text} data * @return {rspamd_text} encrypted text */ -static gint +static int lua_cryptobox_encrypt_memory(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_keypair *kp = NULL; struct rspamd_cryptobox_pubkey *pk = NULL; - const gchar *data; - guchar *out = NULL; + const char *data; + unsigned char *out = NULL; struct rspamd_lua_text *t, *res; gsize len = 0, outlen = 0; GError *err = NULL; @@ -1989,7 +1989,7 @@ lua_cryptobox_encrypt_memory(lua_State *L) } } else if (lua_type(L, 1) == LUA_TSTRING) { - const gchar *b32; + const char *b32; gsize blen; b32 = lua_tolstring(L, 1, &blen); @@ -2019,7 +2019,7 @@ lua_cryptobox_encrypt_memory(lua_State *L) if (kp) { if (!rspamd_keypair_encrypt(kp, data, len, &out, &outlen, &err)) { - gint ret = luaL_error(L, "cannot encrypt data: %s", err->message); + int ret = luaL_error(L, "cannot encrypt data: %s", err->message); g_error_free(err); if (owned_pk) { @@ -2031,7 +2031,7 @@ lua_cryptobox_encrypt_memory(lua_State *L) } else { if (!rspamd_pubkey_encrypt(pk, data, len, &out, &outlen, &err)) { - gint ret = luaL_error(L, "cannot encrypt data: %s", err->message); + int ret = luaL_error(L, "cannot encrypt data: %s", err->message); g_error_free(err); if (owned_pk) { @@ -2069,15 +2069,15 @@ err: * @param {string} filename * @return {rspamd_text} encrypted text */ -static gint +static int lua_cryptobox_encrypt_file(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_keypair *kp = NULL; struct rspamd_cryptobox_pubkey *pk = NULL; - const gchar *filename; - gchar *data = NULL; - guchar *out = NULL; + const char *filename; + char *data = NULL; + unsigned char *out = NULL; struct rspamd_lua_text *res; gsize len = 0, outlen = 0; GError *err = NULL; @@ -2092,7 +2092,7 @@ lua_cryptobox_encrypt_file(lua_State *L) } } else if (lua_type(L, 1) == LUA_TSTRING) { - const gchar *b32; + const char *b32; gsize blen; b32 = lua_tolstring(L, 1, &blen); @@ -2110,8 +2110,8 @@ lua_cryptobox_encrypt_file(lua_State *L) if (kp) { if (!rspamd_keypair_encrypt(kp, data, len, &out, &outlen, &err)) { - gint ret = luaL_error(L, "cannot encrypt file %s: %s", filename, - err->message); + int ret = luaL_error(L, "cannot encrypt file %s: %s", filename, + err->message); g_error_free(err); munmap(data, len); if (own_pk) { @@ -2123,8 +2123,8 @@ lua_cryptobox_encrypt_file(lua_State *L) } else if (pk) { if (!rspamd_pubkey_encrypt(pk, data, len, &out, &outlen, &err)) { - gint ret = luaL_error(L, "cannot encrypt file %s: %s", filename, - err->message); + int ret = luaL_error(L, "cannot encrypt file %s: %s", filename, + err->message); g_error_free(err); munmap(data, len); @@ -2165,13 +2165,13 @@ err: * @param {string} data * @return status,{rspamd_text}|error status is boolean variable followed by either unencrypted data or an error message */ -static gint +static int lua_cryptobox_decrypt_memory(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_keypair *kp; - const gchar *data; - guchar *out; + const char *data; + unsigned char *out; struct rspamd_lua_text *t, *res; gsize len = 0, outlen; GError *err = NULL; @@ -2221,14 +2221,14 @@ lua_cryptobox_decrypt_memory(lua_State *L) * @param {string} filename * @return status,{rspamd_text}|error status is boolean variable followed by either unencrypted data or an error message */ -static gint +static int lua_cryptobox_decrypt_file(lua_State *L) { LUA_TRACE_POINT; struct rspamd_cryptobox_keypair *kp; - const gchar *filename; - gchar *data; - guchar *out; + const char *filename; + char *data; + unsigned char *out; struct rspamd_lua_text *res; gsize len = 0, outlen; GError *err = NULL; @@ -2280,19 +2280,19 @@ lua_cryptobox_decrypt_file(lua_State *L) * @param {string} secret_cookie secret cookie as a string for up to 31 character * @return {string} e function value for this sk and cookie */ -static gint +static int lua_cryptobox_encrypt_cookie(lua_State *L) { - guchar aes_block[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE], *blk; - guchar padded_cookie[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE]; - guchar nonce[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE]; - guchar aes_key[RSPAMD_CRYPTOBOX_AES_KEYSIZE]; - guchar result[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE * 2]; + unsigned char aes_block[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE], *blk; + unsigned char padded_cookie[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE]; + unsigned char nonce[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE]; + unsigned char aes_key[RSPAMD_CRYPTOBOX_AES_KEYSIZE]; + unsigned char result[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE * 2]; uint32_t ts; - const gchar *sk, *cookie; + const char *sk, *cookie; gsize sklen, cookie_len; - gint bklen; + int bklen; sk = lua_tolstring(L, 1, &sklen); cookie = lua_tolstring(L, 2, &cookie_len); @@ -2307,11 +2307,11 @@ lua_cryptobox_encrypt_cookie(lua_State *L) memcpy(aes_key, sk, sizeof(aes_key)); } else { - return luaL_error(L, "invalid keysize %d", (gint) sklen); + return luaL_error(L, "invalid keysize %d", (int) sklen); } if (cookie_len > sizeof(padded_cookie) - 1) { - return luaL_error(L, "cookie is too long %d", (gint) cookie_len); + return luaL_error(L, "cookie is too long %d", (int) cookie_len); } /* Fill nonce */ @@ -2339,13 +2339,13 @@ lua_cryptobox_encrypt_cookie(lua_State *L) /* Encode result */ memcpy(result, nonce, sizeof(nonce)); - for (guint i = 0; i < sizeof(aes_block); i++) { + for (unsigned int i = 0; i < sizeof(aes_block); i++) { result[i + sizeof(nonce)] = padded_cookie[i] ^ aes_block[i]; } gsize rlen; - gchar *res = rspamd_encode_base64(result, sizeof(result), - 0, &rlen); + char *res = rspamd_encode_base64(result, sizeof(result), + 0, &rlen); lua_pushlstring(L, res, rlen); g_free(res); @@ -2372,18 +2372,18 @@ lua_cryptobox_encrypt_cookie(lua_State *L) * @param {string} encrypted_cookie encrypted cookie as a base64 encoded string * @return {string+number} decrypted value of the cookie and the cookie timestamp */ -static gint +static int lua_cryptobox_decrypt_cookie(lua_State *L) { - guchar *blk; - guchar nonce[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE]; - guchar aes_key[RSPAMD_CRYPTOBOX_AES_KEYSIZE]; - guchar *src; + unsigned char *blk; + unsigned char nonce[RSPAMD_CRYPTOBOX_AES_BLOCKSIZE]; + unsigned char aes_key[RSPAMD_CRYPTOBOX_AES_KEYSIZE]; + unsigned char *src; uint32_t ts; - const gchar *sk, *cookie; + const char *sk, *cookie; gsize sklen, cookie_len; - gint bklen; + int bklen; sk = lua_tolstring(L, 1, &sklen); cookie = lua_tolstring(L, 2, &cookie_len); @@ -2398,7 +2398,7 @@ lua_cryptobox_decrypt_cookie(lua_State *L) memcpy(aes_key, sk, sizeof(aes_key)); } else { - return luaL_error(L, "invalid keysize %d", (gint) sklen); + return luaL_error(L, "invalid keysize %d", (int) sklen); } src = g_malloc(cookie_len); @@ -2431,7 +2431,7 @@ lua_cryptobox_decrypt_cookie(lua_State *L) EVP_CIPHER_CTX_free(ctx); /* Decode result */ - for (guint i = 0; i < RSPAMD_CRYPTOBOX_AES_BLOCKSIZE; i++) { + for (unsigned int i = 0; i < RSPAMD_CRYPTOBOX_AES_BLOCKSIZE; i++) { src[i + sizeof(nonce)] ^= nonce[i]; } @@ -2465,19 +2465,19 @@ lua_cryptobox_decrypt_cookie(lua_State *L) * @param {string} kdf_alg algorithm to use (catena or pbkdf2) * @return {string} encrypted password or nil if error occurs */ -static gint +static int lua_cryptobox_pbkdf(lua_State *L) { const struct rspamd_controller_pbkdf *pbkdf = NULL; - const gchar *pbkdf_str = "catena"; - gchar *password; + const char *pbkdf_str = "catena"; + char *password; gsize pwlen; if (lua_type(L, 2) == LUA_TSTRING) { pbkdf_str = lua_tostring(L, 2); } - for (guint i = 0; i < RSPAMD_PBKDF_ID_MAX - 1; i++) { + for (unsigned int i = 0; i < RSPAMD_PBKDF_ID_MAX - 1; i++) { pbkdf = &pbkdf_list[i]; if (g_ascii_strcasecmp(pbkdf_str, pbkdf->alias) == 0) { @@ -2510,8 +2510,8 @@ lua_cryptobox_pbkdf(lua_State *L) return 1; } - guchar *salt, *key; - gchar *encoded_salt, *encoded_key; + unsigned char *salt, *key; + char *encoded_salt, *encoded_key; GString *result; salt = g_alloca(pbkdf->salt_len); @@ -2546,11 +2546,11 @@ lua_cryptobox_pbkdf(lua_State *L) * @param {number} nbits optional number of bits for rsa (default 1024) * @return {rspamd_text,rspamd_text} private key and public key as base64 encoded strings */ -static gint +static int lua_cryptobox_gen_dkim_keypair(lua_State *L) { - const gchar *alg_str = "rsa"; - guint nbits = 1024; + const char *alg_str = "rsa"; + unsigned int nbits = 1024; struct rspamd_lua_text *priv_out, *pub_out; if (lua_type(L, 1) == LUA_TSTRING) { @@ -2595,9 +2595,9 @@ lua_cryptobox_gen_dkim_keypair(lua_State *L) } BIO *mbio; - gint rc, len; - guchar *data; - gchar *b64_data; + int rc, len; + unsigned char *data; + char *b64_data; gsize b64_len; mbio = BIO_new(BIO_s_mem()); @@ -2655,7 +2655,7 @@ lua_cryptobox_gen_dkim_keypair(lua_State *L) else if (strcmp(alg_str, "ed25519") == 0) { rspamd_sig_pk_t pk; rspamd_sig_sk_t sk; - gchar *b64_data; + char *b64_data; gsize b64_len; rspamd_cryptobox_keypair_sig(pk, sk, RSPAMD_CRYPTOBOX_MODE_25519); @@ -2688,7 +2688,7 @@ lua_cryptobox_gen_dkim_keypair(lua_State *L) else if (strcmp(alg_str, "ed25519-seed") == 0) { rspamd_sig_pk_t pk; rspamd_sig_sk_t sk; - gchar *b64_data; + char *b64_data; gsize b64_len; rspamd_cryptobox_keypair_sig(pk, sk, RSPAMD_CRYPTOBOX_MODE_25519); @@ -2740,10 +2740,10 @@ G_STATIC_ASSERT(crypto_secretbox_KEYBYTES >= crypto_generichash_BYTES_MIN); * @param {table} params optional parameters - NYI * @return {rspamd_cryptobox_secretbox} opaque object with the key expanded */ -static gint +static int lua_cryptobox_secretbox_create(lua_State *L) { - const gchar *in; + const char *in; gsize inlen; @@ -2780,7 +2780,7 @@ lua_cryptobox_secretbox_create(lua_State *L) } -static gint +static int lua_cryptobox_secretbox_gc(lua_State *L) { struct rspamd_lua_cryptobox_secretbox *sbox = @@ -2805,10 +2805,10 @@ lua_cryptobox_secretbox_gc(lua_State *L) * @param {table} params optional parameters - NYI * @return {rspamd_text},{rspamd_text} output with mac + nonce or just output if nonce is there */ -static gint +static int lua_cryptobox_secretbox_encrypt(lua_State *L) { - const gchar *in, *nonce; + const char *in, *nonce; gsize inlen, nlen; struct rspamd_lua_cryptobox_secretbox *sbox = lua_check_cryptobox_secretbox(L, 1); @@ -2858,14 +2858,14 @@ lua_cryptobox_secretbox_encrypt(lua_State *L) return luaL_error(L, "bad nonce"); } - guchar real_nonce[crypto_secretbox_NONCEBYTES]; + unsigned char real_nonce[crypto_secretbox_NONCEBYTES]; memset(real_nonce, 0, sizeof(real_nonce)); memcpy(real_nonce, nonce, nlen); out = lua_new_text(L, NULL, inlen + crypto_secretbox_MACBYTES, TRUE); - crypto_secretbox_easy((guchar *) out->start, in, inlen, + crypto_secretbox_easy((unsigned char *) out->start, in, inlen, nonce, sbox->sk); return 1; @@ -2878,8 +2878,8 @@ lua_cryptobox_secretbox_encrypt(lua_State *L) TRUE); random_nonce = lua_new_text(L, NULL, crypto_secretbox_NONCEBYTES, TRUE); - randombytes_buf((guchar *) random_nonce->start, random_nonce->len); - crypto_secretbox_easy((guchar *) out->start, in, inlen, + randombytes_buf((unsigned char *) random_nonce->start, random_nonce->len); + crypto_secretbox_easy((unsigned char *) out->start, in, inlen, random_nonce->start, sbox->sk); return 2; /* output + random nonce */ @@ -2894,10 +2894,10 @@ lua_cryptobox_secretbox_encrypt(lua_State *L) * @param {table} params optional parameters - NYI * @return {boolean},{rspamd_text} decryption result + decrypted text */ -static gint +static int lua_cryptobox_secretbox_decrypt(lua_State *L) { - const gchar *in, *nonce; + const char *in, *nonce; gsize inlen, nlen; struct rspamd_lua_cryptobox_secretbox *sbox = lua_check_cryptobox_secretbox(L, 1); @@ -2956,16 +2956,16 @@ lua_cryptobox_secretbox_decrypt(lua_State *L) return 2; } - guchar real_nonce[crypto_secretbox_NONCEBYTES]; + unsigned char real_nonce[crypto_secretbox_NONCEBYTES]; memset(real_nonce, 0, sizeof(real_nonce)); memcpy(real_nonce, nonce, nlen); out = lua_new_text(L, NULL, inlen - crypto_secretbox_MACBYTES, TRUE); - gint text_pos = lua_gettop(L); + int text_pos = lua_gettop(L); - if (crypto_secretbox_open_easy((guchar *) out->start, in, inlen, + if (crypto_secretbox_open_easy((unsigned char *) out->start, in, inlen, nonce, sbox->sk) == 0) { lua_pushboolean(L, true); lua_pushvalue(L, text_pos); /* Prevent gc by copying in stack */ @@ -2981,7 +2981,7 @@ lua_cryptobox_secretbox_decrypt(lua_State *L) return 2; } -static gint +static int lua_load_pubkey(lua_State *L) { lua_newtable(L); @@ -2990,7 +2990,7 @@ lua_load_pubkey(lua_State *L) return 1; } -static gint +static int lua_load_keypair(lua_State *L) { lua_newtable(L); @@ -2999,7 +2999,7 @@ lua_load_keypair(lua_State *L) return 1; } -static gint +static int lua_load_signature(lua_State *L) { lua_newtable(L); @@ -3008,7 +3008,7 @@ lua_load_signature(lua_State *L) return 1; } -static gint +static int lua_load_hash(lua_State *L) { lua_newtable(L); @@ -3017,7 +3017,7 @@ lua_load_hash(lua_State *L) return 1; } -static gint +static int lua_load_cryptobox_secretbox(lua_State *L) { lua_newtable(L); @@ -3026,7 +3026,7 @@ lua_load_cryptobox_secretbox(lua_State *L) return 1; } -static gint +static int lua_load_cryptobox(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_dns.c b/src/lua/lua_dns.c index cffa31259..2f20b6f5e 100644 --- a/src/lua/lua_dns.c +++ b/src/lua/lua_dns.c @@ -22,7 +22,7 @@ static const struct luaL_reg dns_f[] = { {"__tostring", rspamd_lua_class_tostring}, {NULL, NULL}}; -static const gchar *M = "rspamd lua dns"; +static const char *M = "rspamd lua dns"; void lua_dns_callback(struct rdns_reply *reply, void *arg); @@ -34,18 +34,18 @@ struct lua_rspamd_dns_cbdata { struct rspamd_async_session *s; }; -static gint +static int lua_dns_request(lua_State *L) { GError *err = NULL; struct rspamd_async_session *session = NULL; struct rspamd_config *cfg = NULL; struct lua_rspamd_dns_cbdata *cbdata = NULL; - const gchar *to_resolve = NULL; - const gchar *type_str = NULL; + const char *to_resolve = NULL; + const char *type_str = NULL; struct rspamd_task *task = NULL; rspamd_mempool_t *pool = NULL; - gint ret = 0; + int ret = 0; gboolean forced = FALSE; /* Check arguments */ @@ -183,7 +183,7 @@ void lua_dns_callback(struct rdns_reply *reply, void *arg) } } -static gint +static int lua_load_dns(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_dns_resolver.c b/src/lua/lua_dns_resolver.c index 6c2d4f672..605fdd4fd 100644 --- a/src/lua/lua_dns_resolver.c +++ b/src/lua/lua_dns_resolver.c @@ -41,7 +41,7 @@ local function symbol_callback(task) end */ -static const gchar *M = "rspamd lua dns resolver"; +static const char *M = "rspamd lua dns resolver"; /* Lua bindings */ LUA_FUNCTION_DEF(dns_resolver, init); @@ -71,7 +71,7 @@ static const struct luaL_reg dns_resolverlib_m[] = { {NULL, NULL}}; struct rspamd_dns_resolver * -lua_check_dns_resolver(lua_State *L, gint pos) +lua_check_dns_resolver(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_resolver_classname); luaL_argcheck(L, ud != NULL, pos, "'resolver' expected"); @@ -82,9 +82,9 @@ struct lua_dns_cbdata { struct rspamd_task *task; rspamd_mempool_t *pool; struct rspamd_dns_resolver *resolver; - gint cbref; - gchar *to_resolve; - gchar *user_str; + int cbref; + char *to_resolve; + char *user_str; struct rspamd_symcache_dynamic_item *item; struct rspamd_async_session *s; }; @@ -93,7 +93,7 @@ static int lua_dns_get_type(lua_State *L, int argno) { int type = RDNS_REQUEST_A; - const gchar *strtype; + const char *strtype; if (lua_type(L, argno) != LUA_TSTRING) { lua_pushvalue(L, argno); @@ -121,7 +121,7 @@ lua_dns_resolver_callback(struct rdns_reply *reply, gpointer arg) lua_State *L; struct lua_callback_state cbs; rspamd_mempool_t *pool; - gint err_idx; + int err_idx; pool = cd->pool; lua_thread_pool_prepare_callback(cd->resolver->cfg->lua_thread_pool, &cbs); @@ -162,7 +162,7 @@ lua_dns_resolver_callback(struct rdns_reply *reply, gpointer arg) lua_pushboolean(L, reply->flags & RDNS_AUTH); - const gchar *servname = rdns_request_get_server(reply->request); + const char *servname = rdns_request_get_server(reply->request); if (servname) { lua_pushstring(L, servname); @@ -200,7 +200,7 @@ lua_dns_resolver_callback(struct rdns_reply *reply, gpointer arg) void lua_push_dns_reply(lua_State *L, const struct rdns_reply *reply) { - gint i = 0, naddrs = 0; + int i = 0, naddrs = 0; struct rdns_reply_entry *elt; rspamd_inet_addr_t *addr; @@ -338,9 +338,9 @@ lua_dns_resolver_resolve_common(lua_State *L, LUA_TRACE_POINT; struct rspamd_async_session *session = NULL; rspamd_mempool_t *pool = NULL; - const gchar *to_resolve = NULL, *user_str = NULL; + const char *to_resolve = NULL, *user_str = NULL; struct lua_dns_cbdata *cbdata; - gint cbref = -1, ret; + int cbref = -1, ret; struct rspamd_task *task = NULL; GError *err = NULL; gboolean forced = FALSE; @@ -689,9 +689,9 @@ lua_dns_resolver_idna_convert_utf8(lua_State *L) { struct rspamd_dns_resolver *dns_resolver = lua_check_dns_resolver(L, 1); gsize hlen; - guint conv_len = 0; - const gchar *hname = luaL_checklstring(L, 2, &hlen); - gchar *converted; + unsigned int conv_len = 0; + const char *hname = luaL_checklstring(L, 2, &hlen); + char *converted; rspamd_mempool_t *pool = rspamd_lua_check_udata_maybe(L, 3, rspamd_mempool_classname); @@ -723,7 +723,7 @@ lua_dns_resolver_idna_convert_utf8(lua_State *L) return 1; } -static gint +static int lua_load_dns_resolver(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_expression.c b/src/lua/lua_expression.c index b3c725376..61e199b6d 100644 --- a/src/lua/lua_expression.c +++ b/src/lua/lua_expression.c @@ -96,9 +96,9 @@ static const struct luaL_reg exprlib_f[] = { LUA_INTERFACE_DEF(expr, create), {NULL, NULL}}; -static rspamd_expression_atom_t *lua_atom_parse(const gchar *line, gsize len, +static rspamd_expression_atom_t *lua_atom_parse(const char *line, gsize len, rspamd_mempool_t *pool, gpointer ud, GError **err); -static gdouble lua_atom_process(gpointer runtime_ud, rspamd_expression_atom_t *atom); +static double lua_atom_process(gpointer runtime_ud, rspamd_expression_atom_t *atom); static const struct rspamd_atom_subr lua_atom_subr = { .parse = lua_atom_parse, @@ -108,8 +108,8 @@ static const struct rspamd_atom_subr lua_atom_subr = { struct lua_expression { struct rspamd_expression *expr; - gint parse_idx; - gint process_idx; + int parse_idx; + int process_idx; lua_State *L; rspamd_mempool_t *pool; }; @@ -121,7 +121,7 @@ lua_expr_quark(void) } struct lua_expression * -rspamd_lua_expression(lua_State *L, gint pos) +rspamd_lua_expression(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_expr_classname); luaL_argcheck(L, ud != NULL, pos, "'expr' expected"); @@ -143,13 +143,13 @@ lua_expr_dtor(gpointer p) } static rspamd_expression_atom_t * -lua_atom_parse(const gchar *line, gsize len, +lua_atom_parse(const char *line, gsize len, rspamd_mempool_t *pool, gpointer ud, GError **err) { struct lua_expression *e = (struct lua_expression *) ud; rspamd_expression_atom_t *atom; gsize rlen; - const gchar *tok; + const char *tok; lua_rawgeti(e->L, LUA_REGISTRYINDEX, e->parse_idx); lua_pushlstring(e->L, line, len); @@ -180,17 +180,17 @@ lua_atom_parse(const gchar *line, gsize len, struct lua_atom_process_data { lua_State *L; struct lua_expression *e; - gint process_cb_pos; - gint stack_item; + int process_cb_pos; + int stack_item; }; -static gdouble +static double lua_atom_process(gpointer runtime_ud, rspamd_expression_atom_t *atom) { struct lua_atom_process_data *pd = (struct lua_atom_process_data *) runtime_ud; - gdouble ret = 0; - guint nargs; - gint err_idx; + double ret = 0; + unsigned int nargs; + int err_idx; if (pd->stack_item != -1) { nargs = 2; @@ -224,14 +224,14 @@ lua_atom_process(gpointer runtime_ud, rspamd_expression_atom_t *atom) return ret; } -static gint +static int lua_expr_process(lua_State *L) { LUA_TRACE_POINT; struct lua_expression *e = rspamd_lua_expression(L, 1); struct lua_atom_process_data pd; - gdouble res; - gint flags = 0, old_top; + double res; + int flags = 0, old_top; pd.L = L; pd.e = e; @@ -279,14 +279,14 @@ lua_expr_process(lua_State *L) return 1; } -static gint +static int lua_expr_process_traced(lua_State *L) { LUA_TRACE_POINT; struct lua_expression *e = rspamd_lua_expression(L, 1); struct lua_atom_process_data pd; - gdouble res; - gint flags = 0, old_top; + double res; + int flags = 0, old_top; GPtrArray *trace; pd.L = L; @@ -322,7 +322,7 @@ lua_expr_process_traced(lua_State *L) lua_createtable(L, trace->len, 0); - for (guint i = 0; i < trace->len; i++) { + for (unsigned int i = 0; i < trace->len; i++) { struct rspamd_expression_atom_s *atom = g_ptr_array_index(trace, i); lua_pushlstring(L, atom->str, atom->len); @@ -334,7 +334,7 @@ lua_expr_process_traced(lua_State *L) return 2; } -static gint +static int lua_expr_create(lua_State *L) { LUA_TRACE_POINT; @@ -437,7 +437,7 @@ lua_expr_create(lua_State *L) return 2; } -static gint +static int lua_expr_to_string(lua_State *L) { LUA_TRACE_POINT; @@ -463,7 +463,7 @@ lua_expr_to_string(lua_State *L) struct lua_expr_atoms_cbdata { lua_State *L; - gint idx; + int idx; }; static void @@ -475,7 +475,7 @@ lua_exr_atom_cb(const rspamd_ftok_t *tok, gpointer ud) lua_rawseti(cbdata->L, -2, cbdata->idx++); } -static gint +static int lua_expr_atoms(lua_State *L) { LUA_TRACE_POINT; @@ -495,7 +495,7 @@ lua_expr_atoms(lua_State *L) return 1; } -static gint +static int lua_load_expression(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_html.cxx b/src/lua/lua_html.cxx index 67dbe9738..090e2af55 100644 --- a/src/lua/lua_html.cxx +++ b/src/lua/lua_html.cxx @@ -192,7 +192,7 @@ static const struct luaL_reg taglib_m[] = { {NULL, NULL}}; static struct rspamd::html::html_content * -lua_check_html(lua_State *L, gint pos) +lua_check_html(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_html_classname); luaL_argcheck(L, ud != NULL, pos, "'html' expected"); @@ -205,19 +205,19 @@ struct lua_html_tag { }; static struct lua_html_tag * -lua_check_html_tag(lua_State *L, gint pos) +lua_check_html_tag(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_html_tag_classname); luaL_argcheck(L, ud != NULL, pos, "'html_tag' expected"); return ud ? ((struct lua_html_tag *) ud) : NULL; } -static gint +static int lua_html_has_tag(lua_State *L) { LUA_TRACE_POINT; auto *hc = lua_check_html(L, 1); - const gchar *tagname = luaL_checkstring(L, 2); + const char *tagname = luaL_checkstring(L, 2); gboolean ret = FALSE; if (hc && tagname) { @@ -245,12 +245,12 @@ constexpr const auto prop_map = frozen::make_unordered_map<frozen::string, int>( {"data_urls", RSPAMD_HTML_FLAG_HAS_DATA_URLS}, }); -static gint +static int lua_html_has_property(lua_State *L) { LUA_TRACE_POINT; auto *hc = lua_check_html(L, 1); - const gchar *propname = luaL_checkstring(L, 2); + const char *propname = luaL_checkstring(L, 2); gboolean ret = FALSE; if (hc && propname) { @@ -326,12 +326,12 @@ lua_html_push_image(lua_State *L, const struct html_image *img) lua_settable(L, -3); } -static gint +static int lua_html_get_images(lua_State *L) { LUA_TRACE_POINT; auto *hc = lua_check_html(L, 1); - guint i = 1; + unsigned int i = 1; if (hc != NULL) { lua_createtable(L, hc->images.size(), 0); @@ -397,13 +397,13 @@ lua_html_push_block(lua_State *L, const struct rspamd::html::html_block *bl) lua_settable(L, -3); } -static gint +static int lua_html_foreach_tag(lua_State *L) { LUA_TRACE_POINT; auto *hc = lua_check_html(L, 1); - const gchar *tagname; - gint id; + const char *tagname; + int id; auto any = false; ankerl::unordered_dense::set<int> tags; @@ -491,7 +491,7 @@ lua_html_foreach_tag(lua_State *L) return 0; } -static gint +static int lua_html_get_invisible(lua_State *L) { LUA_TRACE_POINT; @@ -507,12 +507,12 @@ lua_html_get_invisible(lua_State *L) return 1; } -static gint +static int lua_html_tag_get_type(lua_State *L) { LUA_TRACE_POINT; struct lua_html_tag *ltag = lua_check_html_tag(L, 1); - const gchar *tagname; + const char *tagname; if (ltag != NULL) { tagname = rspamd_html_tag_by_id(ltag->tag->id); @@ -531,7 +531,7 @@ lua_html_tag_get_type(lua_State *L) return 1; } -static gint +static int lua_html_tag_get_parent(lua_State *L) { LUA_TRACE_POINT; @@ -557,12 +557,12 @@ lua_html_tag_get_parent(lua_State *L) return 1; } -static gint +static int lua_html_tag_get_flags(lua_State *L) { LUA_TRACE_POINT; struct lua_html_tag *ltag = lua_check_html_tag(L, 1); - gint i = 1; + int i = 1; if (ltag && ltag->tag) { /* Push flags */ @@ -595,7 +595,7 @@ lua_html_tag_get_flags(lua_State *L) return 1; } -static gint +static int lua_html_tag_get_content(lua_State *L) { LUA_TRACE_POINT; @@ -628,7 +628,7 @@ lua_html_tag_get_content(lua_State *L) return 1; } -static gint +static int lua_html_tag_get_content_length(lua_State *L) { LUA_TRACE_POINT; @@ -650,7 +650,7 @@ lua_html_tag_get_content_length(lua_State *L) return 1; } -static gint +static int lua_html_tag_get_extra(lua_State *L) { LUA_TRACE_POINT; @@ -685,7 +685,7 @@ lua_html_tag_get_extra(lua_State *L) return 1; } -static gint +static int lua_html_tag_get_style(lua_State *L) { LUA_TRACE_POINT; @@ -703,13 +703,13 @@ lua_html_tag_get_style(lua_State *L) return 1; } -static gint +static int lua_html_tag_get_attribute(lua_State *L) { LUA_TRACE_POINT; struct lua_html_tag *ltag = lua_check_html_tag(L, 1); gsize slen; - const gchar *attr_name = luaL_checklstring(L, 2, &slen); + const char *attr_name = luaL_checklstring(L, 2, &slen); if (ltag && attr_name) { auto maybe_attr = ltag->tag->find_component( diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c index 4c0596885..2032f7dc1 100644 --- a/src/lua/lua_http.c +++ b/src/lua/lua_http.c @@ -48,7 +48,7 @@ local function symbol_callback(task) #define MAX_HEADERS_SIZE 8192 -static const gchar *M = "rspamd lua http"; +static const char *M = "rspamd lua http"; LUA_FUNCTION_DEF(http, request); @@ -75,20 +75,20 @@ struct lua_http_cbdata { struct rspamd_cryptobox_keypair *local_kp; struct rspamd_cryptobox_pubkey *peer_pk; rspamd_inet_addr_t *addr; - gchar *mime_type; - gchar *host; - gchar *auth; + char *mime_type; + char *host; + char *auth; struct upstream *up; - const gchar *url; + const char *url; gsize max_size; - gint flags; - gint fd; - gint cbref; + int flags; + int fd; + int cbref; struct thread_entry *thread; ref_entry_t ref; }; -static const gdouble default_http_timeout = 5.0; +static const double default_http_timeout = 5.0; static struct rspamd_dns_resolver * lua_http_global_resolver(struct ev_loop *ev_base) @@ -237,7 +237,7 @@ lua_http_finish_handler(struct rspamd_http_connection *conn, { struct lua_http_cbdata *cbd = (struct lua_http_cbdata *) conn->ud; struct rspamd_http_header *h; - const gchar *body; + const char *body; gsize body_len; struct lua_callback_state lcbd; @@ -330,7 +330,7 @@ lua_http_resume_handler(struct rspamd_http_connection *conn, { struct lua_http_cbdata *cbd = (struct lua_http_cbdata *) conn->ud; lua_State *L = cbd->thread->lua_state; - const gchar *body; + const char *body; gsize body_len; struct rspamd_http_header *h; @@ -557,7 +557,7 @@ static void lua_http_push_headers(lua_State *L, struct rspamd_http_message *msg) { const char *name, *value; - gint i, sz; + int i, sz; lua_pushnil(L); while (lua_next(L, -2) != 0) { @@ -614,7 +614,7 @@ lua_http_push_headers(lua_State *L, struct rspamd_http_message *msg) * @return {boolean} `true`, in **async** mode, if a request has been successfully scheduled. If this value is `false` then some error occurred, the callback thus will not be called. * @return In **sync** mode `string|nil, nil|table` In sync mode error message if any and response as table: `int` _code_, `string` _content_ and `table` _headers_ (header -> value) */ -static gint +static int lua_http_request(lua_State *L) { LUA_TRACE_POINT; @@ -629,14 +629,14 @@ lua_http_request(lua_State *L) struct rspamd_cryptobox_pubkey *peer_key = NULL; struct rspamd_cryptobox_keypair *local_kp = NULL; struct upstream *up = NULL; - const gchar *url, *lua_body; + const char *url, *lua_body; rspamd_fstring_t *body = NULL; - gint cbref = -1; + int cbref = -1; gsize bodylen; - gdouble timeout = default_http_timeout; - gint flags = 0; - gchar *mime_type = NULL; - gchar *auth = NULL; + double timeout = default_http_timeout; + int flags = 0; + char *mime_type = NULL; + char *auth = NULL; gsize max_size = 0; gboolean gzip = FALSE; @@ -903,7 +903,7 @@ lua_http_request(lua_State *L) lua_gettable(L, 1); if (lua_type(L, -1) == LUA_TSTRING) { - const gchar *in; + const char *in; gsize inlen; in = lua_tolstring(L, -1, &inlen); @@ -997,14 +997,14 @@ lua_http_request(lua_State *L) lua_gettable(L, 1); if (lua_type(L, -1) == LUA_TSTRING) { - const gchar *user = lua_tostring(L, -1); + const char *user = lua_tostring(L, -1); lua_pushstring(L, "password"); lua_gettable(L, 1); if (lua_type(L, -1) == LUA_TSTRING) { - const gchar *password = lua_tostring(L, -1); - gchar *tmpbuf; + const char *password = lua_tostring(L, -1); + char *tmpbuf; gsize tlen; tlen = strlen(user) + strlen(password) + 1; @@ -1124,7 +1124,7 @@ lua_http_request(lua_State *L) /* Check if we can skip resolving */ gsize hostlen = 0; - const gchar *host = rspamd_http_message_get_http_host(msg, &hostlen); + const char *host = rspamd_http_message_get_http_host(msg, &hostlen); if (host) { cbd->host = g_malloc(hostlen + 1); @@ -1255,7 +1255,7 @@ lua_http_request(lua_State *L) return 1; } -static gint +static int lua_load_http(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c index 5b547b3b6..1cfb297a4 100644 --- a/src/lua/lua_ip.c +++ b/src/lua/lua_ip.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, @@ -220,7 +220,7 @@ lua_ip_new(lua_State *L, struct rspamd_lua_ip *old) } struct rspamd_lua_ip * -lua_check_ip(lua_State *L, gint pos) +lua_check_ip(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_ip_classname); @@ -228,13 +228,13 @@ lua_check_ip(lua_State *L, gint pos) return ud ? *((struct rspamd_lua_ip **) ud) : NULL; } -static gint +static int lua_ip_to_table(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_ip *ip = lua_check_ip(L, 1); - guint max, i; - guint8 *ptr; + unsigned int max, i; + uint8_t *ptr; if (ip != NULL && ip->addr) { ptr = rspamd_inet_address_get_hash_key(ip->addr, &max); @@ -252,14 +252,14 @@ lua_ip_to_table(lua_State *L) return 1; } -static gint +static int lua_ip_str_octets(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_ip *ip = lua_check_ip(L, 1); - guint max, i; - guint8 *ptr; - gint af; + unsigned int max, i; + uint8_t *ptr; + int af; char numbuf[8]; if (ip != NULL && ip->addr) { @@ -293,15 +293,15 @@ lua_ip_str_octets(lua_State *L) return 1; } -static gint +static int lua_ip_inversed_str_octets(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_ip *ip = lua_check_ip(L, 1); - guint max, i; - guint8 *ptr; + unsigned int max, i; + uint8_t *ptr; char numbuf[4]; - gint af; + int af; if (ip != NULL && ip->addr) { ptr = rspamd_inet_address_get_hash_key(ip->addr, &max); @@ -335,7 +335,7 @@ lua_ip_inversed_str_octets(lua_State *L) return 1; } -static gint +static int lua_ip_to_string(lua_State *L) { LUA_TRACE_POINT; @@ -356,7 +356,7 @@ lua_ip_to_string(lua_State *L) return 1; } -static gint +static int lua_ip_get_port(lua_State *L) { LUA_TRACE_POINT; @@ -372,12 +372,12 @@ lua_ip_get_port(lua_State *L) return 1; } -static gint +static int lua_ip_from_string(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_ip *ip; - const gchar *ip_str; + const char *ip_str; gsize len; ip_str = luaL_checklstring(L, 1, &len); @@ -386,7 +386,7 @@ lua_ip_from_string(lua_State *L) if (!rspamd_parse_inet_address(&ip->addr, ip_str, len, RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) { - msg_warn("cannot parse ip: %*s", (gint) len, ip_str); + msg_warn("cannot parse ip: %*s", (int) len, ip_str); ip->addr = NULL; } } @@ -397,14 +397,14 @@ lua_ip_from_string(lua_State *L) return 1; } -static gint +static int lua_ip_to_number(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_ip *ip = lua_check_ip(L, 1); uint32_t c; - guint max, i; - guchar *ptr; + unsigned int max, i; + unsigned char *ptr; if (ip != NULL && ip->addr) { ptr = rspamd_inet_address_get_hash_key(ip->addr, &max); @@ -424,7 +424,7 @@ lua_ip_to_number(lua_State *L) } -static gint +static int lua_ip_destroy(lua_State *L) { LUA_TRACE_POINT; @@ -440,7 +440,7 @@ lua_ip_destroy(lua_State *L) return 0; } -static gint +static int lua_ip_get_version(lua_State *L) { LUA_TRACE_POINT; @@ -456,7 +456,7 @@ lua_ip_get_version(lua_State *L) return 1; } -static gint +static int lua_ip_is_valid(lua_State *L) { LUA_TRACE_POINT; @@ -472,12 +472,12 @@ lua_ip_is_valid(lua_State *L) return 1; } -static gint +static int lua_ip_apply_mask(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_ip *ip = lua_check_ip(L, 1), *nip; - gint mask; + int mask; mask = lua_tonumber(L, 2); if (mask > 0 && ip != NULL && ip->addr) { @@ -491,7 +491,7 @@ lua_ip_apply_mask(lua_State *L) return 1; } -static gint +static int lua_ip_equal(lua_State *L) { LUA_TRACE_POINT; @@ -508,7 +508,7 @@ lua_ip_equal(lua_State *L) return 1; } -static gint +static int lua_ip_copy(lua_State *L) { LUA_TRACE_POINT; @@ -524,7 +524,7 @@ lua_ip_copy(lua_State *L) return 1; } -static gint +static int lua_ip_is_local(lua_State *L) { struct rspamd_lua_ip *ip = lua_check_ip(L, 1); @@ -562,7 +562,7 @@ lua_ip_is_local(lua_State *L) return 1; } -static gint +static int lua_ip_less_than(lua_State *L) { LUA_TRACE_POINT; @@ -596,7 +596,7 @@ void rspamd_lua_ip_push(lua_State *L, rspamd_inet_addr_t *addr) } } -void rspamd_lua_ip_push_fromstring(lua_State *L, const gchar *ip_str) +void rspamd_lua_ip_push_fromstring(lua_State *L, const char *ip_str) { struct rspamd_lua_ip *ip, **pip; @@ -620,7 +620,7 @@ void rspamd_lua_ip_push_fromstring(lua_State *L, const gchar *ip_str) } } -static gint +static int lua_load_ip(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_kann.c b/src/lua/lua_kann.c index 09228387a..eadc8b06c 100644 --- a/src/lua/lua_kann.c +++ b/src/lua/lua_kann.c @@ -185,7 +185,7 @@ rspamd_kann_table_to_flags(lua_State *L, int table_pos) return result; } -static gint +static int lua_load_kann(lua_State *L) { lua_newtable(L); @@ -326,7 +326,7 @@ void luaopen_kann(lua_State *L) static int lua_kann_layer_input(lua_State *L) { - gint nnodes = luaL_checkinteger(L, 1); + int nnodes = luaL_checkinteger(L, 1); if (nnodes > 0) { kad_node_t *t; @@ -355,7 +355,7 @@ static int lua_kann_layer_dense(lua_State *L) { kad_node_t *in = lua_check_kann_node(L, 1); - gint nnodes = luaL_checkinteger(L, 2); + int nnodes = luaL_checkinteger(L, 2); if (in != NULL && nnodes > 0) { kad_node_t *t; @@ -441,8 +441,8 @@ static int lua_kann_layer_rnn(lua_State *L) { kad_node_t *in = lua_check_kann_node(L, 1); - gint nnodes = luaL_checkinteger(L, 2); - gint rnnflags = 0; + int nnodes = luaL_checkinteger(L, 2); + int rnnflags = 0; if (in != NULL && nnodes > 0) { kad_node_t *t; @@ -476,8 +476,8 @@ static int lua_kann_layer_lstm(lua_State *L) { kad_node_t *in = lua_check_kann_node(L, 1); - gint nnodes = luaL_checkinteger(L, 2); - gint rnnflags = 0; + int nnodes = luaL_checkinteger(L, 2); + int rnnflags = 0; if (in != NULL && nnodes > 0) { kad_node_t *t; @@ -511,8 +511,8 @@ static int lua_kann_layer_gru(lua_State *L) { kad_node_t *in = lua_check_kann_node(L, 1); - gint nnodes = luaL_checkinteger(L, 2); - gint rnnflags = 0; + int nnodes = luaL_checkinteger(L, 2); + int rnnflags = 0; if (in != NULL && nnodes > 0) { kad_node_t *t; @@ -743,7 +743,7 @@ lua_kann_loss_ce_multi_weighted(lua_State *L) static int lua_kann_new_scalar(lua_State *L) { - gint flag = luaL_checkinteger(L, 1); + int flag = luaL_checkinteger(L, 1); double x = luaL_checknumber(L, 2); kad_node_t *t; @@ -758,8 +758,8 @@ lua_kann_new_scalar(lua_State *L) static int lua_kann_new_weight(lua_State *L) { - gint nrow = luaL_checkinteger(L, 1); - gint ncol = luaL_checkinteger(L, 2); + int nrow = luaL_checkinteger(L, 1); + int ncol = luaL_checkinteger(L, 2); kad_node_t *t; t = kann_new_weight(nrow, ncol); @@ -773,7 +773,7 @@ lua_kann_new_weight(lua_State *L) static int lua_kann_new_bias(lua_State *L) { - gint n = luaL_checkinteger(L, 1); + int n = luaL_checkinteger(L, 1); kad_node_t *t; t = kann_new_bias(n); @@ -787,10 +787,10 @@ lua_kann_new_bias(lua_State *L) static int lua_kann_new_weight_conv2d(lua_State *L) { - gint nout = luaL_checkinteger(L, 1); - gint nin = luaL_checkinteger(L, 2); - gint krow = luaL_checkinteger(L, 3); - gint kcol = luaL_checkinteger(L, 4); + int nout = luaL_checkinteger(L, 1); + int nin = luaL_checkinteger(L, 2); + int krow = luaL_checkinteger(L, 3); + int kcol = luaL_checkinteger(L, 4); kad_node_t *t; t = kann_new_weight_conv2d(nout, nin, krow, kcol); @@ -804,9 +804,9 @@ lua_kann_new_weight_conv2d(lua_State *L) static int lua_kann_new_weight_conv1d(lua_State *L) { - gint nout = luaL_checkinteger(L, 1); - gint nin = luaL_checkinteger(L, 2); - gint klen = luaL_checkinteger(L, 3); + int nout = luaL_checkinteger(L, 1); + int nin = luaL_checkinteger(L, 2); + int klen = luaL_checkinteger(L, 3); kad_node_t *t; t = kann_new_weight_conv1d(nout, nin, klen); @@ -886,7 +886,7 @@ lua_kann_save(lua_State *L) lua_getfield(L, 2, "filename"); if (lua_isstring(L, -1)) { - const gchar *fname = lua_tostring(L, -1); + const char *fname = lua_tostring(L, -1); FILE *f; f = fopen(fname, "w"); @@ -930,7 +930,7 @@ lua_kann_save(lua_State *L) t = lua_newuserdata(L, sizeof(*t)); rspamd_lua_setclass(L, rspamd_text_classname, -1); t->flags = RSPAMD_TEXT_FLAG_OWN; - t->start = (const gchar *) buf; + t->start = (const char *) buf; t->len = buflen; } } @@ -951,7 +951,7 @@ lua_kann_load(lua_State *L) lua_getfield(L, 2, "filename"); if (lua_isstring(L, -1)) { - const gchar *fname = lua_tostring(L, -1); + const char *fname = lua_tostring(L, -1); f = fopen(fname, "rb"); } @@ -965,7 +965,7 @@ lua_kann_load(lua_State *L) } else if (lua_isstring(L, 1)) { gsize dlen; - const gchar *data; + const char *data; data = lua_tolstring(L, 1, &dlen); @@ -1009,7 +1009,7 @@ lua_kann_load(lua_State *L) struct rspamd_kann_train_cbdata { lua_State *L; kann_t *k; - gint cbref; + int cbref; }; static void @@ -1018,7 +1018,7 @@ lua_kann_train_cb(int iter, float train_cost, float val_cost, void *ud) struct rspamd_kann_train_cbdata *cbd = (struct rspamd_kann_train_cbdata *) ud; if (cbd->cbref != -1) { - gint err_idx; + int err_idx; lua_State *L = cbd->L; lua_pushcfunction(L, &rspamd_lua_traceback); @@ -1056,7 +1056,7 @@ lua_kann_train1(lua_State *L) int64_t max_epoch = 25; int64_t max_drop_streak = 10; double frac_val = 0.1; - gint cbref = -1; + int cbref = -1; if (k && lua_istable(L, 2) && lua_istable(L, 3)) { int n = rspamd_lua_table_size(L, 2); @@ -1338,7 +1338,7 @@ lua_kann_apply1(lua_State *L) kann_feed_bind(k, KANN_F_IN, 0, &t->data); kad_eval_at(k->n, k->v, i_out); - gint outlen = kad_len(k->v[i_out]); + int outlen = kad_len(k->v[i_out]); struct rspamd_lua_tensor *out; out = lua_newtensor(L, 1, &outlen, false, false); /* Ensure that kann and tensor have the same understanding of floats */ diff --git a/src/lua/lua_logger.c b/src/lua/lua_logger.c index 9a0dacf46..21aad8136 100644 --- a/src/lua/lua_logger.c +++ b/src/lua/lua_logger.c @@ -177,13 +177,13 @@ static const struct luaL_reg loggerlib_f[] = { static void lua_common_log_line(GLogLevelFlags level, lua_State *L, - const gchar *msg, - const gchar *uid, - const gchar *module, - gint stack_level) + const char *msg, + const char *uid, + const char *module, + int stack_level) { lua_Debug d; - gchar func_buf[128], *p; + char func_buf[128], *p; if (lua_getstack(L, stack_level, &d) == 1) { (void) lua_getinfo(L, "Sl", &d); @@ -223,31 +223,31 @@ lua_common_log_line(GLogLevelFlags level, } /*** Logger interface ***/ -static gint +static int lua_logger_err(lua_State *L) { return lua_logger_errx(L); } -static gint +static int lua_logger_warn(lua_State *L) { return lua_logger_warnx(L); } -static gint +static int lua_logger_info(lua_State *L) { return lua_logger_infox(L); } -static gint +static int lua_logger_message(lua_State *L) { return lua_logger_messagex(L); } -static gint +static int lua_logger_debug(lua_State *L) { return lua_logger_debugx(L); @@ -280,14 +280,14 @@ lua_logger_char_safe(int t, unsigned int esc_type) } static gsize -lua_logger_out_str(lua_State *L, gint pos, - gchar *outbuf, gsize len, +lua_logger_out_str(lua_State *L, int pos, + char *outbuf, gsize len, struct lua_logger_trace *trace, enum lua_logger_escape_type esc_type) { gsize slen, flen; - const gchar *str = lua_tolstring(L, pos, &slen); - static const gchar hexdigests[16] = "0123456789abcdef"; + const char *str = lua_tolstring(L, pos, &slen); + static const char hexdigests[16] = "0123456789abcdef"; gsize r = 0, s; if (str) { @@ -339,14 +339,14 @@ lua_logger_out_str(lua_State *L, gint pos, } static gsize -lua_logger_out_num(lua_State *L, gint pos, gchar *outbuf, gsize len, +lua_logger_out_num(lua_State *L, int pos, char *outbuf, gsize len, struct lua_logger_trace *trace) { - gdouble num = lua_tonumber(L, pos); + double num = lua_tonumber(L, pos); glong inum; gsize r = 0; - if ((gdouble) (glong) num == num) { + if ((double) (glong) num == num) { inum = num; r = rspamd_snprintf(outbuf, len + 1, "%l", inum); } @@ -358,7 +358,7 @@ lua_logger_out_num(lua_State *L, gint pos, gchar *outbuf, gsize len, } static gsize -lua_logger_out_boolean(lua_State *L, gint pos, gchar *outbuf, gsize len, +lua_logger_out_boolean(lua_State *L, int pos, char *outbuf, gsize len, struct lua_logger_trace *trace) { gboolean val = lua_toboolean(L, pos); @@ -370,11 +370,11 @@ lua_logger_out_boolean(lua_State *L, gint pos, gchar *outbuf, gsize len, } static gsize -lua_logger_out_userdata(lua_State *L, gint pos, gchar *outbuf, gsize len, +lua_logger_out_userdata(lua_State *L, int pos, char *outbuf, gsize len, struct lua_logger_trace *trace) { - gint r = 0, top; - const gchar *str = NULL; + int r = 0, top; + const char *str = NULL; gboolean converted_to_str = FALSE; top = lua_gettop(L); @@ -469,15 +469,15 @@ lua_logger_out_userdata(lua_State *L, gint pos, gchar *outbuf, gsize len, } static gsize -lua_logger_out_table(lua_State *L, gint pos, gchar *outbuf, gsize len, +lua_logger_out_table(lua_State *L, int pos, char *outbuf, gsize len, struct lua_logger_trace *trace, enum lua_logger_escape_type esc_type) { - gchar *d = outbuf; + char *d = outbuf; gsize remain = len, r; gboolean first = TRUE; gconstpointer self = NULL; - gint i, tpos, last_seq = -1, old_top; + int i, tpos, last_seq = -1, old_top; if (!lua_istable(L, pos) || remain == 0) { return 0; @@ -587,12 +587,12 @@ lua_logger_out_table(lua_State *L, gint pos, gchar *outbuf, gsize len, #undef MOVE_BUF -gsize lua_logger_out_type(lua_State *L, gint pos, - gchar *outbuf, gsize len, +gsize lua_logger_out_type(lua_State *L, int pos, + char *outbuf, gsize len, struct lua_logger_trace *trace, enum lua_logger_escape_type esc_type) { - gint type; + int type; gsize r = 0; if (len == 0) { @@ -638,10 +638,10 @@ gsize lua_logger_out_type(lua_State *L, gint pos, return r; } -static const gchar * -lua_logger_get_id(lua_State *L, gint pos, GError **err) +static const char * +lua_logger_get_id(lua_State *L, int pos, GError **err) { - const gchar *uid = NULL, *clsname; + const char *uid = NULL, *clsname; if (lua_getmetatable(L, pos) != 0) { uid = ""; @@ -728,13 +728,13 @@ lua_logger_get_id(lua_State *L, gint pos, GError **err) } static gboolean -lua_logger_log_format(lua_State *L, gint fmt_pos, gboolean is_string, - gchar *logbuf, gsize remain) +lua_logger_log_format(lua_State *L, int fmt_pos, gboolean is_string, + char *logbuf, gsize remain) { - gchar *d; - const gchar *s, *c; + char *d; + const char *s, *c; gsize r, cpylen = 0; - guint arg_num = 0, cur_arg; + unsigned int arg_num = 0, cur_arg; bool num_arg = false; struct lua_logger_trace tr; enum { @@ -799,7 +799,7 @@ lua_logger_log_format(lua_State *L, gint fmt_pos, gboolean is_string, s++; } - if (arg_num < 1 || arg_num > (guint) lua_gettop(L) + 1) { + if (arg_num < 1 || arg_num > (unsigned int) lua_gettop(L) + 1) { msg_err("wrong argument number: %ud", arg_num); return FALSE; @@ -828,7 +828,7 @@ lua_logger_log_format(lua_State *L, gint fmt_pos, gboolean is_string, arg_num = cur_arg; } - if (arg_num < 1 || arg_num > (guint) lua_gettop(L) + 1) { + if (arg_num < 1 || arg_num > (unsigned int) lua_gettop(L) + 1) { msg_err("wrong argument number: %ud", arg_num); return FALSE; @@ -854,16 +854,16 @@ lua_logger_log_format(lua_State *L, gint fmt_pos, gboolean is_string, return TRUE; } -static gint +static int lua_logger_do_log(lua_State *L, GLogLevelFlags level, gboolean is_string, - gint start_pos) + int start_pos) { - gchar logbuf[RSPAMD_LOGBUF_SIZE - 128]; - const gchar *uid = NULL; - gint fmt_pos = start_pos; - gint ret; + char logbuf[RSPAMD_LOGBUF_SIZE - 128]; + const char *uid = NULL; + int fmt_pos = start_pos; + int ret; GError *err = NULL; if (lua_type(L, start_pos) == LUA_TSTRING) { @@ -914,50 +914,50 @@ lua_logger_do_log(lua_State *L, return 0; } -static gint +static int lua_logger_errx(lua_State *L) { LUA_TRACE_POINT; return lua_logger_do_log(L, G_LOG_LEVEL_CRITICAL, FALSE, 1); } -static gint +static int lua_logger_warnx(lua_State *L) { LUA_TRACE_POINT; return lua_logger_do_log(L, G_LOG_LEVEL_WARNING, FALSE, 1); } -static gint +static int lua_logger_infox(lua_State *L) { LUA_TRACE_POINT; return lua_logger_do_log(L, G_LOG_LEVEL_INFO, FALSE, 1); } -static gint +static int lua_logger_messagex(lua_State *L) { LUA_TRACE_POINT; return lua_logger_do_log(L, G_LOG_LEVEL_MESSAGE, FALSE, 1); } -static gint +static int lua_logger_debugx(lua_State *L) { LUA_TRACE_POINT; return lua_logger_do_log(L, G_LOG_LEVEL_DEBUG, FALSE, 1); } -static gint +static int lua_logger_logx(lua_State *L) { LUA_TRACE_POINT; GLogLevelFlags flags = lua_tonumber(L, 1); - const gchar *modname = lua_tostring(L, 2), *uid = NULL; - gchar logbuf[RSPAMD_LOGBUF_SIZE - 128]; + const char *modname = lua_tostring(L, 2), *uid = NULL; + char logbuf[RSPAMD_LOGBUF_SIZE - 128]; gboolean ret; - gint stack_pos = 1; + int stack_pos = 1; if (lua_type(L, 3) == LUA_TSTRING) { uid = luaL_checkstring(L, 3); @@ -993,13 +993,13 @@ lua_logger_logx(lua_State *L) } -static gint +static int lua_logger_debugm(lua_State *L) { LUA_TRACE_POINT; - gchar logbuf[RSPAMD_LOGBUF_SIZE - 128]; - const gchar *uid = NULL, *module = NULL; - gint stack_pos = 1; + char logbuf[RSPAMD_LOGBUF_SIZE - 128]; + const char *uid = NULL, *module = NULL; + int stack_pos = 1; gboolean ret; module = luaL_checkstring(L, 1); @@ -1035,16 +1035,16 @@ lua_logger_debugm(lua_State *L) } -static gint +static int lua_logger_slog(lua_State *L) { return lua_logger_do_log(L, 0, TRUE, 1); } -static gint +static int lua_logger_log_level(lua_State *L) { - gint log_level = rspamd_log_get_log_level(NULL); + int log_level = rspamd_log_get_log_level(NULL); lua_pushstring(L, rspamd_get_log_severity_string(log_level)); @@ -1053,7 +1053,7 @@ lua_logger_log_level(lua_State *L) /*** Init functions ***/ -static gint +static int lua_load_logger(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c index b68665b3c..cce78ff2c 100644 --- a/src/lua/lua_map.c +++ b/src/lua/lua_map.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, @@ -174,25 +174,25 @@ static const struct luaL_reg maplib_m[] = { struct lua_map_callback_data { lua_State *L; - gint ref; + int ref; gboolean opaque; rspamd_fstring_t *data; struct rspamd_lua_map *lua_map; }; struct rspamd_lua_map * -lua_check_map(lua_State *L, gint pos) +lua_check_map(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_map_classname); luaL_argcheck(L, ud != NULL, pos, "'map' expected"); return ud ? *((struct rspamd_lua_map **) ud) : NULL; } -gint lua_config_add_radix_map(lua_State *L) +int lua_config_add_radix_map(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *map_line, *description; + const char *map_line, *description; struct rspamd_lua_map *map, **pmap; struct rspamd_map *m; @@ -228,11 +228,11 @@ gint lua_config_add_radix_map(lua_State *L) return 1; } -gint lua_config_radix_from_config(lua_State *L) +int lua_config_radix_from_config(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *mname, *optname; + const char *mname, *optname; const ucl_object_t *obj; struct rspamd_lua_map *map, **pmap; ucl_object_t *fake_obj; @@ -293,7 +293,7 @@ gint lua_config_radix_from_config(lua_State *L) } -gint lua_config_radix_from_ucl(lua_State *L) +int lua_config_radix_from_ucl(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); @@ -348,11 +348,11 @@ gint lua_config_radix_from_ucl(lua_State *L) return 1; } -gint lua_config_add_hash_map(lua_State *L) +int lua_config_add_hash_map(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *map_line, *description; + const char *map_line, *description; struct rspamd_lua_map *map, **pmap; struct rspamd_map *m; @@ -387,11 +387,11 @@ gint lua_config_add_hash_map(lua_State *L) return 1; } -gint lua_config_add_kv_map(lua_State *L) +int lua_config_add_kv_map(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *map_line, *description; + const char *map_line, *description; struct rspamd_lua_map *map, **pmap; struct rspamd_map *m; @@ -428,8 +428,8 @@ gint lua_config_add_kv_map(lua_State *L) } -static gchar * -lua_map_read(gchar *chunk, gint len, +static char * +lua_map_read(char *chunk, int len, struct map_cb_data *data, gboolean final) { @@ -517,7 +517,7 @@ lua_map_fin(struct map_cb_data *data, void **target) *pmap = cbdata->lua_map; rspamd_lua_setclass(cbdata->L, rspamd_map_classname, -1); - gint ret = lua_pcall(cbdata->L, 2, 0, err_idx); + int ret = lua_pcall(cbdata->L, 2, 0, err_idx); if (ret != 0) { msg_info_map("call to %s failed (%d): %s", "map fin function", @@ -557,12 +557,12 @@ lua_map_dtor(struct map_cb_data *data) } } -gint lua_config_add_map(lua_State *L) +int lua_config_add_map(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); const char *description = NULL; - const gchar *type = NULL; + const char *type = NULL; ucl_object_t *map_obj = NULL; struct lua_map_callback_data *cbdata; struct rspamd_lua_map *map, **pmap; @@ -792,13 +792,13 @@ gint lua_config_add_map(lua_State *L) return 1; } -gint lua_config_get_maps(lua_State *L) +int lua_config_get_maps(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); struct rspamd_lua_map *map, **pmap; struct rspamd_map *m; - gint i = 1; + int i = 1; GList *cur; if (cfg) { @@ -847,8 +847,8 @@ gint lua_config_get_maps(lua_State *L) return 1; } -static const gchar * -lua_map_process_string_key(lua_State *L, gint pos, gsize *len) +static const char * +lua_map_process_string_key(lua_State *L, int pos, gsize *len) { struct rspamd_lua_text *t; @@ -868,14 +868,14 @@ lua_map_process_string_key(lua_State *L, gint pos, gsize *len) } /* Radix and hash table functions */ -static gint +static int lua_map_get_key(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_map *map = lua_check_map(L, 1); struct rspamd_radix_map_helper *radix; struct rspamd_lua_ip *addr = NULL; - const gchar *key, *value = NULL; + const char *key, *value = NULL; gpointer ud; gsize len; uint32_t key_num = 0; @@ -886,7 +886,7 @@ lua_map_get_key(lua_State *L) radix = map->data.radix; if (lua_type(L, 2) == LUA_TSTRING) { - const gchar *addr_str; + const char *addr_str; addr_str = luaL_checklstring(L, 2, &len); addr = g_alloca(sizeof(*addr)); @@ -927,7 +927,7 @@ lua_map_get_key(lua_State *L) } else if (key_num != 0) { if ((p = rspamd_match_radix_map(radix, - (guint8 *) &key_num, sizeof(key_num))) != NULL) { + (uint8_t *) &key_num, sizeof(key_num))) != NULL) { ret = TRUE; } else { @@ -965,8 +965,8 @@ lua_map_get_key(lua_State *L) } else if (map->type == RSPAMD_LUA_MAP_REGEXP_MULTIPLE) { GPtrArray *ar; - guint i; - const gchar *val; + unsigned int i; + const char *val; key = lua_map_process_string_key(L, 2, &len); @@ -1044,7 +1044,7 @@ lua_map_traverse_cb(gconstpointer key, return TRUE; } -static gint +static int lua_map_get_stats(lua_State *L) { LUA_TRACE_POINT; @@ -1071,7 +1071,7 @@ lua_map_get_stats(lua_State *L) struct lua_map_traverse_cbdata { lua_State *L; - gint cbref; + int cbref; gboolean use_text; }; @@ -1111,7 +1111,7 @@ lua_map_foreach_cb(gconstpointer key, gconstpointer value, gsize _hits, gpointer return TRUE; } -static gint +static int lua_map_foreach(lua_State *L) { LUA_TRACE_POINT; @@ -1143,12 +1143,12 @@ lua_map_foreach(lua_State *L) return 1; } -static gint +static int lua_map_get_data_digest(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_map *map = lua_check_map(L, 1); - gchar numbuf[64]; + char numbuf[64]; if (map != NULL) { rspamd_snprintf(numbuf, sizeof(numbuf), "%uL", map->map->digest); @@ -1161,7 +1161,7 @@ lua_map_get_data_digest(lua_State *L) return 1; } -static gint +static int lua_map_get_nelts(lua_State *L) { LUA_TRACE_POINT; @@ -1184,7 +1184,7 @@ lua_map_is_signed(lua_State *L) struct rspamd_lua_map *map = lua_check_map(L, 1); gboolean ret = FALSE; struct rspamd_map_backend *bk; - guint i; + unsigned int i; if (map != NULL) { if (map->map) { @@ -1210,9 +1210,9 @@ lua_map_get_proto(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_map *map = lua_check_map(L, 1); - const gchar *ret = "undefined"; + const char *ret = "undefined"; struct rspamd_map_backend *bk; - guint i; + unsigned int i; if (map != NULL) { for (i = 0; i < map->map->backends->len; i++) { @@ -1248,7 +1248,7 @@ lua_map_get_sign_key(lua_State *L) LUA_TRACE_POINT; struct rspamd_lua_map *map = lua_check_map(L, 1); struct rspamd_map_backend *bk; - guint i; + unsigned int i; GString *ret = NULL; if (map != NULL) { @@ -1285,10 +1285,10 @@ lua_map_set_sign_key(lua_State *L) LUA_TRACE_POINT; struct rspamd_lua_map *map = lua_check_map(L, 1); struct rspamd_map_backend *bk; - const gchar *pk_str; + const char *pk_str; struct rspamd_cryptobox_pubkey *pk; gsize len; - guint i; + unsigned int i; pk_str = lua_tolstring(L, 2, &len); @@ -1346,7 +1346,7 @@ lua_map_get_uri(lua_State *L) LUA_TRACE_POINT; struct rspamd_lua_map *map = lua_check_map(L, 1); struct rspamd_map_backend *bk; - guint i; + unsigned int i; if (map != NULL) { for (i = 0; i < map->map->backends->len; i++) { @@ -1363,7 +1363,7 @@ lua_map_get_uri(lua_State *L) struct lua_map_on_load_cbdata { lua_State *L; - gint ref; + int ref; }; static void @@ -1388,7 +1388,7 @@ lua_map_on_load_handler(struct rspamd_map *map, gpointer ud) } } -static gint +static int lua_map_on_load(lua_State *L) { LUA_TRACE_POINT; diff --git a/src/lua/lua_mempool.c b/src/lua/lua_mempool.c index f272b5173..ddc9b25e9 100644 --- a/src/lua/lua_mempool.c +++ b/src/lua/lua_mempool.c @@ -142,12 +142,12 @@ static const struct luaL_reg mempoollib_f[] = { struct lua_mempool_udata { lua_State *L; - gint cbref; + int cbref; rspamd_mempool_t *mempool; }; struct memory_pool_s * -rspamd_lua_check_mempool(lua_State *L, gint pos) +rspamd_lua_check_mempool(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_mempool_classname); luaL_argcheck(L, ud != NULL, pos, "'mempool' expected"); @@ -269,8 +269,8 @@ lua_mempool_suggest_size(lua_State *L) } struct lua_numbers_bucket { - guint nelts; - gdouble elts[0]; + unsigned int nelts; + double elts[0]; }; static int @@ -278,13 +278,13 @@ lua_mempool_set_bucket(lua_State *L) { LUA_TRACE_POINT; struct memory_pool_s *mempool = rspamd_lua_check_mempool(L, 1); - const gchar *var = luaL_checkstring(L, 2); + const char *var = luaL_checkstring(L, 2); struct lua_numbers_bucket *bucket; - gint nelts = luaL_checknumber(L, 3), i; + int nelts = luaL_checknumber(L, 3), i; if (var && nelts > 0) { bucket = rspamd_mempool_alloc(mempool, - sizeof(*bucket) + sizeof(gdouble) * nelts); + sizeof(*bucket) + sizeof(double) * nelts); bucket->nelts = nelts; if (lua_type(L, 4) == LUA_TTABLE) { @@ -315,17 +315,17 @@ lua_mempool_set_variable(lua_State *L) { LUA_TRACE_POINT; struct memory_pool_s *mempool = rspamd_lua_check_mempool(L, 1); - const gchar *var = luaL_checkstring(L, 2); + const char *var = luaL_checkstring(L, 2); gpointer value; struct lua_numbers_bucket *bucket; - gchar *vp; + char *vp; union { - gdouble d; - const gchar *s; + double d; + const char *s; gboolean b; } val; gsize slen; - gint i, j, len = 0, type; + int i, j, len = 0, type; if (mempool && var) { @@ -334,7 +334,7 @@ lua_mempool_set_variable(lua_State *L) if (type == LUA_TNUMBER) { /* We have some ambiguity here between integer and double */ - len += sizeof(gdouble); + len += sizeof(double); } else if (type == LUA_TBOOLEAN) { len += sizeof(gboolean); @@ -346,7 +346,7 @@ lua_mempool_set_variable(lua_State *L) else if (type == LUA_TTABLE) { /* We assume it as a bucket of numbers so far */ slen = rspamd_lua_table_size(L, i); - len += sizeof(gdouble) * slen + sizeof(*bucket); + len += sizeof(double) * slen + sizeof(*bucket); } else { msg_err("cannot handle lua type %s", lua_typename(L, type)); @@ -365,8 +365,8 @@ lua_mempool_set_variable(lua_State *L) if (type == LUA_TNUMBER) { val.d = lua_tonumber(L, i); - memcpy(vp, &val, sizeof(gdouble)); - vp += sizeof(gdouble); + memcpy(vp, &val, sizeof(double)); + vp += sizeof(double); } else if (type == LUA_TBOOLEAN) { val.b = lua_toboolean(L, i); @@ -390,7 +390,7 @@ lua_mempool_set_variable(lua_State *L) lua_pop(L, 1); } - vp += sizeof(gdouble) * slen + sizeof(*bucket); + vp += sizeof(double) * slen + sizeof(*bucket); } else { msg_err("cannot handle lua type %s", lua_typename(L, type)); @@ -415,11 +415,11 @@ lua_mempool_get_variable(lua_State *L) { LUA_TRACE_POINT; struct memory_pool_s *mempool = rspamd_lua_check_mempool(L, 1); - const gchar *var = luaL_checkstring(L, 2); - const gchar *type = NULL, *pt; + const char *var = luaL_checkstring(L, 2); + const char *type = NULL, *pt; struct lua_numbers_bucket bucket; - const gchar *value, *pv; - guint len, nvar, slen, i; + const char *value, *pv; + unsigned int len, nvar, slen, i; if (mempool && var) { value = rspamd_mempool_get_variable(mempool, var); @@ -438,17 +438,17 @@ lua_mempool_get_variable(lua_State *L) while ((len = strcspn(pt, ", ")) > 0) { if (len == sizeof("double") - 1 && g_ascii_strncasecmp(pt, "double", len) == 0) { - gdouble num; - memcpy(&num, pv, sizeof(gdouble)); + double num; + memcpy(&num, pv, sizeof(double)); lua_pushnumber(L, num); - pv += sizeof(gdouble); + pv += sizeof(double); } else if (len == sizeof("int") - 1 && g_ascii_strncasecmp(pt, "int", len) == 0) { - gint num; - memcpy(&num, pv, sizeof(gint)); + int num; + memcpy(&num, pv, sizeof(int)); lua_pushinteger(L, num); - pv += sizeof(gint); + pv += sizeof(int); } else if (len == sizeof("int64") - 1 && g_ascii_strncasecmp(pt, "int64", len) == 0) { @@ -466,8 +466,8 @@ lua_mempool_get_variable(lua_State *L) } else if (len == sizeof("string") - 1 && g_ascii_strncasecmp(pt, "string", len) == 0) { - slen = strlen((const gchar *) pv); - lua_pushlstring(L, (const gchar *) pv, slen); + slen = strlen((const char *) pv); + lua_pushlstring(L, (const char *) pv, slen); pv += slen + 1; } else if (len == sizeof("gstring") - 1 && @@ -483,7 +483,7 @@ lua_mempool_get_variable(lua_State *L) pv += sizeof(struct lua_numbers_bucket); for (i = 0; i < bucket.nelts; i++) { - gdouble num; + double num; memcpy(&num, pv, sizeof(num)); lua_pushnumber(L, num); lua_rawseti(L, -2, i + 1); @@ -543,7 +543,7 @@ lua_mempool_has_variable(lua_State *L) { LUA_TRACE_POINT; struct memory_pool_s *mempool = rspamd_lua_check_mempool(L, 1); - const gchar *var = luaL_checkstring(L, 2); + const char *var = luaL_checkstring(L, 2); gboolean ret = FALSE; if (mempool && var) { @@ -562,7 +562,7 @@ lua_mempool_delete_variable(lua_State *L) { LUA_TRACE_POINT; struct memory_pool_s *mempool = rspamd_lua_check_mempool(L, 1); - const gchar *var = luaL_checkstring(L, 2); + const char *var = luaL_checkstring(L, 2); gboolean ret = FALSE; if (mempool && var) { @@ -578,7 +578,7 @@ lua_mempool_delete_variable(lua_State *L) return 1; } -static gint +static int lua_mempool_topointer(lua_State *L) { LUA_TRACE_POINT; @@ -595,7 +595,7 @@ lua_mempool_topointer(lua_State *L) return 1; } -static gint +static int lua_load_mempool(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c index 41609848a..07dba9c93 100644 --- a/src/lua/lua_mimepart.c +++ b/src/lua/lua_mimepart.c @@ -623,7 +623,7 @@ lua_check_mimepart(lua_State *L) } -static gint +static int lua_textpart_is_utf(lua_State *L) { LUA_TRACE_POINT; @@ -640,7 +640,7 @@ lua_textpart_is_utf(lua_State *L) } -static gint +static int lua_textpart_has_8bit_raw(lua_State *L) { LUA_TRACE_POINT; @@ -661,7 +661,7 @@ lua_textpart_has_8bit_raw(lua_State *L) return 1; } -static gint +static int lua_textpart_has_8bit(lua_State *L) { LUA_TRACE_POINT; @@ -683,14 +683,14 @@ lua_textpart_has_8bit(lua_State *L) } -static gint +static int lua_textpart_get_content(lua_State *L) { LUA_TRACE_POINT; struct rspamd_mime_text_part *part = lua_check_textpart(L); struct rspamd_lua_text *t; gsize len; - const gchar *start, *type = NULL; + const char *start, *type = NULL; if (part == NULL) { lua_pushnil(L); @@ -768,7 +768,7 @@ lua_textpart_get_content(lua_State *L) return 1; } -static gint +static int lua_textpart_get_raw_content(lua_State *L) { LUA_TRACE_POINT; @@ -789,7 +789,7 @@ lua_textpart_get_raw_content(lua_State *L) return 1; } -static gint +static int lua_textpart_get_content_oneline(lua_State *L) { LUA_TRACE_POINT; @@ -805,7 +805,7 @@ lua_textpart_get_content_oneline(lua_State *L) return 1; } -static gint +static int lua_textpart_get_length(lua_State *L) { LUA_TRACE_POINT; @@ -826,7 +826,7 @@ lua_textpart_get_length(lua_State *L) return 1; } -static gint +static int lua_textpart_get_raw_length(lua_State *L) { LUA_TRACE_POINT; @@ -842,13 +842,13 @@ lua_textpart_get_raw_length(lua_State *L) return 1; } -static gint +static int lua_textpart_get_urls_length(lua_State *L) { LUA_TRACE_POINT; struct rspamd_mime_text_part *part = lua_check_textpart(L); GList *cur; - guint total = 0; + unsigned int total = 0; struct rspamd_process_exception *ex; if (part == NULL) { @@ -869,7 +869,7 @@ lua_textpart_get_urls_length(lua_State *L) return 1; } -static gint +static int lua_textpart_get_lines_count(lua_State *L) { LUA_TRACE_POINT; @@ -890,7 +890,7 @@ lua_textpart_get_lines_count(lua_State *L) return 1; } -static gint +static int lua_textpart_get_words_count(lua_State *L) { LUA_TRACE_POINT; @@ -912,7 +912,7 @@ lua_textpart_get_words_count(lua_State *L) } static inline enum rspamd_lua_words_type -word_extract_type_from_string(const gchar *how_str) +word_extract_type_from_string(const char *how_str) { enum rspamd_lua_words_type how = RSPAMD_LUA_WORDS_MAX; @@ -932,7 +932,7 @@ word_extract_type_from_string(const gchar *how_str) return how; } -static gint +static int lua_textpart_get_words(lua_State *L) { LUA_TRACE_POINT; @@ -948,7 +948,7 @@ lua_textpart_get_words(lua_State *L) } else { if (lua_type(L, 2) == LUA_TSTRING) { - const gchar *how_str = lua_tostring(L, 2); + const char *how_str = lua_tostring(L, 2); how = word_extract_type_from_string(how_str); @@ -963,13 +963,13 @@ lua_textpart_get_words(lua_State *L) return 1; } -static gint +static int lua_textpart_filter_words(lua_State *L) { LUA_TRACE_POINT; struct rspamd_mime_text_part *part = lua_check_textpart(L); struct rspamd_lua_regexp *re = lua_check_regexp(L, 2); - gint lim = -1; + int lim = -1; enum rspamd_lua_words_type how = RSPAMD_LUA_WORDS_STEM; if (part == NULL || re == NULL) { @@ -981,7 +981,7 @@ lua_textpart_filter_words(lua_State *L) } else { if (lua_type(L, 3) == LUA_TSTRING) { - const gchar *how_str = lua_tostring(L, 3); + const char *how_str = lua_tostring(L, 3); how = word_extract_type_from_string(how_str); @@ -994,7 +994,7 @@ lua_textpart_filter_words(lua_State *L) lim = lua_tointeger(L, 4); } - guint cnt, i; + unsigned int cnt, i; lua_createtable(L, 8, 0); @@ -1051,7 +1051,7 @@ lua_textpart_filter_words(lua_State *L) return 1; } -static gint +static int lua_textpart_is_empty(lua_State *L) { LUA_TRACE_POINT; @@ -1067,7 +1067,7 @@ lua_textpart_is_empty(lua_State *L) return 1; } -static gint +static int lua_textpart_is_html(lua_State *L) { LUA_TRACE_POINT; @@ -1083,7 +1083,7 @@ lua_textpart_is_html(lua_State *L) return 1; } -static gint +static int lua_textpart_get_html(lua_State *L) { LUA_TRACE_POINT; @@ -1102,7 +1102,7 @@ lua_textpart_get_html(lua_State *L) return 1; } -static gint +static int lua_textpart_get_language(lua_State *L) { LUA_TRACE_POINT; @@ -1124,7 +1124,7 @@ lua_textpart_get_language(lua_State *L) return 1; } -static gint +static int lua_textpart_get_charset(lua_State *L) { LUA_TRACE_POINT; @@ -1146,12 +1146,12 @@ lua_textpart_get_charset(lua_State *L) return 1; } -static gint +static int lua_textpart_get_languages(lua_State *L) { LUA_TRACE_POINT; struct rspamd_mime_text_part *part = lua_check_textpart(L); - guint i; + unsigned int i; struct rspamd_lang_detector_res *cur; if (part != NULL) { @@ -1205,7 +1205,7 @@ struct lua_shingle_filter_cbdata { static uint64_t lua_shingles_filter(uint64_t *input, gsize count, - gint shno, const guchar *key, gpointer ud) + int shno, const unsigned char *key, gpointer ud) { uint64_t minimal = G_MAXUINT64; gsize i, min_idx = 0; @@ -1236,16 +1236,16 @@ lua_shingles_filter(uint64_t *input, gsize count, #undef STORE_TOKEN -static gint +static int lua_textpart_get_fuzzy_hashes(lua_State *L) { LUA_TRACE_POINT; struct rspamd_mime_text_part *part = lua_check_textpart(L); rspamd_mempool_t *pool = rspamd_lua_check_mempool(L, 2); - guchar key[rspamd_cryptobox_HASHBYTES], digest[rspamd_cryptobox_HASHBYTES], + unsigned char key[rspamd_cryptobox_HASHBYTES], digest[rspamd_cryptobox_HASHBYTES], hexdigest[rspamd_cryptobox_HASHBYTES * 2 + 1], numbuf[64]; struct rspamd_shingle *sgl; - guint i; + unsigned int i; struct lua_shingle_data *sd; rspamd_cryptobox_hash_state_t st; rspamd_stat_token_t *word; @@ -1318,7 +1318,7 @@ lua_textpart_get_fuzzy_hashes(lua_State *L) return 2; } -static gint +static int lua_textpart_get_mimepart(lua_State *L) { LUA_TRACE_POINT; @@ -1351,7 +1351,7 @@ lua_textpart_get_mimepart(lua_State *L) * - `ascii_characters`: number of ascii characters * @return {table} table of stats */ -static gint +static int lua_textpart_get_stats(lua_State *L) { LUA_TRACE_POINT; @@ -1397,7 +1397,7 @@ lua_textpart_get_stats(lua_State *L) /* Mimepart implementation */ -static gint +static int lua_mimepart_get_content(lua_State *L) { LUA_TRACE_POINT; @@ -1422,7 +1422,7 @@ lua_mimepart_get_content(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_raw_content(lua_State *L) { LUA_TRACE_POINT; @@ -1443,7 +1443,7 @@ lua_mimepart_get_raw_content(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_length(lua_State *L) { LUA_TRACE_POINT; @@ -1459,7 +1459,7 @@ lua_mimepart_get_length(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_type_common(lua_State *L, struct rspamd_content_type *ct, gboolean full) { @@ -1513,7 +1513,7 @@ lua_mimepart_get_type_common(lua_State *L, struct rspamd_content_type *ct, return 3; } -static gint +static int lua_mimepart_get_type(lua_State *L) { LUA_TRACE_POINT; @@ -1526,7 +1526,7 @@ lua_mimepart_get_type(lua_State *L) return lua_mimepart_get_type_common(L, part->ct, FALSE); } -static gint +static int lua_mimepart_get_type_full(lua_State *L) { LUA_TRACE_POINT; @@ -1539,7 +1539,7 @@ lua_mimepart_get_type_full(lua_State *L) return lua_mimepart_get_type_common(L, part->ct, TRUE); } -static gint +static int lua_mimepart_get_detected_type(lua_State *L) { LUA_TRACE_POINT; @@ -1552,7 +1552,7 @@ lua_mimepart_get_detected_type(lua_State *L) return lua_mimepart_get_type_common(L, part->detected_ct, FALSE); } -static gint +static int lua_mimepart_get_detected_type_full(lua_State *L) { LUA_TRACE_POINT; @@ -1565,7 +1565,7 @@ lua_mimepart_get_detected_type_full(lua_State *L) return lua_mimepart_get_type_common(L, part->detected_ct, TRUE); } -static gint +static int lua_mimepart_get_detected_ext(lua_State *L) { LUA_TRACE_POINT; @@ -1585,7 +1585,7 @@ lua_mimepart_get_detected_ext(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_cte(lua_State *L) { LUA_TRACE_POINT; @@ -1601,7 +1601,7 @@ lua_mimepart_get_cte(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_filename(lua_State *L) { LUA_TRACE_POINT; @@ -1617,7 +1617,7 @@ lua_mimepart_get_filename(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_boundary(lua_State *L) { LUA_TRACE_POINT; @@ -1646,7 +1646,7 @@ lua_mimepart_get_boundary(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_enclosing_boundary(lua_State *L) { LUA_TRACE_POINT; @@ -1669,11 +1669,11 @@ lua_mimepart_get_enclosing_boundary(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_header_common(lua_State *L, enum rspamd_lua_task_header_type how) { struct rspamd_mime_part *part = lua_check_mimepart(L); - const gchar *name; + const char *name; gboolean strong = FALSE; name = luaL_checkstring(L, 2); @@ -1696,35 +1696,35 @@ lua_mimepart_get_header_common(lua_State *L, enum rspamd_lua_task_header_type ho return 1; } -static gint +static int lua_mimepart_get_header_full(lua_State *L) { LUA_TRACE_POINT; return lua_mimepart_get_header_common(L, RSPAMD_TASK_HEADER_PUSH_FULL); } -static gint +static int lua_mimepart_get_header(lua_State *L) { LUA_TRACE_POINT; return lua_mimepart_get_header_common(L, RSPAMD_TASK_HEADER_PUSH_SIMPLE); } -static gint +static int lua_mimepart_get_header_raw(lua_State *L) { LUA_TRACE_POINT; return lua_mimepart_get_header_common(L, RSPAMD_TASK_HEADER_PUSH_RAW); } -static gint +static int lua_mimepart_get_header_count(lua_State *L) { LUA_TRACE_POINT; return lua_mimepart_get_header_common(L, RSPAMD_TASK_HEADER_PUSH_COUNT); } -static gint +static int lua_mimepart_get_raw_headers(lua_State *L) { LUA_TRACE_POINT; @@ -1746,7 +1746,7 @@ lua_mimepart_get_raw_headers(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_headers(lua_State *L) { LUA_TRACE_POINT; @@ -1784,7 +1784,7 @@ lua_mimepart_get_headers(lua_State *L) } -static gint +static int lua_mimepart_is_image(lua_State *L) { LUA_TRACE_POINT; @@ -1799,7 +1799,7 @@ lua_mimepart_is_image(lua_State *L) return 1; } -static gint +static int lua_mimepart_is_archive(lua_State *L) { LUA_TRACE_POINT; @@ -1814,7 +1814,7 @@ lua_mimepart_is_archive(lua_State *L) return 1; } -static gint +static int lua_mimepart_is_multipart(lua_State *L) { LUA_TRACE_POINT; @@ -1829,7 +1829,7 @@ lua_mimepart_is_multipart(lua_State *L) return 1; } -static gint +static int lua_mimepart_is_message(lua_State *L) { LUA_TRACE_POINT; @@ -1844,7 +1844,7 @@ lua_mimepart_is_message(lua_State *L) return 1; } -static gint +static int lua_mimepart_is_attachment(lua_State *L) { LUA_TRACE_POINT; @@ -1880,7 +1880,7 @@ lua_mimepart_is_attachment(lua_State *L) return 1; } -static gint +static int lua_mimepart_is_text(lua_State *L) { LUA_TRACE_POINT; @@ -1895,7 +1895,7 @@ lua_mimepart_is_text(lua_State *L) return 1; } -static gint +static int lua_mimepart_is_broken(lua_State *L) { LUA_TRACE_POINT; @@ -1915,7 +1915,7 @@ lua_mimepart_is_broken(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_image(lua_State *L) { LUA_TRACE_POINT; @@ -1938,7 +1938,7 @@ lua_mimepart_get_image(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_archive(lua_State *L) { LUA_TRACE_POINT; @@ -1961,13 +1961,13 @@ lua_mimepart_get_archive(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_children(lua_State *L) { LUA_TRACE_POINT; struct rspamd_mime_part *part = lua_check_mimepart(L); struct rspamd_mime_part **pcur, *cur; - guint i; + unsigned int i; if (part == NULL) { return luaL_error(L, "invalid arguments"); @@ -1991,7 +1991,7 @@ lua_mimepart_get_children(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_parent(lua_State *L) { LUA_TRACE_POINT; @@ -2015,7 +2015,7 @@ lua_mimepart_get_parent(lua_State *L) } -static gint +static int lua_mimepart_get_text(lua_State *L) { LUA_TRACE_POINT; @@ -2038,12 +2038,12 @@ lua_mimepart_get_text(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_digest(lua_State *L) { LUA_TRACE_POINT; struct rspamd_mime_part *part = lua_check_mimepart(L); - gchar digestbuf[rspamd_cryptobox_HASHBYTES * 2 + 1]; + char digestbuf[rspamd_cryptobox_HASHBYTES * 2 + 1]; if (part == NULL) { return luaL_error(L, "invalid arguments"); @@ -2057,7 +2057,7 @@ lua_mimepart_get_digest(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_id(lua_State *L) { LUA_TRACE_POINT; @@ -2072,7 +2072,7 @@ lua_mimepart_get_id(lua_State *L) return 1; } -static gint +static int lua_mimepart_headers_foreach(lua_State *L) { LUA_TRACE_POINT; @@ -2080,7 +2080,7 @@ lua_mimepart_headers_foreach(lua_State *L) enum rspamd_lua_task_header_type how = RSPAMD_TASK_HEADER_PUSH_SIMPLE; struct rspamd_lua_regexp *re = NULL; struct rspamd_mime_header *hdr, *cur; - gint old_top; + int old_top; if (part && lua_isfunction(L, 2)) { if (lua_istable(L, 3)) { @@ -2155,7 +2155,7 @@ lua_mimepart_headers_foreach(lua_State *L) return 0; } -static gint +static int lua_mimepart_get_specific(lua_State *L) { LUA_TRACE_POINT; @@ -2175,7 +2175,7 @@ lua_mimepart_get_specific(lua_State *L) return 1; } -static gint +static int lua_mimepart_get_urls(lua_State *L) { LUA_TRACE_POINT; @@ -2187,8 +2187,8 @@ lua_mimepart_get_urls(lua_State *L) struct lua_tree_cb_data cb; struct rspamd_url *u; - static const gint default_protocols_mask = PROTOCOL_HTTP | PROTOCOL_HTTPS | - PROTOCOL_FILE | PROTOCOL_FTP; + static const int default_protocols_mask = PROTOCOL_HTTP | PROTOCOL_HTTPS | + PROTOCOL_FILE | PROTOCOL_FTP; gsize sz, max_urls = 0, i; if (part->urls == NULL) { @@ -2216,7 +2216,7 @@ lua_mimepart_get_urls(lua_State *L) return 1; } -static gint +static int lua_mimepart_is_specific(lua_State *L) { LUA_TRACE_POINT; @@ -2231,7 +2231,7 @@ lua_mimepart_is_specific(lua_State *L) return 1; } -static gint +static int lua_mimepart_set_specific(lua_State *L) { LUA_TRACE_POINT; @@ -2263,7 +2263,7 @@ lua_mimepart_set_specific(lua_State *L) part->specific.lua_specific.cbref = luaL_ref(L, LUA_REGISTRYINDEX); /* Now stack has just a return value as luaL_ref removes value from stack */ - gint ltype = lua_type(L, 2); + int ltype = lua_type(L, 2); switch (ltype) { case LUA_TTABLE: diff --git a/src/lua/lua_parsers.c b/src/lua/lua_parsers.c index 1fc71db33..f77b36952 100644 --- a/src/lua/lua_parsers.c +++ b/src/lua/lua_parsers.c @@ -99,10 +99,10 @@ static const struct luaL_reg parserslib_f[] = { {NULL, NULL}}; -gint lua_parsers_tokenize_text(lua_State *L) +int lua_parsers_tokenize_text(lua_State *L) { LUA_TRACE_POINT; - const gchar *in = NULL; + const char *in = NULL; gsize len = 0, pos, ex_len, i; GList *exceptions = NULL, *cur; struct rspamd_lua_text *t; @@ -165,7 +165,7 @@ gint lua_parsers_tokenize_text(lua_State *L) len, &uc_err); - res = rspamd_tokenize_text((gchar *) in, len, + res = rspamd_tokenize_text((char *) in, len, &utxt, RSPAMD_TOKENIZE_UTF, NULL, exceptions, @@ -197,11 +197,11 @@ gint lua_parsers_tokenize_text(lua_State *L) return 1; } -gint lua_parsers_parse_html(lua_State *L) +int lua_parsers_parse_html(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t; - const gchar *start = NULL; + const char *start = NULL; gsize len; GByteArray *in; rspamd_mempool_t *pool; @@ -240,13 +240,13 @@ gint lua_parsers_parse_html(lua_State *L) return 1; } -gint lua_parsers_parse_mail_address(lua_State *L) +int lua_parsers_parse_mail_address(lua_State *L) { LUA_TRACE_POINT; GPtrArray *addrs; gsize len; - const gchar *str = luaL_checklstring(L, 1, &len); - gint max_addrs = luaL_optinteger(L, 3, 10240); + const char *str = luaL_checklstring(L, 1, &len); + int max_addrs = luaL_optinteger(L, 3, 10240); rspamd_mempool_t *pool; gboolean own_pool = FALSE; @@ -285,11 +285,11 @@ gint lua_parsers_parse_mail_address(lua_State *L) return 1; } -gint lua_parsers_parse_content_type(lua_State *L) +int lua_parsers_parse_content_type(lua_State *L) { LUA_TRACE_POINT; gsize len; - const gchar *ct_str = luaL_checklstring(L, 1, &len); + const char *ct_str = luaL_checklstring(L, 1, &len); rspamd_mempool_t *pool = rspamd_lua_check_mempool(L, 2); struct rspamd_content_type *ct; @@ -339,7 +339,7 @@ gint lua_parsers_parse_content_type(lua_State *L) struct rspamd_content_type_param *param = (struct rspamd_content_type_param *) v, *cur; - guint i = 1; + unsigned int i = 1; lua_pushlstring(L, param->name.begin, param->name.len); lua_createtable(L, 1, 0); @@ -361,7 +361,7 @@ gint lua_parsers_parse_content_type(lua_State *L) int lua_parsers_parse_smtp_date(lua_State *L) { gsize slen; - const gchar *str = lua_tolstring(L, 1, &slen); + const char *str = lua_tolstring(L, 1, &slen); GError *err = NULL; if (str == NULL) { @@ -395,7 +395,7 @@ int lua_parsers_parse_smtp_date(lua_State *L) return 1; } -static gint +static int lua_load_parsers(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index a6a23ce05..f95abb577 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -22,7 +22,7 @@ #define REDIS_DEFAULT_TIMEOUT 1.0 -static const gchar *M = "rspamd lua redis"; +static const char *M = "rspamd lua redis"; static void *redis_null; /*** @@ -101,12 +101,12 @@ struct lua_redis_userdata { struct ev_loop *event_loop; struct rspamd_config *cfg; struct rspamd_redis_pool *pool; - gchar *server; - gchar log_tag[RSPAMD_LOG_ID_LEN + 1]; + char *server; + char log_tag[RSPAMD_LOG_ID_LEN + 1]; struct lua_redis_request_specific_userdata *specific; - gdouble timeout; - guint16 port; - guint16 terminated; + double timeout; + uint16_t port; + uint16_t terminated; }; #define msg_debug_lua_redis(...) rspamd_conditional_debug_fast(NULL, NULL, \ @@ -126,21 +126,21 @@ INIT_LOG_MODULE(lua_redis) #define IS_ASYNC(ctx) ((ctx)->flags & LUA_REDIS_ASYNC) struct lua_redis_request_specific_userdata { - gint cbref; - guint nargs; - gchar **args; + int cbref; + unsigned int nargs; + char **args; gsize *arglens; struct lua_redis_userdata *c; struct lua_redis_ctx *ctx; struct lua_redis_request_specific_userdata *next; ev_timer timeout_ev; - guint flags; + unsigned int flags; }; struct lua_redis_ctx { - guint flags; + unsigned int flags; struct lua_redis_userdata async; - guint cmds_pending; + unsigned int cmds_pending; ref_entry_t ref; GQueue *replies; /* for sync connection only */ GQueue *events_cleanup; /* for sync connection only */ @@ -149,7 +149,7 @@ struct lua_redis_ctx { struct lua_redis_result { gboolean is_error; - gint result_ref; + int result_ref; struct rspamd_symcache_dynamic_item *item; struct rspamd_async_session *s; struct rspamd_task *task; @@ -157,7 +157,7 @@ struct lua_redis_result { }; static struct lua_redis_ctx * -lua_check_redis(lua_State *L, gint pos) +lua_check_redis(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_redis_classname); luaL_argcheck(L, ud != NULL, pos, "'redis' expected"); @@ -165,9 +165,9 @@ lua_check_redis(lua_State *L, gint pos) } static void -lua_redis_free_args(char **args, gsize *arglens, guint nargs) +lua_redis_free_args(char **args, gsize *arglens, unsigned int nargs) { - guint i; + unsigned int i; if (args) { for (i = 0; i < nargs; i++) { @@ -242,7 +242,7 @@ lua_redis_dtor(struct lua_redis_ctx *ctx) g_free(ctx); } -static gint +static int lua_redis_gc(lua_State *L) { struct lua_redis_ctx *ctx = lua_check_redis(L, 1); @@ -281,7 +281,7 @@ lua_redis_fin(void *arg) * @param ud */ static void -lua_redis_push_error(const gchar *err, +lua_redis_push_error(const char *err, struct lua_redis_ctx *ctx, struct lua_redis_request_specific_userdata *sp_ud, gboolean connected) @@ -336,7 +336,7 @@ lua_redis_push_error(const gchar *err, static void lua_redis_push_reply(lua_State *L, const redisReply *r, gboolean text_data) { - guint i; + unsigned int i; struct rspamd_lua_text *t; switch (r->type) { @@ -404,7 +404,7 @@ lua_redis_push_data(const redisReply *r, struct lua_redis_ctx *ctx, rspamd_symcache_set_cur_item(ud->task, ud->item); } - gint ret = lua_pcall(cbs.L, 2, 0, err_idx); + int ret = lua_pcall(cbs.L, 2, 0, err_idx); if (ret != 0) { msg_info("call to lua_redis callback failed (%d): %s", @@ -517,11 +517,11 @@ lua_redis_callback(redisAsyncContext *c, gpointer r, gpointer priv) REDIS_RELEASE(ctx); } -static gint +static int lua_redis_push_results(struct lua_redis_ctx *ctx, lua_State *L) { - gint results = g_queue_get_length(ctx->replies); - gint i; + int results = g_queue_get_length(ctx->replies); + int i; gboolean can_use_lua = TRUE; results = g_queue_get_length(ctx->replies); @@ -589,7 +589,7 @@ lua_redis_callback_sync(redisAsyncContext *ac, gpointer r, gpointer priv) struct lua_redis_ctx *ctx; struct lua_redis_userdata *ud; struct thread_entry *thread; - gint results; + int results; ctx = sp_ud->ctx; ud = sp_ud->c; @@ -771,12 +771,12 @@ lua_redis_timeout(EV_P_ ev_timer *w, int revents) static void -lua_redis_parse_args(lua_State *L, gint idx, const gchar *cmd, - gchar ***pargs, gsize **parglens, guint *nargs) +lua_redis_parse_args(lua_State *L, int idx, const char *cmd, + char ***pargs, gsize **parglens, unsigned int *nargs) { - gchar **args = NULL; + char **args = NULL; gsize *arglens; - gint top; + int top; if (idx != 0 && lua_type(L, idx) == LUA_TTABLE) { /* Get all arguments */ @@ -785,7 +785,7 @@ lua_redis_parse_args(lua_State *L, gint idx, const gchar *cmd, top = 0; while (lua_next(L, -2) != 0) { - gint type = lua_type(L, -1); + int type = lua_type(L, -1); if (type == LUA_TNUMBER || type == LUA_TSTRING || type == LUA_TUSERDATA) { @@ -794,7 +794,7 @@ lua_redis_parse_args(lua_State *L, gint idx, const gchar *cmd, lua_pop(L, 1); } - args = g_malloc((top + 1) * sizeof(gchar *)); + args = g_malloc((top + 1) * sizeof(char *)); arglens = g_malloc((top + 1) * sizeof(gsize)); arglens[0] = strlen(cmd); args[0] = g_malloc(arglens[0]); @@ -803,10 +803,10 @@ lua_redis_parse_args(lua_State *L, gint idx, const gchar *cmd, lua_pushnil(L); while (lua_next(L, -2) != 0) { - gint type = lua_type(L, -1); + int type = lua_type(L, -1); if (type == LUA_TSTRING) { - const gchar *s; + const char *s; s = lua_tolstring(L, -1, &arglens[top]); args[top] = g_malloc(arglens[top]); @@ -826,11 +826,11 @@ lua_redis_parse_args(lua_State *L, gint idx, const gchar *cmd, } } else if (type == LUA_TNUMBER) { - gdouble val = lua_tonumber(L, -1); - gint r; - gchar numbuf[64]; + double val = lua_tonumber(L, -1); + int r; + char numbuf[64]; - if (val == (gdouble) ((int64_t) val)) { + if (val == (double) ((int64_t) val)) { r = rspamd_snprintf(numbuf, sizeof(numbuf), "%L", (int64_t) val); } @@ -853,7 +853,7 @@ lua_redis_parse_args(lua_State *L, gint idx, const gchar *cmd, else { /* Use merely cmd */ - args = g_malloc(sizeof(gchar *)); + args = g_malloc(sizeof(char *)); arglens = g_malloc(sizeof(gsize)); arglens[0] = strlen(cmd); args[0] = g_malloc(arglens[0]); @@ -867,21 +867,21 @@ lua_redis_parse_args(lua_State *L, gint idx, const gchar *cmd, } static struct lua_redis_ctx * -rspamd_lua_redis_prepare_connection(lua_State *L, gint *pcbref, gboolean is_async) +rspamd_lua_redis_prepare_connection(lua_State *L, int *pcbref, gboolean is_async) { struct lua_redis_ctx *ctx = NULL; rspamd_inet_addr_t *ip = NULL; struct lua_redis_userdata *ud = NULL; struct rspamd_lua_ip *addr = NULL; struct rspamd_task *task = NULL; - const gchar *host = NULL; - const gchar *username = NULL, *password = NULL, *dbname = NULL, *log_tag = NULL; - gint cbref = -1; + const char *host = NULL; + const char *username = NULL, *password = NULL, *dbname = NULL, *log_tag = NULL; + int cbref = -1; struct rspamd_config *cfg = NULL; struct rspamd_async_session *session = NULL; struct ev_loop *ev_base = NULL; gboolean ret = FALSE; - guint flags = 0; + unsigned int flags = 0; if (lua_istable(L, 1)) { /* Table version */ @@ -1117,9 +1117,9 @@ lua_redis_make_request(lua_State *L) struct lua_redis_request_specific_userdata *sp_ud; struct lua_redis_userdata *ud; struct lua_redis_ctx *ctx, **pctx; - const gchar *cmd = NULL; - gdouble timeout = REDIS_DEFAULT_TIMEOUT; - gint cbref = -1; + const char *cmd = NULL; + double timeout = REDIS_DEFAULT_TIMEOUT; + int cbref = -1; gboolean ret = FALSE; ctx = rspamd_lua_redis_prepare_connection(L, &cbref, TRUE); @@ -1156,7 +1156,7 @@ lua_redis_make_request(lua_State *L) lua_redis_callback, sp_ud, sp_ud->nargs, - (const gchar **) sp_ud->args, + (const char **) sp_ud->args, sp_ud->arglens); if (ret == REDIS_OK) { @@ -1230,13 +1230,13 @@ lua_redis_make_request_sync(lua_State *L) LUA_TRACE_POINT; struct rspamd_lua_ip *addr = NULL; rspamd_inet_addr_t *ip = NULL; - const gchar *cmd = NULL, *host; + const char *cmd = NULL, *host; struct timeval tv; gboolean ret = FALSE; - gdouble timeout = REDIS_DEFAULT_TIMEOUT; - gchar **args = NULL; + double timeout = REDIS_DEFAULT_TIMEOUT; + char **args = NULL; gsize *arglens = NULL; - guint nargs = 0, flags = 0; + unsigned int nargs = 0, flags = 0; redisContext *ctx; redisReply *r; @@ -1323,7 +1323,7 @@ lua_redis_make_request_sync(lua_State *L) r = redisCommandArgv(ctx, nargs, - (const gchar **) args, + (const char **) args, arglens); if (r != NULL) { @@ -1376,7 +1376,7 @@ lua_redis_connect(lua_State *L) LUA_TRACE_POINT; struct lua_redis_userdata *ud; struct lua_redis_ctx *ctx, **pctx; - gdouble timeout = REDIS_DEFAULT_TIMEOUT; + double timeout = REDIS_DEFAULT_TIMEOUT; ctx = rspamd_lua_redis_prepare_connection(L, NULL, TRUE); @@ -1418,7 +1418,7 @@ static int lua_redis_connect_sync(lua_State *L) { LUA_TRACE_POINT; - gdouble timeout = REDIS_DEFAULT_TIMEOUT; + double timeout = REDIS_DEFAULT_TIMEOUT; struct lua_redis_ctx *ctx, **pctx; ctx = rspamd_lua_redis_prepare_connection(L, NULL, FALSE); @@ -1463,9 +1463,9 @@ lua_redis_add_cmd(lua_State *L) struct lua_redis_ctx *ctx = lua_check_redis(L, 1); struct lua_redis_request_specific_userdata *sp_ud; struct lua_redis_userdata *ud; - const gchar *cmd = NULL; - gint args_pos = 2; - gint cbref = -1, ret; + const char *cmd = NULL; + int args_pos = 2; + int cbref = -1, ret; if (ctx) { if (ctx->flags & LUA_REDIS_TERMINATED) { @@ -1520,7 +1520,7 @@ lua_redis_add_cmd(lua_State *L) lua_redis_callback, sp_ud, sp_ud->nargs, - (const gchar **) sp_ud->args, + (const char **) sp_ud->args, sp_ud->arglens); } else { @@ -1528,7 +1528,7 @@ lua_redis_add_cmd(lua_State *L) lua_redis_callback_sync, sp_ud, sp_ud->nargs, - (const gchar **) sp_ud->args, + (const char **) sp_ud->args, sp_ud->arglens); } @@ -1602,7 +1602,7 @@ lua_redis_exec(lua_State *L) lua_error(L); } if (ctx->cmds_pending == 0 && g_queue_get_length(ctx->replies) > 0) { - gint results = lua_redis_push_results(ctx, L); + int results = lua_redis_push_results(ctx, L); return results; } else { @@ -1612,7 +1612,7 @@ lua_redis_exec(lua_State *L) } } -static gint +static int lua_load_redis(lua_State *L) { lua_newtable(L); @@ -1621,7 +1621,7 @@ lua_load_redis(lua_State *L) return 1; } -static gint +static int lua_redis_null_idx(lua_State *L) { lua_pushnil(L); diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c index 889e0aad8..6e2b0dc22 100644 --- a/src/lua/lua_regexp.c +++ b/src/lua/lua_regexp.c @@ -71,7 +71,7 @@ static const struct luaL_reg regexplib_f[] = { rspamd_mempool_t *regexp_static_pool = NULL; struct rspamd_lua_regexp * -lua_check_regexp(lua_State *L, gint pos) +lua_check_regexp(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_regexp_classname); @@ -96,7 +96,7 @@ lua_regexp_create(lua_State *L) LUA_TRACE_POINT; rspamd_regexp_t *re; struct rspamd_lua_regexp *new, **pnew; - const gchar *string, *flags_str = NULL; + const char *string, *flags_str = NULL; GError *err = NULL; string = luaL_checkstring(L, 1); @@ -147,8 +147,8 @@ lua_regexp_import_glob(lua_State *L) LUA_TRACE_POINT; rspamd_regexp_t *re; struct rspamd_lua_regexp *new, **pnew; - const gchar *string, *flags_str = NULL; - gchar *escaped; + const char *string, *flags_str = NULL; + char *escaped; gsize pat_len; GError *err = NULL; @@ -206,8 +206,8 @@ lua_regexp_import_plain(lua_State *L) LUA_TRACE_POINT; rspamd_regexp_t *re; struct rspamd_lua_regexp *new, **pnew; - const gchar *string, *flags_str = NULL; - gchar *escaped; + const char *string, *flags_str = NULL; + char *escaped; gsize pat_len; GError *err = NULL; @@ -262,7 +262,7 @@ lua_regexp_get_cached(lua_State *L) LUA_TRACE_POINT; rspamd_regexp_t *re; struct rspamd_lua_regexp *new, **pnew; - const gchar *string, *flags_str = NULL; + const char *string, *flags_str = NULL; string = luaL_checkstring(L, 1); if (lua_gettop(L) == 2) { @@ -313,7 +313,7 @@ lua_regexp_create_cached(lua_State *L) LUA_TRACE_POINT; rspamd_regexp_t *re; struct rspamd_lua_regexp *new, **pnew; - const gchar *string, *flags_str = NULL; + const char *string, *flags_str = NULL; GError *err = NULL; string = luaL_checkstring(L, 1); @@ -420,7 +420,7 @@ lua_regexp_set_max_hits(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_regexp *re = lua_check_regexp(L, 1); - guint lim; + unsigned int lim; lim = luaL_checkinteger(L, 2); @@ -487,10 +487,10 @@ lua_regexp_search(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_regexp *re = lua_check_regexp(L, 1); - const gchar *data = NULL; + const char *data = NULL; struct rspamd_lua_text *t; - const gchar *start = NULL, *end = NULL; - gint i; + const char *start = NULL, *end = NULL; + int i; gsize len = 0, capn; gboolean matched = FALSE, capture = FALSE, raw = FALSE; GArray *captures = NULL; @@ -580,7 +580,7 @@ lua_regexp_match(lua_State *L) LUA_TRACE_POINT; struct rspamd_lua_regexp *re = lua_check_regexp(L, 1); struct rspamd_lua_text *t; - const gchar *data = NULL; + const char *data = NULL; gsize len = 0; gboolean raw = FALSE; @@ -637,8 +637,8 @@ lua_regexp_matchn(lua_State *L) LUA_TRACE_POINT; struct rspamd_lua_regexp *re = lua_check_regexp(L, 1); struct rspamd_lua_text *t; - const gchar *data = NULL, *start = NULL, *end = NULL; - gint max_matches, matches; + const char *data = NULL, *start = NULL, *end = NULL; + int max_matches, matches; gsize len = 0; gboolean raw = FALSE; @@ -703,12 +703,12 @@ lua_regexp_split(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_regexp *re = lua_check_regexp(L, 1); - const gchar *data = NULL; + const char *data = NULL; struct rspamd_lua_text *t; gboolean matched = FALSE, is_text = FALSE; gsize len = 0; - const gchar *start = NULL, *end = NULL, *old_start; - gint i; + const char *start = NULL, *end = NULL, *old_start; + int i; if (re && !IS_DESTROYED(re)) { if (lua_type(L, 2) == LUA_TSTRING) { @@ -794,7 +794,7 @@ lua_regexp_split(lua_State *L) * @method re:destroy() * Destroy regexp from caches if needed (the pointer is removed by garbage collector) */ -static gint +static int lua_regexp_destroy(lua_State *L) { LUA_TRACE_POINT; @@ -810,7 +810,7 @@ lua_regexp_destroy(lua_State *L) return 0; } -static gint +static int lua_regexp_gc(lua_State *L) { LUA_TRACE_POINT; @@ -829,7 +829,7 @@ lua_regexp_gc(lua_State *L) return 0; } -static gint +static int lua_load_regexp(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_rsa.c b/src/lua/lua_rsa.c index c2ea39fa5..0f67e91d1 100644 --- a/src/lua/lua_rsa.c +++ b/src/lua/lua_rsa.c @@ -118,11 +118,11 @@ lua_check_rsa_sign(lua_State *L, int pos) return ud ? *((rspamd_fstring_t **) ud) : NULL; } -static gint +static int lua_rsa_pubkey_load(lua_State *L) { RSA *rsa = NULL, **prsa; - const gchar *filename; + const char *filename; FILE *f; filename = luaL_checkstring(L, 1); @@ -154,11 +154,11 @@ lua_rsa_pubkey_load(lua_State *L) return 1; } -static gint +static int lua_rsa_privkey_save(lua_State *L) { - const gchar *filename; - const gchar *type = "pem"; + const char *filename; + const char *type = "pem"; FILE *f; int ret; @@ -220,11 +220,11 @@ lua_rsa_privkey_save(lua_State *L) } -static gint +static int lua_rsa_pubkey_create(lua_State *L) { RSA *rsa = NULL, **prsa; - const gchar *buf; + const char *buf; BIO *bp; buf = luaL_checkstring(L, 1); @@ -249,7 +249,7 @@ lua_rsa_pubkey_create(lua_State *L) return 1; } -static gint +static int lua_rsa_pubkey_gc(lua_State *L) { RSA *rsa = lua_check_rsa_pubkey(L, 1); @@ -261,14 +261,14 @@ lua_rsa_pubkey_gc(lua_State *L) return 0; } -static gint +static int lua_rsa_pubkey_tostring(lua_State *L) { RSA *rsa = lua_check_rsa_pubkey(L, 1); if (rsa != NULL) { BIO *pubout = BIO_new(BIO_s_mem()); - const gchar *pubdata; + const char *pubdata; gsize publen; int rc = i2d_RSA_PUBKEY_bio(pubout, rsa); @@ -289,11 +289,11 @@ lua_rsa_pubkey_tostring(lua_State *L) return 1; } -static gint +static int lua_rsa_privkey_load_file(lua_State *L) { RSA *rsa = NULL, **prsa; - const gchar *filename; + const char *filename; FILE *f; filename = luaL_checkstring(L, 1); @@ -325,13 +325,13 @@ lua_rsa_privkey_load_file(lua_State *L) return 1; } -static gint +static int lua_rsa_privkey_load_pem(lua_State *L) { RSA *rsa = NULL, **prsa; BIO *b; struct rspamd_lua_text *t; - const gchar *data; + const char *data; gsize len; if (lua_isuserdata(L, 1)) { @@ -371,13 +371,13 @@ lua_rsa_privkey_load_pem(lua_State *L) return 1; } -static gint +static int lua_rsa_privkey_load_raw(lua_State *L) { RSA *rsa = NULL, **prsa; BIO *b; struct rspamd_lua_text *t; - const gchar *data; + const char *data; gsize len; if (lua_isuserdata(L, 1)) { @@ -418,15 +418,15 @@ lua_rsa_privkey_load_raw(lua_State *L) return 1; } -static gint +static int lua_rsa_privkey_load_base64(lua_State *L) { RSA *rsa = NULL, **prsa; BIO *b; EVP_PKEY *evp = NULL; struct rspamd_lua_text *t; - const gchar *data; - guchar *decoded; + const char *data; + unsigned char *decoded; gsize len, dec_len; if (lua_isuserdata(L, 1)) { @@ -486,11 +486,11 @@ lua_rsa_privkey_load_base64(lua_State *L) return 1; } -static gint +static int lua_rsa_privkey_create(lua_State *L) { RSA *rsa = NULL, **prsa; - const gchar *buf; + const char *buf; BIO *bp; buf = luaL_checkstring(L, 1); @@ -515,7 +515,7 @@ lua_rsa_privkey_create(lua_State *L) return 1; } -static gint +static int lua_rsa_privkey_gc(lua_State *L) { RSA *rsa = lua_check_rsa_privkey(L, 1); @@ -527,11 +527,11 @@ lua_rsa_privkey_gc(lua_State *L) return 0; } -static gint +static int lua_rsa_signature_load(lua_State *L) { rspamd_fstring_t *sig, **psig; - const gchar *filename; + const char *filename; gpointer data; int fd; struct stat st; @@ -567,12 +567,12 @@ lua_rsa_signature_load(lua_State *L) return 1; } -static gint +static int lua_rsa_signature_save(lua_State *L) { rspamd_fstring_t *sig; - gint fd, flags; - const gchar *filename; + int fd, flags; + const char *filename; gboolean forced = FALSE, res = TRUE; sig = lua_check_rsa_sign(L, 1); @@ -618,11 +618,11 @@ lua_rsa_signature_save(lua_State *L) return 1; } -static gint +static int lua_rsa_signature_create(lua_State *L) { rspamd_fstring_t *sig, **psig; - const gchar *data; + const char *data; gsize dlen; data = luaL_checklstring(L, 1, &dlen); @@ -636,7 +636,7 @@ lua_rsa_signature_create(lua_State *L) return 1; } -static gint +static int lua_rsa_signature_gc(lua_State *L) { rspamd_fstring_t *sig = lua_check_rsa_sign(L, 1); @@ -646,12 +646,12 @@ lua_rsa_signature_gc(lua_State *L) return 0; } -static gint +static int lua_rsa_signature_base64(lua_State *L) { rspamd_fstring_t *sig = lua_check_rsa_sign(L, 1); - guint boundary = 0; - gchar *b64; + unsigned int boundary = 0; + char *b64; gsize outlen; enum rspamd_newlines_type how = RSPAMD_TASK_NEWLINES_CRLF; @@ -660,7 +660,7 @@ lua_rsa_signature_base64(lua_State *L) } if (lua_isstring(L, 3)) { - const gchar *how_str = lua_tostring(L, 3); + const char *how_str = lua_tostring(L, 3); if (strcmp(how_str, "cr") == 0) { how = RSPAMD_TASK_NEWLINES_CR; @@ -696,14 +696,14 @@ lua_rsa_signature_base64(lua_State *L) * true - if string match rsa signature * false - otherwise */ -static gint +static int lua_rsa_verify_memory(lua_State *L) { RSA *rsa; rspamd_fstring_t *signature; - const gchar *data; + const char *data; gsize sz; - gint ret; + int ret; rsa = lua_check_rsa_pubkey(L, 1); signature = lua_check_rsa_sign(L, 2); @@ -740,14 +740,14 @@ lua_rsa_verify_memory(lua_State *L) * rspamd_signature object * nil - otherwise */ -static gint +static int lua_rsa_sign_memory(lua_State *L) { RSA *rsa; rspamd_fstring_t *signature, **psig; - const gchar *data; + const char *data; gsize sz; - gint ret; + int ret; rsa = lua_check_rsa_privkey(L, 1); data = luaL_checklstring(L, 2, &sz); @@ -755,7 +755,7 @@ lua_rsa_sign_memory(lua_State *L) if (rsa != NULL && data != NULL) { signature = rspamd_fstring_sized_new(RSA_size(rsa)); - guint siglen = signature->len; + unsigned int siglen = signature->len; ret = RSA_sign(NID_sha256, data, sz, signature->str, &siglen, rsa); @@ -779,12 +779,12 @@ lua_rsa_sign_memory(lua_State *L) return 1; } -static gint +static int lua_rsa_keypair(lua_State *L) { BIGNUM *e; RSA *rsa, *pub_rsa, *priv_rsa, **prsa; - gint bits = lua_gettop(L) > 0 ? lua_tointeger(L, 1) : 1024; + int bits = lua_gettop(L) > 0 ? lua_tointeger(L, 1) : 1024; if (bits > 4096 || bits < 512) { return luaL_error(L, "invalid bits count"); @@ -811,7 +811,7 @@ lua_rsa_keypair(lua_State *L) return 2; } -static gint +static int lua_load_pubkey(lua_State *L) { lua_newtable(L); @@ -820,7 +820,7 @@ lua_load_pubkey(lua_State *L) return 1; } -static gint +static int lua_load_privkey(lua_State *L) { lua_newtable(L); @@ -829,7 +829,7 @@ lua_load_privkey(lua_State *L) return 1; } -static gint +static int lua_load_signature(lua_State *L) { lua_newtable(L); @@ -838,7 +838,7 @@ lua_load_signature(lua_State *L) return 1; } -static gint +static int lua_load_rsa(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_spf.c b/src/lua/lua_spf.c index caea3e3b9..46e72202f 100644 --- a/src/lua/lua_spf.c +++ b/src/lua/lua_spf.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, @@ -56,11 +56,11 @@ struct rspamd_lua_spf_cbdata { struct rspamd_task *task; lua_State *L; struct rspamd_symcache_dynamic_item *item; - gint cbref; + int cbref; ref_entry_t ref; }; -static gint +static int lua_load_spf(lua_State *L) { lua_newtable(L); @@ -107,14 +107,14 @@ void luaopen_spf(lua_State *L) } static void -lua_spf_push_result(struct rspamd_lua_spf_cbdata *cbd, gint code_flags, - struct spf_resolved *resolved, const gchar *err) +lua_spf_push_result(struct rspamd_lua_spf_cbdata *cbd, int code_flags, + struct spf_resolved *resolved, const char *err) { g_assert(cbd != NULL); REF_RETAIN(cbd); lua_pushcfunction(cbd->L, &rspamd_lua_traceback); - gint err_idx = lua_gettop(cbd->L); + int err_idx = lua_gettop(cbd->L); lua_rawgeti(cbd->L, LUA_REGISTRYINDEX, cbd->cbref); @@ -211,7 +211,7 @@ spf_lua_lib_callback(struct spf_resolved *record, struct rspamd_task *task, * @param {rspamd_task} task task * @param {function} callback callback that is called on spf resolution */ -gint lua_spf_resolve(lua_State *L) +int lua_spf_resolve(lua_State *L) { struct rspamd_task *task = lua_check_task(L, 1); @@ -254,7 +254,7 @@ gint lua_spf_resolve(lua_State *L) return 0; } -static gint +static int lua_spf_record_dtor(lua_State *L) { struct spf_resolved *record; @@ -273,7 +273,7 @@ lua_spf_record_dtor(lua_State *L) static void lua_spf_push_spf_addr(lua_State *L, struct spf_addr *addr) { - gchar *addr_mask; + char *addr_mask; lua_createtable(L, 0, 4); @@ -296,13 +296,13 @@ lua_spf_push_spf_addr(lua_State *L, struct spf_addr *addr) } } -static gint +static int spf_check_element(lua_State *L, struct spf_resolved *rec, struct spf_addr *addr, struct rspamd_lua_ip *ip) { gboolean res = FALSE; - const guint8 *s, *d; - guint af, mask, bmask, addrlen; + const uint8_t *s, *d; + unsigned int af, mask, bmask, addrlen; if (addr->flags & RSPAMD_SPF_FLAG_TEMPFAIL) { @@ -318,11 +318,11 @@ spf_check_element(lua_State *L, struct spf_resolved *rec, struct spf_addr *addr, d = rspamd_inet_address_get_hash_key(ip->addr, &addrlen); if (af == AF_INET6) { - s = (const guint8 *) addr->addr6; + s = (const uint8_t *) addr->addr6; mask = addr->m.dual.mask_v6; } else { - s = (const guint8 *) addr->addr4; + s = (const uint8_t *) addr->addr4; mask = addr->m.dual.mask_v4; } @@ -396,7 +396,7 @@ spf_check_element(lua_State *L, struct spf_resolved *rec, struct spf_addr *addr, * @param {rspamd_ip|string} ip address * @return {result,flag_or_policy,error_or_addr} - triplet */ -static gint +static int lua_spf_record_check_ip(lua_State *L) { struct spf_resolved *record; @@ -404,14 +404,14 @@ lua_spf_record_check_ip(lua_State *L) struct spf_resolved, record); struct rspamd_lua_ip *ip = NULL; - gint nres = 0; + int nres = 0; gboolean need_free_ip = FALSE; if (lua_type(L, 2) == LUA_TUSERDATA) { ip = lua_check_ip(L, 2); } else if (lua_type(L, 2) == LUA_TSTRING) { - const gchar *ip_str; + const char *ip_str; gsize iplen; ip = g_malloc0(sizeof(struct rspamd_lua_ip)); @@ -428,7 +428,7 @@ lua_spf_record_check_ip(lua_State *L) } if (record && ip && ip->addr) { - for (guint i = 0; i < record->elts->len; i++) { + for (unsigned int i = 0; i < record->elts->len; i++) { struct spf_addr *addr = &g_array_index(record->elts, struct spf_addr, i); if ((nres = spf_check_element(L, record, addr, ip)) > 0) { if (need_free_ip) { @@ -473,7 +473,7 @@ lua_spf_record_check_ip(lua_State *L) * @method rspamd_spf_record:get_domain() * Returns domain for the specific spf record */ -static gint +static int lua_spf_record_get_domain(lua_State *L) { struct spf_resolved *record; @@ -495,7 +495,7 @@ lua_spf_record_get_domain(lua_State *L) * @method rspamd_spf_record:get_ttl() * Returns ttl for the specific spf record */ -static gint +static int lua_spf_record_get_ttl(lua_State *L) { struct spf_resolved *record; @@ -517,7 +517,7 @@ lua_spf_record_get_ttl(lua_State *L) * @method rspamd_spf_record:get_timestamp() * Returns ttl for the specific spf record */ -static gint +static int lua_spf_record_get_timestamp(lua_State *L) { struct spf_resolved *record; @@ -539,7 +539,7 @@ lua_spf_record_get_timestamp(lua_State *L) * @method rspamd_spf_record:get_digest() * Returns string hex representation of the record digest (fast hash function) */ -static gint +static int lua_spf_record_get_digest(lua_State *L) { struct spf_resolved *record; @@ -548,7 +548,7 @@ lua_spf_record_get_digest(lua_State *L) record); if (record) { - gchar hexbuf[64]; + char hexbuf[64]; rspamd_snprintf(hexbuf, sizeof(hexbuf), "%xuL", record->digest); lua_pushstring(L, hexbuf); @@ -570,7 +570,7 @@ lua_spf_record_get_digest(lua_State *L) * - addr - address and mask as a string * - str - string representation (if available) */ -static gint +static int lua_spf_record_get_elts(lua_State *L) { struct spf_resolved *record; @@ -579,7 +579,7 @@ lua_spf_record_get_elts(lua_State *L) record); if (record) { - guint i; + unsigned int i; struct spf_addr *addr; lua_createtable(L, record->elts->len, 0); @@ -604,7 +604,7 @@ lua_spf_record_get_elts(lua_State *L) * Configures SPF library according to the UCL config * @param {table} object configuration object */ -gint lua_spf_config(lua_State *L) +int lua_spf_config(lua_State *L) { ucl_object_t *config_obj = ucl_object_lua_import(L, 1); diff --git a/src/lua/lua_sqlite3.c b/src/lua/lua_sqlite3.c index 6926f8081..784a3ba1a 100644 --- a/src/lua/lua_sqlite3.c +++ b/src/lua/lua_sqlite3.c @@ -62,7 +62,7 @@ static const struct luaL_reg sqlitestmtlib_m[] = { static void lua_sqlite3_push_row(lua_State *L, sqlite3_stmt *stmt); static sqlite3 * -lua_check_sqlite3(lua_State *L, gint pos) +lua_check_sqlite3(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_sqlite3_classname); luaL_argcheck(L, ud != NULL, pos, "'sqlite3' expected"); @@ -70,7 +70,7 @@ lua_check_sqlite3(lua_State *L, gint pos) } static sqlite3_stmt * -lua_check_sqlite3_stmt(lua_State *L, gint pos) +lua_check_sqlite3_stmt(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_sqlite3_stmt_classname); luaL_argcheck(L, ud != NULL, pos, "'sqlite3_stmt' expected"); @@ -84,10 +84,10 @@ lua_check_sqlite3_stmt(lua_State *L, gint pos) * @param {string} path path to db * @return {sqlite3} sqlite3 handle */ -static gint +static int lua_sqlite3_open(lua_State *L) { - const gchar *path = luaL_checkstring(L, 1); + const char *path = luaL_checkstring(L, 1); sqlite3 *db, **pdb; GError *err = NULL; @@ -116,13 +116,13 @@ lua_sqlite3_open(lua_State *L) } static void -lua_sqlite3_bind_statements(lua_State *L, gint start, gint end, +lua_sqlite3_bind_statements(lua_State *L, int start, int end, sqlite3_stmt *stmt) { - gint i, type, num = 1; - const gchar *str; + int i, type, num = 1; + const char *str; gsize slen; - gdouble n; + double n; g_assert(start <= end && start > 0 && end > 0); @@ -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) ((int64_t) n)) { + if (n == (double) ((int64_t) n)) { sqlite3_bind_int64(stmt, num, n); } else { @@ -162,15 +162,15 @@ lua_sqlite3_bind_statements(lua_State *L, gint start, gint end, * @param {string|number} args... variable number of arguments * @return {boolean} `true` if a statement has been successfully executed */ -static gint +static int lua_sqlite3_sql(lua_State *L) { LUA_TRACE_POINT; sqlite3 *db = lua_check_sqlite3(L, 1); - const gchar *query = luaL_checkstring(L, 2); + const char *query = luaL_checkstring(L, 2); sqlite3_stmt *stmt; gboolean ret = FALSE; - gint top = 1, rc; + int top = 1, rc; if (db && query) { if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) { @@ -212,11 +212,11 @@ lua_sqlite3_sql(lua_State *L) static void lua_sqlite3_push_row(lua_State *L, sqlite3_stmt *stmt) { - const gchar *str; + const char *str; gsize slen; int64_t num; - gchar numbuf[32]; - gint nresults, i, type; + char numbuf[32]; + int nresults, i, type; nresults = sqlite3_column_count(stmt); lua_createtable(L, 0, nresults); @@ -257,12 +257,12 @@ lua_sqlite3_push_row(lua_State *L, sqlite3_stmt *stmt) } } -static gint +static int lua_sqlite3_next_row(lua_State *L) { LUA_TRACE_POINT; sqlite3_stmt *stmt = *(sqlite3_stmt **) lua_touserdata(L, lua_upvalueindex(1)); - gint rc; + int rc; if (stmt != NULL) { rc = sqlite3_step(stmt); @@ -291,14 +291,14 @@ for row in db:rows([[ SELECT * FROM x ]]) do print(string.format('%d -> %s', row.id, row.value)) end */ -static gint +static int lua_sqlite3_rows(lua_State *L) { LUA_TRACE_POINT; sqlite3 *db = lua_check_sqlite3(L, 1); - const gchar *query = luaL_checkstring(L, 2); + const char *query = luaL_checkstring(L, 2); sqlite3_stmt *stmt, **pstmt; - gint top; + int top; if (db && query) { if (sqlite3_prepare_v2(db, query, -1, &stmt, NULL) != SQLITE_OK) { @@ -329,7 +329,7 @@ lua_sqlite3_rows(lua_State *L) return 1; } -static gint +static int lua_sqlite3_close(lua_State *L) { LUA_TRACE_POINT; @@ -342,7 +342,7 @@ lua_sqlite3_close(lua_State *L) return 0; } -static gint +static int lua_sqlite3_stmt_close(lua_State *L) { sqlite3_stmt *stmt = lua_check_sqlite3_stmt(L, 1); @@ -354,7 +354,7 @@ lua_sqlite3_stmt_close(lua_State *L) return 0; } -static gint +static int lua_load_sqlite3(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index bb2f71faf..e37c6838d 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -1380,7 +1380,7 @@ static const struct luaL_reg archivelib_m[] = { /* Utility functions */ struct rspamd_task * -lua_check_task(lua_State *L, gint pos) +lua_check_task(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_task_classname); luaL_argcheck(L, ud != NULL, pos, "'task' expected"); @@ -1388,7 +1388,7 @@ lua_check_task(lua_State *L, gint pos) } struct rspamd_task * -lua_check_task_maybe(lua_State *L, gint pos) +lua_check_task_maybe(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata_maybe(L, pos, rspamd_task_classname); @@ -1412,8 +1412,8 @@ lua_check_archive(lua_State *L) } static void -lua_task_set_cached(lua_State *L, struct rspamd_task *task, const gchar *key, - gint pos) +lua_task_set_cached(lua_State *L, struct rspamd_task *task, const char *key, + int pos) { LUA_TRACE_POINT; khiter_t k; @@ -1438,7 +1438,7 @@ lua_task_set_cached(lua_State *L, struct rspamd_task *task, const gchar *key, static gboolean -lua_task_get_cached(lua_State *L, struct rspamd_task *task, const gchar *key) +lua_task_get_cached(lua_State *L, struct rspamd_task *task, const char *key) { LUA_TRACE_POINT; khiter_t k; @@ -1577,14 +1577,14 @@ lua_task_set_message(lua_State *L) if (task) { gsize final_len = 0; - gchar *buf = NULL; + char *buf = NULL; if (lua_type(L, 2) == LUA_TTABLE) { /* Piecewise construct */ - guint vec_len = rspamd_lua_table_size(L, 2); + unsigned int vec_len = rspamd_lua_table_size(L, 2); - for (guint i = 0; i < vec_len; i++) { + for (unsigned int i = 0; i < vec_len; i++) { lua_rawgeti(L, 2, i + 1); if (lua_type(L, -1) == LUA_TSTRING) { @@ -1605,17 +1605,17 @@ lua_task_set_message(lua_State *L) } if (final_len > 0) { - gchar *pos; + char *pos; buf = rspamd_mempool_alloc(task->task_pool, final_len); pos = buf; - for (guint i = 0; i < vec_len; i++) { + for (unsigned int i = 0; i < vec_len; i++) { lua_rawgeti(L, 2, i + 1); if (lua_type(L, -1) == LUA_TSTRING) { gsize l; - const gchar *s; + const char *s; s = lua_tolstring(L, -1, &l); memcpy(pos, s, l); @@ -1641,7 +1641,7 @@ lua_task_set_message(lua_State *L) } else { if (lua_type(L, 2) == LUA_TSTRING) { - const gchar *s; + const char *s; s = lua_tolstring(L, -1, &final_len); buf = rspamd_mempool_alloc(task->task_pool, final_len); @@ -1704,12 +1704,12 @@ lua_task_free_dtor(gpointer p) g_free(p); } -static gint +static int lua_task_load_from_file(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = NULL, **ptask; - const gchar *fname = luaL_checkstring(L, 1), *err = NULL; + const char *fname = luaL_checkstring(L, 1), *err = NULL; struct rspamd_config *cfg = NULL; gboolean res = FALSE; gpointer map; @@ -1728,9 +1728,9 @@ lua_task_load_from_file(lua_State *L) if (strcmp(fname, "-") == 0) { /* Read from stdin */ - gint fd = STDIN_FILENO; + int fd = STDIN_FILENO; GString *data = g_string_sized_new(BUFSIZ); - gchar buf[BUFSIZ]; + char buf[BUFSIZ]; gssize r; for (;;) { @@ -1795,12 +1795,12 @@ lua_task_load_from_file(lua_State *L) return 2; } -static gint +static int lua_task_load_from_string(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = NULL, **ptask; - const gchar *str_message; + const char *str_message; gsize message_len; struct rspamd_config *cfg = NULL; @@ -1819,7 +1819,7 @@ lua_task_load_from_string(lua_State *L) task = rspamd_task_new(NULL, cfg, NULL, NULL, NULL, FALSE); task->msg.begin = g_malloc(message_len); - memcpy((gchar *) task->msg.begin, str_message, message_len); + memcpy((char *) task->msg.begin, str_message, message_len); task->msg.len = message_len; rspamd_mempool_add_destructor(task->task_pool, lua_task_free_dtor, (gpointer) task->msg.begin); @@ -1837,7 +1837,7 @@ lua_task_load_from_string(lua_State *L) return 2; } -static gint +static int lua_task_create(lua_State *L) { LUA_TRACE_POINT; @@ -1968,17 +1968,17 @@ lua_task_get_worker(lua_State *L) } -static gint +static int lua_task_insert_result_common(lua_State *L, struct rspamd_scan_result *result, - gint common_args_pos) + int common_args_pos) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *symbol_name; + const char *symbol_name; double weight; struct rspamd_symbol_result *s; enum rspamd_symbol_insert_flags flags = RSPAMD_SYMBOL_INSERT_DEFAULT; - gint i, top, args_start; + int i, top, args_start; if (task != NULL) { if (lua_isboolean(L, common_args_pos)) { @@ -2011,7 +2011,7 @@ lua_task_insert_result_common(lua_State *L, struct rspamd_scan_result *result, lua_pop(L, 1); /* Traceback string */ } for (i = args_start + 2; i <= top; i++) { - gint ltype = lua_type(L, i); + int ltype = lua_type(L, i); if (ltype == LUA_TSTRING) { gsize optlen; @@ -2030,7 +2030,7 @@ lua_task_insert_result_common(lua_State *L, struct rspamd_scan_result *result, else if (ltype == LUA_TTABLE) { gsize objlen = rspamd_lua_table_size(L, i); - for (guint j = 1; j <= objlen; j++) { + for (unsigned int j = 1; j <= objlen; j++) { lua_rawgeti(L, i, j); if (lua_type(L, -1) == LUA_TSTRING) { @@ -2053,7 +2053,7 @@ lua_task_insert_result_common(lua_State *L, struct rspamd_scan_result *result, } } else { - const gchar *tname = lua_typename(L, lua_type(L, -1)); + const char *tname = lua_typename(L, lua_type(L, -1)); lua_pop(L, 2); return luaL_error(L, "not a string option in a table " @@ -2071,7 +2071,7 @@ lua_task_insert_result_common(lua_State *L, struct rspamd_scan_result *result, continue; } else { - const gchar *tname = lua_typename(L, ltype); + const char *tname = lua_typename(L, ltype); return luaL_error(L, "not a string/table option " "when adding symbol %s: %s type", @@ -2098,17 +2098,17 @@ lua_task_insert_result_common(lua_State *L, struct rspamd_scan_result *result, return 0; } -static gint +static int lua_task_insert_result(lua_State *L) { return lua_task_insert_result_common(L, NULL, 2); } -static gint +static int lua_task_insert_result_named(lua_State *L) { struct rspamd_task *task = lua_check_task(L, 1); - const gchar *named_result = luaL_checkstring(L, 2); + const char *named_result = luaL_checkstring(L, 2); struct rspamd_scan_result *res; if (task && named_result) { @@ -2125,16 +2125,16 @@ lua_task_insert_result_named(lua_State *L) return luaL_error(L, "invalid arguments"); } -static gint +static int lua_task_adjust_result(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *symbol_name; + const char *symbol_name; struct rspamd_scan_result *metric_res; struct rspamd_symbol_result *s = NULL; double weight; - gint i, top; + int i, top; if (task != NULL) { @@ -2181,7 +2181,7 @@ lua_task_adjust_result(lua_State *L) else if (lua_type(L, i) == LUA_TTABLE) { gsize objlen = rspamd_lua_table_size(L, i); - for (guint j = 1; j <= objlen; j++) { + for (unsigned int j = 1; j <= objlen; j++) { lua_rawgeti(L, i, j); if (lua_type(L, -1) == LUA_TSTRING) { @@ -2212,14 +2212,14 @@ lua_task_adjust_result(lua_State *L) return 0; } -static gint +static int lua_task_remove_result(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *symbol_name = luaL_checkstring(L, 2); + const char *symbol_name = luaL_checkstring(L, 2); struct rspamd_scan_result *metric_res; - const gchar *named_result = luaL_optstring(L, 3, NULL); + const char *named_result = luaL_optstring(L, 3, NULL); if (task != NULL) { metric_res = rspamd_find_metric_result(task, named_result); @@ -2239,16 +2239,16 @@ lua_task_remove_result(lua_State *L) return 1; } -static gint +static int lua_task_set_pre_result(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *message = NULL, *module = NULL, *fl_str = NULL, *act_str = NULL, - *res_name = NULL; - gdouble score = NAN; + const char *message = NULL, *module = NULL, *fl_str = NULL, *act_str = NULL, + *res_name = NULL; + double score = NAN; struct rspamd_action *action; - guint priority = RSPAMD_PASSTHROUGH_NORMAL, flags = 0; + unsigned int priority = RSPAMD_PASSTHROUGH_NORMAL, flags = 0; if (task != NULL) { @@ -2264,7 +2264,7 @@ lua_task_set_pre_result(lua_State *L) RSPAMD_LUA_PARSE_ARGUMENTS_DEFAULT, "*action=S;message=S;module=S;score=D;priority=i;flags=S;result=S", &act_str, &message, &module, &score, &priority, &fl_str, &res_name)) { - gint ret = luaL_error(L, "invalid arguments: %s", err->message); + int ret = luaL_error(L, "invalid arguments: %s", err->message); g_error_free(err); return ret; @@ -2368,12 +2368,12 @@ lua_task_set_pre_result(lua_State *L) return 0; } -static gint +static int lua_task_has_pre_result(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - gint nret = 1; + int nret = 1; if (task) { if (task->result->passthrough_result) { @@ -2414,12 +2414,12 @@ lua_task_has_pre_result(lua_State *L) return nret; } -static gint +static int lua_task_append_message(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *category; + const char *category; if (task != NULL) { if (lua_type(L, 3) == LUA_TSTRING) { @@ -2442,15 +2442,15 @@ lua_task_append_message(lua_State *L) } -static gint +static int lua_task_get_urls(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); struct lua_tree_cb_data cb; struct rspamd_url *u; - static const gint default_protocols_mask = PROTOCOL_HTTP | PROTOCOL_HTTPS | - PROTOCOL_FILE | PROTOCOL_FTP; + static const int default_protocols_mask = PROTOCOL_HTTP | PROTOCOL_HTTPS | + PROTOCOL_FILE | PROTOCOL_FTP; gsize sz, max_urls = 0; if (task) { @@ -2479,7 +2479,7 @@ lua_task_get_urls(lua_State *L) if (cb.sort) { struct rspamd_url **urls_sorted; - gint i = 0; + int i = 0; urls_sorted = g_new0(struct rspamd_url *, sz); @@ -2513,15 +2513,15 @@ lua_task_get_urls(lua_State *L) return 1; } -static gint +static int lua_task_get_urls_filtered(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); struct lua_tree_cb_data cb; struct rspamd_url *u; - static const gint default_protocols_mask = PROTOCOL_HTTP | PROTOCOL_HTTPS | - PROTOCOL_FILE | PROTOCOL_FTP; + static const int default_protocols_mask = PROTOCOL_HTTP | PROTOCOL_HTTPS | + PROTOCOL_FILE | PROTOCOL_FTP; gsize sz, max_urls = 0; if (task) { @@ -2547,7 +2547,7 @@ lua_task_get_urls_filtered(lua_State *L) if (cb.sort) { struct rspamd_url **urls_sorted; - gint i = 0; + int i = 0; urls_sorted = g_new0(struct rspamd_url *, sz); @@ -2581,7 +2581,7 @@ lua_task_get_urls_filtered(lua_State *L) return 1; } -static gint +static int lua_task_has_urls(lua_State *L) { LUA_TRACE_POINT; @@ -2625,7 +2625,7 @@ lua_task_has_urls(lua_State *L) return 2; } -static gint +static int lua_task_inject_url(lua_State *L) { LUA_TRACE_POINT; @@ -2654,7 +2654,7 @@ lua_task_inject_url(lua_State *L) return 0; } -static gint +static int lua_task_get_content(lua_State *L) { LUA_TRACE_POINT; @@ -2679,7 +2679,7 @@ lua_task_get_content(lua_State *L) return 1; } -static gint +static int lua_task_get_filename(lua_State *L) { LUA_TRACE_POINT; @@ -2700,7 +2700,7 @@ lua_task_get_filename(lua_State *L) return 1; } -static gint +static int lua_task_get_rawbody(lua_State *L) { LUA_TRACE_POINT; @@ -2740,7 +2740,7 @@ lua_task_get_rawbody(lua_State *L) return 1; } -static gint +static int lua_task_get_emails(lua_State *L) { LUA_TRACE_POINT; @@ -2784,11 +2784,11 @@ lua_task_get_emails(lua_State *L) return 1; } -static gint +static int lua_task_get_text_parts(lua_State *L) { LUA_TRACE_POINT; - guint i; + unsigned int i; struct rspamd_task *task = lua_check_task(L, 1); struct rspamd_mime_text_part *part, **ppart; @@ -2821,11 +2821,11 @@ lua_task_get_text_parts(lua_State *L) return 1; } -static gint +static int lua_task_get_parts(lua_State *L) { LUA_TRACE_POINT; - guint i; + unsigned int i; struct rspamd_task *task = lua_check_task(L, 1); struct rspamd_mime_part *part, **ppart; @@ -2853,13 +2853,13 @@ lua_task_get_parts(lua_State *L) return 1; } -static gint +static int lua_task_get_request_header(lua_State *L) { LUA_TRACE_POINT; rspamd_ftok_t *hdr; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *s; + const char *s; struct rspamd_lua_text *t; s = luaL_checkstring(L, 2); @@ -2887,12 +2887,12 @@ lua_task_get_request_header(lua_State *L) return 1; } -static gint +static int lua_task_set_request_header(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *s, *v = NULL; + const char *s, *v = NULL; rspamd_fstring_t *buf; struct rspamd_lua_text *t; rspamd_ftok_t *hdr, *new_name; @@ -2931,8 +2931,8 @@ lua_task_set_request_header(lua_State *L) } -gint rspamd_lua_push_header(lua_State *L, struct rspamd_mime_header *rh, - enum rspamd_lua_task_header_type how) +int rspamd_lua_push_header(lua_State *L, struct rspamd_mime_header *rh, + enum rspamd_lua_task_header_type how) { LUA_TRACE_POINT; switch (how) { @@ -2991,16 +2991,16 @@ gint rspamd_lua_push_header(lua_State *L, struct rspamd_mime_header *rh, return 1; } -gint rspamd_lua_push_header_array(lua_State *L, - const gchar *name, - struct rspamd_mime_header *rh, - enum rspamd_lua_task_header_type how, - gboolean strong) +int rspamd_lua_push_header_array(lua_State *L, + const char *name, + struct rspamd_mime_header *rh, + enum rspamd_lua_task_header_type how, + gboolean strong) { LUA_TRACE_POINT; struct rspamd_mime_header *cur; - guint i; - gint nret = 1; + unsigned int i; + int nret = 1; if (rh == NULL) { if (how == RSPAMD_TASK_HEADER_PUSH_HAS) { @@ -3076,14 +3076,14 @@ gint rspamd_lua_push_header_array(lua_State *L, return nret; } -static gint +static int lua_task_get_header_common(lua_State *L, enum rspamd_lua_task_header_type how) { LUA_TRACE_POINT; gboolean strong = FALSE, need_modified = FALSE; struct rspamd_task *task = lua_check_task(L, 1); struct rspamd_mime_header *rh; - const gchar *name; + const char *name; name = luaL_checkstring(L, 2); @@ -3105,37 +3105,37 @@ lua_task_get_header_common(lua_State *L, enum rspamd_lua_task_header_type how) } } -static gint +static int lua_task_get_header_full(lua_State *L) { return lua_task_get_header_common(L, RSPAMD_TASK_HEADER_PUSH_FULL); } -static gint +static int lua_task_get_header(lua_State *L) { return lua_task_get_header_common(L, RSPAMD_TASK_HEADER_PUSH_SIMPLE); } -static gint +static int lua_task_get_header_raw(lua_State *L) { return lua_task_get_header_common(L, RSPAMD_TASK_HEADER_PUSH_RAW); } -static gint +static int lua_task_get_header_count(lua_State *L) { return lua_task_get_header_common(L, RSPAMD_TASK_HEADER_PUSH_COUNT); } -static gint +static int lua_task_has_header(lua_State *L) { return lua_task_get_header_common(L, RSPAMD_TASK_HEADER_PUSH_HAS); } -static gint +static int lua_task_get_headers(lua_State *L) { LUA_TRACE_POINT; @@ -3172,7 +3172,7 @@ lua_task_get_headers(lua_State *L) return 1; } -static gint +static int lua_task_get_raw_headers(lua_State *L) { LUA_TRACE_POINT; @@ -3194,7 +3194,7 @@ lua_task_get_raw_headers(lua_State *L) return 1; } -static gint +static int lua_task_get_received_headers(lua_State *L) { LUA_TRACE_POINT; @@ -3226,7 +3226,7 @@ lua_task_get_received_headers(lua_State *L) return 1; } -static gint +static int lua_task_get_queue_id(lua_State *L) { LUA_TRACE_POINT; @@ -3247,7 +3247,7 @@ lua_task_get_queue_id(lua_State *L) return 1; } -static gint +static int lua_task_get_uid(lua_State *L) { LUA_TRACE_POINT; @@ -3263,7 +3263,7 @@ lua_task_get_uid(lua_State *L) return 1; } -static gint +static int lua_task_get_resolver(lua_State *L) { LUA_TRACE_POINT; @@ -3282,7 +3282,7 @@ lua_task_get_resolver(lua_State *L) return 1; } -static gint +static int lua_task_set_resolver(lua_State *L) { LUA_TRACE_POINT; @@ -3299,12 +3299,12 @@ lua_task_set_resolver(lua_State *L) return 0; } -static gint +static int lua_task_inc_dns_req(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - static guint warning_shown = 0; + static unsigned int warning_shown = 0; if (warning_shown < 100) { warning_shown++; @@ -3321,7 +3321,7 @@ lua_task_inc_dns_req(lua_State *L) return 0; } -static gint +static int lua_task_get_dns_req(lua_State *L) { LUA_TRACE_POINT; @@ -3352,10 +3352,10 @@ enum lua_email_address_type { * for get_from/get_recipients */ static enum lua_email_address_type -lua_task_str_to_get_type(lua_State *L, struct rspamd_task *task, gint pos, gint last_pos) +lua_task_str_to_get_type(lua_State *L, struct rspamd_task *task, int pos, int last_pos) { - const gchar *type = NULL; - gint ret = LUA_ADDRESS_ANY; + const char *type = NULL; + int ret = LUA_ADDRESS_ANY; uint64_t h; gsize sz; @@ -3389,7 +3389,7 @@ lua_task_str_to_get_type(lua_State *L, struct rspamd_task *task, gint pos, gint ret = LUA_ADDRESS_SMTP; break; default: - msg_err_task("invalid email type: %*s", (gint) sz, type); + msg_err_task("invalid email type: %*s", (int) sz, type); break; } } @@ -3421,7 +3421,7 @@ lua_task_str_to_get_type(lua_State *L, struct rspamd_task *task, gint pos, gint ret |= LUA_ADDRESS_ORIGINAL; break; default: - msg_err_task("invalid email type: %*s", (gint) sz, type); + msg_err_task("invalid email type: %*s", (int) sz, type); break; } } @@ -3518,7 +3518,7 @@ lua_push_email_address(lua_State *L, struct rspamd_email_address *addr) void lua_push_emails_address_list(lua_State *L, GPtrArray *addrs, int flags) { struct rspamd_email_address *addr; - guint i, pos = 1; + unsigned int i, pos = 1; lua_createtable(L, addrs->len, 0); @@ -3542,12 +3542,12 @@ void lua_push_emails_address_list(lua_State *L, GPtrArray *addrs, int flags) static gboolean lua_import_email_address(lua_State *L, struct rspamd_task *task, - gint pos, + int pos, struct rspamd_email_address **paddr) { struct rspamd_email_address *addr; - const gchar *p; - gchar *dst; + const char *p; + char *dst; gsize len; g_assert(paddr != NULL); @@ -3575,8 +3575,8 @@ lua_import_email_address(lua_State *L, struct rspamd_task *task, if (lua_type(L, -1) == LUA_TSTRING) { p = lua_tolstring(L, -1, &len); - addr->user = (const gchar *) rspamd_mempool_alloc(task->task_pool, len); - memcpy((gchar *) addr->user, p, len); + addr->user = (const char *) rspamd_mempool_alloc(task->task_pool, len); + memcpy((char *) addr->user, p, len); addr->user_len = len; } @@ -3587,8 +3587,8 @@ lua_import_email_address(lua_State *L, struct rspamd_task *task, if (lua_type(L, -1) == LUA_TSTRING) { p = lua_tolstring(L, -1, &len); - addr->domain = (const gchar *) rspamd_mempool_alloc(task->task_pool, len); - memcpy((gchar *) addr->domain, p, len); + addr->domain = (const char *) rspamd_mempool_alloc(task->task_pool, len); + memcpy((char *) addr->domain, p, len); addr->domain_len = len; } @@ -3599,15 +3599,15 @@ lua_import_email_address(lua_State *L, struct rspamd_task *task, if (lua_type(L, -1) == LUA_TSTRING) { p = lua_tolstring(L, -1, &len); - addr->addr = (const gchar *) rspamd_mempool_alloc(task->task_pool, len); - memcpy((gchar *) addr->addr, p, len); + addr->addr = (const char *) rspamd_mempool_alloc(task->task_pool, len); + memcpy((char *) addr->addr, p, len); addr->addr_len = len; } else { /* Construct addr */ len = addr->domain_len + addr->user_len + 1; - addr->addr = (const gchar *) rspamd_mempool_alloc(task->task_pool, len); - addr->addr_len = rspamd_snprintf((gchar *) addr->addr, len, "%*s@%*s", + addr->addr = (const char *) rspamd_mempool_alloc(task->task_pool, len); + addr->addr_len = rspamd_snprintf((char *) addr->addr, len, "%*s@%*s", (int) addr->user_len, addr->user, (int) addr->domain_len, addr->domain); } @@ -3618,7 +3618,7 @@ lua_import_email_address(lua_State *L, struct rspamd_task *task, lua_gettable(L, pos); if (lua_type(L, -1) == LUA_TSTRING) { - gchar *cpy; + char *cpy; p = lua_tolstring(L, -1, &len); cpy = rspamd_mempool_alloc(task->task_pool, len + 1); memcpy(cpy, p, len); @@ -3657,13 +3657,13 @@ lua_import_email_address(lua_State *L, struct rspamd_task *task, return TRUE; } -static gint +static int lua_task_get_recipients(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); GPtrArray *ptrs = NULL; - gint what = 0; + int what = 0; if (task) { if (lua_gettop(L) == 2) { @@ -3704,15 +3704,15 @@ lua_task_get_recipients(lua_State *L) return 1; } -static gint +static int lua_task_set_recipients(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); GPtrArray *ptrs = NULL; struct rspamd_email_address *addr = NULL; - gint what = 0, pos = 3; - const gchar *how = "add"; + int what = 0, pos = 3; + const char *how = "add"; gboolean need_update_digest = FALSE; if (task && lua_gettop(L) >= 3) { @@ -3758,7 +3758,7 @@ lua_task_set_recipients(lua_State *L) break; } if (ptrs) { - guint i, flags_existing = RSPAMD_EMAIL_ADDR_ORIGINAL, flags_add = 0; + unsigned int i, flags_existing = RSPAMD_EMAIL_ADDR_ORIGINAL, flags_add = 0; struct rspamd_email_address *tmp; if (strcmp(how, "alias") == 0) { @@ -3830,12 +3830,12 @@ lua_task_set_recipients(lua_State *L) } \ } while (0) -static gint +static int lua_task_has_from(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - gint what = 0, nrcpt = 0; + int what = 0, nrcpt = 0; gboolean ret = FALSE; if (task) { @@ -3876,7 +3876,7 @@ lua_task_has_from(lua_State *L) static inline int rspamd_check_real_recipients_array_size(GPtrArray *ar) { - gint ret = 0, i; + int ret = 0, i; struct rspamd_email_address *addr; PTR_ARRAY_FOREACH(ar, i, addr) @@ -3889,12 +3889,12 @@ rspamd_check_real_recipients_array_size(GPtrArray *ar) return ret; } -static gint +static int lua_task_has_recipients(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - gint what = 0, nrcpt = 0; + int what = 0, nrcpt = 0; gboolean ret = FALSE; if (task) { @@ -3936,14 +3936,14 @@ lua_task_has_recipients(lua_State *L) return 2; } -static gint +static int lua_task_get_from(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); GPtrArray *addrs = NULL; struct rspamd_email_address *addr = NULL; - gint what = 0; + int what = 0; if (task) { if (lua_gettop(L) == 2) { @@ -4007,16 +4007,16 @@ lua_task_get_from(lua_State *L) return 1; } -static gint +static int lua_task_set_from(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *how = "rewrite"; + const char *how = "rewrite"; GPtrArray *addrs = NULL; struct rspamd_email_address **paddr = NULL, *addr; gboolean need_update_digest = FALSE; - gint what = 0; + int what = 0; if (task && lua_gettop(L) >= 3) { what = lua_task_str_to_get_type(L, task, 2, -1); @@ -4049,7 +4049,7 @@ lua_task_set_from(lua_State *L) if (addrs) { if (lua_import_email_address(L, task, 3, &addr)) { - guint i, flags_add = RSPAMD_EMAIL_ADDR_ORIGINAL; + unsigned int i, flags_add = RSPAMD_EMAIL_ADDR_ORIGINAL; struct rspamd_email_address *tmp; if (strcmp(how, "alias") == 0) { @@ -4095,12 +4095,12 @@ lua_task_set_from(lua_State *L) return 1; } -static gint +static int lua_task_get_principal_recipient(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *r; + const char *r; if (task) { r = rspamd_task_get_principal_recipient(task); @@ -4118,7 +4118,7 @@ lua_task_get_principal_recipient(lua_State *L) return 1; } -static gint +static int lua_task_get_reply_sender(lua_State *L) { LUA_TRACE_POINT; @@ -4169,7 +4169,7 @@ lua_task_get_reply_sender(lua_State *L) return 1; } -static gint +static int lua_task_get_user(lua_State *L) { LUA_TRACE_POINT; @@ -4190,12 +4190,12 @@ lua_task_get_user(lua_State *L) return 1; } -static gint +static int lua_task_set_user(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *new_user; + const char *new_user; if (task) { @@ -4232,7 +4232,7 @@ lua_task_set_user(lua_State *L) return 1; } -static gint +static int lua_task_get_from_ip(lua_State *L) { LUA_TRACE_POINT; @@ -4253,7 +4253,7 @@ lua_task_get_from_ip(lua_State *L) return 1; } -static gint +static int lua_task_set_from_ip(lua_State *L) { LUA_TRACE_POINT; @@ -4266,7 +4266,7 @@ lua_task_set_from_ip(lua_State *L) else { if (lua_type(L, 2) == LUA_TSTRING) { gsize len; - const gchar *ip_str = lua_tolstring(L, 2, &len); + const char *ip_str = lua_tolstring(L, 2, &len); if (!rspamd_parse_inet_address(&addr, ip_str, @@ -4304,7 +4304,7 @@ lua_task_set_from_ip(lua_State *L) return 0; } -static gint +static int lua_task_get_from_ip_num(lua_State *L) { LUA_TRACE_POINT; @@ -4313,7 +4313,7 @@ lua_task_get_from_ip_num(lua_State *L) return 1; } -static gint +static int lua_task_get_client_ip(lua_State *L) { LUA_TRACE_POINT; @@ -4334,7 +4334,7 @@ lua_task_get_client_ip(lua_State *L) return 1; } -static gint +static int lua_task_get_helo(lua_State *L) { LUA_TRACE_POINT; @@ -4356,7 +4356,7 @@ lua_task_get_helo(lua_State *L) return 1; } -static gint +static int lua_task_get_subject(lua_State *L) { LUA_TRACE_POINT; @@ -4378,12 +4378,12 @@ lua_task_get_subject(lua_State *L) return 1; } -static gint +static int lua_task_set_helo(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *new_helo; + const char *new_helo; if (task) { new_helo = luaL_checkstring(L, 2); @@ -4398,7 +4398,7 @@ lua_task_set_helo(lua_State *L) return 0; } -static gint +static int lua_task_get_hostname(lua_State *L) { LUA_TRACE_POINT; @@ -4433,12 +4433,12 @@ lua_task_get_hostname(lua_State *L) return 1; } -static gint +static int lua_task_set_hostname(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *new_hostname; + const char *new_hostname; if (task) { new_hostname = luaL_checkstring(L, 2); @@ -4454,12 +4454,12 @@ lua_task_set_hostname(lua_State *L) return 0; } -static gint +static int lua_task_get_images(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - guint nelt = 0, i; + unsigned int nelt = 0, i; struct rspamd_mime_part *part; struct rspamd_image **pimg; @@ -4492,12 +4492,12 @@ lua_task_get_images(lua_State *L) return 1; } -static gint +static int lua_task_get_archives(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - guint nelt = 0, i; + unsigned int nelt = 0, i; struct rspamd_mime_part *part; struct rspamd_archive **parch; @@ -4530,12 +4530,12 @@ lua_task_get_archives(lua_State *L) return 1; } -static gint +static int lua_task_get_dkim_results(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - guint nelt = 0, i; + unsigned int nelt = 0, i; struct rspamd_dkim_check_result **pres, **cur; if (task) { @@ -4555,7 +4555,7 @@ lua_task_get_dkim_results(lua_State *L) for (i = 0; i < nelt; i++) { struct rspamd_dkim_check_result *res = pres[i]; - const gchar *result_str = "unknown"; + const char *result_str = "unknown"; lua_createtable(L, 0, 4); @@ -4617,7 +4617,7 @@ lua_task_get_dkim_results(lua_State *L) static inline gboolean lua_push_symbol_result(lua_State *L, struct rspamd_task *task, - const gchar *symbol, + const char *symbol, struct rspamd_symbol_result *symbol_result, struct rspamd_scan_result *metric_res, gboolean add_metric, @@ -4627,8 +4627,8 @@ lua_push_symbol_result(lua_State *L, struct rspamd_symbol_result *s = NULL; struct rspamd_symbol_option *opt; struct rspamd_symbols_group *sym_group; - guint i; - gint j = 1, table_fields_cnt = 4; + unsigned int i; + int j = 1, table_fields_cnt = 4; if (!metric_res) { metric_res = task->result; @@ -4701,12 +4701,12 @@ lua_push_symbol_result(lua_State *L, return FALSE; } -static gint +static int lua_task_get_symbol(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *symbol; + const char *symbol; gboolean found = FALSE; symbol = luaL_checkstring(L, 2); @@ -4746,13 +4746,13 @@ lua_task_get_symbol(lua_State *L) return 1; } -static gint +static int lua_task_has_symbol(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); struct rspamd_symbol_result *s; - const gchar *symbol; + const char *symbol; gboolean found = FALSE; symbol = luaL_checkstring(L, 2); @@ -4782,12 +4782,12 @@ lua_task_has_symbol(lua_State *L) return 1; } -static gint +static int lua_task_enable_symbol(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *symbol; + const char *symbol; gboolean found = FALSE; symbol = luaL_checkstring(L, 2); @@ -4803,12 +4803,12 @@ lua_task_enable_symbol(lua_State *L) return 1; } -static gint +static int lua_task_disable_symbol(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *symbol; + const char *symbol; gboolean found = FALSE; symbol = luaL_checkstring(L, 2); @@ -4824,13 +4824,13 @@ lua_task_disable_symbol(lua_State *L) return 1; } -static gint +static int lua_task_get_symbols(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); struct rspamd_scan_result *mres; - gint i = 1; + int i = 1; struct rspamd_symbol_result *s; if (task) { @@ -4866,7 +4866,7 @@ lua_task_get_symbols(lua_State *L) return 2; } -static gint +static int lua_task_get_symbols_all(lua_State *L) { LUA_TRACE_POINT; @@ -4874,7 +4874,7 @@ lua_task_get_symbols_all(lua_State *L) struct rspamd_scan_result *mres; struct rspamd_symbol_result *s; gboolean found = FALSE; - gint i = 1; + int i = 1; if (task) { mres = task->result; @@ -4907,13 +4907,13 @@ lua_task_get_symbols_all(lua_State *L) } -static gint +static int lua_task_get_symbols_numeric(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); struct rspamd_scan_result *mres; - gint i = 1, id; + int i = 1, id; struct rspamd_symbol_result *s; if (task) { @@ -4953,7 +4953,7 @@ lua_task_get_symbols_numeric(lua_State *L) return 2; } -static gint +static int lua_task_get_groups(lua_State *L) { LUA_TRACE_POINT; @@ -4961,7 +4961,7 @@ lua_task_get_groups(lua_State *L) gboolean need_private; struct rspamd_scan_result *mres; struct rspamd_symbols_group *gr; - gdouble gr_score; + double gr_score; if (task) { mres = task->result; @@ -5006,7 +5006,7 @@ lua_task_get_groups(lua_State *L) struct tokens_foreach_cbdata { struct rspamd_task *task; lua_State *L; - gint idx; + int idx; gboolean normalize; }; @@ -5015,8 +5015,8 @@ tokens_foreach_cb(struct rspamd_symcache_item *item, gpointer ud) { struct tokens_foreach_cbdata *cbd = ud; struct rspamd_symbol_result *s; - gint flags; - const gchar *sym; + int flags; + const char *sym; sym = rspamd_symcache_item_name(item); flags = rspamd_symcache_item_flags(item); @@ -5045,7 +5045,7 @@ tokens_foreach_cb(struct rspamd_symcache_item *item, gpointer ud) lua_rawseti(cbd->L, -2, cbd->idx++); } -static gint +static int lua_task_get_symbols_tokens(lua_State *L) { LUA_TRACE_POINT; @@ -5077,22 +5077,22 @@ lua_task_get_symbols_tokens(lua_State *L) return 1; } -static gint +static int lua_task_process_ann_tokens(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - gint offset = luaL_checkinteger(L, 4); - gdouble min_score = 0.0; + int offset = luaL_checkinteger(L, 4); + double min_score = 0.0; if (task && lua_istable(L, 2) && lua_istable(L, 3)) { - guint symlen = rspamd_lua_table_size(L, 2); + unsigned int symlen = rspamd_lua_table_size(L, 2); if (lua_isnumber(L, 5)) { min_score = lua_tonumber(L, 5); } - for (guint i = 1; i <= symlen; i++, offset++) { - const gchar *sym; + for (unsigned int i = 1; i <= symlen; i++, offset++) { + const char *sym; struct rspamd_symbol_result *sres; lua_rawgeti(L, 2, i); @@ -5116,7 +5116,7 @@ lua_task_process_ann_tokens(lua_State *L) (!sres->sym || !(rspamd_symcache_item_flags(sres->sym->cache_item) & SYMBOL_TYPE_NOSTAT))) { - gdouble norm_score; + double norm_score; if (sres->sym && !isnan(sres->sym->score)) { if (sres->sym->score == 0) { @@ -5166,18 +5166,18 @@ enum lua_date_type { static enum lua_date_type lua_task_detect_date_type(struct rspamd_task *task, - lua_State *L, gint idx, gboolean *gmt) + lua_State *L, int idx, gboolean *gmt) { enum lua_date_type type = DATE_CONNECT; if (lua_type(L, idx) == LUA_TNUMBER) { - gint num = lua_tonumber(L, idx); + int num = lua_tonumber(L, idx); if (num >= DATE_CONNECT && num < DATE_INVALID) { return num; } } else if (lua_type(L, idx) == LUA_TTABLE) { - const gchar *str; + const char *str; lua_pushvalue(L, idx); lua_pushstring(L, "format"); @@ -5210,13 +5210,13 @@ lua_task_detect_date_type(struct rspamd_task *task, return type; } -static gint +static int lua_task_get_date(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); struct rspamd_mime_header *h; - gdouble tim; + double tim; enum lua_date_type type = DATE_CONNECT; gboolean gmt = TRUE; @@ -5285,7 +5285,7 @@ lua_task_get_date(lua_State *L) return 1; } -static gint +static int lua_task_get_message_id(lua_State *L) { LUA_TRACE_POINT; @@ -5306,7 +5306,7 @@ lua_task_get_message_id(lua_State *L) return 1; } -static gint +static int lua_task_get_timeval(lua_State *L) { LUA_TRACE_POINT; @@ -5335,7 +5335,7 @@ lua_task_get_timeval(lua_State *L) return 1; } -static gint +static int lua_task_get_scan_time(lua_State *L) { LUA_TRACE_POINT; @@ -5348,7 +5348,7 @@ lua_task_get_scan_time(lua_State *L) } rspamd_task_set_finish_time(task); - gdouble diff = task->time_real_finish - task->task_timestamp; + double diff = task->time_real_finish - task->task_timestamp; lua_pushnumber(L, diff); lua_pushnumber(L, diff); @@ -5364,7 +5364,7 @@ lua_task_get_scan_time(lua_State *L) return 2; } -static gint +static int lua_task_get_size(lua_State *L) { LUA_TRACE_POINT; @@ -5427,12 +5427,12 @@ lua_task_get_size(lua_State *L) } \ } while (0) -static gint +static int lua_task_set_flag(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *flag = luaL_checkstring(L, 2); + const char *flag = luaL_checkstring(L, 2); gboolean set = TRUE, found = FALSE; if (lua_gettop(L) >= 3) { @@ -5463,12 +5463,12 @@ lua_task_set_flag(lua_State *L) return 0; } -static gint +static int lua_task_has_flag(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *flag = luaL_checkstring(L, 2); + const char *flag = luaL_checkstring(L, 2); gboolean found = FALSE; if (task != NULL && flag != NULL) { @@ -5504,13 +5504,13 @@ lua_task_has_flag(lua_State *L) return 1; } -static gint +static int lua_task_get_flags(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - gint idx = 1; - guint flags, bit, i; + int idx = 1; + unsigned int flags, bit, i; if (task) { lua_createtable(L, 8, 0); @@ -5584,13 +5584,13 @@ lua_task_get_flags(lua_State *L) return 1; } -static gint +static int lua_task_get_digest(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - gchar hexbuf[sizeof(MESSAGE_FIELD(task, digest)) * 2 + 1]; - gint r; + char hexbuf[sizeof(MESSAGE_FIELD(task, digest)) * 2 + 1]; + int r; if (task) { if (task->message) { @@ -5617,13 +5617,13 @@ lua_task_get_digest(lua_State *L) return 1; } -static gint +static int lua_task_learn(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); gboolean is_spam = FALSE; - const gchar *clname = NULL; + const char *clname = NULL; GError *err = NULL; int ret = 1; @@ -5650,7 +5650,7 @@ lua_task_learn(lua_State *L) return ret; } -static gint +static int lua_task_set_settings(lua_State *L) { LUA_TRACE_POINT; @@ -5659,7 +5659,7 @@ lua_task_set_settings(lua_State *L) const ucl_object_t *act, *metric_elt, *vars, *cur; ucl_object_iter_t it = NULL; struct rspamd_scan_result *mres; - guint i; + unsigned int i; settings = ucl_object_lua_import(L, 2); @@ -5691,7 +5691,7 @@ lua_task_set_settings(lua_State *L) it = NULL; while ((cur = ucl_object_iterate(act, &it, true)) != NULL) { - const gchar *act_name = ucl_object_key(cur); + const char *act_name = ucl_object_key(cur); struct rspamd_action_config *action_config = NULL; double act_score; enum rspamd_action_type act_type; @@ -5810,7 +5810,7 @@ lua_task_set_settings(lua_State *L) return 0; } -static gint +static int lua_task_set_milter_reply(lua_State *L) { LUA_TRACE_POINT; @@ -5856,7 +5856,7 @@ lua_task_set_milter_reply(lua_State *L) while ((cur = ucl_object_iterate(nadd_hdrs, &it, true)) != NULL) { gsize klen; - const gchar *key = ucl_object_keyl(cur, &klen); + const char *key = ucl_object_keyl(cur, &klen); const ucl_object_t *existing; existing = ucl_object_lookup_len(add_hdrs, key, klen); @@ -5893,7 +5893,7 @@ lua_task_set_milter_reply(lua_State *L) return 0; } -static gint +static int lua_task_get_settings(lua_State *L) { LUA_TRACE_POINT; @@ -5915,12 +5915,12 @@ lua_task_get_settings(lua_State *L) return 1; } -static gint +static int lua_task_lookup_settings(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *key = NULL; + const char *key = NULL; const ucl_object_t *elt; if (task != NULL) { @@ -5955,7 +5955,7 @@ lua_task_lookup_settings(lua_State *L) return 1; } -static gint +static int lua_task_get_settings_id(lua_State *L) { LUA_TRACE_POINT; @@ -5977,7 +5977,7 @@ lua_task_get_settings_id(lua_State *L) return 1; } -static gint +static int lua_task_set_settings_id(lua_State *L) { LUA_TRACE_POINT; @@ -6010,12 +6010,12 @@ lua_task_set_settings_id(lua_State *L) return 1; } -static gint +static int lua_task_cache_get(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *key = luaL_checkstring(L, 2); + const char *key = luaL_checkstring(L, 2); if (task && key) { if (!lua_task_get_cached(L, task, key)) { @@ -6029,12 +6029,12 @@ lua_task_cache_get(lua_State *L) return 1; } -static gint +static int lua_task_cache_set(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *key = luaL_checkstring(L, 2); + const char *key = luaL_checkstring(L, 2); if (task && key && lua_gettop(L) >= 3) { lua_task_set_cached(L, task, key, 3); @@ -6047,8 +6047,8 @@ lua_task_cache_set(lua_State *L) } struct lua_file_cbdata { - gchar *fname; - gint fd; + char *fname; + int fd; gboolean keep; }; @@ -6064,16 +6064,16 @@ lua_tmp_file_dtor(gpointer p) close(cbdata->fd); } -static gint +static int lua_task_store_in_file(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); gboolean force_new = FALSE, keep = FALSE; - gchar fpath[PATH_MAX]; - const gchar *tmpmask = NULL, *fname = NULL; - guint mode = 00600; - gint fd; + char fpath[PATH_MAX]; + const char *tmpmask = NULL, *fname = NULL; + unsigned int mode = 00600; + int fd; struct lua_file_cbdata *cbdata; GError *err = NULL; @@ -6120,7 +6120,7 @@ lua_task_store_in_file(lua_State *L) } else { fd = rspamd_file_xopen(fname, O_WRONLY | O_CREAT | O_EXCL, - (guint) mode, FALSE); + (unsigned int) mode, FALSE); } if (fd == -1) { @@ -6155,17 +6155,17 @@ lua_task_store_in_file(lua_State *L) return 1; } -static gint +static int lua_task_process_regexp(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); struct rspamd_lua_regexp *re = NULL; gboolean strong = FALSE; - const gchar *type_str = NULL, *header_str = NULL; + const char *type_str = NULL, *header_str = NULL; gsize header_len = 0; GError *err = NULL; - gint ret = 0; + int ret = 0; enum rspamd_re_type type = RSPAMD_RE_BODY; /* @@ -6216,7 +6216,7 @@ lua_task_process_regexp(lua_State *L) return 1; } -static gint +static int lua_task_get_metric_result(lua_State *L) { LUA_TRACE_POINT; @@ -6287,12 +6287,12 @@ lua_task_get_metric_result(lua_State *L) return 1; } -static gint +static int lua_task_get_metric_score(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - gdouble rs; + double rs; struct rspamd_scan_result *metric_res; if (task) { @@ -6321,7 +6321,7 @@ lua_task_get_metric_score(lua_State *L) return 1; } -static gint +static int lua_task_get_metric_action(lua_State *L) { LUA_TRACE_POINT; @@ -6351,13 +6351,13 @@ lua_task_get_metric_action(lua_State *L) return 1; } -static gint +static int lua_task_set_metric_score(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); struct rspamd_scan_result *metric_res; - gdouble nscore; + double nscore; if (lua_isnumber(L, 2)) { nscore = luaL_checknumber(L, 2); @@ -6390,19 +6390,19 @@ lua_task_set_metric_score(lua_State *L) return 1; } -static gint +static int lua_task_disable_action(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *action_name; + const char *action_name; struct rspamd_action_config *action_res; action_name = luaL_checkstring(L, 2); if (task && action_name) { - for (guint i = 0; i < task->result->nactions; i++) { + for (unsigned int i = 0; i < task->result->nactions; i++) { action_res = &task->result->actions_config[i]; if (strcmp(action_name, action_res->action->name) == 0) { @@ -6425,7 +6425,7 @@ lua_task_disable_action(lua_State *L) return 1; } -static gint +static int lua_task_get_newlines_type(lua_State *L) { LUA_TRACE_POINT; @@ -6460,7 +6460,7 @@ lua_task_get_newlines_type(lua_State *L) static void lua_push_stat_token(lua_State *L, rspamd_token_t *tok) { - gchar numbuf[64]; + char numbuf[64]; /* Table values * - `data`: 64 bit number encoded as a string @@ -6532,12 +6532,12 @@ lua_push_stat_token(lua_State *L, rspamd_token_t *tok) lua_settable(L, -3); } -static gint +static int lua_task_get_stat_tokens(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - guint i; + unsigned int i; rspamd_token_t *tok; if (task) { @@ -6565,12 +6565,12 @@ lua_task_get_stat_tokens(lua_State *L) return 1; } -static gint +static int lua_task_set_metric_subject(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *subject; + const char *subject; subject = luaL_checkstring(L, 2); @@ -6586,12 +6586,12 @@ lua_task_set_metric_subject(lua_State *L) return 1; } -static gint +static int lua_task_get_protocol_reply(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - guint flags = 0; + unsigned int flags = 0; ucl_object_t *obj; if (!task) { @@ -6605,7 +6605,7 @@ lua_task_get_protocol_reply(lua_State *L) if (lua_istable(L, 2)) { for (lua_pushnil(L); lua_next(L, 2); lua_pop(L, 1)) { if (lua_isstring(L, -1)) { - const gchar *str = lua_tostring(L, -1); + const char *str = lua_tostring(L, -1); if (strcmp(str, "default") == 0) { flags |= RSPAMD_PROTOCOL_DEFAULT; @@ -6650,7 +6650,7 @@ lua_task_get_protocol_reply(lua_State *L) return 1; } -static gint +static int lua_task_headers_foreach(lua_State *L) { LUA_TRACE_POINT; @@ -6658,7 +6658,7 @@ lua_task_headers_foreach(lua_State *L) enum rspamd_lua_task_header_type how = RSPAMD_TASK_HEADER_PUSH_SIMPLE; struct rspamd_lua_regexp *re = NULL; struct rspamd_mime_header *hdr, *cur; - gint old_top; + int old_top; if (task && lua_isfunction(L, 2)) { if (task->message) { @@ -6738,12 +6738,12 @@ lua_task_headers_foreach(lua_State *L) return 0; } -static gint +static int lua_task_modify_header(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *hname = luaL_checkstring(L, 2); + const char *hname = luaL_checkstring(L, 2); if (hname && task && lua_type(L, 3) == LUA_TTABLE) { if (task->message) { @@ -6769,7 +6769,7 @@ lua_task_modify_header(lua_State *L) return 1; } -static gint +static int lua_task_get_meta_words(lua_State *L) { LUA_TRACE_POINT; @@ -6785,7 +6785,7 @@ lua_task_get_meta_words(lua_State *L) } else { if (lua_type(L, 2) == LUA_TSTRING) { - const gchar *how_str = lua_tostring(L, 2); + const char *how_str = lua_tostring(L, 2); if (strcmp(how_str, "stem") == 0) { how = RSPAMD_LUA_WORDS_STEM; @@ -6810,18 +6810,18 @@ lua_task_get_meta_words(lua_State *L) return 1; } -static guint +static unsigned int lua_lookup_words_array(lua_State *L, - gint cbpos, + int cbpos, struct rspamd_task *task, struct rspamd_lua_map *map, GArray *words) { rspamd_stat_token_t *tok; - guint i, nmatched = 0; - gint err_idx; + unsigned int i, nmatched = 0; + int err_idx; gboolean matched; - const gchar *key; + const char *key; gsize keylen; for (i = 0; i < words->len; i++) { @@ -6876,7 +6876,7 @@ lua_lookup_words_array(lua_State *L, return nmatched; } -static gint +static int lua_task_lookup_words(lua_State *L) { LUA_TRACE_POINT; @@ -6884,7 +6884,7 @@ lua_task_lookup_words(lua_State *L) struct rspamd_lua_map *map = lua_check_map(L, 2); struct rspamd_mime_text_part *tp; - guint i, matches = 0; + unsigned int i, matches = 0; if (task == NULL || map == NULL || task->message == NULL || lua_type(L, 3) != LUA_TFUNCTION) { return luaL_error(L, "invalid arguments"); @@ -6913,7 +6913,7 @@ lua_task_lookup_words(lua_State *L) return 1; } -static gint +static int lua_task_topointer(lua_State *L) { LUA_TRACE_POINT; @@ -6930,13 +6930,13 @@ lua_task_topointer(lua_State *L) return 1; } -static gint +static int lua_task_add_named_result(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); - const gchar *name = luaL_checkstring(L, 2); - gint cbref; + const char *name = luaL_checkstring(L, 2); + int cbref; if (task && name && lua_isfunction(L, 3)) { lua_pushvalue(L, 3); @@ -6950,14 +6950,14 @@ lua_task_add_named_result(lua_State *L) return 0; } -static gint +static int lua_task_get_all_named_results(lua_State *L) { LUA_TRACE_POINT; struct rspamd_task *task = lua_check_task(L, 1); if (task) { - gint n = 0; + int n = 0; struct rspamd_scan_result *res; DL_COUNT(task->result, res, n); @@ -6985,7 +6985,7 @@ lua_task_get_all_named_results(lua_State *L) /* Image functions */ -static gint +static int lua_image_get_width(lua_State *L) { LUA_TRACE_POINT; @@ -7001,7 +7001,7 @@ lua_image_get_width(lua_State *L) return 1; } -static gint +static int lua_image_get_height(lua_State *L) { LUA_TRACE_POINT; @@ -7017,7 +7017,7 @@ lua_image_get_height(lua_State *L) return 1; } -static gint +static int lua_image_get_type(lua_State *L) { LUA_TRACE_POINT; @@ -7033,7 +7033,7 @@ lua_image_get_type(lua_State *L) return 1; } -static gint +static int lua_image_get_size(lua_State *L) { LUA_TRACE_POINT; @@ -7049,7 +7049,7 @@ lua_image_get_size(lua_State *L) return 1; } -static gint +static int lua_image_get_filename(lua_State *L) { LUA_TRACE_POINT; @@ -7071,7 +7071,7 @@ lua_image_get_filename(lua_State *L) } /* Archive methods */ -static gint +static int lua_archive_get_type(lua_State *L) { LUA_TRACE_POINT; @@ -7087,12 +7087,12 @@ lua_archive_get_type(lua_State *L) return 1; } -static gint +static int lua_archive_get_files(lua_State *L) { LUA_TRACE_POINT; struct rspamd_archive *arch = lua_check_archive(L); - guint i, max_files = 0; + unsigned int i, max_files = 0; struct rspamd_archive_file *f; if (arch != NULL) { @@ -7120,12 +7120,12 @@ lua_archive_get_files(lua_State *L) return 1; } -static gint +static int lua_archive_get_files_full(lua_State *L) { LUA_TRACE_POINT; struct rspamd_archive *arch = lua_check_archive(L); - guint i, max_files = 0; + unsigned int i, max_files = 0; struct rspamd_archive_file *f; if (arch != NULL) { @@ -7170,7 +7170,7 @@ lua_archive_get_files_full(lua_State *L) return 1; } -static gint +static int lua_archive_is_encrypted(lua_State *L) { LUA_TRACE_POINT; @@ -7186,7 +7186,7 @@ lua_archive_is_encrypted(lua_State *L) return 1; } -static gint +static int lua_archive_is_obfuscated(lua_State *L) { LUA_TRACE_POINT; @@ -7203,7 +7203,7 @@ lua_archive_is_obfuscated(lua_State *L) return 1; } -static gint +static int lua_archive_is_unreadable(lua_State *L) { LUA_TRACE_POINT; @@ -7219,7 +7219,7 @@ lua_archive_is_unreadable(lua_State *L) return 1; } -static gint +static int lua_archive_get_size(lua_State *L) { LUA_TRACE_POINT; @@ -7235,7 +7235,7 @@ lua_archive_get_size(lua_State *L) return 1; } -static gint +static int lua_archive_get_filename(lua_State *L) { LUA_TRACE_POINT; @@ -7253,7 +7253,7 @@ lua_archive_get_filename(lua_State *L) /* Init part */ -static gint +static int lua_load_task(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index e0595c5c4..f498f9598 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -20,7 +20,7 @@ #include "unix-std.h" #include <math.h> -static const gchar *M = "rspamd lua tcp"; +static const char *M = "rspamd lua tcp"; /*** * @module rspamd_tcp @@ -262,15 +262,15 @@ static const struct luaL_reg tcp_sync_libm[] = { {NULL, NULL}}; struct lua_tcp_read_handler { - gchar *stop_pattern; - guint plen; - gint cbref; + char *stop_pattern; + unsigned int plen; + int cbref; }; struct lua_tcp_write_handler { struct iovec *iov; - guint iovlen; - gint cbref; + unsigned int iovlen; + int cbref; gsize pos; gsize total_bytes; }; @@ -329,11 +329,11 @@ struct lua_tcp_cbdata { rspamd_inet_addr_t *addr; GByteArray *in; GQueue *handlers; - gint fd; - gint connect_cb; - guint port; - guint flags; - gchar tag[7]; + int fd; + int connect_cb; + unsigned int port; + unsigned int flags; + char tag[7]; struct rspamd_io_ev ev; struct lua_tcp_dtor *dtors; ref_entry_t ref; @@ -342,7 +342,7 @@ struct lua_tcp_cbdata { struct thread_entry *thread; struct rspamd_config *cfg; struct rspamd_ssl_connection *ssl_conn; - gchar *hostname; + char *hostname; struct upstream *up; gboolean eof; }; @@ -366,7 +366,7 @@ lua_tcp_void_finalyser(gpointer arg) { } -static const gdouble default_tcp_timeout = 5.0; +static const double default_tcp_timeout = 5.0; static struct rspamd_dns_resolver * lua_tcp_global_resolver(struct ev_loop *ev_base, @@ -482,7 +482,7 @@ lua_tcp_fin(gpointer arg) } static struct lua_tcp_cbdata * -lua_check_tcp(lua_State *L, gint pos) +lua_check_tcp(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_tcp_classname); luaL_argcheck(L, ud != NULL, pos, "'tcp' expected"); @@ -530,7 +530,7 @@ lua_tcp_push_error(struct lua_tcp_cbdata *cbd, gboolean is_fatal, const char *err, ...) __attribute__((format(printf, 3, 4))); #endif -static void lua_tcp_resume_thread_error_argp(struct lua_tcp_cbdata *cbd, const gchar *error, va_list argp); +static void lua_tcp_resume_thread_error_argp(struct lua_tcp_cbdata *cbd, const char *error, va_list argp); static void lua_tcp_push_error(struct lua_tcp_cbdata *cbd, gboolean is_fatal, @@ -539,7 +539,7 @@ lua_tcp_push_error(struct lua_tcp_cbdata *cbd, gboolean is_fatal, va_list ap, ap_copy; struct lua_tcp_cbdata **pcbd; struct lua_tcp_handler *hdl; - gint cbref, top; + int cbref, top; struct lua_callback_state cbs; lua_State *L; gboolean callback_called = FALSE; @@ -636,15 +636,15 @@ lua_tcp_push_error(struct lua_tcp_cbdata *cbd, gboolean is_fatal, lua_thread_pool_restore_callback(&cbs); } -static void lua_tcp_resume_thread(struct lua_tcp_cbdata *cbd, const guint8 *str, gsize len); +static void lua_tcp_resume_thread(struct lua_tcp_cbdata *cbd, const uint8_t *str, gsize len); static void -lua_tcp_push_data(struct lua_tcp_cbdata *cbd, const guint8 *str, gsize len) +lua_tcp_push_data(struct lua_tcp_cbdata *cbd, const uint8_t *str, gsize len) { struct rspamd_lua_text *t; struct lua_tcp_cbdata **pcbd; struct lua_tcp_handler *hdl; - gint cbref, arg_cnt, top; + int cbref, arg_cnt, top; struct lua_callback_state cbs; lua_State *L; @@ -677,7 +677,7 @@ lua_tcp_push_data(struct lua_tcp_cbdata *cbd, const guint8 *str, gsize len) if (hdl->type == LUA_WANT_READ) { t = lua_newuserdata(L, sizeof(*t)); rspamd_lua_setclass(L, rspamd_text_classname, -1); - t->start = (const gchar *) str; + t->start = (const char *) str; t->len = len; t->flags = 0; arg_cnt = 3; @@ -714,7 +714,7 @@ lua_tcp_push_data(struct lua_tcp_cbdata *cbd, const guint8 *str, gsize len) } static void -lua_tcp_resume_thread_error_argp(struct lua_tcp_cbdata *cbd, const gchar *error, va_list argp) +lua_tcp_resume_thread_error_argp(struct lua_tcp_cbdata *cbd, const char *error, va_list argp) { struct thread_entry *thread = cbd->thread; lua_State *L = thread->lua_state; @@ -730,7 +730,7 @@ lua_tcp_resume_thread_error_argp(struct lua_tcp_cbdata *cbd, const gchar *error, } static void -lua_tcp_resume_thread(struct lua_tcp_cbdata *cbd, const guint8 *str, gsize len) +lua_tcp_resume_thread(struct lua_tcp_cbdata *cbd, const uint8_t *str, gsize len) { /* * typical call returns: @@ -806,8 +806,8 @@ static void lua_tcp_write_helper(struct lua_tcp_cbdata *cbd) { struct iovec *start; - guint niov, i; - gint flags = 0; + unsigned int niov, i; + int flags = 0; bool allocated_iov = false; gsize remain; gssize r; @@ -887,7 +887,7 @@ lua_tcp_write_helper(struct lua_tcp_cbdata *cbd) else { lua_tcp_push_error(cbd, TRUE, "IO write error while trying to write %d bytes: %s", - (gint) remain, strerror(errno)); + (int) remain, strerror(errno)); msg_debug_tcp("write error, terminate connection"); TCP_RELEASE(cbd); @@ -945,7 +945,7 @@ static gboolean lua_tcp_process_read_handler(struct lua_tcp_cbdata *cbd, struct lua_tcp_read_handler *rh, gboolean eof) { - guint slen; + unsigned int slen; goffset pos; if (rh->stop_pattern) { @@ -1006,7 +1006,7 @@ lua_tcp_process_read_handler(struct lua_tcp_cbdata *cbd, static void lua_tcp_process_read(struct lua_tcp_cbdata *cbd, - guchar *in, gssize r) + unsigned char *in, gssize r) { struct lua_tcp_handler *hdl; struct lua_tcp_read_handler *rh; @@ -1089,9 +1089,9 @@ static void lua_tcp_handler(int fd, short what, gpointer ud) { struct lua_tcp_cbdata *cbd = ud; - guchar inbuf[8192]; + unsigned char inbuf[8192]; gssize r; - gint so_error = 0; + int so_error = 0; socklen_t so_len = sizeof(so_error); struct lua_callback_state cbs; lua_State *L; @@ -1135,7 +1135,7 @@ lua_tcp_handler(int fd, short what, gpointer ud) if (cbd->connect_cb != -1) { struct lua_tcp_cbdata **pcbd; - gint top; + int top; lua_thread_pool_prepare_callback(cbd->cfg->lua_thread_pool, &cbs); L = cbs.L; @@ -1450,12 +1450,12 @@ lua_tcp_dns_handler(struct rdns_reply *reply, gpointer ud) } static gboolean -lua_tcp_arg_toiovec(lua_State *L, gint pos, struct lua_tcp_cbdata *cbd, +lua_tcp_arg_toiovec(lua_State *L, int pos, struct lua_tcp_cbdata *cbd, struct iovec *vec) { struct rspamd_lua_text *t; gsize len; - const gchar *str; + const char *str; struct lua_tcp_dtor *dtor; if (lua_type(L, pos) == LUA_TUSERDATA) { @@ -1521,14 +1521,14 @@ lua_tcp_arg_toiovec(lua_State *L, gint pos, struct lua_tcp_cbdata *cbd, * - `upstream`: optional upstream object that would be used to get an address * @return {boolean} true if request has been sent */ -static gint +static int lua_tcp_request(lua_State *L) { LUA_TRACE_POINT; - const gchar *host; - gchar *stop_pattern = NULL; - guint port; - gint cbref, tp, conn_cbref = -1; + const char *host; + char *stop_pattern = NULL; + unsigned int port; + int cbref, tp, conn_cbref = -1; gsize plen = 0; struct ev_loop *event_loop = NULL; struct lua_tcp_cbdata *cbd; @@ -1538,9 +1538,9 @@ lua_tcp_request(lua_State *L) struct rspamd_config *cfg = NULL; struct iovec *iov = NULL; struct upstream *up = NULL; - guint niov = 0, total_out; + unsigned int niov = 0, total_out; uint64_t h; - gdouble timeout = default_tcp_timeout; + double timeout = default_tcp_timeout; gboolean partial = FALSE, do_shutdown = FALSE, do_read = TRUE, ssl = FALSE, ssl_noverify = FALSE; @@ -1639,7 +1639,7 @@ lua_tcp_request(lua_State *L) lua_pushstring(L, "stop_pattern"); lua_gettable(L, -2); if (lua_type(L, -1) == LUA_TSTRING) { - const gchar *p; + const char *p; p = lua_tolstring(L, -1, &plen); @@ -1967,16 +1967,16 @@ lua_tcp_request(lua_State *L) * - `timeout`: floating point value that specifies timeout for IO operations in **seconds** * @return {boolean} true if request has been sent */ -static gint +static int lua_tcp_connect_sync(lua_State *L) { LUA_TRACE_POINT; GError *err = NULL; int64_t port = -1; - gdouble timeout = default_tcp_timeout; - const gchar *host = NULL; - gint ret; + double timeout = default_tcp_timeout; + const char *host = NULL; + int ret; uint64_t h; struct rspamd_task *task = NULL; @@ -2021,7 +2021,7 @@ lua_tcp_connect_sync(lua_State *L) cbd = g_new0(struct lua_tcp_cbdata, 1); if (task) { - static const gchar hexdigests[16] = "0123456789abcdef"; + static const char hexdigests[16] = "0123456789abcdef"; cfg = task->cfg; ev_base = task->event_loop; @@ -2055,7 +2055,7 @@ lua_tcp_connect_sync(lua_State *L) cbd->event_loop = ev_base; cbd->flags |= LUA_TCP_FLAG_SYNC; cbd->fd = -1; - cbd->port = (guint16) port; + cbd->port = (uint16_t) port; cbd->in = g_byte_array_new(); @@ -2088,7 +2088,7 @@ lua_tcp_connect_sync(lua_State *L) if (rspamd_parse_inet_address(&cbd->addr, host, strlen(host), RSPAMD_INET_ADDRESS_PARSE_DEFAULT)) { - rspamd_inet_address_set_port(cbd->addr, (guint16) port); + rspamd_inet_address_set_port(cbd->addr, (uint16_t) port); /* Host is numeric IP, no need to resolve */ if (!lua_tcp_make_connection(cbd)) { lua_pushboolean(L, FALSE); @@ -2135,7 +2135,7 @@ lua_tcp_connect_sync(lua_State *L) return lua_thread_yield(cbd->thread, 0); } -static gint +static int lua_tcp_close(lua_State *L) { LUA_TRACE_POINT; @@ -2174,16 +2174,16 @@ lua_tcp_close(lua_State *L) return 0; } -static gint +static int lua_tcp_add_read(lua_State *L) { LUA_TRACE_POINT; struct lua_tcp_cbdata *cbd = lua_check_tcp(L, 1); struct lua_tcp_handler *rh; - gchar *stop_pattern = NULL; - const gchar *p; + char *stop_pattern = NULL; + const char *p; gsize plen = 0; - gint cbref = -1; + int cbref = -1; if (cbd == NULL) { return luaL_error(L, "invalid arguments"); @@ -2215,15 +2215,15 @@ lua_tcp_add_read(lua_State *L) return 0; } -static gint +static int lua_tcp_add_write(lua_State *L) { LUA_TRACE_POINT; struct lua_tcp_cbdata *cbd = lua_check_tcp(L, 1); struct lua_tcp_handler *wh; - gint cbref = -1, tp; + int cbref = -1, tp; struct iovec *iov = NULL; - guint niov = 0, total_out = 0; + unsigned int niov = 0, total_out = 0; if (cbd == NULL) { return luaL_error(L, "invalid arguments"); @@ -2299,7 +2299,7 @@ lua_tcp_add_write(lua_State *L) return 1; } -static gint +static int lua_tcp_shift_callback(lua_State *L) { LUA_TRACE_POINT; @@ -2316,7 +2316,7 @@ lua_tcp_shift_callback(lua_State *L) } static struct lua_tcp_cbdata * -lua_check_sync_tcp(lua_State *L, gint pos) +lua_check_sync_tcp(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_tcp_sync_classname); luaL_argcheck(L, ud != NULL, pos, "'tcp' expected"); @@ -2396,9 +2396,9 @@ lua_tcp_sync_write(lua_State *L) LUA_TRACE_POINT; struct lua_tcp_cbdata *cbd = lua_check_sync_tcp(L, 1); struct lua_tcp_handler *wh; - gint tp; + int tp; struct iovec *iov = NULL; - guint niov = 0; + unsigned int niov = 0; gsize total_out = 0; if (cbd == NULL) { @@ -2471,7 +2471,7 @@ lua_tcp_sync_write(lua_State *L) return lua_thread_yield(thread, 0); } -static gint +static int lua_tcp_sync_eof(lua_State *L) { LUA_TRACE_POINT; @@ -2485,7 +2485,7 @@ lua_tcp_sync_eof(lua_State *L) return 1; } -static gint +static int lua_tcp_sync_shutdown(lua_State *L) { LUA_TRACE_POINT; @@ -2499,7 +2499,7 @@ lua_tcp_sync_shutdown(lua_State *L) return 0; } -static gint +static int lua_tcp_starttls(lua_State *L) { LUA_TRACE_POINT; @@ -2534,7 +2534,7 @@ lua_tcp_starttls(lua_State *L) return 0; } -static gint +static int lua_tcp_sync_gc(lua_State *L) { struct lua_tcp_cbdata *cbd = lua_check_sync_tcp(L, 1); @@ -2548,7 +2548,7 @@ lua_tcp_sync_gc(lua_State *L) return 0; } -static gint +static int lua_load_tcp(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_tensor.c b/src/lua/lua_tensor.c index d4ee3dcca..fef1576e3 100644 --- a/src/lua/lua_tensor.c +++ b/src/lua/lua_tensor.c @@ -78,7 +78,7 @@ lua_newtensor(lua_State *L, int ndims, const int *dim, bool zero_fill, bool own) res->ndims = ndims; res->size = 1; - for (guint i = 0; i < ndims; i++) { + for (unsigned int i = 0; i < ndims; i++) { res->size *= dim[i]; res->dim[i] = dim[i]; } @@ -106,15 +106,15 @@ lua_newtensor(lua_State *L, int ndims, const int *dim, bool zero_fill, bool own) * Creates a new zero filled tensor with the specific number of dimensions * @return */ -static gint +static int lua_tensor_new(lua_State *L) { - gint ndims = luaL_checkinteger(L, 1); + int ndims = luaL_checkinteger(L, 1); if (ndims > 0 && ndims <= 2) { - gint *dims = g_alloca(sizeof(gint) * ndims); + int *dims = g_alloca(sizeof(int) * ndims); - for (guint i = 0; i < ndims; i++) { + for (unsigned int i = 0; i < ndims; i++) { dims[i] = lua_tointeger(L, i + 2); } @@ -132,7 +132,7 @@ lua_tensor_new(lua_State *L) * Creates a new zero filled tensor with the specific number of dimensions * @return */ -static gint +static int lua_tensor_fromtable(lua_State *L) { if (lua_istable(L, 1)) { @@ -141,14 +141,14 @@ lua_tensor_fromtable(lua_State *L) if (lua_isnumber(L, -1)) { lua_pop(L, 1); /* Input vector */ - gint dims[2]; + int dims[2]; dims[0] = 1; dims[1] = rspamd_lua_table_size(L, 1); struct rspamd_lua_tensor *res = lua_newtensor(L, 2, dims, false, true); - for (guint i = 0; i < dims[1]; i++) { + for (unsigned int i = 0; i < dims[1]; i++) { lua_rawgeti(L, 1, i + 1); res->data[i] = lua_tonumber(L, -1); lua_pop(L, 1); @@ -159,10 +159,10 @@ lua_tensor_fromtable(lua_State *L) lua_pop(L, 1); /* Calculate the overall size */ - gint nrows = rspamd_lua_table_size(L, 1), ncols = 0; - gint err; + int nrows = rspamd_lua_table_size(L, 1), ncols = 0; + int err; - for (gint i = 0; i < nrows; i++) { + for (int i = 0; i < nrows; i++) { lua_rawgeti(L, 1, i + 1); if (ncols == 0) { @@ -180,7 +180,7 @@ lua_tensor_fromtable(lua_State *L) } else { if (ncols != rspamd_lua_table_size(L, -1)) { - gint t = rspamd_lua_table_size(L, -1); + int t = rspamd_lua_table_size(L, -1); lua_pop(L, 1); err = luaL_error(L, "invalid params at pos %d: " @@ -196,17 +196,17 @@ lua_tensor_fromtable(lua_State *L) lua_pop(L, 1); } - gint dims[2]; + int dims[2]; dims[0] = nrows; dims[1] = ncols; struct rspamd_lua_tensor *res = lua_newtensor(L, 2, dims, false, true); - for (gint i = 0; i < nrows; i++) { + for (int i = 0; i < nrows; i++) { lua_rawgeti(L, 1, i + 1); - for (gint j = 0; j < ncols; j++) { + for (int j = 0; j < ncols; j++) { lua_rawgeti(L, -1, j + 1); res->data[i * ncols + j] = lua_tonumber(L, -1); @@ -235,7 +235,7 @@ lua_tensor_fromtable(lua_State *L) * Tensor destructor * @return */ -static gint +static int lua_tensor_destroy(lua_State *L) { struct rspamd_lua_tensor *t = lua_check_tensor(L, 1); @@ -254,11 +254,11 @@ lua_tensor_destroy(lua_State *L) * Tensor serialisation function * @return */ -static gint +static int lua_tensor_save(lua_State *L) { struct rspamd_lua_tensor *t = lua_check_tensor(L, 1); - gint size; + int size; if (t) { if (t->size > 0) { @@ -268,8 +268,8 @@ lua_tensor_save(lua_State *L) size = -(t->size); } - gsize sz = sizeof(gint) * 4 + size * sizeof(rspamd_tensor_num_t); - guchar *data; + gsize sz = sizeof(int) * 4 + size * sizeof(rspamd_tensor_num_t); + unsigned char *data; struct rspamd_lua_text *out = lua_new_text(L, NULL, 0, TRUE); @@ -280,7 +280,7 @@ lua_tensor_save(lua_State *L) memcpy(data + 4 * sizeof(int), t->data, size * sizeof(rspamd_tensor_num_t)); - out->start = (const gchar *) data; + out->start = (const char *) data; out->len = sz; } else { @@ -290,7 +290,7 @@ lua_tensor_save(lua_State *L) return 1; } -static gint +static int lua_tensor_tostring(lua_State *L) { struct rspamd_lua_tensor *t = lua_check_tensor(L, 1); @@ -300,15 +300,15 @@ lua_tensor_tostring(lua_State *L) if (t->ndims == 1) { /* Print as a vector */ - for (gint i = 0; i < t->dim[0]; i++) { + for (int i = 0; i < t->dim[0]; i++) { rspamd_printf_gstring(out, "%.4f ", t->data[i]); } /* Trim last space */ out->len--; } else { - for (gint i = 0; i < t->dim[0]; i++) { - for (gint j = 0; j < t->dim[1]; j++) { + for (int i = 0; i < t->dim[0]; i++) { + for (int j = 0; j < t->dim[1]; j++) { rspamd_printf_gstring(out, "%.4f ", t->data[i * t->dim[1] + j]); } @@ -331,11 +331,11 @@ lua_tensor_tostring(lua_State *L) return 1; } -static gint +static int lua_tensor_index(lua_State *L) { struct rspamd_lua_tensor *t = lua_check_tensor(L, 1); - gint idx; + int idx; if (t) { if (lua_isnumber(L, 2)) { @@ -352,7 +352,7 @@ lua_tensor_index(lua_State *L) } else { /* Push row */ - gint dim = t->dim[1]; + int dim = t->dim[1]; if (idx <= t->dim[0]) { @@ -376,11 +376,11 @@ lua_tensor_index(lua_State *L) return 1; } -static gint +static int lua_tensor_newindex(lua_State *L) { struct rspamd_lua_tensor *t = lua_check_tensor(L, 1); - gint idx; + int idx; if (t) { if (lua_isnumber(L, 2)) { @@ -451,7 +451,7 @@ lua_tensor_newindex(lua_State *L) * Multiply two tensors (optionally transposed) and return a new tensor * @return */ -static gint +static int lua_tensor_mul(lua_State *L) { struct rspamd_lua_tensor *t1 = lua_check_tensor(L, 1), @@ -467,7 +467,7 @@ lua_tensor_mul(lua_State *L) } if (t1 && t2) { - gint dims[2], shadow_dims[2]; + int dims[2], shadow_dims[2]; dims[0] = abs(transA ? t1->dim[1] : t1->dim[0]); shadow_dims[0] = abs(transB ? t2->dim[1] : t2->dim[0]); dims[1] = abs(transB ? t2->dim[0] : t2->dim[1]); @@ -517,10 +517,10 @@ lua_tensor_mul(lua_State *L) * Deserialize tensor * @return */ -static gint +static int lua_tensor_load(lua_State *L) { - const guchar *data; + const unsigned char *data; gsize sz; if (lua_type(L, 1) == LUA_TUSERDATA) { @@ -530,14 +530,14 @@ lua_tensor_load(lua_State *L) return luaL_error(L, "invalid argument"); } - data = (const guchar *) t->start; + data = (const unsigned char *) t->start; sz = t->len; } else { - data = (const guchar *) lua_tolstring(L, 1, &sz); + data = (const unsigned char *) lua_tolstring(L, 1, &sz); } - if (sz >= sizeof(gint) * 4) { + if (sz >= sizeof(int) * 4) { int ndims, nelts, dims[2]; memcpy(&ndims, data, sizeof(int)); @@ -582,11 +582,11 @@ lua_tensor_load(lua_State *L) return 1; } -static gint +static int lua_tensor_len(lua_State *L) { struct rspamd_lua_tensor *t = lua_check_tensor(L, 1); - gint nret = 1; + int nret = 1; if (t) { /* Return the main dimension first */ @@ -606,7 +606,7 @@ lua_tensor_len(lua_State *L) return nret; } -static gint +static int lua_tensor_eigen(lua_State *L) { struct rspamd_lua_tensor *t = lua_check_tensor(L, 1), *eigen; @@ -638,7 +638,7 @@ mean_vec(rspamd_tensor_num_t *x, gsize n) return sum / (rspamd_tensor_num_t) n; } -static gint +static int lua_tensor_mean(lua_State *L) { struct rspamd_lua_tensor *t = lua_check_tensor(L, 1); @@ -666,7 +666,7 @@ lua_tensor_mean(lua_State *L) return 1; } -static gint +static int lua_tensor_transpose(lua_State *L) { struct rspamd_lua_tensor *t = lua_check_tensor(L, 1), *res; @@ -707,7 +707,7 @@ lua_tensor_transpose(lua_State *L) return 1; } -static gint +static int lua_tensor_has_blas(lua_State *L) { #ifdef HAVE_CBLAS @@ -719,7 +719,7 @@ lua_tensor_has_blas(lua_State *L) return 1; } -static gint +static int lua_tensor_scatter_matrix(lua_State *L) { struct rspamd_lua_tensor *t = lua_check_tensor(L, 1), *res; @@ -789,7 +789,7 @@ lua_tensor_scatter_matrix(lua_State *L) return 1; } -static gint +static int lua_load_tensor(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_text.c b/src/lua/lua_text.c index 92dfadce6..4478314f1 100644 --- a/src/lua/lua_text.c +++ b/src/lua/lua_text.c @@ -268,7 +268,7 @@ static const struct luaL_reg textlib_m[] = { {NULL, NULL}}; struct rspamd_lua_text * -lua_check_text(lua_State *L, gint pos) +lua_check_text(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_text_classname); luaL_argcheck(L, ud != NULL, pos, "'text' expected"); @@ -276,9 +276,9 @@ lua_check_text(lua_State *L, gint pos) } struct rspamd_lua_text * -lua_check_text_or_string(lua_State *L, gint pos) +lua_check_text_or_string(lua_State *L, int pos) { - gint pos_type = lua_type(L, pos); + int pos_type = lua_type(L, pos); if (pos_type == LUA_TUSERDATA) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_text_classname); @@ -312,7 +312,7 @@ lua_check_text_or_string(lua_State *L, gint pos) } struct rspamd_lua_text * -lua_new_text(lua_State *L, const gchar *start, gsize len, gboolean own) +lua_new_text(lua_State *L, const char *start, gsize len, gboolean own) { struct rspamd_lua_text *t; @@ -320,7 +320,7 @@ lua_new_text(lua_State *L, const gchar *start, gsize len, gboolean own) t->flags = 0; if (own) { - gchar *storage; + char *storage; if (len > 0) { storage = g_malloc(len); @@ -348,7 +348,7 @@ lua_new_text(lua_State *L, const gchar *start, gsize len, gboolean own) struct rspamd_lua_text * lua_new_text_task(lua_State *L, struct rspamd_task *task, - const gchar *start, gsize len, gboolean own) + const char *start, gsize len, gboolean own) { struct rspamd_lua_text *t; @@ -356,7 +356,7 @@ lua_new_text_task(lua_State *L, struct rspamd_task *task, t->flags = 0; if (own) { - gchar *storage; + char *storage; if (len > 0) { storage = rspamd_mempool_alloc(task->task_pool, len); @@ -398,11 +398,11 @@ bool lua_is_text_binary(struct rspamd_lua_text *t) } -static gint +static int lua_text_fromstring(lua_State *L) { LUA_TRACE_POINT; - const gchar *str; + const char *str; gsize l = 0; gboolean transparent = FALSE; @@ -423,7 +423,7 @@ lua_text_fromstring(lua_State *L) return 1; } -static gint +static int lua_text_null(lua_State *L) { LUA_TRACE_POINT; @@ -433,11 +433,11 @@ lua_text_null(lua_State *L) return 1; } -static gint +static int lua_text_randombytes(lua_State *L) { LUA_TRACE_POINT; - guint nbytes = luaL_checkinteger(L, 1); + unsigned int nbytes = luaL_checkinteger(L, 1); struct rspamd_lua_text *out; out = lua_new_text(L, NULL, nbytes, TRUE); @@ -450,7 +450,7 @@ lua_text_randombytes(lua_State *L) #define MAX_REC 10 static void -lua_text_tbl_length(lua_State *L, gsize dlen, gsize *dest, guint rec) +lua_text_tbl_length(lua_State *L, gsize dlen, gsize *dest, unsigned int rec) { gsize tblen, stlen; struct rspamd_lua_text *elt; @@ -495,12 +495,12 @@ lua_text_tbl_length(lua_State *L, gsize dlen, gsize *dest, guint rec) static void lua_text_tbl_append(lua_State *L, - const gchar *delim, + const char *delim, gsize dlen, - gchar **dest, - guint rec) + char **dest, + unsigned int rec) { - const gchar *st; + const char *st; gsize tblen, stlen; struct rspamd_lua_text *elt; @@ -512,7 +512,7 @@ lua_text_tbl_append(lua_State *L, tblen = rspamd_lua_table_size(L, -1); - for (guint i = 0; i < tblen; i++) { + for (unsigned int i = 0; i < tblen; i++) { lua_rawgeti(L, -1, i + 1); if (lua_type(L, -1) == LUA_TSTRING) { @@ -541,14 +541,14 @@ lua_text_tbl_append(lua_State *L, } } -static gint +static int lua_text_fromtable(lua_State *L) { LUA_TRACE_POINT; - const gchar *delim = ""; + const char *delim = ""; struct rspamd_lua_text *t; gsize textlen = 0, dlen, oldtop = lua_gettop(L); - gchar *dest; + char *dest; if (!lua_istable(L, 1)) { return luaL_error(L, "invalid arguments"); @@ -578,13 +578,13 @@ lua_text_fromtable(lua_State *L) lua_text_tbl_append(L, delim, dlen, &dest, 0); lua_pop(L, 1); /* Table arg */ - gint newtop = lua_gettop(L); + int newtop = lua_gettop(L); g_assert(newtop == oldtop + 1); return 1; } -static gint +static int lua_text_len(lua_State *L) { LUA_TRACE_POINT; @@ -603,7 +603,7 @@ lua_text_len(lua_State *L) return 1; } -static gint +static int lua_text_str(lua_State *L) { LUA_TRACE_POINT; @@ -619,7 +619,7 @@ lua_text_str(lua_State *L) return 1; } -static gint +static int lua_text_ptr(lua_State *L) { LUA_TRACE_POINT; @@ -635,12 +635,12 @@ lua_text_ptr(lua_State *L) return 1; } -static gint +static int lua_text_take_ownership(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t = lua_check_text(L, 1); - gchar *dest; + char *dest; if (t != NULL) { if (t->flags & RSPAMD_TEXT_FLAG_OWN) { @@ -662,7 +662,7 @@ lua_text_take_ownership(lua_State *L) return 1; } -static gint +static int lua_text_span(lua_State *L) { LUA_TRACE_POINT; @@ -700,7 +700,7 @@ lua_text_span(lua_State *L) /* Helpers to behave exactly as Lua does */ static inline gsize -relative_pos_start(gint pos, gsize len) +relative_pos_start(int pos, gsize len) { if (pos > 0) { return pos; @@ -708,7 +708,7 @@ relative_pos_start(gint pos, gsize len) else if (pos == 0) { return 1; } - else if (pos < -((gint) len)) { + else if (pos < -((int) len)) { return 1; } @@ -717,22 +717,22 @@ relative_pos_start(gint pos, gsize len) } static inline gsize -relative_pos_end(gint pos, gsize len) +relative_pos_end(int pos, gsize len) { - if (pos > (gint) len) { + if (pos > (int) len) { return len; } else if (pos >= 0) { return (size_t) pos; } - else if (pos < -((gint) len)) { + else if (pos < -((int) len)) { return 0; } return len + ((gsize) pos) + 1; } -static gint +static int lua_text_sub(lua_State *L) { LUA_TRACE_POINT; @@ -764,10 +764,10 @@ static int64_t rspamd_lua_text_push_line(lua_State *L, struct rspamd_lua_text *t, int64_t start_offset, - const gchar *sep_pos, + const char *sep_pos, gboolean stringify) { - const gchar *start; + const char *start; gsize len; int64_t ret; @@ -801,7 +801,7 @@ rspamd_lua_text_push_line(lua_State *L, return ret; } -static gint +static int rspamd_lua_text_readline(lua_State *L) { struct rspamd_lua_text *t = lua_touserdata(L, lua_upvalueindex(1)); @@ -809,7 +809,7 @@ rspamd_lua_text_readline(lua_State *L) int64_t pos = lua_tointeger(L, lua_upvalueindex(3)); if (pos < 0) { - return luaL_error(L, "invalid pos: %d", (gint) pos); + return luaL_error(L, "invalid pos: %d", (int) pos); } if (pos >= t->len) { @@ -817,7 +817,7 @@ rspamd_lua_text_readline(lua_State *L) return 0; } - const gchar *sep_pos; + const char *sep_pos; /* We look just for `\n` ignoring `\r` as it is very rare nowadays */ sep_pos = memchr(t->start + pos, '\n', t->len - pos); @@ -846,7 +846,7 @@ rspamd_lua_text_readline(lua_State *L) return 1; } -static gint +static int lua_text_lines(lua_State *L) { LUA_TRACE_POINT; @@ -870,7 +870,7 @@ lua_text_lines(lua_State *L) return 1; } -static gint +static int rspamd_lua_text_regexp_split(lua_State *L) { struct rspamd_lua_text *t = lua_touserdata(L, lua_upvalueindex(1)), @@ -882,7 +882,7 @@ rspamd_lua_text_regexp_split(lua_State *L) gboolean matched; if (pos < 0) { - return luaL_error(L, "invalid pos: %d", (gint) pos); + return luaL_error(L, "invalid pos: %d", (int) pos); } if (pos >= t->len) { @@ -890,7 +890,7 @@ rspamd_lua_text_regexp_split(lua_State *L) return 0; } - const gchar *start, *end, *old_start; + const char *start, *end, *old_start; end = t->start + pos; @@ -963,7 +963,7 @@ rspamd_lua_text_regexp_split(lua_State *L) return 1; } -static gint +static int lua_text_split(lua_State *L) { LUA_TRACE_POINT; @@ -985,9 +985,9 @@ lua_text_split(lua_State *L) c_re = rspamd_regexp_new(lua_tostring(L, 2), NULL, &err); if (c_re == NULL) { - gint ret = luaL_error(L, "cannot parse regexp: %s, error: %s", - lua_tostring(L, 2), - err == NULL ? "undefined" : err->message); + int ret = luaL_error(L, "cannot parse regexp: %s, error: %s", + lua_tostring(L, 2), + err == NULL ? "undefined" : err->message); if (err) { g_error_free(err); } @@ -1032,13 +1032,13 @@ lua_text_split(lua_State *L) } -static gint +static int lua_text_at(lua_State *L) { return lua_text_byte(L); } -static gint +static int lua_text_byte(lua_State *L) { LUA_TRACE_POINT; @@ -1061,7 +1061,7 @@ lua_text_byte(lua_State *L) return end - start; } -static gint +static int lua_text_memchr(lua_State *L) { LUA_TRACE_POINT; @@ -1074,7 +1074,7 @@ lua_text_memchr(lua_State *L) } else { gsize l; - const gchar *str = lua_tolstring(L, 2, &l); + const char *str = lua_tolstring(L, 2, &l); if (str) { c = str[0]; @@ -1116,7 +1116,7 @@ lua_text_memchr(lua_State *L) return 1; } -static gint +static int lua_text_bytes(lua_State *L) { LUA_TRACE_POINT; @@ -1126,7 +1126,7 @@ lua_text_bytes(lua_State *L) lua_createtable(L, t->len, 0); for (gsize i = 0; i < t->len; i++) { - lua_pushinteger(L, (guchar) t->start[i]); + lua_pushinteger(L, (unsigned char) t->start[i]); lua_rawseti(L, -2, i + 1); } } @@ -1137,14 +1137,14 @@ lua_text_bytes(lua_State *L) return 1; } -static gint +static int lua_text_save_in_file(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t = lua_check_text(L, 1); - const gchar *fname = NULL; - guint mode = 00644; - gint fd = -1; + const char *fname = NULL; + unsigned int mode = 00644; + int fd = -1; gboolean need_close = FALSE; if (t != NULL) { @@ -1201,7 +1201,7 @@ lua_text_save_in_file(lua_State *L) return 1; } -static gint +static int lua_text_gc(lua_State *L) { LUA_TRACE_POINT; @@ -1212,7 +1212,7 @@ lua_text_gc(lua_State *L) if (t->flags & RSPAMD_TEXT_FLAG_OWN) { if (t->flags & RSPAMD_TEXT_FLAG_WIPE) { - rspamd_explicit_memzero((guchar *) t->start, t->len); + rspamd_explicit_memzero((unsigned char *) t->start, t->len); } if (t->flags & RSPAMD_TEXT_FLAG_MMAPED) { @@ -1232,7 +1232,7 @@ lua_text_gc(lua_State *L) return 0; } -static gint +static int lua_text_eq(lua_State *L) { LUA_TRACE_POINT; @@ -1249,7 +1249,7 @@ lua_text_eq(lua_State *L) return 1; } -static gint +static int lua_text_lt(lua_State *L) { LUA_TRACE_POINT; @@ -1268,7 +1268,7 @@ lua_text_lt(lua_State *L) return 1; } -static gint +static int lua_text_concat(lua_State *L) { LUA_TRACE_POINT; @@ -1286,7 +1286,7 @@ lua_text_concat(lua_State *L) return 1; } -static gint +static int lua_text_wipe(lua_State *L) { LUA_TRACE_POINT; @@ -1294,7 +1294,7 @@ lua_text_wipe(lua_State *L) if (t != NULL) { if (t->flags & RSPAMD_TEXT_FLAG_OWN) { - rspamd_explicit_memzero((guchar *) t->start, t->len); + rspamd_explicit_memzero((unsigned char *) t->start, t->len); } else { return luaL_error(L, "cannot wipe not owned text"); @@ -1307,7 +1307,7 @@ lua_text_wipe(lua_State *L) return 0; } -static gint +static int lua_text_base32(lua_State *L) { LUA_TRACE_POINT; @@ -1324,7 +1324,7 @@ lua_text_base32(lua_State *L) } out = lua_new_text(L, NULL, t->len * 8 / 5 + 2, TRUE); - out->len = rspamd_encode_base32_buf(t->start, t->len, (gchar *) out->start, + out->len = rspamd_encode_base32_buf(t->start, t->len, (char *) out->start, out->len, btype); } else { @@ -1334,7 +1334,7 @@ lua_text_base32(lua_State *L) return 1; } -static gint +static int lua_text_base64(lua_State *L) { LUA_TRACE_POINT; @@ -1354,7 +1354,7 @@ lua_text_base64(lua_State *L) enum rspamd_newlines_type how = RSPAMD_TASK_NEWLINES_CRLF; if (lua_type(L, 3) == LUA_TSTRING) { - const gchar *how_str = lua_tostring(L, 3); + const char *how_str = lua_tostring(L, 3); if (g_ascii_strcasecmp(how_str, "cr") == 0) { how = RSPAMD_TASK_NEWLINES_CR; @@ -1387,7 +1387,7 @@ lua_text_base64(lua_State *L) return 1; } -static gint +static int lua_text_hex(lua_State *L) { LUA_TRACE_POINT; @@ -1396,7 +1396,7 @@ lua_text_hex(lua_State *L) if (t != NULL) { out = lua_new_text(L, NULL, t->len * 2, TRUE); - out->len = rspamd_encode_hex_buf(t->start, t->len, (gchar *) out->start, + out->len = rspamd_encode_hex_buf(t->start, t->len, (char *) out->start, out->len); } else { @@ -1406,13 +1406,13 @@ lua_text_hex(lua_State *L) return 1; } -static gint +static int lua_text_find(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t = lua_check_text(L, 1); gsize patlen, init = 1; - const gchar *pat = luaL_checklstring(L, 2, &patlen); + const char *pat = luaL_checklstring(L, 2, &patlen); if (t != NULL && pat != NULL) { @@ -1449,17 +1449,17 @@ lua_text_find(lua_State *L) #define BITOP(a, b, op) \ ((a)[(uint64_t) (b) / (8u * sizeof *(a))] op(uint64_t) 1 << ((uint64_t) (b) % (8u * sizeof *(a)))) -static gint +static int lua_text_exclude_chars(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t = lua_check_text(L, 1); gssize patlen; - const gchar *pat = lua_tolstring(L, 2, &patlen), *p, *end; - gchar *dest, *d; + const char *pat = lua_tolstring(L, 2, &patlen), *p, *end; + char *dest, *d; uint64_t byteset[32 / sizeof(uint64_t)]; /* Bitset for ascii */ gboolean copy = TRUE; - guint *plen; + unsigned int *plen; if (t != NULL && pat && patlen > 0) { if (lua_isboolean(L, 3)) { @@ -1470,7 +1470,7 @@ lua_text_exclude_chars(lua_State *L) } if (!copy) { - dest = (gchar *) t->start; + dest = (char *) t->start; plen = &t->len; lua_pushvalue(L, 1); /* Push text as a result */ } @@ -1503,7 +1503,7 @@ lua_text_exclude_chars(lua_State *L) */ switch (*pat) { case '%': - BITOP(byteset, *(guchar *) pat, |=); + BITOP(byteset, *(unsigned char *) pat, |=); break; case 's': /* "\r\n\t\f " */ @@ -1528,17 +1528,17 @@ lua_text_exclude_chars(lua_State *L) } else { /* Last '%' */ - BITOP(byteset, (guchar) '%', |=); + BITOP(byteset, (unsigned char) '%', |=); } } else { - BITOP(byteset, *(guchar *) pat, |=); + BITOP(byteset, *(unsigned char *) pat, |=); } pat++; patlen--; } - for (; patlen > 0 && BITOP(byteset, *(guchar *) pat, |=); pat++, patlen--) + for (; patlen > 0 && BITOP(byteset, *(unsigned char *) pat, |=); pat++, patlen--) ; p = t->start; @@ -1546,7 +1546,7 @@ lua_text_exclude_chars(lua_State *L) d = dest; while (p < end) { - if (!BITOP(byteset, *(guchar *) p, &)) { + if (!BITOP(byteset, *(unsigned char *) p, &)) { *d++ = *p; } @@ -1562,16 +1562,16 @@ lua_text_exclude_chars(lua_State *L) return 1; } -static gint +static int lua_text_oneline(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t = lua_check_text(L, 1); - const gchar *p, *end; - gchar *dest, *d; + const char *p, *end; + char *dest, *d; uint64_t byteset[32 / sizeof(uint64_t)]; /* Bitset for ascii */ gboolean copy = TRUE, seen_8bit = FALSE; - guint *plen; + unsigned int *plen; if (t != NULL) { if (lua_isboolean(L, 2)) { @@ -1582,7 +1582,7 @@ lua_text_oneline(lua_State *L) } if (!copy) { - dest = (gchar *) t->start; + dest = (char *) t->start; plen = &t->len; lua_pushvalue(L, 1); /* Push text as a result */ } @@ -1617,11 +1617,11 @@ lua_text_oneline(lua_State *L) d = dest; while (p < end) { - if (!BITOP(byteset, *(guchar *) p, &)) { + if (!BITOP(byteset, *(unsigned char *) p, &)) { *d++ = *p; } else { - if ((*(guchar *) p) & 0x80) { + if ((*(unsigned char *) p) & 0x80) { seen_8bit = TRUE; *d++ = *p; } @@ -1665,10 +1665,10 @@ lua_text_oneline(lua_State *L) UChar32 uc; goffset err_offset; gsize remain = d - dest; - gchar *nd = dest; + char *nd = dest; while (remain > 0 && (err_offset = rspamd_fast_utf8_validate(nd, remain)) > 0) { - gint i = 0; + int i = 0; err_offset--; /* As it returns it 1 indexed */ nd += err_offset; @@ -1676,7 +1676,7 @@ lua_text_oneline(lua_State *L) /* Each invalid character of input requires 3 bytes of output (+2 bytes) */ while (i < remain) { - gint old_pos = i; + int old_pos = i; U8_NEXT(nd, i, remain, uc); if (uc < 0) { @@ -1702,7 +1702,7 @@ lua_text_oneline(lua_State *L) return 1; } -static gint +static int lua_text_lower(lua_State *L) { LUA_TRACE_POINT; @@ -1726,10 +1726,10 @@ lua_text_lower(lua_State *L) } if (!is_utf8) { - rspamd_str_lc((gchar *) nt->start, nt->len); + rspamd_str_lc((char *) nt->start, nt->len); } else { - rspamd_str_lc_utf8((gchar *) nt->start, nt->len); + rspamd_str_lc_utf8((char *) nt->start, nt->len); } } else { @@ -1739,7 +1739,7 @@ lua_text_lower(lua_State *L) return 1; } -static gint +static int lua_text_strtoul(lua_State *L) { LUA_TRACE_POINT; @@ -1763,9 +1763,9 @@ lua_text_strtoul(lua_State *L) } /* Used to distinguish lua text metatable */ -static const guint rspamd_lua_text_cookie = 0x2b21ef6fU; +static const unsigned int rspamd_lua_text_cookie = 0x2b21ef6fU; -static gint +static int lua_load_text(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_thread_pool.cxx b/src/lua/lua_thread_pool.cxx index 295f33d07..e1eabe60b 100644 --- a/src/lua/lua_thread_pool.cxx +++ b/src/lua/lua_thread_pool.cxx @@ -37,11 +37,11 @@ static void thread_entry_free(lua_State *L, struct thread_entry *ent); struct lua_thread_pool { std::vector<struct thread_entry *> available_items; lua_State *L; - gint max_items; + int max_items; struct thread_entry *running_entry; static const int default_max_items = 100; - lua_thread_pool(lua_State *L, gint max_items = default_max_items) + lua_thread_pool(lua_State *L, int max_items = default_max_items) : L(L), max_items(max_items) { running_entry = nullptr; @@ -77,7 +77,7 @@ struct lua_thread_pool { return ent; } - auto return_thread(struct thread_entry *thread_entry, const gchar *loc) -> void + auto return_thread(struct thread_entry *thread_entry, const char *loc) -> void { /* we can't return a running/yielded thread into the pool */ g_assert(lua_status(thread_entry->lua_state) == 0); @@ -108,7 +108,7 @@ struct lua_thread_pool { } auto terminate_thread(struct thread_entry *thread_entry, - const gchar *loc, + const char *loc, bool enforce) -> void { struct thread_entry *ent = NULL; @@ -197,13 +197,13 @@ lua_thread_pool_get_for_config(struct rspamd_config *cfg) } void lua_thread_pool_return_full(struct lua_thread_pool *pool, - struct thread_entry *thread_entry, const gchar *loc) + struct thread_entry *thread_entry, const char *loc) { pool->return_thread(thread_entry, loc); } void lua_thread_pool_terminate_entry_full(struct lua_thread_pool *pool, - struct thread_entry *thread_entry, const gchar *loc, + struct thread_entry *thread_entry, const char *loc, bool enforce) { pool->terminate_thread(thread_entry, loc, enforce); @@ -211,7 +211,7 @@ void lua_thread_pool_terminate_entry_full(struct lua_thread_pool *pool, struct thread_entry * lua_thread_pool_get_running_entry_full(struct lua_thread_pool *pool, - const gchar *loc) + const char *loc) { msg_debug_lua_threads("%s: lua_thread_pool_get_running_entry_full", loc); return pool->get_running_entry(); @@ -219,7 +219,7 @@ lua_thread_pool_get_running_entry_full(struct lua_thread_pool *pool, void lua_thread_pool_set_running_entry_full(struct lua_thread_pool *pool, struct thread_entry *thread_entry, - const gchar *loc) + const char *loc) { msg_debug_lua_threads("%s: lua_thread_pool_set_running_entry_full", loc); pool->set_running_entry(thread_entry); @@ -227,7 +227,7 @@ void lua_thread_pool_set_running_entry_full(struct lua_thread_pool *pool, static void lua_thread_pool_set_running_entry_for_thread(struct thread_entry *thread_entry, - const gchar *loc) + const char *loc) { struct lua_thread_pool *pool; @@ -243,7 +243,7 @@ lua_thread_pool_set_running_entry_for_thread(struct thread_entry *thread_entry, void lua_thread_pool_prepare_callback_full(struct lua_thread_pool *pool, struct lua_callback_state *cbs, - const gchar *loc) + const char *loc) { msg_debug_lua_threads("%s: lua_thread_pool_prepare_callback_full", loc); cbs->thread_pool = pool; @@ -253,15 +253,15 @@ void lua_thread_pool_prepare_callback_full(struct lua_thread_pool *pool, } void lua_thread_pool_restore_callback_full(struct lua_callback_state *cbs, - const gchar *loc) + const char *loc) { lua_thread_pool_return_full(cbs->thread_pool, cbs->my_thread, loc); lua_thread_pool_set_running_entry_full(cbs->thread_pool, cbs->previous_thread, loc); } -static gint -lua_do_resume_full(lua_State *L, gint narg, const gchar *loc) +static int +lua_do_resume_full(lua_State *L, int narg, const char *loc) { #if LUA_VERSION_NUM >= 504 int nres; @@ -280,9 +280,9 @@ lua_do_resume_full(lua_State *L, gint narg, const gchar *loc) static void lua_resume_thread_internal_full(struct thread_entry *thread_entry, - gint narg, const gchar *loc) + int narg, const char *loc) { - gint ret; + int ret; struct lua_thread_pool *pool; struct rspamd_task *task; @@ -335,8 +335,8 @@ lua_resume_thread_internal_full(struct thread_entry *thread_entry, } } -void lua_thread_resume_full(struct thread_entry *thread_entry, gint narg, - const gchar *loc) +void lua_thread_resume_full(struct thread_entry *thread_entry, int narg, + const char *loc) { /* * The only state where we can resume from is LUA_YIELD @@ -350,7 +350,7 @@ void lua_thread_resume_full(struct thread_entry *thread_entry, gint narg, } void lua_thread_call_full(struct thread_entry *thread_entry, - int narg, const gchar *loc) + int narg, const char *loc) { g_assert(lua_status(thread_entry->lua_state) == 0); /* we can't call running/yielded thread */ g_assert(thread_entry->task != NULL || thread_entry->cfg != NULL); /* we can't call without pool */ @@ -358,9 +358,9 @@ void lua_thread_call_full(struct thread_entry *thread_entry, lua_resume_thread_internal_full(thread_entry, narg, loc); } -gint lua_thread_yield_full(struct thread_entry *thread_entry, - gint nresults, - const gchar *loc) +int lua_thread_yield_full(struct thread_entry *thread_entry, + int nresults, + const char *loc) { g_assert(lua_status(thread_entry->lua_state) == 0); diff --git a/src/lua/lua_thread_pool.h b/src/lua/lua_thread_pool.h index b612ac3a5..c6ad31847 100644 --- a/src/lua/lua_thread_pool.h +++ b/src/lua/lua_thread_pool.h @@ -16,7 +16,7 @@ typedef void (*lua_thread_error_t)(struct thread_entry *thread, int ret, const c struct thread_entry { lua_State *lua_state; - gint thread_index; + int thread_index; gpointer cd; /* function to handle result of called method, can be NULL */ @@ -82,7 +82,7 @@ lua_thread_pool_get_for_config(struct rspamd_config *cfg); */ void lua_thread_pool_return_full(struct lua_thread_pool *pool, struct thread_entry *thread_entry, - const gchar *loc); + const char *loc); #define lua_thread_pool_return(pool, thread_entry) \ lua_thread_pool_return_full(pool, thread_entry, G_STRLOC) @@ -95,7 +95,7 @@ void lua_thread_pool_return_full(struct lua_thread_pool *pool, */ struct thread_entry * lua_thread_pool_get_running_entry_full(struct lua_thread_pool *pool, - const gchar *loc); + const char *loc); #define lua_thread_pool_get_running_entry(pool) \ lua_thread_pool_get_running_entry_full(pool, G_STRLOC) @@ -108,7 +108,7 @@ lua_thread_pool_get_running_entry_full(struct lua_thread_pool *pool, */ void lua_thread_pool_set_running_entry_full(struct lua_thread_pool *pool, struct thread_entry *thread_entry, - const gchar *loc); + const char *loc); #define lua_thread_pool_set_running_entry(pool, thread_entry) \ lua_thread_pool_set_running_entry_full(pool, thread_entry, G_STRLOC) @@ -120,7 +120,7 @@ void lua_thread_pool_set_running_entry_full(struct lua_thread_pool *pool, * @param cbs */ void lua_thread_pool_prepare_callback_full(struct lua_thread_pool *pool, - struct lua_callback_state *cbs, const gchar *loc); + struct lua_callback_state *cbs, const char *loc); #define lua_thread_pool_prepare_callback(pool, cbs) \ lua_thread_pool_prepare_callback_full(pool, cbs, G_STRLOC) @@ -131,7 +131,7 @@ void lua_thread_pool_prepare_callback_full(struct lua_thread_pool *pool, * @param cbs */ void lua_thread_pool_restore_callback_full(struct lua_callback_state *cbs, - const gchar *loc); + const char *loc); #define lua_thread_pool_restore_callback(cbs) \ lua_thread_pool_restore_callback_full(cbs, G_STRLOC) @@ -145,7 +145,7 @@ void lua_thread_pool_restore_callback_full(struct lua_callback_state *cbs, */ void lua_thread_call_full(struct thread_entry *thread_entry, int narg, - const gchar *loc); + const char *loc); #define lua_thread_call(thread_entry, narg) \ lua_thread_call_full(thread_entry, narg, G_STRLOC) @@ -157,7 +157,7 @@ void lua_thread_call_full(struct thread_entry *thread_entry, * @return */ int lua_thread_yield_full(struct thread_entry *thread_entry, int nresults, - const gchar *loc); + const char *loc); #define lua_thread_yield(thread_entry, narg) \ lua_thread_yield_full(thread_entry, narg, G_STRLOC) @@ -170,7 +170,7 @@ int lua_thread_yield_full(struct thread_entry *thread_entry, int nresults, */ void lua_thread_resume_full(struct thread_entry *thread_entry, int narg, - const gchar *loc); + const char *loc); #define lua_thread_resume(thread_entry, narg) \ lua_thread_resume_full(thread_entry, narg, G_STRLOC) @@ -183,7 +183,7 @@ void lua_thread_resume_full(struct thread_entry *thread_entry, */ void lua_thread_pool_terminate_entry_full(struct lua_thread_pool *pool, struct thread_entry *thread_entry, - const gchar *loc, bool enforce); + const char *loc, bool enforce); #define lua_thread_pool_terminate_entry(pool, thread_entry) \ lua_thread_pool_terminate_entry_full(pool, thread_entry, G_STRLOC, false) diff --git a/src/lua/lua_trie.c b/src/lua/lua_trie.c index 70a685da2..210b089bb 100644 --- a/src/lua/lua_trie.c +++ b/src/lua/lua_trie.c @@ -60,7 +60,7 @@ static const struct luaL_reg trielib_f[] = { {NULL, NULL}}; static struct rspamd_multipattern * -lua_check_trie(lua_State *L, gint idx) +lua_check_trie(lua_State *L, int idx) { void *ud = rspamd_lua_check_udata(L, 1, rspamd_trie_classname); @@ -68,7 +68,7 @@ lua_check_trie(lua_State *L, gint idx) return ud ? *((struct rspamd_multipattern **) ud) : NULL; } -static gint +static int lua_trie_destroy(lua_State *L) { struct rspamd_multipattern *trie = lua_check_trie(L, 1); @@ -86,7 +86,7 @@ lua_trie_destroy(lua_State *L) * * @return {bool} true if hyperscan is supported */ -static gint +static int lua_trie_has_hyperscan(lua_State *L) { lua_pushboolean(L, rspamd_multipattern_has_hyperscan()); @@ -99,11 +99,11 @@ lua_trie_has_hyperscan(lua_State *L) * @param {table} array of string patterns * @return {trie} new trie object */ -static gint +static int lua_trie_create(lua_State *L) { struct rspamd_multipattern *trie, **ptrie; - gint npat = 0, flags = RSPAMD_MULTIPATTERN_ICASE | RSPAMD_MULTIPATTERN_GLOB; + int npat = 0, flags = RSPAMD_MULTIPATTERN_ICASE | RSPAMD_MULTIPATTERN_GLOB; GError *err = NULL; if (lua_isnumber(L, 2)) { @@ -130,7 +130,7 @@ lua_trie_create(lua_State *L) while (lua_next(L, -2) != 0) { if (lua_isstring(L, -1)) { - const gchar *pat; + const char *pat; gsize patlen; pat = lua_tolstring(L, -1, &patlen); @@ -173,17 +173,17 @@ lua_trie_create(lua_State *L) } while (0) /* Normal callback type */ -static gint +static int lua_trie_lua_cb_callback(struct rspamd_multipattern *mp, - guint strnum, - gint match_start, - gint textpos, - const gchar *text, + unsigned int strnum, + int match_start, + int textpos, + const char *text, gsize len, void *context) { lua_State *L = context; - gint ret; + int ret; gboolean report_start = lua_toboolean(L, -1); @@ -208,18 +208,18 @@ lua_trie_lua_cb_callback(struct rspamd_multipattern *mp, } /* Table like callback, expect result table on top of the stack */ -static gint +static int lua_trie_table_callback(struct rspamd_multipattern *mp, - guint strnum, - gint match_start, - gint textpos, - const gchar *text, + unsigned int strnum, + int match_start, + int textpos, + const char *text, gsize len, void *context) { lua_State *L = context; - gint report_start = lua_toboolean(L, -2); + int report_start = lua_toboolean(L, -2); /* Set table, indexed by pattern number */ lua_rawgeti(L, -1, strnum + 1); @@ -247,12 +247,12 @@ lua_trie_table_callback(struct rspamd_multipattern *mp, /* * We assume that callback argument is at pos 3 and icase is in position 4 */ -static gint +static int lua_trie_search_str(lua_State *L, struct rspamd_multipattern *trie, - const gchar *str, gsize len, rspamd_multipattern_cb_t cb) + const char *str, gsize len, rspamd_multipattern_cb_t cb) { - gint ret; - guint nfound = 0; + int ret; + unsigned int nfound = 0; if ((ret = rspamd_multipattern_lookup(trie, str, len, cb, L, &nfound)) == 0) { @@ -270,18 +270,18 @@ lua_trie_search_str(lua_State *L, struct rspamd_multipattern *trie, * @param {boolean} report_start report both start and end offset when matching patterns * @return {boolean} `true` if any pattern has been found (`cb` might be called multiple times however). If `cb` is not defined then it returns a table of match positions indexed by pattern number */ -static gint +static int lua_trie_match(lua_State *L) { LUA_TRACE_POINT; struct rspamd_multipattern *trie = lua_check_trie(L, 1); - const gchar *text; + const char *text; gsize len; gboolean found = FALSE, report_start = FALSE; struct rspamd_lua_text *t; rspamd_multipattern_cb_t cb = lua_trie_lua_cb_callback; - gint old_top = lua_gettop(L); + int old_top = lua_gettop(L); if (trie) { if (lua_type(L, 3) != LUA_TFUNCTION) { @@ -360,14 +360,14 @@ lua_trie_match(lua_State *L) * @param {boolean} caseless if `true` then match ignores symbols case (ASCII only) * @return {boolean} `true` if any pattern has been found (`cb` might be called multiple times however) */ -static gint +static int lua_trie_search_mime(lua_State *L) { LUA_TRACE_POINT; struct rspamd_multipattern *trie = lua_check_trie(L, 1); struct rspamd_task *task = lua_check_task(L, 2); struct rspamd_mime_text_part *part; - const gchar *text; + const char *text; gsize len, i; gboolean found = FALSE; rspamd_multipattern_cb_t cb = lua_trie_lua_cb_callback; @@ -398,13 +398,13 @@ lua_trie_search_mime(lua_State *L) * @param {boolean} caseless if `true` then match ignores symbols case (ASCII only) * @return {boolean} `true` if any pattern has been found (`cb` might be called multiple times however) */ -static gint +static int lua_trie_search_rawmsg(lua_State *L) { LUA_TRACE_POINT; struct rspamd_multipattern *trie = lua_check_trie(L, 1); struct rspamd_task *task = lua_check_task(L, 2); - const gchar *text; + const char *text; gsize len; gboolean found = FALSE; @@ -429,13 +429,13 @@ lua_trie_search_rawmsg(lua_State *L) * @param {boolean} caseless if `true` then match ignores symbols case (ASCII only) * @return {boolean} `true` if any pattern has been found (`cb` might be called multiple times however) */ -static gint +static int lua_trie_search_rawbody(lua_State *L) { LUA_TRACE_POINT; struct rspamd_multipattern *trie = lua_check_trie(L, 1); struct rspamd_task *task = lua_check_task(L, 2); - const gchar *text; + const char *text; gsize len; gboolean found = FALSE; @@ -459,7 +459,7 @@ lua_trie_search_rawbody(lua_State *L) return 1; } -static gint +static int lua_load_trie(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_udp.c b/src/lua/lua_udp.c index d20475933..392c47f52 100644 --- a/src/lua/lua_udp.c +++ b/src/lua/lua_udp.c @@ -20,7 +20,7 @@ #include <math.h> #include <src/libutil/libev_helper.h> -static const gchar *M = "rspamd lua udp"; +static const char *M = "rspamd lua udp"; /*** * @module rspamd_udp @@ -69,10 +69,10 @@ struct lua_udp_cbdata { struct rspamd_async_session *s; struct iovec *iov; lua_State *L; - guint retransmits; - guint iovlen; - gint sock; - gint cbref; + unsigned int retransmits; + unsigned int iovlen; + int sock; + int cbref; gboolean sent; }; @@ -85,7 +85,7 @@ INIT_LOG_MODULE(lua_udp) static inline void lua_fill_iov(lua_State *L, rspamd_mempool_t *pool, - struct iovec *iov, gint pos) + struct iovec *iov, int pos) { if (lua_type(L, pos) == LUA_TUSERDATA) { struct rspamd_lua_text *t = lua_check_text(L, pos); @@ -97,7 +97,7 @@ lua_fill_iov(lua_State *L, rspamd_mempool_t *pool, } } else { - const gchar *s; + const char *s; gsize len; s = lua_tolstring(L, pos, &len); @@ -154,7 +154,7 @@ static enum rspamd_udp_send_result lua_try_send_request(struct lua_udp_cbdata *cbd) { struct msghdr msg; - gint r; + int r; memset(&msg, 0, sizeof(msg)); msg.msg_iov = cbd->iov; @@ -175,10 +175,10 @@ lua_try_send_request(struct lua_udp_cbdata *cbd) } static void -lua_udp_maybe_push_error(struct lua_udp_cbdata *cbd, const gchar *err) +lua_udp_maybe_push_error(struct lua_udp_cbdata *cbd, const char *err) { if (cbd->cbref != -1) { - gint top; + int top; lua_State *L = cbd->L; top = lua_gettop(L); @@ -203,11 +203,11 @@ lua_udp_maybe_push_error(struct lua_udp_cbdata *cbd, const gchar *err) } static void -lua_udp_push_data(struct lua_udp_cbdata *cbd, const gchar *data, +lua_udp_push_data(struct lua_udp_cbdata *cbd, const char *data, gssize len) { if (cbd->cbref != -1) { - gint top; + int top; lua_State *L = cbd->L; top = lua_gettop(L); @@ -259,7 +259,7 @@ lua_udp_maybe_register_event(struct lua_udp_cbdata *cbd) } static void -lua_udp_io_handler(gint fd, short what, gpointer p) +lua_udp_io_handler(int fd, short what, gpointer p) { struct lua_udp_cbdata *cbd = (struct lua_udp_cbdata *) p; gssize r; @@ -311,7 +311,7 @@ lua_udp_io_handler(gint fd, short what, gpointer p) } } else if (what == EV_READ) { - guchar udpbuf[4096]; + unsigned char udpbuf[4096]; socklen_t slen; struct sockaddr *sa; @@ -343,19 +343,19 @@ lua_udp_io_handler(gint fd, short what, gpointer p) * - `callback`: optional callback if reply should be read * @return {boolean} true if request has been sent (additional string if it has not) */ -static gint +static int lua_udp_sendto(lua_State *L) { LUA_TRACE_POINT; - const gchar *host; - guint port; + const char *host; + unsigned int port; struct ev_loop *ev_base = NULL; struct lua_udp_cbdata *cbd; struct rspamd_async_session *session = NULL; struct rspamd_task *task = NULL; rspamd_inet_addr_t *addr; rspamd_mempool_t *pool = NULL; - gdouble timeout = default_udp_timeout; + double timeout = default_udp_timeout; if (lua_type(L, 1) == LUA_TTABLE) { lua_pushstring(L, "port"); @@ -579,7 +579,7 @@ lua_udp_sendto(lua_State *L) return 1; } -static gint +static int lua_load_udp(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_upstream.c b/src/lua/lua_upstream.c index 69d9f39c4..181ef9398 100644 --- a/src/lua/lua_upstream.c +++ b/src/lua/lua_upstream.c @@ -106,7 +106,7 @@ lua_check_upstream(lua_State *L, int pos) * Get ip of upstream * @return {ip} ip address object */ -static gint +static int lua_upstream_get_addr(lua_State *L) { LUA_TRACE_POINT; @@ -127,7 +127,7 @@ lua_upstream_get_addr(lua_State *L) * Get name of upstream * @return {string} name of the upstream */ -static gint +static int lua_upstream_get_name(lua_State *L) { LUA_TRACE_POINT; @@ -148,7 +148,7 @@ lua_upstream_get_name(lua_State *L) * Get port of upstream * @return {int} port of the upstream */ -static gint +static int lua_upstream_get_port(lua_State *L) { LUA_TRACE_POINT; @@ -168,13 +168,13 @@ lua_upstream_get_port(lua_State *L) * @method upstream:fail() * Indicate upstream failure. After certain amount of failures during specified time frame, an upstream is marked as down and does not participate in rotations. */ -static gint +static int lua_upstream_fail(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_upstream *up = lua_check_upstream(L, 1); gboolean fail_addr = FALSE; - const gchar *reason = "unknown"; + const char *reason = "unknown"; if (up) { @@ -199,7 +199,7 @@ lua_upstream_fail(lua_State *L) * @method upstream:ok() * Indicates upstream success. Resets errors count for an upstream. */ -static gint +static int lua_upstream_ok(lua_State *L) { LUA_TRACE_POINT; @@ -212,7 +212,7 @@ lua_upstream_ok(lua_State *L) return 0; } -static gint +static int lua_upstream_destroy(lua_State *L) { LUA_TRACE_POINT; @@ -239,7 +239,7 @@ lua_check_upstream_list(lua_State *L) } static struct rspamd_lua_upstream * -lua_push_upstream(lua_State *L, gint up_idx, struct upstream *up) +lua_push_upstream(lua_State *L, int up_idx, struct upstream *up) { struct rspamd_lua_upstream *lua_ups; @@ -265,15 +265,15 @@ lua_push_upstream(lua_State *L, gint up_idx, struct upstream *up) * @param {number} default_port default port for upstreams * @return {upstream_list} upstream list structure */ -static gint +static int lua_upstream_list_create(lua_State *L) { LUA_TRACE_POINT; struct upstream_list *new = NULL, **pnew; struct rspamd_config *cfg = NULL; - const gchar *def; - guint default_port = 0; - gint top; + const char *def; + unsigned int default_port = 0; + int top; if (lua_type(L, 1) == LUA_TUSERDATA) { @@ -333,7 +333,7 @@ lua_upstream_list_create(lua_State *L) * @param L * @return */ -static gint +static int lua_upstream_list_destroy(lua_State *L) { LUA_TRACE_POINT; @@ -350,13 +350,13 @@ lua_upstream_list_destroy(lua_State *L) * @param {string} key a string used as input for stable hash algorithm * @return {upstream} upstream from a list corresponding to the given key */ -static gint +static int lua_upstream_list_get_upstream_by_hash(lua_State *L) { LUA_TRACE_POINT; struct upstream_list *upl; struct upstream *selected; - const gchar *key; + const char *key; gsize keyl; upl = lua_check_upstream_list(L); @@ -364,7 +364,7 @@ lua_upstream_list_get_upstream_by_hash(lua_State *L) key = luaL_checklstring(L, 2, &keyl); if (key) { selected = rspamd_upstream_get(upl, RSPAMD_UPSTREAM_HASHED, key, - (guint) keyl); + (unsigned int) keyl); if (selected) { lua_push_upstream(L, 1, selected); @@ -389,7 +389,7 @@ lua_upstream_list_get_upstream_by_hash(lua_State *L) * Get upstream round robin (by current weight) * @return {upstream} upstream from a list in round-robin matter */ -static gint +static int lua_upstream_list_get_upstream_round_robin(lua_State *L) { LUA_TRACE_POINT; @@ -419,7 +419,7 @@ lua_upstream_list_get_upstream_round_robin(lua_State *L) * Get upstream master slave order (by static priority) * @return {upstream} upstream from a list in master-slave order */ -static gint +static int lua_upstream_list_get_upstream_master_slave(lua_State *L) { LUA_TRACE_POINT; @@ -448,10 +448,10 @@ lua_upstream_list_get_upstream_master_slave(lua_State *L) struct upstream_foreach_cbdata { lua_State *L; - gint ups_pos; + int ups_pos; }; -static void lua_upstream_inserter(struct upstream *up, guint idx, void *ud) +static void lua_upstream_inserter(struct upstream *up, unsigned int idx, void *ud) { struct upstream_foreach_cbdata *cbd = (struct upstream_foreach_cbdata *) ud; @@ -463,7 +463,7 @@ static void lua_upstream_inserter(struct upstream *up, guint idx, void *ud) * Returns all upstreams for this list * @return {table|upstream} all upstreams defined */ -static gint +static int lua_upstream_list_all_upstreams(lua_State *L) { LUA_TRACE_POINT; @@ -486,7 +486,7 @@ lua_upstream_list_all_upstreams(lua_State *L) } static inline enum rspamd_upstreams_watch_event -lua_str_to_upstream_flag(const gchar *str) +lua_str_to_upstream_flag(const char *str) { enum rspamd_upstreams_watch_event fl = 0; @@ -509,10 +509,10 @@ lua_str_to_upstream_flag(const gchar *str) return fl; } -static inline const gchar * +static inline const char * lua_upstream_flag_to_str(enum rspamd_upstreams_watch_event fl) { - const gchar *res = "unknown"; + const char *res = "unknown"; /* Works with single flags, not combinations */ if (fl & RSPAMD_UPSTREAM_WATCH_SUCCESS) { @@ -536,22 +536,22 @@ lua_upstream_flag_to_str(enum rspamd_upstreams_watch_event fl) struct rspamd_lua_upstream_watcher_cbdata { lua_State *L; - gint cbref; - gint parent_cbref; /* Reference to the upstream list */ + int cbref; + int parent_cbref; /* Reference to the upstream list */ struct upstream_list *upl; }; static void lua_upstream_watch_func(struct upstream *up, enum rspamd_upstreams_watch_event event, - guint cur_errors, + unsigned int cur_errors, void *ud) { struct rspamd_lua_upstream_watcher_cbdata *cdata = (struct rspamd_lua_upstream_watcher_cbdata *) ud; lua_State *L; - const gchar *what; - gint err_idx; + const char *what; + int err_idx; L = cdata->L; what = lua_upstream_flag_to_str(event); @@ -604,7 +604,7 @@ ups:add_watcher('success', function(what, up, cur_errors) ... end) ups:add_watcher({'online', 'offline'}, function(what, up, cur_errors) ... end) * @return nothing */ -static gint +static int lua_upstream_list_add_watcher(lua_State *L) { LUA_TRACE_POINT; @@ -652,7 +652,7 @@ lua_upstream_list_add_watcher(lua_State *L) return 0; } -static gint +static int lua_load_upstream_list(lua_State *L) { lua_newtable(L); diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c index f84f64a2c..8e6680a91 100644 --- a/src/lua/lua_url.c +++ b/src/lua/lua_url.c @@ -117,7 +117,7 @@ static const struct luaL_reg urllib_f[] = { {NULL, NULL}}; struct rspamd_lua_url * -lua_check_url(lua_State *L, gint pos) +lua_check_url(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_url_classname); luaL_argcheck(L, ud != NULL, pos, "'url' expected"); @@ -143,7 +143,7 @@ lua_url_single_inserter(struct rspamd_url *url, gsize start_offset, * Get length of the url * @return {number} length of url in bytes */ -static gint +static int lua_url_get_length(lua_State *L) { LUA_TRACE_POINT; @@ -163,7 +163,7 @@ lua_url_get_length(lua_State *L) * Get domain part of the url * @return {string} domain part of URL */ -static gint +static int lua_url_get_host(lua_State *L) { LUA_TRACE_POINT; @@ -183,7 +183,7 @@ lua_url_get_host(lua_State *L) * Get port of the url * @return {number} url port */ -static gint +static int lua_url_get_port(lua_State *L) { LUA_TRACE_POINT; @@ -208,7 +208,7 @@ lua_url_get_port(lua_State *L) * Get user part of the url (e.g. username in email) * @return {string} user part of URL */ -static gint +static int lua_url_get_user(lua_State *L) { LUA_TRACE_POINT; @@ -229,7 +229,7 @@ lua_url_get_user(lua_State *L) * Get path of the url * @return {string} path part of URL */ -static gint +static int lua_url_get_path(lua_State *L) { LUA_TRACE_POINT; @@ -250,7 +250,7 @@ lua_url_get_path(lua_State *L) * Get query of the url * @return {string} query part of URL */ -static gint +static int lua_url_get_query(lua_State *L) { LUA_TRACE_POINT; @@ -271,7 +271,7 @@ lua_url_get_query(lua_State *L) * Get fragment of the url * @return {string} fragment part of URL */ -static gint +static int lua_url_get_fragment(lua_State *L) { LUA_TRACE_POINT; @@ -292,7 +292,7 @@ lua_url_get_fragment(lua_State *L) * Get full content of the url * @return {string} url string */ -static gint +static int lua_url_get_text(lua_State *L) { LUA_TRACE_POINT; @@ -313,7 +313,7 @@ lua_url_get_text(lua_State *L) * Get full content of the url or user@domain in case of email * @return {string} url as a string */ -static gint +static int lua_url_tostring(lua_State *L) { LUA_TRACE_POINT; @@ -321,8 +321,8 @@ lua_url_tostring(lua_State *L) if (url != NULL && url->url != NULL) { if (url->url->protocol == PROTOCOL_MAILTO) { - gchar *tmp = g_malloc(url->url->userlen + 1 + - url->url->hostlen); + char *tmp = g_malloc(url->url->userlen + 1 + + url->url->hostlen); if (url->url->userlen) { memcpy(tmp, url->url->string + url->url->usershift, url->url->userlen); } @@ -350,7 +350,7 @@ lua_url_tostring(lua_State *L) * Get URL suitable for HTTP request (e.g. by trimming fragment and user parts) * @return {string} url as a string */ -static gint +static int lua_url_to_http(lua_State *L) { LUA_TRACE_POINT; @@ -373,8 +373,8 @@ lua_url_to_http(lua_State *L) len--; } } - gchar *nstr = g_malloc(len); - gchar *d = nstr, *end = nstr + len; + char *nstr = g_malloc(len); + char *d = nstr, *end = nstr + len; memcpy(nstr, url->url->string, url->url->protocollen); d += url->url->protocollen; *d++ = ':'; @@ -433,7 +433,7 @@ lua_url_to_http(lua_State *L) * Get full content of the url as it was parsed (e.g. with urldecode) * @return {string} url string */ -static gint +static int lua_url_get_raw(lua_State *L) { LUA_TRACE_POINT; @@ -454,7 +454,7 @@ lua_url_get_raw(lua_State *L) * Check whether URL is treated as phished * @return {boolean} `true` if URL is phished */ -static gint +static int lua_url_is_phished(lua_State *L) { LUA_TRACE_POINT; @@ -475,7 +475,7 @@ lua_url_is_phished(lua_State *L) * Check whether URL was redirected * @return {boolean} `true` if URL is redirected */ -static gint +static int lua_url_is_redirected(lua_State *L) { LUA_TRACE_POINT; @@ -496,7 +496,7 @@ lua_url_is_redirected(lua_State *L) * Check whether URL is treated as obscured or obfuscated (e.g. numbers in IP address or other hacks) * @return {boolean} `true` if URL is obscured */ -static gint +static int lua_url_is_obscured(lua_State *L) { LUA_TRACE_POINT; @@ -518,7 +518,7 @@ lua_url_is_obscured(lua_State *L) * Check whether URL is just displayed in HTML (e.g. NOT a real href) * @return {boolean} `true` if URL is displayed only */ -static gint +static int lua_url_is_html_displayed(lua_State *L) { LUA_TRACE_POINT; @@ -539,7 +539,7 @@ lua_url_is_html_displayed(lua_State *L) * Check whether URL is found in subject * @return {boolean} `true` if URL is found in subject */ -static gint +static int lua_url_is_subject(lua_State *L) { LUA_TRACE_POINT; @@ -560,7 +560,7 @@ lua_url_is_subject(lua_State *L) * Get another URL that pretends to be this URL (e.g. used in phishing) * @return {url} phished URL */ -static gint +static int lua_url_get_phished(lua_State *L) { LUA_TRACE_POINT; @@ -591,7 +591,7 @@ lua_url_get_phished(lua_State *L) * @param {pool} pool memory pool to allocate memory if needed * @return {url} parsed redirected url (if needed) */ -static gint +static int lua_url_set_redirected(lua_State *L) { LUA_TRACE_POINT; @@ -615,7 +615,7 @@ lua_url_set_redirected(lua_State *L) } gsize len; - const gchar *urlstr = lua_tolstring(L, 2, &len); + const char *urlstr = lua_tolstring(L, 2, &len); rspamd_url_find_single(pool, urlstr, len, RSPAMD_URL_FIND_ALL, lua_url_single_inserter, L); @@ -666,7 +666,7 @@ lua_url_set_redirected(lua_State *L) * Get effective second level domain part (eSLD) of the url host * @return {string} effective second level domain part (eSLD) of the url host */ -static gint +static int lua_url_get_tld(lua_State *L) { LUA_TRACE_POINT; @@ -687,7 +687,7 @@ lua_url_get_tld(lua_State *L) * Get protocol name * @return {string} protocol as a string */ -static gint +static int lua_url_get_protocol(lua_State *L) { LUA_TRACE_POINT; @@ -708,7 +708,7 @@ lua_url_get_protocol(lua_State *L) * Return number of occurrences for this particular URL * @return {number} number of occurrences */ -static gint +static int lua_url_get_count(lua_State *L) { LUA_TRACE_POINT; @@ -729,7 +729,7 @@ lua_url_get_count(lua_State *L) * Get visible part of the url with html tags stripped * @return {string} url string */ -static gint +static int lua_url_get_visible(lua_State *L) { LUA_TRACE_POINT; @@ -757,7 +757,7 @@ lua_url_get_visible(lua_State *L) * - `protocol`: url protocol * @return {table} URL as a table */ -static gint +static int lua_url_to_table(lua_State *L) { LUA_TRACE_POINT; @@ -844,7 +844,7 @@ RSPAMD_DESTRUCTOR(rspamd_urls_static_pool_dtor) * @param {string} text that contains URL (can also contain other stuff) * @return {url} new url object that exists as long as the corresponding mempool exists */ -static gint +static int lua_url_create(lua_State *L) { LUA_TRACE_POINT; @@ -885,7 +885,7 @@ lua_url_create(lua_State *L) /* Add flags */ for (lua_pushnil(L); lua_next(L, 3); lua_pop(L, 1)) { int nmask = 0; - const gchar *fname = lua_tostring(L, -1); + const char *fname = lua_tostring(L, -1); if (rspamd_url_flag_from_string(fname, &nmask)) { u->url->flags |= nmask; @@ -906,10 +906,10 @@ lua_url_create(lua_State *L) * @param {string} tld_file path to effective_tld_names.dat file (public suffix list) * @return nothing */ -static gint +static int lua_url_init(lua_State *L) { - const gchar *tld_path; + const char *tld_path; tld_path = luaL_checkstring(L, 1); @@ -924,7 +924,7 @@ lua_url_table_inserter(struct rspamd_url *url, gsize start_offset, { lua_State *L = ud; struct rspamd_lua_url *lua_url; - gint n; + int n; n = rspamd_lua_table_size(L, -1); lua_url = lua_newuserdata(L, sizeof(struct rspamd_lua_url)); @@ -936,12 +936,12 @@ lua_url_table_inserter(struct rspamd_url *url, gsize start_offset, } -static gint +static int lua_url_all(lua_State *L) { LUA_TRACE_POINT; rspamd_mempool_t *pool = rspamd_lua_check_mempool(L, 1); - const gchar *text; + const char *text; size_t length; if (pool == NULL) { @@ -999,7 +999,7 @@ lua_url_all(lua_State *L) } \ } while (0) -static gint +static int lua_url_get_flags(lua_State *L) { LUA_TRACE_POINT; @@ -1011,7 +1011,7 @@ lua_url_get_flags(lua_State *L) lua_createtable(L, 0, 4); - for (gint i = 0; i < RSPAMD_URL_MAX_FLAG_SHIFT; i++) { + for (int i = 0; i < RSPAMD_URL_MAX_FLAG_SHIFT; i++) { PUSH_FLAG(1u << i); } } @@ -1024,7 +1024,7 @@ lua_url_get_flags(lua_State *L) #undef PUSH_FLAG -static gint +static int lua_url_get_flags_num(lua_State *L) { LUA_TRACE_POINT; @@ -1040,7 +1040,7 @@ lua_url_get_flags_num(lua_State *L) return 1; } -static gint +static int lua_url_get_order(lua_State *L) { LUA_TRACE_POINT; @@ -1061,7 +1061,7 @@ lua_url_get_order(lua_State *L) return 1; } -static gint +static int lua_url_get_part_order(lua_State *L) { LUA_TRACE_POINT; @@ -1113,7 +1113,7 @@ void lua_tree_url_callback(gpointer key, gpointer value, gpointer ud) } if (cb->skip_prob > 0) { - gdouble coin = rspamd_random_double_fast_seed(&cb->random_seed); + double coin = rspamd_random_double_fast_seed(&cb->random_seed); if (coin < cb->skip_prob) { return; @@ -1130,16 +1130,16 @@ void lua_tree_url_callback(gpointer key, gpointer value, gpointer ud) gboolean lua_url_cbdata_fill(lua_State *L, - gint pos, + int pos, struct lua_tree_cb_data *cbd, - guint default_protocols, - guint default_flags, + unsigned int default_protocols, + unsigned int default_flags, gsize max_urls) { - gint protocols_mask = 0; + int protocols_mask = 0; - gint pos_arg_type = lua_type(L, pos); - guint flags_mask = default_flags; + int pos_arg_type = lua_type(L, pos); + unsigned int flags_mask = default_flags; gboolean seen_flags = FALSE, seen_protocols = FALSE; memset(cbd, 0, sizeof(*cbd)); @@ -1157,11 +1157,11 @@ lua_url_cbdata_fill(lua_State *L, lua_getfield(L, pos, "flags"); if (lua_istable(L, -1)) { - gint top = lua_gettop(L); + int top = lua_gettop(L); lua_getfield(L, pos, "flags_mode"); if (lua_isstring(L, -1)) { - const gchar *mode_str = lua_tostring(L, -1); + const char *mode_str = lua_tostring(L, -1); if (strcmp(mode_str, "explicit") == 0) { cbd->flags_mode = url_flags_mode_include_explicit; @@ -1179,7 +1179,7 @@ lua_url_cbdata_fill(lua_State *L, if (lua_type(L, -1) == LUA_TSTRING) { - const gchar *fname = lua_tostring(L, -1); + const char *fname = lua_tostring(L, -1); if (rspamd_url_flag_from_string(fname, &nmask)) { @@ -1204,11 +1204,11 @@ lua_url_cbdata_fill(lua_State *L, lua_getfield(L, pos, "protocols"); if (lua_istable(L, -1)) { - gint top = lua_gettop(L); + int top = lua_gettop(L); for (lua_pushnil(L); lua_next(L, top); lua_pop(L, 1)) { int nmask; - const gchar *pname = lua_tostring(L, -1); + const char *pname = lua_tostring(L, -1); nmask = rspamd_url_protocol_from_string(pname); @@ -1285,7 +1285,7 @@ lua_url_cbdata_fill(lua_State *L, /* Plain table of the protocols */ for (lua_pushnil(L); lua_next(L, pos); lua_pop(L, 1)) { int nmask; - const gchar *pname = lua_tostring(L, -1); + const char *pname = lua_tostring(L, -1); nmask = rspamd_url_protocol_from_string(pname); @@ -1302,9 +1302,9 @@ lua_url_cbdata_fill(lua_State *L, lua_pop(L, 1); /* After rspamd_lua_geti */ } else if (pos_arg_type == LUA_TSTRING) { - const gchar *plist = lua_tostring(L, pos); - gchar **strvec; - gchar *const *cvec; + const char *plist = lua_tostring(L, pos); + char **strvec; + char *const *cvec; strvec = g_strsplit_set(plist, ",;", -1); cvec = strvec; @@ -1362,15 +1362,15 @@ lua_url_cbdata_fill(lua_State *L, gboolean lua_url_cbdata_fill_exclude_include(lua_State *L, - gint pos, + int pos, struct lua_tree_cb_data *cbd, - guint default_protocols, + unsigned int default_protocols, gsize max_urls) { - guint protocols_mask = default_protocols; - guint include_flags_mask, exclude_flags_mask; + unsigned int protocols_mask = default_protocols; + unsigned int include_flags_mask, exclude_flags_mask; - gint pos_arg_type = lua_type(L, pos); + int pos_arg_type = lua_type(L, pos); memset(cbd, 0, sizeof(*cbd)); cbd->flags_mode = url_flags_mode_exclude_include; @@ -1383,7 +1383,7 @@ lua_url_cbdata_fill_exclude_include(lua_State *L, int nmask = 0; if (lua_type(L, -1) == LUA_TSTRING) { - const gchar *fname = lua_tostring(L, -1); + const char *fname = lua_tostring(L, -1); if (rspamd_url_flag_from_string(fname, &nmask)) { include_flags_mask |= nmask; @@ -1416,7 +1416,7 @@ lua_url_cbdata_fill_exclude_include(lua_State *L, int nmask = 0; if (lua_type(L, -1) == LUA_TSTRING) { - const gchar *fname = lua_tostring(L, -1); + const char *fname = lua_tostring(L, -1); if (rspamd_url_flag_from_string(fname, &nmask)) { exclude_flags_mask |= nmask; @@ -1445,7 +1445,7 @@ lua_url_cbdata_fill_exclude_include(lua_State *L, for (lua_pushnil(L); lua_next(L, pos + 2); lua_pop(L, 1)) { int nmask; - const gchar *pname = lua_tostring(L, -1); + const char *pname = lua_tostring(L, -1); nmask = rspamd_url_protocol_from_string(pname); @@ -1486,12 +1486,12 @@ void lua_url_cbdata_dtor(struct lua_tree_cb_data *cbd) } gsize lua_url_adjust_skip_prob(float timestamp, - guchar digest[16], + unsigned char digest[16], struct lua_tree_cb_data *cb, gsize sz) { if (cb->max_urls > 0 && sz > cb->max_urls) { - cb->skip_prob = 1.0 - ((gdouble) cb->max_urls) / (gdouble) sz; + cb->skip_prob = 1.0 - ((double) cb->max_urls) / (double) sz; /* * Use task dependent probabilistic seed to ensure that * consequent task:get_urls return the same list of urls @@ -1506,7 +1506,7 @@ gsize lua_url_adjust_skip_prob(float timestamp, return sz; } -static gint +static int lua_url_eq(lua_State *L) { LUA_TRACE_POINT; @@ -1523,7 +1523,7 @@ lua_url_eq(lua_State *L) return 1; } -static gint +static int lua_url_lt(lua_State *L) { LUA_TRACE_POINT; @@ -1540,7 +1540,7 @@ lua_url_lt(lua_State *L) return 1; } -static gint +static int lua_load_url(lua_State *L) { lua_newtable(L); @@ -1549,7 +1549,7 @@ lua_load_url(lua_State *L) /* Push flags */ lua_createtable(L, 0, RSPAMD_URL_MAX_FLAG_SHIFT); for (int i = 0; i < RSPAMD_URL_MAX_FLAG_SHIFT; i++) { - guint flag = 1u << i; + unsigned int flag = 1u << i; lua_pushinteger(L, flag); lua_setfield(L, -2, rspamd_url_flag_to_string(flag)); diff --git a/src/lua/lua_url.h b/src/lua/lua_url.h index 930b4f553..3bb505994 100644 --- a/src/lua/lua_url.h +++ b/src/lua/lua_url.h @@ -26,9 +26,9 @@ struct lua_tree_cb_data { lua_State *L; int i; int metatable_pos; - guint flags_mask; - guint flags_exclude_mask; - guint protocols_mask; + unsigned int flags_mask; + unsigned int flags_exclude_mask; + unsigned int protocols_mask; enum { url_flags_mode_include_any, url_flags_mode_include_explicit, @@ -36,7 +36,7 @@ struct lua_tree_cb_data { } flags_mode; gboolean sort; gsize max_urls; - gdouble skip_prob; + double skip_prob; uint64_t random_seed; }; @@ -49,15 +49,15 @@ void lua_tree_url_callback(gpointer key, gpointer value, gpointer ud); * @param cbd * @return */ -gboolean lua_url_cbdata_fill(lua_State *L, gint pos, +gboolean lua_url_cbdata_fill(lua_State *L, int pos, struct lua_tree_cb_data *cbd, - guint default_protocols, - guint default_flags, + unsigned int default_protocols, + unsigned int default_flags, gsize max_urls); -gboolean lua_url_cbdata_fill_exclude_include(lua_State *L, gint pos, +gboolean lua_url_cbdata_fill_exclude_include(lua_State *L, int pos, struct lua_tree_cb_data *cbd, - guint default_protocols, + unsigned int default_protocols, gsize max_urls); /** @@ -76,7 +76,7 @@ void lua_url_cbdata_dtor(struct lua_tree_cb_data *cbd); * @return */ gsize lua_url_adjust_skip_prob(float timestamp, - guchar digest[16], + unsigned char digest[16], struct lua_tree_cb_data *cb, gsize sz); diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c index 11e45b723..3370a757d 100644 --- a/src/lua/lua_util.c +++ b/src/lua/lua_util.c @@ -761,7 +761,7 @@ static const struct luaL_reg ev_baselib_m[] = { {NULL, NULL}}; static int64_t -lua_check_int64(lua_State *L, gint pos) +lua_check_int64(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_int64_classname); luaL_argcheck(L, ud != NULL, pos, "'int64' expected"); @@ -769,7 +769,7 @@ lua_check_int64(lua_State *L, gint pos) } -static gint +static int lua_util_create_event_base(lua_State *L) { LUA_TRACE_POINT; @@ -782,12 +782,12 @@ lua_util_create_event_base(lua_State *L) return 1; } -static gint +static int lua_util_load_rspamd_config(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg, **pcfg; - const gchar *cfg_name; + const char *cfg_name; cfg_name = luaL_checkstring(L, 1); @@ -810,13 +810,13 @@ lua_util_load_rspamd_config(lua_State *L) return 1; } -static gint +static int parse_config_options(const char *str_options) { - gint ret = 0; - gchar **vec; - const gchar *str; - guint i, l; + int ret = 0; + char **vec; + const char *str; + unsigned int i, l; vec = g_strsplit_set(str_options, ",;", -1); if (vec) { @@ -853,7 +853,7 @@ parse_config_options(const char *str_options) return ret; } -static gint +static int lua_util_config_from_ucl(lua_State *L) { LUA_TRACE_POINT; @@ -862,7 +862,7 @@ lua_util_config_from_ucl(lua_State *L) GError *err = NULL; ucl_object_t *obj; const char *str_options = NULL; - gint int_options = 0; + int int_options = 0; obj = ucl_object_lua_import(L, 1); @@ -919,12 +919,12 @@ lua_util_task_fin(struct rspamd_task *task, void *ud) return TRUE; } -static gint +static int lua_util_process_message(lua_State *L) { LUA_TRACE_POINT; struct rspamd_config *cfg = lua_check_config(L, 1); - const gchar *message; + const char *message; gsize mlen; struct rspamd_task *task; struct ev_loop *base; @@ -979,12 +979,12 @@ lua_util_process_message(lua_State *L) return 1; } -static gint +static int lua_util_encode_base64(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t; - gchar *out; + char *out; gsize outlen; long str_lim = 0; gboolean fold = FALSE; @@ -1008,7 +1008,7 @@ lua_util_encode_base64(lua_State *L) enum rspamd_newlines_type how = RSPAMD_TASK_NEWLINES_CRLF; if (lua_type(L, 3) == LUA_TSTRING) { - const gchar *how_str = lua_tostring(L, 3); + const char *how_str = lua_tostring(L, 3); if (g_ascii_strcasecmp(how_str, "cr") == 0) { how = RSPAMD_TASK_NEWLINES_CR; @@ -1035,15 +1035,15 @@ lua_util_encode_base64(lua_State *L) return 1; } -static gint +static int lua_util_encode_qp(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t; - const gchar *s = NULL; - gchar *out; + const char *s = NULL; + char *out; gsize inlen, outlen; - guint str_lim = 0; + unsigned int str_lim = 0; if (lua_type(L, 1) == LUA_TSTRING) { s = luaL_checklstring(L, 1, &inlen); @@ -1068,7 +1068,7 @@ lua_util_encode_qp(lua_State *L) enum rspamd_newlines_type how = RSPAMD_TASK_NEWLINES_CRLF; if (lua_type(L, 3) == LUA_TSTRING) { - const gchar *how_str = lua_tostring(L, 3); + const char *how_str = lua_tostring(L, 3); if (g_ascii_strcasecmp(how_str, "cr") == 0) { how = RSPAMD_TASK_NEWLINES_CR; @@ -1099,12 +1099,12 @@ lua_util_encode_qp(lua_State *L) return 1; } -static gint +static int lua_util_decode_qp(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t, *out; - const gchar *s = NULL; + const char *s = NULL; gsize inlen = 0; gssize outlen; @@ -1128,7 +1128,7 @@ lua_util_decode_qp(lua_State *L) rspamd_lua_setclass(L, rspamd_text_classname, -1); out->start = g_malloc(inlen + 1); out->flags = RSPAMD_TEXT_FLAG_OWN; - outlen = rspamd_decode_qp_buf(s, inlen, (gchar *) out->start, inlen + 1); + outlen = rspamd_decode_qp_buf(s, inlen, (char *) out->start, inlen + 1); if (outlen > 0) { out->len = outlen; @@ -1145,12 +1145,12 @@ lua_util_decode_qp(lua_State *L) return 1; } -static gint +static int lua_util_decode_base64(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t; - const gchar *s = NULL; + const char *s = NULL; gsize inlen = 0, outlen; if (lua_type(L, 1) == LUA_TSTRING) { @@ -1171,7 +1171,7 @@ lua_util_decode_base64(lua_State *L) t->len = (inlen / 4) * 3 + 3; t->start = g_malloc(t->len); - rspamd_cryptobox_base64_decode(s, inlen, (guchar *) t->start, + rspamd_cryptobox_base64_decode(s, inlen, (unsigned char *) t->start, &outlen); t->len = outlen; t->flags = RSPAMD_TEXT_FLAG_OWN; @@ -1183,13 +1183,13 @@ lua_util_decode_base64(lua_State *L) return 1; } -static gint +static int lua_util_encode_base32(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t; - const gchar *s = NULL; - gchar *out; + const char *s = NULL; + char *out; enum rspamd_base32_type btype = RSPAMD_BASE32_DEFAULT; gsize inlen, outlen; @@ -1236,12 +1236,12 @@ lua_util_encode_base32(lua_State *L) return 1; } -static gint +static int lua_util_decode_base32(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t; - const gchar *s = NULL; + const char *s = NULL; gsize inlen, outlen; enum rspamd_base32_type btype = RSPAMD_BASE32_DEFAULT; @@ -1266,14 +1266,14 @@ lua_util_decode_base32(lua_State *L) } if (s != NULL) { - guchar *decoded; + unsigned char *decoded; decoded = rspamd_decode_base32(s, inlen, &outlen, btype); if (decoded) { t = lua_newuserdata(L, sizeof(*t)); rspamd_lua_setclass(L, rspamd_text_classname, -1); - t->start = (const gchar *) decoded; + t->start = (const char *) decoded; t->len = outlen; t->flags = RSPAMD_TEXT_FLAG_OWN; } @@ -1288,7 +1288,7 @@ lua_util_decode_base32(lua_State *L) return 1; } -static gint +static int lua_util_decode_url(lua_State *L) { LUA_TRACE_POINT; @@ -1309,36 +1309,36 @@ lua_util_decode_url(lua_State *L) } -static gint +static int lua_util_tokenize_text(lua_State *L) { return lua_parsers_tokenize_text(L); } -static gint +static int lua_util_tanh(lua_State *L) { LUA_TRACE_POINT; - gdouble in = luaL_checknumber(L, 1); + double in = luaL_checknumber(L, 1); lua_pushnumber(L, tanh(in)); return 1; } -static gint +static int lua_util_parse_html(lua_State *L) { return lua_parsers_parse_html(L); } -static gint +static int lua_util_levenshtein_distance(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t1, *t2; - gint dist = 0; - guint replace_cost = 1; + int dist = 0; + unsigned int replace_cost = 1; t1 = lua_check_text_or_string(L, 1); t2 = lua_check_text_or_string(L, 2); @@ -1359,11 +1359,11 @@ lua_util_levenshtein_distance(lua_State *L) return 1; } -static gint +static int lua_util_fold_header(lua_State *L) { LUA_TRACE_POINT; - const gchar *how, *stop_chars = NULL; + const char *how, *stop_chars = NULL; struct rspamd_lua_text *name, *value; GString *folded; @@ -1415,13 +1415,13 @@ lua_util_fold_header(lua_State *L) return 1; } -static gint +static int lua_util_is_uppercase(lua_State *L) { LUA_TRACE_POINT; int32_t i = 0; UChar32 uc; - guint nlc = 0, nuc = 0; + unsigned int nlc = 0, nuc = 0; struct rspamd_lua_text *t = lua_check_text_or_string(L, 1); if (t) { @@ -1451,12 +1451,12 @@ lua_util_is_uppercase(lua_State *L) return 1; } -static gint +static int lua_util_humanize_number(lua_State *L) { LUA_TRACE_POINT; int64_t number = luaL_checkinteger(L, 1); - gchar numbuf[32]; + char numbuf[32]; rspamd_snprintf(numbuf, sizeof(numbuf), "%hL", number); @@ -1465,11 +1465,11 @@ lua_util_humanize_number(lua_State *L) return 1; } -static gint +static int lua_util_get_tld(lua_State *L) { LUA_TRACE_POINT; - const gchar *host; + const char *host; gsize hostlen; rspamd_ftok_t tld; @@ -1491,13 +1491,13 @@ lua_util_get_tld(lua_State *L) } -static gint +static int lua_util_glob(lua_State *L) { LUA_TRACE_POINT; - const gchar *pattern; + const char *pattern; glob_t gl; - gint top, i, flags = 0; + int top, i, flags = 0; top = lua_gettop(L); memset(&gl, 0, sizeof(gl)); @@ -1518,7 +1518,7 @@ lua_util_glob(lua_State *L) lua_createtable(L, gl.gl_pathc, 0); /* Push results */ - for (i = 0; i < (gint) gl.gl_pathc; i++) { + for (i = 0; i < (int) gl.gl_pathc; i++) { lua_pushstring(L, gl.gl_pathv[i]); lua_rawseti(L, -2, i + 1); } @@ -1528,13 +1528,13 @@ lua_util_glob(lua_State *L) return 1; } -static gint +static int lua_util_parse_mail_address(lua_State *L) { return lua_parsers_parse_mail_address(L); } -static gint +static int lua_util_strlen_utf8(lua_State *L) { LUA_TRACE_POINT; @@ -1547,7 +1547,7 @@ lua_util_strlen_utf8(lua_State *L) UChar32 uc; while (i < t->len) { - U8_NEXT((guint8 *) t->start, i, t->len, uc); + U8_NEXT((uint8_t *) t->start, i, t->len, uc); nchars++; } @@ -1560,13 +1560,13 @@ lua_util_strlen_utf8(lua_State *L) return 1; } -static gint +static int lua_util_lower_utf8(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t; - gchar *dst; + char *dst; UChar32 uc; UBool err = 0; int32_t i = 0, j = 0; @@ -1577,7 +1577,7 @@ lua_util_lower_utf8(lua_State *L) dst = g_malloc(t->len); while (i < t->len && err == 0) { - U8_NEXT((guint8 *) t->start, i, t->len, uc); + U8_NEXT((uint8_t *) t->start, i, t->len, uc); uc = u_tolower(uc); U8_APPEND(dst, j, t->len, uc, err); } @@ -1599,7 +1599,7 @@ lua_util_lower_utf8(lua_State *L) return 1; } -static gint +static int lua_util_normalize_utf8(lua_State *L) { LUA_TRACE_POINT; @@ -1632,7 +1632,7 @@ lua_util_normalize_utf8(lua_State *L) return 2; } -static gint +static int lua_util_transliterate(lua_State *L) { LUA_TRACE_POINT; @@ -1650,12 +1650,12 @@ lua_util_transliterate(lua_State *L) return 1; } -static gint +static int lua_util_strequal_caseless(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t1, *t2; - gint ret = -1; + int ret = -1; t1 = lua_check_text_or_string(L, 1); t2 = lua_check_text_or_string(L, 2); @@ -1677,12 +1677,12 @@ lua_util_strequal_caseless(lua_State *L) return 1; } -static gint +static int lua_util_strequal_caseless_utf8(lua_State *L) { LUA_TRACE_POINT; struct rspamd_lua_text *t1, *t2; - gint ret = -1; + int ret = -1; t1 = lua_check_text_or_string(L, 1); t2 = lua_check_text_or_string(L, 2); @@ -1699,11 +1699,11 @@ lua_util_strequal_caseless_utf8(lua_State *L) return 1; } -static gint +static int lua_util_get_ticks(lua_State *L) { LUA_TRACE_POINT; - gdouble ticks; + double ticks; gboolean rdtsc = FALSE; if (lua_isboolean(L, 1)) { @@ -1716,7 +1716,7 @@ lua_util_get_ticks(lua_State *L) return 1; } -static gint +static int lua_util_get_time(lua_State *L) { LUA_TRACE_POINT; @@ -1726,11 +1726,11 @@ lua_util_get_time(lua_State *L) return 1; } -static gint +static int lua_util_time_to_string(lua_State *L) { LUA_TRACE_POINT; - gdouble seconds; + double seconds; char timebuf[128]; if (lua_isnumber(L, 1)) { @@ -1746,11 +1746,11 @@ lua_util_time_to_string(lua_State *L) return 1; } -static gint +static int lua_util_stat(lua_State *L) { LUA_TRACE_POINT; - const gchar *fpath; + const char *fpath; struct stat st; fpath = luaL_checkstring(L, 1); @@ -1792,12 +1792,12 @@ lua_util_stat(lua_State *L) return 2; } -static gint +static int lua_util_unlink(lua_State *L) { LUA_TRACE_POINT; - const gchar *fpath; - gint ret; + const char *fpath; + int ret; fpath = luaL_checkstring(L, 1); @@ -1820,12 +1820,12 @@ lua_util_unlink(lua_State *L) return 1; } -static gint +static int lua_util_lock_file(lua_State *L) { LUA_TRACE_POINT; - const gchar *fpath; - gint fd = -1; + const char *fpath; + int fd = -1; gboolean own = FALSE; #if !HAVE_FLOCK @@ -1878,11 +1878,11 @@ lua_util_lock_file(lua_State *L) return 1; } -static gint +static int lua_util_unlock_file(lua_State *L) { LUA_TRACE_POINT; - gint fd = -1, ret, serrno; + int fd = -1, ret, serrno; gboolean do_close = TRUE; #if !HAVE_FLOCK @@ -1928,12 +1928,12 @@ lua_util_unlock_file(lua_State *L) return 1; } -static gint +static int lua_util_create_file(lua_State *L) { LUA_TRACE_POINT; - gint fd, mode = 00644; - const gchar *fpath; + int fd, mode = 00644; + const char *fpath; fpath = luaL_checkstring(L, 1); @@ -1960,11 +1960,11 @@ lua_util_create_file(lua_State *L) return 1; } -static gint +static int lua_util_close_file(lua_State *L) { LUA_TRACE_POINT; - gint fd = -1; + int fd = -1; if (lua_isnumber(L, 1)) { fd = lua_tointeger(L, 1); @@ -1985,12 +1985,12 @@ lua_util_close_file(lua_State *L) return 1; } -static gint +static int lua_util_random_hex(lua_State *L) { LUA_TRACE_POINT; - gchar *buf; - gint buflen; + char *buf; + int buflen; buflen = lua_tointeger(L, 1); @@ -2006,41 +2006,41 @@ lua_util_random_hex(lua_State *L) return 1; } -static gint +static int lua_util_zstd_compress(lua_State *L) { return lua_compress_zstd_compress(L); } -static gint +static int lua_util_zstd_decompress(lua_State *L) { return lua_compress_zstd_decompress(L); } -static gint +static int lua_util_gzip_compress(lua_State *L) { return lua_compress_zlib_compress(L); } -static gint +static int lua_util_gzip_decompress(lua_State *L) { return lua_compress_zlib_decompress(L, true); } -static gint +static int lua_util_inflate(lua_State *L) { return lua_compress_zlib_decompress(L, false); } -static gint +static int lua_util_normalize_prob(lua_State *L) { LUA_TRACE_POINT; - gdouble x, bias = 0.5; + double x, bias = 0.5; x = lua_tonumber(L, 1); @@ -2053,7 +2053,7 @@ lua_util_normalize_prob(lua_State *L) return 1; } -static gint +static int lua_util_caseless_hash(lua_State *L) { LUA_TRACE_POINT; @@ -2082,7 +2082,7 @@ lua_util_caseless_hash(lua_State *L) return 1; } -static gint +static int lua_util_caseless_hash_fast(lua_State *L) { LUA_TRACE_POINT; @@ -2118,14 +2118,14 @@ lua_util_caseless_hash_fast(lua_State *L) return 1; } -static gint +static int lua_util_is_utf_spoofed(lua_State *L) { LUA_TRACE_POINT; gsize l1, l2; - gint ret, nres = 2; - const gchar *s1 = lua_tolstring(L, 1, &l1), - *s2 = lua_tolstring(L, 2, &l2); + int ret, nres = 2; + const char *s1 = lua_tolstring(L, 1, &l1), + *s2 = lua_tolstring(L, 2, &l2); static USpoofChecker *spc, *spc_sgl; UErrorCode uc_err = U_ZERO_ERROR; @@ -2195,12 +2195,12 @@ lua_util_is_utf_spoofed(lua_State *L) return nres; } -static gint +static int lua_util_is_utf_mixed_script(lua_State *L) { LUA_TRACE_POINT; gsize len_of_string; - const guchar *string_to_check = lua_tolstring(L, 1, &len_of_string); + const unsigned char *string_to_check = lua_tolstring(L, 1, &len_of_string); UScriptCode last_script_code = USCRIPT_INVALID_CODE; UErrorCode uc_err = U_ZERO_ERROR; @@ -2250,17 +2250,17 @@ lua_util_is_utf_mixed_script(lua_State *L) return 1; } -static gint +static int lua_util_get_string_stats(lua_State *L) { LUA_TRACE_POINT; - gint num_of_digits = 0, num_of_letters = 0; + int num_of_digits = 0, num_of_letters = 0; struct rspamd_lua_text *t; t = lua_check_text_or_string(L, 1); if (t) { - const gchar *p = t->start, *end = t->start + t->len; + const char *p = t->start, *end = t->start + t->len; while (p < end) { if (g_ascii_isdigit(*p)) { num_of_digits++; @@ -2287,11 +2287,11 @@ lua_util_get_string_stats(lua_State *L) } -static gint +static int lua_util_is_utf_outside_range(lua_State *L) { LUA_TRACE_POINT; - gint ret; + int ret; struct rspamd_lua_text *t = lua_check_text_or_string(L, 1); uint32_t range_start = lua_tointeger(L, 2); uint32_t range_end = lua_tointeger(L, 3); @@ -2358,11 +2358,11 @@ lua_util_is_utf_outside_range(lua_State *L) } -static gint +static int lua_util_get_hostname(lua_State *L) { LUA_TRACE_POINT; - gchar *hostbuf; + char *hostbuf; gsize hostlen; hostlen = sysconf(_SC_HOST_NAME_MAX); @@ -2383,20 +2383,20 @@ lua_util_get_hostname(lua_State *L) return 1; } -static gint +static int lua_util_parse_content_type(lua_State *L) { return lua_parsers_parse_content_type(L); } -static gint +static int lua_util_mime_header_encode(lua_State *L) { LUA_TRACE_POINT; gsize len; - const gchar *hdr = luaL_checklstring(L, 1, &len); - gchar *encoded; + const char *hdr = luaL_checklstring(L, 1, &len); + char *encoded; if (!hdr) { return luaL_error(L, "invalid arguments"); @@ -2409,7 +2409,7 @@ lua_util_mime_header_encode(lua_State *L) return 1; } -static gint +static int lua_util_is_valid_utf8(lua_State *L) { LUA_TRACE_POINT; @@ -2435,7 +2435,7 @@ lua_util_is_valid_utf8(lua_State *L) return 1; } -static gint +static int lua_util_has_obscured_unicode(lua_State *L) { LUA_TRACE_POINT; @@ -2464,12 +2464,12 @@ lua_util_has_obscured_unicode(lua_State *L) return 1; } -static gint +static int lua_util_readline(lua_State *L) { LUA_TRACE_POINT; - const gchar *prompt = ""; - gchar *input = NULL; + const char *prompt = ""; + char *input = NULL; if (lua_type(L, 1) == LUA_TSTRING) { prompt = lua_tostring(L, 1); @@ -2483,7 +2483,7 @@ lua_util_readline(lua_State *L) replxx_history_add(rx_instance, ""); } - input = (gchar *) replxx_input(rx_instance, prompt); + input = (char *) replxx_input(rx_instance, prompt); if (input) { lua_pushstring(L, input); @@ -2515,11 +2515,11 @@ lua_util_readline(lua_State *L) return 1; } -static gint +static int lua_util_readpassphrase(lua_State *L) { LUA_TRACE_POINT; - gchar test_password[8192]; + char test_password[8192]; gsize r; r = rspamd_read_passphrase(test_password, sizeof(test_password), 0, NULL); @@ -2537,12 +2537,12 @@ lua_util_readpassphrase(lua_State *L) return 1; } -static gint +static int lua_util_file_exists(lua_State *L) { LUA_TRACE_POINT; - const gchar *fname = luaL_checkstring(L, 1); - gint serrno; + const char *fname = luaL_checkstring(L, 1); + int serrno; if (fname) { if (access(fname, R_OK) == -1) { @@ -2562,13 +2562,13 @@ lua_util_file_exists(lua_State *L) return 2; } -static gint +static int lua_util_mkdir(lua_State *L) { LUA_TRACE_POINT; - const gchar *dname = luaL_checkstring(L, 1); + const char *dname = luaL_checkstring(L, 1); gboolean recursive = FALSE; - gint r = -1; + int r = -1; if (dname) { if (lua_isboolean(L, 2)) { @@ -2626,14 +2626,14 @@ lua_util_mkdir(lua_State *L) } -static gint +static int lua_util_umask(lua_State *L) { LUA_TRACE_POINT; mode_t mask = 0, old; if (lua_type(L, 1) == LUA_TSTRING) { - const gchar *str = lua_tostring(L, 1); + const char *str = lua_tostring(L, 1); if (str[0] == '0') { /* e.g. '022' */ @@ -2658,7 +2658,7 @@ lua_util_umask(lua_State *L) return 1; } -static gint +static int lua_util_isatty(lua_State *L) { LUA_TRACE_POINT; @@ -3418,7 +3418,7 @@ lua_util_btc_polymod(lua_State *L) } for (lua_pushnil(L); lua_next(L, 1); lua_pop(L, 1)) { - guint8 c0 = c >> 35; + uint8_t c0 = c >> 35; uint64_t d = lua_tointeger(L, -1); c = ((c & 0x07ffffffff) << 5) ^ d; @@ -3447,7 +3447,7 @@ lua_util_parse_smtp_date(lua_State *L) } -static gint +static int lua_load_util(lua_State *L) { lua_newtable(L); @@ -3456,7 +3456,7 @@ lua_load_util(lua_State *L) return 1; } -static gint +static int lua_load_int64(lua_State *L) { lua_newtable(L); @@ -3480,7 +3480,7 @@ static int lua_int64_tostring(lua_State *L) { int64_t n = lua_check_int64(L, 1); - gchar buf[32]; + char buf[32]; bool is_signed = false; if (lua_isboolean(L, 2)) { @@ -3547,7 +3547,7 @@ static int lua_int64_tonumber(lua_State *L) { int64_t n = lua_check_int64(L, 1); - gdouble d; + double d; d = n; lua_pushinteger(L, d); @@ -3559,7 +3559,7 @@ static int lua_int64_hex(lua_State *L) { int64_t n = lua_check_int64(L, 1); - gchar buf[32]; + char buf[32]; rspamd_snprintf(buf, sizeof(buf), "%XL", n); lua_pushstring(L, buf); diff --git a/src/lua/lua_worker.c b/src/lua/lua_worker.c index 2b9856b08..b18e9e515 100644 --- a/src/lua/lua_worker.c +++ b/src/lua/lua_worker.c @@ -61,14 +61,14 @@ const luaL_reg worker_reg[] = { {NULL, NULL}}; static struct rspamd_worker * -lua_check_worker(lua_State *L, gint pos) +lua_check_worker(lua_State *L, int pos) { void *ud = rspamd_lua_check_udata(L, pos, rspamd_worker_classname); luaL_argcheck(L, ud != NULL, pos, "'worker' expected"); return ud ? *((struct rspamd_worker **) ud) : NULL; } -static gint +static int lua_worker_get_stat(lua_State *L) { struct rspamd_worker *w = lua_check_worker(L, 1); @@ -77,7 +77,7 @@ lua_worker_get_stat(lua_State *L) rspamd_mempool_stat_t mem_st; struct rspamd_stat *stat, stat_copy; ucl_object_t *top, *sub; - gint i; + int i; uint64_t spam = 0, ham = 0; memset(&mem_st, 0, sizeof(mem_st)); @@ -150,7 +150,7 @@ lua_worker_get_stat(lua_State *L) return 1; } -static gint +static int lua_worker_get_name(lua_State *L) { struct rspamd_worker *w = lua_check_worker(L, 1); @@ -165,7 +165,7 @@ lua_worker_get_name(lua_State *L) return 1; } -static gint +static int lua_worker_get_index(lua_State *L) { struct rspamd_worker *w = lua_check_worker(L, 1); @@ -180,7 +180,7 @@ lua_worker_get_index(lua_State *L) return 1; } -static gint +static int lua_worker_get_count(lua_State *L) { struct rspamd_worker *w = lua_check_worker(L, 1); @@ -195,7 +195,7 @@ lua_worker_get_count(lua_State *L) return 1; } -static gint +static int lua_worker_get_pid(lua_State *L) { struct rspamd_worker *w = lua_check_worker(L, 1); @@ -211,7 +211,7 @@ lua_worker_get_pid(lua_State *L) } -static gint +static int lua_worker_is_scanner(lua_State *L) { struct rspamd_worker *w = lua_check_worker(L, 1); @@ -226,7 +226,7 @@ lua_worker_is_scanner(lua_State *L) return 1; } -static gint +static int lua_worker_is_primary_controller(lua_State *L) { struct rspamd_worker *w = lua_check_worker(L, 1); @@ -249,8 +249,8 @@ struct rspamd_control_cbdata { struct ev_loop *event_loop; struct rspamd_async_session *session; enum rspamd_control_type cmd; - gint cbref; - gint fd; + int cbref; + int fd; }; static gboolean @@ -284,8 +284,8 @@ lua_worker_control_session_dtor(void *ud) static gboolean lua_worker_control_handler(struct rspamd_main *rspamd_main, struct rspamd_worker *worker, - gint fd, - gint attached_fd, + int fd, + int attached_fd, struct rspamd_control_command *cmd, gpointer ud) { @@ -293,7 +293,7 @@ lua_worker_control_handler(struct rspamd_main *rspamd_main, struct rspamd_control_cbdata *cbd = (struct rspamd_control_cbdata *) ud; rspamd_mempool_t *pool; lua_State *L; - gint err_idx, status; + int err_idx, status; L = cbd->L; pool = cbd->pool; @@ -403,13 +403,13 @@ lua_worker_control_handler(struct rspamd_main *rspamd_main, return TRUE; } -static gint +static int lua_worker_add_control_handler(lua_State *L) { struct rspamd_worker *w = lua_check_worker(L, 1); struct rspamd_config *cfg = lua_check_config(L, 2); struct ev_loop *event_loop = lua_check_ev_base(L, 3); - const gchar *cmd_name = luaL_checkstring(L, 4); + const char *cmd_name = luaL_checkstring(L, 4); enum rspamd_control_type cmd; struct rspamd_control_cbdata *cbd; @@ -454,7 +454,7 @@ lua_worker_jemalloc_stats_cb(void *ud, const char *msg) } #endif -static gint +static int lua_worker_get_mem_stats(lua_State *L) { struct rspamd_worker *w = lua_check_worker(L, 1); @@ -474,9 +474,9 @@ lua_worker_get_mem_stats(lua_State *L) } struct rspamd_lua_process_cbdata { - gint sp[2]; - gint func_cbref; - gint cb_cbref; + int sp[2]; + int func_cbref; + int cb_cbref; gboolean replied; gboolean is_error; pid_t cpid; @@ -494,7 +494,7 @@ static void rspamd_lua_execute_lua_subprocess(lua_State *L, struct rspamd_lua_process_cbdata *cbdata) { - gint err_idx, r; + int err_idx, r; uint64_t wlen = 0; lua_pushcfunction(L, &rspamd_lua_traceback); @@ -503,7 +503,7 @@ rspamd_lua_execute_lua_subprocess(lua_State *L, lua_rawgeti(L, LUA_REGISTRYINDEX, cbdata->func_cbref); if (lua_pcall(L, 0, 1, err_idx) != 0) { - const gchar *s = lua_tostring(L, -1); + const char *s = lua_tostring(L, -1); gsize slen = strlen(s); msg_err("call to subprocess failed: %s", s); @@ -549,10 +549,10 @@ rspamd_lua_execute_lua_subprocess(lua_State *L, static void rspamd_lua_call_on_complete(lua_State *L, struct rspamd_lua_process_cbdata *cbdata, - const gchar *err_msg, - const gchar *data, gsize datalen) + const char *err_msg, + const char *data, gsize datalen) { - gint err_idx; + int err_idx; lua_pushcfunction(L, &rspamd_lua_traceback); err_idx = lua_gettop(L); @@ -588,7 +588,7 @@ rspamd_lua_cld_handler(struct rspamd_worker_signal_handler *sigh, void *ud) struct rspamd_srv_command srv_cmd; lua_State *L; pid_t died; - gint res = 0; + int res = 0; /* Are we called by a correct children ? */ died = waitpid(cbdata->cpid, &res, WNOHANG); @@ -673,7 +673,7 @@ rspamd_lua_subprocess_io(EV_P_ ev_io *w, int revents) cbdata->io_buf->len += r; if (cbdata->io_buf->len == sizeof(uint64_t)) { - memcpy((guchar *) &sz, cbdata->io_buf->str, sizeof(sz)); + memcpy((unsigned char *) &sz, cbdata->io_buf->str, sizeof(sz)); if (sz & (1ULL << 63)) { cbdata->is_error = TRUE; @@ -718,7 +718,7 @@ rspamd_lua_subprocess_io(EV_P_ ev_io *w, int revents) cbdata->io_buf->len += r; if (cbdata->io_buf->len == cbdata->sz) { - gchar rep[4]; + char rep[4]; ev_io_stop(cbdata->event_loop, &cbdata->ev); /* Finished reading data */ @@ -742,18 +742,18 @@ rspamd_lua_subprocess_io(EV_P_ ev_io *w, int revents) } } -static gint +static int lua_worker_spawn_process(lua_State *L) { struct rspamd_worker *w = lua_check_worker(L, 1); struct rspamd_lua_process_cbdata *cbdata; struct rspamd_abstract_worker_ctx *actx; struct rspamd_srv_command srv_cmd; - const gchar *cmdline = NULL, *input = NULL, *proctitle = NULL; + const char *cmdline = NULL, *input = NULL, *proctitle = NULL; gsize inputlen = 0; pid_t pid; GError *err = NULL; - gint func_cbref, cb_cbref; + int func_cbref, cb_cbref; if (!rspamd_lua_parse_table_arguments(L, 2, &err, RSPAMD_LUA_PARSE_ARGUMENTS_DEFAULT, @@ -806,8 +806,8 @@ lua_worker_spawn_process(lua_State *L) } else if (pid == 0) { /* Child */ - gint rc; - gchar inbuf[4]; + int rc; + char inbuf[4]; rspamd_log_on_fork(w->cf->type, w->srv->cfg, w->srv->logger); rc = ottery_init(w->srv->cfg->libs_ctx->ottery_cfg); diff --git a/src/lua/lua_xmlrpc.c b/src/lua/lua_xmlrpc.c index efb2b22e6..67e8840d5 100644 --- a/src/lua/lua_xmlrpc.c +++ b/src/lua/lua_xmlrpc.c @@ -60,26 +60,26 @@ enum lua_xmlrpc_stack { struct lua_xmlrpc_ud { enum lua_xmlrpc_state parser_state; GQueue *st; - gint param_count; + int param_count; gboolean got_text; lua_State *L; }; static void xmlrpc_start_element(GMarkupParseContext *context, - const gchar *name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *name, + const char **attribute_names, + const char **attribute_values, gpointer user_data, GError **error); static void xmlrpc_end_element(GMarkupParseContext *context, - const gchar *element_name, + const char *element_name, gpointer user_data, GError **error); static void xmlrpc_error(GMarkupParseContext *context, GError *error, gpointer user_data); static void xmlrpc_text(GMarkupParseContext *context, - const gchar *text, + const char *text, gsize text_len, gpointer user_data, GError **error); @@ -100,9 +100,9 @@ xmlrpc_error_quark(void) static void xmlrpc_start_element(GMarkupParseContext *context, - const gchar *name, - const gchar **attribute_names, - const gchar **attribute_values, + const char *name, + const char **attribute_names, + const char **attribute_values, gpointer user_data, GError **error) { @@ -328,7 +328,7 @@ xmlrpc_start_element(GMarkupParseContext *context, static void xmlrpc_end_element(GMarkupParseContext *context, - const gchar *name, + const char *name, gpointer user_data, GError **error) { @@ -521,7 +521,7 @@ xmlrpc_end_element(GMarkupParseContext *context, case read_array_element: /* Got tag value */ if (g_ascii_strcasecmp(name, "value") == 0) { - guint tbl_len = rspamd_lua_table_size(ud->L, -2); + unsigned int tbl_len = rspamd_lua_table_size(ud->L, -2); lua_rawseti(ud->L, -2, tbl_len + 1); msg_debug_xmlrpc("set array element idx: %d", tbl_len + 1); ud->parser_state = read_array_value; @@ -547,14 +547,14 @@ xmlrpc_end_element(GMarkupParseContext *context, static void xmlrpc_text(GMarkupParseContext *context, - const gchar *text, + const char *text, gsize text_len, gpointer user_data, GError **error) { struct lua_xmlrpc_ud *ud = user_data; gulong num; - gdouble dnum; + double dnum; /* Strip line */ while (text_len > 0 && g_ascii_isspace(*text)) { @@ -599,11 +599,11 @@ xmlrpc_error(GMarkupParseContext *context, GError *error, gpointer user_data) msg_err("xmlrpc parser error: %s", error->message); } -static gint +static int lua_xmlrpc_parse_reply(lua_State *L) { LUA_TRACE_POINT; - const gchar *data; + const char *data; GMarkupParseContext *ctx; GError *err = NULL; struct lua_xmlrpc_ud ud; @@ -635,14 +635,14 @@ lua_xmlrpc_parse_reply(lua_State *L) return 1; } -static gint +static int lua_xmlrpc_parse_table(lua_State *L, - gint pos, - gchar *databuf, - gint pr, + int pos, + char *databuf, + int pr, gsize size) { - gint r = pr, num; + int r = pr, num; double dnum; r += rspamd_snprintf(databuf + r, size - r, "<struct>"); @@ -705,13 +705,13 @@ lua_xmlrpc_parse_table(lua_State *L, * Internal limitation: xmlrpc request must NOT be more than * BUFSIZ * 2 (16384 bytes) */ -static gint +static int lua_xmlrpc_make_request(lua_State *L) { LUA_TRACE_POINT; - gchar databuf[BUFSIZ * 2]; - const gchar *func; - gint r, top, i, num; + char databuf[BUFSIZ * 2]; + const char *func; + int r, top, i, num; double dnum; func = luaL_checkstring(L, 1); @@ -781,7 +781,7 @@ lua_xmlrpc_make_request(lua_State *L) return 1; } -static gint +static int lua_load_xmlrpc(lua_State *L) { lua_newtable(L); |