1 /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
20 * POSIX Standard: 7.1-2 General Terminal Interface <termios.h>
30 /* This is supposed to be compatible with 4.4BSD. */
32 /* Type of terminal control flag masks. */
33 typedef unsigned long int tcflag_t;
35 /* Type of control characters. */
36 typedef unsigned char cc_t;
38 /* Type of baud rate specifiers. */
39 typedef long int speed_t;
41 /* Terminal control structure. */
46 #define IGNBRK (1 << 0) /* Ignore break condition. */
47 #define BRKINT (1 << 1) /* Signal interrupt on break. */
48 #define IGNPAR (1 << 2) /* Ignore characters with parity errors. */
49 #define PARMRK (1 << 3) /* Mark parity and framing errors. */
50 #define INPCK (1 << 4) /* Enable input parity check. */
51 #define INLCR (1 << 5) /* Map NL to CR on input. */
52 #define ISTRIP (1 << 6) /* Strip 8th bit off characters. */
53 #define IGNCR (1 << 7) /* Ignore CR. */
54 #define ICRNL (1 << 8) /* Map CR to NL on input. */
55 #define IXON (1 << 9) /* Enable start/stop output control. */
56 #define IXOFF (1 << 10) /* Enable start/stop input control. */
58 #define IXANY (1 << 11) /* Any character will restart after stop. */
59 #define IMAXBEL (1 << 13) /* Ring bell when input queue is full. */
64 #define OPOST (1 << 0) /* Perform output processing. */
66 #define ONLCR (1 << 1) /* Map NL to CR-NL on output. */
67 #define OXTABS (1 << 2) /* Expand tabs to spaces. */
68 #define ONOEOT (1 << 8) /* Discard EOT (^D) on output. */
74 #define CIGNORE (1 << 0) /* Ignore these control flags. */
76 #define CSIZE (CS5|CS6|CS7|CS8) /* Number of bits per byte (mask). */
77 #define CS5 0 /* 5 bits per byte. */
78 #define CS6 (1 << 8) /* 6 bits per byte. */
79 #define CS7 (1 << 9) /* 7 bits per byte. */
80 #define CS8 (CS6|CS7) /* 8 bits per byte. */
81 #define CSTOPB (1 << 10) /* Two stop bits instead of one. */
82 #define CREAD (1 << 11) /* Enable receiver. */
83 #define PARENB (1 << 12) /* Parity enable. */
84 #define PARODD (1 << 13) /* Odd parity instead of even. */
85 #define HUPCL (1 << 14) /* Hang up on last close. */
86 #define CLOCAL (1 << 15) /* Ignore modem status lines. */
88 #define CCTS_OFLOW (1 << 16) /* CTS flow control of output. */
89 #define CRTS_IFLOW (1 << 17) /* RTS flow control of input. */
90 #define MDMBUF (1 << 20) /* Carrier flow control of output. */
96 #define ECHOKE (1 << 0) /* Visual erase for KILL. */
98 #define _ECHOE (1 << 1) /* Visual erase for ERASE. */
100 #define _ECHOK (1 << 2) /* Echo NL after KILL. */
102 #define _ECHO (1 << 3) /* Enable echo. */
104 #define _ECHONL (1 << 4) /* Echo NL even if ECHO is off. */
105 #define ECHONL _ECHONL
107 #define ECHOPRT (1 << 5) /* Hardcopy visual erase. */
108 #define ECHOCTL (1 << 6) /* Echo control characters as ^X. */
110 #define _ISIG (1 << 7) /* Enable signals. */
112 #define _ICANON (1 << 8) /* Do erase and kill processing. */
113 #define ICANON _ICANON
115 #define ALTWERASE (1 << 9) /* Alternate WERASE algorithm. */
117 #define _IEXTEN (1 << 10) /* Enable DISCARD and LNEXT. */
118 #define IEXTEN _IEXTEN
119 #define EXTPROC (1 << 11) /* External processing. */
120 #define _TOSTOP (1 << 22) /* Send SIGTTOU for background output. */
121 #define TOSTOP _TOSTOP
123 #define FLUSHO (1 << 23) /* Output being flushed (state). */
124 #define NOKERNINFO (1 << 25) /* Disable VSTATUS. */
125 #define PENDIN (1 << 29) /* Retype pending input (state). */
127 #define _NOFLSH (1 << 31) /* Disable flush after interrupt. */
128 #define NOFLSH _NOFLSH
130 /* Control characters. */
131 #define VEOF 0 /* End-of-file character [ICANON]. */
132 #define VEOL 1 /* End-of-line character [ICANON]. */
134 #define VEOL2 2 /* Second EOL character [ICANON]. */
136 #define VERASE 3 /* Erase character [ICANON]. */
138 #define VWERASE 4 /* Word-erase character [ICANON]. */
140 #define VKILL 5 /* Kill-line character [ICANON]. */
142 #define VREPRINT 6 /* Reprint-line character [ICANON]. */
144 #define VINTR 8 /* Interrupt character [ISIG]. */
145 #define VQUIT 9 /* Quit character [ISIG]. */
146 #define VSUSP 10 /* Suspend character [ISIG]. */
148 #define VDSUSP 11 /* Delayed suspend character [ISIG]. */
150 #define VSTART 12 /* Start (X-ON) character [IXON, IXOFF]. */
151 #define VSTOP 13 /* Stop (X-OFF) character [IXON, IXOFF]. */
153 #define VLNEXT 14 /* Literal-next character [IEXTEN]. */
154 #define VDISCARD 15 /* Discard character [IEXTEN]. */
156 #define VMIN 16 /* Minimum number of bytes read at once [!ICANON]. */
157 #define VTIME 17 /* Time-out value (tenths of a second) [!ICANON]. */
159 #define VSTATUS 18 /* Status character [ICANON]. */
164 /* Input and output baud rates. */
165 speed_t __ispeed, __ospeed;
166 #define B0 0 /* Hang up. */
167 #define B50 50 /* 50 baud. */
168 #define B75 75 /* 75 baud. */
169 #define B110 110 /* 110 baud. */
170 #define B134 134 /* 134.5 baud. */
171 #define B150 150 /* 150 baud. */
172 #define B200 200 /* 200 baud. */
173 #define B300 300 /* 300 baud. */
174 #define B600 600 /* 600 baud. */
175 #define B1200 1200 /* 1200 baud. */
176 #define B1800 1800 /* 1800 baud. */
177 #define B2400 2400 /* 2400 baud. */
178 #define B4800 4800 /* 4800 baud. */
179 #define B9600 9600 /* 9600 baud. */
180 #define B19200 19200 /* 19200 baud. */
181 #define B38400 38400 /* 38400 baud. */
188 #define _IOT_termios /* Hurd ioctl type field. */ \
189 _IOT (_IOTS (cflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)
191 /* Return the output baud rate stored in *TERMIOS_P. */
192 extern speed_t cfgetospeed __P ((__const struct termios * __termios_p));
194 /* Return the input baud rate stored in *TERMIOS_P. */
195 extern speed_t cfgetispeed __P ((__const struct termios * __termios_p));
197 /* Set the output baud rate stored in *TERMIOS_P to SPEED. */
198 extern int cfsetospeed __P ((struct termios * __termios_p, speed_t __speed));
200 /* Set the input baud rate stored in *TERMIOS_P to SPEED. */
201 extern int cfsetispeed __P ((struct termios * __termios_p, speed_t __speed));
204 #define cfgetospeed(t) ((t)->__ospeed)
205 #define cfgetispeed(t) ((t)->__ispeed)
206 #define cfsetospeed(t, s) ((t)->__ospeed = (s))
207 #define cfsetispeed(t, s) ((t)->__ispeed = (s))
211 /* Set both the input and output baud rates in *TERMIOS_OP to SPEED. */
212 extern void cfsetspeed __P ((struct termios * __termios_p, speed_t __speed));
216 /* Put the state of FD into *TERMIOS_P. */
217 extern int __tcgetattr __P ((int __fd, struct termios * __termios_p));
218 extern int tcgetattr __P ((int __fd, struct termios * __termios_p));
221 #define tcgetattr(fd, termios_p) __tcgetattr((fd), (termios_p))
222 #endif /* Optimizing. */
224 /* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */
225 #define TCSANOW 0 /* Change immediately. */
226 #define TCSADRAIN 1 /* Change when pending output is written. */
227 #define TCSAFLUSH 2 /* Flush pending input before changing. */
229 #define TCSASOFT 0x10 /* Flag: Don't alter hardware state. */
232 /* Set the state of FD to *TERMIOS_P. */
233 extern int tcsetattr __P ((int __fd, int __optional_actions,
234 __const struct termios * __termios_p));
238 /* Set *TERMIOS_P to indicate raw mode. */
239 extern void cfmakeraw __P ((struct termios * __termios_p));
242 /* Send zero bits on FD. */
243 extern int tcsendbreak __P ((int __fd, int __duration));
245 /* Wait for pending output to be written on FD. */
246 extern int tcdrain __P ((int __fd));
248 /* Values for the QUEUE_SELECTOR argument to `tcflush'. */
249 #define TCIFLUSH 1 /* Discard data received but not yet read. */
250 #define TCOFLUSH 2 /* Discard data written but not yet sent. */
251 #define TCIOFLUSH 3 /* Discard all pending data. */
253 /* Flush pending data on FD. */
254 extern int tcflush __P ((int __fd, int __queue_selector));
256 /* Values for the ACTION argument to `tcflow'. */
257 #define TCOOFF 1 /* Suspend output. */
258 #define TCOON 2 /* Restart suspended output. */
259 #define TCIOFF 3 /* Send a STOP character. */
260 #define TCION 4 /* Send a START character. */
262 /* Suspend or restart transmission on FD. */
263 extern int tcflow __P ((int __fd, int __action));
267 #include <sys/ttydefaults.h>
272 #endif /* termios.h */