Ttyiin() accepts characters from the device and places them in the input
buffer. It would be a fairly simple routine, except for the fact that it
has a bunch of logic in it related to keyboard input processing.
Ttyiin() can operate in one of three modes - as determined by a flag
in the tty control block. The modes are:
Raw - received characters are placed in the input buffer (for
the upper half routines to collect) as they are typed. No input processing
is done.
Cbreak - received characters are put in the input buffer one
at a time, with special attention paid to certain characters. As examples
if [ctrl-Q] is pressed, it will stop tty output,
if [ctrl-S] is pressed, it will start tty output,
if [RETURN] is pressed, it will map it to a NEWLINE,
if the input buffer is full, it will beep a bell (in raw mode, the
character would have been thrown away with no notification),
if the echo flag is set, the character will be echoed back out the
transmitter
Cooked - all the processing of Cbreak mode is done, except that
lines are only delivered to the upper half routines when [return]
is pressed (not as they are typed as above), and some special line-editing
characters are paid attention to. Examples include:
the line kill character will erase to the beginning of the line,
the backspace character will erase the most recently typed character
from the buffer.