convert newlines DOS->UNIX
This commit is contained in:
parent
e1834f5cd5
commit
00bdf794ec
|
|
@ -1,494 +1,494 @@
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
***************************************************************************
|
***************************************************************************
|
||||||
|
|
||||||
W E G A - Quelle
|
W E G A - Quelle
|
||||||
KERN 3.2 Modul : tt0.c
|
KERN 3.2 Modul : tt0.c
|
||||||
|
|
||||||
Bearbeiter : O. Lehmann
|
Bearbeiter : O. Lehmann
|
||||||
Datum : 03.05.08
|
Datum : 03.05.08
|
||||||
Version : 1.0
|
Version : 1.0
|
||||||
|
|
||||||
***************************************************************************
|
***************************************************************************
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/state.h>
|
#include <sys/state.h>
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
#include <sys/dir.h>
|
#include <sys/dir.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/tty.h>
|
#include <sys/tty.h>
|
||||||
#include <sys/ttold.h>
|
#include <sys/ttold.h>
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/inode.h>
|
#include <sys/inode.h>
|
||||||
#include <sys/mmu.h>
|
#include <sys/mmu.h>
|
||||||
#include <sys/s.out.h>
|
#include <sys/s.out.h>
|
||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Line discipline 0
|
* Line discipline 0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char tt0wstr[] = "@[$]tt0.c Rev : 4.1 09/29/83 01:02:58";
|
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
|
* Place character(s) on raw TTY input queue, putting in delimiters
|
||||||
* and waking up top half as needed.
|
* and waking up top half as needed.
|
||||||
* Also echo if required.
|
* Also echo if required.
|
||||||
*/
|
*/
|
||||||
ttin(tp, ucp, ncode)
|
ttin(tp, ucp, ncode)
|
||||||
register struct tty *tp;
|
register struct tty *tp;
|
||||||
union {
|
union {
|
||||||
long ch;
|
long ch;
|
||||||
struct cblock *ptr;
|
struct cblock *ptr;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char l_l;
|
char l_l;
|
||||||
char l_r;
|
char l_r;
|
||||||
char r_l;
|
char r_l;
|
||||||
char r_r;
|
char r_r;
|
||||||
}
|
}
|
||||||
byte;
|
byte;
|
||||||
} ucp;
|
} ucp;
|
||||||
int ncode;
|
int ncode;
|
||||||
{
|
{
|
||||||
register c;
|
register c;
|
||||||
register flg;
|
register flg;
|
||||||
register unsigned char *cp;
|
register unsigned char *cp;
|
||||||
char *csp;
|
char *csp;
|
||||||
extern tttimeo();
|
extern tttimeo();
|
||||||
|
|
||||||
flg = tp->t_iflag;
|
flg = tp->t_iflag;
|
||||||
switch (ncode) {
|
switch (ncode) {
|
||||||
case 0:
|
case 0:
|
||||||
ncode++;
|
ncode++;
|
||||||
c = ucp.ch;
|
c = ucp.ch;
|
||||||
if (c&PERROR && !(flg&INPCK))
|
if (c&PERROR && !(flg&INPCK))
|
||||||
c &= ~PERROR;
|
c &= ~PERROR;
|
||||||
if (c&(FRERROR|PERROR|OVERRUN)) {
|
if (c&(FRERROR|PERROR|OVERRUN)) {
|
||||||
if ((c&0377) == 0) {
|
if ((c&0377) == 0) {
|
||||||
if (flg&IGNBRK)
|
if (flg&IGNBRK)
|
||||||
return;
|
return;
|
||||||
if (flg&BRKINT) {
|
if (flg&BRKINT) {
|
||||||
signal(tp->t_pgrp, SIGINT);
|
signal(tp->t_pgrp, SIGINT);
|
||||||
ttyflush(tp, (FREAD|FWRITE));
|
ttyflush(tp, (FREAD|FWRITE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (flg&IGNPAR)
|
if (flg&IGNPAR)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (flg&PARMRK) {
|
if (flg&PARMRK) {
|
||||||
ttin(tp, (long) 0377, 1);
|
ttin(tp, (long) 0377, 1);
|
||||||
ttin(tp, (long) 0, 1);
|
ttin(tp, (long) 0, 1);
|
||||||
} else
|
} else
|
||||||
c = 0;
|
c = 0;
|
||||||
c |= 0400;
|
c |= 0400;
|
||||||
} else {
|
} else {
|
||||||
if (flg&ISTRIP)
|
if (flg&ISTRIP)
|
||||||
c &= 0177;
|
c &= 0177;
|
||||||
else {
|
else {
|
||||||
c &= 0377;
|
c &= 0377;
|
||||||
if (c == 0377 && flg&PARMRK)
|
if (c == 0377 && flg&PARMRK)
|
||||||
if (putc(0377, &tp->t_rawq))
|
if (putc(0377, &tp->t_rawq))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flg&IXON) {
|
if (flg&IXON) {
|
||||||
if (tp->t_state&TTSTOP) {
|
if (tp->t_state&TTSTOP) {
|
||||||
if (c == CSTART || flg&IXANY)
|
if (c == CSTART || flg&IXANY)
|
||||||
(*tp->t_proc)(tp, T_RESUME);
|
(*tp->t_proc)(tp, T_RESUME);
|
||||||
} else {
|
} else {
|
||||||
if (c == CSTOP)
|
if (c == CSTOP)
|
||||||
(*tp->t_proc)(tp, T_SUSPEND);
|
(*tp->t_proc)(tp, T_SUSPEND);
|
||||||
}
|
}
|
||||||
if (c == CSTART || c == CSTOP)
|
if (c == CSTART || c == CSTOP)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (c == '\n' && flg&INLCR)
|
if (c == '\n' && flg&INLCR)
|
||||||
c = '\r';
|
c = '\r';
|
||||||
else if (c == '\r')
|
else if (c == '\r')
|
||||||
if (flg&IGNCR)
|
if (flg&IGNCR)
|
||||||
return;
|
return;
|
||||||
else if (flg&ICRNL)
|
else if (flg&ICRNL)
|
||||||
c = '\n';
|
c = '\n';
|
||||||
if (flg&IUCLC && 'A' <= c && c <= 'Z')
|
if (flg&IUCLC && 'A' <= c && c <= 'Z')
|
||||||
c += 'a' - 'A';
|
c += 'a' - 'A';
|
||||||
ucp.ch = c;
|
ucp.ch = c;
|
||||||
case 1:
|
case 1:
|
||||||
if (putc(ucp.r_r, &tp->t_rawq))
|
if (putc(ucp.r_r, &tp->t_rawq))
|
||||||
return;
|
return;
|
||||||
sysinfo.rawch++;
|
sysinfo.rawch++;
|
||||||
cp = (unsigned char *)&ucp.r_r;
|
cp = (unsigned char *)&ucp.r_r;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
putcb(ucp.ch, &tp->t_rawq);
|
putcb(ucp.ch, &tp->t_rawq);
|
||||||
sysinfo.rawch += ncode;
|
sysinfo.rawch += ncode;
|
||||||
cp = (unsigned 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 && !(tp->t_state&TBLOCK))
|
if (flg&IXOFF && !(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) {
|
||||||
ttyflush(tp, FREAD);
|
ttyflush(tp, FREAD);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
flg = tp->t_lflag;
|
flg = tp->t_lflag;
|
||||||
if (!(tp->t_state&IEXTPROC))
|
if (!(tp->t_state&IEXTPROC))
|
||||||
if (tp->t_lflag)
|
if (tp->t_lflag)
|
||||||
while (ncode--) {
|
while (ncode--) {
|
||||||
c = *cp++;
|
c = *cp++;
|
||||||
flg = tp->t_lflag; /* FIXME - wird das hier gebraucht? */
|
flg = tp->t_lflag; /* FIXME - wird das hier gebraucht? */
|
||||||
|
|
||||||
if (flg&ISIG) {
|
if (flg&ISIG) {
|
||||||
if (c == tp->t_cc[VINTR]) {
|
if (c == tp->t_cc[VINTR]) {
|
||||||
signal(tp->t_pgrp, SIGINT);
|
signal(tp->t_pgrp, SIGINT);
|
||||||
if (!(flg&NOFLSH))
|
if (!(flg&NOFLSH))
|
||||||
ttyflush(tp, (FREAD|FWRITE));
|
ttyflush(tp, (FREAD|FWRITE));
|
||||||
if ((flg&ECHO) &&
|
if ((flg&ECHO) &&
|
||||||
(flg&ISPCI)) { /* muss bleiben */
|
(flg&ISPCI)) { /* muss bleiben */
|
||||||
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;
|
||||||
}
|
}
|
||||||
if (c == tp->t_cc[VQUIT]) {
|
if (c == tp->t_cc[VQUIT]) {
|
||||||
signal(tp->t_pgrp, SIGQUIT);
|
signal(tp->t_pgrp, SIGQUIT);
|
||||||
if (!(flg&NOFLSH))
|
if (!(flg&NOFLSH))
|
||||||
ttyflush(tp, (FREAD|FWRITE));
|
ttyflush(tp, (FREAD|FWRITE));
|
||||||
if ((flg&ECHO) ||
|
if ((flg&ECHO) ||
|
||||||
(flg&ISPCI)) { /* muss bleiben */
|
(flg&ISPCI)) { /* muss bleiben */
|
||||||
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);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flg&ICANON) {
|
if (flg&ICANON) {
|
||||||
if (c == '\n') {
|
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 if (c == tp->t_cc[VEOL])
|
||||||
tp->t_delct++;
|
tp->t_delct++;
|
||||||
if (!(tp->t_state&ESC)) {
|
if (!(tp->t_state&ESC)) {
|
||||||
if (c == '\\')
|
if (c == '\\')
|
||||||
tp->t_state |= ESC;
|
tp->t_state |= ESC;
|
||||||
if (c == tp->t_cc[VERASE] && flg&ECHOE) {
|
if (c == tp->t_cc[VERASE] && flg&ECHOE) {
|
||||||
if (flg&ECHO)
|
if (flg&ECHO)
|
||||||
ttxput(tp, (long) '\b', 0);
|
ttxput(tp, (long) '\b', 0);
|
||||||
flg |= ECHO;
|
flg |= ECHO;
|
||||||
ttxput(tp, (long) ' ', 0);
|
ttxput(tp, (long) ' ', 0);
|
||||||
c = '\b';
|
c = '\b';
|
||||||
} else if (c == tp->t_cc[VKILL] && flg&ECHOK) {
|
} else if (c == tp->t_cc[VKILL] && flg&ECHOK) {
|
||||||
if ((flg & ECHO) &&
|
if ((flg & ECHO) &&
|
||||||
(flg & ISPCI)) { /* FIXME - muss das hier weg? */
|
(flg & ISPCI)) { /* FIXME - muss das hier weg? */
|
||||||
for ( csp = "XXX"; (*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]) {
|
||||||
if ((flg & ECHO) &&
|
if ((flg & ECHO) &&
|
||||||
(flg & ISPCI)) { /* muss bleiben */
|
(flg & ISPCI)) { /* muss bleiben */
|
||||||
for ( csp = "(eof)\n"; (*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 {
|
} else {
|
||||||
if (c != '\\' || (flg&XCASE))
|
if (c != '\\' || (flg&XCASE))
|
||||||
tp->t_state &= ~ESC;
|
tp->t_state &= ~ESC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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)) {
|
if (!(flg&ICANON)) {
|
||||||
tp->t_state &= ~RTO;
|
tp->t_state &= ~RTO;
|
||||||
if (tp->t_rawq.c_cc >= tp->t_cc[VMIN])
|
if (tp->t_rawq.c_cc >= tp->t_cc[VMIN])
|
||||||
tp->t_delct = 1;
|
tp->t_delct = 1;
|
||||||
else if (tp->t_cc[VTIME]) {
|
else if (tp->t_cc[VTIME]) {
|
||||||
if (!(tp->t_state&TACT))
|
if (!(tp->t_state&TACT))
|
||||||
tttimeo(tp);
|
tttimeo(tp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tp->t_delct && (tp->t_state&IASLP)) {
|
if (tp->t_delct && (tp->t_state&IASLP)) {
|
||||||
tp->t_state &= ~IASLP;
|
tp->t_state &= ~IASLP;
|
||||||
wakeup(tp);
|
wakeup(tp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Put character(s) on TTY output queue, adding delays,
|
* Put character(s) on TTY output queue, adding delays,
|
||||||
* expanding tabs, and handling the CR/NL bit.
|
* expanding tabs, and handling the CR/NL bit.
|
||||||
* It is called both from the top half for output, and from
|
* It is called both from the top half for output, and from
|
||||||
* interrupt level for echoing.
|
* interrupt level for echoing.
|
||||||
*/
|
*/
|
||||||
ttxput(tp, ucp, ncode)
|
ttxput(tp, ucp, ncode)
|
||||||
register struct tty *tp;
|
register struct tty *tp;
|
||||||
union {
|
union {
|
||||||
long ch;
|
long ch;
|
||||||
struct cblock *ptr;
|
struct cblock *ptr;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char l_l;
|
char l_l;
|
||||||
char l_r;
|
char l_r;
|
||||||
char r_l;
|
char r_l;
|
||||||
char r_r;
|
char r_r;
|
||||||
}
|
}
|
||||||
byte;
|
byte;
|
||||||
} ucp;
|
} ucp;
|
||||||
int ncode;
|
int ncode;
|
||||||
{
|
{
|
||||||
register c;
|
register c;
|
||||||
register flg;
|
register flg;
|
||||||
register unsigned char *cp;
|
register unsigned char *cp;
|
||||||
register char *colp;
|
register char *colp;
|
||||||
int ctype;
|
int ctype;
|
||||||
register int cs;
|
register int cs;
|
||||||
struct cblock *scf;
|
struct cblock *scf;
|
||||||
|
|
||||||
flg = tp->t_oflag;
|
flg = tp->t_oflag;
|
||||||
if (tp->t_state&OEXTPROC)
|
if (tp->t_state&OEXTPROC)
|
||||||
flg &= ~OPOST;
|
flg &= ~OPOST;
|
||||||
if (ncode == 0) {
|
if (ncode == 0) {
|
||||||
if (tp->t_outq.c_cc >= TTYHOG)
|
if (tp->t_outq.c_cc >= TTYHOG)
|
||||||
return;
|
return;
|
||||||
ncode++;
|
ncode++;
|
||||||
if (!(flg&OPOST)) {
|
if (!(flg&OPOST)) {
|
||||||
sysinfo.outch++;
|
sysinfo.outch++;
|
||||||
putc(ucp.r_r, &tp->t_outq);
|
putc(ucp.r_r, &tp->t_outq);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cp = (unsigned char *)&ucp.r_r;
|
cp = (unsigned char *)&ucp.r_r;
|
||||||
scf = NULL;
|
scf = NULL;
|
||||||
} else {
|
} else {
|
||||||
if (!(flg&OPOST)) {
|
if (!(flg&OPOST)) {
|
||||||
sysinfo.outch += ncode;
|
sysinfo.outch += ncode;
|
||||||
putcb(ucp.ch, &tp->t_outq);
|
putcb(ucp.ch, &tp->t_outq);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cp = (unsigned char *)&ucp.ptr->c_data[ucp.ptr->c_first];
|
cp = (unsigned char *)&ucp.ptr->c_data[ucp.ptr->c_first];
|
||||||
scf = ucp.ptr;
|
scf = ucp.ptr;
|
||||||
}
|
}
|
||||||
while (ncode--) {
|
while (ncode--) {
|
||||||
c = *cp++;
|
c = *cp++;
|
||||||
if (c >= DELAYDEL){
|
if (c >= DELAYDEL){
|
||||||
if (c == DELAYDEL)
|
if (c == DELAYDEL)
|
||||||
putc(DELAYDEL, &tp->t_outq);
|
putc(DELAYDEL, &tp->t_outq);
|
||||||
sysinfo.outch++;
|
sysinfo.outch++;
|
||||||
putc(c, &tp->t_outq);
|
putc(c, &tp->t_outq);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Generate escapes for upper-case-only terminals.
|
* Generate escapes for upper-case-only terminals.
|
||||||
*/
|
*/
|
||||||
if (tp->t_lflag&XCASE) {
|
if (tp->t_lflag&XCASE) {
|
||||||
colp = "({)}!|^~'`\\";
|
colp = "({)}!|^~'`\\";
|
||||||
while(*colp++)
|
while(*colp++)
|
||||||
if (c == *colp++) {
|
if (c == *colp++) {
|
||||||
tp->t_lflag &= ~XCASE;
|
tp->t_lflag &= ~XCASE;
|
||||||
ttxput(tp, (long)'\\', 0);
|
ttxput(tp, (long)'\\', 0);
|
||||||
tp->t_lflag |= XCASE;
|
tp->t_lflag |= XCASE;
|
||||||
c = colp[-2];
|
c = colp[-2];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ('A' <= c && c <= 'Z'){
|
if ('A' <= c && c <= 'Z'){
|
||||||
tp->t_lflag &= ~XCASE;
|
tp->t_lflag &= ~XCASE;
|
||||||
ttxput(tp, (long)'\\', 0);
|
ttxput(tp, (long)'\\', 0);
|
||||||
tp->t_lflag |= XCASE;
|
tp->t_lflag |= XCASE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (flg&OLCUC && 'a' <= c && c <= 'z')
|
if (flg&OLCUC && 'a' <= c && c <= 'z')
|
||||||
c += 'A' - 'a';
|
c += 'A' - 'a';
|
||||||
cs = c;
|
cs = c;
|
||||||
/*
|
/*
|
||||||
* Calculate delays.
|
* Calculate delays.
|
||||||
* The numbers here represent clock ticks
|
* The numbers here represent clock ticks
|
||||||
* and are not necessarily optimal for all terminals.
|
* and are not necessarily optimal for all terminals.
|
||||||
* The delays are indicated by characters above 0200.
|
* The delays are indicated by characters above 0200.
|
||||||
*/
|
*/
|
||||||
ctype = partab[c];
|
ctype = partab[c];
|
||||||
colp = &tp->t_col;
|
colp = &tp->t_col;
|
||||||
c = 0;
|
c = 0;
|
||||||
switch (ctype&077) {
|
switch (ctype&077) {
|
||||||
case 0: /* ordinary */
|
case 0: /* ordinary */
|
||||||
(*colp)++;
|
(*colp)++;
|
||||||
|
|
||||||
case 1: /* non-printing */
|
case 1: /* non-printing */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* backspace */
|
case 2: /* backspace */
|
||||||
if (flg&BSDLY)
|
if (flg&BSDLY)
|
||||||
c = 2;
|
c = 2;
|
||||||
if (*colp)
|
if (*colp)
|
||||||
(*colp)--;
|
(*colp)--;
|
||||||
break;
|
break;
|
||||||
case 3: /* line feed */
|
case 3: /* line feed */
|
||||||
if (flg&ONLRET)
|
if (flg&ONLRET)
|
||||||
goto cr;
|
goto cr;
|
||||||
if (flg&ONLCR) {
|
if (flg&ONLCR) {
|
||||||
if (!(flg&ONOCR && *colp==0)) {
|
if (!(flg&ONOCR && *colp==0)) {
|
||||||
sysinfo.outch++;
|
sysinfo.outch++;
|
||||||
putc('\r', &tp->t_outq);
|
putc('\r', &tp->t_outq);
|
||||||
}
|
}
|
||||||
goto cr;
|
goto cr;
|
||||||
}
|
}
|
||||||
nl:
|
nl:
|
||||||
if (flg&NLDLY)
|
if (flg&NLDLY)
|
||||||
c = 5;
|
c = 5;
|
||||||
break;
|
break;
|
||||||
case 4: /* tab */
|
case 4: /* tab */
|
||||||
c = 8 - ((*colp)&07);
|
c = 8 - ((*colp)&07);
|
||||||
*colp += c;
|
*colp += c;
|
||||||
ctype = flg&TABDLY;
|
ctype = flg&TABDLY;
|
||||||
if (ctype == TAB0) {
|
if (ctype == TAB0) {
|
||||||
c = 0;
|
c = 0;
|
||||||
} else if (ctype == TAB1) {
|
} else if (ctype == TAB1) {
|
||||||
if (c < 5)
|
if (c < 5)
|
||||||
c = 0;
|
c = 0;
|
||||||
} else if (ctype == TAB2) {
|
} else if (ctype == TAB2) {
|
||||||
c = 2;
|
c = 2;
|
||||||
} else if (ctype == TAB3) {
|
} else if (ctype == TAB3) {
|
||||||
sysinfo.outch += c;
|
sysinfo.outch += c;
|
||||||
do
|
do
|
||||||
putc(' ', &tp->t_outq);
|
putc(' ', &tp->t_outq);
|
||||||
while (--c);
|
while (--c);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: /* vertical tab */
|
case 5: /* vertical tab */
|
||||||
if (flg&VTDLY)
|
if (flg&VTDLY)
|
||||||
c = 0177;
|
c = 0177;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6: /* carriage return */
|
case 6: /* carriage return */
|
||||||
if (flg&OCRNL) {
|
if (flg&OCRNL) {
|
||||||
cs = '\n';
|
cs = '\n';
|
||||||
goto nl;
|
goto nl;
|
||||||
}
|
}
|
||||||
if (flg&ONOCR && *colp == 0)
|
if (flg&ONOCR && *colp == 0)
|
||||||
continue;
|
continue;
|
||||||
cr:
|
cr:
|
||||||
ctype = flg&CRDLY;
|
ctype = flg&CRDLY;
|
||||||
if (ctype == CR1) {
|
if (ctype == CR1) {
|
||||||
if (*colp)
|
if (*colp)
|
||||||
c = max((*colp>>4) + 3, 6);
|
c = max((*colp>>4) + 3, 6);
|
||||||
} else if (ctype == CR2) {
|
} else if (ctype == CR2) {
|
||||||
c = 5;
|
c = 5;
|
||||||
} else if (ctype == CR3) {
|
} else if (ctype == CR3) {
|
||||||
c = 9;
|
c = 9;
|
||||||
}
|
}
|
||||||
*colp = 0;
|
*colp = 0;
|
||||||
break;
|
break;
|
||||||
case 7: /* form feed */
|
case 7: /* form feed */
|
||||||
if (flg&FFDLY)
|
if (flg&FFDLY)
|
||||||
c = 0177;
|
c = 0177;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sysinfo.outch++;
|
sysinfo.outch++;
|
||||||
putc(cs, &tp->t_outq);
|
putc(cs, &tp->t_outq);
|
||||||
if (c) {
|
if (c) {
|
||||||
if ((c < 32) && flg&OFILL) {
|
if ((c < 32) && flg&OFILL) {
|
||||||
if (flg&OFDEL)
|
if (flg&OFDEL)
|
||||||
cs = 0177;
|
cs = 0177;
|
||||||
else
|
else
|
||||||
cs = 0;
|
cs = 0;
|
||||||
putc(cs, &tp->t_outq);
|
putc(cs, &tp->t_outq);
|
||||||
if (c > 3)
|
if (c > 3)
|
||||||
putc(cs, &tp->t_outq);
|
putc(cs, &tp->t_outq);
|
||||||
} else {
|
} else {
|
||||||
putc(DELAYDEL, &tp->t_outq);
|
putc(DELAYDEL, &tp->t_outq);
|
||||||
putc(c|DELAYDEL, &tp->t_outq);
|
putc(c|DELAYDEL, &tp->t_outq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (scf != NULL)
|
if (scf != NULL)
|
||||||
putcf(scf);
|
putcf(scf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get next function from output queue.
|
* Get next function from output queue.
|
||||||
* Called from xmit interrupt complete.
|
* Called from xmit interrupt complete.
|
||||||
*/
|
*/
|
||||||
ttout(tp)
|
ttout(tp)
|
||||||
register struct tty *tp;
|
register struct tty *tp;
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern timeout();
|
extern timeout();
|
||||||
tttimeo(tp)
|
tttimeo(tp)
|
||||||
register struct tty *tp;
|
register struct tty *tp;
|
||||||
{
|
{
|
||||||
|
|
||||||
tp->t_state &= ~TACT; /* timeout waiting on rawq */
|
tp->t_state &= ~TACT; /* timeout waiting on rawq */
|
||||||
if (tp->t_lflag&ICANON)
|
if (tp->t_lflag&ICANON)
|
||||||
return; /* enable canonicalization */
|
return; /* enable canonicalization */
|
||||||
if (tp->t_cc[VTIME] == 0)
|
if (tp->t_cc[VTIME] == 0)
|
||||||
return; /* time out */
|
return; /* time out */
|
||||||
if (( tp->t_rawq.c_cc == 0) && (tp->t_cc[VMIN]))
|
if (( tp->t_rawq.c_cc == 0) && (tp->t_cc[VMIN]))
|
||||||
return;
|
return;
|
||||||
if (tp->t_state&RTO) { /* timeout waiting on rawq */
|
if (tp->t_state&RTO) { /* timeout waiting on rawq */
|
||||||
tp->t_delct = 1;
|
tp->t_delct = 1;
|
||||||
if (tp->t_state&IASLP) {/* wakeup when input done */
|
if (tp->t_state&IASLP) {/* wakeup when input done */
|
||||||
tp->t_state &= ~IASLP;
|
tp->t_state &= ~IASLP;
|
||||||
wakeup(tp);
|
wakeup(tp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tp->t_state |= RTO|TACT;
|
tp->t_state |= RTO|TACT;
|
||||||
timeout(tttimeo, tp, tp->t_cc[VTIME]*(HZ/10));
|
timeout(tttimeo, tp, tp->t_cc[VTIME]*(HZ/10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ttioctl(tp, cmd, arg)
|
ttioctl(tp, cmd, arg)
|
||||||
register struct tty *tp;
|
register struct tty *tp;
|
||||||
int cmd;
|
int cmd;
|
||||||
long arg;
|
long arg;
|
||||||
{
|
{
|
||||||
ushort chg;
|
ushort chg;
|
||||||
|
|
||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
case LDCHG:
|
case LDCHG:
|
||||||
chg = tp->t_lflag^arg;
|
chg = tp->t_lflag^arg;
|
||||||
if (!(chg&ICANON))
|
if (!(chg&ICANON))
|
||||||
break;
|
break;
|
||||||
dvi();
|
dvi();
|
||||||
if (tp->t_canq.c_cc) {
|
if (tp->t_canq.c_cc) {
|
||||||
if (tp->t_rawq.c_cc) {
|
if (tp->t_rawq.c_cc) {
|
||||||
tp->t_canq.c_cc += tp->t_rawq.c_cc;
|
tp->t_canq.c_cc += tp->t_rawq.c_cc;
|
||||||
tp->t_canq.c_cl->c_next = tp->t_rawq.c_cf;
|
tp->t_canq.c_cl->c_next = tp->t_rawq.c_cf;
|
||||||
tp->t_canq.c_cl = tp->t_rawq.c_cl;
|
tp->t_canq.c_cl = tp->t_rawq.c_cl;
|
||||||
}
|
}
|
||||||
tp->t_rawq = tp->t_canq;
|
tp->t_rawq = tp->t_canq;
|
||||||
tp->t_canq = ttnulq;
|
tp->t_canq = ttnulq;
|
||||||
}
|
}
|
||||||
tp->t_delct = tp->t_rawq.c_cc;
|
tp->t_delct = tp->t_rawq.c_cc;
|
||||||
evi();
|
evi();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue