Subject: Re: gcc for WinNT
From: [email-masked] ("John R. Dennis")

7 Mar 1997 19:42:25 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Original-To: [email-masked]
Original-CC: [email-masked], [email-masked], [email-masked]
In-reply-to: <Pine.SUN.3.91.970307080553.29823B-100000@terra>
	([email-masked])
Original-Sender: [email-masked]

>>>>> "Ron" == Ron G Minnich <[email-masked]> 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> "[email-masked]" 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
"[email-masked]" with one line of text: "help".