diff options
author | Marcel Ritter <unrzl1@linux.rrze.uni-erlangen.de> | 2008-12-15 08:35:55 +0100 |
---|---|---|
committer | Marcel Ritter <unrzl1@linux.rrze.uni-erlangen.de> | 2008-12-15 08:35:55 +0100 |
commit | 16fa94bd8c1556d7aae3942293cba0a2f61e4ce7 (patch) | |
tree | d7fcdb14b3142a3ce67b602a8a632f0e693d28f0 | |
parent | 095aac438f89b61e0a279453e5622a4acefeec71 (diff) | |
download | syslinux-16fa94bd8c1556d7aae3942293cba0a2f61e4ce7.tar.gz |
COM32: lua - added simple syslinux_run_command function
-rw-r--r-- | com32/lua/src/Makefile | 1 | ||||
-rw-r--r-- | com32/lua/src/linit.c | 1 | ||||
-rw-r--r-- | com32/lua/src/lualib.h | 3 | ||||
-rw-r--r-- | com32/lua/src/syslinux.c | 29 | ||||
-rw-r--r-- | com32/lua/test/syslinux.lua | 1 |
5 files changed, 35 insertions, 0 deletions
diff --git a/com32/lua/src/Makefile b/com32/lua/src/Makefile index f6b1b236..f9e0ab32 100644 --- a/com32/lua/src/Makefile +++ b/com32/lua/src/Makefile @@ -47,6 +47,7 @@ LNXLIBS = ../../libutil/libutil_lnx.a LIBLUA_OBJS := lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o LIBLUA_OBJS += lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o LIBLUA_OBJS += lstate.o lstring.o ltable.o ltm.o lvm.o lzio.o lundump.o +LIBLUA_OBJS += syslinux.o LIBLUA_OBJS += lauxlib.o lbaselib.o ldblib.o ltablib.o \ lstrlib.o loadlib.o linit.o diff --git a/com32/lua/src/linit.c b/com32/lua/src/linit.c index def297b8..04d2b550 100644 --- a/com32/lua/src/linit.c +++ b/com32/lua/src/linit.c @@ -25,6 +25,7 @@ static const luaL_Reg lualibs[] = { {LUA_MATHLIBNAME, luaopen_math}, #endif {LUA_DBLIBNAME, luaopen_debug}, + {LUA_SYSLINUXLIBNAME, luaopen_syslinux}, {NULL, NULL} }; diff --git a/com32/lua/src/lualib.h b/com32/lua/src/lualib.h index 469417f6..2aa93246 100644 --- a/com32/lua/src/lualib.h +++ b/com32/lua/src/lualib.h @@ -39,6 +39,9 @@ LUALIB_API int (luaopen_debug) (lua_State *L); #define LUA_LOADLIBNAME "package" LUALIB_API int (luaopen_package) (lua_State *L); +#define LUA_SYSLINUXLIBNAME "syslinux" +LUALIB_API int (luaopen_syslinux) (lua_State *L); + /* open all previous libraries */ LUALIB_API void (luaL_openlibs) (lua_State *L); diff --git a/com32/lua/src/syslinux.c b/com32/lua/src/syslinux.c new file mode 100644 index 00000000..8e88fb96 --- /dev/null +++ b/com32/lua/src/syslinux.c @@ -0,0 +1,29 @@ +#include <stdlib.h> +#include <string.h> + +#define lnetlib_c /* Define the library */ + +#include "lua.h" +#include "lauxlib.h" +#include "lualib.h" + +static int sl_run_command(lua_State *L) +{ + const char *cmd = luaL_checkstring(L, 1); /* Reads the string parameter */ + syslinux_run_command(cmd); + return 0; +} + + +static const luaL_reg syslinuxlib[] = { + {"run_command", sl_run_command}, + {NULL, NULL} +}; + +/* This defines a function that opens up your library. */ + +LUALIB_API int luaopen_syslinux (lua_State *L) { + luaL_openlib(L, LUA_SYSLINUXLIBNAME, syslinuxlib, 0); + return 1; +} + diff --git a/com32/lua/test/syslinux.lua b/com32/lua/test/syslinux.lua new file mode 100644 index 00000000..3f72ebea --- /dev/null +++ b/com32/lua/test/syslinux.lua @@ -0,0 +1 @@ +syslinux.run_command("memdisk initrd=/dos/BIOS/FSC-P7935-108.img raw") |