home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
PROGRAMM
/
SNIP0492.ZIP
/
ISFILE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-06
|
914b
|
39 lines
/*
** ISFILE.C - determine if a file handle is associated with a file
**
** by: Bob Jarvis
**
** Returns: 1 - handle is associated with a file
** 0 - handle is associated with a device
** -1 - error
*/
#include <dos.h>
int isfile(int handle)
{
union REGS regs;
regs.x.ax = 0x4400;
regs.x.bx = handle;
intdos(®s, ®s);
if(regs.x.cflag == 0) /* carry flag not set */
{
if((regs.x.dx & 0x80) == 0)
return 1;
else return 0;
}
else return -1; /* error - return -1 */
}
#include <stdio.h>
int main()
{
if(isfile(fileno(stdout)))
printf("stdout is associated with a file\n");
else printf("stdout is NOT associated with a file\n");
}