Initial import from FreeBSD RELENG_4:
[dragonfly.git] / games / hack / hack.ioctl.c
1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.ioctl.c - version 1.0.2 */
3 /* $FreeBSD: src/games/hack/hack.ioctl.c,v 1.2 1999/09/12 07:01:23 marcel Exp $
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 BSD
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 BSD
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 BSD
33 }
34
35 #ifdef SUSPEND          /* implies BSD */
36 #include        <signal.h>
37 dosuspend() {
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 SIGTSTP
52         return(0);
53 }
54 #endif SUSPEND