2 * Copyright 2004-2012 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
12 typedef __haiku_uint32 tcflag_t
;
13 typedef unsigned char speed_t
;
14 typedef unsigned char cc_t
;
16 #define NCCS 11 /* number of control characters */
19 tcflag_t c_iflag
; /* input modes */
20 tcflag_t c_oflag
; /* output modes */
21 tcflag_t c_cflag
; /* control modes */
22 tcflag_t c_lflag
; /* local modes */
23 char c_line
; /* line discipline */
24 speed_t c_ispeed
; /* custom input baudrate */
25 speed_t c_ospeed
; /* custom output baudrate */
26 cc_t c_cc
[NCCS
]; /* control characters */
29 /* control characters */
44 /* c_iflag - input control modes */
45 #define IGNBRK 0x01 /* ignore break condition */
46 #define BRKINT 0x02 /* break sends interrupt */
47 #define IGNPAR 0x04 /* ignore characters with parity errors */
48 #define PARMRK 0x08 /* mark parity errors */
49 #define INPCK 0x10 /* enable input parity checking */
50 #define ISTRIP 0x20 /* strip high bit from characters */
51 #define INLCR 0x40 /* maps newline to CR on input */
52 #define IGNCR 0x80 /* ignore carriage returns */
53 #define ICRNL 0x100 /* map CR to newline on input */
54 #define IUCLC 0x200 /* map all upper case to lower */
55 #define IXON 0x400 /* enable input SW flow control */
56 #define IXANY 0x800 /* any character will restart input */
57 #define IXOFF 0x1000 /* enable output SW flow control */
59 /* c_oflag - output control modes */
60 #define OPOST 0x01 /* enable postprocessing of output */
61 #define OLCUC 0x02 /* map lowercase to uppercase */
62 #define ONLCR 0x04 /* map NL to CR-NL on output */
63 #define OCRNL 0x08 /* map CR to NL on output */
64 #define ONOCR 0x10 /* no CR output when at column 0 */
65 #define ONLRET 0x20 /* newline performs CR function */
66 #define OFILL 0x40 /* use fill characters for delays */
67 #define OFDEL 0x80 /* Fills are DEL, otherwise NUL */
68 #define NLDLY 0x100 /* Newline delays: */
71 #define CRDLY 0x600 /* Carriage return delays: */
76 #define TABDLY 0x1800 /* Tab delays: */
81 #define BSDLY 0x2000 /* Backspace delays: */
84 #define VTDLY 0x4000 /* Vertical tab delays: */
87 #define FFDLY 0x8000 /* Form feed delays: */
91 /* c_cflag - control modes */
92 #define CBAUD 0x1F /* line speed definitions */
94 #define B0 0x00 /* hang up */
95 #define B50 0x01 /* 50 baud */
113 #define B31250 0x13 /* for MIDI */
115 #define CSIZE 0x20 /* character size */
116 #define CS5 0x00 /* only 7 and 8 bits supported */
117 #define CS6 0x00 /* Note, it was not very wise to set all of these */
118 #define CS7 0x00 /* to zero, but there is not much we can do about it*/
120 #define CSTOPB 0x40 /* send 2 stop bits, not 1 */
121 #define CREAD 0x80 /* enable receiver */
122 #define PARENB 0x100 /* parity enable */
123 #define PARODD 0x200 /* odd parity, else even */
124 #define HUPCL 0x400 /* hangs up on last close */
125 #define CLOCAL 0x800 /* indicates local line */
126 #define XLOBLK 0x1000 /* block layer output ?*/
127 #define CTSFLOW 0x2000 /* enable CTS flow */
128 #define RTSFLOW 0x4000 /* enable RTS flow */
129 #define CRTSCTS (RTSFLOW | CTSFLOW)
131 /* c_lflag - local modes */
132 #define ISIG 0x01 /* enable signals */
133 #define ICANON 0x02 /* Canonical input */
134 #define XCASE 0x04 /* Canonical u/l case */
135 #define ECHO 0x08 /* Enable echo */
136 #define ECHOE 0x10 /* Echo erase as bs-sp-bs */
137 #define ECHOK 0x20 /* Echo nl after kill */
138 #define ECHONL 0x40 /* Echo nl */
139 #define NOFLSH 0x80 /* Disable flush after int or quit */
140 #define TOSTOP 0x100 /* stop bg processes that write to tty */
141 #define IEXTEN 0x200 /* implementation defined extensions */
142 #define ECHOCTL 0x400
143 #define ECHOPRT 0x800
144 #define ECHOKE 0x1000
145 #define FLUSHO 0x2000
146 #define PENDIN 0x4000
148 /* options to tcsetattr() */
149 #define TCSANOW 0x01 /* make change immediate */
150 #define TCSADRAIN 0x02 /* drain output, then change */
151 #define TCSAFLUSH 0x04 /* drain output, flush input */
153 /* actions for tcflow() */
154 #define TCOOFF 0x01 /* suspend output */
155 #define TCOON 0x02 /* restart output */
156 #define TCIOFF 0x04 /* transmit STOP character, intended to stop input data */
157 #define TCION 0x08 /* transmit START character, intended to resume input data */
159 /* values for tcflush() */
160 #define TCIFLUSH 0x01 /* flush pending input */
161 #define TCOFLUSH 0x02 /* flush untransmitted output */
162 #define TCIOFLUSH 0x03 /* flush both */
165 /* ioctl() identifiers to control the TTY */
166 #define TCGETA 0x8000
167 #define TCSETA (TCGETA + 1)
168 #define TCSETAF (TCGETA + 2)
169 #define TCSETAW (TCGETA + 3)
170 #define TCWAITEVENT (TCGETA + 4)
171 #define TCSBRK (TCGETA + 5)
172 #define TCFLSH (TCGETA + 6)
173 #define TCXONC (TCGETA + 7)
174 #define TCQUERYCONNECTED (TCGETA + 8)
175 #define TCGETBITS (TCGETA + 9)
176 #define TCSETDTR (TCGETA + 10)
177 #define TCSETRTS (TCGETA + 11)
178 #define TIOCGWINSZ (TCGETA + 12) /* pass in a struct winsize */
179 #define TIOCSWINSZ (TCGETA + 13) /* pass in a struct winsize */
180 #define TCVTIME (TCGETA + 14) /* pass in bigtime_t, old value saved */
181 #define TIOCGPGRP (TCGETA + 15) /* Gets the process group ID of the TTY device */
182 #define TIOCSPGRP (TCGETA + 16) /* Sets the process group ID ('pgid' in BeOS) */
183 #define TIOCSCTTY (TCGETA + 17) /* Become controlling TTY */
184 #define TIOCMGET (TCGETA + 18) /* get line state, like TCGETBITS */
185 #define TIOCMSET (TCGETA + 19) /* does TCSETDTR/TCSETRTS */
186 #define TIOCSBRK (TCGETA + 20) /* set txd pin */
187 #define TIOCCBRK (TCGETA + 21) /* both are a frontend to TCSBRK */
188 #define TIOCMBIS (TCGETA + 22) /* set bits in line state */
189 #define TIOCMBIC (TCGETA + 23) /* clear bits in line state */
191 /* Event codes. Returned from TCWAITEVENT */
192 #define EV_RING 0x0001
193 #define EV_BREAK 0x0002
194 #define EV_CARRIER 0x0004
195 #define EV_CARRIERLOST 0x0008
199 unsigned short ws_row
;
200 unsigned short ws_col
;
201 unsigned short ws_xpixel
;
202 unsigned short ws_ypixel
;
205 /* Bits for the TCGETBITS control */
206 #define TCGB_CTS 0x01
207 #define TCGB_DSR 0x02
209 #define TCGB_DCD 0x08
211 /* Bits for the TIOCMGET / TIOCMSET control */
212 #define TIOCM_CTS TCGB_CTS /* clear to send */
213 #define TIOCM_CD TCGB_DCD /* carrier detect */
214 #define TIOCM_CAR TIOCM_CD
215 #define TIOCM_RI TCGB_RI /* ring indicator */
216 #define TIOCM_DSR TCGB_DSR /* dataset ready */
217 #define TIOCM_DTR 0x10 /* data terminal ready */
218 #define TIOCM_RTS 0x20 /* request to send */
225 extern speed_t
cfgetispeed(const struct termios
*termios
);
226 extern speed_t
cfgetospeed(const struct termios
*termios
);
227 extern int cfsetispeed(struct termios
*termios
, speed_t speed
);
228 extern int cfsetospeed(struct termios
*termios
, speed_t speed
);
229 extern void cfmakeraw(struct termios
*termios
);
230 extern int tcgetattr(int fd
, struct termios
*termios
);
231 extern int tcsetattr(int fd
, int option
, const struct termios
*termios
);
232 extern int tcsendbreak(int fd
, int duration
);
233 extern int tcdrain(int fd
);
234 extern int tcflow(int fd
, int action
);
235 extern int tcflush(int fd
, int queueSelector
);
241 #endif /* _TERMIOS_H_ */