Path: utzoo!utgpu!water!watmath!clyde!rutgers!cmcl2!nrl-cmf!mailrus!umix!uunet!seismo!sundc!pitstop!sun!quintus!ok From: ok@quintus.UUCP (Richard A. O'Keefe) Newsgroups: comp.lang.c Subject: Re: Binary I/O on stdin/stdout? Summary: possibly stupid suggestion Message-ID: <844@cresswell.quintus.UUCP> Date: 2 Apr 88 04:20:54 GMT References: <302@goofy.megatest.UUCP> <225800017@uxe.cso.uiuc.edu> <4296@hoptoad.uucp> Organization: Quintus Computer Systems, Mountain View, CA Lines: 25 In article <4296@hoptoad.uucp>, gnu@hoptoad.uucp (John Gilmore) writes: > karl@haddock.ISC.COM (Karl Heuer) wrote: > > In article <8036@elsie.UUCP> ado@elsie.UUCP (Arthur David Olson) writes: > > >> > There seems to be *no way* to "reopen" these streams as binary. > This really works on Unix, and it would be pretty easy to make these > work on any system that could support binary files as stdin/stdout, > (and had a shell that would make pipes, like MSDOS or Unix), but not if > the standard doesn't tell me and those implementers a good way for me > to say "please sir, don't translate CR to LF on stdin for me, just let > me at the bytes"... If UNIX needed this facility, and if it used "b" to indicate binary mode, FILE *binin = fdopen(fileno(stdin), "rb"); FILE *binout= fdopen(fileno(stdout),"wb"); /* use bin_in, bin_out instead of stdin, stdout */ would do the job. Would this work in MSDOS? Instead of having a way of switching the mode, why not ask for two more "standard" streams: binin and binout, where systems which don't need a distinction between text and binary would identify them with stdin and stdout, systems where switching is possible would switch as necessary, and systems where only one method of connexion was allowed would have all I/O on the "wrong" connexions return EOF, and systems where either method was allowed but not both would pick it up from the first use.