[comp.windows.ms.programmer] What to do about stdin, stdout, and stderr under Windows 3.0?

dak@sq.sq.com (David A Keldsen) (04/30/91)

On reading through the includes for the SDK, I see that std{in,out,err} are
not supported under Windows.  While this isn't entirely surprising, what do
you do to substitute for them?  (On Unix, I'd consider opening /dev/null,
but there isn't one that I can find for DOS/MS-WINDOWS.)

Please reply by email; I'll post a summary if there is enough interest.

(Ah, the joys of porting code.  The rambling through the fields of bits,
stumbling over segments...)

Dak
-- 
David A. 'Dak' Keldsen of SoftQuad, Inc. email: dak@sq.com  phone: 416-963-8337
"Anyway, you shouldn't believe everything you read in the Classics," Rincewind
added.  "They never check their facts.  They're just out to sell legends."
	-- _Eric_ by Terry Pratchett

oneel@heawk1.rosserv.gsfc.nasa.gov ( Bruce Oneel ) (05/01/91)

In article <1991Apr30.162028.7771@sq.sq.com> dak@sq.sq.com (David A Keldsen) writes:

   On reading through the includes for the SDK, I see that std{in,out,err} are
   not supported under Windows.  While this isn't entirely surprising, what do
   you do to substitute for them?  (On Unix, I'd consider opening /dev/null,
   but there isn't one that I can find for DOS/MS-WINDOWS.)

   Please reply by email; I'll post a summary if there is enough interest.

   (Ah, the joys of porting code.  The rambling through the fields of bits,
   stumbling over segments...)

   Dak
   -- 
   David A. 'Dak' Keldsen of SoftQuad, Inc. email: dak@sq.com  phone: 416-963-8337
   "Anyway, you shouldn't believe everything you read in the Classics," Rincewind
   added.  "They never check their facts.  They're just out to sell legends."
	   -- _Eric_ by Terry Pratchett
Uh, not to be silly, but don't use them.  But, in the next issue of
Tech Specialist they will have a package to replace stdio in c under
windows 3.0 so that you can write and read from windows.  This from
some kind net person.

bruce
--
| Bruce O'Neel              | internet : oneel@heasfs.gsfc.nasa.gov|
| Code 664/STX              |     span : lheavx::oneel             |
| NASA/GSFC Bld 28/W281     |compuserve: 72737,1315                |
| Greenbelt  MD 20771       |  AT&Tnet : (301)-286-4585            |

Thats me in the corner, thats me in the spotlight, losin' my religion -- rem

rogerhef@matt.ksu.ksu.edu (Roger Heflin) (05/02/91)

In <1991Apr30.162028.7771@sq.sq.com> dak@sq.sq.com (David A Keldsen) writes:

>On reading through the includes for the SDK, I see that std{in,out,err} are
>not supported under Windows.  While this isn't entirely surprising, what do
>you do to substitute for them?  (On Unix, I'd consider opening /dev/null,
>but there isn't one that I can find for DOS/MS-WINDOWS.)

I just tried it, it is not /dev/null it is /dev/nul under dos.


--
Rogerhef@Matt.ksu.ksu.edu                        Roger Heflin
                                                 EECE Grad Student
                                                 (913) 532-5600

mlord@bwdls58.bnr.ca (Mark Lord) (05/03/91)

In article <1991Apr30.162028.7771@sq.sq.com> dak@sq.sq.com (David A Keldsen) writes:
<On reading through the includes for the SDK, I see that std{in,out,err} are
<not supported under Windows.  While this isn't entirely surprising, what do
<you do to substitute for them?  (On Unix, I'd consider opening /dev/null,
<but there isn't one that I can find for DOS/MS-WINDOWS.)

There is a device called NUL for use in the PC world.  NUL == /dev/null

dak@sq.sq.com (David A Keldsen) (05/08/91)

>In article <1991Apr30.162028.7771@sq.sq.com> I wrote:
><On reading through the includes for the SDK, I see that std{in,out,err} are
><not supported under Windows.  While this isn't entirely surprising, what do
><you do to substitute for them?  (On Unix, I'd consider opening /dev/null,
><but there isn't one that I can find for DOS/MS-WINDOWS.)

mlord@bwdls58.bnr.ca (Mark Lord) writes:
>There is a device called NUL for use in the PC world.  NUL == /dev/null

Nice idea, but apparently "NUL" is magical to command.com.  fopen() in
the MSC libraries certainly doesn't do anything useful with "NUL" or
"NUL:"

I guess it's time for the summary, so here are the replies that I
received in the mail:

(1)  /dev/null doesn't work, but /dev/nul *does*.  
     (Ick!  It works empirically, but I don't know if I trust MS not to
     change it, as it sounds like a bug.)
(2)  You shouldn't be using streams under Windows anyhow, read Petzold's 
     book on Windows programming and redirect the output to a window.
     (Not applicable at this stage in development, although it's useful 
     information; clearly this is the model intended for MS-WINDOWS, but
     for this particular purpose, tossing the output to /dev/null is 
     just as useful.)
(3)  Try NUL
     (Doesn't work.)

So, what I'm going to do is...none of the above.  We're using a higher-level
"port" abstraction for what we're doing, and we've created a "null port"
which takes care of the problem and doesn't even use stdio.  Someday, it'll
do the appropriate magic for windowing systems...

Thanks (in no particular order) to:
cs352a41@zaphod.cs.iastate.edu. (Adam Goldberg)
rogerhef@matt.ksu.ksu.edu (Roger Heflin)
poffen@sj.ate.slb.com  (Russ Poffenberger)

Regards,
Dak
-- 
David A. 'Dak' Keldsen of SoftQuad, Inc. email: dak@sq.com  phone: 416-963-8337
"It is well known that _things_ from undesirable universes are always seeking 
entrance into this one, which is the psychic equivalent of handy for the 
buses and closer to the shops." -- Terry Pratchett, _The Light Fantastic_

dj@ctron.com (DJ Delorie) (05/08/91)

In article <1991May7.213347.709@sq.sq.com>, dak@sq.sq.com (David A Keldsen) writes:
> mlord@bwdls58.bnr.ca (Mark Lord) writes:
> >There is a device called NUL for use in the PC world.  NUL == /dev/null
> 
> Nice idea, but apparently "NUL" is magical to command.com.  fopen() in
> the MSC libraries certainly doesn't do anything useful with "NUL" or
> "NUL:"
> (1)  /dev/null doesn't work, but /dev/nul *does*.  
>      (Ick!  It works empirically, but I don't know if I trust MS not to
>      change it, as it sounds like a bug.)

"NUL" is a real device in MS-DOS.  There is a regular device driver
for it, as well as CON LPTx COMx.  By convention, DOS allows you to
specify \DEV\xxx (ex: \DEV\CON) or xxx: (ex: LPT1:) as well as just
xxx (ex: COM3).  There *used* to be a DOS call that made the \DEV\
part mandatory, so you could have a file called CON and a device
called \DEV\CON, but they took that away, so it's just optional now.
They may decide to remove the \DEV\ option completely.  Their standard
convention for device names is NUL or NUL: .

To prove this, try DIR > NUL and then DIR.

Disclaimer: I don't have "Windows", so if it screws up the NUL device
then Windows is at fault, not my information.

DJ
dj@ctron.com

jpc@fct.unl.pt (Jose Pina Coelho) (05/08/91)

In article <1991May7.213347.709@sq.sq.com> dak@sq.sq.com (David A
Keldsen) writes: 
   mlord@bwdls58.bnr.ca (Mark Lord) writes:
   >There is a device called NUL for use in the PC world.  NUL == /dev/null
One should say MSDOS's NUL: <={Sort-of}=> *IX's /dev/null

   Nice idea, but apparently "NUL" is magical to command.com.
Nope, it's in the ibmbio.sys/ibmdos.sys files in pcdos
(io.sys/msdos.sys in msdos).

   fopen() in the MSC libraries certainly doesn't do anything useful
   with "NUL" or "NUL:"

Sounds like MicroSoft C trying to dodge MicroSoft DOS (cute, he ?)
Probably it checks for dev names.

   (1)  /dev/null doesn't work, but /dev/nul *does*.  
	(Ick!  It works empirically, but I don't know if I trust MS not to
	change it, as it sounds like a bug.)
That is due to quite a bug (sorry, feature (i think it's documented,
but i'm not sure), if a filename is 3 characters long, dos
will (try to?) interpret it as dev (ignoreing the missing ':'), so
\dev\nul has a filename with 3 chars (nul) and you can use it.
Ever tried to mess arround (rmdir) with a directory called AUX, or
CON, or ... or even NUL

   (3)  Try NUL
	(Doesn't work.)
Try NUL:, dos is *plain* *weird*.

--
Jose Pedro T. Pina Coelho   | BITNET/Internet: jpc@fct.unl.pt
Rua Jau N 1, 2 Dto          | UUCP: ...!mcsun!unl!jpc
1300 Lisboa, PORTUGAL       | Home phone: (+351) (1) 640767

- If all men were brothers, would you let one marry your sister ?