summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlukem <lukem@NetBSD.org>1997-10-10 02:07:01 +0000
committerlukem <lukem@NetBSD.org>1997-10-10 02:07:01 +0000
commit872a50db510aae37e624f1b82db06f08023c5712 (patch)
treee5af9998b7c1daa1acf8046cd6ea941cbf25345b
parent3c0c7a72c2f0803e801f2330c329aff2eee680d5 (diff)
downloadbsdgames-darwin-872a50db510aae37e624f1b82db06f08023c5712.tar.gz
bsdgames-darwin-872a50db510aae37e624f1b82db06f08023c5712.tar.zst
bsdgames-darwin-872a50db510aae37e624f1b82db06f08023c5712.zip
WARNSify
-rw-r--r--atc/Makefile4
-rw-r--r--atc/extern.c5
-rw-r--r--atc/extern.h78
-rw-r--r--atc/grammar.y20
-rw-r--r--atc/graphics.c39
-rw-r--r--atc/include.h44
-rw-r--r--atc/input.c45
-rw-r--r--atc/lex.l7
-rw-r--r--atc/list.c7
-rw-r--r--atc/log.c46
-rw-r--r--atc/main.c28
-rw-r--r--atc/tunable.c5
-rw-r--r--atc/update.c30
13 files changed, 254 insertions, 104 deletions
diff --git a/atc/Makefile b/atc/Makefile
index 367a7e64..38a633e3 100644
--- a/atc/Makefile
+++ b/atc/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.11 1997/03/24 22:15:37 christos Exp $
+# $NetBSD: Makefile,v 1.12 1997/10/10 02:07:01 lukem Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= atc
-CFLAGS+=-DBSD -I${.CURDIR} -I.
+CFLAGS+=-DBSD -I${.CURDIR} -I. -DYY_NO_UNPUT
SRCS= extern.c grammar.c graphics.c input.c lex.c list.c log.c \
main.c tunable.c update.c
MAN= atc.6
diff --git a/atc/extern.c b/atc/extern.c
index 1f3d8980..f02eb4c3 100644
--- a/atc/extern.c
+++ b/atc/extern.c
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.c,v 1.4 1995/04/27 21:22:19 mycroft Exp $ */
+/* $NetBSD: extern.c,v 1.5 1997/10/10 02:07:04 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -45,11 +45,12 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: extern.c,v 1.4 1995/04/27 21:22:19 mycroft Exp $";
+__RCSID("$NetBSD: extern.c,v 1.5 1997/10/10 02:07:04 lukem Exp $");
#endif
#endif /* not lint */
diff --git a/atc/extern.h b/atc/extern.h
index ec5c3a7a..e233c1c8 100644
--- a/atc/extern.h
+++ b/atc/extern.h
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.4 1995/04/27 21:22:22 mycroft Exp $ */
+/* $NetBSD: extern.h,v 1.5 1997/10/10 02:07:06 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -61,4 +61,78 @@ extern struct termios tty_start, tty_new;
extern DISPLACEMENT displacement[MAXDIR];
-extern PLANE *findplane(), *newplane();
+int addplane __P((void));
+void append __P((LIST *, PLANE *));
+void check_adir __P((int, int, int));
+void check_edge __P((int, int));
+void check_edir __P((int, int, int));
+void check_line __P((int, int, int, int));
+void check_linepoint __P((int, int));
+void check_point __P((int, int));
+int checkdefs __P((void));
+int compar __P((const void *, const void *));
+void delete __P((LIST *, PLANE *));
+int dir_deg __P((int));
+int dir_no __P((char));
+void done_screen __P((void));
+void draw_all __P((void));
+void draw_line __P((WINDOW *, int, int, int, int, char *));
+void erase_all __P((void));
+int getAChar __P((void));
+int getcommand __P((void));
+int gettoken __P((void));
+void init_gr __P((void));
+void ioaddstr __P((int, char *));
+void ioclrtobot __P((void));
+void ioclrtoeol __P((int));
+void ioerror __P((int, int, char *));
+void iomove __P((int));
+int list_games __P((void));
+int log_score __P((int));
+void log_score_quit __P((int));
+void loser __P((PLANE *, char *));
+int main __P((int, char *[]));
+char name __P((PLANE *));
+int next_plane __P((void));
+void noise __P((void));
+int number __P((char));
+void planewin __P((void));
+int pop __P((void));
+void push __P((int, int));
+void quit __P((int));
+int read_file __P((char *));
+void redraw __P((void));
+void rezero __P((void));
+void setup_screen __P((C_SCREEN *));
+int too_close __P((PLANE *p1, PLANE *p2, int));
+void update __P((int));
+int yyerror __P((const char *));
+int yylex __P((void));
+int yyparse __P((void));
+char *Left __P((char));
+char *Right __P((char));
+char *airport __P((char));
+char *beacon __P((char));
+char *benum __P((char));
+char *circle __P((char));
+char *climb __P((char));
+char *command __P((PLANE *));
+char *default_game __P((void));
+char *delayb __P((char));
+char *descend __P((char));
+char *ex_it __P((char));
+PLANE *findplane __P((int));
+char *ignore __P((char));
+char *left __P((char));
+char *mark __P((char));
+PLANE *newplane __P((void));
+char *okay_game __P((char *));
+char *rel_dir __P((char));
+char *right __P((char));
+char *setalt __P((char));
+char *setplane __P((char));
+char *setrelalt __P((char));
+char *timestr __P((int));
+char *to_dir __P((char));
+char *turn __P((char));
+char *unmark __P((char));
diff --git a/atc/grammar.y b/atc/grammar.y
index a409b490..91266ac7 100644
--- a/atc/grammar.y
+++ b/atc/grammar.y
@@ -1,4 +1,4 @@
-/* $NetBSD: grammar.y,v 1.3 1995/03/21 15:03:59 cgd Exp $ */
+/* $NetBSD: grammar.y,v 1.4 1997/10/10 02:07:08 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -63,11 +63,12 @@
%{
#include "include.h"
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)grammar.y 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: grammar.y,v 1.3 1995/03/21 15:03:59 cgd Exp $";
+__RCSID("$NetBSD: grammar.y,v 1.4 1997/10/10 02:07:08 lukem Exp $");
#endif
#endif /* not lint */
@@ -288,14 +289,18 @@ Lline:
;
%%
+void
check_edge(x, y)
+ int x, y;
{
if (!(x == 0) && !(x == sp->width - 1) &&
!(y == 0) && !(y == sp->height - 1))
yyerror("edge value not on edge.");
}
+void
check_point(x, y)
+ int x, y;
{
if (x < 1 || x >= sp->width - 1)
yyerror("X value out of range.");
@@ -303,7 +308,9 @@ check_point(x, y)
yyerror("Y value out of range.");
}
+void
check_linepoint(x, y)
+ int x, y;
{
if (x < 0 || x >= sp->width)
yyerror("X value out of range.");
@@ -311,7 +318,9 @@ check_linepoint(x, y)
yyerror("Y value out of range.");
}
+void
check_line(x1, y1, x2, y2)
+ int x1, y1, x2, y2;
{
int d1, d2;
@@ -325,7 +334,9 @@ check_line(x1, y1, x2, y2)
yyerror("Bad line endpoints.");
}
+int
yyerror(s)
+ const char *s;
{
fprintf(stderr, "\"%s\": line %d: %s\n", file, line, s);
errors++;
@@ -333,7 +344,9 @@ yyerror(s)
return (errors);
}
+void
check_edir(x, y, dir)
+ int x, y, dir;
{
int bad = 0;
@@ -364,10 +377,13 @@ check_edir(x, y, dir)
yyerror("Bad direction for entrance at exit.");
}
+void
check_adir(x, y, dir)
+ int x, y, dir;
{
}
+int
checkdefs()
{
int err = 0;
diff --git a/atc/graphics.c b/atc/graphics.c
index 75df3925..6e4ec80c 100644
--- a/atc/graphics.c
+++ b/atc/graphics.c
@@ -1,4 +1,4 @@
-/* $NetBSD: graphics.c,v 1.3 1995/03/21 15:04:04 cgd Exp $ */
+/* $NetBSD: graphics.c,v 1.4 1997/10/10 02:07:11 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -45,18 +45,16 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)graphics.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: graphics.c,v 1.3 1995/03/21 15:04:04 cgd Exp $";
+__RCSID("$NetBSD: graphics.c,v 1.4 1997/10/10 02:07:11 lukem Exp $");
#endif
#endif /* not lint */
#include "include.h"
-#ifdef SYSV
-#include <errno.h>
-#endif
#define C_TOPBOTTOM '-'
#define C_LEFTRIGHT '|'
@@ -68,6 +66,7 @@ static char rcsid[] = "$NetBSD: graphics.c,v 1.3 1995/03/21 15:04:04 cgd Exp $";
WINDOW *radar, *cleanradar, *credit, *input, *planes;
+int
getAChar()
{
#ifdef BSD
@@ -81,6 +80,7 @@ getAChar()
#endif
}
+void
erase_all()
{
PLANE *pp;
@@ -95,6 +95,7 @@ erase_all()
}
}
+void
draw_all()
{
PLANE *pp;
@@ -114,6 +115,7 @@ draw_all()
fflush(stdout);
}
+void
init_gr()
{
static char buffer[BUFSIZ];
@@ -126,11 +128,12 @@ init_gr()
planes = newwin(LINES - INPUT_LINES, PLANE_COLS, 0, COLS - PLANE_COLS);
}
+void
setup_screen(scp)
C_SCREEN *scp;
{
- register int i, j;
- char str[3], *airstr;
+ int i, j;
+ char str[3], *airstr;
str[2] = '\0';
@@ -217,8 +220,10 @@ setup_screen(scp)
fflush(stdout);
}
+void
draw_line(w, x, y, lx, ly, s)
WINDOW *w;
+ int x, y, lx, ly;
char *s;
{
int dx, dy;
@@ -235,7 +240,9 @@ draw_line(w, x, y, lx, ly, s)
}
}
+void
ioclrtoeol(pos)
+ int pos;
{
wmove(input, 0, pos);
wclrtoeol(input);
@@ -243,14 +250,18 @@ ioclrtoeol(pos)
fflush(stdout);
}
+void
iomove(pos)
+ int pos;
{
wmove(input, 0, pos);
wrefresh(input);
fflush(stdout);
}
+void
ioaddstr(pos, str)
+ int pos;
char *str;
{
wmove(input, 0, pos);
@@ -259,6 +270,7 @@ ioaddstr(pos, str)
fflush(stdout);
}
+void
ioclrtobot()
{
wclrtobot(input);
@@ -266,7 +278,9 @@ ioclrtobot()
fflush(stdout);
}
+void
ioerror(pos, len, str)
+ int pos, len;
char *str;
{
int i;
@@ -280,7 +294,9 @@ ioerror(pos, len, str)
fflush(stdout);
}
-quit()
+void
+quit(dummy)
+ int dummy;
{
int c, y, x;
#ifdef BSD
@@ -317,13 +333,12 @@ quit()
wmove(input, y, x);
wrefresh(input);
fflush(stdout);
- return;
}
+void
planewin()
{
PLANE *pp;
- char *command();
int warning = 0;
#ifdef BSD
@@ -363,6 +378,7 @@ planewin()
fflush(stdout);
}
+void
loser(p, s)
PLANE *p;
char *s;
@@ -397,6 +413,7 @@ loser(p, s)
exit(0);
}
+void
redraw()
{
clear();
@@ -415,7 +432,7 @@ redraw()
fflush(stdout);
}
-
+void
done_screen()
{
clear();
diff --git a/atc/include.h b/atc/include.h
index bfa892e5..0afa881b 100644
--- a/atc/include.h
+++ b/atc/include.h
@@ -1,4 +1,4 @@
-/* $NetBSD: include.h,v 1.5 1995/04/27 21:22:23 mycroft Exp $ */
+/* $NetBSD: include.h,v 1.6 1997/10/10 02:07:14 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -47,38 +47,26 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
#include <sys/types.h>
-#include <pwd.h>
-#include <termios.h>
-
-#ifdef BSD
-#include <sys/time.h>
#include <sys/file.h>
-#endif
-
-#ifdef SYSV
-#include <fcntl.h>
-#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/time.h>
#include <sys/utsname.h>
-#endif
-
-#include <signal.h>
-#include <math.h>
+#include <sys/wait.h>
+#include <ctype.h>
#include <curses.h>
-
-#ifdef SYSV
-#define index strchr
-#define rindex strrchr
-#define bcopy(a,b,c) memcpy((b), (a), (c))
-#define bzero(a,b) memset((a), '\0', (b))
-#define srandom srand
-#define random rand
-#endif
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <math.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <termios.h>
+#include <unistd.h>
#include "def.h"
#include "struct.h"
diff --git a/atc/input.c b/atc/input.c
index 054e02fd..95ada133 100644
--- a/atc/input.c
+++ b/atc/input.c
@@ -1,4 +1,4 @@
-/* $NetBSD: input.c,v 1.5 1997/01/13 06:50:25 tls Exp $ */
+/* $NetBSD: input.c,v 1.6 1997/10/10 02:07:18 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -45,11 +45,12 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: input.c,v 1.5 1997/01/13 06:50:25 tls Exp $";
+__RCSID("$NetBSD: input.c,v 1.6 1997/10/10 02:07:18 lukem Exp $");
#endif
#endif not lint
@@ -73,7 +74,7 @@ typedef struct {
int token;
int to_state;
char *str;
- char *(*func)();
+ char *(*func) __P((char));
} RULE;
typedef struct {
@@ -99,10 +100,6 @@ typedef struct {
#define NUMSTATES NUMELS(st)
-char *setplane(), *circle(), *left(), *right(), *Left(), *Right(),
- *beacon(), *ex_it(), *climb(), *descend(), *setalt(), *setrelalt(),
- *benum(), *to_dir(), *rel_dir(), *delayb(), *mark(), *unmark(),
- *airport(), *turn(), *ignore();
RULE state0[] = { { ALPHATOKEN, 1, "%c:", setplane},
{ RETTOKEN, -1, "", NULL },
@@ -196,6 +193,7 @@ int level;
int tval;
int dest_type, dest_no, dir;
+int
pop()
{
if (level == 0)
@@ -210,6 +208,7 @@ pop()
return (0);
}
+void
rezero()
{
iomove(0);
@@ -222,7 +221,9 @@ rezero()
strcpy(T_STR, "");
}
+void
push(ruleno, ch)
+ int ruleno, ch;
{
int newstate, newpos;
@@ -243,10 +244,11 @@ push(ruleno, ch)
strcpy(T_STR, "");
}
+int
getcommand()
{
int c, i, done;
- char *s, *(*func)();
+ char *s, *(*func) __P((char));
PLANE *pp;
rezero();
@@ -301,12 +303,14 @@ getcommand()
return (0);
}
+void
noise()
{
putchar('\07');
fflush(stdout);
}
+int
gettoken()
{
while ((tval = getAChar()) == REDRAWTOKEN || tval == SHELLTOKEN)
@@ -325,7 +329,7 @@ gettoken()
#endif
if (fork() == 0) /* child */
{
- char *shell, *base, *getenv(), *strrchr();
+ char *shell, *base;
setuid(getuid()); /* turn off setuid bit */
done_screen();
@@ -372,6 +376,7 @@ gettoken()
char *
setplane(c)
+ char c;
{
PLANE *pp;
@@ -385,6 +390,7 @@ setplane(c)
char *
turn(c)
+ char c;
{
if (p.altitude == 0)
return ("Planes at airports may not change direction");
@@ -393,6 +399,7 @@ turn(c)
char *
circle(c)
+ char c;
{
if (p.altitude == 0)
return ("Planes cannot circle on the ground");
@@ -402,6 +409,7 @@ circle(c)
char *
left(c)
+ char c;
{
dir = D_LEFT;
p.new_dir = p.dir - 1;
@@ -412,6 +420,7 @@ left(c)
char *
right(c)
+ char c;
{
dir = D_RIGHT;
p.new_dir = p.dir + 1;
@@ -422,6 +431,7 @@ right(c)
char *
Left(c)
+ char c;
{
p.new_dir = p.dir - 2;
if (p.new_dir < 0)
@@ -431,6 +441,7 @@ Left(c)
char *
Right(c)
+ char c;
{
p.new_dir = p.dir + 2;
if (p.new_dir > MAXDIR)
@@ -440,6 +451,7 @@ Right(c)
char *
delayb(c)
+ char c;
{
int xdiff, ydiff;
@@ -485,6 +497,7 @@ delayb(c)
char *
beacon(c)
+ char c;
{
dest_type = T_BEACON;
return (NULL);
@@ -492,6 +505,7 @@ beacon(c)
char *
ex_it(c)
+ char c;
{
dest_type = T_EXIT;
return (NULL);
@@ -499,6 +513,7 @@ ex_it(c)
char *
airport(c)
+ char c;
{
dest_type = T_AIRPORT;
return (NULL);
@@ -506,6 +521,7 @@ airport(c)
char *
climb(c)
+ char c;
{
dir = D_UP;
return (NULL);
@@ -513,6 +529,7 @@ climb(c)
char *
descend(c)
+ char c;
{
dir = D_DOWN;
return (NULL);
@@ -520,6 +537,7 @@ descend(c)
char *
setalt(c)
+ char c;
{
if ((p.altitude == c - '0') && (p.new_altitude == p.altitude))
return ("Already at that altitude");
@@ -529,6 +547,7 @@ setalt(c)
char *
setrelalt(c)
+ char c;
{
if (c == 0)
return ("altitude not changed");
@@ -553,6 +572,7 @@ setrelalt(c)
char *
benum(c)
+ char c;
{
dest_no = c -= '0';
@@ -584,6 +604,7 @@ benum(c)
char *
to_dir(c)
+ char c;
{
p.new_dir = dir_no(c);
return (NULL);
@@ -591,6 +612,7 @@ to_dir(c)
char *
rel_dir(c)
+ char c;
{
int angle;
@@ -615,6 +637,7 @@ rel_dir(c)
char *
mark(c)
+ char c;
{
if (p.altitude == 0)
return ("Cannot mark planes on the ground");
@@ -626,6 +649,7 @@ mark(c)
char *
unmark(c)
+ char c;
{
if (p.altitude == 0)
return ("Cannot unmark planes on the ground");
@@ -637,6 +661,7 @@ unmark(c)
char *
ignore(c)
+ char c;
{
if (p.altitude == 0)
return ("Cannot ignore planes on the ground");
@@ -646,11 +671,13 @@ ignore(c)
return (NULL);
}
+int
dir_no(ch)
char ch;
{
int dir;
+ dir = -1;
switch (ch) {
case 'w': dir = 0; break;
case 'e': dir = 1; break;
diff --git a/atc/lex.l b/atc/lex.l
index 54f84c46..1bd76f6d 100644
--- a/atc/lex.l
+++ b/atc/lex.l
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: lex.l,v 1.3 1995/03/21 15:04:15 cgd Exp $ */
+/* $NetBSD: lex.l,v 1.4 1997/10/10 02:07:20 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -46,15 +46,18 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)lex.l 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: lex.l,v 1.3 1995/03/21 15:04:15 cgd Exp $";
+__RCSID("$NetBSD: lex.l,v 1.4 1997/10/10 02:07:20 lukem Exp $");
#endif
#endif /* not lint */
+#include "include.h"
#include "y.tab.h"
+
extern int line;
%}
diff --git a/atc/list.c b/atc/list.c
index 62132cb9..a8bfed02 100644
--- a/atc/list.c
+++ b/atc/list.c
@@ -1,4 +1,4 @@
-/* $NetBSD: list.c,v 1.3 1995/03/21 15:04:18 cgd Exp $ */
+/* $NetBSD: list.c,v 1.4 1997/10/10 02:07:23 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -45,11 +45,12 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)list.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: list.c,v 1.3 1995/03/21 15:04:18 cgd Exp $";
+__RCSID("$NetBSD: list.c,v 1.4 1997/10/10 02:07:23 lukem Exp $");
#endif
#endif /* not lint */
@@ -61,6 +62,7 @@ newplane()
return ((PLANE *) calloc(1, sizeof (PLANE)));
}
+void
append(l, p)
LIST *l;
PLANE *p;
@@ -99,6 +101,7 @@ append(l, p)
}
}
+void
delete(l, p)
LIST *l;
PLANE *p;
diff --git a/atc/log.c b/atc/log.c
index b887c936..fa61cc0c 100644
--- a/atc/log.c
+++ b/atc/log.c
@@ -1,4 +1,4 @@
-/* $NetBSD: log.c,v 1.4 1997/01/13 06:50:26 tls Exp $ */
+/* $NetBSD: log.c,v 1.5 1997/10/10 02:07:25 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -45,20 +45,26 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: log.c,v 1.4 1997/01/13 06:50:26 tls Exp $";
+__RCSID("$NetBSD: log.c,v 1.5 1997/10/10 02:07:25 lukem Exp $");
#endif
#endif not lint
#include "include.h"
#include "pathnames.h"
-compar(a, b)
- SCORE *a, *b;
+int
+compar(va, vb)
+ const void *va, *vb;
{
+ SCORE *a, *b;
+
+ a = (SCORE *)va;
+ b = (SCORE *)vb;
if (b->planes == a->planes)
return (b->time - a->time);
else
@@ -77,6 +83,7 @@ compar(a, b)
char *
timestr(t)
+ int t;
{
static char s[80];
@@ -94,16 +101,16 @@ timestr(t)
return (s);
}
+int
log_score(list_em)
+ int list_em;
{
- register int i, fd, num_scores = 0, good, changed = 0, found = 0;
+ int i, fd, num_scores = 0, good, changed = 0, found = 0;
struct passwd *pw;
FILE *fp;
- char *cp, *index(), *rindex();
+ char *cp;
SCORE score[100], thisscore;
-#ifdef SYSV
struct utsname name;
-#endif
umask(0);
fd = open(_PATH_SCORE, O_CREAT|O_RDWR, 0644);
@@ -149,18 +156,11 @@ log_score(list_em)
return (-1);
}
strcpy(thisscore.name, pw->pw_name);
-#ifdef BSD
- if (gethostname(thisscore.host, sizeof (thisscore.host)) < 0) {
- perror("gethostname");
- return (-1);
- }
-#endif
-#ifdef SYSV
uname(&name);
- strcpy(thisscore.host, name.sysname);
-#endif
+ strncpy(thisscore.host, name.sysname, sizeof(thisscore.host)-1);
+ thisscore.host[sizeof(thisscore.host) - 1] = '\0';
- cp = rindex(file, '/');
+ cp = strrchr(file, '/');
if (cp == NULL) {
fprintf(stderr, "log: where's the '/' in %s?\n", file);
return (-1);
@@ -240,7 +240,7 @@ log_score(list_em)
"game", "time", "real time", "planes safe");
puts("-------------------------------------------------------------------------------");
for (i = 0; i < num_scores; i++) {
- cp = index(score[i].host, '.');
+ cp = strchr(score[i].host, '.');
if (cp != NULL)
*cp = '\0';
printf("%2d: %-8s %-8s %-18s %4d %9s %4d\n", i + 1,
@@ -251,3 +251,11 @@ log_score(list_em)
putchar('\n');
return (0);
}
+
+void
+log_score_quit(dummy)
+ int dummy;
+{
+ (void)log_score(0);
+ exit(0);
+}
diff --git a/atc/main.c b/atc/main.c
index 9f2c0cef..29bf723f 100644
--- a/atc/main.c
+++ b/atc/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $ */
+/* $NetBSD: main.c,v 1.5 1997/10/10 02:07:30 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -45,24 +45,27 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1990, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1990, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: main.c,v 1.4 1995/04/27 21:22:25 mycroft Exp $";
+__RCSID("$NetBSD: main.c,v 1.5 1997/10/10 02:07:30 lukem Exp $");
#endif
#endif /* not lint */
#include "include.h"
#include "pathnames.h"
+
+int
main(ac, av)
+ int ac;
char *av[];
{
int seed;
@@ -74,8 +77,6 @@ main(ac, av)
#ifdef BSD
struct itimerval itv;
#endif
- extern char *default_game(), *okay_game();
- extern void log_score(), quit(), update();
start_time = seed = time(0);
@@ -83,7 +84,7 @@ main(ac, av)
while (*av) {
#ifndef SAVEDASH
if (**av == '-')
- *++*av;
+ ++*av;
else
break;
#endif
@@ -114,8 +115,7 @@ main(ac, av)
av++;
break;
default:
- fprintf(stderr, "Unknown option '%c'\n", *ptr,
- name);
+ warnx("unknown option '%c'\n", *ptr);
f_usage++;
break;
}
@@ -162,8 +162,8 @@ main(ac, av)
signal(SIGTSTP, SIG_IGN);
signal(SIGSTOP, SIG_IGN);
#endif
- signal(SIGHUP, log_score);
- signal(SIGTERM, log_score);
+ signal(SIGHUP, log_score_quit);
+ signal(SIGTERM, log_score_quit);
tcgetattr(fileno(stdin), &tty_start);
tty_new = tty_start;
@@ -203,7 +203,7 @@ main(ac, av)
alarm(0);
#endif
- update();
+ update(0);
#ifdef BSD
itv.it_value.tv_sec = sp->update_secs;
@@ -219,6 +219,7 @@ main(ac, av)
}
}
+int
read_file(s)
char *s;
{
@@ -300,6 +301,7 @@ okay_game(s)
return (ret);
}
+int
list_games()
{
FILE *fp;
diff --git a/atc/tunable.c b/atc/tunable.c
index b864e70d..bb0ba493 100644
--- a/atc/tunable.c
+++ b/atc/tunable.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tunable.c,v 1.3 1995/03/21 15:04:33 cgd Exp $ */
+/* $NetBSD: tunable.c,v 1.4 1997/10/10 02:07:32 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -45,11 +45,12 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)tunable.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: tunable.c,v 1.3 1995/03/21 15:04:33 cgd Exp $";
+__RCSID("$NetBSD: tunable.c,v 1.4 1997/10/10 02:07:32 lukem Exp $");
#endif
#endif /* not lint */
diff --git a/atc/update.c b/atc/update.c
index fd7c8a05..ef15c705 100644
--- a/atc/update.c
+++ b/atc/update.c
@@ -1,4 +1,4 @@
-/* $NetBSD: update.c,v 1.5 1997/01/13 06:50:27 tls Exp $ */
+/* $NetBSD: update.c,v 1.6 1997/10/10 02:07:34 lukem Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -45,20 +45,23 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: update.c,v 1.5 1997/01/13 06:50:27 tls Exp $";
+__RCSID("$NetBSD: update.c,v 1.6 1997/10/10 02:07:34 lukem Exp $");
#endif
#endif not lint
#include "include.h"
-update()
+void
+update(dummy)
+ int dummy;
{
- int i, dir_diff, mask, unclean;
- PLANE *pp, *p1, *p2, *p;
+ int i, dir_diff, unclean;
+ PLANE *pp, *p1, *p2;
#ifdef SYSV
alarm(0);
@@ -224,7 +227,6 @@ command(pp)
PLANE *pp;
{
static char buf[50], *bp, *comm_start;
- char *index();
buf[0] = '\0';
bp = buf;
@@ -232,7 +234,7 @@ command(pp)
(pp->fuel < LOWFUEL) ? '*' : ' ',
(pp->dest_type == T_AIRPORT) ? 'A' : 'E', pp->dest_no);
- comm_start = bp = index(buf, '\0');
+ comm_start = bp = strchr(buf, '\0');
if (pp->altitude == 0)
(void)sprintf(bp, "Holding @ A%d", pp->orig_no);
else if (pp->new_dir >= MAXDIR || pp->new_dir < 0)
@@ -240,18 +242,18 @@ command(pp)
else if (pp->new_dir != pp->dir)
(void)sprintf(bp, "%d", dir_deg(pp->new_dir));
- bp = index(buf, '\0');
+ bp = strchr(buf, '\0');
if (pp->delayd)
(void)sprintf(bp, " @ B%d", pp->delayd_no);
- bp = index(buf, '\0');
+ bp = strchr(buf, '\0');
if (*comm_start == '\0' &&
(pp->status == S_UNMARKED || pp->status == S_IGNORED))
strcpy(bp, "---------");
return (buf);
}
-/* char */
+char
name(p)
PLANE *p;
{
@@ -261,7 +263,9 @@ name(p)
return ('a' + p->plane_no);
}
+int
number(l)
+ char l;
{
if (l < 'a' && l > 'z' && l < 'A' && l > 'Z')
return (-1);
@@ -271,6 +275,7 @@ number(l)
return (l - 'A');
}
+int
next_plane()
{
static int last_plane = -1;
@@ -299,6 +304,7 @@ next_plane()
return (last_plane);
}
+int
addplane()
{
PLANE p, *pp, *p1;
@@ -383,8 +389,10 @@ findplane(n)
return (NULL);
}
+int
too_close(p1, p2, dist)
PLANE *p1, *p2;
+ int dist;
{
if (ABS(p1->altitude - p2->altitude) <= dist &&
ABS(p1->xpos - p2->xpos) <= dist && ABS(p1->ypos - p2->ypos) <= dist)
@@ -393,7 +401,9 @@ too_close(p1, p2, dist)
return (0);
}
+int
dir_deg(d)
+ int d;
{
switch (d) {
case 0: return (0);