X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/a1870bc7909b311399735583c9363b06af9b0a56..8d2dd1244517d9cf4b4e1fd9a4914c5496e8dfac:/atc/input.c 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 #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;