1 /* $XTermId: xterm_io.h,v 1.50 2010/05/23 16:04:32 tom Exp $ */
4 * Copyright 2000-2006,2010 by Thomas E. Dickey
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
23 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Except as contained in this notice, the name(s) of the above copyright
28 * holders shall not be used in advertising or otherwise to promote the
29 * sale, use or other dealings in this Software without prior written
33 #ifndef included_xterm_io_h
34 #define included_xterm_io_h
39 * System-specific definitions (keep these chunks one-per-system!).
41 * FIXME: some, such as those defining USE_TERMIOS should be moved to xterm.h
42 * as they are integrated with the configure script.
52 #define USE_SYSV_TERMIO
56 #define USE_SYSV_TERMIO
59 #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__INTERIX) || defined(__APPLE__) || defined(__UNIXWARE__)
60 #ifndef USE_POSIX_TERMIOS
61 #define USE_POSIX_TERMIOS
66 #define USE_POSIX_TERMIOS
84 #define USE_SYSV_TERMIO
88 #undef SYSV /* pretend to be bsd (sgtty.h) */
91 #if defined(__GLIBC__) && !defined(linux)
92 #define USE_POSIX_TERMIOS /* GNU/Hurd, GNU/KFreeBSD and GNU/KNetBSD */
97 #define USE_POSIX_TERMIOS
101 #define USE_POSIX_TERMIOS
105 #define USE_POSIX_TERMIOS
110 * Indirect system dependencies
112 #if defined(SVR4) && !defined(__sgi)
117 #define USE_SYSV_TERMIO
120 #if defined(USE_POSIX_TERMIOS) && !defined(USE_TERMIOS)
125 * Low-level ioctl, where it is needed or non-conflicting with termio/etc.
130 #include <sys/ioctl.h>
134 * Terminal I/O includes (termio, termios, sgtty headers).
136 #if defined(USE_POSIX_TERMIOS)
138 #elif defined(USE_TERMIOS)
140 /* this hacked termios support only works on SYSV */
141 #define USE_ANY_SYSV_TERMIO
142 #define termio termios
145 #define TCGETA TCGETS
147 #define TCSETA TCSETS
149 #define TCSETAW TCSETSW
151 #elif defined(USE_SYSV_TERMIO)
152 # define USE_ANY_SYSV_TERMIO
156 # include <sys/termio.h>
158 #elif defined(SYSV) || defined(ISC)
159 # include <sys/termio.h>
162 #endif /* USE_POSIX_TERMIOS */
165 * Stream includes, which declare struct winsize or ttysize.
169 #include <sys/stream.h> /* get typedef used in ptem.h */
170 #if !defined(SVR4) || defined(__SCO__)
171 #include <sys/ptem.h> /* get struct winsize */
173 #endif /* USE_USG_PTYS */
174 #elif defined(sun) && !defined(SVR4)
175 #include <sys/ttycom.h>
182 * Special cases (structures and definitions that have to be adjusted).
184 #if defined(__CYGWIN__) && !defined(TIOCSPGRP)
186 #define TIOCSPGRP (_IOW('t', 118, pid_t))
191 #define XFREE86_PTY 0x76
193 #define XTY_TIOCSETA 0x48
194 #define XTY_TIOCSETAW 0x49
195 #define XTY_TIOCSETAF 0x4a
196 #define XTY_TIOCCONS 0x4d
197 #define XTY_TIOCSWINSZ 0x53
198 #define XTY_ENADUP 0x5a
199 #define XTY_TRACE 0x5b
200 #define XTY_TIOCGETA 0x65
201 #define XTY_TIOCGWINSZ 0x66
202 #define PTMS_GETPTY 0x64
203 #define PTMS_BUFSZ 14
210 #define TIOCSWINSZ 113
211 #define TIOCGWINSZ 117
215 unsigned short c_iflag;
216 unsigned short c_oflag;
217 unsigned short c_cflag;
218 unsigned short c_lflag;
219 unsigned char c_cc[NCCS];
224 unsigned short ws_row; /* rows, in characters */
225 unsigned short ws_col; /* columns, in characters */
226 unsigned short ws_xpixel; /* horizontal size, pixels */
227 unsigned short ws_ypixel; /* vertical size, pixels */
229 #define TTYSIZE_STRUCT struct winsize
230 #define USE_STRUCT_WINSIZE 1
233 extern int ptioctl(int fd, int func, void* data);
234 #define ioctl ptioctl
237 #endif /* __UNIXOS2__ */
240 #include <sys/bsdtty.h> /* defines TIOCSLTC */
244 #define TIOCGPGRP TCGETPGRP
245 #define TIOCSPGRP TCSETPGRP
249 #include <resource.h>
250 #elif !(defined(SYSV) || defined(linux) || defined(VMS) || (defined(__QNX__)&&!defined(__QNXNTO__)))
251 #include <sys/resource.h>
260 #undef TIOCSLTC /* <sgtty.h> conflicts with <termios.h> */
264 #if defined(__sgi) && (OSMAJORVERSION >= 5)
265 #undef TIOCLSET /* defined, but not useable */
268 #if defined(__GNU__) || defined(__MVS__) || defined(__osf__)
273 #if defined (__sgi) || (defined(__linux__) && defined(__sparc__)) || defined(__UNIXWARE__)
274 #undef TIOCLSET /* XXX why is this undef-ed again? */
277 #if defined(sun) || defined(__UNIXWARE__)
278 #include <sys/filio.h>
281 #if defined(TIOCSLTC) && ! (defined(linux) || defined(__MVS__) || defined(Lynx) || defined(SVR4))
285 #if !defined(TTYSIZE_STRUCT)
286 #if defined(TIOCSSIZE) && (defined(sun) && !defined(SVR4))
287 #define USE_STRUCT_TTYSIZE 1
288 #define TTYSIZE_STRUCT struct ttysize
289 #elif defined(TIOCSWINSZ)
290 #define USE_STRUCT_WINSIZE 1
291 #define TTYSIZE_STRUCT struct winsize
292 #endif /* sun vs TIOCSWINSZ */
293 #endif /* TTYSIZE_STRUCT */
295 #if defined(USE_STRUCT_TTYSIZE)
296 #define TTYSIZE_STRUCT struct ttysize
297 #define SET_TTYSIZE(fd, data) ioctl(fd, TIOCSSIZE, &data);
298 #define TTYSIZE_COLS(data) data.ts_cols
299 #define TTYSIZE_ROWS(data) data.ts_lines
300 #elif defined(USE_STRUCT_WINSIZE)
301 #define TTYSIZE_STRUCT struct winsize
302 #define SET_TTYSIZE(fd, data) ioctl(fd, TIOCSWINSZ, (char *) &data)
303 #define TTYSIZE_COLS(data) data.ws_col
304 #define TTYSIZE_ROWS(data) data.ws_row
307 typedef unsigned short ttySize_t;
309 #endif /* included_xterm_io_h */