[syslinux] Added functions config_file(), ipappend_strs(), and reboot() to Lua.c32.

Geert Stappers stappers at stappers.nl
Sun Sep 23 11:35:58 PDT 2012


On Sun, Sep 23, 2012 at 06:42:57PM +0200, Hung-chi Lihn wrote:

It was me, stappers,  who wrote the _reformatted_ patch.

> From: Hung-chi Lihn <hlihn at google.com>

Is the original author of the [PATCH] that
  Added 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.
> ---
>  com32/lua/src/syslinux.c |   33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/com32/lua/src/syslinux.c b/com32/lua/src/syslinux.c
> index af5db83..afbccd4 100644
> --- a/com32/lua/src/syslinux.c
> +++ b/com32/lua/src/syslinux.c
> @@ -408,6 +409,35 @@ static int sl_boot_it(lua_State * L)
       <snip linecount="19"/>
> +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;
> +}
> +

That give a compiler error.

After reverting a line-wrap and prefixed line numbers I have this:

428 static int sl_ipappend_strs(lua_State * L)
429 {
430     int i;
431     const struct syslinux_ipappend_strings *ip_strs = syslinux_ipappend_strings lua_newtable(L);
432     for (i = 0; i < ip_strs->count; i++) {
433         lua_pushinteger(L, i + 1);
434         lua_pushstring(L, ip_strs->ptr[i]);
435         lua_settable(L,-3);
436     }
437     return 1;
438 }

But the still this compile error:

make[2]: Entering directory `/usr/src/syslinux/com32/lua/src'
gcc -std=gnu99 -m32 -fno-stack-protector -fwrapv -freg-struct-return -march=i386 -Os -fomit-frame-pointer -mregparm=3 -DREGPARM=3 -fno-exceptions -fno-asynchronous-unwind-tables -fPIE -falign-functions=0 -falign-jumps=0 -falign-labels=0 -falign-loops=0 -mpreferred-stack-boundary=2 -W -Wall -march=i386 -fomit-frame-pointer -D__COM32__ -DDYNAMIC_MODULE -nostdinc -iwithprefix include -I../../../com32/libutil/include -I../../../com32/include -I../../../com32/gplinclude -I../../../core/include -DSYSLINUX -DLUA_ANSI -c -o syslinux.o syslinux.c
syslinux.c: In function 'sl_ipappend_strs':
syslinux.c:431:55: warning: initialization from incompatible pointer type [enabled by default]
syslinux.c:431:81: error: expected ',' or ';' before 'lua_createtable'
make[2]: *** [syslinux.o] Error 1
make[2]: Leaving directory `/usr/src/syslinux/com32/lua/src'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/syslinux/com32'
make: *** [all] Error 2


So where I did my best to help,
seems it now that more help is needed to get an ipappend function in Lua.


Groeten
Geert Stappers
-- 
> And is there a policy on top-posting vs. bottom-posting?
Yes.



More information about the Syslinux mailing list