home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / posix / termios / tcgetatr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-15  |  976 b   |  49 lines

  1. #include <errno.h>
  2. #include <io.h>
  3. #include <stddef.h>
  4. #include <termios.h>
  5. #include <libc/bss.h>
  6. #include <libc/ttyprvt.h>
  7.  
  8. #define _DEV_STDIN  0x0001
  9. #define _DEV_STDOUT 0x0002
  10. #define _DEV_NUL    0x0004
  11. #define _DEV_CLOCK  0x0008
  12. #define _DEV_RAW    0x0020
  13. #define _DEV_CDEV   0x0080
  14. #define _DEV_IOCTRL 0x4000
  15.  
  16. int
  17. tcgetattr (int handle, struct termios *termiosp)
  18. {
  19.   short devmod;
  20.  
  21.   /* initialize */
  22.   if (__libc_termios_hook_common_count != __bss_count)
  23.     __libc_termios_init ();
  24.  
  25.   /* check handle whether valid or not */
  26.   devmod = _get_dev_info (handle);
  27.   if (devmod == -1)
  28.     return -1;
  29.  
  30.   /* check console */
  31.   if (! (devmod & _DEV_CDEV) || ! (devmod & (_DEV_STDIN|_DEV_STDOUT)))
  32.     {
  33.       errno = ENOTTY;
  34.       return -1;
  35.     }
  36.  
  37.   /* check arguments */
  38.   if (termiosp == NULL)
  39.     {
  40.       errno = EINVAL;
  41.       return -1;
  42.     }
  43.  
  44.   /* get the structure */
  45.   *termiosp = __libc_tty_p->t_termios;
  46.  
  47.   return 0;
  48. }
  49.