xref: /csrg-svn/games/hack/hack.ioctl.c (revision 41239)
1*41239Sbostic /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2*41239Sbostic /* hack.ioctl.c - version 1.0.2 */
3*41239Sbostic 
4*41239Sbostic /* This cannot be part of hack.tty.c (as it was earlier) since on some
5*41239Sbostic    systems (e.g. MUNIX) the include files <termio.h> and <sgtty.h>
6*41239Sbostic    define the same constants, and the C preprocessor complains. */
7*41239Sbostic #include <stdio.h>
8*41239Sbostic #include "config.h"
9*41239Sbostic #ifdef BSD
10*41239Sbostic #include	<sgtty.h>
11*41239Sbostic struct ltchars ltchars, ltchars0;
12*41239Sbostic #else
13*41239Sbostic #include	<termio.h>	/* also includes part of <sgtty.h> */
14*41239Sbostic struct termio termio;
15*41239Sbostic #endif BSD
16*41239Sbostic 
getioctls()17*41239Sbostic getioctls() {
18*41239Sbostic #ifdef BSD
19*41239Sbostic 	(void) ioctl(fileno(stdin), (int) TIOCGLTC, (char *) &ltchars);
20*41239Sbostic 	(void) ioctl(fileno(stdin), (int) TIOCSLTC, (char *) &ltchars0);
21*41239Sbostic #else
22*41239Sbostic 	(void) ioctl(fileno(stdin), (int) TCGETA, &termio);
23*41239Sbostic #endif BSD
24*41239Sbostic }
25*41239Sbostic 
setioctls()26*41239Sbostic setioctls() {
27*41239Sbostic #ifdef BSD
28*41239Sbostic 	(void) ioctl(fileno(stdin), (int) TIOCSLTC, (char *) &ltchars);
29*41239Sbostic #else
30*41239Sbostic 	(void) ioctl(fileno(stdin), (int) TCSETA, &termio);
31*41239Sbostic #endif BSD
32*41239Sbostic }
33*41239Sbostic 
34*41239Sbostic #ifdef SUSPEND		/* implies BSD */
dosuspend()35*41239Sbostic dosuspend() {
36*41239Sbostic #include	<signal.h>
37*41239Sbostic #ifdef SIGTSTP
38*41239Sbostic 	if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) {
39*41239Sbostic 		settty((char *) 0);
40*41239Sbostic 		(void) signal(SIGTSTP, SIG_DFL);
41*41239Sbostic 		(void) kill(0, SIGTSTP);
42*41239Sbostic 		gettty();
43*41239Sbostic 		setftty();
44*41239Sbostic 		docrt();
45*41239Sbostic 	} else {
46*41239Sbostic 		pline("I don't think your shell has job control.");
47*41239Sbostic 	}
48*41239Sbostic #else SIGTSTP
49*41239Sbostic 	pline("Sorry, it seems we have no SIGTSTP here. Try ! or S.");
50*41239Sbostic #endif SIGTSTP
51*41239Sbostic 	return(0);
52*41239Sbostic }
53*41239Sbostic #endif SUSPEND
54