1 /* sys/termios.h */ 2 3 #ifndef _SYS_TERMIOS_H 4 #define _SYS_TERMIOS_H 5 6 #define TCOOFF 0 7 #define TCOON 1 8 #define TCIOFF 2 9 #define TCION 3 10 11 #define TCGETA 5 12 #define TCSETA 6 13 #define TCSETAW 7 14 #define TCSETAF 8 15 16 #define TCIFLUSH 0 17 #define TCOFLUSH 1 18 #define TCIOFLUSH 2 19 #define TCFLSH 3 20 21 #define TCSAFLUSH 1 22 #define TCSANOW 2 23 #define TCSADRAIN 3 24 #define TCSADFLUSH 4 25 26 #define TIOCPKT 6 27 28 #define TIOCPKT_DATA 0 29 #define TIOCPKT_FLUSHREAD 1 30 #define TIOCPKT_FLUSHWRITE 2 31 #define TIOCPKT_STOP 4 32 #define TIOCPKT_START 8 33 #define TIOCPKT_NOSTOP 16 34 #define TIOCPKT_DOSTOP 32 35 36 #define FIONBIO 0x8004667e /* To be compatible with socket version */ 37 38 #define CTRL(ch) ((ch)&0x1F) 39 40 #define CNUL 0 41 #define CDEL 0x0007f 42 #define CESC '\\' 43 #define CINTR CTRL('C') 44 #define CQUIT 0x0001c 45 #define CERASE CTRL('H') 46 #define CKILL CTRL('U') 47 #define CEOT CTRL('D') 48 #define CEOL 0 49 #define CEOL2 0 50 #define CEOF CTRL('D') 51 #define CSTART CTRL('Q') 52 #define CSTOP CTRL('S') 53 #define CSWTCH 0x0001a 54 #define NSWTCH 0 55 #define CSUSP CTRL('Z') 56 #define CDSUSP CTRL('Y') 57 #define CRPRNT CTRL('R') 58 #define CFLUSH CTRL('O') 59 #define CWERASE CTRL('W') 60 #define CLNEXT CTRL('V') 61 62 /* iflag bits */ 63 #define IGNBRK 0x00001 64 #define BRKINT 0x00002 65 #define IGNPAR 0x00004 66 #define IMAXBEL 0x00008 67 #define INPCK 0x00010 68 #define ISTRIP 0x00020 69 #define INLCR 0x00040 70 #define IGNCR 0x00080 71 #define ICRNL 0x00100 72 #define IXON 0x00400 73 #define IXOFF 0x01000 74 #define IUCLC 0x04000 75 #define IXANY 0x08000 76 #define PARMRK 0x10000 77 78 /* oflag bits */ 79 80 #define OPOST 0x00001 81 #define OLCUC 0x00002 82 #define OCRNL 0x00004 83 #define ONLCR 0x00008 84 #define ONOCR 0x00010 85 #define ONLRET 0x00020 86 #define OFILL 0x00040 87 #define CRDLY 0x00180 88 #define CR0 0x00000 89 #define CR1 0x00080 90 #define CR2 0x00100 91 #define CR3 0x00180 92 #define NLDLY 0x00200 93 #define NL0 0x00000 94 #define NL1 0x00200 95 #define BSDLY 0x00400 96 #define BS0 0x00000 97 #define BS1 0x00400 98 #define TABDLY 0x01800 99 #define TAB0 0x00000 100 #define TAB1 0x00800 101 #define TAB2 0x01000 102 #define TAB3 0x01800 103 #define XTABS 0x01800 104 #define VTDLY 0x02000 105 #define VT0 0x00000 106 #define VT1 0x02000 107 #define FFDLY 0x04000 108 #define FF0 0x00000 109 #define FF1 0x04000 110 #define OFDEL 0x08000 111 112 /* cflag bits */ 113 114 /* Baud rate values. These must fit in speed_t, which is unsigned 115 char. See also the extended baud rates below. These baud rates 116 set an additional bit. */ 117 #define CBAUD 0x0100f 118 #define B0 0x00000 119 #define B50 0x00001 120 #define B75 0x00002 121 #define B110 0x00003 122 #define B134 0x00004 123 #define B150 0x00005 124 #define B200 0x00006 125 #define B300 0x00007 126 #define B600 0x00008 127 #define B1200 0x00009 128 #define B1800 0x0000a 129 #define B2400 0x0000b 130 #define B4800 0x0000c 131 #define B9600 0x0000d 132 #define B19200 0x0000e 133 #define B38400 0x0000f 134 135 #define CSIZE 0x00030 136 #define CS5 0x00000 137 #define CS6 0x00010 138 #define CS7 0x00020 139 #define CS8 0x00030 140 #define CSTOPB 0x00040 141 #define CREAD 0x00080 142 #define PARENB 0x00100 143 #define PARODD 0x00200 144 #define HUPCL 0x00400 145 #define CLOCAL 0x00800 146 #define CBAUDEX 0x0100f 147 #define B57600 0x01001 148 #define B115200 0x01002 149 #define B128000 0x01003 150 #define B256000 0x01003 151 #define CRTSXOFF 0x04000 152 #define CRTSCTS 0x08000 153 154 /* lflag bits */ 155 #define ISIG 0x0001 156 #define ICANON 0x0002 157 #define ECHO 0x0004 158 #define ECHOE 0x0008 159 #define ECHOK 0x0010 160 #define ECHONL 0x0020 161 #define NOFLSH 0x0040 162 #define TOSTOP 0x0080 163 #define IEXTEN 0x0100 164 #define FLUSHO 0x0200 165 #define ECHOKE 0x0400 166 #define ECHOCTL 0x0800 167 168 #define VDISCARD 1 169 #define VEOL 2 170 #define VEOL2 3 171 #define VEOF 4 172 #define VERASE 5 173 #define VINTR 6 174 #define VKILL 7 175 #define VLNEXT 8 176 #define VMIN 9 177 #define VQUIT 10 178 #define VREPRINT 11 179 #define VSTART 12 180 #define VSTOP 13 181 #define VSUSP 14 182 #define VSWTC 15 183 #define VTIME 16 184 #define VWERASE 17 185 186 #define NCCS 18 187 188 typedef unsigned char cc_t; 189 typedef unsigned int tcflag_t; 190 typedef unsigned int speed_t; 191 typedef unsigned short otcflag_t; 192 typedef unsigned char ospeed_t; 193 194 struct __oldtermios { 195 otcflag_t c_iflag; 196 otcflag_t c_oflag; 197 otcflag_t c_cflag; 198 otcflag_t c_lflag; 199 char c_line; 200 cc_t c_cc[NCCS]; 201 ospeed_t c_ispeed; 202 ospeed_t c_ospeed; 203 }; 204 205 struct termios { 206 tcflag_t c_iflag; 207 tcflag_t c_oflag; 208 tcflag_t c_cflag; 209 tcflag_t c_lflag; 210 char c_line; 211 cc_t c_cc[NCCS]; 212 speed_t c_ispeed; 213 speed_t c_ospeed; 214 }; 215 216 #ifdef CYGWIN_VERSION_DLL_IS_OLD_TERMIOS 217 #ifdef __GNUC__ 218 # define __tonew_termios(ti) \ 219 ({ \ 220 struct termios *__newti; \ 221 \ 222 if (!CYGWIN_VERSION_DLL_IS_OLD_TERMIOS) \ 223 __newti = (struct termios *) ti; \ 224 else \ 225 { \ 226 __newti = (struct termios *) alloca(sizeof(struct termios)); \ 227 __newti->c_iflag = ((struct __oldtermios *)ti)->c_iflag; \ 228 __newti->c_oflag = ((struct __oldtermios *)ti)->c_oflag; \ 229 __newti->c_cflag = ((struct __oldtermios *)ti)->c_cflag; \ 230 __newti->c_lflag = ((struct __oldtermios *)ti)->c_lflag; \ 231 __newti->c_line = ((struct __oldtermios *)ti)->c_line; \ 232 __newti->c_ispeed = ((struct __oldtermios *)ti)->c_ispeed; \ 233 __newti->c_ospeed = ((struct __oldtermios *)ti)->c_ospeed; \ 234 memcpy (__newti->c_cc, ((struct __oldtermios *)ti)->c_cc, sizeof(__newti->c_cc)); \ 235 } \ 236 __newti; \ 237 }) 238 239 # define __makenew_termios(ti) \ 240 (CYGWIN_VERSION_DLL_IS_OLD_TERMIOS ? \ 241 (struct termios *) alloca (sizeof (struct termios)) : (ti)) 242 243 # define __toapp_termios(toti, fromti) \ 244 ({ \ 245 if (!CYGWIN_VERSION_DLL_IS_OLD_TERMIOS) \ 246 toti = fromti; \ 247 else \ 248 { \ 249 ((struct __oldtermios *)toti)->c_iflag = fromti->c_iflag; \ 250 ((struct __oldtermios *)toti)->c_oflag = fromti->c_oflag; \ 251 ((struct __oldtermios *)toti)->c_cflag = fromti->c_cflag; \ 252 ((struct __oldtermios *)toti)->c_lflag = fromti->c_lflag; \ 253 ((struct __oldtermios *)toti)->c_line = fromti->c_line; \ 254 ((struct __oldtermios *)toti)->c_ispeed = fromti->c_ispeed; \ 255 ((struct __oldtermios *)toti)->c_ospeed = fromti->c_ospeed; \ 256 memcpy (((struct __oldtermios*)toti)->c_cc, fromti->c_cc, sizeof(fromti->c_cc)); \ 257 } \ 258 toti; \ 259 }) 260 #endif /*__GNUC__*/ 261 #endif 262 263 #define termio termios 264 265 #define cfgetospeed(tp) ((tp)->c_ospeed) 266 #define cfgetispeed(tp) ((tp)->c_ispeed) 267 #define cfsetospeed(tp,s) (((tp)->c_ospeed = (s)), 0) 268 #define cfsetispeed(tp,s) (((tp)->c_ispeed = (s)), 0) 269 270 #ifdef __cplusplus 271 extern "C" { 272 #endif 273 274 int tcgetattr (int, struct termios *); 275 int tcsetattr (int, int, const struct termios *); 276 int tcsendbreak (int, int); 277 int tcdrain (int); 278 int tcflush (int, int); 279 int tcflow (int, int); 280 281 #ifdef __cplusplus 282 } 283 #endif 284 285 /* Extra stuff to make porting stuff easier. */ 286 struct winsize 287 { 288 unsigned short ws_row, ws_col; 289 unsigned short ws_xpixel, ws_ypixel; 290 }; 291 292 #define TIOCGWINSZ (('T' << 8) | 1) 293 #define TIOCSWINSZ (('T' << 8) | 2) 294 295 #endif /* _SYS_TERMIOS_H */ |