1 /* aNetHack 0.0.1 ioctl.c $ANH-Date: 1432512788 2015/05/25 00:13:08 $ $ANH-Branch: master $:$ANH-Revision: 1.12 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* aNetHack may be freely redistributed. See license for details. */
5 /* This cannot be part of hack.tty.c (as it was earlier) since on some
6 systems (e.g. MUNIX) the include files <termio.h> and <sgtty.h>
7 define the same constants, and the C preprocessor complains. */
11 #if defined(BSD_JOB_CONTROL) || defined(_BULL_SOURCE)
15 #if defined(AIX_31) && !defined(_ALL_SOURCE)
16 #define _ALL_SOURCE /* causes struct winsize to be present */
18 #include <sys/ioctl.h>
21 #if defined(_BULL_SOURCE)
23 struct termios termio
;
24 #undef TIMEOUT /* defined in you.h and sys/tty.h */
25 #include <sys/tty.h> /* define winsize */
26 #include <sys/ttold.h> /* define struct ltchars */
27 #include <sys/bsdioctl.h> /* define TIOGWINSZ */
30 #include <bsd/sgtty.h>
36 struct ltchars ltchars
;
37 struct ltchars ltchars0
= { -1, -1, -1, -1, -1, -1 }; /* turn all off */
42 struct termios termio
;
43 #if defined(BSD) || defined(_AIX32) || defined(__linux__)
44 #if defined(_AIX32) && !defined(_ALL_SOURCE)
47 #include <sys/ioctl.h>
50 #include <termio.h> /* also includes part of <sgtty.h> */
51 #if defined(TCSETS) && !defined(AIX_31)
52 struct termios termio
;
57 #if defined(AMIX) || defined(__APPLE__)
58 #include <sys/ioctl.h>
62 #ifdef SUSPEND /* BSD isn't alone anymore... */
66 #if defined(TIOCGWINSZ) \
67 && (defined(BSD) || defined(ULTRIX) || defined(AIX_31) \
68 || defined(_BULL_SOURCE) || defined(SVR4))
70 #include "tcap.h" /* for LI and CO */
74 extern void NDECL(sco_mapon
);
75 extern void NDECL(sco_mapoff
);
78 extern void NDECL(linux_mapon
);
79 extern void NDECL(linux_mapoff
);
86 signal(SIGTSTP
, SIG_DFL
);
96 * ttysize is found on Suns and BSD
97 * winsize is found on Suns, BSD, and Ultrix
101 if (ioctl(fileno(stdin
), (int) TIOCGWINSZ
, (char *) &ttsz
) != -1) {
103 * Use the kernel's values for lines and columns if it has
117 #ifdef BSD_JOB_CONTROL
118 (void) ioctl(fileno(stdin
), (int) TIOCGLTC
, (char *) <chars
);
119 (void) ioctl(fileno(stdin
), (int) TIOCSLTC
, (char *) <chars0
);
122 (void) tcgetattr(fileno(stdin
), &termio
);
124 #if defined(TCSETS) && !defined(AIX_31)
125 (void) ioctl(fileno(stdin
), (int) TCGETS
, &termio
);
127 (void) ioctl(fileno(stdin
), (int) TCGETA
, &termio
);
133 (void) signal(SIGTSTP
, catch_stp
);
140 #ifdef BSD_JOB_CONTROL
141 (void) ioctl(fileno(stdin
), (int) TIOCSLTC
, (char *) <chars
);
144 (void) tcsetattr(fileno(stdin
), TCSADRAIN
, &termio
);
146 #if defined(TCSETS) && !defined(AIX_31)
147 (void) ioctl(fileno(stdin
), (int) TCSETSW
, &termio
);
149 (void) ioctl(fileno(stdin
), (int) TCSETAW
, &termio
);
155 #ifdef SUSPEND /* No longer implies BSD */
160 /* NB: check_user_string() is port-specific. */
161 if (!sysopt
.shellers
|| !sysopt
.shellers
[0]
162 || !check_user_string(sysopt
.shellers
)) {
163 Norep("Suspend command not available.");
167 #if defined(SIGTSTP) && !defined(NO_SIGNAL)
168 if (signal(SIGTSTP
, SIG_IGN
) == SIG_DFL
) {
169 suspend_nhwindows((char *) 0);
176 (void) signal(SIGTSTP
, SIG_DFL
);
178 (void) kill(0, SIGSTOP
);
180 (void) kill(0, SIGTSTP
);
190 pline("I don't think your shell has job control.");
193 pline("Sorry, it seems we have no SIGTSTP here. Try ! or S.");