CANON(K) UNIX System V CANON(K)
Name
canon - processes raw input data from tty device
Syntax
#include "sys/types.h"
#include "sys/tty.h"
int
canon(tp)
struct tty *tp;
Description
canon is called by ttread(K) to process characters received
from a tty device, indicated by the tp argument. The canon
routine conveys characters from the raw input queue, the
t_rawq field, to the processed character queue, the t_canq
field. The canon routine receives characters until a
delimiter is encountered in the input data. (All t_ fields
shown on this manual page are members of the tty structure
described in sys/tty.h.)
When the delimiter is found, then the accumulated characters
are processed and sent to the calling program. The t_delct
delimiter count field indicates that a delimiter character
has been received. Until a delimiter is received, canon can
call sleep(K) to wait for characters to be placed in the raw
queue. The priority argument to sleep is TTIPRI.
canon processes characters as long as there is a carrier and
as long as FNDELAY (no-delay mode) is not set.
The canon routine must not be called from a driver's
initialization or interrupt routines.
The canon routine has two character processing modes. The
first mode is called the canonical processing mode.
Canonical processing means resolving special characters such
as backspace or delete before the received data is given to
the calling program. The termio(M) manual page describes
guidelines that are used when canonical processing takes
place. Refer to the description of the c_cc array on the
termio manual page for information about which characters
are resolved by canonical processing. Canonical processing
mode is enabled by setting he s-1ICANON flag in the t_lflag
field. In canonical processing mode, international
characters are translated, as are these termio constants:
VERASE, VKILL, VEOF, VEOL, VEOL2, and XCASE.
The second mode passes characters to a calling program after
a time requirement has been satisfied or after a minimum
number of characters have been received. This mode requires
that ICANON not be set and that the t_cc[VMIN] field be set
to zero. This mode interacts with the VMIN and VTIME
constants which are described on the termio manual page.
After the time and minimum character requirements are
satisfied, characters are conveyed from t_rawq to t_canq.
tttimeo(K) is called in this mode to resolve VTIME.
If during the course of either processing modes, as long as
characters remain to be processed, if t_state is set to
TBLOCK, then the canon routine calls the driver's xxproc
routine with the T_UNBLOCK argument.
Notes
The canon routine must not be called from a driver's
initialization or interrupt routines.
Parameters
tp a pointer to the struct tty data structure
associated with the device being accessed.
See Also
termio(M), ttiocom(K), tty(K)
(printed 7/6/89)