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