mirror of
https://github.com/lammertb/libhttp.git
synced 2025-09-04 12:42:09 +03:00
Rewrite open all Lua libraries
This commit is contained in:
@@ -557,9 +557,9 @@ static void set_absolute_path(char *options[], const char *option_name,
|
||||
|
||||
#ifdef USE_LUA
|
||||
#define main luatest_main
|
||||
#define luaL_openlibs lua_civet_openlibs
|
||||
#define luaL_openlibs lua_civet_open_all_libs
|
||||
struct lua_State;
|
||||
extern void lua_civet_openlibs(struct lua_State *L);
|
||||
extern void lua_civet_open_all_libs(struct lua_State *L);
|
||||
#include "../src/third_party/lua-5.2.3/src/lua.c"
|
||||
#undef main
|
||||
#endif
|
||||
|
@@ -982,12 +982,12 @@ static void prepare_lua_request_info(struct mg_connection *conn, lua_State *L)
|
||||
lua_rawset(L, -3);
|
||||
}
|
||||
|
||||
static void prepare_lua_environment(struct mg_context * ctx, struct mg_connection *conn, struct lua_websock_data *conn_list, lua_State *L, const char *script_name, int lua_env_type)
|
||||
void lua_civet_open_all_libs(lua_State *L)
|
||||
{
|
||||
{
|
||||
extern void luaL_openlibs(lua_State *);
|
||||
luaL_openlibs(L);
|
||||
|
||||
assert(ctx);
|
||||
}
|
||||
|
||||
#ifdef USE_LUA_SQLITE3
|
||||
{
|
||||
@@ -1007,6 +1007,11 @@ static void prepare_lua_environment(struct mg_context * ctx, struct mg_connectio
|
||||
luaopen_lfs(L);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void prepare_lua_environment(struct mg_context * ctx, struct mg_connection *conn, struct lua_websock_data *conn_list, lua_State *L, const char *script_name, int lua_env_type)
|
||||
{
|
||||
lua_civet_open_all_libs(L);
|
||||
|
||||
luaL_newmetatable(L, LUASOCKET);
|
||||
lua_pushliteral(L, "__index");
|
||||
@@ -1108,12 +1113,6 @@ static void prepare_lua_environment(struct mg_context * ctx, struct mg_connectio
|
||||
}
|
||||
}
|
||||
|
||||
void lua_civet_openlibs(lua_State *L)
|
||||
{
|
||||
static struct mg_context fake_ctx;
|
||||
prepare_lua_environment(&fake_ctx, NULL, NULL, L, NULL, 0);
|
||||
}
|
||||
|
||||
static int lua_error_handler(lua_State *L)
|
||||
{
|
||||
const char *error_msg = lua_isstring(L, -1) ? lua_tostring(L, -1) : "?\n";
|
||||
|
Reference in New Issue
Block a user