lua-users home
lua-l archive

Re: Extending the io library

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


"Paul Moore" <p.f.moore@gmail.com> wrote:
> 
> On 17/07/2008, Thomas Lauer <thomas.lauer@virgin.net> wrote:
> > Why not set Lua's io.std* variables from your C code?
> 
> To what? I only have a FILE* and I can't get an io object from it, as
> far as I can tell.
That's where the "right massaging" I was referring to comes in.
Basically it acquires a temp FILE* by wildly duplicating file handles
(OS and runtime) and then slips that under the hoods of the io library
into the right slots. Then it executes a piece of script and finally
reassigns the old FILE* handles.
It's a half-ugly hack and may not be stable in all environments and
platforms but so far it works. Good luck.
-- 
cheers thomasl
web: http://thomaslauer.com/start

AltStyle によって変換されたページ (->オリジナル) /