NAME
termios.h — define
values for termios
SYNOPSIS
#include
<termios.h>
DESCRIPTION
The <termios.h> header shall contain the definitions used by the terminal I/O interfaces (see V1_chap11(7) for the structures and names defined).
The termios Structure
The <termios.h> header shall define the following data types through typedef:
- cc_t
- Used for terminal special characters.
- speed_t
- Used for terminal baud rates.
- tcflag_t
- Used for terminal modes.
The above types shall be all unsigned integer types.
The implementation shall support one or more programming environments in which the widths of cc_t, speed_t, and tcflag_t are no greater than the width of type long. The names of these programming environments can be obtained using the confstr(3) function or the getconf(1) utility.
The <termios.h> header shall define the termios structure, which shall include at least the following members:
tcflag_t c_iflag Input modes. tcflag_t c_oflag Output modes. tcflag_t c_cflag Control modes. tcflag_t c_lflag Local modes. cc_t c_cc[NCCS] Control characters.
The <termios.h> header shall define the following symbolic constant:
- NCCS
- Size of the array c_cc for control characters.
The <termios.h> header shall define the following symbolic constants for use as subscripts for the array c_cc:
| Subscript Usage | ||
| Canonical Mode | Non-Canonical Mode | Description |
| VEOF | EOF character. | |
| VEOL | EOL character. | |
| VERASE | ERASE character. | |
| VINTR | VINTR | INTR character. |
| VKILL | KILL character. | |
| VMIN | MIN value. | |
| VQUIT | VQUIT | QUIT character. |
| VSTART | VSTART | START character. |
| VSTOP | VSTOP | STOP character. |
| VSUSP | VSUSP | SUSP character. |
| VTIME | TIME value. |
The subscript values shall be suitable for use in #if preprocessing directives and shall be distinct, except that the VMIN and VTIME subscripts may have the same values as the VEOF and VEOL subscripts, respectively.
Input Modes
The <termios.h> header shall define the following symbolic constants for use as flags in the c_iflag field. The c_iflag field describes the basic terminal input control.
- BRKINT
- Signal interrupt on break.
- ICRNL
- Map CR to NL on input.
- IGNBRK
- Ignore break condition.
- IGNCR
- Ignore CR.
- IGNPAR
- Ignore characters with parity errors.
- INLCR
- Map NL to CR on input.
- INPCK
- Enable input parity check.
- ISTRIP
- Strip character.
- IXANY
- Enable any character to restart output.
- IXOFF
- Enable start/stop input control.
- IXON
- Enable start/stop output control.
- PARMRK
- Mark parity errors.
Output Modes
The <termios.h> header shall define the following symbolic constants for use as flags in the c_oflag field. The c_oflag field specifies the system treatment of output.
- OPOST
- Post-process output.
- ONLCR
- [XSI] Map NL to CR-NL on output.
- OCRNL
- [XSI] Map CR to NL on output.
- ONOCR
- [XSI] No CR output at column 0.
- ONLRET
- [XSI] NL performs CR function.
- OFDEL
- [XSI] Fill is DEL.
- OFILL
- [XSI] Use fill characters for delay.
- NLDLY
- [XSI] Select newline delays:
- CRDLY
- [XSI] Select carriage-return delays:
- TABDLY
- [XSI] Select horizontal-tab delays:
- BSDLY
- [XSI] Select backspace delays:
- VTDLY
- [XSI] Select vertical-tab delays:
- FFDLY
- [XSI] Select form-feed delays:
Baud Rate Selection
The <termios.h> header shall define the following symbolic constants for use as values of objects of type speed_t.
The input and output baud rates are stored in the termios structure. These are the valid values for objects of type speed_t. Not all baud rates need be supported by the underlying hardware.
Control Modes
The <termios.h> header shall define the following symbolic constants for use as flags in the c_cflag field. The c_cflag field describes the hardware control of the terminal; not all values specified are required to be supported by the underlying hardware.
- CSIZE
- Character size:
- CSTOPB
- Send two stop bits, else one.
- CREAD
- Enable receiver.
- PARENB
- Parity enable.
- PARODD
- Odd parity, else even.
- HUPCL
- Hang up on last close.
- CLOCAL
- Ignore modem status lines.
The implementation shall support the functionality associated with the symbols CS7, CS8, CSTOPB, PARODD, and PARENB.
Local Modes
The <termios.h> header shall define the following symbolic constants for use as flags in the c_lflag field. The c_lflag field of the argument structure is used to control various terminal functions.
- ECHO
- Enable echo.
- ECHOE
- Echo erase character as error-correcting backspace.
- ECHOK
- Echo KILL.
- ECHONL
- Echo NL.
- ICANON
- Canonical input (erase and kill processing).
- IEXTEN
- Enable extended input character processing.
- ISIG
- Enable signals.
- NOFLSH
- Disable flush after interrupt or quit.
- TOSTOP
- Send SIGTTOU for background output.
The winsize Structure
The <termios.h> header shall define the winsize structure, which shall include at least the following members:
unsigned short ws_row Rows, in characters. unsigned short ws_col Columns, in characters.
Attribute Selection
The <termios.h> header shall define the following symbolic constants for use with tcsetattr(3):
Line Control
The <termios.h> header shall define the following symbolic constants for use with tcflush(3):
- TCIFLUSH
- Flush pending input.
- TCIOFLUSH
- Flush both pending input and untransmitted output.
- TCOFLUSH
- Flush untransmitted output.
The <termios.h> header shall define the following symbolic constants for use with tcflow(3):
- TCIOFF
- Transmit a STOP character, intended to suspend input data.
- TCION
- Transmit a START character, intended to restart input data.
- TCOOFF
- Suspend output.
- TCOON
- Restart output.
The <termios.h> header shall define the pid_t type as described in <sys/types.h>.
The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.
speed_t cfgetispeed(const struct termios *); speed_t cfgetospeed(const struct termios *); int cfsetispeed(struct termios *, speed_t); int cfsetospeed(struct termios *, speed_t); int tcdrain(int); int tcflow(int, int); int tcflush(int, int); int tcgetattr(int, struct termios *); pid_t tcgetsid(int); int tcgetwinsize(int, struct winsize *); int tcsendbreak(int, int); int tcsetattr(int, int, const struct termios *); int tcsetwinsize(int, const struct winsize *);
APPLICATION USAGE
The following names are reserved for XSI-conformant systems to use as an extension to the above; therefore strictly conforming applications shall not use them:
| CBAUD | EXTB | VDSUSP |
| DEFECHO | FLUSHO | VLNEXT |
| ECHOCTL | LOBLK | VREPRINT |
| ECHOKE | PENDIN | VSTATUS |
| ECHOPRT | SWTCH | VWERASE |
| EXTA | VDISCARD |
RATIONALE
None.
FUTURE DIRECTIONS
None.
SEE ALSO
XSH cfgetispeed(3), cfgetospeed(3), cfsetispeed(3), cfsetospeed(3), confstr(3), tcdrain(3), tcflow(3), tcflush(3), tcgetattr(3), tcgetsid(3), tcgetwinsize(3), tcsendbreak(3), tcsetattr(3), tcsetwinsize(3)
XCU V1_chap11(7), getconf(1)
CHANGE HISTORY
First released in Issue 3.
Included for alignment with the ISO POSIX-1 standard.
Issue 6
The LEGACY symbols IUCLC, OLCUC, and XCASE are removed.
FIPS 151-2 requirements for the symbols CS7, CS8, CSTOPB, PARODD, and PARENB are reaffirmed.
IEEE Std 1003.1-2001 (“POSIX.1”)/Cor 1-2002, item XBD/TC1/D6/19 is applied, changing ECHOK to ECHOKE in the APPLICATION USAGE section.
Issue 7
Austin Group Interpretation 1003.1-2001 #144 is applied, moving functionality relating to the IXANY symbol from the XSI option to the Base.
SD5-XBD-ERN-35 is applied, adding the OFDEL output mode.
This reference page is clarified with respect to macros and symbolic constants, and a declaration for the pid_t type is added.
Issue 8
Austin Group Defects 1151 and 1484 are applied, adding the winsize structure and the tcgetwinsize(3) and tcsetwinsize(3) functions.