2 * $Header: /src/pub/tcsh/ed.term.c,v 1.28 2002/07/06 22:28:13 christos Exp $
3 * $DragonFly: src/contrib/tcsh/Attic/ed.term.c,v 1.2 2003/10/13 21:24:29 dillon Exp $
6 * ed.term.c: Low level terminal interface
9 * Copyright (c) 1980, 1991 The Regents of the University of California.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 RCSID("$Id: ed.term.c,v 1.28 2002/07/06 22:28:13 christos Exp $")
46 #if defined(POSIX) || defined(TERMIO)
47 { "iflag:", ICRNL
, (INLCR
|IGNCR
) },
48 { "oflag:", (OPOST
|ONLCR
), ONLRET
},
50 { "lflag:", (ISIG
|ICANON
|ECHO
|ECHOE
|ECHOCTL
|IEXTEN
),
51 (NOFLSH
|ECHONL
|EXTPROC
|FLUSHO
|IDEFAULT
) },
53 { "nrmal:", (ECHO
|CRMOD
|ANYP
), (CBREAK
|RAW
|LCASE
|VTDELAY
|ALLDELAY
) },
54 { "local:", (LCRTBS
|LCRTERA
|LCRTKIL
), (LPRTERA
|LFLUSHO
) },
55 #endif /* POSIX || TERMIO */
59 #if defined(POSIX) || defined(TERMIO)
60 { "iflag:", (INLCR
|ICRNL
), IGNCR
},
61 { "oflag:", (OPOST
|ONLCR
), ONLRET
},
64 (NOFLSH
|ICANON
|ECHO
|ECHOK
|ECHONL
|EXTPROC
|IEXTEN
|FLUSHO
|
67 { "nrmal:", (CBREAK
|CRMOD
|ANYP
), (RAW
|ECHO
|LCASE
|VTDELAY
|ALLDELAY
) },
68 { "local:", (LCRTBS
|LCRTERA
|LCRTKIL
), (LPRTERA
|LFLUSHO
) },
69 #endif /* POSIX || TERMIO */
70 { "chars:", (C_SH(C_MIN
)|C_SH(C_TIME
)|C_SH(C_SWTCH
)|C_SH(C_DSWTCH
)|
71 C_SH(C_WERASE
)|C_SH(C_REPRINT
)|C_SH(C_SUSP
)|C_SH(C_DSUSP
)|
72 C_SH(C_EOF
)|C_SH(C_EOL
)|C_SH(C_DISCARD
)|C_SH(C_PGOFF
)|
73 C_SH(C_KILL2
)|C_SH(C_PAGE
)|C_SH(C_STATUS
)|C_SH(C_CHECKPT
)|
78 #if defined(POSIX) || defined(TERMIO)
79 { "iflag:", 0, IXON
| IXOFF
},
82 { "lflag:", 0, ISIG
| IEXTEN
},
84 { "nrmal:", RAW
, CBREAK
},
86 #endif /* POSIX || TERMIO */
91 static struct tcshmodes
{
94 unsigned long m_value
;
100 #if defined(POSIX) || defined(TERMIO)
103 { "ignbrk", IGNBRK
, M_INPUT
},
106 { "brkint", BRKINT
, M_INPUT
},
109 { "ignpar", IGNPAR
, M_INPUT
},
112 { "parmrk", PARMRK
, M_INPUT
},
115 { "inpck", INPCK
, M_INPUT
},
118 { "istrip", ISTRIP
, M_INPUT
},
121 { "inlcr", INLCR
, M_INPUT
},
124 { "igncr", IGNCR
, M_INPUT
},
127 { "icrnl", ICRNL
, M_INPUT
},
130 { "iuclc", IUCLC
, M_INPUT
},
133 { "ixon", IXON
, M_INPUT
},
136 { "ixany", IXANY
, M_INPUT
},
139 { "ixoff", IXOFF
, M_INPUT
},
142 { "imaxbel",IMAXBEL
,M_INPUT
},
143 # endif /* IMAXBEL */
145 { "idelete",IDELETE
,M_INPUT
},
146 # endif /* IDELETE */
149 { "opost", OPOST
, M_OUTPUT
},
152 { "olcuc", OLCUC
, M_OUTPUT
},
155 { "onlcr", ONLCR
, M_OUTPUT
},
158 { "ocrnl", OCRNL
, M_OUTPUT
},
161 { "onocr", ONOCR
, M_OUTPUT
},
164 { "onoeot", ONOEOT
, M_OUTPUT
},
167 { "onlret", ONLRET
, M_OUTPUT
},
170 { "ofill", OFILL
, M_OUTPUT
},
173 { "ofdel", OFDEL
, M_OUTPUT
},
176 { "nldly", NLDLY
, M_OUTPUT
},
179 { "crdly", CRDLY
, M_OUTPUT
},
182 { "tabdly", TABDLY
, M_OUTPUT
},
185 { "xtabs", XTABS
, M_OUTPUT
},
188 { "bsdly", BSDLY
, M_OUTPUT
},
191 { "vtdly", VTDLY
, M_OUTPUT
},
194 { "ffdly", FFDLY
, M_OUTPUT
},
197 { "pageout",PAGEOUT
,M_OUTPUT
},
198 # endif /* PAGEOUT */
200 { "wrap", WRAP
, M_OUTPUT
},
204 { "cignore",CIGNORE
,M_CONTROL
},
207 { "cbaud", CBAUD
, M_CONTROL
},
210 { "cstopb", CSTOPB
, M_CONTROL
},
213 { "cread", CREAD
, M_CONTROL
},
216 { "parenb", PARENB
, M_CONTROL
},
219 { "parodd", PARODD
, M_CONTROL
},
222 { "hupcl", HUPCL
, M_CONTROL
},
225 { "clocal", CLOCAL
, M_CONTROL
},
228 { "loblk", LOBLK
, M_CONTROL
},
231 { "cibaud", CIBAUD
, M_CONTROL
},
235 { "ccts_oflow",CCTS_OFLOW
,M_CONTROL
},
237 { "crtscts",CRTSCTS
,M_CONTROL
},
238 # endif /* CCTS_OFLOW */
239 # endif /* CRTSCTS */
241 { "crts_iflow",CRTS_IFLOW
,M_CONTROL
},
242 # endif /* CRTS_IFLOW */
244 { "mdmbuf", MDMBUF
, M_CONTROL
},
247 { "rcv1en", RCV1EN
, M_CONTROL
},
250 { "xmt1en", XMT1EN
, M_CONTROL
},
254 { "isig", ISIG
, M_LINED
},
257 { "icanon", ICANON
, M_LINED
},
260 { "xcase", XCASE
, M_LINED
},
263 { "echo", ECHO
, M_LINED
},
266 { "echoe", ECHOE
, M_LINED
},
269 { "echok", ECHOK
, M_LINED
},
272 { "echonl", ECHONL
, M_LINED
},
275 { "noflsh", NOFLSH
, M_LINED
},
278 { "tostop", TOSTOP
, M_LINED
},
281 { "echoctl",ECHOCTL
,M_LINED
},
282 # endif /* ECHOCTL */
284 { "echoprt",ECHOPRT
,M_LINED
},
285 # endif /* ECHOPRT */
287 { "echoke", ECHOKE
, M_LINED
},
290 { "defecho",DEFECHO
,M_LINED
},
291 # endif /* DEFECHO */
293 { "flusho", FLUSHO
, M_LINED
},
296 { "pendin", PENDIN
, M_LINED
},
299 { "iexten", IEXTEN
, M_LINED
},
302 { "nokerninfo",NOKERNINFO
,M_LINED
},
303 # endif /* NOKERNINFO */
305 { "altwerase",ALTWERASE
,M_LINED
},
306 # endif /* ALTWERASE */
308 { "extproc",EXTPROC
,M_LINED
},
309 # endif /* EXTPROC */
311 { "idefault",IDEFAULT
,M_LINED
},
312 # endif /* IDEFAULT */
317 { "tandem", TANDEM
, M_CONTROL
},
320 { "cbreak", CBREAK
, M_CONTROL
},
323 { "lcase", LCASE
, M_CONTROL
},
326 { "echo", ECHO
, M_CONTROL
},
329 { "crmod", CRMOD
, M_CONTROL
},
332 { "raw", RAW
, M_CONTROL
},
335 { "oddp", ODDP
, M_CONTROL
},
338 { "evenp", EVENP
, M_CONTROL
},
341 { "anyp", ANYP
, M_CONTROL
},
344 { "nldelay",NLDELAY
,M_CONTROL
},
345 # endif /* NLDELAY */
347 { "tbdelay",TBDELAY
,M_CONTROL
},
348 # endif /* TBDELAY */
350 { "xtabs", XTABS
, M_CONTROL
},
353 { "crdelay",CRDELAY
,M_CONTROL
},
354 # endif /* CRDELAY */
356 { "vtdelay",VTDELAY
,M_CONTROL
},
357 # endif /* VTDELAY */
359 { "bsdelay",BSDELAY
,M_CONTROL
},
360 # endif /* BSDELAY */
362 { "crtbs", CRTBS
, M_CONTROL
},
365 { "prtera", PRTERA
, M_CONTROL
},
368 { "crtera", CRTERA
, M_CONTROL
},
371 { "tilde", TILDE
, M_CONTROL
},
374 { "mdmbuf", MDMBUF
, M_CONTROL
},
377 { "litout", LITOUT
, M_CONTROL
},
380 { "tostop", TOSTOP
, M_CONTROL
},
383 { "flusho", FLUSHO
, M_CONTROL
},
386 { "nohang", NOHANG
, M_CONTROL
},
389 { "l001000",L001000
,M_CONTROL
},
390 # endif /* L001000 */
392 { "crtkil", CRTKIL
, M_CONTROL
},
395 { "pass8", PASS8
, M_CONTROL
},
398 { "ctlech", CTLECH
, M_CONTROL
},
401 { "pendin", PENDIN
, M_CONTROL
},
404 { "decctq", DECCTQ
, M_CONTROL
},
407 { "noflsh", NOFLSH
, M_CONTROL
},
411 { "lcrtbs", LCRTBS
, M_LOCAL
},
414 { "lprtera",LPRTERA
,M_LOCAL
},
415 # endif /* LPRTERA */
417 { "lcrtera",LCRTERA
,M_LOCAL
},
418 # endif /* LCRTERA */
420 { "ltilde", LTILDE
, M_LOCAL
},
423 { "lmdmbuf",LMDMBUF
,M_LOCAL
},
424 # endif /* LMDMBUF */
426 { "llitout",LLITOUT
,M_LOCAL
},
427 # endif /* LLITOUT */
429 { "ltostop",LTOSTOP
,M_LOCAL
},
430 # endif /* LTOSTOP */
432 { "lflusho",LFLUSHO
,M_LOCAL
},
433 # endif /* LFLUSHO */
435 { "lnohang",LNOHANG
,M_LOCAL
},
436 # endif /* LNOHANG */
438 { "lcrtkil",LCRTKIL
,M_LOCAL
},
439 # endif /* LCRTKIL */
441 { "lpass8", LPASS8
, M_LOCAL
},
444 { "lctlech",LCTLECH
,M_LOCAL
},
445 # endif /* LCTLECH */
447 { "lpendin",LPENDIN
,M_LOCAL
},
448 # endif /* LPENDIN */
450 { "ldecctq",LDECCTQ
,M_LOCAL
},
451 # endif /* LDECCTQ */
453 { "lnoflsh",LNOFLSH
,M_LOCAL
},
454 # endif /* LNOFLSH */
456 #endif /* POSIX || TERMIO */
457 # if defined(VINTR) || defined(TIOCGETC)
458 { "intr", C_SH(C_INTR
), M_CHAR
},
460 # if defined(VQUIT) || defined(TIOCGETC)
461 { "quit", C_SH(C_QUIT
), M_CHAR
},
463 # if defined(VERASE) || defined(TIOCGETP)
464 { "erase", C_SH(C_ERASE
), M_CHAR
},
466 # if defined(VKILL) || defined(TIOCGETP)
467 { "kill", C_SH(C_KILL
), M_CHAR
},
469 # if defined(VEOF) || defined(TIOCGETC)
470 { "eof", C_SH(C_EOF
), M_CHAR
},
473 { "eol", C_SH(C_EOL
), M_CHAR
},
476 { "eol2", C_SH(C_EOL2
), M_CHAR
},
479 { "swtch", C_SH(C_SWTCH
), M_CHAR
},
481 # if defined(VDSWTCH)
482 { "dswtch", C_SH(C_DSWTCH
), M_CHAR
},
483 # endif /* VDSWTCH */
484 # if defined(VERASE2)
485 { "erase2", C_SH(C_ERASE2
), M_CHAR
},
486 # endif /* VERASE2 */
487 # if defined(VSTART) || defined(TIOCGETC)
488 { "start", C_SH(C_START
), M_CHAR
},
490 # if defined(VSTOP) || defined(TIOCGETC)
491 { "stop", C_SH(C_STOP
), M_CHAR
},
493 # if defined(VWERASE) || defined(TIOCGLTC)
494 { "werase", C_SH(C_WERASE
), M_CHAR
},
495 # endif /* VWERASE */
496 # if defined(VSUSP) || defined(TIOCGLTC)
497 { "susp", C_SH(C_SUSP
), M_CHAR
},
499 # if defined(VDSUSP) || defined(TIOCGLTC)
500 { "dsusp", C_SH(C_DSUSP
), M_CHAR
},
502 # if defined(VREPRINT) || defined(TIOCGLTC)
503 { "reprint", C_SH(C_REPRINT
),M_CHAR
},
504 # endif /* WREPRINT */
505 # if defined(VDISCARD) || defined(TIOCGLTC)
506 { "discard", C_SH(C_DISCARD
),M_CHAR
},
507 # endif /* VDISCARD */
508 # if defined(VLNEXT) || defined(TIOCGLTC)
509 { "lnext", C_SH(C_LNEXT
), M_CHAR
},
511 # if defined(VSTATUS) || defined(TIOCGPAGE)
512 { "status", C_SH(C_STATUS
), M_CHAR
},
513 # endif /* VSTATUS */
514 # if defined(VCHECKPT) || defined(TIOCGPAGE)
515 { "ckpt", C_SH(C_CHECKPT
),M_CHAR
},
516 # endif /* VSTATUS */
517 # if defined(VPAGE) || defined(TIOCGPAGE)
518 { "page", C_SH(C_PAGE
), M_CHAR
},
520 # if defined(VPGOFF) || defined(TIOCGPAGE)
521 { "pgoff", C_SH(C_PGOFF
), M_CHAR
},
524 { "kill2", C_SH(C_KILL2
), M_CHAR
},
526 # if defined(VBRK) || defined(TIOCGETC)
527 { "brk", C_SH(C_BRK
), M_CHAR
},
530 { "min", C_SH(C_MIN
), M_CHAR
},
533 { "time", C_SH(C_TIME
), M_CHAR
},
539 * If EAGAIN and/or EWOULDBLOCK are defined, we can't just return -1 in all
540 * situations where ioctl() does.
542 * On AIX 4.1.5 (and presumably some other versions and OSes), as you
543 * perform the manual test suite in the README, if you 'bg' vi immediately
544 * after suspending it, all is well, but if you wait a few seconds,
545 * usually ioctl() will return -1, which previously caused tty_setty() to
546 * return -1, causing Rawmode() to return -1, causing Inputl() to return
547 * 0, causing bgetc() to return -1, causing readc() to set doneinp to 1,
548 * causing process() to break out of the main loop, causing tcsh to exit
551 * If ioctl()'s errno is EAGAIN/EWOULDBLOCK ("Resource temporarily
552 * unavailable"), apparently the tty is being messed with by the OS and we
553 * need to try again. In my testing, ioctl() was never called more than
556 * -- Dan Harkless <dan@wave.eng.uci.edu>
558 * So, I retry all ioctl's in case others happen to fail too (christos)
561 #if defined(EAGAIN) && defined(EWOULDBLOCK) && (EWOULDBLOCK != EAGAIN)
562 # define OKERROR(e) (((e) == EAGAIN) || ((e) == EWOULDBLOCK) || ((e) == EINTR))
564 # define OKERROR(e) (((e) == EAGAIN) || ((e) == EINTR))
565 #elif defined(EWOULDBLOCK)
566 # define OKERROR(e) (((e) == EWOULDBLOCK) || ((e) == EINTR))
568 # define OKERROR(e) ((e) == EINTR)
572 #define KLUDGE (errno == ENOTTY && count < 10)
577 /* Retry a system call */
580 for (count = 0;; count++) \
582 if (OKERROR(errno) || KLUDGE) \
601 char cmdname
[BUFSIZE
];
604 setname(strcpy(cmdname
, short2str(*v
++)));
606 while (v
&& *v
&& v
[0][0] == '-' && v
[0][2] == '\0')
625 stderror(ERR_NAME
| ERR_SYSTEM
, short2str(v
[0]),
626 CGETS(8, 1, "Unknown switch"));
633 int len
= 0, st
= 0, cu
;
634 for (m
= modelist
; m
->m_name
; m
++) {
635 if (m
->m_type
!= i
) {
636 xprintf("%s%s", i
!= -1 ? "\n" : "",
637 ttylist
[z
][m
->m_type
].t_name
);
639 st
= len
= strlen(ttylist
[z
][m
->m_type
].t_name
);
642 x
= (ttylist
[z
][i
].t_setmask
& m
->m_value
) ? '+' : '\0';
643 x
= (ttylist
[z
][i
].t_clrmask
& m
->m_value
) ? '-' : x
;
645 if (x
!= '\0' || aflag
) {
646 cu
= strlen(m
->m_name
) + (x
!= '\0') + 1;
647 if (len
+ cu
>= T_Cols
) {
648 xprintf("\n%*s", st
, "");
654 xprintf("%c%s ", x
, m
->m_name
);
656 xprintf("%s ", m
->m_name
);
662 while (v
&& (s
= *v
++)) {
673 for (m
= modelist
; m
->m_name
; m
++)
674 if (strcmp(m
->m_name
, d
) == 0)
677 stderror(ERR_NAME
| ERR_SYSTEM
, d
, CGETS(8, 2, "Invalid argument"));
681 ttylist
[z
][m
->m_type
].t_setmask
|= m
->m_value
;
682 ttylist
[z
][m
->m_type
].t_clrmask
&= ~m
->m_value
;
685 ttylist
[z
][m
->m_type
].t_setmask
&= ~m
->m_value
;
686 ttylist
[z
][m
->m_type
].t_clrmask
|= m
->m_value
;
689 ttylist
[z
][m
->m_type
].t_setmask
&= ~m
->m_value
;
690 ttylist
[z
][m
->m_type
].t_clrmask
&= ~m
->m_value
;
702 RETRY(tcgetattr(fd
, &td
->d_t
));
703 #else /* TERMIO || GSTTY */
705 RETRY(ioctl(fd
, TCGETA
, (ioctl_t
) &td
->d_t
));
708 RETRY(ioctl(fd
, TIOCGETP
, (ioctl_t
) &td
->d_t
));
709 # endif /* TIOCGETP */
711 RETRY(ioctl(fd
, TIOCGETC
, (ioctl_t
) &td
->d_tc
));
712 # endif /* TIOCGETC */
714 RETRY(ioctl(fd
, TIOCGPAGE
, (ioctl_t
) &td
->d_pc
));
715 # endif /* TIOCGPAGE */
717 RETRY(ioctl(fd
, TIOCLGET
, (ioctl_t
) &td
->d_lb
));
718 # endif /* TIOCLGET */
723 RETRY(ioctl(fd
, TIOCGLTC
, (ioctl_t
) &td
->d_ltc
));
724 #endif /* TIOCGLTC */
735 RETRY(tcsetattr(fd
, TCSADRAIN
, &td
->d_t
));
738 RETRY(ioctl(fd
, TCSETAW
, (ioctl_t
) &td
->d_t
));
741 RETRY(ioctl(fd
, TIOCSETN
, (ioctl_t
) &td
->d_t
));
742 # endif /* TIOCSETN */
744 RETRY(ioctl(fd
, TIOCSETC
, (ioctl_t
) &td
->d_tc
));
745 # endif /* TIOCGETC */
747 RETRY(ioctl(fd
, TIOCSPAGE
, (ioctl_t
) &td
->d_pc
));
748 # endif /* TIOCGPAGE */
750 RETRY(ioctl(fd
, TIOCLSET
, (ioctl_t
) &td
->d_lb
));
751 # endif /* TIOCLGET */
756 RETRY(ioctl(fd
, TIOCSLTC
, (ioctl_t
) &td
->d_ltc
));
757 #endif /* TIOCGLTC */
769 struct ltchars
*n
= &td
->d_ltc
;
771 s
[C_SUSP
] = n
->t_suspc
;
772 s
[C_DSUSP
] = n
->t_dsuspc
;
773 s
[C_REPRINT
] = n
->t_rprntc
;
774 s
[C_DISCARD
] = n
->t_flushc
;
775 s
[C_WERASE
] = n
->t_werasc
;
776 s
[C_LNEXT
] = n
->t_lnextc
;
778 #endif /* TIOCGLTC */
780 #if defined(POSIX) || defined(TERMIO)
783 struct termios
*n
= &td
->d_t
;
785 struct termio
*n
= &td
->d_t
;
789 s
[C_INTR
] = n
->c_cc
[VINTR
];
792 s
[C_QUIT
] = n
->c_cc
[VQUIT
];
795 s
[C_ERASE
] = n
->c_cc
[VERASE
];
798 s
[C_KILL
] = n
->c_cc
[VKILL
];
801 s
[C_EOF
] = n
->c_cc
[VEOF
];
804 s
[C_EOL
] = n
->c_cc
[VEOL
];
807 s
[C_EOL2
] = n
->c_cc
[VEOL2
];
810 s
[C_SWTCH
] = n
->c_cc
[VSWTCH
];
813 s
[C_DSWTCH
] = n
->c_cc
[VDSWTCH
];
814 # endif /* VDSWTCH */
816 s
[C_ERASE2
] = n
->c_cc
[VERASE2
];
817 # endif /* VERASE2 */
819 s
[C_START
] = n
->c_cc
[VSTART
];
822 s
[C_STOP
] = n
->c_cc
[VSTOP
];
825 s
[C_WERASE
] = n
->c_cc
[VWERASE
];
826 # endif /* VWERASE */
828 s
[C_SUSP
] = n
->c_cc
[VSUSP
];
831 s
[C_DSUSP
] = n
->c_cc
[VDSUSP
];
834 s
[C_REPRINT
] = n
->c_cc
[VREPRINT
];
835 # endif /* WREPRINT */
837 s
[C_DISCARD
] = n
->c_cc
[VDISCARD
];
838 # endif /* VDISCARD */
840 s
[C_LNEXT
] = n
->c_cc
[VLNEXT
];
843 s
[C_STATUS
] = n
->c_cc
[VSTATUS
];
844 # endif /* VSTATUS */
846 s
[C_CHECKPT
] = n
->c_cc
[VCHECKPT
];
847 # endif /* VCHECKPT */
849 s
[C_PAGE
] = n
->c_cc
[VPAGE
];
852 s
[C_PGOFF
] = n
->c_cc
[VPGOFF
];
855 s
[C_KILL2
] = n
->c_cc
[VKILL2
];
858 s
[C_MIN
] = n
->c_cc
[VMIN
];
861 s
[C_TIME
] = n
->c_cc
[VTIME
];
869 struct ttypagestat
*n
= &td
->d_pc
;
871 s
[C_STATUS
] = n
->tps_statc
;
872 s
[C_CHECKPT
] = n
->tps_checkp
;
873 s
[C_PAGE
] = n
->tps_pagec
;
874 s
[C_PGOFF
] = n
->tps_pgoffc
;
876 # endif /* TIOCGPAGE */
880 struct tchars
*n
= &td
->d_tc
;
882 s
[C_INTR
] = n
->t_intrc
;
883 s
[C_QUIT
] = n
->t_quitc
;
884 s
[C_START
] = n
->t_startc
;
885 s
[C_STOP
] = n
->t_stopc
;
886 s
[C_EOF
] = n
->t_eofc
;
887 s
[C_BRK
] = n
->t_brkc
;
889 # endif /* TIOCGETC */
893 struct sgttyb
*n
= &td
->d_t
;
895 s
[C_ERASE
] = n
->sg_erase
;
896 s
[C_KILL
] = n
->sg_kill
;
898 # endif /* TIOCGETP */
899 #endif /* !POSIX || TERMIO */
911 struct ltchars
*n
= &td
->d_ltc
;
913 n
->t_suspc
= s
[C_SUSP
];
914 n
->t_dsuspc
= s
[C_DSUSP
];
915 n
->t_rprntc
= s
[C_REPRINT
];
916 n
->t_flushc
= s
[C_DISCARD
];
917 n
->t_werasc
= s
[C_WERASE
];
918 n
->t_lnextc
= s
[C_LNEXT
];
920 #endif /* TIOCGLTC */
922 #if defined(POSIX) || defined(TERMIO)
925 struct termios
*n
= &td
->d_t
;
927 struct termio
*n
= &td
->d_t
;
931 n
->c_cc
[VINTR
] = s
[C_INTR
];
934 n
->c_cc
[VQUIT
] = s
[C_QUIT
];
937 n
->c_cc
[VERASE
] = s
[C_ERASE
];
940 n
->c_cc
[VKILL
] = s
[C_KILL
];
943 n
->c_cc
[VEOF
] = s
[C_EOF
];
946 n
->c_cc
[VEOL
] = s
[C_EOL
];
949 n
->c_cc
[VEOL2
] = s
[C_EOL2
];
952 n
->c_cc
[VSWTCH
] = s
[C_SWTCH
];
955 n
->c_cc
[VDSWTCH
] = s
[C_DSWTCH
];
956 # endif /* VDSWTCH */
958 n
->c_cc
[VERASE2
] = s
[C_ERASE2
];
959 # endif /* VERASE2 */
961 n
->c_cc
[VSTART
] = s
[C_START
];
964 n
->c_cc
[VSTOP
] = s
[C_STOP
];
967 n
->c_cc
[VWERASE
] = s
[C_WERASE
];
968 # endif /* VWERASE */
970 n
->c_cc
[VSUSP
] = s
[C_SUSP
];
973 n
->c_cc
[VDSUSP
] = s
[C_DSUSP
];
976 n
->c_cc
[VREPRINT
] = s
[C_REPRINT
];
977 # endif /* WREPRINT */
979 n
->c_cc
[VDISCARD
] = s
[C_DISCARD
];
980 # endif /* VDISCARD */
982 n
->c_cc
[VLNEXT
] = s
[C_LNEXT
];
985 n
->c_cc
[VSTATUS
] = s
[C_STATUS
];
986 # endif /* VSTATUS */
988 n
->c_cc
[VCHECKPT
] = s
[C_CHECKPT
];
989 # endif /* VCHECKPT */
991 n
->c_cc
[VPAGE
] = s
[C_PAGE
];
994 n
->c_cc
[VPGOFF
] = s
[C_PGOFF
];
997 n
->c_cc
[VKILL2
] = s
[C_KILL2
];
1000 n
->c_cc
[VMIN
] = s
[C_MIN
];
1003 n
->c_cc
[VTIME
] = s
[C_TIME
];
1011 struct ttypagestat
*n
= &td
->d_pc
;
1015 n
->tps_statc
= s
[C_STATUS
];
1016 n
->tps_pagec
= s
[C_PAGE
];
1017 n
->tps_pgoffc
= s
[C_PGOFF
];
1020 # endif /* TIOCGPAGE */
1024 struct tchars
*n
= &td
->d_tc
;
1025 n
->t_intrc
= s
[C_INTR
];
1026 n
->t_quitc
= s
[C_QUIT
];
1027 n
->t_startc
= s
[C_START
];
1028 n
->t_stopc
= s
[C_STOP
];
1029 n
->t_eofc
= s
[C_EOF
];
1030 n
->t_brkc
= s
[C_BRK
];
1032 # endif /* TIOCGETC */
1036 struct sgttyb
*n
= &td
->d_t
;
1038 n
->sg_erase
= s
[C_ERASE
];
1039 n
->sg_kill
= s
[C_KILL
];
1041 # endif /* TIOCGETP */
1042 #endif /* !POSIX || TERMIO */
1053 if ((spd
= cfgetispeed(&td
->d_t
)) == 0)
1054 spd
= cfgetospeed(&td
->d_t
);
1058 spd
= td
->d_t
.c_cflag
& CBAUD
;
1063 spd
= td
->d_t
.sg_ispeed
;
1064 # endif /* TERMIO */
1068 } /* end tty_getspeed */
1074 #if defined(POSIX) || defined(TERMIO)
1075 return ((td
->d_t
.c_oflag
& TAB3
) == TAB3
) ? 0 : 1;
1077 return (td
->d_t
.sg_flags
& XTABS
) == XTABS
? 0 : 1;
1078 #endif /* POSIX || TERMIO */
1079 } /* end tty_gettabs */
1085 #if defined(POSIX) || defined(TERMIO)
1086 return (td
->d_t
.c_cflag
& CSIZE
) == CS8
;
1088 return td
->d_lb
& (LPASS8
| LLITOUT
);
1089 #endif /* POSIX || TERMIO */
1090 } /* end tty_geteightbit */
1096 #if defined(POSIX) || defined(TERMIO)
1097 return (td
->d_t
.c_lflag
& ICANON
);
1099 return !(td
->d_t
.sg_flags
& (RAW
| CBREAK
));
1100 #endif /* POSIX || TERMIO */
1101 } /* end tty_cooked_mode */
1105 tty_setdisc(fd
, dis
)
1109 static bool edit_discipline
= 0;
1110 static union txname tx_disc
;
1111 extern char strPOSIX
[];
1115 if (edit_discipline
) {
1116 if (ioctl(fd
, TXSETLD
, (ioctl_t
) & tx_disc
) == -1)
1118 edit_discipline
= 0;
1123 tx_disc
.tx_which
= 0;
1124 if (ioctl(fd
, TXGETLD
, (ioctl_t
) & tx_disc
) == -1)
1126 if (strcmp(tx_disc
.tx_name
, strPOSIX
) != 0) {
1127 edit_discipline
= 1;
1128 if (ioctl(fd
, TXSETLD
, (ioctl_t
) strPOSIX
) == -1)
1136 } /* end tty_setdisc */
1144 struct tcshmodes
*m
;
1147 for (i
= 0; i
< C_NCC
; i
++) {
1148 for (m
= modelist
; m
->m_name
; m
++)
1149 if (m
->m_type
== M_CHAR
&& C_SH(i
) == m
->m_value
)
1152 xprintf("%s ^%c ", m
->m_name
, s
[i
] + 'A' - 1);
1158 #endif /* DEBUG_TTY */
1159 #else /* WINNT_NATIVE */
1164 return do_nt_check_cooked_mode();
1166 #endif /* !WINNT_NATIVE */