lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sun, Mar 27, 2011 at 11:26 AM, Sean Conner <sean@conman.org> wrote:
>  Perhaps I'm missing something, but I've done stuff like:
>
> Lua:
>
>        f = io.open("/tmp/foo","r")
>        x = blah(f)
>
> C:
>
>        int blah(lua_State *L)
>        {
>          FILE **pfp;
>
>          pfp = luaL_checkudata(L,1,LUA_FILEHANDLE);
>          /* ... use *pfp to do fileish things */
>        }

I've done the same, but on /dev.ttyS0, so I could then make tc calls
to set the terminal attributes.

Its not "official" but works fine with lua. Maybe lua and luajit can
coordinate to have a luaL_ api that  returns the FILE*.

Sam