Add in_lua flag

In preparation of making config errors available to lua scripts,
instead outputting them via pline.
This commit is contained in:
Pasi Kallinen
2021-02-10 17:06:08 +02:00
parent 33ee596d68
commit 9576154690
6 changed files with 16 additions and 6 deletions

View File

@@ -1110,6 +1110,7 @@ nhl_init(void)
{
lua_State *L = luaL_newstate();
iflags.in_lua = TRUE;
luaL_openlibs(L);
nhl_set_package_path(L, "./?.lua");
@@ -1130,13 +1131,20 @@ nhl_init(void)
l_obj_register(L);
if (!nhl_loadlua(L, "nhlib.lua")) {
lua_close(L);
nhl_done(L);
return (lua_State *) 0;
}
return L;
}
void
nhl_done(lua_State *L)
{
lua_close(L);
iflags.in_lua = FALSE;
}
boolean
load_lua(const char *name)
{
@@ -1154,7 +1162,7 @@ load_lua(const char *name)
}
give_up:
lua_close(L);
nhl_done(L);
return ret;
}