diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-21 16:07:25 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-21 16:07:25 +0100 |
commit | 2a7ad799437105f91dfe7e89ba50de655c1d06eb (patch) | |
tree | 9edd21cf40959d0c143b906541e41aa9c5d261e6 /src/lua | |
parent | fc08274623ea616dff051d5555755dc3cfbebee8 (diff) | |
download | rspamd-2a7ad799437105f91dfe7e89ba50de655c1d06eb.tar.gz rspamd-2a7ad799437105f91dfe7e89ba50de655c1d06eb.zip |
[Minor] Add lua_geti compat method
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_common.c | 14 | ||||
-rw-r--r-- | src/lua/lua_common.h | 13 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 9c4a5d8d1..d53ebbc48 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -2539,4 +2539,16 @@ rspamd_lua_universal_pcall (lua_State *L, gint cbref, const gchar* strloc, va_end (ap); return true; -}
\ No newline at end of file +} + +#if defined( LUA_VERSION_NUM ) && LUA_VERSION_NUM <= 502 +gint +rspamd_lua_geti (lua_State *L, int pos, int i) +{ + pos = lua_absindex (L, pos); + lua_pushinteger (L, i); + lua_gettable (L, pos); + + return lua_type (L, -1); +} +#endif
\ No newline at end of file diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h index 296b8f326..f9ec8e2e3 100644 --- a/src/lua/lua_common.h +++ b/src/lua/lua_common.h @@ -605,6 +605,19 @@ gchar *rspamd_lua_get_module_name (lua_State *L); bool rspamd_lua_universal_pcall (lua_State *L, gint cbref, const gchar* strloc, gint nret, const gchar *args, GError **err, ...); +/** + * Wrapper for lua_geti from lua 5.3 + * @param L + * @param index + * @param i + * @return + */ +#if defined( LUA_VERSION_NUM ) && LUA_VERSION_NUM <= 502 +gint rspamd_lua_geti (lua_State *L, int index, int i); +#else +#define rspamd_lua_geti lua_geti +#endif + /* Paths defs */ #define RSPAMD_CONFDIR_INDEX "CONFDIR" #define RSPAMD_LOCAL_CONFDIR_INDEX "LOCAL_CONFDIR" |