| 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 | $DragonFly: src/games/hack/hack.ioctl.c,v 1.4 2006/08/21 19:45:32 pavalos Exp $ |
| 5 | |
| 6 | This cannot be part of hack.tty.c (as it was earlier) since on some |
| 7 | systems (e.g. MUNIX) the include files <termio.h> and <sgtty.h> |
| 8 | define the same constants, and the C preprocessor complains. */ |
| 9 | #include "hack.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 | void |
| 19 | getioctls(void) |
| 20 | { |
| 21 | #ifdef BSD |
| 22 | ioctl(fileno(stdin), (int) TIOCGLTC, (char *) <chars); |
| 23 | ioctl(fileno(stdin), (int) TIOCSLTC, (char *) <chars0); |
| 24 | #else |
| 25 | ioctl(fileno(stdin), (int) TCGETA, &termio); |
| 26 | #endif /* BSD */ |
| 27 | } |
| 28 | |
| 29 | void |
| 30 | setioctls(void) |
| 31 | { |
| 32 | #ifdef BSD |
| 33 | ioctl(fileno(stdin), (int) TIOCSLTC, (char *) <chars); |
| 34 | #else |
| 35 | ioctl(fileno(stdin), (int) TCSETA, &termio); |
| 36 | #endif /* BSD */ |
| 37 | } |
| 38 | |
| 39 | #ifdef SUSPEND /* implies BSD */ |
| 40 | #include <signal.h> |
| 41 | int |
| 42 | dosuspend(void) |
| 43 | { |
| 44 | #ifdef SIGTSTP |
| 45 | if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) { |
| 46 | settty(NULL); |
| 47 | signal(SIGTSTP, SIG_DFL); |
| 48 | kill(0, SIGTSTP); |
| 49 | gettty(); |
| 50 | setftty(); |
| 51 | docrt(); |
| 52 | } else { |
| 53 | pline("I don't think your shell has job control."); |
| 54 | } |
| 55 | #else /* SIGTSTP */ |
| 56 | pline("Sorry, it seems we have no SIGTSTP here. Try ! or S."); |
| 57 | #endif /* SIGTSTP */ |
| 58 | return(0); |
| 59 | } |
| 60 | #endif /* SUSPEND */ |