home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / LIB / unix.zoo / isatty.c < prev    next >
Text File  |  2009-11-06  |  2KB  |  59 lines

  1.  
  2. /***************************************************************************/
  3. /*                                                                         */
  4. /* isatty() : Unix library (OS9/68000)                                     */
  5. /* ========                                                                */
  6. /*                                                                         */
  7. /* Author:     K. Schmitt                                                  */
  8. /* Compiler:   Microware C Vers. 3.0                                       */
  9. /* OS:         OS9/68000 Vers. 2.2                                         */
  10. /*                                                                         */
  11. /* Edition History                                                         */
  12. /* ===============                                                         */
  13. /*                                                                         */
  14. /* Ed. 0.00  Date 11/11/88                                                 */
  15. /*           First version                                                 */
  16. /*                                                                         */
  17. /***************************************************************************/
  18. /*                                                                         */
  19. /* Description                                                             */
  20. /*                                                                         */
  21. /*
  22.  
  23.      NAME
  24.           isatty - check fildes
  25.  
  26.      SYNOPSIS
  27.           int isatty (fildes)
  28.           int fildes;
  29.           struct sgbuf _tty_opt_; (GLOBAL defined - see ioctl() )
  30.  
  31.      DESCRIPTION
  32.           Isatty returns 1 if fildes is associated with a terminal
  33.           device, 0 otherwise. If the fildes is invalid, -1.
  34.  
  35.      FILES sgstat.h
  36.  
  37. */
  38.  
  39. #define DT_SCF      0    /* device type: SCF        */
  40. #define ERROR      -1
  41.  
  42. #include <sgstat.h>
  43.  
  44. struct sgbuf _tty_opt_;  /* buffer for path options */
  45.  
  46. isatty(fildes)
  47.           int fildes;
  48.           {
  49.           extern int _gs_opt();
  50.           register struct sgbuf *tty_options = &_tty_opt_;
  51.  
  52.           if (_gs_opt(fildes,tty_options) == ERROR) return (ERROR);
  53.           if (tty_options->sg_class != DT_SCF) return (0);
  54.  
  55.           return (1); /* it's a tty */
  56.  
  57.           } /* end of isatty */
  58.  
  59.