/*1** $Id: linit.c,v 1.39.1.1 2017/04/19 17:20:42 roberto Exp $2** Initialization of libraries for lua.c and other clients3** See Copyright Notice in lua.h4*/567#define linit_c8#define LUA_LIB910/*11** If you embed Lua in your program and need to open the standard12** libraries, call luaL_openlibs in your program. If you need a13** different set of libraries, copy this file to your project and edit14** it to suit your needs.15**16** You can also *preload* libraries, so that a later 'require' can17** open the library, which is already linked to the application.18** For that, do the following code:19**20** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE);21** lua_pushcfunction(L, luaopen_modname);22** lua_setfield(L, -2, modname);23** lua_pop(L, 1); // remove PRELOAD table24*/2526#include "lprefix.h"272829#include <stddef.h>3031#include "lua.h"3233#include "lualib.h"34#include "lauxlib.h"35#include "lfs.h"36#include "lposix.h"37#include "lfbsd.h"3839/*40** these libs are loaded by lua.c and are readily available to any Lua41** program42*/43static const luaL_Reg loadedlibs[] = {44{"_G", luaopen_base},45{LUA_LOADLIBNAME, luaopen_package},46{LUA_COLIBNAME, luaopen_coroutine},47{LUA_TABLIBNAME, luaopen_table},48{LUA_IOLIBNAME, luaopen_io},49{LUA_OSLIBNAME, luaopen_os},50{LUA_STRLIBNAME, luaopen_string},51{LUA_MATHLIBNAME, luaopen_math},52{LUA_UTF8LIBNAME, luaopen_utf8},53{LUA_DBLIBNAME, luaopen_debug},54#if defined(LUA_COMPAT_BITLIB)55{LUA_BITLIBNAME, luaopen_bit32},56#endif57/* FreeBSD Extensions */58{"lfs", luaopen_lfs},59{"posix", luaopen_posix},60{"fbsd", luaopen_fbsd},61{NULL, NULL}62};6364LUALIB_API void luaL_openlibs (lua_State *L) {65const luaL_Reg *lib;66/* "require" functions from 'loadedlibs' and set results to global table */67for (lib = loadedlibs; lib->func; lib++) {68luaL_requiref(L, lib->name, lib->func, 1);69lua_pop(L, 1); /* remove lib */70}71}727374