1 /* Copyright (c) 2015-2017 the Civetweb developers 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a copy 4 * of this software and associated documentation files (the "Software"), to deal 5 * in the Software without restriction, including without limitation the rights 6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 * copies of the Software, and to permit persons to whom the Software is 8 * furnished to do so, subject to the following conditions: 9 * 10 * The above copyright notice and this permission notice shall be included in 11 * all copies or substantial portions of the Software. 12 * 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 * THE SOFTWARE. 20 */ 21 22 /* This header is intended to support Lua 5.1, Lua 5.2 and Lua 5.3 in the same 23 * C source code. 24 */ 25 26 #ifndef CIVETWEB_LUA_H 27 #define CIVETWEB_LUA_H 28 29 #define LUA_LIB 30 #include "lauxlib.h" 31 #include "lua.h" 32 #include "lualib.h" 33 34 #ifndef LUA_VERSION_NUM 35 #error "Unknown Lua version" 36 37 #elif LUA_VERSION_NUM == 501 38 /* Lua 5.1 detected */ 39 #define LUA_OK 0 40 #define LUA_ERRGCMM 999 /* not supported */ 41 #define mg_lua_load(a, b, c, d, e) lua_load(a, b, c, d) 42 #define lua_rawlen lua_objlen 43 #define lua_newstate(a, b) \ 44 luaL_newstate() /* Must use luaL_newstate() for 64 bit target */ 45 #define lua_pushinteger lua_pushnumber 46 #define luaL_newlib(L, t) \ 47 { \ 48 luaL_Reg const *r = t; \ 49 while (r->name) { \ 50 lua_register(L, r->name, r->func); \ 51 r++; \ 52 } \ 53 } 54 #define luaL_setfuncs(L, r, u) lua_register(L, r->name, r->func) 55 56 #elif LUA_VERSION_NUM == 502 57 /* Lua 5.2 detected */ 58 #define mg_lua_load lua_load 59 60 #elif LUA_VERSION_NUM == 503 61 /* Lua 5.3 detected */ 62 #define mg_lua_load lua_load 63 64 #elif LUA_VERSION_NUM == 504 65 /* Lua 5.4 detected */ 66 #define mg_lua_load lua_load 67 68 #endif 69 70 #ifdef LUA_VERSION_MAKEFILE 71 #if LUA_VERSION_MAKEFILE != LUA_VERSION_NUM 72 #error \ 73 "Mismatch between Lua version specified in Makefile and Lua version in lua.h" 74 #endif 75 #endif 76 77 #endif /* #ifndef CIVETWEB_LUA_H */ 78