Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtksh / ksh93 / src / cmd / ksh93 / include / terminal.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: terminal.h /main/3 1995/11/01 16:43:45 rswiston $ */
24 /***************************************************************
25 *                                                              *
26 *                      AT&T - PROPRIETARY                      *
27 *                                                              *
28 *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF        *
29 *                    AT&T BELL LABORATORIES                    *
30 *         AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN         *
31 *            ACCORDANCE WITH APPLICABLE AGREEMENTS             *
32 *                                                              *
33 *                Copyright (c) 1995 AT&T Corp.                 *
34 *              Unpublished & Not for Publication               *
35 *                     All Rights Reserved                      *
36 *                                                              *
37 *       The copyright notice above does not evidence any       *
38 *      actual or intended publication of such source code      *
39 *                                                              *
40 *               This software was created by the               *
41 *           Advanced Software Technology Department            *
42 *                    AT&T Bell Laboratories                    *
43 *                                                              *
44 *               For further information contact                *
45 *                    {research,attmail}!dgk                    *
46 *                                                              *
47 ***************************************************************/
48
49 /* : : generated by proto : : */
50                   
51
52 #ifndef _terminal_
53 #if !defined(__PROTO__)
54 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
55 #if defined(__cplusplus)
56 #define __MANGLE__      "C"
57 #else
58 #define __MANGLE__
59 #endif
60 #define __STDARG__
61 #define __PROTO__(x)    x
62 #define __OTORP__(x)
63 #define __PARAM__(n,o)  n
64 #if !defined(__STDC__) && !defined(__cplusplus)
65 #if !defined(c_plusplus)
66 #define const
67 #endif
68 #define signed
69 #define void            int
70 #define volatile
71 #define __V_            char
72 #else
73 #define __V_            void
74 #endif
75 #else
76 #define __PROTO__(x)    ()
77 #define __OTORP__(x)    x
78 #define __PARAM__(n,o)  o
79 #define __MANGLE__
80 #define __V_            char
81 #define const
82 #define signed
83 #define void            int
84 #define volatile
85 #endif
86 #if defined(__cplusplus) || defined(c_plusplus)
87 #define __VARARG__      ...
88 #else
89 #define __VARARG__
90 #endif
91 #if defined(__STDARG__)
92 #define __VA_START__(p,a)       va_start(p,a)
93 #else
94 #define __VA_START__(p,a)       va_start(p)
95 #endif
96 #endif
97
98 #define _terminal_      1
99
100 #include        "FEATURE/ttys"
101 /*
102  * terminal interface
103  * complicated by the fact that there are so many variations
104  * This will use POSIX <termios.h> interface where available
105  */
106
107 #ifdef _hdr_termios
108 #   define tcgetattr    _SYS_tcgetattr
109 #   define tcsetattr    _SYS_tcsetattr
110 #   define tcgetpgrp    _SYS_tcgetpgrp
111 #   define tcsetpgrp    _SYS_tcsetpgrp
112 #   define cfgetospeed  _SYS_cfgetospeed
113 #   include     <termios.h>
114 #   if __sgi__ || sgi   /* special hack to eliminate ^M problem */
115 #       ifndef ECHOCTL
116 #           define ECHOCTL      ECHOE
117 #       endif /* ECHOCTL */
118 #       ifndef CNSUSP
119 #           define CNSUSP       CNSWTCH
120 #       endif /* CNSUSP */
121 #   endif /* sgi */
122 #   ifdef _NEXT_SOURCE
123 #       define _lib_tcgetattr   1
124 #       define _lib_tcgetpgrp   1
125 #   endif /* _NEXT_SOURCE */
126 #else
127 #   if defined(_sys_termios) && defined(_lib_tcgetattr)
128 #       define tcgetattr        _SYS_tcgetattr
129 #       define tcsetattr        _SYS_tcsetattr
130 #       define tcgetpgrp        _SYS_tcgetpgrp
131 #       define tcsetpgrp        _SYS_tcsetpgrp
132 #       define cfgetospeed      _SYS_cfgetospeed
133 #       include <sys/termios.h>
134 #       define _hdr_termios
135 #   else
136 #       undef _sys_termios
137 #   endif /* _sys_termios */
138 #endif /* _hdr_termios */
139
140 #ifdef _hdr_termios
141 #   undef _hdr_sgtty
142 #   undef tcgetattr
143 #   undef tcsetattr
144 #   undef tcgetpgrp
145 #   undef tcsetpgrp
146 #   undef cfgetospeed
147 #   ifndef TCSANOW
148 #       define TCSANOW          TCSETS
149 #       define TCSADRAIN        TCSETSW
150 #       define TCSAFLUSH        TCSETSF
151 #   endif /* TCSANOW */
152     /* The following corrects bugs in some implementations */
153 #   if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
154 #       define TCSAFLUSH        TCSADFLUSH
155 #   endif /* TCSADFLUSH */
156 #   ifndef _lib_tcgetattr
157 #       define tcgetattr(fd,tty)        ioctl(fd, TCGETS, tty)
158 #       define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
159 #       define cfgetospeed(tp)          ((tp)->c_cflag & CBAUD)
160 #   else
161         extern __MANGLE__ int tcgetattr __PROTO__((int, struct termios*));
162         extern __MANGLE__ int tcsetattr __PROTO__((int, int, const struct termios*));
163         extern __MANGLE__ int cfgetospeed __PROTO__((const struct termios*));
164 #   endif /* _lib_tcgetattr */
165 #   undef TIOCGETC
166 #   ifdef SHOPT_OLDTERMIO  /* use both termios and termio */
167 #       ifdef _hdr_termio
168 #           include     <termio.h>
169 #       else
170 #           ifdef _sys_termio
171 #               include <sys/termio.h>
172 #               define _hdr_termio 1
173 #           else
174 #               undef SHOPT_OLDTERMIO
175 #           endif /* _sys_termio */
176 #       endif /* _hdr_termio */
177 #   endif /* SHOPT_OLDTERMIO */
178 #else
179 #   define cfgetospeed(tp)      ((tp)->c_cflag & CBAUD)
180 #   undef SHOPT_OLDTERMIO
181 #   ifdef _hdr_termio
182 #       include <termio.h>
183 #   else
184 #       ifdef _sys_termio
185 #           include     <sys/termio.h>
186 #           define _hdr_termio 1
187 #       endif /* _sys_termio */
188 #   endif /* _hdr_termio */
189 #   ifdef _hdr_termio
190 #       define termios termio
191 #       undef TIOCGETC
192 #       define tcgetattr(fd,tty)                ioctl(fd, TCGETA, tty)
193 #       define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
194
195 #       ifdef _sys_bsdtty
196 #          include      <sys/bsdtty.h>
197 #       endif /* _sys_bsdtty */
198 #   else
199 #       ifdef _hdr_sgtty
200 #           include     <sgtty.h>
201 #           ifndef LPENDIN
202 #               ifdef _sys_nttyio
203 #                   include     <sys/nttyio.h>
204 #               endif /* _sys_nttyio */
205 #           endif /* LPENDIN */
206 #           define termios sgttyb
207 #           ifdef TIOCSETN
208 #               undef TCSETAW
209 #           endif /* TIOCSETN */
210 #           ifdef TIOCGETP
211 #               define tcgetattr(fd,tty)                ioctl(fd, TIOCGETP, tty)
212 #               define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
213 #           else
214 #               define tcgetattr(fd,tty)        gtty(fd, tty)
215 #               define tcsetattr(fd,action,tty) stty(fd, tty)
216 #           endif /* TIOCGETP */
217 #       endif /* _hdr_sgtty */
218 #   endif /* hdr_termio */
219
220 #   ifndef TCSANOW
221 #       ifdef TCSETAW
222 #           define TCSANOW      TCSETA
223 #           ifdef u370
224             /* delays are too long, don't wait for output to drain */
225 #               define TCSADRAIN        TCSETA
226 #           else
227 #               define TCSADRAIN        TCSETAW
228 #           endif /* u370 */
229 #           define TCSAFLUSH    TCSETAF
230 #       else
231 #           ifdef TIOCSETN
232 #               define TCSANOW  TIOCSETN
233 #               define TCSADRAIN        TIOCSETN
234 #               define TCSAFLUSH        TIOCSETP
235 #           endif /* TIOCSETN */
236 #       endif /* TCSETAW */
237 #   endif /* TCSANOW */
238 #endif /* _hdr_termios */
239
240 /* set ECHOCTL if driver can echo control charaters as ^c */
241 #ifdef LCTLECH
242 #   ifndef ECHOCTL
243 #       define ECHOCTL  LCTLECH
244 #   endif /* !ECHOCTL */
245 #endif /* LCTLECH */
246 #ifdef LNEW_CTLECH
247 #   ifndef ECHOCTL
248 #       define ECHOCTL  LNEW_CTLECH
249 #   endif /* !ECHOCTL */
250 #endif /* LNEW_CTLECH */
251 #ifdef LNEW_PENDIN
252 #   ifndef PENDIN
253 #       define PENDIN LNEW_PENDIN
254 #  endif /* !PENDIN */
255 #endif /* LNEW_PENDIN */
256 #ifndef ECHOCTL
257 #   ifndef VEOL
258 #       define RAWONLY  1
259 #   endif /* !VEOL */
260 #endif /* !ECHOCTL */
261
262 #ifdef _sys_filio
263 #   ifndef FIONREAD
264 #       include <sys/filio.h>
265 #   endif /* FIONREAD */
266 #endif /* _sys_filio */
267 /* set FIORDCHK if you can check for characters in input queue */
268 #ifdef FIONREAD
269 #   ifndef FIORDCHK
270 #       define FIORDCHK FIONREAD
271 #   endif /* !FIORDCHK */
272 #endif /* FIONREAD */
273
274 extern __MANGLE__ int   tty_alt __PROTO__((int));
275 extern __MANGLE__ void  tty_cooked __PROTO__((int));
276 extern __MANGLE__ int   tty_get __PROTO__((int,struct termios*));
277 extern __MANGLE__ int   tty_raw __PROTO__((int,int));
278 extern __MANGLE__ int   tty_check __PROTO__((int));
279 extern __MANGLE__ int   tty_set __PROTO__((int, int, struct termios*));
280
281 #endif /* _terminal_ */