Merge branch 'vendor/OPENSSL'
[dragonfly.git] / contrib / tcsh-6 / ed.term.h
1 /* $Header: /p/tcsh/cvsroot/tcsh/ed.term.h,v 1.19 2015/03/25 19:53:16 christos Exp $ */
2 /*
3  * ed.term.h: Local terminal header
4  */
5 /*-
6  * Copyright (c) 1980, 1991 The Regents of the University of California.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33 #ifndef _h_ed_term
34 #define _h_ed_term
35
36 #define TO_CONTROL(A)   ((A) & 037)
37
38 #if defined(TERMIO) || defined(POSIX)
39 /*
40  * Aix compatible names
41  */
42 # if defined(VWERSE) && !defined(VWERASE)
43 #  define VWERASE VWERSE
44 # endif /* VWERSE && !VWERASE */
45
46 # if defined(VDISCRD) && !defined(VDISCARD)
47 #  define VDISCARD VDISCRD
48 # endif /* VDISCRD && !VDISCARD */
49
50 # if defined(VFLUSHO) && !defined(VDISCARD)
51 #  define VDISCARD VFLUSHO
52 # endif  /* VFLUSHO && VDISCARD */
53
54 # if defined(VSTRT) && !defined(VSTART)
55 #  define VSTART VSTRT
56 # endif /* VSTRT && ! VSTART */
57
58 # if defined(VSTAT) && !defined(VSTATUS)
59 #  define VSTATUS VSTAT
60 # endif /* VSTAT && ! VSTATUS */
61
62 # ifndef ONLRET
63 #  define ONLRET 0
64 # endif /* ONLRET */
65
66 # ifndef TAB3
67 #  ifdef OXTABS
68 #   define TAB3 OXTABS
69 #  else
70 #   define TAB3 0
71 #  endif /* OXTABS */
72 # endif /* !TAB3 */
73
74 # if defined(OXTABS) && !defined(XTABS)
75 #  define XTABS OXTABS
76 # endif /* OXTABS && !XTABS */
77
78 # ifndef ONLCR
79 #  define ONLCR 0
80 # endif /* ONLCR */
81
82 # ifndef IEXTEN
83 #  define IEXTEN 0
84 # endif /* IEXTEN */
85
86 /*
87  * emx garbage
88  */
89 # ifndef IDEFAULT
90 #  define IDEFAULT 0
91 # endif /* IDEFAULT */
92
93 # ifndef IDELETE
94 #  define IDELETE 0
95 # endif /* IDELETE */
96
97 # ifndef ECHOCTL
98 #  define ECHOCTL 0
99 # endif /* ECHOCTL */
100
101 # ifndef PARENB
102 #  define PARENB 0
103 # endif /* PARENB */
104
105 # ifndef EXTPROC
106 #  define EXTPROC 0
107 # endif /* EXTPROC */
108
109 # ifndef FLUSHO
110 #  define FLUSHO  0
111 # endif /* FLUSHO */
112
113
114 # if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
115 #  define _POSIX_VDISABLE VDISABLE
116 # endif /* VDISABLE && ! _POSIX_VDISABLE */
117
118 /*
119  * Work around ISC's definition of IEXTEN which is
120  * XCASE!
121  */
122 # ifdef ISC
123 #  if defined(IEXTEN) && defined(XCASE)
124 #   if IEXTEN == XCASE
125 #    undef IEXTEN
126 #    define IEXTEN 0
127 #   endif /* IEXTEN == XCASE */
128 #  endif /* IEXTEN && XCASE */
129 #  if defined(IEXTEN) && !defined(XCASE)
130 #   define XCASE IEXTEN
131 #   undef IEXTEN
132 #   define IEXTEN 0
133 #  endif /* IEXTEN && !XCASE */
134 # endif /* ISC */
135
136 /*
137  * Work around convex weirdness where turning off IEXTEN makes us
138  * lose all postprocessing!
139  */
140 #ifdef convex
141 # if defined(IEXTEN) && IEXTEN != 0
142 #  undef IEXTEN
143 #  define IEXTEN 0
144 # endif /* IEXTEN != 0 */
145 #endif /* convex */
146
147
148 # else /* SGTTY */
149
150 # ifndef LPASS8
151 #  define LPASS8  0
152 # endif /* LPASS8 */
153
154 #endif /* TERMIO || POSIX */
155
156 #ifndef _POSIX_VDISABLE
157 # define _POSIX_VDISABLE ((unsigned char) -1)
158 #endif /* _POSIX_VDISABLE */
159
160
161 #if !defined(CREPRINT) && defined(CRPRNT)
162 # define CREPRINT CRPRNT
163 #endif /* !CREPRINT && CRPRNT */
164 #if !defined(CDISCARD) && defined(CFLUSH)
165 # define CDISCARD CFLUSH
166 #endif /* !CDISCARD && CFLUSH */
167 #if !defined(CDISCARD) && defined(CFLUSHO)
168 # define CDISCARD CFLUSHO
169 #endif /* !CDISCARD && CFLUSHO */
170
171 /*
172  * IRIX4.0 control macro is broken!
173  * Ignore and undef all default tty chars defined and redefine only
174  * the ones that are different in the IRIX file.
175  */
176 #if __STDC__ && defined(IRIS4D)
177 # undef  CINTR
178 # define CINTR          0177    /* ^? */
179 # undef  CQUIT
180 # undef  CERASE
181 # define CERASE         TO_CONTROL('h')
182 # undef  CKILL
183 # undef  CEOF
184 # undef  CEOL
185 # undef  CEOL2  
186 # undef  CSWTCH 
187 # define CSWTCH         TO_CONTROL('z')
188 # undef  CDSWTCH 
189 # undef  CERASE2
190 # undef  CSTART
191 # undef  CSTOP
192 # undef  CWERASE
193 # undef  CSUSP
194 # undef  CDSUSP
195 # undef  CREPRINT
196 # undef  CDISCARD
197 # undef  CLNEXT
198 # undef  CSTATUS
199 # undef  CCHECKPT
200 # undef  CPAGE
201 # undef  CPGOFF
202 # undef  CKILL2
203 # undef  CBRK
204 # undef  CMIN
205 # undef  CTIME
206 #endif /* __STDC__ && IRIS4D */
207
208
209 #ifndef CINTR
210 # define CINTR          TO_CONTROL('c')
211 #endif /* CINTR */
212 #ifndef CQUIT
213 # define CQUIT          034     /* ^\ */
214 #endif /* CQUIT */
215 #ifndef CERASE
216 # define CERASE         0177    /* ^? */
217 #endif /* CERASE */
218 #ifndef CKILL
219 # define CKILL          TO_CONTROL('u')
220 #endif /* CKILL */
221 #ifndef CEOF
222 # define CEOF           TO_CONTROL('d')
223 #endif /* CEOF */
224 #ifndef CEOL
225 # define CEOL           _POSIX_VDISABLE
226 #endif /* CEOL */
227 #ifndef CEOL2
228 # define CEOL2          _POSIX_VDISABLE
229 #endif /* CEOL2 */
230 #ifndef CSWTCH
231 # define CSWTCH         _POSIX_VDISABLE
232 #endif /* CSWTCH */
233 #ifndef CDSWTCH
234 # define CDSWTCH        _POSIX_VDISABLE
235 #endif /* CDSWTCH */
236 #ifndef CERASE2
237 # define CERASE2        _POSIX_VDISABLE
238 #endif /* CERASE2 */
239 #ifndef CSTART
240 # define CSTART         TO_CONTROL('q')
241 #endif /* CSTART */
242 #ifndef CSTOP
243 # define CSTOP          TO_CONTROL('s')
244 #endif /* CSTOP */
245 #ifndef CSUSP
246 # define CSUSP          TO_CONTROL('z')
247 #endif /* CSUSP */
248 #ifndef CDSUSP
249 # define CDSUSP         TO_CONTROL('y')
250 #endif /* CDSUSP */
251
252 #ifdef hpux
253
254 # ifndef CREPRINT
255 #  define CREPRINT      _POSIX_VDISABLE
256 # endif /* CREPRINT */
257 # ifndef CDISCARD
258 #  define CDISCARD      _POSIX_VDISABLE
259 # endif /* CDISCARD */
260 # ifndef CLNEXT
261 #  define CLNEXT        _POSIX_VDISABLE
262 # endif /* CLNEXT */
263 # ifndef CWERASE
264 #  define CWERASE       _POSIX_VDISABLE
265 # endif /* CWERASE */
266
267 #else /* !hpux */
268
269 # ifndef CREPRINT
270 #  define CREPRINT      TO_CONTROL('r')
271 # endif /* CREPRINT */
272 # ifndef CDISCARD
273 #  define CDISCARD      TO_CONTROL('o')
274 # endif /* CDISCARD */
275 # ifndef CLNEXT
276 #  define CLNEXT        TO_CONTROL('v')
277 # endif /* CLNEXT */
278 # ifndef CWERASE
279 #  define CWERASE       TO_CONTROL('w')
280 # endif /* CWERASE */
281
282 #endif /* hpux */
283
284 #ifndef CSTATUS
285 # define CSTATUS        TO_CONTROL('t')
286 #endif /* CSTATUS */
287 #ifndef CCHECKPT
288 # define CCHECKPT       TO_CONTROL('e')
289 #endif /* CCHECKPT */
290 #ifndef CPAGE
291 # define CPAGE          ' '
292 #endif /* CPAGE */
293 #ifndef CPGOFF
294 # define CPGOFF         TO_CONTROL('m')
295 #endif /* CPGOFF */
296 #ifndef CKILL2
297 # define CKILL2         _POSIX_VDISABLE
298 #endif /* CKILL2 */
299 #ifndef CBRK
300 # ifndef masscomp
301 #  define CBRK          0377
302 # else
303 #  define CBRK          '\0'
304 # endif /* masscomp */
305 #endif /* CBRK */
306 #ifndef CMIN
307 # if VMIN == VEOF
308 #  define CMIN          CEOF
309 # else
310 #  define CMIN          1
311 # endif
312 #endif /* CMIN */
313 #ifndef CTIME
314 # if VTIME == VEOL
315 #  define CTIME         CEOL
316 # else
317 #  define CTIME         0
318 # endif
319 #endif /* CTIME */
320
321 /*
322  * Fix for sun inconsistency. On termio VSUSP and the rest of the
323  * ttychars > NCC are defined. So we undefine them.
324  */
325 #if defined(TERMIO) || defined(POSIX)
326 # if defined(POSIX) && defined(NCCS)
327 #  define NUMCC         NCCS
328 # else
329 #  ifdef NCC
330 #   define NUMCC        NCC
331 #  endif /* NCC */
332 # endif /* POSIX && NCCS */
333 # ifdef NUMCC
334 #  ifdef VINTR
335 #   if NUMCC <= VINTR
336 #    undef VINTR
337 #   endif /* NUMCC <= VINTR */
338 #  endif /* VINTR */
339 #  ifdef VQUIT
340 #   if NUMCC <= VQUIT
341 #    undef VQUIT
342 #   endif /* NUMCC <= VQUIT */
343 #  endif /* VQUIT */
344 #  ifdef VERASE
345 #   if NUMCC <= VERASE
346 #    undef VERASE
347 #   endif /* NUMCC <= VERASE */
348 #  endif /* VERASE */
349 #  ifdef VKILL
350 #   if NUMCC <= VKILL
351 #    undef VKILL
352 #   endif /* NUMCC <= VKILL */
353 #  endif /* VKILL */
354 #  ifdef VEOF
355 #   if NUMCC <= VEOF
356 #    undef VEOF
357 #   endif /* NUMCC <= VEOF */
358 #  endif /* VEOF */
359 #  ifdef VEOL
360 #   if NUMCC <= VEOL
361 #    undef VEOL
362 #   endif /* NUMCC <= VEOL */
363 #  endif /* VEOL */
364 #  ifdef VEOL2
365 #   if NUMCC <= VEOL2
366 #    undef VEOL2
367 #   endif /* NUMCC <= VEOL2 */
368 #  endif /* VEOL2 */
369 #  ifdef VSWTCH
370 #   if NUMCC <= VSWTCH
371 #    undef VSWTCH
372 #   endif /* NUMCC <= VSWTCH */
373 #  endif /* VSWTCH */
374 #  ifdef VDSWTCH
375 #   if NUMCC <= VDSWTCH
376 #    undef VDSWTCH
377 #   endif /* NUMCC <= VDSWTCH */
378 #  endif /* VDSWTCH */
379 #  ifdef VERASE2
380 #   if NUMCC <= VERASE2
381 #    undef VERASE2
382 #   endif /* NUMCC <= VERASE2 */
383 #  endif /* VERASE2 */
384 #  ifdef VSTART
385 #   if NUMCC <= VSTART
386 #    undef VSTART
387 #   endif /* NUMCC <= VSTART */
388 #  endif /* VSTART */
389 #  ifdef VSTOP
390 #   if NUMCC <= VSTOP
391 #    undef VSTOP
392 #   endif /* NUMCC <= VSTOP */
393 #  endif /* VSTOP */
394 #  ifdef VWERASE
395 #   if NUMCC <= VWERASE
396 #    undef VWERASE
397 #   endif /* NUMCC <= VWERASE */
398 #  endif /* VWERASE */
399 #  ifdef VSUSP
400 #   if NUMCC <= VSUSP
401 #    undef VSUSP
402 #   endif /* NUMCC <= VSUSP */
403 #  endif /* VSUSP */
404 #  ifdef VDSUSP
405 #   if NUMCC <= VDSUSP
406 #    undef VDSUSP
407 #   endif /* NUMCC <= VDSUSP */
408 #  endif /* VDSUSP */
409 #  ifdef VREPRINT
410 #   if NUMCC <= VREPRINT
411 #    undef VREPRINT
412 #   endif /* NUMCC <= VREPRINT */
413 #  endif /* VREPRINT */
414 #  ifdef VDISCARD
415 #   if NUMCC <= VDISCARD
416 #    undef VDISCARD
417 #   endif /* NUMCC <= VDISCARD */
418 #  endif /* VDISCARD */
419 #  ifdef VLNEXT
420 #   if NUMCC <= VLNEXT
421 #    undef VLNEXT
422 #   endif /* NUMCC <= VLNEXT */
423 #  endif /* VLNEXT */
424 #  ifdef VSTATUS
425 #   if NUMCC <= VSTATUS
426 #    undef VSTATUS
427 #   endif /* NUMCC <= VSTATUS */
428 #  endif /* VSTATUS */
429 #  ifdef VCHECKPT
430 #   if NUMCC <= VCHECKPT
431 #    undef VCHECKPT
432 #   endif /* NUMCC <= VCHECKPT */
433 #  endif /* VCHECKPT */
434 #  ifdef VPAGE
435 #   if NUMCC <= VPAGE
436 #    undef VPAGE
437 #   endif /* NUMCC <= VPAGE */
438 #  endif /* VPAGE */
439 #  ifdef VPGOFF
440 #   if NUMCC <= VPGOFF
441 #    undef VPGOFF
442 #   endif /* NUMCC <= VPGOFF */
443 #  endif /* VPGOFF */
444 #  ifdef VKILL2
445 #   if NUMCC <= VKILL2
446 #    undef VKILL2
447 #   endif /* NUMCC <= VKILL2 */
448 #  endif /* VKILL2 */
449 #  ifdef VBRK
450 #   if NUMCC <= VBRK
451 #    undef VBRK
452 #   endif /* NUMCC <= VBRK */
453 #  endif /* VBRK */
454 #  ifdef VMIN
455 #   if NUMCC <= VMIN
456 #    undef VMIN
457 #   endif /* NUMCC <= VMIN */
458 #  endif /* VMIN */
459 #  ifdef VTIME
460 #   if NUMCC <= VTIME
461 #    undef VTIME
462 #   endif /* NUMCC <= VTIME */
463 #  endif /* VTIME */
464 # endif /* NUMCC */
465 #endif /* !POSIX */
466
467 /*
468  * fix for hpux10 inconsistency: it has VWERASE, but TIOCSLTC returns
469  * EINVAL if one tries to change it
470  * Also for RH6.2 on the alpha, defined TIOCGLTC, but does not have
471  * struct ltchars
472  */
473 #if (defined(hpux) && defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT)) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__QNXNTO__)
474 # undef TIOCGLTC       /* not really needed */
475 # undef TIOCSLTC
476 #endif
477
478 #define C_INTR           0
479 #define C_QUIT           1
480 #define C_ERASE          2
481 #define C_KILL           3
482 #define C_EOF            4
483 #define C_EOL            5
484 #define C_EOL2           6
485 #define C_SWTCH          7
486 #define C_DSWTCH         8
487 #define C_ERASE2         9
488 #define C_START         10
489 #define C_STOP          11
490 #define C_WERASE        12
491 #define C_SUSP          13
492 #define C_DSUSP         14
493 #define C_REPRINT       15
494 #define C_DISCARD       16
495 #define C_LNEXT         17
496 #define C_STATUS        18
497 #define C_PAGE          19
498 #define C_PGOFF         20
499 #define C_KILL2         21
500 #define C_BRK           22
501 #define C_MIN           23
502 #define C_TIME          24
503 #define C_CHECKPT       25
504 #define C_NCC           26
505 #define C_SH(A)         (1 << (A))
506
507 /*
508  * Terminal dependend data structures
509  */
510 typedef struct {
511 #ifdef WINNT_NATIVE
512     int dummy;
513 #else /* !WINNT_NATIVE */
514 # if defined(POSIX) || defined(TERMIO)
515 #  ifdef POSIX
516     struct termios d_t;
517 #  else
518     struct termio d_t;
519 #  endif /* POSIX */
520 # else /* SGTTY */
521 #  ifdef TIOCGETP
522     struct sgttyb d_t;
523 #  endif /* TIOCGETP */
524 #  ifdef TIOCGETC
525     struct tchars d_tc;
526 #  endif /* TIOCGETC */
527 #  ifdef TIOCGPAGE
528     struct ttypagestat d_pc;
529 #  endif /* TIOCGPAGE */
530 #  ifdef TIOCLGET
531     int d_lb;
532 #  endif /* TIOCLGET */
533 # endif /* POSIX || TERMIO */
534 # ifdef TIOCGLTC
535     struct ltchars d_ltc;
536 # endif /* TIOCGLTC */
537 #endif /* WINNT_NATIVE */
538 } ttydata_t;
539
540 #endif /* _h_ed_term */