]> git.cameronkatri.com Git - bsdgames-darwin.git/blobdiff - atc/main.c
Merge upstream (can't test, hopefully nothing broke)
[bsdgames-darwin.git] / atc / main.c
index 49c5d6aa32e1f746c1e73299165542e71850a04d..db0896514e5ab64a16afa13094a8883b4ad8b671 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.20 2009/08/12 04:48:03 dholland Exp $       */
+/*     $NetBSD: main.c,v 1.24 2015/06/25 05:33:02 dholland Exp $       */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -51,12 +51,23 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993\
 #if 0
 static char sccsid[] = "@(#)main.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: main.c,v 1.20 2009/08/12 04:48:03 dholland Exp $");
+__RCSID("$NetBSD: main.c,v 1.24 2015/06/25 05:33:02 dholland Exp $");
 #endif
 #endif /* not lint */
 
-#include "include.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <termios.h>
+#include <getopt.h>
+#include <err.h>
+
 #include "pathnames.h"
+#include "def.h"
+#include "struct.h"
+#include "extern.h"
+#include "tunable.h"
 
 extern FILE    *yyin;
 
@@ -64,6 +75,7 @@ static int read_file(const char *);
 static const char *default_game(void);
 static const char *okay_game(const char *);
 static int list_games(void);
+static void quit(int);
 
 int
 main(int argc, char *argv[])
@@ -90,17 +102,17 @@ main(int argc, char *argv[])
                case '?':
                case 'u':
                default: 
-                       f_usage++;
+                       f_usage = 1;
                        break;
                case 'l':
-                       f_list++;
+                       f_list = 1;
                        break;
                case 's':
                case 't':
-                       f_showscore++;
+                       f_showscore = 1;
                        break;
                case 'p':
-                       f_printpath++;
+                       f_printpath = 1;
                        break;
                case 'r':
                        seed = atoi(optarg);
@@ -112,7 +124,7 @@ main(int argc, char *argv[])
                }
        }
        if (optind < argc)
-               f_usage++;
+               f_usage = 1;
        srandom(seed);
 
        if (f_usage)
@@ -144,7 +156,7 @@ main(int argc, char *argv[])
        init_gr();
        setup_screen(sp);
 
-       (void)addplane();
+       addplane();
 
        (void)signal(SIGINT, quit);
        (void)signal(SIGQUIT, quit);
@@ -316,3 +328,30 @@ list_games(void)
        }
        return (0);
 }
+
+/* ARGSUSED */
+static void
+quit(int dummy __unused)
+{
+       int c;
+#ifdef BSD
+       struct itimerval        itv;
+#endif
+       ioaskquit();
+       c = getAChar();
+       if (c == EOF || c == 'y') {
+               /* disable timer */
+#ifdef BSD
+               itv.it_value.tv_sec = 0;
+               itv.it_value.tv_usec = 0;
+               (void)setitimer(ITIMER_REAL, &itv, NULL);
+#endif
+#ifdef SYSV
+               alarm(0);
+#endif
+               shutdown_gr();
+               (void)log_score(0);
+               exit(0);
+       }
+       ionoquit();
+}