1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1982-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * David Korn <dgk@research.att.com> *
19 ***********************************************************************/
25 #include "FEATURE/ttys"
28 * complicated by the fact that there are so many variations
29 * This will use POSIX <termios.h> interface where available
34 # if __sgi__ || sgi /* special hack to eliminate ^M problem */
36 # define ECHOCTL ECHOE
39 # define CNSUSP CNSWTCH
43 # define _lib_tcgetattr 1
44 # define _lib_tcgetpgrp 1
45 # endif /* _NEXT_SOURCE */
47 # if defined(_sys_termios) && defined(_lib_tcgetattr)
48 # include <sys/termios.h>
52 # endif /* _sys_termios */
53 #endif /* _hdr_termios */
63 # define TCSANOW TCSETS
64 # define TCSADRAIN TCSETSW
65 # define TCSAFLUSH TCSETSF
67 /* The following corrects bugs in some implementations */
68 # if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
69 # define TCSAFLUSH TCSADFLUSH
70 # endif /* TCSADFLUSH */
71 # ifndef _lib_tcgetattr
73 # define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
75 # define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
77 # define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
78 # endif /* _lib_tcgetattr */
80 # if SHOPT_OLDTERMIO /* use both termios and termio */
85 # include <sys/termio.h>
86 # define _hdr_termio 1
88 # undef SHOPT_OLDTERMIO
89 # endif /* _sys_termio */
90 # endif /* _hdr_termio */
91 # endif /* SHOPT_OLDTERMIO */
93 # define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
94 # undef SHOPT_OLDTERMIO
99 # include <sys/termio.h>
100 # define _hdr_termio 1
101 # endif /* _sys_termio */
102 # endif /* _hdr_termio */
104 # define termios termio
106 # define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
107 # define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
110 # include <sys/bsdtty.h>
111 # endif /* _sys_bsdtty */
117 # include <sys/nttyio.h>
118 # endif /* _sys_nttyio */
119 # endif /* LPENDIN */
120 # define termios sgttyb
123 # endif /* TIOCSETN */
125 # define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
126 # define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
128 # define tcgetattr(fd,tty) gtty(fd, tty)
129 # define tcsetattr(fd,action,tty) stty(fd, tty)
130 # endif /* TIOCGETP */
131 # endif /* _hdr_sgtty */
132 # endif /* hdr_termio */
136 # define TCSANOW TCSETA
138 /* delays are too long, don't wait for output to drain */
139 # define TCSADRAIN TCSETA
141 # define TCSADRAIN TCSETAW
143 # define TCSAFLUSH TCSETAF
146 # define TCSANOW TIOCSETN
147 # define TCSADRAIN TIOCSETN
148 # define TCSAFLUSH TIOCSETP
149 # endif /* TIOCSETN */
150 # endif /* TCSETAW */
151 # endif /* TCSANOW */
152 #endif /* _hdr_termios */
154 /* set ECHOCTL if driver can echo control charaters as ^c */
157 # define ECHOCTL LCTLECH
158 # endif /* !ECHOCTL */
162 # define ECHOCTL LNEW_CTLECH
163 # endif /* !ECHOCTL */
164 #endif /* LNEW_CTLECH */
167 # define PENDIN LNEW_PENDIN
168 # endif /* !PENDIN */
169 #endif /* LNEW_PENDIN */
174 #endif /* !ECHOCTL */
178 # include <sys/filio.h>
179 # endif /* FIONREAD */
180 #endif /* _sys_filio */
181 /* set FIORDCHK if you can check for characters in input queue */
184 # define FIORDCHK FIONREAD
185 # endif /* !FIORDCHK */
186 #endif /* FIONREAD */
188 extern int tty_alt(int);
189 extern void tty_cooked(int);
190 extern int tty_get(int,struct termios
*);
191 extern int tty_raw(int,int);
192 extern int tty_check(int);
193 extern int tty_set(int, int, struct termios
*);
195 #endif /* _terminal_ */