+/* $NetBSD: main.c,v 1.10 2001/07/22 13:34:01 wiz Exp $ */
+
/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1980 Regents of the University of California.\n\
- All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
-/*static char sccsid[] = "from: @(#)main.c 5.7 (Berkeley) 2/28/91";*/
-static char rcsid[] = "$Id: main.c,v 1.2 1993/08/01 18:50:18 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: main.c,v 1.10 2001/07/22 13:34:01 wiz Exp $");
+#endif
#endif /* not lint */
-# include "trek.h"
-# include <stdio.h>
-# include <sgtty.h>
-# include <setjmp.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include <termios.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <err.h>
+#include <time.h>
+#include <sys/types.h>
+#include "trek.h"
+#include "getpar.h"
# define PRIO 00 /* default priority */
-int Mother = 51 + (51 << 8);
+uid_t Mother = 51 + (51 << 8);
/*
** #### ##### # #### ##### #### ##### # #
**
** Many things in trek are not as clear as they might be, but are
** done to reduce space. I compile with the -f and -O flags. I
-** am constrained to running with non-seperated I/D space, since
+** am constrained to running with non-separated I/D space, since
** we don't have doubleing point hardware here; even if we did, I
** would like trek to be available to the large number of people
** who either have an 11/40 or do not have FP hardware. I also
jmp_buf env;
+int main __P((int, char **));
+
+int
main(argc, argv)
int argc;
char **argv;
{
+ time_t curtime;
long vect;
- /* extern FILE *f_log; */
- register char opencode;
+ char opencode;
int prio;
- register int ac;
- register char **av;
- struct sgttyb argp;
+ int ac;
+ char **av;
+ struct termios argp;
+
+ /* Revoke setgid privileges */
+ setgid(getgid());
av = argv;
ac = argc;
av++;
- time(&vect);
+ time(&curtime);
+ vect = (long) curtime;
srand(vect);
opencode = 'w';
prio = PRIO;
- if (gtty(1, &argp) == 0)
+
+ if (tcgetattr(1, &argp) == 0)
{
- if ((argp.sg_ispeed ) < B1200)
+ if (cfgetispeed(&argp) < B1200)
Etc.fast++;
}
+
while (ac > 1 && av[0][0] == '-')
{
switch (av[0][1])
av++;
}
if (ac > 2)
- syserr(0, "arg count");
+ errx(1, "arg count");
/*
if (ac > 1)
f_log = fopen(av[0], opencode);
} while (getynpar("Another game"));
fflush(stdout);
+ return 0;
}