X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/64e97658ba659a3c374b975c3262f10910904254..3c48fe193d2fb7c927c2c9d1dbf76707e657a9fd:/atc/main.c diff --git a/atc/main.c b/atc/main.c index 8bc180d5..a579e89d 100644 --- a/atc/main.c +++ b/atc/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.8 1998/11/10 13:43:31 hubertf Exp $ */ +/* $NetBSD: main.c,v 1.13 2003/08/07 09:36:54 agc Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -15,11 +15,7 @@ * 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 + * 3. 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. * @@ -55,13 +51,14 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: main.c,v 1.8 1998/11/10 13:43:31 hubertf Exp $"); +__RCSID("$NetBSD: main.c,v 1.13 2003/08/07 09:36:54 agc Exp $"); #endif #endif /* not lint */ #include "include.h" #include "pathnames.h" +extern FILE *yyin; int main(ac, av) @@ -72,62 +69,52 @@ main(ac, av) int f_usage = 0, f_list = 0, f_showscore = 0; int f_printpath = 0; const char *file = NULL; - char *name, *ptr; + int ch; struct sigaction sa; #ifdef BSD struct itimerval itv; #endif - start_time = seed = time(0); + /* Open the score file then revoke setgid privileges */ + open_score_file(); + setgid(getgid()); - name = *av++; - while (*av) { -#ifndef SAVEDASH - if (**av == '-') - ++*av; - else + start_time = seed = time(NULL); + + while ((ch = getopt(ac, av, "ulstpg:f:r:")) != -1) { + switch (ch) { + case '?': + case 'u': + default: + f_usage++; + break; + case 'l': + f_list++; + break; + case 's': + case 't': + f_showscore++; + break; + case 'p': + f_printpath++; + break; + case 'r': + seed = atoi(optarg); + break; + case 'f': + case 'g': + file = optarg; break; -#endif - ptr = *av++; - while (*ptr) { - switch (*ptr) { - case '?': - case 'u': - f_usage++; - break; - case 'l': - f_list++; - break; - case 's': - case 't': - f_showscore++; - break; - case 'p': - f_printpath++; - break; - case 'r': - seed = atoi(*av); - av++; - break; - case 'f': - case 'g': - file = *av; - av++; - break; - default: - warnx("unknown option '%c'\n", *ptr); - f_usage++; - break; - } - ptr++; } } + if (optind < ac) + f_usage++; srandom(seed); if (f_usage) fprintf(stderr, "Usage: %s -[u?lstp] [-[gf] game_name] [-r random seed]\n", - name); + av[0]); if (f_showscore) log_score(1); if (f_list) @@ -224,7 +211,6 @@ int read_file(s) const char *s; { - extern FILE *yyin; int retval; file = s;