-/* $NetBSD: main.c,v 1.13 2000/11/30 22:07:24 jwise Exp $ */
+/* $NetBSD: main.c,v 1.25 2009/03/14 23:51:35 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
* 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.
*
#include <sys/cdefs.h>
#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
+__COPYRIGHT("@(#) Copyright (c) 1983, 1993\
+ The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: main.c,v 1.13 2000/11/30 22:07:24 jwise Exp $");
+__RCSID("$NetBSD: main.c,v 1.25 2009/03/14 23:51:35 dholland Exp $");
#endif
#endif /* not lint */
-#include "extern.h"
+#include <err.h>
#include <fcntl.h>
-#include <unistd.h>
+#include <setjmp.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
-int main (int, char **);
+#include <time.h>
+#include <unistd.h>
+#include "extern.h"
+#include "pathnames.h"
+#include "restart.h"
int
main(int argc, char **argv)
exit(1);
close(fd);
+ if (chdir(_PATH_SAILDIR) < 0) {
+ err(1, "%s", _PATH_SAILDIR);
+ }
+
srandom((u_long)time(NULL));
if ((p = strrchr(*argv, '/')) != NULL)
else
mode = MODE_PLAYER;
- while ((a = getopt(argc, argv, "dsDxlb")))
+ while ((a = getopt(argc, argv, "dsxlb")) != -1)
switch (a) {
case 'd':
mode = MODE_DRIVER;
case 's':
mode = MODE_LOGGER;
break;
- case 'D':
- debug++;
- break;
case 'x':
randomize++;
break;
nobells++;
break;
default:
- fprintf(stderr, "SAIL: Unknown flag %s.\n", p);
- exit(1);
+ errx(1, "Usage: %s [-bdlsx] [scenario-number]", p);
}
+ argc -= optind;
+ argv += optind;
+
if (*argv)
game = atoi(*argv);
else
case MODE_LOGGER:
return lo_main();
default:
- fprintf(stderr, "SAIL: Unknown mode %d.\n", mode);
+ warnx("Unknown mode %d", mode);
abort();
}
/*NOTREACHED*/