Go to the documentation of this file.
31 #if !defined (LUA_IGMARK)
32 #define LUA_IGMARK "-"
42 #if !defined(LUA_CSUBSEP)
43 #define LUA_CSUBSEP LUA_DIRSEP
46 #if !defined(LUA_LSUBSEP)
47 #define LUA_LSUBSEP LUA_DIRSEP
52 #define LUA_POF "luaopen_"
62 static const char *
const CLIBS =
"_CLIBS";
64 #define LIB_FAIL "open"
67 #define setprogdir(L) ((void)0)
104 #if defined(LUA_USE_DLOPEN)
121 #if defined(__GNUC__)
122 #define cast_func(p) (__extension__ (lua_CFunction)(p))
124 #define cast_func(p) ((lua_CFunction)(p))
134 void *
lib = dlopen(path, RTLD_NOW | (seeglb ? RTLD_GLOBAL : RTLD_LOCAL));
135 if (l_unlikely(
lib == NULL))
143 if (l_unlikely(f == NULL))
152 #elif defined(LUA_DL_DLL)
165 #if !defined(LUA_LLE_FLAGS)
166 #define LUA_LLE_FLAGS 0
178 char buff[MAX_PATH + 1];
180 DWORD nsize =
sizeof(buff)/
sizeof(
char);
181 DWORD n = GetModuleFileNameA(NULL, buff, nsize);
182 if (n == 0 || n == nsize || (lb = strrchr(buff,
'\\')) == NULL)
183 luaL_error(L,
"unable to get ModuleFileName");
195 int error = GetLastError();
197 if (FormatMessageA(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
198 NULL,
error, 0, buffer,
sizeof(buffer)/
sizeof(
char), NULL))
205 FreeLibrary((HMODULE)
lib);
210 HMODULE
lib = LoadLibraryExA(path, NULL, LUA_LLE_FLAGS);
212 if (
lib == NULL) pusherror(L);
219 if (f == NULL) pusherror(L);
234 #define LIB_FAIL "absent"
237 #define DLMSG "dynamic libraries not enabled; check your Lua installation"
272 #if !defined(LUA_PATH_VAR)
273 #define LUA_PATH_VAR "LUA_PATH"
276 #if !defined(LUA_CPATH_VAR)
277 #define LUA_CPATH_VAR "LUA_CPATH"
302 const char *path = getenv(nver);
304 path = getenv(envname);
305 if (path == NULL ||
noenv(L))
310 size_t len = strlen(path);
313 if (path < dftmark) {
318 if (dftmark < path + len - 2) {
365 for (; n >= 1; n--) {
394 if (reg == NULL)
return ERRLIB;
415 if (l_likely(stat == 0))
435 FILE *
f = fopen(filename,
"r");
436 if (
f == NULL)
return 0;
452 else if (*name ==
'\0') {
484 const char *dirsep) {
488 const char *filename;
490 if (*sep !=
'\0' && strchr(name, *sep) != NULL)
513 if (
f != NULL)
return 1;
524 const char *dirsep) {
528 if (l_unlikely(path == NULL))
529 luaL_error(L,
"'package.%s' must be a string", pname);
530 return searchpath(L, name, path,
".", dirsep);
535 if (l_likely(stat)) {
540 return luaL_error(L,
"error loading module '%s' from file '%s':\n\t%s",
546 const char *filename;
549 if (filename == NULL)
return 1;
563 const char *openfunc;
572 if (stat !=
ERRFUNC)
return stat;
583 if (filename == NULL)
return 1;
589 const char *filename;
591 const char *p = strchr(name,
'.');
593 if (p == NULL)
return 0;
596 if (filename == NULL)
return 1;
597 if ((stat =
loadfunc(L, filename, name)) != 0) {
630 luaL_error(L,
"'package.searchers' must be a table");
717 for (i=0; searchers[i] != NULL; i++) {
static int searcher_Lua(lua_State *L)
#define luaL_optstring(L, n, d)
#define lua_pushliteral(L, s)
LUA_API void lua_rotate(lua_State *L, int idx, int n)
#define LUA_PRELOAD_TABLE
static void findloader(lua_State *L, const char *name)
LUALIB_API void luaL_addstring(luaL_Buffer *B, const char *s)
#define lua_pushglobaltable(L)
#define LUA_CPATH_DEFAULT
static const luaL_Reg pk_funcs[]
static int ll_require(lua_State *L)
#define lua_tostring(L, i)
#define luaL_checkstring(L, n)
LUA_API int lua_getfield(lua_State *L, int idx, const char *k)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
static void pusherrornotfound(lua_State *L, const char *path)
static int gctm(lua_State *L)
static const luaL_Reg ll_funcs[]
#define lua_remove(L, idx)
const LUA_API char * lua_pushfstring(lua_State *L, const char *fmt,...)
LUALIB_API void luaL_addlstring(luaL_Buffer *B, const char *s, size_t l)
LUA_API int lua_isstring(lua_State *L, int idx)
static void addtoclib(lua_State *L, const char *path, void *plib)
#define luaL_loadfile(L, f)
LUAMOD_API int luaopen_package(lua_State *L)
#define luaL_buffsub(B, s)
static void * checkclib(lua_State *L, const char *path)
LUA_API int lua_setmetatable(lua_State *L, int objindex)
static l_noret error(LoadState *S, const char *why)
const LUA_API char * lua_pushstring(lua_State *L, const char *s)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
#define lua_isfunction(L, n)
static int noenv(lua_State *L)
#define lua_insert(L, idx)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction fn, int n)
static int ll_searchpath(lua_State *L)
static void createclibstable(lua_State *L)
LUA_API int lua_rawgeti(lua_State *L, int idx, lua_Integer n)
static int checkload(lua_State *L, int stat, const char *filename)
static int loadfunc(lua_State *L, const char *filename, const char *modname)
#define LUA_REGISTRYINDEX
LUA_API void * lua_touserdata(lua_State *L, int idx)
#define luaL_addchar(B, c)
LUA_API void lua_settop(lua_State *L, int idx)
static void setpath(lua_State *L, const char *fieldname, const char *envname, const char *dft)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUA_API void lua_pushvalue(lua_State *L, int idx)
LUALIB_API lua_Integer luaL_len(lua_State *L, int idx)
#define lua_pushcfunction(L, f)
#define lua_call(L, n, r)
const LUA_API char * lua_pushlstring(lua_State *L, const char *s, size_t len)
LUA_API void lua_rawseti(lua_State *L, int idx, lua_Integer n)
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
static lua_CFunction lsys_sym(lua_State *L, void *lib, const char *sym)
static int searcher_Croot(lua_State *L)
static void * lsys_load(lua_State *L, const char *path, int seeglb)
static void lsys_unloadlib(void *lib)
static int ll_loadlib(lua_State *L)
static int readable(const char *filename)
static const char *const CLIBS
#define luaL_newlib(L, l)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
static const char * findfile(lua_State *L, const char *name, const char *pname, const char *dirsep)
const LUALIB_API char * luaL_gsub(lua_State *L, const char *s, const char *p, const char *r)
#define luaL_buffaddr(bf)
void init(const M_string &remappings)
static void createsearcherstable(lua_State *L)
LUALIB_API int luaL_getsubtable(lua_State *L, int idx, const char *fname)
int(* lua_CFunction)(lua_State *L)
static int searcher_preload(lua_State *L)
static const char * getnextfilename(char **path, char *end)
static int searcher_C(lua_State *L)
LUA_API int lua_toboolean(lua_State *L, int idx)
#define lua_upvalueindex(i)
static int lookforfunc(lua_State *L, const char *path, const char *sym)
LUALIB_API void luaL_addvalue(luaL_Buffer *B)
LUALIB_API void luaL_addgsub(luaL_Buffer *b, const char *s, const char *p, const char *r)
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_copy(lua_State *L, int fromidx, int toidx)
static const char * searchpath(lua_State *L, const char *name, const char *path, const char *sep, const char *dirsep)
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44