TODO: more progress but still not 100% complete

This commit is contained in:
Oliver Lehmann 2008-05-04 12:04:12 +00:00
parent 0fb2ed429a
commit a1d830ffc9
1 changed files with 66 additions and 60 deletions

View File

@ -37,20 +37,33 @@ char tt0wstr[] = "@[$]tt0.c Rev : 4.1 09/29/83 01:02:58";
extern putcb(); extern putcb();
extern char partab[]; extern char partab[];
/*
* Place character(s) on raw TTY input queue, putting in delimiters
* and waking up top half as needed.
* Also echo if required.
*/
ttin(tp, ucp, ncode) ttin(tp, ucp, ncode)
register struct tty *tp; register struct tty *tp;
union { union {
ushort ch; long ch;
struct cblock *ptr; struct cblock *ptr;
struct
{
char l_l;
char l_r;
char r_l;
char r_r;
}
byte;
} ucp; } ucp;
int ncode; int ncode;
{ {
register ushort c; register c;
register ushort flg; register flg;
register char *cp; register unsigned char *cp;
char *csp; char *csp;
extern tttimeo();
flg = tp->t_iflag; flg = tp->t_iflag;
switch (ncode) { switch (ncode) {
@ -110,18 +123,17 @@ int ncode;
c += 'a' - 'A'; c += 'a' - 'A';
ucp.ch = c; ucp.ch = c;
case 1: case 1:
if (putc(c, tp)) if (putc(ucp.r_r, &tp->t_rawq))
return; return;
sysinfo.rawch++; sysinfo.rawch++;
cp = (char *)&lobyte(ucp.ch); cp = (unsigned char *)ucp.r_r;
break; break;
default: default:
putcb(c, tp); putcb(ucp.ch, &tp->t_rawq);
sysinfo.rawch += ncode; sysinfo.rawch += ncode;
cp = (char *)&ucp.ptr->c_data[ucp.ptr->c_first]; cp = (unsigned 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 ((flg & IXOFF)&& if ((flg & IXOFF)&&
(tp->t_state & TBLOCK)) (tp->t_state & TBLOCK))
@ -136,23 +148,22 @@ int ncode;
c = *cp++; c = *cp++;
flg = tp->t_lflag; flg = tp->t_lflag;
if (flg&ISIG) { if (flg&ISIG) {
if (c == tp->t_cc[VINTR]){ if (c == tp->t_cc[VINTR]) {
if (!(flg & NOFLSH)) if (!(flg&NOFLSH))
ttyflush(tp, T_RESUME); ttyflush(tp, (FREAD|FWRITE));
if ((flg & ECHO) && if ((flg&ECHO) &&
(flg & 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 { }
if (c == tp->t_cc[VQUIT]) /* 44 */ if (c == tp->t_cc[VQUIT]) {
continue; if (!(flg&NOFLSH))
if (!(flg & NOFLSH)) ttyflush(tp, (FREAD|FWRITE));
ttyflush(tp, T_RESUME); if ((flg&ECHO) ||
if ((flg & ECHO) || (flg&ISPCI)) {
(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);
@ -160,70 +171,65 @@ int ncode;
continue; continue;
} }
} }
if (flg & ICANON){ /* 69 */ if (flg&ICANON) {
if (c == '\n'){ /* 70 */ if (c == '\n') {
if (flg & ECHONL) if (flg&ECHONL)
flg |= ECHO; flg |= ECHO;
tp->t_delct++; tp->t_delct++;
} } else if (c == tp->t_cc[VEOL])
else tp->t_delct++;
if (c == tp->t_cc[VEOL]) if ((tp->t_state&ESC) == 0) {
tp->t_delct++;
if ((tp->t_state & ESC) == 0){ /* 50 */
if (c == '\\') if (c == '\\')
tp->t_state |= ESC; tp->t_state |= ESC;
if ((c == tp->t_cc[VERASE]) && if (c == tp->t_cc[VERASE] && flg&ECHOE) {
(flg & INPCK)){ /* 52,53 */ if (flg&ECHO)
if (flg & ECHO) /* 54 */ ttxput(tp, (long) '\b', 0);
ttxput(tp, (long) CERASE, 0);
flg |= ECHO; flg |= ECHO;
ttxput(tp, (long) ' ', 0); ttxput(tp, (long) ' ', 0);
c = CERASE; c = '\b';
} /* von 52,53 */ } else if (c == tp->t_cc[VKILL] && flg&ECHOK) {
else if ((c == tp->t_cc[VKILL]) &&
(flg & ISTRIP)){ /* 55,56 */
if ((flg & ECHO) && if ((flg & ECHO) &&
(flg & ISPCI)){ /* 57,58 */ (flg & ISPCI)) {
for ( csp = "???"; (*csp);) for ( csp = "XXX"; (*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) c, 0); ttxput(tp, (long) c, 0);
flg |= ECHO; flg |= ECHO;
c = '\n'; c = '\n';
} } else if (c == tp->t_cc[VEOF]) {
else if (c != tp->t_cc[VEOF]) /* 60 */
if ((flg & ECHO) && if ((flg & ECHO) &&
(flg & ISPCI)){ /* 61,62 */ (flg & ISPCI)) {
for ( csp = "(eof)"; (*csp);) for ( csp = "(eof)\n"; (*csp);)
ttxput(tp, (long) *csp++, 0); ttxput(tp, (long) *csp++, 0);
(*tp->t_proc)(tp, T_OUTPUT); (*tp->t_proc)(tp, T_OUTPUT);
} }
flg &= ~ECHO; flg &= ~ECHO;
tp->t_delct++; tp->t_delct++;
}
} else {
if (c != '\\' || (flg&XCASE))
tp->t_state &= ~ESC;
} }
else if ((c == '\\') ||
(flg & XCASE)) /* 64,65 */
tp->t_state &= ~RTO;
} }
if (flg & ECHO){ if (flg&ECHO) {
ttxput(tp, (long) c, 0); ttxput(tp, (long) c, 0);
(*tp->t_proc)(tp, T_OUTPUT); (*tp->t_proc)(tp, T_OUTPUT);
} }
} }
if (!(flg & ICANON)){ /* 6 */ if (!(flg&ICANON)) {
if (tp->t_cc[VMIN] <= tp->t_rawq.c_cc) tp->t_state &= ~RTO;
if (tp->t_rawq.c_cc >= tp->t_cc[VMIN])
tp->t_delct = 1; tp->t_delct = 1;
if ((tp->t_cc[VTIME]) && else if (tp->t_cc[VTIME]) {
((tp->t_state & TACT) == 0)) if (!(tp->t_state&TACT))
tttimeout(tp); tttimeo(tp);
} /* von 6 */ }
if ((tp->t_delct) && }
(tp->t_state & IASLP)){ /* 74,75 */ if (tp->t_delct && (tp->t_state&IASLP)) {
tp->t_state &= ~IASLP; tp->t_state &= ~IASLP;
wakeup(tp); wakeup(tp);
} }
return;
} }
/* /*