36 #if !defined(LUA_PATH)
37 #define LUA_PATH "LUA_PATH"
40 #if !defined(LUA_CPATH)
41 #define LUA_CPATH "LUA_CPATH"
44 #define LUA_PATHSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
46 #define LUA_PATHVERSION LUA_PATH LUA_PATHSUFFIX
47 #define LUA_CPATHVERSION LUA_CPATH LUA_PATHSUFFIX
58 #if !defined (LUA_PATH_SEP)
59 #define LUA_PATH_SEP ";"
61 #if !defined (LUA_PATH_MARK)
62 #define LUA_PATH_MARK "?"
64 #if !defined (LUA_EXEC_DIR)
65 #define LUA_EXEC_DIR "!"
67 #if !defined (LUA_IGMARK)
68 #define LUA_IGMARK "-"
78 #if !defined(LUA_CSUBSEP)
79 #define LUA_CSUBSEP LUA_DIRSEP
82 #if !defined(LUA_LSUBSEP)
83 #define LUA_LSUBSEP LUA_DIRSEP
88 #define LUA_POF "luaopen_"
95 #define CLIBS "_CLIBS"
97 #define LIB_FAIL "open"
104 #define setprogdir(L) ((void)0)
116 #if defined(LUA_USE_DLOPEN)
134 void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL));
150 #elif defined(LUA_DL_DLL)
162 #if !defined(LUA_LLE_FLAGS)
163 #define LUA_LLE_FLAGS 0
168 char buff[MAX_PATH + 1];
170 DWORD nsize =
sizeof(buff)/
sizeof(
char);
171 DWORD
n = GetModuleFileNameA(NULL, buff, nsize);
172 if (n == 0 || n == nsize || (lb = strrchr(buff,
'\\')) == NULL)
173 luaL_error(L,
"unable to get ModuleFileName");
183 int error = GetLastError();
185 if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
186 NULL, error, 0, buffer,
sizeof(buffer)/
sizeof(
char), NULL))
193 FreeLibrary((HMODULE)lib);
198 HMODULE lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS);
200 if (lib == NULL) pusherror(L);
207 if (f == NULL) pusherror(L);
222 #define LIB_FAIL "absent"
225 #define DLMSG "dynamic libraries not enabled; check your Lua installation"
276 for (; n >= 1; n--) {
288 reg =
ll_load(L, path, *sym ==
'*');
289 if (reg == NULL)
return ERRLIB;
330 FILE *f = fopen(filename,
"r");
331 if (f == NULL)
return 0;
340 if (*path ==
'\0')
return NULL;
342 if (l == NULL) l = path + strlen(path);
351 const char *dirsep) {
376 if (f != NULL)
return 1;
387 const char *dirsep) {
393 return searchpath(L, name, path,
".", dirsep);
404 " from file " LUA_QS ":\n\t%s",
410 const char *filename;
413 if (filename == NULL)
return 1;
428 if (stat !=
ERRFUNC)
return stat;
439 if (filename == NULL)
return 1;
445 const char *filename;
447 const char *
p = strchr(name,
'.');
449 if (p == NULL)
return 0;
452 if (filename == NULL)
return 1;
453 if ((stat =
loadfunc(L, filename, name)) != 0) {
540 #if defined(LUA_COMPAT_MODULE)
559 for (i = 2; i <=
n; i++) {
575 dot = strrchr(modname,
'.');
576 if (dot == NULL) dot = modname;
637 const char *envname2,
const char *def) {
638 const char *path = getenv(envname1);
640 path = getenv(envname2);
641 if (path == NULL ||
noenv(L))
646 LUA_PATH_SEP
AUXMARK LUA_PATH_SEP);
658 #if defined(LUA_COMPAT_MODULE)
666 #if defined(LUA_COMPAT_MODULE)
681 for (i=0; searchers[
i] != NULL; i++) {
699 #if defined(LUA_COMPAT_LOADERS)
LUA_API void lua_rawgeti(lua_State *L, int idx, int n)
LUALIB_API void luaL_addvalue(luaL_Buffer *B)
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
#define lua_pushcfunction(L, f)
LUA_API void lua_getfield(lua_State *L, int idx, const char *k)
static int ll_searchpath(lua_State *L)
static int ll_require(lua_State *L)
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
static void findloader(lua_State *L, const char *name)
LUA_API void lua_settop(lua_State *L, int idx)
static const luaL_Reg pk_funcs[]
static int loadfunc(lua_State *L, const char *filename, const char *modname)
#define LUA_CPATH_DEFAULT
LUA_API void lua_pushboolean(lua_State *L, int b)
static int searcher_C(lua_State *L)
LUALIB_API int luaL_getsubtable(lua_State *L, int idx, const char *fname)
static l_noret error(LoadState *S, const char *why)
LUALIB_API void luaL_checktype(lua_State *L, int narg, int t)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
LUA_API int lua_gettop(lua_State *L)
static int ll_module(lua_State *L)
LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction fn, int n)
static void dooptions(lua_State *L, int n)
static void createsearcherstable(lua_State *L)
LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar)
static int ll_loadlib(lua_State *L)
static int checkload(lua_State *L, int stat, const char *filename)
int(* lua_CFunction)(lua_State *L)
#define luaL_loadfile(L, f)
GLdouble GLdouble GLdouble b
#define lua_upvalueindex(i)
static void * ll_load(lua_State *L, const char *path, int seeglb)
GLsizei const char ** path
LUALIB_API const char * luaL_gsub(lua_State *L, const char *s, const char *p, const char *r)
LUA_API int lua_isstring(lua_State *L, int idx)
static int ll_seeall(lua_State *L)
static void ll_addtoclib(lua_State *L, const char *path, void *plib)
static void ll_unloadlib(void *lib)
static void set_env(lua_State *L)
LUA_API int lua_toboolean(lua_State *L, int idx)
#define lua_pushglobaltable(L)
LUAMOD_API int luaopen_package(lua_State *L)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
LUA_API const char * lua_pushlstring(lua_State *L, const char *s, size_t len)
LUA_API int lua_getmetatable(lua_State *L, int objindex)
LUA_API int lua_setmetatable(lua_State *L, int objindex)
LUA_API void lua_remove(lua_State *L, int idx)
void init()
Initializes the gui subsystems.
LUA_API void lua_pushnil(lua_State *L)
LUA_API const char * lua_setupvalue(lua_State *L, int funcindex, int n)
#define lua_pushliteral(L, s)
LUA_API void * lua_touserdata(lua_State *L, int idx)
static void * ll_checkclib(lua_State *L, const char *path)
static void modinit(lua_State *L, const char *modname)
static int searcher_preload(lua_State *L)
LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
#define lua_isfunction(L, n)
static const char * pushnexttemplate(lua_State *L, const char *path)
static void setpath(lua_State *L, const char *fieldname, const char *envname1, const char *envname2, const char *def)
#define lua_tostring(L, i)
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
LUA_API void lua_rawseti(lua_State *L, int idx, int n)
static int searcher_Croot(lua_State *L)
LUA_API int lua_iscfunction(lua_State *L, int idx)
static int funcname(LexState *ls, expdesc *v)
LUA_API void lua_insert(lua_State *L, int idx)
LUA_API void lua_pushvalue(lua_State *L, int idx)
static int ll_loadfunc(lua_State *L, const char *path, const char *sym)
#define luaL_newlib(L, l)
#define lua_call(L, n, r)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
static int searcher_Lua(lua_State *L)
GLuint const GLchar * name
#define LUA_REGISTRYINDEX
static int readable(const char *filename)
static int noenv(lua_State *L)
#define lua_istable(L, n)
static int gctm(lua_State *L)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
static const luaL_Reg ll_funcs[]
LUALIB_API int luaL_len(lua_State *L, int idx)
static const char * searchpath(lua_State *L, const char *name, const char *path, const char *sep, const char *dirsep)
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
static const char * findfile(lua_State *L, const char *name, const char *pname, const char *dirsep)
LUALIB_API void luaL_pushmodule(lua_State *L, const char *modname, int sizehint)
#define luaL_optstring(L, n, d)
LUA_API const char * lua_pushstring(lua_State *L, const char *s)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
#define luaL_checkstring(L, n)