linit_flua.c (1726db7af6b3738eb04d962b351d7f4017e1fc77) linit_flua.c (bb2d016afb009920f4bb2400c15a86e557b2d55a)
1/*
2** $Id: linit.c,v 1.39.1.1 2017/04/19 17:20:42 roberto Exp $
3** Initialization of libraries for lua.c and other clients
4** See Copyright Notice in lua.h
5*/
6
7
8#define linit_c

--- 22 unchanged lines hidden (view full) ---

31
32#include "lua.h"
33
34#include "lualib.h"
35#include "lauxlib.h"
36#include "lfs.h"
37#include "lposix.h"
38#include "lfbsd.h"
1/*
2** $Id: linit.c,v 1.39.1.1 2017/04/19 17:20:42 roberto Exp $
3** Initialization of libraries for lua.c and other clients
4** See Copyright Notice in lua.h
5*/
6
7
8#define linit_c

--- 22 unchanged lines hidden (view full) ---

31
32#include "lua.h"
33
34#include "lualib.h"
35#include "lauxlib.h"
36#include "lfs.h"
37#include "lposix.h"
38#include "lfbsd.h"
39#include "lua_ucl.h"
40
41/*
42** these libs are loaded by lua.c and are readily available to any Lua
43** program
44*/
45static const luaL_Reg loadedlibs[] = {
46 {"_G", luaopen_base},
47 {LUA_LOADLIBNAME, luaopen_package},

--- 8 unchanged lines hidden (view full) ---

56#if defined(LUA_COMPAT_BITLIB)
57 {LUA_BITLIBNAME, luaopen_bit32},
58#endif
59 /* FreeBSD Extensions */
60 {"lfs", luaopen_lfs},
61 {"posix.sys.stat", luaopen_posix_sys_stat},
62 {"posix.sys.utsname", luaopen_posix_sys_utsname},
63 {"posix.unistd", luaopen_posix_unistd},
39
40/*
41** these libs are loaded by lua.c and are readily available to any Lua
42** program
43*/
44static const luaL_Reg loadedlibs[] = {
45 {"_G", luaopen_base},
46 {LUA_LOADLIBNAME, luaopen_package},

--- 8 unchanged lines hidden (view full) ---

55#if defined(LUA_COMPAT_BITLIB)
56 {LUA_BITLIBNAME, luaopen_bit32},
57#endif
58 /* FreeBSD Extensions */
59 {"lfs", luaopen_lfs},
60 {"posix.sys.stat", luaopen_posix_sys_stat},
61 {"posix.sys.utsname", luaopen_posix_sys_utsname},
62 {"posix.unistd", luaopen_posix_unistd},
64 {"ucl", luaopen_ucl},
65 {"fbsd", luaopen_fbsd},
66 {NULL, NULL}
67};
68
69
70LUALIB_API void luaL_openlibs (lua_State *L) {
71 const luaL_Reg *lib;
72 /* "require" functions from 'loadedlibs' and set results to global table */
73 for (lib = loadedlibs; lib->func; lib++) {
74 luaL_requiref(L, lib->name, lib->func, 1);
75 lua_pop(L, 1); /* remove lib */
76 }
77}
78
63 {"fbsd", luaopen_fbsd},
64 {NULL, NULL}
65};
66
67
68LUALIB_API void luaL_openlibs (lua_State *L) {
69 const luaL_Reg *lib;
70 /* "require" functions from 'loadedlibs' and set results to global table */
71 for (lib = loadedlibs; lib->func; lib++) {
72 luaL_requiref(L, lib->name, lib->func, 1);
73 lua_pop(L, 1); /* remove lib */
74 }
75}
76