38#define LUA_PATH "LUA_PATH"
41#if !defined(LUA_CPATH)
42#define LUA_CPATH "LUA_CPATH"
45#define LUA_PATHSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
47#define LUA_PATHVERSION LUA_PATH LUA_PATHSUFFIX
48#define LUA_CPATHVERSION LUA_CPATH LUA_PATHSUFFIX
59#if !defined (LUA_PATH_SEP)
60#define LUA_PATH_SEP ";"
62#if !defined (LUA_PATH_MARK)
63#define LUA_PATH_MARK "?"
65#if !defined (LUA_EXEC_DIR)
66#define LUA_EXEC_DIR "!"
68#if !defined (LUA_IGMARK)
79#if !defined(LUA_CSUBSEP)
80#define LUA_CSUBSEP LUA_DIRSEP
83#if !defined(LUA_LSUBSEP)
84#define LUA_LSUBSEP LUA_DIRSEP
89#define LUA_POF "luaopen_"
98#define LIB_FAIL "open"
105#define setprogdir(L) ((void)0)
117#if defined(LUA_USE_DLOPEN)
135 void *lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL));
151#elif defined(LUA_DL_DLL)
163#if !defined(LUA_LLE_FLAGS)
164#define LUA_LLE_FLAGS 0
169 char buff[MAX_PATH + 1];
171 DWORD nsize =
sizeof(buff)/
sizeof(
char);
172 DWORD n = GetModuleFileNameA(
NULL, buff, nsize);
173 if (n == 0 || n == nsize || (lb = strrchr(buff,
'\\')) ==
NULL)
174 luaL_error(L,
"unable to get ModuleFileName");
184 int error = GetLastError();
186 if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
194 FreeLibrary((HMODULE)lib);
199 HMODULE lib = LoadLibraryExA(path,
NULL, LUA_LLE_FLAGS);
223#define LIB_FAIL "absent"
226#define DLMSG "dynamic libraries not enabled; check your Lua installation"
235 (void)(path); (void)(seeglb);
242 (void)(lib); (void)(sym);
277 for (; n >= 1; n--) {
289 reg =
ll_load(L, path, *sym ==
'*');
331 FILE *f = fopen(filename,
"r");
332 if (f ==
NULL)
return 0;
341 if (*path ==
'\0')
return NULL;
343 if (l ==
NULL) l = path + strlen(path);
352 const char *dirsep) {
377 if (f !=
NULL)
return 1;
388 const char *dirsep) {
405 " from file " LUA_QS ":\n\t%s",
411 const char *filename;
414 if (filename ==
NULL)
return 1;
429 if (stat !=
ERRFUNC)
return stat;
440 if (filename ==
NULL)
return 1;
446 const char *filename;
448 const char *p = strchr(
name,
'.');
450 if (p ==
NULL)
return 0;
453 if (filename ==
NULL)
return 1;
541#if defined(LUA_COMPAT_MODULE)
560 for (i = 2; i <= n; i++) {
576 dot = strrchr(modname,
'.');
577 if (dot ==
NULL) dot = modname;
588 luaL_pushmodule(L, modname, 1);
638 const char *envname2,
const char *def) {
639 const char *path = getenv(envname1);
641 path = getenv(envname2);
659#if defined(LUA_COMPAT_MODULE)
667#if defined(LUA_COMPAT_MODULE)
682 for (i=0; searchers[i] !=
NULL; i++) {
700#if defined(LUA_COMPAT_LOADERS)
static int pusherror(lua_State *L, const char *info)
LUA_API void lua_pushstring(lua_State *L, const char *s)
LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction fn, int n)
LUA_API int lua_setmetatable(lua_State *L, int objindex)
LUA_API void lua_pushnil(lua_State *L)
LUA_API const char * lua_pushfstring(lua_State *L, const char *fmt,...)
LUA_API int lua_iscfunction(lua_State *L, int idx)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API int lua_toboolean(lua_State *L, int idx)
LUA_API int lua_getmetatable(lua_State *L, int objindex)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUA_API void lua_createtable(lua_State *L, int narray, int nrec)
LUA_API void lua_pushlightuserdata(lua_State *L, void *p)
LUA_API void lua_rawseti(lua_State *L, int idx, int n)
LUA_API int lua_isstring(lua_State *L, int idx)
LUA_API void * lua_touserdata(lua_State *L, int idx)
LUA_API void lua_pushlstring(lua_State *L, const char *s, size_t len)
LUA_API const char * lua_setupvalue(lua_State *L, int funcindex, int n)
LUA_API void lua_settop(lua_State *L, int idx)
LUA_API void lua_rawgeti(lua_State *L, int idx, int n)
LUA_API void lua_getfield(lua_State *L, int idx, const char *k)
LUA_API int lua_gettop(lua_State *L)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
LUALIB_API void luaL_checktype(lua_State *L, int narg, int t)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
LUALIB_API void luaL_addvalue(luaL_Buffer *B)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
LUALIB_API const char * luaL_gsub(lua_State *L, const char *s, const char *p, const char *r)
#define luaL_optstring(L, n, d)
#define luaL_checkstring(L, n)
LUA_API int lua_getstack(lua_State *L, int level, lua_Debug *ar)
LUA_API int lua_getinfo(lua_State *L, const char *what, lua_Debug *ar)
static void modinit(lua_State *L, const char *modname)
static void dooptions(lua_State *L, int n)
static int ll_seeall(lua_State *L)
static int ll_module(lua_State *L)
static int funcname(LexState *ls, expdesc *v)
#define lua_istable(L, n)
#define lua_pushcfunction(L, f)
#define LUA_REGISTRYINDEX
#define lua_pushliteral(L, s)
#define lua_isfunction(L, n)
int(* lua_CFunction)(lua_State *L)
#define lua_upvalueindex(i)
#define lua_tostring(L, i)
#define LUA_CPATH_DEFAULT
static void error(LoadState *S, const char *why)
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
LUALIB_API int luaL_getsubtable(lua_State *L, int idx, const char *fname)
LUALIB_API int luaL_len(lua_State *L, int idx)
#define luaL_loadfile(L, f)
#define luaL_newlib(L, l)
static int noenv(lua_State *L)
static int ll_require(lua_State *L)
static int searcher_Croot(lua_State *L)
static int ll_loadfunc(lua_State *L, const char *path, const char *sym)
static const luaL_Reg ll_funcs[]
static int ll_searchpath(lua_State *L)
static const char * pushnexttemplate(lua_State *L, const char *path)
static lua_CFunction ll_sym(lua_State *L, void *lib, const char *sym)
static int gctm(lua_State *L)
static void * ll_checkclib(lua_State *L, const char *path)
static void * ll_load(lua_State *L, const char *path, int seeglb)
static int searcher_preload(lua_State *L)
static void ll_addtoclib(lua_State *L, const char *path, void *plib)
static int searcher_Lua(lua_State *L)
static void createsearcherstable(lua_State *L)
static int loadfunc(lua_State *L, const char *filename, const char *modname)
static int searcher_C(lua_State *L)
static const char * searchpath(lua_State *L, const char *name, const char *path, const char *sep, const char *dirsep)
static int ll_loadlib(lua_State *L)
static void setpath(lua_State *L, const char *fieldname, const char *envname1, const char *envname2, const char *def)
LUAMOD_API int luaopen_package(lua_State *L)
static int checkload(lua_State *L, int stat, const char *filename)
static void ll_unloadlib(void *lib)
static const char * findfile(lua_State *L, const char *name, const char *pname, const char *dirsep)
static void findloader(lua_State *L, const char *name)
static int readable(const char *filename)
static const luaL_Reg pk_funcs[]
#define lua_call(L, n, r)
#define lua_pushglobaltable(L)
#define lua_insert(L, idx)
#define lua_remove(L, idx)