2 * Copyright (c) 1988, 1989, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * @(#)termios.h 8.3 (Berkeley) 3/28/94
34 * $FreeBSD: src/sys/sys/termios.h,v 1.13.2.1 2001/03/06 06:31:44 jhb Exp $
37 #ifndef _SYS_TERMIOS_H_
38 #define _SYS_TERMIOS_H_
40 /* Needed by tcgetsid(3). */
41 #include <sys/stdint.h>
42 #ifndef _PID_T_DECLARED
43 typedef __pid_t pid_t;
44 #define _PID_T_DECLARED
48 * Special Control Characters
50 * Index into c_cc[] character array.
52 * Name Subscript Enabled by
54 #define VEOF 0 /* ICANON */
55 #define VEOL 1 /* ICANON */
57 #define VEOL2 2 /* ICANON together with IEXTEN */
59 #define VERASE 3 /* ICANON */
61 #define VWERASE 4 /* ICANON together with IEXTEN */
63 #define VKILL 5 /* ICANON */
65 #define VREPRINT 6 /* ICANON together with IEXTEN */
66 #define VERASE2 7 /* ICANON */
68 #define VINTR 8 /* ISIG */
69 #define VQUIT 9 /* ISIG */
70 #define VSUSP 10 /* ISIG */
72 #define VDSUSP 11 /* ISIG together with IEXTEN */
74 #define VSTART 12 /* IXON, IXOFF */
75 #define VSTOP 13 /* IXON, IXOFF */
77 #define VLNEXT 14 /* IEXTEN */
78 #define VDISCARD 15 /* IEXTEN */
80 #define VMIN 16 /* !ICANON */
81 #define VTIME 17 /* !ICANON */
83 #define VSTATUS 18 /* ICANON together with IEXTEN */
84 #define VCHECKPT 19 /* ICANON together with IEXTEN */
88 #define _POSIX_VDISABLE 0xff
91 #define CCEQ(val, c) ((c) == (val) ? (val) != _POSIX_VDISABLE : 0)
95 * Input flags - software input processing
97 #define IGNBRK 0x00000001 /* ignore BREAK condition */
98 #define BRKINT 0x00000002 /* map BREAK to SIGINTR */
99 #define IGNPAR 0x00000004 /* ignore (discard) parity errors */
100 #define PARMRK 0x00000008 /* mark parity and framing errors */
101 #define INPCK 0x00000010 /* enable checking of parity errors */
102 #define ISTRIP 0x00000020 /* strip 8th bit off chars */
103 #define INLCR 0x00000040 /* map NL into CR */
104 #define IGNCR 0x00000080 /* ignore CR */
105 #define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */
106 #define IXON 0x00000200 /* enable output flow control */
107 #define IXOFF 0x00000400 /* enable input flow control */
108 #ifndef _POSIX_SOURCE
109 #define IXANY 0x00000800 /* any char will restart after stop */
110 #define IMAXBEL 0x00002000 /* ring bell on input queue full */
111 #endif /*_POSIX_SOURCE */
114 * Output flags - software output processing
116 #define OPOST 0x00000001 /* enable following output processing */
117 #ifndef _POSIX_SOURCE
118 #define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */
119 #define OXTABS 0x00000004 /* expand tabs to spaces */
120 #define ONOEOT 0x00000008 /* discard EOT's (^D) on output) */
121 #define OCRNL 0x00000010 /* map CR to NL on output */
122 #define ONOCR 0x00000020 /* no CR output at column 0 */
123 #define ONLRET 0x00000040 /* NL performs CR function */
124 #endif /*_POSIX_SOURCE */
127 * Control flags - hardware control of terminal
129 #ifndef _POSIX_SOURCE
130 #define CIGNORE 0x00000001 /* ignore control flags */
132 #define CSIZE 0x00000300 /* character size mask */
133 #define CS5 0x00000000 /* 5 bits (pseudo) */
134 #define CS6 0x00000100 /* 6 bits */
135 #define CS7 0x00000200 /* 7 bits */
136 #define CS8 0x00000300 /* 8 bits */
137 #define CSTOPB 0x00000400 /* send 2 stop bits */
138 #define CREAD 0x00000800 /* enable receiver */
139 #define PARENB 0x00001000 /* parity enable */
140 #define PARODD 0x00002000 /* odd parity, else even */
141 #define HUPCL 0x00004000 /* hang up on last close */
142 #define CLOCAL 0x00008000 /* ignore modem status lines */
143 #ifndef _POSIX_SOURCE
144 #define CCTS_OFLOW 0x00010000 /* CTS flow control of output */
145 #define CRTSCTS (CCTS_OFLOW | CRTS_IFLOW)
146 #define CRTS_IFLOW 0x00020000 /* RTS flow control of input */
147 #define CDTR_IFLOW 0x00040000 /* DTR flow control of input */
148 #define CDSR_OFLOW 0x00080000 /* DSR flow control of output */
149 #define CCAR_OFLOW 0x00100000 /* DCD flow control of output */
150 #define MDMBUF 0x00100000 /* old name for CCAR_OFLOW */
155 * "Local" flags - dumping ground for other state
157 * Warning: some flags in this structure begin with
158 * the letter "I" and look like they belong in the
162 #ifndef _POSIX_SOURCE
163 #define ECHOKE 0x00000001 /* visual erase for line kill */
164 #endif /*_POSIX_SOURCE */
165 #define ECHOE 0x00000002 /* visually erase chars */
166 #define ECHOK 0x00000004 /* echo NL after line kill */
167 #define ECHO 0x00000008 /* enable echoing */
168 #define ECHONL 0x00000010 /* echo NL even if ECHO is off */
169 #ifndef _POSIX_SOURCE
170 #define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */
171 #define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */
172 #endif /*_POSIX_SOURCE */
173 #define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */
174 #define ICANON 0x00000100 /* canonicalize input lines */
175 #ifndef _POSIX_SOURCE
176 #define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */
177 #endif /*_POSIX_SOURCE */
178 #define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */
179 #define EXTPROC 0x00000800 /* external processing */
180 #define TOSTOP 0x00400000 /* stop background jobs from output */
181 #ifndef _POSIX_SOURCE
182 #define FLUSHO 0x00800000 /* output being flushed (state) */
183 #define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */
184 #define PENDIN 0x20000000 /* XXX retype pending input (state) */
185 #endif /*_POSIX_SOURCE */
186 #define NOFLSH 0x80000000 /* don't flush after interrupt */
188 typedef unsigned int tcflag_t;
189 typedef unsigned char cc_t;
190 typedef unsigned int speed_t;
193 tcflag_t c_iflag; /* input flags */
194 tcflag_t c_oflag; /* output flags */
195 tcflag_t c_cflag; /* control flags */
196 tcflag_t c_lflag; /* local flags */
197 cc_t c_cc[NCCS]; /* control chars */
198 speed_t c_ispeed; /* input speed */
199 speed_t c_ospeed; /* output speed */
203 * Commands passed to tcsetattr() for setting the termios structure.
205 #define TCSANOW 0 /* make change immediate */
206 #define TCSADRAIN 1 /* drain output, then change */
207 #define TCSAFLUSH 2 /* drain output, flush input */
208 #ifndef _POSIX_SOURCE
209 #define TCSASOFT 0x10 /* flag - don't alter h.w. state */
231 #ifndef _POSIX_SOURCE
237 #define B115200 115200
238 #define B230400 230400
241 #endif /* !_POSIX_SOURCE */
251 #include <sys/cdefs.h>
254 speed_t cfgetispeed (const struct termios *);
255 speed_t cfgetospeed (const struct termios *);
256 int cfsetispeed (struct termios *, speed_t);
257 int cfsetospeed (struct termios *, speed_t);
258 int tcgetattr (int, struct termios *);
259 int tcsetattr (int, int, const struct termios *);
261 int tcflow (int, int);
262 int tcflush (int, int);
263 int tcsendbreak (int, int);
265 #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
267 #endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
269 #ifndef _POSIX_SOURCE
270 void cfmakeraw (struct termios *);
271 int cfsetspeed (struct termios *, speed_t);
272 #endif /* !_POSIX_SOURCE */
275 #ifndef _POSIX_SOURCE
278 * Include tty ioctl's that aren't just for backwards compatibility
279 * with the old tty driver. These ioctl definitions were previously
282 #include <sys/ttycom.h>
286 * END OF PROTECTED INCLUDE.
288 #endif /* !_SYS_TERMIOS_H_ */
290 #ifndef _POSIX_SOURCE
291 #include <sys/ttydefaults.h>