Commit 8c118bf4 authored by Sergey Lyubka's avatar Sergey Lyubka

Exported mg_prepare_lua_environment()

parent 2e232b33
...@@ -161,7 +161,7 @@ static void reg_function(struct lua_State *L, const char *name, ...@@ -161,7 +161,7 @@ static void reg_function(struct lua_State *L, const char *name,
lua_rawset(L, -3); lua_rawset(L, -3);
} }
static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) { void mg_prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
const struct mg_request_info *ri = mg_get_request_info(conn); const struct mg_request_info *ri = mg_get_request_info(conn);
extern void luaL_openlibs(lua_State *); extern void luaL_openlibs(lua_State *);
int i; int i;
...@@ -171,6 +171,8 @@ static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) { ...@@ -171,6 +171,8 @@ static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
{ extern int luaopen_lsqlite3(lua_State *); luaopen_lsqlite3(L); } { extern int luaopen_lsqlite3(lua_State *); luaopen_lsqlite3(L); }
#endif #endif
if (conn == NULL) return;
// Register mg module // Register mg module
lua_newtable(L); lua_newtable(L);
...@@ -243,7 +245,7 @@ static int handle_lsp_request(struct mg_connection *conn, const char *path, ...@@ -243,7 +245,7 @@ static int handle_lsp_request(struct mg_connection *conn, const char *path,
} else { } else {
// We're not sending HTTP headers here, Lua page must do it. // We're not sending HTTP headers here, Lua page must do it.
if (ls == NULL) { if (ls == NULL) {
prepare_lua_environment(conn, L); mg_prepare_lua_environment(conn, L);
if (conn->ctx->callbacks.init_lua != NULL) { if (conn->ctx->callbacks.init_lua != NULL) {
conn->ctx->callbacks.init_lua(conn, L); conn->ctx->callbacks.init_lua(conn, L);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment