-/* $NetBSD: dr_main.c,v 1.4 1995/04/22 10:36:52 cgd Exp $ */
+/* $NetBSD: dr_main.c,v 1.14 2009/03/14 19:36:42 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.
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dr_main.c 8.2 (Berkeley) 4/16/94";
#else
-static char rcsid[] = "$NetBSD: dr_main.c,v 1.4 1995/04/22 10:36:52 cgd Exp $";
+__RCSID("$NetBSD: dr_main.c,v 1.14 2009/03/14 19:36:42 dholland Exp $");
#endif
#endif /* not lint */
+#include <err.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "extern.h"
#include "driver.h"
-dr_main()
+int
+dr_main(void)
{
- register int n;
- register struct ship *sp;
+ int n;
+ struct ship *sp;
int nat[NNATION];
int value = 0;
- (void) signal(SIGINT, SIG_IGN);
- (void) signal(SIGQUIT, SIG_IGN);
- (void) signal(SIGTSTP, SIG_IGN);
- if (issetuid)
- (void) setuid(geteuid());
+ signal(SIGINT, SIG_IGN);
+ signal(SIGQUIT, SIG_IGN);
+ signal(SIGTSTP, SIG_IGN);
if (game < 0 || game >= NSCENE) {
- fprintf(stderr, "DRIVER: Bad game number %d\n", game);
- exit(1);
+ errx(1, "driver: Bad game number %d", game);
}
cc = &scene[game];
ls = SHIP(cc->vessels);
if (sync_open() < 0) {
- perror("driver: syncfile");
- exit(1);
+ err(1, "driver: syncfile");
}
for (n = 0; n < NNATION; n++)
nat[n] = 0;
foreachship(sp) {
if (sp->file == NULL &&
- (sp->file = (struct File *)calloc(1, sizeof (struct File))) == NULL) {
- (void) fprintf(stderr, "DRIVER: Out of memory.\n");
+ (sp->file = calloc(1, sizeof (struct File))) == NULL) {
+ fprintf(stderr, "DRIVER: Out of memory.\n");
exit(1);
}
sp->file->index = sp - SHIP(0);