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