Module: kamailio
Branch: master
Commit: a30a6ceb5d7616bc135377b1dc507bd2eeeab876
URL:
https://github.com/kamailio/kamailio/commit/a30a6ceb5d7616bc135377b1dc507bd…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-01-17T08:29:13+01:00
app_lua: added internal alternative to luaL_openlib()
- it was deprecated in Lua API, no longer available in newer versions [wip]
---
Modified: src/modules/app_lua/app_lua_api.c
---
Diff:
https://github.com/kamailio/kamailio/commit/a30a6ceb5d7616bc135377b1dc507bd…
Patch:
https://github.com/kamailio/kamailio/commit/a30a6ceb5d7616bc135377b1dc507bd…
---
diff --git a/src/modules/app_lua/app_lua_api.c b/src/modules/app_lua/app_lua_api.c
index 8b572d2382..6dffde1119 100644
--- a/src/modules/app_lua/app_lua_api.c
+++ b/src/modules/app_lua/app_lua_api.c
@@ -184,6 +184,34 @@ int sr_lua_reload_module(unsigned int reload)
return 0;
}
+/**
+ *
+ */
+void ksr_luaL_openlib_mode(lua_State *L, const char *libname,
+ const luaL_Reg *lfuncs, int nup, int mode)
+{
+ if(mode) {
+ lua_getglobal(L, libname);
+ if (lua_isnil(L, -1)) {
+ lua_pop(L, 1);
+ lua_newtable(L);
+ }
+ } else {
+ lua_newtable(L);
+ }
+ luaL_setfuncs(L, lfuncs, 0);
+ lua_setglobal(L, libname);
+}
+
+/**
+ *
+ */
+void ksr_luaL_openlib(lua_State *L, const char *libname,
+ const luaL_Reg *lfuncs, int nup)
+{
+ ksr_luaL_openlib_mode(L, libname, lfuncs, nup, 0);
+}
+
/**
*
*/