xterm_io.h revision d522f475
1/* $XTermId: xterm_io.h,v 1.47 2006/02/13 01:15:00 tom Exp $ */
2
3/*
4 * $XFree86: xc/programs/xterm/xterm_io.h,v 1.20 2006/02/13 01:15:00 dickey Exp $
5 */
6
7/*
8 * Copyright 2000-2005,2006 by Thomas E. Dickey
9 *
10 *                         All Rights Reserved
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the
14 * "Software"), to deal in the Software without restriction, including
15 * without limitation the rights to use, copy, modify, merge, publish,
16 * distribute, sublicense, and/or sell copies of the Software, and to
17 * permit persons to whom the Software is furnished to do so, subject to
18 * the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included
21 * in all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26 * IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
27 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 *
31 * Except as contained in this notice, the name(s) of the above copyright
32 * holders shall not be used in advertising or otherwise to promote the
33 * sale, use or other dealings in this Software without prior written
34 * authorization.
35 */
36
37#ifndef	included_xterm_io_h
38#define	included_xterm_io_h
39
40#include <xterm.h>
41
42/*
43 * System-specific definitions (keep these chunks one-per-system!).
44 *
45 * FIXME:  some, such as those defining USE_TERMIOS should be moved to xterm.h
46 * as they are integrated with the configure script.
47 */
48#ifdef CSRG_BASED
49#define USE_TERMIOS
50#endif
51
52#ifdef __CYGWIN__
53#define ATT
54#define SVR4
55#define SYSV
56#define USE_SYSV_TERMIO
57#endif
58
59#ifdef __UNIXOS2__
60#define USE_SYSV_TERMIO
61#endif
62
63#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__INTERIX) || defined(__APPLE__) || defined(__UNIXWARE__)
64#ifndef USE_POSIX_TERMIOS
65#define USE_POSIX_TERMIOS
66#endif
67#endif
68
69#if defined(AIXV4)
70#define USE_POSIX_TERMIOS
71#ifndef SYSV
72#define SYSV
73#endif
74#endif
75
76#ifdef linux
77#define USE_TERMIOS
78#endif
79
80#ifdef __SCO__
81#define USE_TERMIOS
82#ifndef _SVID3
83#define _SVID3
84#endif
85#endif
86
87#ifdef Lynx
88#define USE_SYSV_TERMIO
89#endif
90
91#ifdef macII
92#undef SYSV			/* pretend to be bsd (sgtty.h) */
93#endif /* macII */
94
95#if defined(__GLIBC__) && !defined(linux)
96#define USE_POSIX_TERMIOS	/* GNU/Hurd, GNU/KFreeBSD and GNU/KNetBSD */
97#endif
98
99#ifdef __MVS__
100#define SVR4
101#define USE_POSIX_TERMIOS
102#endif
103
104#ifdef __QNX__
105#define USE_POSIX_TERMIOS
106#endif
107
108#if defined(__osf__)
109#define USE_POSIX_TERMIOS
110#undef SYSV
111#endif
112
113/*
114 * Indirect system dependencies
115 */
116#if defined(SVR4) && !defined(__sgi)
117#define USE_TERMIOS
118#endif
119
120#ifdef SYSV
121#define USE_SYSV_TERMIO
122#endif
123
124#if defined(USE_POSIX_TERMIOS) && !defined(USE_TERMIOS)
125#define USE_TERMIOS
126#endif
127
128/*
129 * Low-level ioctl, where it is needed or non-conflicting with termio/etc.
130 */
131#ifdef __QNX__
132#include <ioctl.h>
133#else
134#include <sys/ioctl.h>
135#endif
136
137/*
138 * Terminal I/O includes (termio, termios, sgtty headers).
139 */
140#if defined(USE_POSIX_TERMIOS)
141#include <termios.h>
142#elif defined(USE_TERMIOS)
143#include <termios.h>
144/* this hacked termios support only works on SYSV */
145#define USE_ANY_SYSV_TERMIO
146#define termio termios
147#ifndef __CYGWIN__
148#undef  TCGETA
149#define TCGETA TCGETS
150#undef  TCSETA
151#define TCSETA TCSETS
152#undef  TCSETAW
153#define TCSETAW TCSETSW
154#endif
155#elif defined(USE_SYSV_TERMIO)
156# define USE_ANY_SYSV_TERMIO
157# ifdef Lynx
158#  include <termio.h>
159# else
160#  include <sys/termio.h>
161# endif
162#elif defined(SYSV) || defined(ISC)
163# include <sys/termio.h>
164#elif !defined(VMS)
165# include <sgtty.h>
166#endif /* USE_POSIX_TERMIOS */
167
168/*
169 * Stream includes, which declare struct winsize or ttysize.
170 */
171#ifdef SYSV
172#ifdef USE_USG_PTYS
173#include <sys/stream.h>			/* get typedef used in ptem.h */
174#if !defined(SVR4) || defined(__SCO__)
175#include <sys/ptem.h>			/* get struct winsize */
176#endif
177#endif /* USE_USG_PTYS */
178#elif defined(sun) && !defined(SVR4)
179#include <sys/ttycom.h>
180#ifdef TIOCSWINSZ
181#undef TIOCSSIZE
182#endif
183#endif /* SYSV */
184
185/*
186 * Special cases (structures and definitions that have to be adjusted).
187 */
188#if defined(__CYGWIN__) && !defined(TIOCSPGRP)
189#include <termios.h>
190#define TIOCSPGRP (_IOW('t', 118, pid_t))
191#endif
192
193#ifdef __UNIXOS2__
194
195#define XFREE86_PTY	0x76
196
197#define XTY_TIOCSETA	0x48
198#define XTY_TIOCSETAW	0x49
199#define XTY_TIOCSETAF	0x4a
200#define XTY_TIOCCONS	0x4d
201#define XTY_TIOCSWINSZ	0x53
202#define XTY_ENADUP	0x5a
203#define XTY_TRACE	0x5b
204#define XTY_TIOCGETA	0x65
205#define XTY_TIOCGWINSZ	0x66
206#define PTMS_GETPTY	0x64
207#define PTMS_BUFSZ	14
208
209#ifndef NCCS
210#define NCCS 11
211#endif
212
213#define TIOCCONS	108
214#define TIOCSWINSZ	113
215#define TIOCGWINSZ	117
216
217struct pt_termios
218{
219        unsigned short  c_iflag;
220        unsigned short  c_oflag;
221        unsigned short  c_cflag;
222        unsigned short  c_lflag;
223        unsigned char   c_cc[NCCS];
224        long            _reserved_[4];
225};
226
227struct winsize {
228	unsigned short	ws_row;		/* rows, in characters */
229	unsigned short	ws_col;		/* columns, in characters */
230	unsigned short	ws_xpixel;	/* horizontal size, pixels */
231	unsigned short	ws_ypixel;	/* vertical size, pixels */
232};
233#define TTYSIZE_STRUCT struct winsize
234#define USE_STRUCT_WINSIZE 1
235
236#ifdef XTERM_MAIN
237extern int ptioctl(int fd, int func, void* data);
238#define ioctl ptioctl
239#endif
240
241#endif /* __UNIXOS2__ */
242
243#ifdef __hpux
244#include <sys/bsdtty.h>		/* defines TIOCSLTC */
245#endif
246
247#ifdef ISC
248#define TIOCGPGRP TCGETPGRP
249#define TIOCSPGRP TCSETPGRP
250#endif
251
252#ifdef Lynx
253#include <resource.h>
254#elif !(defined(SYSV) || defined(linux) || defined(VMS) || (defined(__QNX__)&&!defined(__QNXNTO__)))
255#include <sys/resource.h>
256#endif
257
258#ifdef macII
259#undef FIOCLEX
260#undef FIONCLEX
261#endif /* macII */
262
263#ifdef __QNX__
264#undef TIOCSLTC			/* <sgtty.h> conflicts with <termios.h> */
265#undef TIOCLSET
266#endif
267
268#if defined(__sgi) && (OSMAJORVERSION >= 5)
269#undef TIOCLSET				/* defined, but not useable */
270#endif
271
272#if defined(__GNU__) || defined(__MVS__) || defined(__osf__)
273#undef TIOCLSET
274#undef TIOCSLTC
275#endif
276
277#if defined (__sgi) || (defined(__linux__) && defined(__sparc__)) || defined(__UNIXWARE__)
278#undef TIOCLSET /* XXX why is this undef-ed again? */
279#endif
280
281#if defined(sun) || defined(__UNIXWARE__)
282#include <sys/filio.h>
283#endif
284
285#if defined(TIOCSLTC) && ! (defined(linux) || defined(__MVS__) || defined(Lynx) || defined(SVR4))
286#define HAS_LTCHARS
287#endif
288
289#if !defined(TTYSIZE_STRUCT)
290#if defined(TIOCSSIZE) && (defined(sun) && !defined(SVR4))
291#define USE_STRUCT_TTYSIZE 1
292#define TTYSIZE_STRUCT struct ttysize
293#elif defined(TIOCSWINSZ)
294#define USE_STRUCT_WINSIZE 1
295#define TTYSIZE_STRUCT struct winsize
296#endif /* sun vs TIOCSWINSZ */
297#endif /* TTYSIZE_STRUCT */
298
299#if defined(USE_STRUCT_TTYSIZE)
300#define TTYSIZE_STRUCT struct ttysize
301#define SET_TTYSIZE(fd, data) ioctl(fd, TIOCSSIZE, &data);
302#define TTYSIZE_COLS(data) data.ts_cols
303#define TTYSIZE_ROWS(data) data.ts_lines
304#elif defined(USE_STRUCT_WINSIZE)
305#define TTYSIZE_STRUCT struct winsize
306#define SET_TTYSIZE(fd, data) ioctl(fd, TIOCSWINSZ, (char *) &data)
307#define TTYSIZE_COLS(data) data.ws_col
308#define TTYSIZE_ROWS(data) data.ws_row
309#endif
310
311#endif	/* included_xterm_io_h */
312