[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4 Files Reference

termios.h File

Purpose

Defines the structure of the termios file, which provides the terminal interface for POSIX compatibility.

Description

The /usr/include/termios.h file contains information used by subroutines that apply to terminal files. The definitions, values, and structures in this file are required for compatibility with the POSIX standard. The termios.h file also supports ioctl modem-control operations.

The general terminal interface information is contained in the termio.h file. The termio structure in the termio.h file defines the basic input, output, control, and line discipline modes. If a calling program is identified as requiring POSIX compatibility, the termios structure and additional POSIX control-packet information in the termios.h file is implemented. Window and terminal size operations use the winsize structure, which is defined in the ioctl.h file. The termios structure in the termios.h file contains the following fields:

The termios.h file also defines the values for the following parameters of the tcsetattr subroutine:

The termios.h file also supports ioctl modem-control operations.

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 one 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 it is not put on the input queue and therefore not read by any process.
BRKINT Signal interrupt 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 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, or if the PARMRK flag is set, 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 CR character. If this flag is set, a received CR character is ignored and not read.
ICRNL Maps a CR character to the NL character on input. If the ICRNL flag is set and the IGNCR flag is not set, a received CR character is translated into a 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.
IMAXBEL Echoes the ASCII BEL character if the input stream overflows. Further input is not stored, but input already present in the input stream is not lost. If this flag is not set, no BEL character is echoed; the input in the input queue is discarded if the input stream overflows. This function also requires the IEXTEN bit to be set.
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 flag 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. If this flag is set, no CR character is transmitted when at column 0 (first position).
ONLRET NL performs 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 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 a 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, this delay transmits two fill characters.
CR2 Specifies a delay of approximately 0.10 seconds. If the OFILL flag is set, this delay transmits four fill characters.
CR3 Specifies a 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 a delay of approximately 2 seconds.
FFDLY Selects the form-feed delays. This is the 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.
B50 50 baud.
B75 75 baud.
B110 110 baud.
B134 134.5 baud.
B150 150 baud.
B200 200 baud.
B300 300 baud.
B600 600 baud.
B1200 1200 baud.
B1800 1800 baud.
B2400 2400 baud.
B4800 4800 baud.
B9600 9600 baud.
B19200 19200 baud.
B38400 38400 baud.
EXTA External A.
EXTB 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 number of stop bits. If this flag is set, 2 stop bits are sent; otherwise, only 1 stop bit is sent.
CREAD Enables 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.
CIBAUD Specifies the input baud rate if different from the output rate.
PAREXT Specifies extended parity for mark and space parity.
c_lflag Controls various terminal functions. The initial value after an open is "all bits clear." In addition to the basic modes, this field uses the following mask name symbols:
ISIG Enables signals. If this flag is set, each input character is checked against the INTR, QUIT, SUSP, and DSUSP special control characters. If an input character matches one of these control characters, the function associated with that character is performed. If the ISIG flag 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 MIN are received.
  • The time-out value specified by TIME has expired since the last character was received. This allows bursts of input to 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, QUIT, and SUSP characters is not done.
FLUSHO Flushes the output. When this bit is set by typing the FLUSH character, data written to the terminal is discarded. A terminal can cancel the effect of typing the FLUSH character by clearing this bit.
PENDIN Reprints pending input. If this flag is set, any input that is pending after a switch from raw to canonical mode is re-input the next time a read operation becomes pending or the next time input arrives. The PENDIN flag is an internal-state bit.
IEXTEN Enables extended (implementation-defined) functions to be recognized from the input data. If this flag is not set, implementation-defined functions are not recognized, and the corresponding input characters are processed as described for the ICANON, ISIG, IXON, and IXOFF flags. Recognition of the following special control characters requires the IEXTEN flag to be set:
  • VEOL2
  • VDSUSP
  • VREPRINT
  • VDISCRD
  • VWERSE
  • VLNEXT

The functions associated with the following bits also require the IEXTEN flag to be set:

  • IMAXBEL
  • ECHOKE
  • ECHOPRT
  • ECHOCTL
TOSTOP Sends a SIGTTOU signal when a process in a background process group tries to write to its controlling terminal. The SIGTTOU signal stops the members of the process group.
ECHO Enables echo. If this flag is set, characters are echoed as they are received.

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

ECHOE Echoes the erase character as Backspace-Space-Backspace. If the ECHO and ECHOE flags are both set and the ECHOPRT flag is not set, the ERASE and WERASE characters are echoed as one or more ASCII Backspace-Space-Backspace sequences, which clears the last characters from the screen.
ECHOPRT If the ECHO and ECHOPRT flags are both set, the first ERASE and WERASE character in a sequence are echoed as a \ (backslash), followed by the characters being erased. Subsequent ERASE and WERASE characters echo the characters being erased, in reverse order. The next non-erase character causes a / (slash) to be typed before the nonerase character is echoed. This function also requires the IEXTEN bit to be set.
ECHOKE Backspace-Space-Backspace entire line on line kill. If this flag is set, the kill character is echoed by erasing the entire line from the screen (using the mechanism selected by the ECHOE and ECHOPRT flags). This function also requires the IEXTEN flag to be set.
ECHOK Echoes the NL character after kill. If the ECHOK flag is set and the ECHOKE flag is not 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").
ECHOCTL Echoes control characters (with codes between 0 and 37 octal) as ^X, where X is the character that results from adding 100 octal to the code of the control character. (For example, the character with octal code 1 is echoed as ^A ). The ASCII DEL character (code 177 octal) is echoed as ^? . The ASCII TAB, NL, and START characters are not echoed. Unless escaped (preceded by a backslash), the EOF character is not echoed. As a result, because EOT is the default EOF character, terminals that respond to EOT are prevented from hanging up. This function also requires the IEXTEN flag to be set.
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 a 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 and IEXTEN flags are set. EOL2 is an additional line delimiter, like NL, and is not normally used.
VSTART Indexes the START special character (Ctrl-q), which is recognized on input if the IXON flag is set, and generated on output if the IXOFF flag is set. The START character can be used to resume output that has been suspended by a STOP character. If the IXON flag is set, the START character is discarded when processed. While output is not suspended, START characters are ignored and not read. VSTRT is an alias for VSTART.
VSTOP Indexes the STOP special character (Ctrl-s), which is recognized on input if the IXON flag is set, and generated on output if the IXOFF flag is set. The STOP character can be used to with terminals to prevent output from disappearing before it can be read. If the IXON flag is set, the STOP character is discarded when processed. While output is suspended, STOP characters are ignored and not read.
VSUSP Indexes the SUSP special character (Ctrl-z), which is recognized on input if the ISIG flag is set. The SUSP character generates a SIGTSTP 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 SUSP character is discarded when processed.
VDSUSP Indexes the DSUSP special character (Ctrl-y), which is recognized on input if the ISIG and IEXTEN flags are set. The DSUSP character generates a SIGTSTP signal as the SUSP character does, but the signal is sent when a process in the foreground process group attempts to read the DSUSP character, rather than when DSUSP is typed. If the ISIG and IEXTEN flags are set, the DSUSP character is discarded when processed.
VREPRINT Indexes the REPRINT special character (Ctrl-r), which is recognized on input if the ICANON and IEXTEN flags are set. The REPRINT character reprints all characters, preceded by a new line, that have not been read. If the ICANON and IEXTEN flags are set, the REPRINT character is discarded when processed.
VDISCRD Indexes the DISCARD special character (Ctrl-o), which is recognized on input if the ICANON and IEXTEN flags are set. The DISCARD character causes subsequent output to be discarded until another DISCARD character is typed, more input arrives, or the condition is cleared by a program. If the ICANON and IEXTEN flags are set, the DISCARD character is discarded when processed.
VWERSE Indexes the WERASE special character (Ctrl-w), which is recognized on input if the ICANON and IEXTEN flags are set. The WERASE character causes the preceding word to be erased. The WERASE character does not erase beyond the beginning of the line as delimited by a NL, EOL, EOF, or EOL2 character. If the ICANON and IEXTEN flags are set, the WERASE character is discarded when processed.
VLNEXT Indexes the LNEXT (literal next) special character (Ctrl-v), which is recognized on input if the ICANON and IEXTEN flags are set. The LNEXT character causes the special meaning of the next character to be ignored so that characters can be input without being interpreted by the system. If the ICANON, ECHO, and IEXTEN flags are set, the LNEXT character is replaced by a ^-Backspace sequence when processed.
VMIN Indexes the MIN value, which is not a special character. The use of the MIN value is described in the discussion of noncanonical mode input processing in "ldterm Line Discipline" in AIX 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 noncanonical mode input processing in "ldterm Line Discipline" in AIX General Programming Concepts: Writing and Debugging Programs.

The character values for the following control characters can be changed:

INTR EOF STOP DISCARD
QUIT EOL SUSP WERASE
ERASE EOL2 DSUSP LNEXT
KILL START REPRINT

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

Parameter Value Definitions

The following values for the OptionalActions parameter of the tcsetattr subroutine are also defined in the termios.h file:

TCSANOW Immediately sets the parameters associated with the terminal from the referenced termios structure.
TCSADRAIN Waits until all output written to the object file has been transmitted before setting the terminal parameters from the termios structure.
TCSAFLUSH Waits until all output written to the object file has been transmitted and until all input received but not read has been discarded before setting the terminal parameters from the termios structure.

The following values for the QueueSelector parameter of the tcflush subroutine are also defined in this header file:

TCIFLUSH Flushes data that is received but not read.
TCOFLUSH Flushes data that is written but not transmitted.
TCIOFLUSH Flushes data that is received but not read as well as data that is written but not transmitted.

The following values for the Action parameter of the tcflow subroutine are also defined in the termios.h file:

TCOOFF Suspends the output of data by the object file named in the tcflow subroutine.
TCOON Restarts data output that was suspended by the TCOOFF action.
TCIOFF Transmits a stop character to stop data transmission by the terminal device.
TCION Transmits a start character to start or restart data transmission by the terminal device.

Modem Control Operations

The following ioctl operations, used for modem control, are an extension to the POSIX line discipline interface. To use these operations in a program, the program must contain an #include statement for the ioctl.h file.

TIOCMBIS Turns on the control lines specified by the integer mask value of the argument to this command. No other control lines are affected.
TIOCMBIC Turns off the control lines specified by the integer mask value of the argument to this command. No other control lines are affected.
TIOCMGET Gets all modem bits. The argument to this command is a pointer to an integer where the current state of the modem status lines is stored. Which modem status and modem control lines are supported depends on the capabilities of the hardware and the hardware's device driver.
TIOCMSET Sets all modem bits. The argument to this command is a pointer to an integer containing a new set of modem bits. The modem control bits use these bits to turn the modem control lines on or off, depending on whether the bit for that line is set or clear. Any modem status bits are ignored. The actual modem control lines which are supported depend on the capabilities of the hardware and the hardware's device driver.

The integer specifies one of the following modem control or status lines on which the modem control ioctl command operates:

TIOCM_LE Line enable
TIOCM_DTR Data terminal ready
TIOCM_RTS Request to send
TIOCM_ST Secondary transmit
TIOCM_SR Secondary receive
TIOCM_CTS Clear to send
TIOCM_CAR Carrier detect
TIOCM_CD TIOCM_CAR
TIOCM_RNG Ring
TIOCM_RI TIOCM_RNG
TIOCM_DSR Data set ready.

Implementation Specifics

This file is for POSIX compatibility.

This file is part of Base Operating System (BOS) Runtime.

Related Information

The termiox.h file, types.h file.

The csh command, getty command, ksh command, stty command, tset command.

The cfgetispeed, cfgetospeed, cfsetispeed, cfsetospeed subroutine, ioctl subroutine, sigvec subroutine, tcdrain subroutine, tcflow subroutine, tcflush subroutine, tcgetattr subroutine, tcsendbreak subroutine, tcsetattr subroutine.

tty Subsystem Overview in AIX General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]