xterm_io.h revision 01037d57
1/* $XTermId: xterm_io.h,v 1.58 2014/07/25 08:26:56 tom Exp $ */ 2 3/* 4 * Copyright 2000-2013,2014 by Thomas E. Dickey 5 * 6 * All Rights Reserved 7 * 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: 15 * 16 * The above copyright notice and this permission notice shall be included 17 * in all copies or substantial portions of the Software. 18 * 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. 26 * 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 30 * authorization. 31 */ 32 33#ifndef included_xterm_io_h 34#define included_xterm_io_h 35 36#include <xterm.h> 37 38/* 39 * System-specific definitions (keep these chunks one-per-system!). 40 * 41 * FIXME: some, such as those defining USE_TERMIOS should be moved to xterm.h 42 * as they are integrated with the configure script. 43 */ 44#if defined(__minix) 45#define USE_POSIX_TERMIOS 1 46#undef HAVE_POSIX_OPENPT /* present, does not work */ 47#endif 48 49#ifdef CSRG_BASED 50#define USE_TERMIOS 51#endif 52 53#ifdef __CYGWIN__ 54#define ATT 55#define SVR4 56#define SYSV 57#define USE_SYSV_TERMIO 58#endif 59 60#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__INTERIX) || defined(__APPLE__) || defined(__UNIXWARE__) || defined(__hpux) 61#ifndef USE_POSIX_TERMIOS 62#define USE_POSIX_TERMIOS 63#endif 64#endif 65 66#if defined(AIXV4) 67#define USE_POSIX_TERMIOS 68#ifndef SYSV 69#define SYSV 70#endif 71#endif 72 73#ifdef linux 74#define USE_TERMIOS 75#endif 76 77#ifdef __SCO__ 78#define USE_TERMIOS 79#ifndef _SVID3 80#define _SVID3 81#endif 82#endif 83 84#ifdef Lynx 85#define USE_SYSV_TERMIO 86#endif 87 88#ifdef macII 89#undef SYSV /* pretend to be bsd (sgtty.h) */ 90#endif /* macII */ 91 92#if defined(__GLIBC__) && !defined(linux) 93#define USE_POSIX_TERMIOS /* GNU/Hurd, GNU/KFreeBSD and GNU/KNetBSD */ 94#endif 95 96#ifdef __MVS__ 97#define SVR4 98#define USE_POSIX_TERMIOS 99#endif 100 101#ifdef __QNX__ 102#define USE_POSIX_TERMIOS 103#endif 104 105#if defined(__osf__) 106#define USE_POSIX_TERMIOS 107#undef SYSV 108#endif 109 110/* 111 * Indirect system dependencies 112 */ 113#if defined(SVR4) && !defined(__sgi) 114#define USE_TERMIOS 115#endif 116 117#ifdef SYSV 118#define USE_SYSV_TERMIO 119#endif 120 121#if defined(USE_POSIX_TERMIOS) && !defined(USE_TERMIOS) 122#define USE_TERMIOS 123#endif 124 125/* 126 * Low-level ioctl, where it is needed or non-conflicting with termio/etc. 127 */ 128#ifdef __QNX__ 129#include <ioctl.h> 130#else 131#include <sys/ioctl.h> 132#endif 133 134/* 135 * Terminal I/O includes (termio, termios, sgtty headers). 136 */ 137#if defined(USE_POSIX_TERMIOS) && !defined(__hpux) 138#include <termios.h> 139#elif defined(USE_TERMIOS) 140#include <termios.h> 141/* this hacked termios support only works on SYSV */ 142#define USE_ANY_SYSV_TERMIO 143#define termio termios 144#ifndef __CYGWIN__ 145#undef TCGETA 146#define TCGETA TCGETS 147#undef TCSETA 148#define TCSETA TCSETS 149#undef TCSETAW 150#define TCSETAW TCSETSW 151#endif 152#elif defined(USE_SYSV_TERMIO) 153# define USE_ANY_SYSV_TERMIO 154# ifdef Lynx 155# include <termio.h> 156# else 157# include <sys/termio.h> 158# endif 159#elif defined(SYSV) || defined(ISC) 160# include <sys/termio.h> 161#elif !defined(VMS) 162# include <sgtty.h> 163#endif /* USE_POSIX_TERMIOS */ 164 165/* 166 * Stream includes, which declare struct winsize or ttysize. 167 */ 168#ifdef SYSV 169#ifdef USE_USG_PTYS 170#include <sys/stream.h> /* get typedef used in ptem.h */ 171#ifdef HAVE_SYS_PTEM_H 172#include <sys/ptem.h> /* get struct winsize */ 173#endif 174#endif /* USE_USG_PTYS */ 175#endif /* SYSV */ 176 177/* 178 * Special cases (structures and definitions that have to be adjusted). 179 */ 180#if defined(__CYGWIN__) && !defined(TIOCSPGRP) 181#include <termios.h> 182#define TIOCSPGRP (_IOW('t', 118, pid_t)) 183#endif 184 185#ifdef __hpux 186#include <sys/bsdtty.h> /* defines TIOCSLTC */ 187#endif 188 189#ifdef ISC 190#define TIOCGPGRP TCGETPGRP 191#define TIOCSPGRP TCSETPGRP 192#endif 193 194#ifdef Lynx 195#include <resource.h> 196#elif !(defined(SYSV) || defined(linux) || defined(VMS) || (defined(__QNX__)&&!defined(__QNXNTO__))) 197#include <sys/resource.h> 198#endif 199 200#ifdef macII 201#undef FIOCLEX 202#undef FIONCLEX 203#endif /* macII */ 204 205#ifdef __QNX__ 206#undef TIOCSLTC /* <sgtty.h> conflicts with <termios.h> */ 207#undef TIOCLSET 208#endif 209 210#if defined(__sgi) && (OSMAJORVERSION >= 5) 211#undef TIOCLSET /* defined, but not useable */ 212#endif 213 214#if defined(__GNU__) || defined(__MVS__) || defined(__osf__) 215#undef TIOCLSET 216#undef TIOCSLTC 217#endif 218 219#if defined (__sgi) || (defined(__linux__) && defined(__sparc__)) || defined(__UNIXWARE__) 220#undef TIOCLSET /* XXX why is this undef-ed again? */ 221#endif 222 223#if defined(sun) || defined(__UNIXWARE__) 224#include <sys/filio.h> 225#endif 226 227#if defined(TIOCSLTC) && ! (defined(linux) || defined(__MVS__) || defined(Lynx) || defined(SVR4)) 228#define HAS_LTCHARS 229#endif 230 231#if !defined(TTYSIZE_STRUCT) 232#if defined(TIOCSWINSZ) 233#define USE_STRUCT_WINSIZE 1 234#define TTYSIZE_STRUCT struct winsize 235#define GET_TTYSIZE(fd, data) ioctl(fd, TIOCGWINSZ, (char *) &data) 236#define SET_TTYSIZE(fd, data) ioctl(fd, TIOCSWINSZ, (char *) &data) 237#define TTYSIZE_COLS(data) data.ws_col 238#define TTYSIZE_ROWS(data) data.ws_row 239#endif /* TIOCSWINSZ */ 240#endif /* TTYSIZE_STRUCT */ 241 242#ifndef USE_STRUCT_WINSIZE 243#error "There is a configuration error with struct winsize ifdef" 244#endif 245 246#if OPT_TRACE 247#define TRACE_TTYSIZE(fd, id) { \ 248 TTYSIZE_STRUCT debug_ttysize; \ 249 if (GET_TTYSIZE(fd, debug_ttysize) == 0) \ 250 TRACE(("%s@%d, TTYSIZE %s %d %d\n", __FILE__, __LINE__, id, TTYSIZE_ROWS(debug_ttysize), TTYSIZE_COLS(debug_ttysize))); \ 251 else \ 252 TRACE(("%s@%d, TTYSIZE failed %s\n", __FILE__, __LINE__, strerror(errno))); \ 253 } 254#else 255#define TRACE_TTYSIZE(fd, id) /* nothing */ 256#endif 257 258typedef unsigned short ttySize_t; 259 260#endif /* included_xterm_io_h */ 261