The Battle for Wesnoth  1.15.1+dev
Macros | Functions | Variables
loadlib.cpp File Reference
#include "lprefix.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Include dependency graph for loadlib.cpp:

Go to the source code of this file.

Macros

#define loadlib_c
 
#define LUA_LIB
 
#define LUA_IGMARK   "-"
 
#define LUA_CSUBSEP   LUA_DIRSEP
 
#define LUA_LSUBSEP   LUA_DIRSEP
 
#define LUA_POF   "luaopen_"
 
#define LUA_OFSEP   "_"
 
#define LIB_FAIL   "open"
 
#define setprogdir(L)   ((void)0)
 
#define LIB_FAIL   "absent"
 
#define DLMSG   "dynamic libraries not enabled; check your Lua installation"
 
#define LUA_PATH_VAR   "LUA_PATH"
 
#define LUA_CPATH_VAR   "LUA_CPATH"
 
#define AUXMARK   "\1" /* auxiliary mark */
 
#define ERRLIB   1
 
#define ERRFUNC   2
 

Functions

static void lsys_unloadlib (void *lib)
 
static void * lsys_load (lua_State *L, const char *path, int seeglb)
 
static lua_CFunction lsys_sym (lua_State *L, void *lib, const char *sym)
 
static int noenv (lua_State *L)
 
static void setpath (lua_State *L, const char *fieldname, const char *envname, const char *dft)
 
static void * checkclib (lua_State *L, const char *path)
 
static void addtoclib (lua_State *L, const char *path, void *plib)
 
static int gctm (lua_State *L)
 
static int lookforfunc (lua_State *L, const char *path, const char *sym)
 
static int ll_loadlib (lua_State *L)
 
static int readable (const char *filename)
 
static const char * pushnexttemplate (lua_State *L, const char *path)
 
static const char * searchpath (lua_State *L, const char *name, const char *path, const char *sep, const char *dirsep)
 
static int ll_searchpath (lua_State *L)
 
static const char * findfile (lua_State *L, const char *name, const char *pname, const char *dirsep)
 
static int checkload (lua_State *L, int stat, const char *filename)
 
static int searcher_Lua (lua_State *L)
 
static int loadfunc (lua_State *L, const char *filename, const char *modname)
 
static int searcher_C (lua_State *L)
 
static int searcher_Croot (lua_State *L)
 
static int searcher_preload (lua_State *L)
 
static void findloader (lua_State *L, const char *name)
 
static int ll_require (lua_State *L)
 
static void createsearcherstable (lua_State *L)
 
static void createclibstable (lua_State *L)
 
LUAMOD_API int luaopen_package (lua_State *L)
 

Variables

static const int CLIBS = 0
 
static const luaL_Reg pk_funcs []
 
static const luaL_Reg ll_funcs []
 

Macro Definition Documentation

◆ AUXMARK

#define AUXMARK   "\1" /* auxiliary mark */

Definition at line 272 of file loadlib.cpp.

Referenced by setpath().

◆ DLMSG

#define DLMSG   "dynamic libraries not enabled; check your Lua installation"

Definition at line 228 of file loadlib.cpp.

Referenced by lsys_load(), and lsys_sym().

◆ ERRFUNC

#define ERRFUNC   2

Definition at line 359 of file loadlib.cpp.

Referenced by loadfunc(), lookforfunc(), and searcher_Croot().

◆ ERRLIB

#define ERRLIB   1

Definition at line 358 of file loadlib.cpp.

Referenced by ll_loadlib(), and lookforfunc().

◆ LIB_FAIL [1/2]

#define LIB_FAIL   "open"

Definition at line 225 of file loadlib.cpp.

Referenced by ll_loadlib().

◆ LIB_FAIL [2/2]

#define LIB_FAIL   "absent"

Definition at line 225 of file loadlib.cpp.

◆ loadlib_c

#define loadlib_c

Definition at line 11 of file loadlib.cpp.

◆ LUA_CPATH_VAR

#define LUA_CPATH_VAR   "LUA_CPATH"

Definition at line 268 of file loadlib.cpp.

Referenced by luaopen_package().

◆ LUA_CSUBSEP

#define LUA_CSUBSEP   LUA_DIRSEP

Definition at line 43 of file loadlib.cpp.

Referenced by searcher_C(), and searcher_Croot().

◆ LUA_IGMARK

#define LUA_IGMARK   "-"

Definition at line 32 of file loadlib.cpp.

Referenced by loadfunc(), and luaopen_package().

◆ LUA_LIB

#define LUA_LIB

Definition at line 12 of file loadlib.cpp.

◆ LUA_LSUBSEP

#define LUA_LSUBSEP   LUA_DIRSEP

Definition at line 47 of file loadlib.cpp.

Referenced by searcher_Lua().

◆ LUA_OFSEP

#define LUA_OFSEP   "_"

Definition at line 55 of file loadlib.cpp.

Referenced by loadfunc().

◆ LUA_PATH_VAR

#define LUA_PATH_VAR   "LUA_PATH"

Definition at line 264 of file loadlib.cpp.

Referenced by luaopen_package().

◆ LUA_POF

#define LUA_POF   "luaopen_"

Definition at line 52 of file loadlib.cpp.

Referenced by loadfunc().

◆ setprogdir

#define setprogdir (   L)    ((void)0)

Definition at line 67 of file loadlib.cpp.

Referenced by setpath().

Function Documentation

◆ addtoclib()

static void addtoclib ( lua_State L,
const char *  path,
void *  plib 
)
static

◆ checkclib()

static void* checkclib ( lua_State L,
const char *  path 
)
static

Definition at line 317 of file loadlib.cpp.

References CLIBS, lua_getfield(), lua_pop, lua_rawgetp(), LUA_REGISTRYINDEX, and lua_touserdata().

Referenced by lookforfunc().

◆ checkload()

static int checkload ( lua_State L,
int  stat,
const char *  filename 
)
static

Definition at line 484 of file loadlib.cpp.

References lua_pushstring(), lua_tostring, and luaL_error().

Referenced by searcher_C(), searcher_Croot(), and searcher_Lua().

◆ createclibstable()

static void createclibstable ( lua_State L)
static

◆ createsearcherstable()

static void createsearcherstable ( lua_State L)
static

◆ findfile()

static const char* findfile ( lua_State L,
const char *  name,
const char *  pname,
const char *  dirsep 
)
static

◆ findloader()

static void findloader ( lua_State L,
const char *  name 
)
static

◆ gctm()

static int gctm ( lua_State L)
static

Definition at line 345 of file loadlib.cpp.

References lsys_unloadlib(), lua_pop, lua_rawgeti(), lua_touserdata(), and luaL_len().

Referenced by createclibstable().

◆ ll_loadlib()

static int ll_loadlib ( lua_State L)
static

◆ ll_require()

static int ll_require ( lua_State L)
static

◆ ll_searchpath()

static int ll_searchpath ( lua_State L)
static

◆ loadfunc()

static int loadfunc ( lua_State L,
const char *  filename,
const char *  modname 
)
static

◆ lookforfunc()

static int lookforfunc ( lua_State L,
const char *  path,
const char *  sym 
)
static

Definition at line 372 of file loadlib.cpp.

References addtoclib(), checkclib(), ERRFUNC, ERRLIB, lsys_load(), lsys_sym(), lua_pushboolean(), and lua_pushcfunction.

Referenced by ll_loadlib(), and loadfunc().

◆ lsys_load()

static void * lsys_load ( lua_State L,
const char *  path,
int  seeglb 
)
static

Definition at line 236 of file loadlib.cpp.

References DLMSG, and lua_pushliteral.

Referenced by lookforfunc().

◆ lsys_sym()

static lua_CFunction lsys_sym ( lua_State L,
void *  lib,
const char *  sym 
)
static

Definition at line 243 of file loadlib.cpp.

References DLMSG, and lua_pushliteral.

Referenced by lookforfunc().

◆ lsys_unloadlib()

static void lsys_unloadlib ( void *  lib)
static

Definition at line 231 of file loadlib.cpp.

Referenced by gctm().

◆ luaopen_package()

LUAMOD_API int luaopen_package ( lua_State L)

◆ noenv()

static int noenv ( lua_State L)
static

Definition at line 278 of file loadlib.cpp.

References b, lua_getfield(), lua_pop, LUA_REGISTRYINDEX, and lua_toboolean().

Referenced by setpath().

◆ pushnexttemplate()

static const char* pushnexttemplate ( lua_State L,
const char *  path 
)
static

Definition at line 424 of file loadlib.cpp.

References LUA_PATH_SEP, and lua_pushlstring().

Referenced by searchpath().

◆ readable()

static int readable ( const char *  filename)
static

Definition at line 416 of file loadlib.cpp.

Referenced by searchpath().

◆ searcher_C()

static int searcher_C ( lua_State L)
static

Definition at line 530 of file loadlib.cpp.

References checkload(), findfile(), loadfunc(), LUA_CSUBSEP, luaL_checkstring, and name().

Referenced by createsearcherstable().

◆ searcher_Croot()

static int searcher_Croot ( lua_State L)
static

◆ searcher_Lua()

static int searcher_Lua ( lua_State L)
static

Definition at line 495 of file loadlib.cpp.

References checkload(), findfile(), LUA_LSUBSEP, LUA_OK, luaL_checkstring, luaL_loadfile, and name().

Referenced by createsearcherstable().

◆ searcher_preload()

static int searcher_preload ( lua_State L)
static

◆ searchpath()

static const char* searchpath ( lua_State L,
const char *  name,
const char *  path,
const char *  sep,
const char *  dirsep 
)
static

◆ setpath()

static void setpath ( lua_State L,
const char *  fieldname,
const char *  envname,
const char *  dft 
)
static

Variable Documentation

◆ CLIBS

const int CLIBS = 0
static

Definition at line 62 of file loadlib.cpp.

Referenced by addtoclib(), checkclib(), and createclibstable().

◆ ll_funcs

const luaL_Reg ll_funcs[]
static
Initial value:
= {
{"require", ll_require},
{NULL, NULL}
}
static int ll_require(lua_State *L)
Definition: loadlib.cpp:597

Definition at line 724 of file loadlib.cpp.

◆ pk_funcs

const luaL_Reg pk_funcs[]
static
Initial value:
= {
{"loadlib", ll_loadlib},
{"searchpath", ll_searchpath},
{"preload", NULL},
{"cpath", NULL},
{"path", NULL},
{"searchers", NULL},
{"loaded", NULL},
{NULL, NULL}
}
static int ll_searchpath(lua_State *L)
Definition: loadlib.cpp:458
static int ll_loadlib(lua_State *L)
Definition: loadlib.cpp:393

Definition at line 708 of file loadlib.cpp.