From: jdennis AT ultranet DOT com ("John R. Dennis") Subject: Re: gcc for WinNT 7 Mar 1997 19:42:25 -0800 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: <199703072049.PAA27466.cygnus.gnu-win32@cinna.ultra.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Original-To: rminnich AT sarnoff DOT com Original-CC: jqb AT netcom DOT com, kokyong AT irdu DOT nus DOT sg, gnu-win32 AT cygnus DOT com In-reply-to: (rminnich AT sarnoff DOT com) Original-Sender: owner-gnu-win32 AT cygnus DOT com >>>>> "Ron" == Ron G Minnich writes: Ron> reading in text mode? this is a simple int fd = open("file", Ron> O_RDONLY); fd = read(blah blah) Ron> How do you control text mode from that? new options or an Ron> fcntl? ron - For help on using this list, send a message to Ron> "gnu-win32-request AT cygnus DOT com" with one line of text: "help". There are many ways to set binary vs. text mode on a file stream. in fopen add either the b (binary) or the t (text) character in the mode string, e.g. fopen(filename "rb") to open a file for binary reading. In open() bitwise OR one of _O_BINARY, _O_TEXT flags. You can call _setmode(handle, mode) where mode is _O_TEXT or _O_BINARY after a file is open, for example: /* Set "stdin" to have binary mode: */ result = _setmode( _fileno( stdin ), _O_BINARY ); if( result == -1 ) perror( "Cannot set mode" ); else printf( "'stdin' successfully changed to binary mode\n" ); You can set the global variable _fmode. The _fmode variable sets the default file-translation mode for text or binary translation. It is declared in STDLIB.H as extern int _fmode; The default setting of _fmode is _O_TEXT, for text-mode translation. _O_BINARY is the setting for binary mode. You can change the value of _fmode in either of two ways: Link with BINMODE.OBJ. This changes the initial setting of _fmode to _O_BINARY, causing all files except stdin, stdout, and stderr to be opened in binary mode. Change the value of _fmode directly by setting it in your program. Hope that helps, John Dennis - For help on using this list, send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".