Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
civetweb_lua.h
Go to the documentation of this file.
1/* Copyright (c) 2015-2021 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#define LUA_COMPAT_LOG10
31#define LUA_COMPAT_APIINTCASTS
32
33#if defined(__cplusplus)
34extern "C" {
35#endif
36#include "lauxlib.h"
37#include "lua.h"
38#include "lualib.h"
39#if defined(__cplusplus)
40} /* extern "C" */
41#endif
42
43#ifndef LUA_VERSION_NUM
44#error "Unknown Lua version"
45
46#elif LUA_VERSION_NUM == 501
47/* Lua 5.1 detected */
48#define LUA_OK 0
49#define LUA_ERRGCMM 999 /* not supported */
50#define mg_lua_load(a, b, c, d, e) lua_load(a, b, c, d)
51#define lua_rawlen lua_objlen
52#define lua_newstate(a, b) \
53 luaL_newstate() /* Must use luaL_newstate() for 64 bit target */
54#define lua_pushinteger lua_pushnumber
55#define luaL_newlib(L, t) \
56 { \
57 luaL_Reg const *r = t; \
58 while (r->name) { \
59 lua_register(L, r->name, r->func); \
60 r++; \
61 } \
62 }
63#define luaL_setfuncs(L, r, u) lua_register(L, r->name, r->func)
64
65#elif LUA_VERSION_NUM == 502
66/* Lua 5.2 detected */
67#define mg_lua_load lua_load
68
69#elif LUA_VERSION_NUM == 503
70/* Lua 5.3 detected */
71#define mg_lua_load lua_load
72
73#elif LUA_VERSION_NUM == 504
74/* Lua 5.4 detected */
75#define mg_lua_load lua_load
76
77#else
78#error "Lua version not supported (yet?)"
79
80#endif
81
82#if defined(LUA_VERSION_MAKEFILE)
83#if LUA_VERSION_MAKEFILE != LUA_VERSION_NUM
84#error \
85 "Mismatch between Lua version specified in Makefile and Lua version in lua.h"
86#endif
87#endif
88
89#endif /* #ifndef CIVETWEB_LUA_H */