diff options
author | mycroft <mycroft@NetBSD.org> | 1995-04-27 21:22:19 +0000 |
---|---|---|
committer | mycroft <mycroft@NetBSD.org> | 1995-04-27 21:22:19 +0000 |
commit | 3e95714e815457b8e2c95138f9242701e3c08434 (patch) | |
tree | c2402f388750a4900ace82a944c066039d54afa1 /atc | |
parent | a65a873e56c35780711e9f73872c4fe0254589b0 (diff) | |
download | bsdgames-darwin-3e95714e815457b8e2c95138f9242701e3c08434.tar.gz bsdgames-darwin-3e95714e815457b8e2c95138f9242701e3c08434.tar.zst bsdgames-darwin-3e95714e815457b8e2c95138f9242701e3c08434.zip |
Use POSIX signal and tty semantics.
Diffstat (limited to 'atc')
-rw-r--r-- | atc/extern.c | 6 | ||||
-rw-r--r-- | atc/extern.h | 4 | ||||
-rw-r--r-- | atc/include.h | 7 | ||||
-rw-r--r-- | atc/input.c | 11 | ||||
-rw-r--r-- | atc/main.c | 33 | ||||
-rw-r--r-- | atc/update.c | 10 |
6 files changed, 28 insertions, 43 deletions
diff --git a/atc/extern.c b/atc/extern.c index 2f9a2128..1f3d8980 100644 --- a/atc/extern.c +++ b/atc/extern.c @@ -1,4 +1,4 @@ -/* $NetBSD: extern.c,v 1.3 1995/03/21 15:03:50 cgd Exp $ */ +/* $NetBSD: extern.c,v 1.4 1995/04/27 21:22:19 mycroft Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -49,7 +49,7 @@ #if 0 static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: extern.c,v 1.3 1995/03/21 15:03:50 cgd Exp $"; +static char rcsid[] = "$NetBSD: extern.c,v 1.4 1995/04/27 21:22:19 mycroft Exp $"; #endif #endif /* not lint */ @@ -67,7 +67,7 @@ C_SCREEN screen, *sp = &screen; LIST air, ground; -struct sgttyb tty_start, tty_new; +struct termios tty_start, tty_new; DISPLACEMENT displacement[MAXDIR] = { { 0, -1 }, diff --git a/atc/extern.h b/atc/extern.h index fac22924..ec5c3a7a 100644 --- a/atc/extern.h +++ b/atc/extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.3 1995/03/21 15:03:54 cgd Exp $ */ +/* $NetBSD: extern.h,v 1.4 1995/04/27 21:22:22 mycroft Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -57,7 +57,7 @@ extern C_SCREEN screen, *sp; extern LIST air, ground; -extern struct sgttyb tty_start, tty_new; +extern struct termios tty_start, tty_new; extern DISPLACEMENT displacement[MAXDIR]; diff --git a/atc/include.h b/atc/include.h index b6ca43b2..bfa892e5 100644 --- a/atc/include.h +++ b/atc/include.h @@ -1,4 +1,4 @@ -/* $NetBSD: include.h,v 1.4 1995/04/24 12:21:46 cgd Exp $ */ +/* $NetBSD: include.h,v 1.5 1995/04/27 21:22:23 mycroft Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -53,9 +53,9 @@ #include <ctype.h> #include <sys/types.h> #include <pwd.h> +#include <termios.h> #ifdef BSD -#include <sgtty.h> #include <sys/time.h> #include <sys/file.h> #endif @@ -78,9 +78,6 @@ #define bzero(a,b) memset((a), '\0', (b)) #define srandom srand #define random rand -#define sgttyb termio -#define sg_erase c_cc[2] -#define sg_kill c_cc[3] #endif #include "def.h" diff --git a/atc/input.c b/atc/input.c index fa2d58e9..b932d47f 100644 --- a/atc/input.c +++ b/atc/input.c @@ -1,4 +1,4 @@ -/* $NetBSD: input.c,v 1.3 1995/03/21 15:04:12 cgd Exp $ */ +/* $NetBSD: input.c,v 1.4 1995/04/27 21:22:24 mycroft Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -49,7 +49,7 @@ #if 0 static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: input.c,v 1.3 1995/03/21 15:04:12 cgd Exp $"; +static char rcsid[] = "$NetBSD: input.c,v 1.4 1995/04/27 21:22:24 mycroft Exp $"; #endif #endif not lint @@ -253,10 +253,10 @@ getcommand() do { c = gettoken(); - if (c == tty_new.sg_erase) { + if (c == tty_new.c_cc[VERASE]) { if (pop() < 0) noise(); - } else if (c == tty_new.sg_kill) { + } else if (c == tty_new.c_cc[VKILL]) { while (pop() >= 0) ; } else { @@ -347,8 +347,8 @@ gettoken() } wait(0); + tcsetattr(fileno(stdin), TCSADRAIN, &tty_new); #ifdef BSD - ioctl(fileno(stdin), TIOCSETP, &tty_new); itv.it_value.tv_sec = 0; itv.it_value.tv_usec = 1; itv.it_interval.tv_sec = sp->update_secs; @@ -356,7 +356,6 @@ gettoken() setitimer(ITIMER_REAL, &itv, NULL); #endif #ifdef SYSV - ioctl(fileno(stdin), TCSETAW, &tty_new); alarm(aval); #endif } @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.3 1995/03/21 15:04:24 cgd Exp $ */ +/* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -55,7 +55,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: main.c,v 1.3 1995/03/21 15:04:24 cgd Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $"; #endif #endif /* not lint */ @@ -70,6 +70,7 @@ main(ac, av) int f_printpath = 0; char *file = NULL; char *name, *ptr; + struct sigaction sa; #ifdef BSD struct itimerval itv; #endif @@ -164,25 +165,19 @@ main(ac, av) signal(SIGHUP, log_score); signal(SIGTERM, log_score); -#ifdef BSD - ioctl(fileno(stdin), TIOCGETP, &tty_start); - bcopy(&tty_start, &tty_new, sizeof(tty_new)); - tty_new.sg_flags |= CBREAK; - tty_new.sg_flags &= ~ECHO; - ioctl(fileno(stdin), TIOCSETP, &tty_new); -#endif - -#ifdef SYSV - ioctl(fileno(stdin), TCGETA, &tty_start); - bcopy(&tty_start, &tty_new, sizeof(tty_new)); - tty_new.c_lflag &= ~ICANON; - tty_new.c_lflag &= ~ECHO; + tcgetattr(fileno(stdin), &tty_start); + tty_new = tty_start; + tty_new.c_lflag &= ~(ICANON|ECHO); tty_new.c_cc[VMIN] = 1; tty_new.c_cc[VTIME] = 0; - ioctl(fileno(stdin), TCSETAW, &tty_new); -#endif - - signal(SIGALRM, update); + tcsetattr(fileno(stdin), TCSADRAIN, &tty_new); + + sa.sa_handler = update; + sigemptyset(&sa.sa_mask); + sigaddset(&sa.sa_mask, SIGALRM); + sigaddset(&sa.sa_mask, SIGINT); + sa.sa_flags = 0; + sigaction(SIGALRM, &sa, (struct sigaction *)0); #ifdef BSD itv.it_value.tv_sec = 0; diff --git a/atc/update.c b/atc/update.c index cc2f85c5..9fdc32b1 100644 --- a/atc/update.c +++ b/atc/update.c @@ -1,4 +1,4 @@ -/* $NetBSD: update.c,v 1.3 1995/03/21 15:04:37 cgd Exp $ */ +/* $NetBSD: update.c,v 1.4 1995/04/27 21:22:26 mycroft Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -49,7 +49,7 @@ #if 0 static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: update.c,v 1.3 1995/03/21 15:04:37 cgd Exp $"; +static char rcsid[] = "$NetBSD: update.c,v 1.4 1995/04/27 21:22:26 mycroft Exp $"; #endif #endif not lint @@ -60,9 +60,6 @@ update() int i, dir_diff, mask, unclean; PLANE *pp, *p1, *p2, *p; -#ifdef BSD - mask = sigblock(sigmask(SIGINT)); -#endif #ifdef SYSV alarm(0); signal(SIGALRM, update); @@ -217,9 +214,6 @@ update() if ((rand() % sp->newplane_time) == 0) addplane(); -#ifdef BSD - sigsetmask(mask); -#endif #ifdef SYSV alarm(sp->update_secs); #endif |