void mattorch_init(void) { /* Set CWD before starting Lua */ lua_executable_dir("./lua"); /* Declare a Lua State, open the Lua State and load all libraries */ L = lua_open(); lua_gc(L, LUA_GCSTOP, 0); luaL_openlibs(L); lua_gc(L, LUA_GCRESTART, 0); }
void sl_init(void) { /* Set CWD before starting Lua */ lua_executable_dir("./lua"); /* Declare a Lua State, open the Lua State and load all libraries */ L = lua_open(); luaL_openlibs(L); sl_stack = L; }
const char * lua_cpath_default() { if (! s_cpath_default) { const char *dir = lua_executable_dir(0); s_cpath_default = LUA_CPATH_DEFAULT_STATIC; if (dir) s_cpath_default = relocate_path(dir, LUA_CPATH_DEFAULT_STATIC); } return s_cpath_default; }
static int lua_execdir(lua_State *L) { const char *s = 0; #if HAVE_LUA_EXECUTABLE_DIR s = lua_executable_dir(0); #endif if (s && s[0]) lua_pushstring(L, s); else lua_pushnil(L); return 1; }
int main (int argc, char **argv) { int status; struct Smain s; #if HAVE_LUA_EXECUTABLE_DIR lua_executable_dir(argv[0]); #endif lua_State *L = lua_open(); /* create state */ if (L == NULL) { l_message(argv[0], "cannot create state: not enough memory"); return EXIT_FAILURE; } s.argc = argc; s.argv = argv; status = lua_cpcall(L, &pmain, &s); report(L, status); lua_close(L); return (status || s.status) ? EXIT_FAILURE : EXIT_SUCCESS; }