1 /* 2 tty.h -- centralized definitions for a variety of terminal interfaces 3 4 created by DPK, Oct. 1986 5 6 Rearranged to work with autoconf, added TTY_state, get_tty/set_tty 7 Michael Rendell, May '94 8 9 last edit: 30-Jul-1987 D A Gwyn 10 */ 11 /* $Id$ */ 12 13 /* some useful #defines */ 14 #ifdef EXTERN 15 # define I__(i) = i 16 #else 17 # define I__(i) 18 # define EXTERN extern 19 # define EXTERN_DEFINED 20 #endif 21 22 /* Don't know of a system on which including sys/ioctl.h with termios.h 23 * causes problems. If there is one, these lines need to be deleted and 24 * aclocal.m4 needs to have stuff un-commented. 25 */ 26 #ifdef SYS_IOCTL_WITH_TERMIOS 27 # define SYS_IOCTL_WITH_TERMIOS 28 #endif /* SYS_IOCTL_WITH_TERMIOS */ 29 #ifdef SYS_IOCTL_WITH_TERMIO 30 # define SYS_IOCTL_WITH_TERMIO 31 #endif /* SYS_IOCTL_WITH_TERMIO */ 32 33 #ifdef HAVE_TERMIOS_H 34 # include <termios.h> 35 # ifdef SYS_IOCTL_WITH_TERMIOS 36 # if !(defined(sun) && !defined(__svr4__)) /* too many warnings on sunos */ 37 /* Need to include sys/ioctl.h on some systems to get the TIOCGWINSZ 38 * stuff (eg, digital unix). 39 */ 40 # include <sys/ioctl.h> 41 # endif /* !(sun && !__svr4__) */ 42 # endif /* SYS_IOCTL_WITH_TERMIOS */ 43 typedef struct termios TTY_state; 44 #else 45 # ifdef HAVE_TERMIO_H 46 # include <termio.h> 47 # ifdef SYS_IOCTL_WITH_TERMIO 48 # include <sys/ioctl.h> /* see comment above in termios stuff */ 49 # endif /* SYS_IOCTL_WITH_TERMIO */ 50 # if _BSD_SYSV /* BRL UNIX System V emulation */ 51 # ifndef NTTYDISC 52 # define TIOCGETD _IOR( 't', 0, int ) 53 # define TIOCSETD _IOW( 't', 1, int ) 54 # define NTTYDISC 2 55 # endif 56 # ifndef TIOCSTI 57 # define TIOCSTI _IOW( 't', 114, char ) 58 # endif 59 # ifndef TIOCSPGRP 60 # define TIOCSPGRP _IOW( 't', 118, int ) 61 # endif 62 # endif /* _BSD_SYSV */ 63 typedef struct termio TTY_state; 64 # else /* HAVE_TERMIO_H */ 65 /* Assume BSD tty stuff. Uses TIOCGETP, TIOCSETN; uses TIOCGATC/TIOCSATC if 66 * available, otherwise it uses TIOCGETC/TIOCSETC (also uses TIOCGLTC/TIOCSLTC 67 * if available) 68 */ 69 # ifdef _MINIX 70 # include <sgtty.h> 71 # define TIOCSETN TIOCSETP 72 # else 73 # include <sys/ioctl.h> 74 # endif 75 typedef struct { 76 struct sgttyb sgttyb; 77 # ifdef TIOCGATC 78 struct lchars lchars; 79 # else /* TIOCGATC */ 80 struct tchars tchars; 81 # ifdef TIOCGLTC 82 struct ltchars ltchars; 83 # endif /* TIOCGLTC */ 84 # endif /* TIOCGATC */ 85 } TTY_state; 86 # endif /* HAVE_TERMIO_H */ 87 #endif /* HAVE_TERMIOS_H */ 88 89 /* Flags for set_tty() */ 90 #define TF_NONE 0x00 91 #define TF_WAIT 0x01 /* drain output, even it requires sleep() */ 92 #define TF_MIPSKLUDGE 0x02 /* kludge to unwedge RISC/os 5.0 tty driver */ 93 94 EXTERN int tty_fd I__(-1); /* dup'd tty file descriptor */ 95 EXTERN int tty_devtty; /* true if tty_fd is from /dev/tty */ 96 EXTERN TTY_state tty_state; /* saved tty state */ 97 98 extern int get_tty ARGS((int fd, TTY_state *ts)); 99 extern int set_tty ARGS((int fd, TTY_state *ts, int flags)); 100 extern void tty_init ARGS((int init_ttystate)); 101 extern void tty_close ARGS((void)); 102 103 /* be sure not to interfere with anyone else's idea about EXTERN */ 104 #ifdef EXTERN_DEFINED 105 # undef EXTERN_DEFINED 106 # undef EXTERN 107 #endif 108 #undef I__ 109