* Copyright 1973 Bell Telephone Laboratories Inc
* general TTY subroutines
000,000,000,000,004,000,000,000,
000,000,000,000,000,000,000,000,
000,000,000,000,000,000,000,000,
000,000,000,000,000,000,000,000,
000,'|',000,'#',000,000,000,'`',
'{','}',000,000,000,000,000,000,
000,000,000,000,000,000,000,000,
000,000,000,000,000,000,000,000,
'@',000,000,000,000,000,000,000,
000,000,000,000,000,000,000,000,
000,000,000,000,000,000,000,000,
000,000,000,000,000,000,'~',000,
000,'A','B','C','D','E','F','G',
'H','I','J','K','L','M','N','O',
'P','Q','R','S','T','U','V','W',
'X','Y','Z',000,000,000,000,000,
struct cblock cfree
[NCLIST
];
struct cblock
*cfreelist
;
u
.u_arg
[1] = fuword(++up
);
u
.u_arg
[2] = fuword(++up
);
register struct file
*fp
;
register struct inode
*ip
;
if ((fp
= getf(u
.u_ar0
[R0
])) == NULL
)
if ((ip
->i_mode
&IFMT
) != IFCHR
) {
(*cdevsw
[ip
->i_addr
[0].d_major
].d_sgtty
)(ip
->i_addr
[0], v
);
sleep(&tp
->t_outq
, TTOPRI
);
register struct cblock
*cp
;
register struct cdevsw
*cdp
;
for (cp
=(ccp
+07)&~07; cp
<= &cfree
[NCLIST
-1]; cp
++) {
for(cdp
= cdevsw
; cdp
->d_open
; cdp
++)
while (getc(&tp
->t_canq
) >= 0);
while (getc(&tp
->t_outq
) >= 0);
while (getc(&tp
->t_rawq
) >= 0);
* transfer raw list to canonical list,
if ((tp
->t_state
&CARR_ON
)==0)
sleep(&tp
->t_rawq
, TTIPRI
);
while ((c
=getc(&tp
->t_rawq
)) >= 0) {
if ((tp
->t_flags
&RAW
)==0) {
if (maptab
[c
] && (maptab
[c
]==c
|| (tp
->t_flags
&LCASE
))) {
* place a character on raw TTY input queue, putting in delimiters
* and waking up top half as needed.
if ((c
=& 0177) == '\r' && t_flags
&CRMOD
)
if ((t_flags
&RAW
)==0 && (c
==CQUIT
|| c
==CINTR
)) {
signal(tp
, c
==CINTR
? SIGINT
:SIGQIT
);
if (tp
->t_rawq
.c_cc
>=TTYHOG
) {
if (t_flags
&LCASE
&& c
>='A' && c
<='Z')
if (t_flags
&RAW
|| c
=='\n' || c
==004) {
if (putc(0377, &tp
->t_rawq
)==0)
* put character on TTY output queue, adding delays,
* expanding tabs, and handling the CR/NL bit.
register struct tty
*rtp
;
if (c
==004 && (rtp
->t_flags
&RAW
)==0)
if (c
=='\t' && rtp
->t_flags
&XTABS
) {
if (rtp
->t_flags
&LCASE
) {
if (c
=='\n' && rtp
->t_flags
&CRMOD
)
if (putc(c
, &rtp
->t_outq
))
c
= max((*colp
>>4) + 3, 6);
if ((rtp
->t_flags
&NTDELAY
)==0)
if (c
&& (rtp
->t_flags
&NODELAY
)==0)
putc(c
|0200, &rtp
->t_outq
);
struct { int (*func
)(); };
if (tp
->t_state
&SSTART
) {
if ((addr
->tttcsr
&DONE
)==0 || tp
->t_state
&TIMEOUT
)
if ((c
=getc(&tp
->t_outq
)) >= 0) {
addr
->tttbuf
= c
| (partab
[c
]&0200);
timeout(ttrstrt
, tp
, c
&0177);
if (tp
->t_canq
.c_cc
|| canon(tp
))
while (tp
->t_canq
.c_cc
&& passc(getc(&tp
->t_canq
))>=0);
while (tp
->t_outq
.c_cc
> TTHIWAT
) {
sleep(&tp
->t_outq
, TTOPRI
);