V8/usr/man/man4/ttyld.4
.TH TTYLD 4
.SH NAME
ttyld \- terminal processing
.SH SYNOPSIS
.B #include <sgtty.h>
.SH DESCRIPTION
This processing module is usually inserted into a
.IR stream (4)
connected to a terminal device.
It gathers input into lines, performs erase and kill processing,
and translates control sequences.
.PP
Certain special characters have particular meaning on input.
These characters are not passed to a program
except in raw mode, where they lose their special character.
It is possible to change these characters from the default.
.TP
.B #
erases the last-typed character.
It will not erase beyond the beginning of a line or an EOT.
.TP
.B @
erases the entire preceding part of the line, but not beyond an EOT.
.TP
EOT
(Control-D) may be used to generate an end of file
from a terminal.
When an EOT is received, all the characters
waiting to be read are immediately passed to
the program, without waiting for a new-line,
and the EOT is discarded.
Thus if there are no characters waiting, which
is to say the EOT occurred at the beginning of a line,
zero characters will be passed back, and this is
the standard end-of-file indication.
.TP
.B \e
escapes a following erase, kill, or EOT character
and allows it to be treated as ordinary data.
.TP
DEL
is not passed to a program but generates
the
.I interrupt
signal (2).
The signal is sent to any processes in the process group of the stream;
see
.IR stream (4).
.TP
FS
generates the
.I quit
signal (3).
.TP
DC3
delays all printing on the terminal
until something is typed in.
.TP
DC1
restarts printing after DC3 without generating
any input to a program.
.PP
Several
.IR ioctl (2)
calls apply to terminals.
Most of them use the following structure,
defined in
<sgtty.h>:
.IP
.nf
struct sgttyb {
char sg_ispeed;
char sg_ospeed;
char sg_erase;
char sg_kill;
int sg_flags;
};
.fi
.PP
The
.I sg_ispeed
and
.I sg_ospeed
fields describe the input and output speeds of the
device according to the following table.
They are not interpreted by the tty line discipline, but merely passed
on to the device.
Devices ignore impossible speed changes.
Symbolic values in the table are as defined in
.IR <sgtty.h> .
.PP
.nf
.ta \w'B9600 'u +5n
B0 0 (hang up device)
B50 1 50 baud
B75 2 75 baud
B110 3 110 baud
B134 4 134.5 baud
B150 5 150 baud
B200 6 200 baud
B300 7 300 baud
B600 8 600 baud
B1200 9 1200 baud
B1800 10 1800 baud
B2400 11 2400 baud
B4800 12 4800 baud
B9600 13 9600 baud
EXTA 14 External A
EXTB 15 External B
.fi
.DT
.PP
The
.I sg_erase
and
.I sg_kill
fields of the argument structure
specify the erase and kill characters respectively.
(Defaults are # and @.)
.PP
The
.I sg_flags
field of the argument structure
contains several bits that determine the
system's treatment of the terminal:
.PP
.ta \w'ALLDELAY 'u +\w'0100000 'u
.nf
ALLDELAY 0177400 Delay algorithm selection
VTDELAY 0040000 Select form-feed and vertical-tab delays:
FF0 0
FF1 0100000
CRDELAY 0030000 Select carriage-return delays:
CR0 0
CR1 0010000
CR2 0020000
CR3 0030000
TBDELAY 0006000 Select tab delays:
TAB0 0
TAB1 0001000
TAB2 0004000
XTABS 0006000
NLDELAY 0001400 Select new-line delays:
NL0 0
NL1 0000400
NL2 0001000
NL3 0001400
EVENP 0000200 Even parity allowed on input (most terminals)
ODDP 0000100 Odd parity allowed on input
RAW 0000040 Raw mode: wake up on all characters, 8-bit interface
CRMOD 0000020 Map CR into LF; echo LF or CR as CR-LF
ECHO 0000010 Echo (full duplex)
LCASE 0000004 Map upper case to lower on input
CBREAK 0000002 Return each character as soon as typed
TANDEM 0000001 Automatic flow control
.DT
.fi
.PP
The delay bits specify how long
transmission stops to allow for mechanical or other movement
when certain characters are sent to the terminal.
In all cases a value of 0 indicates no delay.
.PP
If a form-feed/vertical tab delay is specified,
it lasts for about 2 seconds.
.PP
Carriage-return delay type 1 lasts about .08 seconds.
Delay type 2 lasts about .16 seconds.
Delay type 3 is supposed to be for the Concept 100.
.PP
New-line delay type 1 is supposed to be for the Teletype model 37.
Type 2 is about .10 seconds.
Type 3 is unimplemented and is 0.
.PP
Tab delay type 1 is supposed to be for the Teletype model 37.
Type 3, called XTABS,
is not a delay at all but causes tabs to be replaced
by the appropriate number of spaces on output.
.PP
In raw mode, every character is passed immediately
to the program without waiting until a full line has been typed.
No erase or kill processing is done;
the end-of-file indicator (EOT), the interrupt character
(DEL) and the quit character (FS) are not treated specially.
There are no delays and no echoing, and no replacement of
one character for another;
characters are a full 8 bits for both input and output.
.PP
Mode 020 causes input carriage returns to be turned into
new-lines;
input of either CR or LF causes LF-CR both to
be echoed
(for terminals without a new-line function).
.PP
CBREAK is a sort of half-cooked mode.
Programs read each character as soon as typed, instead
of waiting for a full line,
but quit and interrupt work, and output delays
CRMOD, XTABS, ECHO, and parity work normally.
On the other hand there is no erase or kill,
and no special treatment of \e or EOT.
.PP
TANDEM mode causes the system to produce
a stop character (default DC3) whenever the input
queue is in danger of overflowing, and a start character
(default DC1)
when the input queue has drained sufficiently.
It is useful for flow control when the `terminal'
is actually another machine that obeys the conventions.
.PP
Several
.I ioctl
calls have the form:
.IP
.nf
#include <sgtty.h>
.sp
ioctl(fildes, code, arg)
struct sgttyb *arg;
.fi
.PP
The applicable codes are:
.TP
TIOCGETP
Fetch the parameters associated with the terminal, and store
in the pointed-to structure.
.TP
TIOCSETP, TIOCSETN
Set the parameters according to the pointed-to structure.
These (equivalent) codes are synchronous with output data.
.PP
The following codes affect characters that are special
to the terminal interface.
The argument is a pointer to the following structure,
defined in
<sgtty.h>:
.IP
.nf
.ta \w'struct 'u +\w'tchars {'u +\w't_startc; 'u
struct tchars {
char t_intrc /* interrupt */
char t_quitc; /* quit */
char t_startc; /* start output */
char t_stopc; /* stop output */
char t_eofc; /* end-of-file */
char t_brkc; /* input delimiter (like nl) */
};
.fi
.PP
The default values for these characters are
DEL, FS, DC1, DC3, EOT, and \-1.
A character value of \-1
eliminates the effect of that character.
The
.I t_brkc
character, by default \-1,
acts like a new-line in that it terminates a `line,'
is echoed, and is passed to the program.
The `stop' and `start' characters may be the same,
to produce a toggle effect.
It is counterproductive to make
other special characters (including erase and kill)
identical.
.TP
TIOCSETC
Change the various special characters to those given in the structure.
.TP
TIOCGETC
Fill in the structure with the current special characters.
.SH SEE ALSO
getty(8), stty(1), signal(2), ioctl(2), stream(4)