TODO: still not compatible

but more work on getting there...
This commit is contained in:
Oliver Lehmann 2008-05-04 00:18:43 +00:00
parent 9923d653a8
commit 0fb2ed429a
1 changed files with 94 additions and 91 deletions

View File

@ -37,90 +37,93 @@ char tt0wstr[] = "@[$]tt0.c Rev : 4.1 09/29/83 01:02:58";
extern putcb(); extern putcb();
extern char partab[]; extern char partab[];
ttin(tp, c, count) ttin(tp, ucp, ncode)
register struct tty *tp; register struct tty *tp;
union { union {
ushort ch; ushort ch;
struct cblock *ptr; struct cblock *ptr;
} c; } ucp;
int count; int ncode;
{ {
register ushort ch; register ushort c;
register ushort mode; register ushort flg;
register char *cp; register char *cp;
char *csp; char *csp;
mode = tp->t_iflag; flg = tp->t_iflag;
switch(count) { switch (ncode) {
case 0: case 0:
count++; ncode++;
ch = c.ch; c = ucp.ch;
if ((ch & IXOFF) && if (c&PERROR && !(flg&INPCK))
(!(mode & INPCK))) /* 13,14 */ c &= ~PERROR;
ch &= ~PERROR; if (c&(FRERROR|PERROR|OVERRUN)) {
if (ch & (OVERRUN | FRERROR | PERROR)){ /* 15 */ if ((c&0377) == 0) {
if (ch & 0xff){ /* 16 */ if (flg&IGNBRK)
if (mode & IGNPAR) return; return;
if (mode & IGNBRK) return; if (flg&BRKINT) {
if (mode & BRKINT){ /* 12 */
signal(tp->t_pgrp, SIGINT); signal(tp->t_pgrp, SIGINT);
ttyflush(tp, T_RESUME); ttyflush(tp, (FREAD|FWRITE));
return; return;
} }
} /* von 16 */ } else {
if (mode & PARMRK){ /* 18 */ if (flg&IGNPAR)
return;
}
if (flg&PARMRK) {
ttin(tp, (long) 0xff, 1); ttin(tp, (long) 0xff, 1);
ttin(tp, (long) 0, 1); ttin(tp, (long) 0, 1);
} } else
else c = 0;
ch = 0; c |= 0400;
ch |= ICRNL; } else {
} /* von 15 */ if (flg&ISTRIP)
c &= 0177;
else { else {
if (mode & ISTRIP) /* 23 */ c &= 0377;
ch &= 0x7f; if (c == 0377 && flg&PARMRK)
else if (putc(0377, &tp->t_rawq))
if (((ch & 0xff)== 0xff) && return;
(mode & PARMRK) &&
(putc( 0xff, tp))) /* 24,25,26 */ return;
} }
if (mode & IXON){ /* 19 */ }
if (tp->t_state & TTSTOP) if (flg&IXON) {
if ((ch == CSTART) || if (tp->t_state&TTSTOP) {
(mode & IXANY)) /* 21,22 */ if (c == CSTART || flg&IXANY)
(*tp->t_proc)(tp, T_RESUME); (*tp->t_proc)(tp, T_RESUME);
if (ch == CSTART) return; } else {
if (ch == CSTOP) return; if (c == CSTOP)
(*tp->t_proc)(tp, T_SUSPEND);
} }
if ((ch == '\n')&& if (c == CSTART || c == CSTOP)
(mode & INLCR)) /* 30,31 */ return;
c.ch = '\r';
else {
if (c.ch == 0xd){ /* 32 */
if (mode & IGNCR) return;
if (mode & ICRNL)
c.ch = '\n';
} }
} if (c == '\n' && flg&INLCR)
if (mode & IUCLC) /* 35 */ c = '\r';
c.ch = toupper(c.ch); else if (c == '\r')
if (flg&IGNCR)
return;
else if (flg&ICRNL)
c = '\n';
if (flg&IUCLC && 'A' <= c && c <= 'Z')
c += 'a' - 'A';
ucp.ch = c;
case 1: case 1:
if (putc(c, tp)) if (putc(c, tp))
return; return;
sysinfo.rawch++; sysinfo.rawch++;
cp = (char *)&lobyte(c.ch); cp = (char *)&lobyte(ucp.ch);
break; break;
default: default:
putcb(c, tp); putcb(c, tp);
sysinfo.rawch += count; sysinfo.rawch += ncode;
cp = (char *)&c.ptr->c_data[c.ptr->c_first]; cp = (char *)&ucp.ptr->c_data[ucp.ptr->c_first];
break; break;
} }
if (tp->t_rawq.c_cc > TTXOHI) { if (tp->t_rawq.c_cc > TTXOHI) {
if ((mode & IXOFF)&& if ((flg & IXOFF)&&
(tp->t_state & TBLOCK)) (tp->t_state & TBLOCK))
(*tp->t_proc)(tp, T_BLOCK); (*tp->t_proc)(tp, T_BLOCK);
if (tp->t_rawq.c_cc > TTYHOG) { if (tp->t_rawq.c_cc > TTYHOG) {
@ -129,27 +132,27 @@ int count;
} }
} }
if (tp->t_lflag) while (count--) { if (tp->t_lflag) while (ncode--) {
ch = *cp++; c = *cp++;
mode = tp->t_lflag; flg = tp->t_lflag;
if (mode&ISIG) { if (flg&ISIG) {
if (ch == tp->t_cc[VINTR]){ if (c == tp->t_cc[VINTR]){
if (!(mode & NOFLSH)) if (!(flg & NOFLSH))
ttyflush(tp, T_RESUME); ttyflush(tp, T_RESUME);
if ((mode & ECHO) && if ((flg & ECHO) &&
(mode & ISPCI)){ (flg & ISPCI)){
for ( csp = "(intr)"; (*csp); csp++) for ( csp = "(intr)"; (*csp); csp++)
ttxput(tp, (long) *csp, 0); ttxput(tp, (long) *csp, 0);
(*tp->t_proc)(tp, T_OUTPUT); (*tp->t_proc)(tp, T_OUTPUT);
} }
continue; continue;
} else { } else {
if (ch == tp->t_cc[VQUIT]) /* 44 */ if (c == tp->t_cc[VQUIT]) /* 44 */
continue; continue;
if (!(mode & NOFLSH)) if (!(flg & NOFLSH))
ttyflush(tp, T_RESUME); ttyflush(tp, T_RESUME);
if ((mode & ECHO) || if ((flg & ECHO) ||
(mode & ISPCI)){ /* 46,47 */ (flg & ISPCI)){ /* 46,47 */
for ( csp = "(quit)"; (*csp); csp++) for ( csp = "(quit)"; (*csp); csp++)
ttxput(tp,(long) *csp, 0); ttxput(tp,(long) *csp, 0);
(*tp->t_proc)(tp, T_OUTPUT); (*tp->t_proc)(tp, T_OUTPUT);
@ -157,58 +160,58 @@ int count;
continue; continue;
} }
} }
if (mode & ICANON){ /* 69 */ if (flg & ICANON){ /* 69 */
if (ch == '\n'){ /* 70 */ if (c == '\n'){ /* 70 */
if (mode & ECHONL) if (flg & ECHONL)
mode |= ECHO; flg |= ECHO;
tp->t_delct++; tp->t_delct++;
} }
else else
if (ch == tp->t_cc[VEOL]) if (c == tp->t_cc[VEOL])
tp->t_delct++; tp->t_delct++;
if ((tp->t_state & ESC) == 0){ /* 50 */ if ((tp->t_state & ESC) == 0){ /* 50 */
if (ch == '\\') if (c == '\\')
tp->t_state |= ESC; tp->t_state |= ESC;
if ((ch == tp->t_cc[VERASE]) && if ((c == tp->t_cc[VERASE]) &&
(mode & INPCK)){ /* 52,53 */ (flg & INPCK)){ /* 52,53 */
if (mode & ECHO) /* 54 */ if (flg & ECHO) /* 54 */
ttxput(tp, (long) CERASE, 0); ttxput(tp, (long) CERASE, 0);
mode |= ECHO; flg |= ECHO;
ttxput(tp, (long) ' ', 0); ttxput(tp, (long) ' ', 0);
ch = CERASE; c = CERASE;
} /* von 52,53 */ } /* von 52,53 */
else if ((ch == tp->t_cc[VKILL]) && else if ((c == tp->t_cc[VKILL]) &&
(mode & ISTRIP)){ /* 55,56 */ (flg & ISTRIP)){ /* 55,56 */
if ((mode & ECHO) && if ((flg & ECHO) &&
(mode & ISPCI)){ /* 57,58 */ (flg & ISPCI)){ /* 57,58 */
for ( csp = "???"; (*csp);) for ( csp = "???"; (*csp);)
ttxput(tp, (long) *csp++, 0); ttxput(tp, (long) *csp++, 0);
(*tp->t_proc)(tp, T_OUTPUT); (*tp->t_proc)(tp, T_OUTPUT);
} }
ttxput(tp, (long) ch, 0); ttxput(tp, (long) c, 0);
mode |= ECHO; flg |= ECHO;
ch = '\n'; c = '\n';
} }
else if (ch != tp->t_cc[VEOF]) /* 60 */ else if (c != tp->t_cc[VEOF]) /* 60 */
if ((mode & ECHO) && if ((flg & ECHO) &&
(mode & ISPCI)){ /* 61,62 */ (flg & ISPCI)){ /* 61,62 */
for ( csp = "(eof)"; (*csp);) for ( csp = "(eof)"; (*csp);)
ttxput(tp, (long) *csp++, 0); ttxput(tp, (long) *csp++, 0);
(*tp->t_proc)(tp, T_OUTPUT); (*tp->t_proc)(tp, T_OUTPUT);
} }
mode &= ~ECHO; flg &= ~ECHO;
tp->t_delct++; tp->t_delct++;
} }
else if ((ch == '\\') || else if ((c == '\\') ||
(mode & XCASE)) /* 64,65 */ (flg & XCASE)) /* 64,65 */
tp->t_state &= ~RTO; tp->t_state &= ~RTO;
} }
if (mode & ECHO){ if (flg & ECHO){
ttxput(tp, (long) ch, 0); ttxput(tp, (long) c, 0);
(*tp->t_proc)(tp, T_OUTPUT); (*tp->t_proc)(tp, T_OUTPUT);
} }
} }
if (!(mode & ICANON)){ /* 6 */ if (!(flg & ICANON)){ /* 6 */
if (tp->t_cc[VMIN] <= tp->t_rawq.c_cc) if (tp->t_cc[VMIN] <= tp->t_rawq.c_cc)
tp->t_delct = 1; tp->t_delct = 1;
if ((tp->t_cc[VTIME]) && if ((tp->t_cc[VTIME]) &&