diff options
author | Hung-chi Lihn <hlihn@google.com> | 2012-09-22 18:23:38 +0200 |
---|---|---|
committer | Erwan Velu <erwanaliasr1@gmail.com> | 2012-09-22 18:23:38 +0200 |
commit | 280a43d406e02b1e8439e90eedb65379847c7df9 (patch) | |
tree | 42768f0a4456beae8dd3a4a9cccd712bdefef536 | |
parent | a634ca1454ee70e115f0a0a319f3e02f273381e8 (diff) | |
download | syslinux-280a43d406e02b1e8439e90eedb65379847c7df9.tar.gz |
Added the native syslinux functions config_file(), ipappend_strs(), and reboot() to Lua.c32. This allows the Lua script to query the config file name and the ipappend strings (pxelinux only), as well as to perform reboot (warm and cold) to the system.
In Lua.c32, the extension will be used as the following:
1. syslinux.config_file() will return the config file string.
2. syslinux.ipappend_strs() will return a table of IPAPPEND strings with numerical indices.
3. syslinux.reboot() will perform cold reboot, while syslinux.reboot(1) will perform warm reboot.
Signed-off-by: Hung-chi Lihn <hlihn@google.com>
Signed-off-by: Erwan Velu <erwanaliasr1@gmail.com>
-rw-r--r-- | com32/lua/src/syslinux.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/com32/lua/src/syslinux.c b/com32/lua/src/syslinux.c index af5db834..afcdcaad 100644 --- a/com32/lua/src/syslinux.c +++ b/com32/lua/src/syslinux.c @@ -39,6 +39,7 @@ #include "syslinux/loadfile.h" #include "syslinux/linux.h" #include "syslinux/config.h" +#include "syslinux/reboot.h" int __parse_argv(char ***argv, const char *str); @@ -408,6 +409,35 @@ static int sl_boot_it(lua_State * L) initramfs, NULL, (char *)cmdline); } +static int sl_config_file(lua_State * L) +{ + const char *config_file = syslinux_config_file(); + lua_pushstring(L, config_file); + return 1; +} + +static int sl_reboot(lua_State * L) +{ + int warm_boot = luaL_optint(L, 1, 0); + /* explicitly convert it to 1 or 0 */ + warm_boot = warm_boot? 1 : 0; + syslinux_reboot(warm_boot); + return 0; +} + +static int sl_ipappend_strs(lua_State * L) +{ + int i; + const struct syslinux_ipappend_strings *ip_strs = syslinux_ipappend_strings(); + lua_newtable(L); + for (i = 0; i < ip_strs->count; i++) { + lua_pushinteger(L, i + 1); + lua_pushstring(L, ip_strs->ptr[i]); + lua_settable(L,-3); + } + return 1; +} + static int sl_derivative(lua_State * L) { const struct syslinux_version *sv; @@ -459,6 +489,9 @@ static const luaL_reg syslinuxlib[] = { {"initramfs_load_archive", sl_initramfs_load_archive}, {"initramfs_add_file", sl_initramfs_add_file}, {"boot_it", sl_boot_it}, + {"config_file", sl_config_file}, + {"ipappend_strs", sl_ipappend_strs}, + {"reboot", sl_reboot}, {"derivative", sl_derivative}, {"version", sl_version}, {NULL, NULL} |