[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Extending the io library
- From: Thomas Lauer <thomas.lauer@...>
- Date: Thu, 17 Jul 2008 11:58:48 +0100
"Paul Moore" <email@example.com> wrote:
> On 17/07/2008, Thomas Lauer <firstname.lastname@example.org> 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.