aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lua/lua_common.c14
-rw-r--r--src/lua/lua_common.h13
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"