2019-02-24 04:41:42 -07:00
|
|
|
/* $XTermId: xterm_io.h,v 1.65 2018/06/28 21:35:01 tom Exp $ */
|
2006-11-26 04:11:12 -07:00
|
|
|
|
|
|
|
/*
|
2019-02-24 04:41:42 -07:00
|
|
|
* Copyright 2000-2017,2018 by Thomas E. Dickey
|
2006-11-26 04:11:12 -07:00
|
|
|
*
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Except as contained in this notice, the name(s) of the above copyright
|
|
|
|
* holders shall not be used in advertising or otherwise to promote the
|
|
|
|
* sale, use or other dealings in this Software without prior written
|
|
|
|
* authorization.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef included_xterm_io_h
|
|
|
|
#define included_xterm_io_h
|
|
|
|
|
|
|
|
#include <xterm.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* System-specific definitions (keep these chunks one-per-system!).
|
|
|
|
*
|
|
|
|
* FIXME: some, such as those defining USE_TERMIOS should be moved to xterm.h
|
|
|
|
* as they are integrated with the configure script.
|
|
|
|
*/
|
2014-10-05 10:39:19 -06:00
|
|
|
#if defined(__minix)
|
|
|
|
#define USE_POSIX_TERMIOS 1
|
|
|
|
#undef HAVE_POSIX_OPENPT /* present, does not work */
|
|
|
|
#endif
|
|
|
|
|
2006-11-26 04:11:12 -07:00
|
|
|
#ifdef CSRG_BASED
|
|
|
|
#define USE_TERMIOS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
#define ATT
|
|
|
|
#define SVR4
|
|
|
|
#define SYSV
|
|
|
|
#define USE_SYSV_TERMIO
|
|
|
|
#endif
|
|
|
|
|
2011-08-18 13:47:42 -06:00
|
|
|
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__INTERIX) || defined(__APPLE__) || defined(__UNIXWARE__) || defined(__hpux)
|
2006-11-26 04:11:12 -07:00
|
|
|
#ifndef USE_POSIX_TERMIOS
|
|
|
|
#define USE_POSIX_TERMIOS
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(AIXV4)
|
|
|
|
#define USE_POSIX_TERMIOS
|
|
|
|
#ifndef SYSV
|
|
|
|
#define SYSV
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef linux
|
|
|
|
#define USE_TERMIOS
|
2019-02-24 04:41:42 -07:00
|
|
|
#define HAVE_POSIX_OPENPT 1
|
|
|
|
#define HAVE_PTSNAME 1
|
|
|
|
#define HAVE_GRANTPT_PTY_ISATTY 1
|
2006-11-26 04:11:12 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __SCO__
|
|
|
|
#define USE_TERMIOS
|
|
|
|
#ifndef _SVID3
|
|
|
|
#define _SVID3
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef Lynx
|
|
|
|
#define USE_SYSV_TERMIO
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef macII
|
|
|
|
#undef SYSV /* pretend to be bsd (sgtty.h) */
|
|
|
|
#endif /* macII */
|
|
|
|
|
|
|
|
#if defined(__GLIBC__) && !defined(linux)
|
|
|
|
#define USE_POSIX_TERMIOS /* GNU/Hurd, GNU/KFreeBSD and GNU/KNetBSD */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __MVS__
|
|
|
|
#define SVR4
|
|
|
|
#define USE_POSIX_TERMIOS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __QNX__
|
|
|
|
#define USE_POSIX_TERMIOS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(__osf__)
|
|
|
|
#define USE_POSIX_TERMIOS
|
|
|
|
#undef SYSV
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Indirect system dependencies
|
|
|
|
*/
|
|
|
|
#if defined(SVR4) && !defined(__sgi)
|
|
|
|
#define USE_TERMIOS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SYSV
|
|
|
|
#define USE_SYSV_TERMIO
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(USE_POSIX_TERMIOS) && !defined(USE_TERMIOS)
|
|
|
|
#define USE_TERMIOS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Low-level ioctl, where it is needed or non-conflicting with termio/etc.
|
|
|
|
*/
|
|
|
|
#ifdef __QNX__
|
|
|
|
#include <ioctl.h>
|
|
|
|
#else
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Terminal I/O includes (termio, termios, sgtty headers).
|
|
|
|
*/
|
2011-08-18 13:47:42 -06:00
|
|
|
#if defined(USE_POSIX_TERMIOS) && !defined(__hpux)
|
2006-11-26 04:11:12 -07:00
|
|
|
#include <termios.h>
|
|
|
|
#elif defined(USE_TERMIOS)
|
|
|
|
#include <termios.h>
|
|
|
|
/* this hacked termios support only works on SYSV */
|
|
|
|
#define USE_ANY_SYSV_TERMIO
|
|
|
|
#define termio termios
|
|
|
|
#ifndef __CYGWIN__
|
|
|
|
#undef TCGETA
|
|
|
|
#define TCGETA TCGETS
|
|
|
|
#undef TCSETA
|
|
|
|
#define TCSETA TCSETS
|
|
|
|
#undef TCSETAW
|
|
|
|
#define TCSETAW TCSETSW
|
|
|
|
#endif
|
|
|
|
#elif defined(USE_SYSV_TERMIO)
|
|
|
|
# define USE_ANY_SYSV_TERMIO
|
|
|
|
# ifdef Lynx
|
|
|
|
# include <termio.h>
|
|
|
|
# else
|
|
|
|
# include <sys/termio.h>
|
|
|
|
# endif
|
|
|
|
#elif defined(SYSV) || defined(ISC)
|
|
|
|
# include <sys/termio.h>
|
|
|
|
#elif !defined(VMS)
|
|
|
|
# include <sgtty.h>
|
|
|
|
#endif /* USE_POSIX_TERMIOS */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stream includes, which declare struct winsize or ttysize.
|
|
|
|
*/
|
|
|
|
#ifdef SYSV
|
|
|
|
#ifdef USE_USG_PTYS
|
2014-10-05 10:39:19 -06:00
|
|
|
#include <sys/stream.h> /* get typedef used in ptem.h */
|
2012-04-14 03:02:46 -06:00
|
|
|
#ifdef HAVE_SYS_PTEM_H
|
2014-10-05 10:39:19 -06:00
|
|
|
#include <sys/ptem.h> /* get struct winsize */
|
2006-11-26 04:11:12 -07:00
|
|
|
#endif
|
|
|
|
#endif /* USE_USG_PTYS */
|
|
|
|
#endif /* SYSV */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Special cases (structures and definitions that have to be adjusted).
|
|
|
|
*/
|
|
|
|
#if defined(__CYGWIN__) && !defined(TIOCSPGRP)
|
|
|
|
#include <termios.h>
|
|
|
|
#define TIOCSPGRP (_IOW('t', 118, pid_t))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __hpux
|
|
|
|
#include <sys/bsdtty.h> /* defines TIOCSLTC */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ISC
|
|
|
|
#define TIOCGPGRP TCGETPGRP
|
|
|
|
#define TIOCSPGRP TCSETPGRP
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef Lynx
|
|
|
|
#include <resource.h>
|
|
|
|
#elif !(defined(SYSV) || defined(linux) || defined(VMS) || (defined(__QNX__)&&!defined(__QNXNTO__)))
|
|
|
|
#include <sys/resource.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef macII
|
|
|
|
#undef FIOCLEX
|
|
|
|
#undef FIONCLEX
|
|
|
|
#endif /* macII */
|
|
|
|
|
2017-07-15 13:20:51 -06:00
|
|
|
#if defined(__QNX__) || defined(__GNU__) || defined(__MVS__) || defined(__osf__)
|
2006-11-26 04:11:12 -07:00
|
|
|
#undef TIOCSLTC /* <sgtty.h> conflicts with <termios.h> */
|
|
|
|
#undef TIOCSLTC
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined (__sgi) || (defined(__linux__) && defined(__sparc__)) || defined(__UNIXWARE__)
|
2017-07-15 13:20:51 -06:00
|
|
|
#undef TIOCLSET /* defined, but not useable */
|
2006-11-26 04:11:12 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(sun) || defined(__UNIXWARE__)
|
|
|
|
#include <sys/filio.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(TIOCSLTC) && ! (defined(linux) || defined(__MVS__) || defined(Lynx) || defined(SVR4))
|
|
|
|
#define HAS_LTCHARS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(TTYSIZE_STRUCT)
|
2013-03-09 07:45:38 -07:00
|
|
|
#if defined(TIOCSWINSZ)
|
2006-11-26 04:11:12 -07:00
|
|
|
#define USE_STRUCT_WINSIZE 1
|
|
|
|
#define TTYSIZE_STRUCT struct winsize
|
2012-06-07 14:20:23 -06:00
|
|
|
#define GET_TTYSIZE(fd, data) ioctl(fd, TIOCGWINSZ, (char *) &data)
|
2006-11-26 04:11:12 -07:00
|
|
|
#define SET_TTYSIZE(fd, data) ioctl(fd, TIOCSWINSZ, (char *) &data)
|
|
|
|
#define TTYSIZE_COLS(data) data.ws_col
|
|
|
|
#define TTYSIZE_ROWS(data) data.ws_row
|
2013-03-09 07:45:38 -07:00
|
|
|
#endif /* TIOCSWINSZ */
|
|
|
|
#endif /* TTYSIZE_STRUCT */
|
2012-06-07 14:20:23 -06:00
|
|
|
|
2013-03-09 07:45:38 -07:00
|
|
|
#ifndef USE_STRUCT_WINSIZE
|
|
|
|
#error "There is a configuration error with struct winsize ifdef"
|
|
|
|
#endif
|
2012-06-07 14:20:23 -06:00
|
|
|
|
2017-07-15 13:20:51 -06:00
|
|
|
/* "resize" depends upon order of assignments in this macro */
|
|
|
|
#ifdef USE_STRUCT_WINSIZE
|
|
|
|
#define setup_winsize(ts, rows, cols, height, width) \
|
|
|
|
(ts).ws_xpixel = (ttySize_t) (width), \
|
|
|
|
(ts).ws_ypixel = (ttySize_t) (height), \
|
|
|
|
TTYSIZE_ROWS(ts) = (ttySize_t) (rows), \
|
|
|
|
TTYSIZE_COLS(ts) = (ttySize_t) (cols)
|
|
|
|
#else
|
|
|
|
#define setup_winsize(ts, rows, cols, height, width) \
|
|
|
|
TTYSIZE_ROWS(ts) = (ttySize_t) (rows), \
|
|
|
|
TTYSIZE_COLS(ts) = (ttySize_t) (cols)
|
|
|
|
#endif
|
|
|
|
|
2012-06-07 14:20:23 -06:00
|
|
|
#if OPT_TRACE
|
2017-07-15 13:20:51 -06:00
|
|
|
|
|
|
|
#ifdef USE_STRUCT_WINSIZE
|
|
|
|
#define trace_winsize(ts, id) \
|
|
|
|
TRACE(("%s@%d, TTYSIZE %s chars %dx%d pixels %dx%d\n", \
|
|
|
|
__FILE__, __LINE__, id, \
|
|
|
|
TTYSIZE_ROWS(ts), TTYSIZE_COLS(ts), (ts).ws_ypixel, (ts).ws_xpixel))
|
|
|
|
#else
|
|
|
|
#define trace_winsize(ts, id) \
|
|
|
|
TRACE(("%s@%d, TTYSIZE %s chars %dx%d\n", __FILE__, __LINE__, id, \
|
|
|
|
TTYSIZE_ROWS(ts), TTYSIZE_COLS(ts)))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define TRACE_GET_TTYSIZE(fd, id) { \
|
2012-06-07 14:20:23 -06:00
|
|
|
TTYSIZE_STRUCT debug_ttysize; \
|
|
|
|
if (GET_TTYSIZE(fd, debug_ttysize) == 0) \
|
2017-07-15 13:20:51 -06:00
|
|
|
trace_winsize(debug_ttysize, id); \
|
2012-06-07 14:20:23 -06:00
|
|
|
else \
|
|
|
|
TRACE(("%s@%d, TTYSIZE failed %s\n", __FILE__, __LINE__, strerror(errno))); \
|
|
|
|
}
|
|
|
|
#else
|
2017-07-15 13:20:51 -06:00
|
|
|
#define trace_winsize(ts, id) /* nothing */
|
|
|
|
#define TRACE_GET_TTYSIZE(fd, id) /* nothing */
|
2006-11-26 04:11:12 -07:00
|
|
|
#endif
|
|
|
|
|
2010-08-22 07:38:11 -06:00
|
|
|
typedef unsigned short ttySize_t;
|
|
|
|
|
2017-07-15 13:20:51 -06:00
|
|
|
#endif /* included_xterm_io_h */
|