termio.h File

Purpose

Defines the structure of the termio file, which provides the terminal interface for Version 2 compatibility.

Description

The /usr/include/sys/termio.h file contains the termio structure, which defines special characters as well as the basic input, output, control, and line discipline modes. The termio.h file is provided for compatibility with Version 2 applications.

Version 2 applications that include the termio.h file can use the Version 2 terminal interface provided by the POSIX line discipline. The following Version 2 terminal interface operations are not supported by the POSIX line discipline:

The termio structure in the termio.h file contains the following fields:

Field Descriptions

c_iflag
Describes the basic terminal input control. The initial input-control value is all bits clear. The possible input modes are:
IGNBRK
Ignores the break condition. In the context of asynchronous serial data transmission, a break condition is defined as a sequence of zero-valued bits that continues for more than the time required to send 1 byte. The entire sequence of zero-valued bits is interpreted as a single break condition, even if it continues for an amount of time equivalent to more than one byte. If the IGNBRK flag is set, a break condition detected on input is ignored, which means that the break condition is not put on the input queue and therefore not read by any process.
BRKINT
Interrupts the signal on the break condition. If the IGNBRK flag is not set and the BRKINT flag is set, the break condition flushes the input and output queues. If the terminal is the controlling terminal of a foreground process group, the break condition generates a single SIGINT signal to that foreground process group. If neither the IGNBRK nor the BRKINT flag is set, a break condition is read as a single \0. If the PARMRK flag is set, a break condition is read as \377, \0, \0.
IGNPAR
Ignores characters with parity errors. If this flag is set, a byte with a framing or parity error (other than break) is ignored.
PARMRK
Marks parity errors. If the PARMRK flag is set and the IGNPAR flag is not set, a byte with a framing or parity error (other than break) is given to the application as the three-character sequence \377, \0, x, where \377, \0 is a two-character flag preceding each sequence and x is the data of the character received in error. To avoid ambiguity in this case, if the ISTRIP flag is not set, a valid character of \377 is given to the application as \377, \377. If neither the IGNPAR nor the PARMRK flag is set, a framing or parity error (other than break) is given to the application as a single character, \0.
INPCK
Enables input parity checking. If this flag is set, input parity checking is enabled. If not set, input parity checking is disabled. This allows for output parity generation without input parity errors.
ISTRIP
Strips characters. If this flag is set, valid input characters are first stripped to 7 bits; otherwise, all 8 bits are processed.
INLCR
Maps a new-line character (NL) to a carriage return (CR) on input. If this flag is set, a received NL character is translated into a CR character.
IGNCR
Ignores a CR character. If this flag is set, a received CR character is ignored and not read.
ICRNL
Maps a CR character to an NL character on input. If the ICRNL flag is set and the IGNCR flag is not set, a received CR character is translated into an NL character.
IUCLC
Maps uppercase to lowercase on input. If this flag is set, a received uppercase, alphabetic character is translated into the corresponding lowercase character.
IXON
Enables start and stop output control. If this flag is set, a received STOP character suspends output and a received START character restarts output. When the IXON flag is set, START and STOP characters are not read, but merely perform flow-control functions. When the IXON flag is not set, the START and STOP characters are read.
IXANY
Enables any character to restart output. If this flag is set, any input character restarts output that was suspended.
IXOFF
Enables start-and-stop input control. If this flag is set, the system transmits a STOP character when the input queue is nearly full and a START character when enough input has been read that the queue is nearly empty again.
c_oflag
Specifies how the system treats output. The initial output-control value is "all bits clear". The possible output modes are:
OPOST
Post processes output. If this flag is set, output characters are post-processed as indicated by the remaining flags; otherwise, characters are transmitted without change.
OLCUC
Maps lowercase to uppercase on output. If this flag is set, a lowercase alphabetic character is transmitted as the corresponding uppercase character. This function is often used in conjunction with the IUCLC input mode.
ONLCR
Maps NL to CR-NL on output. If this flag is set, the NL character is transmitted as the CR-NL character pair.
OCRNL
Maps CR to NL on output. If this flag is set, the CR character is transmitted as the NL character.
ONOCR
Indicates no CR output at column 0 (first position). If this flag is set, no CR character is transmitted when at column 0 (first position).
ONLRET
NL performs the CR function. If this flag is set, the NL character is assumed to do the carriage-return function. The column pointer is set to 0, and the delay specified for carriage return is used. If neither the ONLCR, OCRNL, ONOCR, nor ONLRET flag is set, the NL character is assumed to do the line-feed function only. The column pointer remains unchanged. The column pointer is also set to 0 if the CR character is actually transmitted.

The delay bits specify how long a transmission stops to allow for mechanical or other movement when certain characters are sent to the terminal. The actual delays depend on line speed and system load.

OFILL
Uses fill characters for delay. If this flag is set, fill characters are transmitted for a delay instead of a timed delay. This is useful for high baud rate terminals that need only a minimal delay.
OFDEL
If this flag is set, the fill character is DEL. If this flag is not set, the fill character is NULL.
NLDLY
Selects the new-line character delays. This is the mask to use before comparing to NL0 and NL1:
NL0
Specifies no delay.
NL1
Specifies one delay of approximately 0.10 seconds. If the ONLRET flag is set, the carriage-return delays are used instead of the new-line delays. If the OFILL flag is set, two fill characters are transmitted.
CRDLY
Selects the carriage-return delays. This is the mask to use before comparing to CR0, CR1, CR2, and CR3:
CR0
Specifies no delay.
CR1
Specifies that the delay is dependent on the current column position. If the OFILL flag is set, two fill characters are transmitted.
CR2
Specifies a delay of approximately 0.10 seconds. If the OFILL flag is set, this delay transmits four fill characters.
CR3
Specifies one delay of approximately 0.15 seconds.
TABDLY
Selects the horizontal-tab delays. This is the mask to use before comparing to TAB0, TAB1, TAB2, and TAB3. If the OFILL flag is set, any of these delays (except TAB3) transmit two fill characters:
TAB0
Specifies no delay.
TAB1
Specifies that the delay is dependent on the current column position. If the OFILL flag is set, two fill characters are transmitted.
TAB2
Specifies a delay of approximately 0.10 seconds.
TAB3
Specifies that tabs are to be expanded into spaces.
BSDLY
Selects the backspace delays. This is the mask to use before comparing to BS0 and BS1:
BS0
Specifies no delay.
BS1
Specifies a delay of approximately 0.05 seconds. If the OFILL flag is set, this delay transmits one fill character.
VTDLY
Selects the vertical-tab delays. This is the mask to use before comparing to VT0 and VT1:
VT0
Specifies no delay.
VT1
Specifies one delay of approximately 2 seconds.
FFDLY
Selects the form-feed delays. This is a mask to use before comparing to FF0 and FF1:
FF0
Specifies no delay.
FF1
Specifies a delay of approximately 2 seconds.
c_cflag
Describes the hardware control of the terminal. In addition to the basic control modes, this field uses the following control characters:
CBAUD
Specifies baud rate. These bits specify the baud rate for a connection. For any particular hardware, impossible speed changes are ignored.
B0
Specifies a zero baud rate which is used to hang up the connection. If B0 is specified, the `data terminal ready' signal is not asserted. As a result, the line is usually disconnected. This delay transmits two fill characters. Normally, this disconnects the line.
B50
Specifies 50 baud.
B75
Specifies 75 baud.
B110
Specifies 110 baud.
B134
Specifies 134.5 baud.
B150
Specifies 150 baud.
B200
Specifies 200 baud.
B300
Specifies 300 baud.
B600
Specifies 600 baud.
B1200
Specifies 1200 baud.
B1800
Specifies 1800 baud.
B2400
Specifies 2400 baud.
B4800
Specifies 4800 baud.
B9600
Specifies 9600 baud.
B19200
Specifies 19,200 baud.
B38400
Specifies 38,400 baud.
EXTA
Specifies External A.
EXTB
Specifies External B.
CSIZE
Specifies the character size. These bits specify the character size, in bits, for both transmit and receive operations. The character size does not include the parity bit, if one is used:
CS5
5 bits
CS6
6 bits
CS7
7 bits
CS8
8 bits
CSTOPB
Specifies the number of stop bits. If this flag is set, 2 stop bits are sent; otherwise, only 1 stop bit is sent.
CREAD
Enables the receiver. If this flag is set, the receiver is enabled. Otherwise, characters are not received.
PARENB
Enables parity. If this flag is set, parity generation and detection is enabled and a parity bit is added to each character.
PARODD
Specifies odd parity. If parity is enabled, the PARODD flag specifies odd parity if set. If parity is enabled and the PARODD flag is not set, even parity is used.
HUPCL
Hangs up on last close. If this flag is set, the line is disconnected when the last process closes the line or when the process terminates (when the `data terminal ready' signal drops).
CLOCAL
Specifies a local line. If this flag is set, the line is assumed to have a local, direct connection with no modem control. If not set, modem control (dial-up) is assumed.
c_lflag
Controls various terminal functions. The initial value after an open is "all bits clear." This field uses the following mask name symbols:
ISIG
Enables signals. If this flag is set, each input character is checked against the INTR and QUIT special control characters. If an input character matches one of these control characters, the function associated with that character is performed. If the ISIG function is not set, checking is not done.
ICANON
Enables canonical input. If this flag is set, it turns on canonical processing, which enables the erase and kill edit functions as well as the assembly of input characters into lines delimited by NL, EOF, and EOL characters. If the ICANON flag is not set, read requests are satisfied directly from the input queue. In this case, a read request is not satisfied until one of the following conditions is met:
  • The minimum number of characters specified by the MIN value are received.
  • The time-out value specified by the TIME value has expired since the last character was received.

As a result bursts of input can be read, while still allowing single-character input. The MIN and TIME values are stored in the positions for the EOF and EOL characters, respectively. The character values of MIN and TIME are converted to their ascii equivalents to get the numeric value. The time value represents tenths of seconds.

XCASE
Enables canonical uppercase and lowercase presentation. If this flag is set along with the ICANON flag, an uppercase letter (or the uppercase letter translated to lowercase by the IUCLC input mode) is accepted on input by preceding it with a \ (backslash) character. The output is then also preceded by a backslash character. In this mode, the output generates and the input accepts the following escape sequences:
For: Use:
` (grave) \ `
| \ !
~ \ ^
{ \ (
} \ )
\ \ \

For example, A is input as \a, \n as \\n, and \N as \\\n.

NOFLSH
Disables queue flushing. If this flag is set, the normal flushing of the input and output queues associated with the INTR and QUIT characters is not done.
ECHO
Enables echo. If this flag is set, characters are echoed as they are received.

When the ICANON flag is set, the following echo functions are possible:

ECHOE
Echoes the erase character as Backspace-Space-Backspace. If the ECHO and ECHOE flags are both set, the ERASE character is echoed as one or more ASCII Backspace-Space-Backspace sequences, which clears the last characters from the screen.
ECHOK
Echoes the NL character after kill. If the ECHOK flag is set, the NL character is echoed after the kill character is received. This emphasizes that the line is deleted.
ECHONL
Echoes the NL character. If the ECHONL flag is set, the NL character is echoed even if the ECHO flag is not set. This is useful for terminals that are set to "local echo" (also referred to as "half-duplex").
c_cc
Specifies an array that defines the special control characters. The relative positions and initial values for each function are:
VINTR
Indexes the INTR special character (Ctrl-c), which is recognized on input if the ISIG flag is set. The INTR character generates a SIGINT signal, which is sent to all processes in the foreground process group for which the terminal is the controlling terminal. If the ISIG flag is set, the INTR character is discarded when processed.
VQUIT
Indexes the QUIT special character (Ctrl-\), which is recognized on input if the ISIG flag is set. The QUIT character generates a SIGQUIT signal, which is sent to all processes in the foreground process group for which the terminal is the controlling terminal, and writes a core image file into the current working directory. If the ISIG flag is set, the QUIT character is discarded when processed.
VERASE
Indexes the ERASE special character (Backspace), which is recognized on input if the ICANON flag is set. The ERASE character does not erase beyond the beginning of the line as delimited by a NL, EOL, EOF, or EOL2 character. If the ICANON flag is set, the ERASE character is discarded when processed.
VKILL
Indexes the KILL special character (Ctrl-u), which is recognized on input if the ICANON flag is set. The KILL character deletes the entire line, as delimited by an NL, EOL, EOF, or EOL2 character. If the ICANON flag is set, the KILL character is discarded when processed.
VEOF
Indexes the EOF special character (Ctrl-d), which is recognized on input if the ICANON flag is set. When EOF is received, all the characters waiting to be read are immediately passed to the process, without waiting for a new line, and the EOF is discarded. If the EOF is received at the beginning of a line (no characters are waiting), a character count of zero is returned from the read, indicating an end-of-file. If the ICANON flag is set, the EOF character is discarded when processed.
VEOL
Indexes the EOL special character (Ctrl-@ or ASCII NULL), which is recognized on input if the ICANON flag is set. EOL is an additional line delimiter, like NL, and is not normally used.
VEOL2
Indexes the EOL2 special character (Ctrl-@ or ASCII NULL), which is recognized on input if the ICANON flag is set. EOL2 is another additional line delimiter, like NL, and is not normally used.
VMIN
Indexes the MIN value, which is not a special character. The use of the MIN value is described in the discussion of non-canonical mode input processing in "POSIX (termios.h File) Line Discipline" in AIX® Version 7.1 General Programming Concepts: Writing and Debugging Programs.
VTIME
Indexes the TIME value, which is not a special character. The use of the TIME value is described in the discussion of non-canonical mode input processing in "POSIX (termios.h File) Line Discipline" in AIX Version 7.1 General Programming Concepts: Writing and Debugging Programs.
The character values for the following control characters can be changed:
  • INTR
  • ERASE
  • EOF
  • EOL2
  • QUIT
  • KILL
  • EOL

The ERASE, KILL, and EOF characters can also be escaped (preceded with a backslash) so that no special processing is done.

The primary ioctl subroutines have the form:

ioctl (FileDescriptor, Command, Structure)
struct termio *Structure;

The operations using this form are:

TCGETA
Gets the parameters associated with the terminal and stores them in the termio structure referenced by the Structure parameter.
TCSETA
Sets the parameters associated with the terminal from the structure referenced by the Structure parameter. The change is immediate.
TCSETAF
Waits for the output to drain, and then flushes the input queue and sets the new parameters.
TCSETAW
Waits for the output to drain before setting the new parameters. This form should be used when changing parameters that will affect output.

Other ioctl subroutines have the form:

ioctl (FileDescriptor, Command, Value)
int Value;
The operations using this form are:
Note: If the user writes an application that performs a TCSBRK operation followed by a TCFLSH operation prior to closing a port, the last data left in the concentrator box on the 64-port adapter is lost. However, no problem occurs if an SIO, 8-port, or 16-port adapter is used.
TCSBRK
Waits for the output to drain. If the Value parameter has a value of 0, it sends a break of 0.25 seconds. A nonzero value causes a break condition of that many milliseconds.
TCSBREAK
Waits for the output to drain. If the Value parameter has a value of 0, it sends a break of .25 seconds. A nonzero value causes a break condition of that many milliseconds.
TCXONC
Starts and stops control. If the Value parameter has a value of 0, it suspends output. If the Value parameter has a value of 1, it restarts suspended output. If the Value parameter has a value of 2, it blocks input. If the Value parameter has a value of 3, it unblocks input.
TCFLSH
If the Value parameter has a value of 0, it flushes the input queue. If the Value parameter has a value of 1, it flushes the output queue. If the Value parameter has a value of 2, it flushes both the input and output queues.

Another form for ioctl subroutines is:

ioctl (FileDescriptor, Command, Structure)
struct csmap* Structure;
TCSCSMAP
Sets the code set map from the structure referenced by the structure parameter and rejects any invalid map (any map with 0 length/width or a length greater than MB_LEN_MAX). The /usr/include/sys/tty.h file contains the structure used for TCSCSMAP and TCGCSMAP operations.
TCGCSMAP
Returns a copy of the current code set map in the structure referenced by the structure parameter. The /usr/include/sys/tty.h file contains the structure used for TCSCSMAP and TCGCSMAP operations.

The following ioctl operations are used for trusted communications path operations:

TCSAK
Points to an integer that enables the Secure Attention Key (SAK) sequence (Ctrl-X, Ctrl-R) to provide a clean terminal to which only trusted processes can read or write. When SAK is enabled and the user types this sequence, all processes that are currently running are ended. The TCSAKON operation turns the SAK sequence on; the TCSAKOFF operation turns the SAK sequence off.
TCQSAK
Queries the state (TCSAKON or TCSAKOFF) of the SAK sequence.
TCTRUST
Sets a bit by which another process can query, (with the TCQTRUST operation), the state of the terminal, (TCTRUSTED or TCUNTRUSTED).
TCQTRUST
Queries the state of the terminal (TCTRUSTED or TCUNTRUSTED).