certmanager: Fix compat for MattJs old LuaSec fork
[prosody.git] / util-src / windows.c
index 121cc47153ba465ce25feeccde25a315e5c4f789..37f850e35070eccaf140721adece23d8c626c3dd 100644 (file)
 #include "lua.h"
 #include "lauxlib.h"
 
+#if (LUA_VERSION_NUM == 502)
+#define luaL_register(L, N, R) luaL_setfuncs(L, R, 0)
+#endif
+
 static int Lget_nameservers(lua_State *L) {
        char stack_buffer[1024]; // stack allocated buffer
        IP4_ARRAY* ips = (IP4_ARRAY*) stack_buffer;
@@ -58,7 +62,7 @@ static int Lget_consolecolor(lua_State *L) {
        
        if (console == INVALID_HANDLE_VALUE) return lerror(L, "GetStdHandle");
        if (!GetConsoleScreenBufferInfo(console, &info)) return lerror(L, "GetConsoleScreenBufferInfo");
-       if (!ReadConsoleOutputAttribute(console, &color, sizeof(WORD), info.dwCursorPosition, &read_len)) return lerror(L, "ReadConsoleOutputAttribute");
+       if (!ReadConsoleOutputAttribute(console, &color, 1, info.dwCursorPosition, &read_len)) return lerror(L, "ReadConsoleOutputAttribute");
 
        lua_pushnumber(L, color);
        return 1;
@@ -81,9 +85,9 @@ static const luaL_Reg Reg[] =
 };
 
 LUALIB_API int luaopen_util_windows(lua_State *L) {
-       luaL_register(L, "windows", Reg);
-       lua_pushliteral(L, "version");                  /** version */
+       lua_newtable(L);
+       luaL_register(L, NULL, Reg);
        lua_pushliteral(L, "-3.14");
-       lua_settable(L,-3);
+       lua_setfield(L, -2, "version");
        return 1;
 }