1 #ifndef _TERMIOS_H_ 2 #define _TERMIOS_H_ 3 4 /* 5 ** Distributed under the terms of the OpenBeOS License. 6 */ 7 8 #include <sys/types.h> 9 #include <unistd.h> 10 11 12 #define NCC 11 /* number of control characters */ 13 #define NCCS NCC 14 15 /* control characters */ 16 #define VINTR 0 17 #define VQUIT 1 18 #define VERASE 2 19 #define VKILL 3 20 #define VEOF 4 21 #define VEOL 5 22 #define VMIN 4 23 #define VTIME 5 24 #define VEOL2 6 25 #define VSWTCH 7 26 #define VSTART 8 27 #define VSTOP 9 28 #define VSUSP 10 29 30 31 #define termio termios /* for old non-posix code */ 32 33 typedef unsigned long tcflag_t; 34 typedef unsigned char speed_t; 35 typedef unsigned char cc_t; 36 37 struct termios { 38 tcflag_t c_iflag; /* input modes */ 39 tcflag_t c_oflag; /* output modes */ 40 tcflag_t c_cflag; /* control modes */ 41 tcflag_t c_lflag; /* local modes */ 42 char c_line; /* line discipline */ 43 speed_t c_ixxxxx; /* (unused) */ 44 speed_t c_oxxxxx; /* (unused) */ 45 cc_t c_cc[NCC]; /* control chars */ 46 }; 47 48 49 struct winsize { /* for the TIOCGWINSZ ioctl */ 50 unsigned short ws_row; 51 unsigned short ws_col; 52 unsigned short ws_xpixel; 53 unsigned short ws_ypixel; 54 }; 55 56 57 /* 58 * c_iflag - input control modes 59 */ 60 #define IGNBRK 0x01 /* ignore breaks */ 61 #define BRKINT 0x02 /* break sends interrupt */ 62 #define IGNPAR 0x04 /* ignore chars with parity errors */ 63 #define PARMRK 0x08 /* marks parity errors */ 64 #define INPCK 0x10 /* enable input parity checking */ 65 #define ISTRIP 0x20 /* strip high bit from characters */ 66 #define INLCR 0x40 /* maps newline to CR on input */ 67 #define IGNCR 0x80 /* ignores carriage returns */ 68 #define ICRNL 0x100 /* maps CR to newlines on input */ 69 #define IUCLC 0x200 /* maps all upper case to lower */ 70 #define IXON 0x400 /* enables input SW flow control */ 71 #define IXANY 0x800 /* any character will restart input */ 72 #define IXOFF 0x1000 /* enables output SW flow control */ 73 74 75 /* 76 * c_oflag - output control modes 77 */ 78 #define OPOST 0x01 /* enable postprocessing of output */ 79 #define OLCUC 0x02 /* maps lowercase to uppercase */ 80 #define ONLCR 0x04 /* maps NL to CR-NL on output */ 81 #define OCRNL 0x08 /* maps CR to NL on output */ 82 #define ONOCR 0x10 /* no CR output when at column 0 */ 83 #define ONLRET 0x20 /* newline performs CR function */ 84 #define OFILL 0x40 /* uses fill characters for delays */ 85 #define OFDEL 0x80 /* Fills are DEL, otherwise NUL */ 86 #define NLDLY 0x100 /* Newline delays: */ 87 #define NL0 0x000 88 #define NL1 0x100 89 #define CRDLY 0x600 /* Carriage return delays: */ 90 #define CR0 0x000 91 #define CR1 0x200 92 #define CR2 0x400 93 #define CR3 0x600 94 #define TABDLY 0x1800 /* Tab delays: */ 95 #define TAB0 0x0000 96 #define TAB1 0x0800 97 #define TAB2 0x1000 98 #define TAB3 0x1800 99 #define BSDLY 0x2000 /* Backspace delays: */ 100 #define BS0 0x0000 101 #define BS1 0x2000 102 #define VTDLY 0x4000 /* Vertical tab delays: */ 103 #define VT0 0x0000 104 #define VT1 0x4000 105 #define FFDLY 0x8000 /* Form feed delays: */ 106 #define FF0 0x0000 107 #define FF1 0x8000 108 109 /* 110 * c_cflag - control modes 111 */ 112 #define CBAUD 0x1F /* line speed definitions */ 113 114 #define B0 0x00 115 #define B50 0x01 116 #define B75 0x02 117 #define B110 0x03 118 #define B134 0x04 119 #define B150 0x05 120 #define B200 0x06 121 #define B300 0x07 122 #define B600 0x08 123 #define B1200 0x09 124 #define B1800 0x0A 125 #define B2400 0x0B 126 #define B4800 0x0C 127 #define B9600 0x0D 128 #define B19200 0x0E 129 #define B38400 0x0F 130 #define B57600 0x10 131 #define B115200 0x11 132 #define B230400 0x12 133 #define B31250 0x13 /* for MIDI */ 134 135 #define CSIZE 0x20 /* character size */ 136 #define CS5 0x00 /* only 7 and 8 bits supported */ 137 #define CS6 0x00 138 #define CS7 0x00 139 #define CS8 0x20 140 #define CSTOPB 0x40 /* send 2 stop bits, not 1 */ 141 #define CREAD 0x80 /* enables receiver */ 142 #define PARENB 0x100 /* xmit parity enable */ 143 #define PARODD 0x200 /* odd parity, else even */ 144 #define HUPCL 0x400 /* hangs up on last close */ 145 #define CLOCAL 0x800 /* indicates local line */ 146 #define XLOBLK 0x1000 /* block layer output ?*/ 147 #define CTSFLOW 0x2000 /* enable CTS flow */ 148 #define RTSFLOW 0x4000 /* enable RTS flow */ 149 #define CRTSCTS (RTSFLOW | CTSFLOW) 150 151 /* 152 * c_lflag - local modes 153 */ 154 #define ISIG (0x01) /* enable signals */ 155 #define ICANON (0x02) /* Canonical input */ 156 #define XCASE (0x04) /* Canonical u/l case */ 157 #define ECHO (0x08) /* Enable echo */ 158 #define ECHOE (0x10) /* Echo erase as bs-sp-bs */ 159 #define ECHOK (0x20) /* Echo nl after kill */ 160 #define ECHONL (0x40) /* Echo nl */ 161 #define NOFLSH (0x80) /* Disable flush after int or quit */ 162 #define TOSTOP (0x100) /* stop bg processes that write to tty */ 163 #define IEXTEN (0x200) /* implementation defined extensions */ 164 165 /* 166 * Event codes. Returned from TCWAITEVENT 167 */ 168 #define EV_RING 0x0001 169 #define EV_BREAK 0x0002 170 #define EV_CARRIER 0x0004 171 #define EV_CARRIERLOST 0x0008 172 173 /* 174 * These are ioctl identifiers to control the serial driver. 175 */ 176 #define TCGETA (0x8000) 177 #define TCSETA (TCGETA+1) 178 #define TCSETAF (TCGETA+2) 179 #define TCSETAW (TCGETA+3) 180 #define TCWAITEVENT (TCGETA+4) 181 #define TCSBRK (TCGETA+5) 182 #define TCFLSH (TCGETA+6) 183 #define TCXONC (TCGETA+7) 184 #define TCQUERYCONNECTED (TCGETA+8) 185 #define TCGETBITS (TCGETA+9) 186 #define TCSETDTR (TCGETA+10) 187 #define TCSETRTS (TCGETA+11) 188 #define TIOCGWINSZ (TCGETA+12) /* pass in a struct winsize */ 189 #define TIOCSWINSZ (TCGETA+13) /* pass in a struct winsize */ 190 #define TCVTIME (TCGETA+14) /* pass in bigtime_t, old val saved */ 191 192 /* 193 * Bits for the TCGETBITS control 194 */ 195 #define TCGB_CTS 0x01 196 #define TCGB_DSR 0x02 197 #define TCGB_RI 0x04 198 #define TCGB_DCD 0x08 199 200 201 #ifdef __cplusplus 202 extern "C" { 203 #endif 204 205 #define tcgetattr(f, t) ioctl(f, TCGETA, (char *)t) 206 207 extern speed_t cfgetispeed( const struct termios *); 208 extern speed_t cfgetospeed( const struct termios *); 209 extern int cfsetispeed( struct termios *, speed_t); 210 extern int cfsetospeed( struct termios *, speed_t); 211 extern int tcsetattr( int fd, int opt, const struct termios *tp); 212 213 /* 214 * Options to tcsetattr() 215 */ 216 #define TCSANOW 0x01 /* make change immediate */ 217 #define TCSADRAIN 0x02 /* drain output, then change */ 218 #define TCSAFLUSH 0x04 /* drain output, flush input */ 219 220 221 int tcsendbreak(int fd, int duration); 222 int tcdrain(int fd); 223 int tcflow(int fd, int action); 224 225 /* 226 * Actions for tcflow() 227 */ 228 #define TCOOFF 0x01 229 #define TCOON 0x02 230 #define TCIOFF 0x04 231 #define TCION 0x08 232 233 234 int tcflush(int fd, int queue_selector); 235 236 /* 237 * Values for "queue_selector" in tcflush() 238 */ 239 #define TCIFLUSH 0x01 240 #define TCOFLUSH 0x02 241 #define TCIOFLUSH (TCIFLUSH | TCOFLUSH) 242 243 int tcsetpgrp(int fd, pid_t pgrpid); 244 pid_t tcgetpgrp(int fd); 245 246 #ifdef __cplusplus 247 } 248 #endif 249 250 #endif /* _TERMIOS_H_ */ 251