lua-users home
lua-l archive

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


Have a look at liolib.c:
LUALIB_API int luaopen_io (lua_State *L)
How about adding your _setmode(fileno(stdin), O_BINARY);
in this function?

Regards,
Jason
----- Original Message ----- 
From: <lua@gavinmckenzie.fastmail.fm>
To: <lua@bazar2.conectiva.com.br>
Sent: Monday, October 23, 2006 5:45 PM
Subject: A method to set stdin and stdout to binary mode?


> Folks,
> 
> I am about to write a print-stream filter that needs to run on a Windows
> box.  It has to receive the print-stream on stdin and produce a filtered
> stream on stdout.  Because I'm dealing with a print-stream (PCL) and I'm
> on Windows, I need to put stdin and stdout into binary mode.  Were I in
> C, I'd do the following:
> 
>  _setmode(fileno(stdin), O_BINARY);
>  _setmode(fileno(stdout), O_BINARY);
> 
> Programming in Lua says, in section 21.2.2 "Binary Files" that stdin and
> stdout are open in text mode.
> So...I'm looking for a way to access stdin and stdout in binary mode. 
> Is there any way to make this happen in Lua?
> 
> Gavin.
>