]>
git.proxmox.com Git - ceph.git/blob - ceph/src/civetweb/src/third_party/lua-5.3.1/src/linit.c
2 ** $Id: linit.c,v 1.38 2015/01/05 13:48:33 roberto Exp $
3 ** Initialization of libraries for lua.c and other clients
4 ** See Copyright Notice in lua.h
12 ** If you embed Lua in your program and need to open the standard
13 ** libraries, call luaL_openlibs in your program. If you need a
14 ** different set of libraries, copy this file to your project and edit
15 ** it to suit your needs.
17 ** You can also *preload* libraries, so that a later 'require' can
18 ** open the library, which is already linked to the application.
19 ** For that, do the following code:
21 ** luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD");
22 ** lua_pushcfunction(L, luaopen_modname);
23 ** lua_setfield(L, -2, modname);
24 ** lua_pop(L, 1); // remove _PRELOAD table
39 ** these libs are loaded by lua.c and are readily available to any Lua
42 static const luaL_Reg loadedlibs
[] = {
44 {LUA_LOADLIBNAME
, luaopen_package
},
45 {LUA_COLIBNAME
, luaopen_coroutine
},
46 {LUA_TABLIBNAME
, luaopen_table
},
47 {LUA_IOLIBNAME
, luaopen_io
},
48 {LUA_OSLIBNAME
, luaopen_os
},
49 {LUA_STRLIBNAME
, luaopen_string
},
50 {LUA_MATHLIBNAME
, luaopen_math
},
51 {LUA_UTF8LIBNAME
, luaopen_utf8
},
52 {LUA_DBLIBNAME
, luaopen_debug
},
53 #if defined(LUA_COMPAT_BITLIB)
54 {LUA_BITLIBNAME
, luaopen_bit32
},
60 LUALIB_API
void luaL_openlibs (lua_State
*L
) {
62 /* "require" functions from 'loadedlibs' and set results to global table */
63 for (lib
= loadedlibs
; lib
->func
; lib
++) {
64 luaL_requiref(L
, lib
->name
, lib
->func
, 1);
65 lua_pop(L
, 1); /* remove lib */