BSD 4_3_Net_2 release
[unix-history] / usr / src / games / trek / main.c
index 5bcb294..3cad83c 100644 (file)
@@ -2,12 +2,33 @@
  * Copyright (c) 1980 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1980 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of California at Berkeley. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -17,12 +38,14 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.7 (Berkeley) 2/28/91";
 #endif /* not lint */
 
 # include      "trek.h"
 # include      <stdio.h>
 # include      <sgtty.h>
 #endif /* not lint */
 
 # include      "trek.h"
 # include      <stdio.h>
 # include      <sgtty.h>
+# include      <setjmp.h>
+
 # define       PRIO            00      /* default priority */
 
 int    Mother  = 51 + (51 << 8);
 # define       PRIO            00      /* default priority */
 
 int    Mother  = 51 + (51 << 8);
@@ -124,6 +147,8 @@ int Mother  = 51 + (51 << 8);
 ***********************************************************************
 */
 
 ***********************************************************************
 */
 
+jmp_buf env;
+
 main(argc, argv)
 int    argc;
 char   **argv;
 main(argc, argv)
 int    argc;
 char   **argv;
@@ -135,7 +160,6 @@ char        **argv;
        register int            ac;
        register char           **av;
        struct  sgttyb          argp;
        register int            ac;
        register char           **av;
        struct  sgttyb          argp;
-       int                     been_here = 0;
 
        av = argv;
        ac = argc;
 
        av = argv;
        ac = argc;
@@ -176,8 +200,8 @@ char        **argv;
                  case 'p':     /* set priority */
                        if (getuid() != Mother)
                                goto badflag;
                  case 'p':     /* set priority */
                        if (getuid() != Mother)
                                goto badflag;
-                       if (scanf(-1, &av[0][2], "%d", &prio) > 0)
-                               break;
+                       prio = atoi(av[0] + 2);
+                       break;
 
                  default:
                  badflag:
 
                  default:
                  badflag:
@@ -196,13 +220,11 @@ char      **argv;
 
        printf("\n   * * *   S T A R   T R E K   * * *\n\nPress return to continue.\n");
 
 
        printf("\n   * * *   S T A R   T R E K   * * *\n\nPress return to continue.\n");
 
-       setexit();
-       if ( been_here == 1 )
+       if (setjmp(env))
        {
                if ( !getynpar("Another game") )
                        exit(0);
        }
        {
                if ( !getynpar("Another game") )
                        exit(0);
        }
-       been_here = 1;
        do
        {
                setup();
        do
        {
                setup();