Defines | Functions | Variables

lua/loadlib.c File Reference

#include <stdlib.h>
#include <string.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
Include dependency graph for loadlib.c:

Go to the source code of this file.

Defines

#define loadlib_c
#define LUA_LIB
#define LUA_PATH   "LUA_PATH"
#define LUA_CPATH   "LUA_CPATH"
#define LUA_PATHSUFFIX   "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR
#define LUA_PATHVERSION   LUA_PATH LUA_PATHSUFFIX
#define LUA_CPATHVERSION   LUA_CPATH LUA_PATHSUFFIX
#define LUA_PATH_SEP   ";"
#define LUA_PATH_MARK   "?"
#define LUA_EXEC_DIR   "!"
#define LUA_IGMARK   "-"
#define LUA_CSUBSEP   LUA_DIRSEP
#define LUA_LSUBSEP   LUA_DIRSEP
#define LUA_POF   "luaopen_"
#define LUA_OFSEP   "_"
#define LIBPREFIX   "LOADLIB: "
#define POF   LUA_POF
#define LIB_FAIL   "open"
#define ERRLIB   1
#define ERRFUNC   2
#define setprogdir(L)   ((void)0)
#define LIB_FAIL   "absent"
#define DLMSG   "dynamic libraries not enabled; check your Lua installation"
#define AUXMARK   "\1"

Functions

static void ll_unloadlib (void *lib)
static void * ll_load (lua_State *L, const char *path, int seeglb)
static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym)
static void ** ll_register (lua_State *L, const char *path)
static int gctm (lua_State *L)
static int ll_loadfunc (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 set_env (lua_State *L)
static void dooptions (lua_State *L, int n)
static void modinit (lua_State *L, const char *modname)
static int ll_module (lua_State *L)
static int ll_seeall (lua_State *L)
static int noenv (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)

Variables

static const luaL_Reg pk_funcs []
static const luaL_Reg ll_funcs []
static const lua_CFunction searchers []

Define Documentation

#define AUXMARK   "\1"

Definition at line 616 of file loadlib.c.

Referenced by setpath().

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

Definition at line 226 of file loadlib.c.

Referenced by ll_load(), and ll_sym().

#define ERRFUNC   2

Definition at line 103 of file loadlib.c.

Referenced by loadfunc(), and searcher_Croot().

#define ERRLIB   1

Definition at line 102 of file loadlib.c.

Referenced by ll_loadlib().

#define LIB_FAIL   "absent"

Definition at line 223 of file loadlib.c.

#define LIB_FAIL   "open"

Definition at line 223 of file loadlib.c.

Referenced by ll_loadlib().

#define LIBPREFIX   "LOADLIB: "

Definition at line 95 of file loadlib.c.

Referenced by ll_register().

#define loadlib_c

Definition at line 24 of file loadlib.c.

#define LUA_CPATH   "LUA_CPATH"

Definition at line 42 of file loadlib.c.

Referenced by luaopen_package().

#define LUA_CPATHVERSION   LUA_CPATH LUA_PATHSUFFIX

Definition at line 48 of file loadlib.c.

Referenced by luaopen_package().

#define LUA_CSUBSEP   LUA_DIRSEP

Definition at line 80 of file loadlib.c.

Referenced by searcher_C(), and searcher_Croot().

#define LUA_EXEC_DIR   "!"

Definition at line 66 of file loadlib.c.

Referenced by luaopen_package().

#define LUA_IGMARK   "-"

Definition at line 69 of file loadlib.c.

Referenced by loadfunc(), and luaopen_package().

#define LUA_LIB

Definition at line 25 of file loadlib.c.

#define LUA_LSUBSEP   LUA_DIRSEP

Definition at line 84 of file loadlib.c.

Referenced by searcher_Lua().

#define LUA_OFSEP   "_"

Definition at line 92 of file loadlib.c.

Referenced by loadfunc().

#define LUA_PATH   "LUA_PATH"

Definition at line 38 of file loadlib.c.

Referenced by luaopen_package().

#define LUA_PATH_MARK   "?"

Definition at line 63 of file loadlib.c.

Referenced by luaopen_package(), and searchpath().

#define LUA_PATH_SEP   ";"

Definition at line 60 of file loadlib.c.

Referenced by luaopen_package(), pushnexttemplate(), and setpath().

#define LUA_PATHSUFFIX   "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR

Definition at line 45 of file loadlib.c.

#define LUA_PATHVERSION   LUA_PATH LUA_PATHSUFFIX

Definition at line 47 of file loadlib.c.

Referenced by luaopen_package().

#define LUA_POF   "luaopen_"

Definition at line 89 of file loadlib.c.

#define POF   LUA_POF

Definition at line 97 of file loadlib.c.

Referenced by loadfunc().

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

Definition at line 105 of file loadlib.c.

Referenced by setpath().


Function Documentation

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

Definition at line 392 of file loadlib.c.

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

static void dooptions ( lua_State L,
int  n 
) [static]

Definition at line 552 of file loadlib.c.

References lua_call, lua_isfunction, and lua_pushvalue().

Referenced by ll_module().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 380 of file loadlib.c.

References lua_getfield(), LUA_QL, lua_tostring, lua_upvalueindex, luaL_error(), and searchpath().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 472 of file loadlib.c.

References lua_call, lua_getfield(), lua_isfunction, lua_isnil, lua_isstring(), lua_istable, lua_pop, lua_pushstring(), LUA_QL, LUA_QS, lua_rawgeti(), lua_tostring, lua_upvalueindex, luaL_addvalue(), luaL_buffinit(), luaL_error(), and luaL_pushresult().

Referenced by ll_require().

Here is the call graph for this function:

Here is the caller graph for this function:

static int gctm ( lua_State L  )  [static]

Definition at line 275 of file loadlib.c.

References ll_unloadlib(), and luaL_checkudata().

Referenced by luaopen_package().

Here is the call graph for this function:

Here is the caller graph for this function:

static void * ll_load ( lua_State L,
const char *  path,
int  seeglb 
) [static]

Definition at line 234 of file loadlib.c.

References DLMSG, and lua_pushliteral.

Referenced by ll_loadfunc().

Here is the caller graph for this function:

static int ll_loadfunc ( lua_State L,
const char *  path,
const char *  sym 
) [static]

Definition at line 283 of file loadlib.c.

References ll_load(), ll_register(), ll_sym(), lua_pushboolean(), and lua_pushcfunction.

Referenced by ll_loadlib(), and loadfunc().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ll_loadlib ( lua_State L  )  [static]

Definition at line 301 of file loadlib.c.

References ERRLIB, ai::registry::init(), LIB_FAIL, ll_loadfunc(), lua_insert(), lua_pushnil(), lua_pushstring(), and luaL_checkstring.

Here is the call graph for this function:

static int ll_module ( lua_State L  )  [static]

Definition at line 579 of file loadlib.c.

References dooptions(), lua_getfield(), lua_gettop(), lua_isnil, lua_pop, lua_pushvalue(), luaL_checkstring, luaL_pushmodule(), modinit(), and set_env().

Here is the call graph for this function:

static void** ll_register ( lua_State L,
const char *  path 
) [static]

Definition at line 252 of file loadlib.c.

References LIBPREFIX, lua_gettable(), lua_isnil, lua_newuserdata(), lua_pop, lua_pushfstring(), lua_pushvalue(), LUA_REGISTRYINDEX, lua_settable(), lua_touserdata(), and luaL_setmetatable().

Referenced by ll_loadfunc().

Here is the call graph for this function:

Here is the caller graph for this function:

static int ll_require ( lua_State L  )  [static]
static int ll_searchpath ( lua_State L  )  [static]

Definition at line 366 of file loadlib.c.

References LUA_DIRSEP, lua_insert(), lua_pushnil(), luaL_checkstring, luaL_optstring, and searchpath().

Here is the call graph for this function:

static int ll_seeall ( lua_State L  )  [static]

Definition at line 598 of file loadlib.c.

References lua_createtable(), lua_getmetatable(), lua_pushglobaltable, lua_pushvalue(), lua_setfield(), lua_setmetatable(), LUA_TTABLE, and luaL_checktype().

Here is the call graph for this function:

static lua_CFunction ll_sym ( lua_State L,
void *  lib,
const char *  sym 
) [static]

Definition at line 241 of file loadlib.c.

References DLMSG, and lua_pushliteral.

Referenced by ll_loadfunc().

Here is the caller graph for this function:

static void ll_unloadlib ( void *  lib  )  [static]

Definition at line 229 of file loadlib.c.

Referenced by gctm().

Here is the caller graph for this function:

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

Definition at line 413 of file loadlib.c.

References ERRFUNC, ll_loadfunc(), LUA_IGMARK, LUA_OFSEP, lua_pushfstring(), lua_pushlstring(), luaL_gsub(), and POF.

Referenced by searcher_C(), and searcher_Croot().

Here is the call graph for this function:

Here is the caller graph for this function:

LUAMOD_API int luaopen_package ( lua_State L  ) 
static void modinit ( lua_State L,
const char *  modname 
) [static]

Definition at line 564 of file loadlib.c.

References lua_pushlstring(), lua_pushstring(), lua_pushvalue(), and lua_setfield().

Referenced by ll_module().

Here is the call graph for this function:

Here is the caller graph for this function:

static int noenv ( lua_State L  )  [static]

Definition at line 622 of file loadlib.c.

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

Referenced by setpath().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 332 of file loadlib.c.

References LUA_PATH_SEP, and lua_pushlstring().

Referenced by searchpath().

Here is the call graph for this function:

Here is the caller graph for this function:

static int readable ( const char *  filename  )  [static]

Definition at line 324 of file loadlib.c.

Referenced by searchpath().

Here is the caller graph for this function:

static int searcher_C ( lua_State L  )  [static]

Definition at line 431 of file loadlib.c.

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

Here is the call graph for this function:

static int searcher_Croot ( lua_State L  )  [static]

Definition at line 439 of file loadlib.c.

References checkload(), ERRFUNC, findfile(), loadfunc(), LUA_CSUBSEP, lua_pushfstring(), lua_pushlstring(), lua_pushstring(), LUA_QS, lua_tostring, and luaL_checkstring.

Here is the call graph for this function:

static int searcher_Lua ( lua_State L  )  [static]

Definition at line 404 of file loadlib.c.

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

Here is the call graph for this function:

static int searcher_preload ( lua_State L  )  [static]

Definition at line 462 of file loadlib.c.

References lua_getfield(), lua_isnil, lua_pushfstring(), LUA_REGISTRYINDEX, and luaL_checkstring.

Here is the call graph for this function:

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

Definition at line 343 of file loadlib.c.

References LUA_PATH_MARK, lua_pushfstring(), LUA_QS, lua_remove(), lua_tostring, luaL_addvalue(), luaL_buffinit(), luaL_gsub(), luaL_pushresult(), pushnexttemplate(), and readable().

Referenced by findfile(), and ll_searchpath().

Here is the call graph for this function:

Here is the caller graph for this function:

static void set_env ( lua_State L  )  [static]

Definition at line 540 of file loadlib.c.

References lua_getinfo(), lua_getstack(), lua_iscfunction(), lua_pop, lua_pushvalue(), LUA_QL, lua_setupvalue(), and luaL_error().

Referenced by ll_module().

Here is the call graph for this function:

Here is the caller graph for this function:

static void setpath ( lua_State L,
const char *  fieldname,
const char *  envname1,
const char *  envname2,
const char *  def 
) [static]

Definition at line 631 of file loadlib.c.

References AUXMARK, LUA_PATH_SEP, lua_pushstring(), lua_remove(), lua_setfield(), luaL_gsub(), noenv(), and setprogdir.

Referenced by luaopen_package().

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

const luaL_Reg ll_funcs[] [static]
Initial value:
 {

  {"module", ll_module},

  {"require", ll_require},
  {NULL, NULL}
}

Definition at line 660 of file loadlib.c.

const luaL_Reg pk_funcs[] [static]
Initial value:
 {
  {"loadlib", ll_loadlib},
  {"searchpath", ll_searchpath},

  {"seeall", ll_seeall},

  {NULL, NULL}
}

Definition at line 650 of file loadlib.c.

const lua_CFunction searchers[] [static]
Initial value:
  {searcher_preload, searcher_Lua, searcher_C, searcher_Croot, NULL}

Definition at line 669 of file loadlib.c.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:07:20 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs