Source:NetHack 1.3d/ioctl.c

From NetHackWiki
Jump to: navigation, search

Below is the full text to ioctl.c from the source code of NetHack 1.3d. To link to a particular line, write [[NetHack 1.3d/ioctl.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

Screenshots and source code from Hack are used under the CWI license.

1.    /*	SCCS Id: @(#)ioctl.c	1.3	87/07/14
2.    /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3.    /* hack.ioctl.c - version 1.0.2 */
4.    
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. */
8.    #include <stdio.h>
9.    #include "config.h"
10.   #ifdef BSD
11.   #include	<sgtty.h>
12.   struct ltchars ltchars, ltchars0;
13.   #else
14.   #include	<termio.h>	/* also includes part of <sgtty.h> */
15.   struct termio termio;
16.   #endif
17.   
18.   getioctls() {
19.   #ifdef BSD
20.   	(void) ioctl(fileno(stdin), (int) TIOCGLTC, (char *) &ltchars);
21.   	(void) ioctl(fileno(stdin), (int) TIOCSLTC, (char *) &ltchars0);
22.   #else
23.   	(void) ioctl(fileno(stdin), (int) TCGETA, &termio);
24.   #endif
25.   }
26.   
27.   setioctls() {
28.   #ifdef BSD
29.   	(void) ioctl(fileno(stdin), (int) TIOCSLTC, (char *) &ltchars);
30.   #else
31.   	(void) ioctl(fileno(stdin), (int) TCSETA, &termio);
32.   #endif
33.   }
34.   
35.   #ifdef SUSPEND		/* implies BSD */
36.   dosuspend() {
37.   #include	<signal.h>
38.   #ifdef SIGTSTP
39.   	if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) {
40.   		settty((char *) 0);
41.   		(void) signal(SIGTSTP, SIG_DFL);
42.   		(void) kill(0, SIGTSTP);
43.   		gettty();
44.   		setftty();
45.   		docrt();
46.   	} else {
47.   		pline("I don't think your shell has job control.");
48.   	}
49.   #else SIGTSTP
50.   	pline("Sorry, it seems we have no SIGTSTP here. Try ! or S.");
51.   #endif
52.   	return(0);
53.   }
54.   #endif /* SUSPEND /**/