Annotation of prex/include/sys/termios.h, Revision 1.1.1.1
1.1 nbrk 1: /*
2: * Copyright (c) 1988, 1989, 1993, 1994
3: * The Regents of the University of California. All rights reserved.
4: *
5: * Redistribution and use in source and binary forms, with or without
6: * modification, are permitted provided that the following conditions
7: * are met:
8: * 1. Redistributions of source code must retain the above copyright
9: * notice, this list of conditions and the following disclaimer.
10: * 2. Redistributions in binary form must reproduce the above copyright
11: * notice, this list of conditions and the following disclaimer in the
12: * documentation and/or other materials provided with the distribution.
13: * 3. Neither the name of the University nor the names of its contributors
14: * may be used to endorse or promote products derived from this software
15: * without specific prior written permission.
16: *
17: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27: * SUCH DAMAGE.
28: *
29: * @(#)termios.h 8.3 (Berkeley) 3/28/94
30: */
31:
32: #ifndef _SYS_TERMIOS_H_
33: #define _SYS_TERMIOS_H_
34:
35: #include <sys/ioctl.h>
36:
37: /*
38: * Special Control Characters
39: *
40: * Index into c_cc[] character array.
41: *
42: * Name Subscript Enabled by
43: */
44: #define VEOF 0 /* ICANON */
45: #define VEOL 1 /* ICANON */
46: #define VEOL2 2 /* ICANON */
47: #define VERASE 3 /* ICANON */
48: #define VWERASE 4 /* ICANON */
49: #define VKILL 5 /* ICANON */
50: #define VREPRINT 6 /* ICANON */
51: /* 7 spare 1 */
52: #define VINTR 8 /* ISIG */
53: #define VQUIT 9 /* ISIG */
54: #define VSUSP 10 /* ISIG */
55: #define VDSUSP 11 /* ISIG */
56: #define VSTART 12 /* IXON, IXOFF */
57: #define VSTOP 13 /* IXON, IXOFF */
58: #define VLNEXT 14 /* IEXTEN */
59: #define VDISCARD 15 /* IEXTEN */
60: #define VMIN 16 /* !ICANON */
61: #define VTIME 17 /* !ICANON */
62: #define VSTATUS 18 /* ICANON */
63: /* 19 spare 2 */
64: #define NCCS 20
65:
66: #define _POSIX_VDISABLE ((unsigned char)'\377')
67:
68: #define CCEQ(val, c) (c == val ? val != _POSIX_VDISABLE : 0)
69:
70: /*
71: * Input flags - software input processing
72: */
73: #define IGNBRK 0x00000001 /* ignore BREAK condition */
74: #define BRKINT 0x00000002 /* map BREAK to SIGINTR */
75: #define IGNPAR 0x00000004 /* ignore (discard) parity errors */
76: #define PARMRK 0x00000008 /* mark parity and framing errors */
77: #define INPCK 0x00000010 /* enable checking of parity errors */
78: #define ISTRIP 0x00000020 /* strip 8th bit off chars */
79: #define INLCR 0x00000040 /* map NL into CR */
80: #define IGNCR 0x00000080 /* ignore CR */
81: #define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */
82: #define IXON 0x00000200 /* enable output flow control */
83: #define IXOFF 0x00000400 /* enable input flow control */
84: #define IXANY 0x00000800 /* any char will restart after stop */
85: #define IMAXBEL 0x00002000 /* ring bell on input queue full */
86:
87: /*
88: * Output flags - software output processing
89: */
90: #define OPOST 0x00000001 /* enable following output processing */
91: #define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */
92: #define OXTABS 0x00000004 /* expand tabs to spaces */
93: #define ONOEOT 0x00000008 /* discard EOT's (^D) on output) */
94:
95: /*
96: * Control flags - hardware control of terminal
97: */
98: #define CIGNORE 0x00000001 /* ignore control flags */
99: #define CSIZE 0x00000300 /* character size mask */
100: #define CS5 0x00000000 /* 5 bits (pseudo) */
101: #define CS6 0x00000100 /* 6 bits */
102: #define CS7 0x00000200 /* 7 bits */
103: #define CS8 0x00000300 /* 8 bits */
104: #define CSTOPB 0x00000400 /* send 2 stop bits */
105: #define CREAD 0x00000800 /* enable receiver */
106: #define PARENB 0x00001000 /* parity enable */
107: #define PARODD 0x00002000 /* odd parity, else even */
108: #define HUPCL 0x00004000 /* hang up on last close */
109: #define CLOCAL 0x00008000 /* ignore modem status lines */
110: #define CCTS_OFLOW 0x00010000 /* CTS flow control of output */
111: #define CRTSCTS CCTS_OFLOW /* ??? */
112: #define CRTS_IFLOW 0x00020000 /* RTS flow control of input */
113: #define MDMBUF 0x00100000 /* flow control output via Carrier */
114:
115:
116: /*
117: * "Local" flags - dumping ground for other state
118: *
119: * Warning: some flags in this structure begin with
120: * the letter "I" and look like they belong in the
121: * input flag.
122: */
123:
124: #ifndef _POSIX_SOURCE
125: #define ECHOKE 0x00000001 /* visual erase for line kill */
126: #endif /*_POSIX_SOURCE */
127: #define ECHOE 0x00000002 /* visually erase chars */
128: #define ECHOK 0x00000004 /* echo NL after line kill */
129: #define ECHO 0x00000008 /* enable echoing */
130: #define ECHONL 0x00000010 /* echo NL even if ECHO is off */
131: #ifndef _POSIX_SOURCE
132: #define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */
133: #define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */
134: #endif /*_POSIX_SOURCE */
135: #define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */
136: #define ICANON 0x00000100 /* canonicalize input lines */
137: #ifndef _POSIX_SOURCE
138: #define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */
139: #endif /*_POSIX_SOURCE */
140: #define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */
141: #define EXTPROC 0x00000800 /* external processing */
142: #define TOSTOP 0x00400000 /* stop background jobs from output */
143: #ifndef _POSIX_SOURCE
144: #define FLUSHO 0x00800000 /* output being flushed (state) */
145: #define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */
146: #define PENDIN 0x20000000 /* XXX retype pending input (state) */
147: #endif /*_POSIX_SOURCE */
148: #define NOFLSH 0x80000000 /* don't flush after interrupt */
149:
150: typedef unsigned long tcflag_t;
151: typedef unsigned char cc_t;
152: typedef long speed_t;
153:
154: struct termios {
155: tcflag_t c_iflag; /* input flags */
156: tcflag_t c_oflag; /* output flags */
157: tcflag_t c_cflag; /* control flags */
158: tcflag_t c_lflag; /* local flags */
159: cc_t c_cc[NCCS]; /* control chars */
160: long c_ispeed; /* input speed */
161: long c_ospeed; /* output speed */
162: };
163:
164: /*
165: * Commands passed to tcsetattr() for setting the termios structure.
166: */
167: #define TCSANOW 0 /* make change immediate */
168: #define TCSADRAIN 1 /* drain output, then change */
169: #define TCSAFLUSH 2 /* drain output, flush input */
170: #ifndef _POSIX_SOURCE
171: #define TCSASOFT 0x10 /* flag - don't alter h.w. state */
172: #endif
173:
174: /*
175: * Standard speeds
176: */
177: #define B0 0
178: #define B50 50
179: #define B75 75
180: #define B110 110
181: #define B134 134
182: #define B150 150
183: #define B200 200
184: #define B300 300
185: #define B600 600
186: #define B1200 1200
187: #define B1800 1800
188: #define B2400 2400
189: #define B4800 4800
190: #define B9600 9600
191: #define B19200 19200
192: #define B38400 38400
193:
194: #ifndef KERNEL
195:
196: #define TCIFLUSH 1
197: #define TCOFLUSH 2
198: #define TCIOFLUSH 3
199: #define TCOOFF 1
200: #define TCOON 2
201: #define TCIOFF 3
202: #define TCION 4
203:
204: #include <sys/cdefs.h>
205:
206: __BEGIN_DECLS
207: speed_t cfgetispeed(const struct termios *);
208: speed_t cfgetospeed(const struct termios *);
209: int cfsetispeed(struct termios *, speed_t);
210: int cfsetospeed(struct termios *, speed_t);
211: int tcgetattr(int, struct termios *);
212: int tcsetattr(int, int, const struct termios *);
213: int tcdrain(int);
214: int tcflow(int, int);
215: int tcflush(int, int);
216: int tcsendbreak(int, int);
217:
218: #ifndef _POSIX_SOURCE
219: void cfmakeraw(struct termios *);
220: int cfsetspeed(struct termios *, speed_t);
221: #endif /* !_POSIX_SOURCE */
222: __END_DECLS
223:
224: #endif /* !KERNEL */
225:
226:
227: /*
228: * Tty ioctl's except for those supported only for backwards compatibility
229: * with the old tty driver.
230: */
231:
232: /*
233: * Window/terminal size structure. This information is stored by the kernel
234: * in order to provide a consistent interface, but is not used by the kernel.
235: */
236: struct winsize {
237: unsigned short ws_row; /* rows, in characters */
238: unsigned short ws_col; /* columns, in characters */
239: unsigned short ws_xpixel; /* horizontal size, pixels */
240: unsigned short ws_ypixel; /* vertical size, pixels */
241: };
242:
243: #define TIOCMODG _IOR('t', 3, int) /* get modem control state */
244: #define TIOCMODS _IOW('t', 4, int) /* set modem control state */
245: #define TIOCM_LE 0001 /* line enable */
246: #define TIOCM_DTR 0002 /* data terminal ready */
247: #define TIOCM_RTS 0004 /* request to send */
248: #define TIOCM_ST 0010 /* secondary transmit */
249: #define TIOCM_SR 0020 /* secondary receive */
250: #define TIOCM_CTS 0040 /* clear to send */
251: #define TIOCM_CAR 0100 /* carrier detect */
252: #define TIOCM_CD TIOCM_CAR
253: #define TIOCM_RNG 0200 /* ring */
254: #define TIOCM_RI TIOCM_RNG
255: #define TIOCM_DSR 0400 /* data set ready */
256: /* 8-10 compat */
257: #define TIOCEXCL _IO('t', 13) /* set exclusive use of tty */
258: #define TIOCNXCL _IO('t', 14) /* reset exclusive use of tty */
259: /* 15 unused */
260: #define TIOCFLUSH _IOW('t', 16, int) /* flush buffers */
261: /* 17-18 compat */
262: #define TIOCGETA _IOR('t', 19, struct termios) /* get termios struct */
263: #define TIOCSETA _IOW('t', 20, struct termios) /* set termios struct */
264: #define TIOCSETAW _IOW('t', 21, struct termios) /* drain output, set */
265: #define TIOCSETAF _IOW('t', 22, struct termios) /* drn out, fls in, set */
266: #define TIOCGETD _IOR('t', 26, int) /* get line discipline */
267: #define TIOCSETD _IOW('t', 27, int) /* set line discipline */
268: /* 127-124 compat */
269: #define TIOCSBRK _IO('t', 123) /* set break bit */
270: #define TIOCCBRK _IO('t', 122) /* clear break bit */
271: #define TIOCSDTR _IO('t', 121) /* set data terminal ready */
272: #define TIOCCDTR _IO('t', 120) /* clear data terminal ready */
273: #define TIOCGPGRP _IOR('t', 119, int) /* get pgrp of tty */
274: #define TIOCSPGRP _IOW('t', 118, int) /* set pgrp of tty */
275: /* 117-116 compat */
276: #define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
277: #define TIOCSTI _IOW('t', 114, char) /* simulate terminal input */
278: #define TIOCNOTTY _IO('t', 113) /* void tty association */
279: #define TIOCPKT _IOW('t', 112, int) /* pty: set/clear packet mode */
280: #define TIOCPKT_DATA 0x00 /* data packet */
281: #define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
282: #define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
283: #define TIOCPKT_STOP 0x04 /* stop output */
284: #define TIOCPKT_START 0x08 /* start output */
285: #define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
286: #define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
287: #define TIOCPKT_IOCTL 0x40 /* state change of pty driver */
288: #define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
289: #define TIOCSTART _IO('t', 110) /* start output, like ^Q */
290: #define TIOCMSET _IOW('t', 109, int) /* set all modem bits */
291: #define TIOCMBIS _IOW('t', 108, int) /* bis modem bits */
292: #define TIOCMBIC _IOW('t', 107, int) /* bic modem bits */
293: #define TIOCMGET _IOR('t', 106, int) /* get all modem bits */
294: #define TIOCREMOTE _IOW('t', 105, int) /* remote input editing */
295: #define TIOCGWINSZ _IOR('t', 104, struct winsize) /* get window size */
296: #define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */
297: #define TIOCUCNTL _IOW('t', 102, int) /* pty: set/clr usr cntl mode */
298: #define UIOCCMD(n) _IO('u', n) /* usr cntl op "n" */
299: #define TIOCCONS _IOW('t', 98, int) /* become virtual console */
300: #define TIOCSCTTY _IO('t', 97) /* become controlling tty */
301: #define TIOCEXT _IOW('t', 96, int) /* pty: external processing */
302: #define TIOCSIG _IO('t', 95) /* pty: generate signal */
303: #define TIOCDRAIN _IO('t', 94) /* wait till output drained */
304:
305: #define TTYDISC 0 /* termios tty line discipline */
306: #define TABLDISC 3 /* tablet discipline */
307: #define SLIPDISC 4 /* serial IP discipline */
308:
309: #define TIOCSETSIGT _IOW('t', 200, int) /* set signal task */
310:
311:
312: /*
313: * Defaults on "first" open.
314: */
315: #define TTYDEF_IFLAG (tcflag_t)(BRKINT | ICRNL | IXON | IXANY)
316: #define TTYDEF_OFLAG (tcflag_t)(OPOST | ONLCR | OXTABS)
317: #define TTYDEF_LFLAG (tcflag_t)(ECHO | ICANON | ISIG | ECHOE|ECHOK|ECHONL)
318: #define TTYDEF_CFLAG (tcflag_t)(CREAD | CS8 | HUPCL)
319: #define TTYDEF_SPEED (B9600)
320:
321: /*
322: * Control Character Defaults
323: */
324: #define CTRL(x) (cc_t)(x&037)
325: #define CEOF CTRL('d')
326: #define CEOL ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
327: #define CERASE 0177
328: #define CINTR CTRL('c')
329: #define CSTATUS ((unsigned char)'\377') /* XXX avoid _POSIX_VDISABLE */
330: #define CKILL CTRL('u')
331: #define CMIN 1
332: #define CQUIT 034 /* FS, ^\ */
333: #define CSUSP CTRL('z')
334: #define CTIME 0
335: #define CDSUSP CTRL('y')
336: #define CSTART CTRL('q')
337: #define CSTOP CTRL('s')
338: #define CLNEXT CTRL('v')
339: #define CDISCARD CTRL('o')
340: #define CWERASE CTRL('w')
341: #define CREPRINT CTRL('r')
342: #define CEOT CEOF
343: /* compat */
344: #define CBRK CEOL
345: #define CRPRNT CREPRINT
346: #define CFLUSH CDISCARD
347:
348: #ifdef KERNEL
349: /*
350: * #define TTYDEFCHARS to include an array of default control characters.
351: */
352: #define TTYDEFCHARS \
353: { \
354: CEOF, CEOL, CEOL, CERASE, CWERASE, CKILL, CREPRINT, \
355: _POSIX_VDISABLE, CINTR, CQUIT, CSUSP, CDSUSP, CSTART, CSTOP, CLNEXT, \
356: CDISCARD, CMIN, CTIME, CSTATUS, _POSIX_VDISABLE \
357: }
358: #endif /* KERNEL */
359:
360: /*
361: * END OF PROTECTED INCLUDE.
362: */
363: #endif /* !_SYS_TERMIOS_H_ */
CVSweb