🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.msdos.programmer
Article #1147

Re: Detecting DOS redirection requests.

#1147
From: Derick J.R. Qua-Gonzalez
Date: Sun, 03 Sep 1995 23:41
44 lines
1941 bytes
Bob Stout <bobstout@neosoft.com> writes:

>Not every DOS C compiler supports the ioctl() call. This is portable 
>between all major compilers:

>/*
>**  iscons()
>**
>**  A function to determine if a specified stream refers to the console.

>*/

>#include <stdio.h>
>#include <dos.h>

>#define BOOL(x) (!(!(x)))

>int iscons(FILE *fp)
>{
>      union REGS regs;

>      regs.x.ax = 0x4400;
>      regs.x.bx = (unsigned)fileno(fp);
>      intdos(&regs, &regs);
>      if (0 == (regs.x.ax & 0x80))
>            return 0;
>      return BOOL(regs.x.ax & 0x13);
>}

Careful Bob!  :-)  This isn't ``portable between all major compilers.''
The very presence of <dos.h>, the union REGS and the intdos call should
have been a clue to that!  The qualification should have been ``portable
between all major _MS-DOS_ C compilers.''

Best regards,
Derick.
--
+------------------------------------------------------------------------+
| Derick R. Qua-Gonzalez                                      | ________ |
| Department of High Energy Physics, Cal State University     | \      / |
| dqua@dqua.EarthLink.Net                                     |  \    /  |
|     ``It is better to be hated for what one is,             |   \  /   |
|       than loved for what one is not.'' (A. Gide)           | G  \/ USA|
+-------------------------------------------------------------+----------+
Technical Details
Message-ID: <dqua.810171676@dqua>
Path: arc1-ca.pugleaf.net!nntp.earthlink.net!dqua!dqua
References: <92011.microtsk@fox.nstn.ca> <42bg3q$dr0@ixnews6.ix.netcom.com> <42cu2b$dk4@mo6.rc.tudelft.nl> <Pine.BSD.3.91.950903152817.23959A-100000@Starbase.NeoSoft.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nntp.earthlink.net!dqua!dqua
From: dqua@earthlink.net (Derick J.R. Qua-Gonzalez)
Newsgroups: alt.msdos.programmer,comp.lang.c,comp.os.msdos.programmer
Subject: Re: Detecting DOS redirection requests.
Date: 3 Sep 95 23:41:16 GMT
Organization: Earthlink Network, Inc.
Message-ID: <dqua.810171676@dqua>
References: <92011.microtsk@fox.nstn.ca> <42bg3q$dr0@ixnews6.ix.netcom.com> <42cu2b$dk4@mo6.rc.tudelft.nl> <Pine.BSD.3.91.950903152817.23959A-100000@Starbase.NeoSoft.COM>
NNTP-Posting-Host: dqua.earthlink.net