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