home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / ISCONS.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  1KB  |  43 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*
  4. **  iscons()
  5. **
  6. **  A function to determine if a specified stream refers to the console.
  7. **
  8. **  Original Copyright 1988-1991 by Bob Stout as part of
  9. **  the MicroFirm Function Library (MFL)
  10. **
  11. **  The user is granted a free limited license to use this source file
  12. **  to create royalty-free programs, subject to the terms of the
  13. **  license restrictions specified in the LICENSE.MFL file.
  14. */
  15.  
  16. #include <dos.h>
  17. #include "dosfiles.h"
  18.  
  19. int iscons(FILE *fp)
  20. {
  21.       union REGS regs;
  22.  
  23.       regs.x.ax = 0x4400;
  24.       regs.x.bx = (unsigned)fileno(fp);
  25.       intdos(®s, ®s);
  26.       if (0 == (regs.x.ax & 0x80))
  27.             return 0;
  28.       return TOBOOL(regs.x.ax & 0x13);
  29. }
  30.  
  31. #ifdef TEST
  32.  
  33. int main(void)
  34. {
  35.       fprintf(stderr, "stdin is%s redirected\n",
  36.             iscons(stdin) ? " not" : "");
  37.       fprintf(stderr, "stdout is%s redirected\n",
  38.             iscons(stdout) ? " not" : "");
  39.       return 0;
  40. }
  41.  
  42. #endif /* TEST */
  43.