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