Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!sri-unix!hplabs!decwrl!pyramid!prls!philabs!mcnc!ecsvax!bet From: bet@ecsvax.UUCP Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: Unbuffered I/O using MicroSoft C 3.0 Message-ID: <2609@ecsvax.UUCP> Date: Wed, 28-Jan-87 19:25:09 EST Article-I.D.: ecsvax.2609 Posted: Wed Jan 28 19:25:09 1987 Date-Received: Sat, 31-Jan-87 05:47:22 EST References: <1867@sunybcs.UUCP> <645@uw-warp.UUCP> <650@uw-warp.UUCP> Reply-To: bet@ecsvax.UUCP (Bennett E. Todd III) Organization: Duke User Services Lines: 53 Xref: watmath comp.lang.c:886 comp.sys.ibm.pc:1267 While setbuf will still be needed to get unbuffered I/O, there is a wondrously simple way to ensure that I/O doesn't get redirected without mucking about with DOS interrupts! Like so: FILE *fopen(), *console; console = fopen("\\dev\\con", "r"); The '\' characters are doubled because '\' is the quoting character in C strings; you can simplify the above to the more obvious: FILE *fopen(), *console; console = fopen("con", "r"); (or "con:", or whatever floats your boat) if you are guaranteed that your program will never be run on a system using the undocumented DOS AVAILDEV function to hide devices. -Bennett P.S. AVAILDEV: Issue DOS function call INT 21H with AH=37H to access SWITCHAR and AVAILDEV: AL=0 read SWITCHAR value into DL AL=1 set SWITCHAR from DL AL=2 read AVAILDEV into DL AL=3 set AVAILDEV from DL The SWITCHAR is the character used for "switches" in DOS command arguments (defaults to '/', as in "DIR /P"). '-' is popular to make a system look more like UNIX; if the SWITCHAR is anything other than '/', then '/' may be used instead of '\' for pathnames (even more like UNIX!). AVAILDEV=0 means than devices must be referenced in an imaginary subdirectory "\dev" (shades of UNIX's /dev/*); a filename "prn.dat" can be created on disk and manipulated like any other. If AVAILDEV != 0 then device names are recognized anywhere (this is the default): "prn.dat" is synonymous with "prn:". NOTE: These functions are undocumented, whicn means they are unsupported, which means they are liable to go away whenever Microsoft is feeling frisky. Use at your own risk! However, PLEASE program around them to make life nicer for the daring souls who take the risk. -Bennett -- Bennett Todd -- Duke Computation Center, Durham, NC 27706-7756; (919) 684-3695 UUCP: ...{decvax,seismo,philabs,ihnp4,akgua}!mcnc!ecsvax!duccpc!bet BITNET: DBTODD@TUCC.BITNET -or- DBTODD@TUCCVM.BITNET -or- bet@ECSVAX.BITNET terrorist, cryptography, DES, drugs, cipher, secret, decode, NSA, CIA, NRO.