-/* $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
* 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
int token;
int to_state;
char *str;
- char *(*func)();
+ char *(*func) __P((char));
} RULE;
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 },
int tval;
int dest_type, dest_no, dir;
+int
pop()
{
if (level == 0)
return (0);
}
+void
rezero()
{
iomove(0);
strcpy(T_STR, "");
}
+void
push(ruleno, ch)
+ int ruleno, ch;
{
int newstate, newpos;
strcpy(T_STR, "");
}
+int
getcommand()
{
int c, i, done;
- char *s, *(*func)();
+ char *s, *(*func) __P((char));
PLANE *pp;
rezero();
return (0);
}
+void
noise()
{
putchar('\07');
fflush(stdout);
}
+int
gettoken()
{
while ((tval = getAChar()) == REDRAWTOKEN || tval == SHELLTOKEN)
#endif
if (fork() == 0) /* child */
{
- char *shell, *base, *getenv(), *strrchr();
+ char *shell, *base;
setuid(getuid()); /* turn off setuid bit */
done_screen();
char *
setplane(c)
+ char c;
{
PLANE *pp;
char *
turn(c)
+ char c;
{
if (p.altitude == 0)
return ("Planes at airports may not change direction");
char *
circle(c)
+ char c;
{
if (p.altitude == 0)
return ("Planes cannot circle on the ground");
char *
left(c)
+ char c;
{
dir = D_LEFT;
p.new_dir = p.dir - 1;
char *
right(c)
+ char c;
{
dir = D_RIGHT;
p.new_dir = p.dir + 1;
char *
Left(c)
+ char c;
{
p.new_dir = p.dir - 2;
if (p.new_dir < 0)
char *
Right(c)
+ char c;
{
p.new_dir = p.dir + 2;
if (p.new_dir > MAXDIR)
char *
delayb(c)
+ char c;
{
int xdiff, ydiff;
char *
beacon(c)
+ char c;
{
dest_type = T_BEACON;
return (NULL);
char *
ex_it(c)
+ char c;
{
dest_type = T_EXIT;
return (NULL);
char *
airport(c)
+ char c;
{
dest_type = T_AIRPORT;
return (NULL);
char *
climb(c)
+ char c;
{
dir = D_UP;
return (NULL);
char *
descend(c)
+ char c;
{
dir = D_DOWN;
return (NULL);
char *
setalt(c)
+ char c;
{
if ((p.altitude == c - '0') && (p.new_altitude == p.altitude))
return ("Already at that altitude");
char *
setrelalt(c)
+ char c;
{
if (c == 0)
return ("altitude not changed");
char *
benum(c)
+ char c;
{
dest_no = c -= '0';
char *
to_dir(c)
+ char c;
{
p.new_dir = dir_no(c);
return (NULL);
char *
rel_dir(c)
+ char c;
{
int angle;
char *
mark(c)
+ char c;
{
if (p.altitude == 0)
return ("Cannot mark planes on the ground");
char *
unmark(c)
+ char c;
{
if (p.altitude == 0)
return ("Cannot unmark planes on the ground");
char *
ignore(c)
+ char c;
{
if (p.altitude == 0)
return ("Cannot ignore planes on the ground");
return (NULL);
}
+int
dir_no(ch)
char ch;
{
int dir;
+ dir = -1;
switch (ch) {
case 'w': dir = 0; break;
case 'e': dir = 1; break;