1 /* $NetBSD: termios.h,v 1.24 2001/11/11 00:00:16 perry Exp $ */ 2 3 /* 4 * Copyright (c) 1988, 1989, 1993, 1994 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by the University of 18 * California, Berkeley and its contributors. 19 * 4. Neither the name of the University nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 * @(#)termios.h 8.3 (Berkeley) 3/28/94 36 */ 37 38 #ifndef _SYS_TERMIOS_H_ 39 #define _SYS_TERMIOS_H_ 40 41 #include <sys/ansi.h> 42 #include <sys/featuretest.h> 43 44 /* 45 * Special Control Characters 46 * 47 * Index into c_cc[] character array. 48 * 49 * Name Subscript Enabled by 50 */ 51 #define VEOF 0 /* ICANON */ 52 #define VEOL 1 /* ICANON */ 53 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 54 #define VEOL2 2 /* ICANON */ 55 #endif 56 #define VERASE 3 /* ICANON */ 57 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 58 #define VWERASE 4 /* ICANON */ 59 #endif 60 #define VKILL 5 /* ICANON */ 61 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 62 #define VREPRINT 6 /* ICANON */ 63 #endif 64 /* 7 spare 1 */ 65 #define VINTR 8 /* ISIG */ 66 #define VQUIT 9 /* ISIG */ 67 #define VSUSP 10 /* ISIG */ 68 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 69 #define VDSUSP 11 /* ISIG */ 70 #endif 71 #define VSTART 12 /* IXON, IXOFF */ 72 #define VSTOP 13 /* IXON, IXOFF */ 73 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 74 #define VLNEXT 14 /* IEXTEN */ 75 #define VDISCARD 15 /* IEXTEN */ 76 #endif 77 #define VMIN 16 /* !ICANON */ 78 #define VTIME 17 /* !ICANON */ 79 #ifndef _POSIX_C_SOURCE 80 #define VSTATUS 18 /* ICANON */ 81 /* 19 spare 2 */ 82 #endif 83 #define NCCS 20 84 85 #define _POSIX_VDISABLE ((unsigned char)'\377') 86 87 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 88 #define CCEQ(val, c) (c == val ? val != _POSIX_VDISABLE : 0) 89 #endif 90 91 /* 92 * Input flags - software input processing 93 */ 94 #define IGNBRK 0x00000001 /* ignore BREAK condition */ 95 #define BRKINT 0x00000002 /* map BREAK to SIGINTR */ 96 #define IGNPAR 0x00000004 /* ignore (discard) parity errors */ 97 #define PARMRK 0x00000008 /* mark parity and framing errors */ 98 #define INPCK 0x00000010 /* enable checking of parity errors */ 99 #define ISTRIP 0x00000020 /* strip 8th bit off chars */ 100 #define INLCR 0x00000040 /* map NL into CR */ 101 #define IGNCR 0x00000080 /* ignore CR */ 102 #define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */ 103 #define IXON 0x00000200 /* enable output flow control */ 104 #define IXOFF 0x00000400 /* enable input flow control */ 105 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) 106 #define IXANY 0x00000800 /* any char will restart after stop */ 107 #endif 108 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 109 #define IMAXBEL 0x00002000 /* ring bell on input queue full */ 110 #endif 111 112 /* 113 * Output flags - software output processing 114 */ 115 #define OPOST 0x00000001 /* enable following output processing */ 116 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) 117 #define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */ 118 #endif 119 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 120 #define OXTABS 0x00000004 /* expand tabs to spaces */ 121 #define ONOEOT 0x00000008 /* discard EOT's (^D) on output */ 122 #endif 123 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) 124 #define OCRNL 0x00000010 /* map CR to NL */ 125 #define ONOCR 0x00000020 /* discard CR's when on column 0 */ 126 #define ONLRET 0x00000040 /* move to column 0 on CR */ 127 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) */ 128 129 /* 130 * Control flags - hardware control of terminal 131 */ 132 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 133 #define CIGNORE 0x00000001 /* ignore control flags */ 134 #endif 135 #define CSIZE 0x00000300 /* character size mask */ 136 #define CS5 0x00000000 /* 5 bits (pseudo) */ 137 #define CS6 0x00000100 /* 6 bits */ 138 #define CS7 0x00000200 /* 7 bits */ 139 #define CS8 0x00000300 /* 8 bits */ 140 #define CSTOPB 0x00000400 /* send 2 stop bits */ 141 #define CREAD 0x00000800 /* enable receiver */ 142 #define PARENB 0x00001000 /* parity enable */ 143 #define PARODD 0x00002000 /* odd parity, else even */ 144 #define HUPCL 0x00004000 /* hang up on last close */ 145 #define CLOCAL 0x00008000 /* ignore modem status lines */ 146 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 147 #define CRTSCTS 0x00010000 /* RTS/CTS full-duplex flow control */ 148 #define CRTS_IFLOW CRTSCTS /* XXX compat */ 149 #define CCTS_OFLOW CRTSCTS /* XXX compat */ 150 #define CDTRCTS 0x00020000 /* DTR/CTS full-duplex flow control */ 151 #define MDMBUF 0x00100000 /* DTR/DCD hardware flow control */ 152 #define CHWFLOW (MDMBUF|CRTSCTS|CDTRCTS) /* all types of hw flow control */ 153 #endif 154 155 156 /* 157 * "Local" flags - dumping ground for other state 158 * 159 * Warning: some flags in this structure begin with 160 * the letter "I" and look like they belong in the 161 * input flag. 162 */ 163 164 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 165 #define ECHOKE 0x00000001 /* visual erase for line kill */ 166 #endif 167 #define ECHOE 0x00000002 /* visually erase chars */ 168 #define ECHOK 0x00000004 /* echo NL after line kill */ 169 #define ECHO 0x00000008 /* enable echoing */ 170 #define ECHONL 0x00000010 /* echo NL even if ECHO is off */ 171 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 172 #define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */ 173 #define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */ 174 #endif /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */ 175 #define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */ 176 #define ICANON 0x00000100 /* canonicalize input lines */ 177 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 178 #define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */ 179 #endif /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */ 180 #define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */ 181 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 182 #define EXTPROC 0x00000800 /* external processing */ 183 #endif /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */ 184 #define TOSTOP 0x00400000 /* stop background jobs on output */ 185 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 186 #define FLUSHO 0x00800000 /* output being flushed (state) */ 187 #define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */ 188 #define PENDIN 0x20000000 /* re-echo input buffer at next read */ 189 #endif /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */ 190 #define NOFLSH 0x80000000 /* don't flush output on signal */ 191 192 typedef unsigned int tcflag_t; 193 typedef unsigned char cc_t; 194 typedef unsigned int speed_t; 195 196 struct termios { 197 tcflag_t c_iflag; /* input flags */ 198 tcflag_t c_oflag; /* output flags */ 199 tcflag_t c_cflag; /* control flags */ 200 tcflag_t c_lflag; /* local flags */ 201 cc_t c_cc[NCCS]; /* control chars */ 202 int c_ispeed; /* input speed */ 203 int c_ospeed; /* output speed */ 204 }; 205 206 /* 207 * Commands passed to tcsetattr() for setting the termios structure. 208 */ 209 #define TCSANOW 0 /* make change immediate */ 210 #define TCSADRAIN 1 /* drain output, then change */ 211 #define TCSAFLUSH 2 /* drain output, flush input */ 212 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 213 #define TCSASOFT 0x10 /* flag - don't alter h.w. state */ 214 #endif 215 216 /* 217 * Standard speeds 218 */ 219 #define B0 0 220 #define B50 50 221 #define B75 75 222 #define B110 110 223 #define B134 134 224 #define B150 150 225 #define B200 200 226 #define B300 300 227 #define B600 600 228 #define B1200 1200 229 #define B1800 1800 230 #define B2400 2400 231 #define B4800 4800 232 #define B9600 9600 233 #define B19200 19200 234 #define B38400 38400 235 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 236 #define B7200 7200 237 #define B14400 14400 238 #define B28800 28800 239 #define B57600 57600 240 #define B76800 76800 241 #define B115200 115200 242 #define B230400 230400 243 #define EXTA 19200 244 #define EXTB 38400 245 #endif /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */ 246 247 #ifndef _KERNEL 248 249 #define TCIFLUSH 1 250 #define TCOFLUSH 2 251 #define TCIOFLUSH 3 252 #define TCOOFF 1 253 #define TCOON 2 254 #define TCIOFF 3 255 #define TCION 4 256 257 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) 258 #ifndef pid_t 259 typedef __pid_t pid_t; 260 #define pid_t __pid_t 261 #endif 262 #endif /* !_POSIX_C_SOURCE || _XOPEN_SOURCE */ 263 #include <sys/cdefs.h> 264 265 __BEGIN_DECLS 266 speed_t cfgetispeed __P((const struct termios *)); 267 speed_t cfgetospeed __P((const struct termios *)); 268 int cfsetispeed __P((struct termios *, speed_t)); 269 int cfsetospeed __P((struct termios *, speed_t)); 270 int tcgetattr __P((int, struct termios *)); 271 int tcsetattr __P((int, int, const struct termios *)); 272 int tcdrain __P((int)); 273 int tcflow __P((int, int)); 274 int tcflush __P((int, int)); 275 int tcsendbreak __P((int, int)); 276 #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) 277 pid_t tcgetsid __P((int)); 278 #endif /* !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) */ 279 280 281 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 282 void cfmakeraw __P((struct termios *)); 283 int cfsetspeed __P((struct termios *, speed_t)); 284 #endif /* !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) */ 285 __END_DECLS 286 287 #endif /* !_KERNEL */ 288 289 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) 290 291 /* 292 * Include tty ioctl's that aren't just for backwards compatibility 293 * with the old tty driver. These ioctl definitions were previously 294 * in <sys/ioctl.h>. 295 */ 296 #include <sys/ttycom.h> 297 #endif 298 299 /* 300 * END OF PROTECTED INCLUDE. 301 */ 302 #endif /* !_SYS_TERMIOS_H_ */ 303 304 #if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) 305 #include <sys/ttydefaults.h> 306 #endif 307