crimmins@uxc.cso.uiuc.edu.UUCP (02/09/87)
/* Written 11:38 am Feb 5, 1987 by bob@cald80.UUCP in uxc.cso.uiuc.edu:comp.sys.ibm.pc */ >In article <3281@hplabs.hplabs.UUCP> drichard@hplabs.UUCP (Dave Richards) writes: >> >>putc()ing characters to a stream that was successfully opened via >>fopen() for "w" access to "COM1". I check the returned pointer for NULL >>and guaranteed fopen()s success. However, after writing BUFSIZ >>...much deleted for Pnews >> Dave Richards at Hewlett-Packard Labs (drichard@hplabs) > >I have found that fopen()ing a file causes the system to assume that >you are going to send text to it. It usually turns on ^Z mapping to >end of file. It also does \n to \r\n mapping. Needless to say, you >can't pump binary to it. I'm not sure about aztec or desmet, but most of the C compilers I've used (including MSC) give you the option of opening the file in binary mode by appending a b to the mode (i.e. fopen("file","wb");). >Try to use open() on COM1 and see if that has any better success. With MSC, there are 5 predefined stream pointers...stdin, stdout, stderr, stdaux (COM1:), and stdprn (LPT1:). No opening is necessary...just write to the appropriate stream. This is all documented completely in the manuals. > Bob Meyer > Calspan ATC ---- Dan Crimmins University of Illinois at Urbana-Champaign Computing Services Office - Micro Consulting Dept. ARPA: crimmins@uiucuxc.cso.uiuc.edu BITNET: crimmins@uiucuxc.bitnet CSNET: crimmins@uiucuxc.csnet UUCP: {ihnp4,pur-ee,convex}!uiucdcs!uiucuxc!crimmins
sbanner1@uvicctr.UUCP (02/15/87)
In article <174200030@uxc.cso.uiuc.edu> crimmins@uxc.cso.uiuc.edu writes: > >/* Written 11:38 am Feb 5, 1987 by bob@cald80.UUCP in uxc.cso.uiuc.edu:comp.sys.ibm.pc */ >>In article <3281@hplabs.hplabs.UUCP> drichard@hplabs.UUCP (Dave Richards) writes: >>> >>>putc()ing characters to a stream that was successfully opened via >>>fopen() for "w" access to "COM1". I check the returned pointer for NULL >>>and guaranteed fopen()s success. However, after writing BUFSIZ >>>...much deleted for Pnews >>> Dave Richards at Hewlett-Packard Labs (drichard@hplabs) >> >>I have found that fopen()ing a file causes the system to assume that >>you are going to send text to it. It usually turns on ^Z mapping to >>end of file. It also does \n to \r\n mapping. Needless to say, you >>can't pump binary to it. > >I'm not sure about aztec or desmet, but most of the C compilers I've >used (including MSC) give you the option of opening the file in >binary mode by appending a b to the mode (i.e. fopen("file","wb");). > >>Try to use open() on COM1 and see if that has any better success. > >With MSC, there are 5 predefined stream pointers...stdin, stdout, >stderr, stdaux (COM1:), and stdprn (LPT1:). No opening is >necessary...just write to the appropriate stream. This is all >documented completely in the manuals. Yes, but what if you want to read binary from stdin, and write binary to stdout??? S. John Banner ...!{uw-beaver,ubc-vision}!uvicctr!sbanner1 ccsjb@uvvm sbanner1@uvunix.UVIC.CDN #1 1121 Fort St. Victoria BC. Canada V8V 3K9
ljz@well.UUCP (02/15/87)
In article <227@uvicctr.UUCP> sbanner1@uvicctr.UUCP (S. John Banner) writes: >Yes, but what if you want to read binary from stdin, and write >binary to stdout??? You could then use the setmode() function (in the Microsoft C run-time library) to change the mode ... #include <stdio.h> #include <fcntl.h> extern int errno; ... if(setmode(fileno(stdin), O_BINARY) == -1) printf("error = %d when changing mode to binary\n", errno); As described in the "Run-time Library Reference Manual", setmode() changes the mode (text or binary) of an already open file. Lloyd Zusman Master Byte Software ...!hplabs!well!ljz
crimmins@uxc.cso.uiuc.edu.UUCP (02/19/87)
>In article <174200030@uxc.cso.uiuc.edu> crimmins@uxc.cso.uiuc.edu writes: >> (stuff deleted) >>With MSC, there are 5 predefined stream pointers...stdin, stdout, >>stderr, stdaux (COM1:), and stdprn (LPT1:). No opening is >>necessary...just write to the appropriate stream. This is all >>documented completely in the manuals. > >Yes, but what if you want to read binary from stdin, and write >binary to stdout??? > > S. John Banner Try: #include <fcntl.h> int result; result = setmode(fileno(stdin),O_BINARY); result = setmode(fileno(stdout),O_BINARY); This is taken directly from the MSC run-time library documentation, page 346-7. As an aside, I'd just like to add that I think the MSC documentation is a model of what good documentation should be. I have never had a problem that it did not cover, and is superb in all aspects. Congratulation, Microsoft. Keep up the good work. ---- Dan Crimmins University of Illinois at Urbana-Champaign Computing Services Office - Micro Consulting Dept. ARPA: crimmins@uiucuxc.cso.uiuc.edu BITNET: crimmins@uiucuxc.bitnet CSNET: crimmins@uiucuxc.csnet UUCP: {ihnp4,pur-ee,convex}!uiucdcs!uiucuxc!crimmins
tom@uw-warp.UUCP (02/19/87)
In article <227@uvicctr.UUCP> sbanner1@uvicctr.UUCP (S. John Banner) writes: >In article <174200030@uxc.cso.uiuc.edu> crimmins@uxc.cso.uiuc.edu writes: >>/* Written 11:38 am Feb 5, 1987 by bob@cald80.UUCP in uxc.cso.uiuc.edu:comp.sys.ibm.pc */ >>With MSC, there are 5 predefined stream pointers...stdin, stdout, >>stderr, stdaux (COM1:), and stdprn (LPT1:). No opening is >>necessary...just write to the appropriate stream. This is all >>documented completely in the manuals. > >Yes, but what if you want to read binary from stdin, and write >binary to stdout??? > > S. John Banner > >...!{uw-beaver,ubc-vision}!uvicctr!sbanner1 >ccsjb@uvvm >sbanner1@uvunix.UVIC.CDN Somebody already said this a while back: #include <stdio.h> #include <fcntl.h> setmode (fileno(stdin), O_BINARY); setmode (fileno(stdout), O_BINARY); -- Tom May. uw-beaver!uw-nsr!uw-warp!tom