Subject: Re: re-configuring standard input to binary mode
From: [email-masked] (Ku Wei)

7 Jul 1997 17:34:31 -0700
Sender: [email-masked]
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Original-To: Peter Lu <[email-masked]>
Original-cc: [email-masked]
In-Reply-To: <[email-masked]>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Original-Sender: [email-masked]

It seems to me that the consle input and output are set binary since the 
following code segment is working fine on my home PC under bash 2.01. 
However, it will not working properly under DOS prompt in which the 
'\x0d' is missing due to the property of text mode.

PS: I use Sergey's patch of gnuwin32.dll, gnuwin32.a, and bash 2.01 
with binary mounting.

int main(int argc, char* argv[]) {
  if( argc == 1) {
    //  ...
    // need to set cout as binary to make this work under DOS !
    // OK with UNIX
    dos2ux( cout, cin);
  }
  else if( argc == 3) {
    ifstream file_in;
    ofstream file_out;
    ...
    file_in.open( argv[1], ios::in | ios::binary);
    file_out.open( argv[2], ios::out | ios::binary);
    ...
  dos2ux( file_out, file_in);
}

void dos2ux( ostream & out, istream & in) {
  char c;

  while( ( c = in.get()) != -1)
    if( c != '\x0d') out << c;
}

Hope this help.

Sincerely,
Wei Ku

***************************************
Department of Physics and Astronomy
The University of Tennessee
1408 Circle Drive
Knoxville, Tennessee 37996-1200
[email-masked]
---------------------------------------
Solid State Division
Oak Ridge National Laboratory
P.O.Box 2008
Oak Ridge, TN 37831-6032
Phone: (423) 574-5795
Fax: (423) 574-4143
[email-masked]
***************************************

On Mon, 7 Jul 1997, Peter Lu wrote:

> Hi,
> 
> 	How does one configure the standard input stream (fd = 0) to run in
> binary mode?  The default mode seems to be text mode.
> 
> 	I've tried to use fcntl() to no avail.  I've also tried tricks
> like dup() and fdopen().
> 
> 	Thanks for any help.
> 
> Peter Lu ([email-masked])
> -
> For help on using this list (especially unsubscribing), send a message to
> "[email-masked]" with one line of text: "help".
> 
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".