blob: b757d89b5944eb0e6c45762fa4c27515dc03edc9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
/*
** iscons()
**
** A function to determine if a specified stream refers to the console.
**
** Original Copyright 1988-1991 by Bob Stout as part of
** the MicroFirm Function Library (MFL)
**
** This subset version is hereby donated to the public domain.
*/
#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(®s, ®s);
if (0 == (regs.x.ax & 0x80))
return 0;
return BOOL(regs.x.ax & 0x13);
}
#ifdef TEST
int main(void)
{
fprintf(stderr, "stdin is%s redirected\n",
iscons(stdin) ? " not" : "");
fprintf(stderr, "stdout is%s redirected\n",
iscons(stdout) ? " not" : "");
}
#endif /* TEST */
|