Merge a bunch of cleanups from NetBSD.

PR:		8083
Submitted by:	Stephen J. Roznowski <sjr@home.net>
Obtained from:	a whole slew of NetBSD PRs
This commit is contained in:
Steve Price 1999-04-19 03:59:02 +00:00
parent f1cb6ca392
commit af71cfbb87
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=45801
93 changed files with 696 additions and 579 deletions

View File

@ -39,9 +39,9 @@ static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 5/31/93";
static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91"; static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91";
#endif /* not lint */ #endif /* not lint */
typedef unsigned long u_long; #include <sys/types.h>
u_long crctab[] = { const u_long crctab[] = {
0x7fffffff, 0x7fffffff,
0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e,
@ -105,7 +105,7 @@ u_long crctab[] = {
*/ */
u_long crcval; u_long crcval;
int step; u_int step;
crc_start() crc_start()
{ {
@ -113,11 +113,11 @@ crc_start()
} }
u_long crc(ptr, nr) /* Process nr bytes at a time; ptr points to them */ u_long crc(ptr, nr) /* Process nr bytes at a time; ptr points to them */
char *ptr; const char *ptr;
int nr; int nr;
{ {
register int i; register int i;
register char *p; register const char *p;
while (nr > 0) while (nr > 0)
for (p = ptr; nr--; ++p) for (p = ptr; nr--; ++p)

View File

@ -109,6 +109,7 @@ int entry; /* entry=2 means goto 20000 */ /* 3=19000 */
} }
void
die(entry) /* label 90 */ die(entry) /* label 90 */
int entry; int entry;
{ register int i; { register int i;
@ -135,5 +136,4 @@ int entry;
} }
loc=3; loc=3;
oldloc=loc; oldloc=loc;
return(2000);
} }

View File

@ -53,15 +53,16 @@
/* hdr.h: included by c advent files */ /* hdr.h: included by c advent files */
#include <sys/types.h> #include <sys/types.h>
#include <signal.h>
int datfd; /* message file descriptor */ int datfd; /* message file descriptor */
int delhit; volatile sig_atomic_t delhit;
int yea; int yea;
extern char data_file[]; /* Virtual data file */ extern char data_file[]; /* Virtual data file */
#define TAB 011 #define TAB 011
#define LF 012 #define LF 012
#define FLUSHLINE while (getchar()!='\n') #define FLUSHLINE do { int flushline_ch; while ((flushline_ch = getchar()) != EOF && flushline_ch != '\n'); } while (0)
#define FLUSHLF while (next()!=LF) #define FLUSHLF while (next()!=LF)
int loc,newloc,oldloc,oldlc2,wzdark,gaveup,kq,k,k2; int loc,newloc,oldloc,oldlc2,wzdark,gaveup,kq,k,k2;

View File

@ -197,14 +197,14 @@ linkdata() /* secondary data manipulation */
trapdel() /* come here if he hits a del */ trapdel() /* come here if he hits a del */
{ delhit++; /* main checks, treats as QUIT */ { delhit = 1; /* main checks, treats as QUIT */
signal(2,trapdel); /* catch subsequent DELs */ signal(2,trapdel); /* catch subsequent DELs */
} }
startup() startup()
{ {
demo=Start(0); demo=Start();
srandomdev(); srandomdev();
hinted[3]=yes(65,1,0); hinted[3]=yes(65,1,0);
newloc=1; newloc=1;

View File

@ -46,6 +46,7 @@ static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <err.h>
getin(wrd1,wrd2) /* get command from user */ getin(wrd1,wrd2) /* get command from user */
@ -78,6 +79,9 @@ char **wrd1,**wrd2; /* no prompt, usually */
*s=0; *s=0;
return; return;
} }
case EOF:
printf("user closed input stream, quitting...\n");
exit(0);
default: default:
if (++numch>=MAXSTR) /* string too long */ if (++numch>=MAXSTR) /* string too long */
{ printf("Give me a break!!\n"); { printf("Give me a break!!\n");
@ -90,27 +94,19 @@ char **wrd1,**wrd2; /* no prompt, usually */
} }
} }
confirm(mesg) /* confirm irreversible action */
char *mesg;
{ register int result;
printf("%s",mesg); /* tell him what he did */
if (getchar()=='y') /* was his first letter a 'y'? */
result=1;
else result=0;
FLUSHLINE;
return(result);
}
yes(x,y,z) /* confirm with rspeak */ yes(x,y,z) /* confirm with rspeak */
int x,y,z; int x,y,z;
{ register int result; { register int result;
register char ch; int ch;
for (;;) for (;;)
{ rspeak(x); /* tell him what we want*/ { rspeak(x); /* tell him what we want*/
if ((ch=getchar())=='y') if ((ch=getchar())=='y')
result=TRUE; result=TRUE;
else if (ch=='n') result=FALSE; else if (ch=='n') result=FALSE;
else if (ch == EOF) {
printf("user closed input stream, quitting...\n");
exit(0);
}
FLUSHLINE; FLUSHLINE;
if (ch=='y'|| ch=='n') break; if (ch=='y'|| ch=='n') break;
printf("Please answer the question.\n"); printf("Please answer the question.\n");
@ -123,12 +119,16 @@ int x,y,z;
yesm(x,y,z) /* confirm with mspeak */ yesm(x,y,z) /* confirm with mspeak */
int x,y,z; int x,y,z;
{ register int result; { register int result;
register char ch; int ch;
for (;;) for (;;)
{ mspeak(x); /* tell him what we want*/ { mspeak(x); /* tell him what we want*/
if ((ch=getchar())=='y') if ((ch=getchar())=='y')
result=TRUE; result=TRUE;
else if (ch=='n') result=FALSE; else if (ch=='n') result=FALSE;
else if (ch == EOF) {
printf("user closed input stream, quitting...\n");
exit(0);
}
FLUSHLINE; FLUSHLINE;
if (ch=='y'|| ch=='n') break; if (ch=='y'|| ch=='n') break;
printf("Please answer the question.\n"); printf("Please answer the question.\n");
@ -144,8 +144,8 @@ char *inptr; /* Pointer into virtual disk */
int outsw = 0; /* putting stuff to data file? */ int outsw = 0; /* putting stuff to data file? */
char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l"; const char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l";
char *tape = iotape; /* pointer to encryption tape */ const char *tape = iotape; /* pointer to encryption tape */
next() /* next virtual char, bump adr */ next() /* next virtual char, bump adr */
{ {
@ -274,8 +274,7 @@ int sect;
break; break;
case 6: /* random messages */ case 6: /* random messages */
if (oldloc>RTXSIZ) if (oldloc>RTXSIZ)
{ printf("Too many random msgs\n"); { errx(1, "Too many random msgs");
exit(0);
} }
rtext[oldloc].seekadr=seekhere; rtext[oldloc].seekadr=seekhere;
rtext[oldloc].txtlen=maystart-seekstart; rtext[oldloc].txtlen=maystart-seekstart;
@ -287,15 +286,13 @@ int sect;
break; break;
case 12: /* magic messages */ case 12: /* magic messages */
if (oldloc>MAGSIZ) if (oldloc>MAGSIZ)
{ printf("Too many magic msgs\n"); { errx(1, "Too many magic msgs");
exit(0);
} }
mtext[oldloc].seekadr=seekhere; mtext[oldloc].seekadr=seekhere;
mtext[oldloc].txtlen=maystart-seekstart; mtext[oldloc].txtlen=maystart-seekstart;
break; break;
default: default:
printf("rdesc called with bad section\n"); errx(1, "rdesc called with bad section");
exit(0);
} }
seekhere += maystart-seekstart; seekhere += maystart-seekstart;
} }
@ -331,13 +328,15 @@ rtrav() /* read travel table */
if (locc!=oldloc) /* getting a new entry */ if (locc!=oldloc) /* getting a new entry */
{ t=travel[locc]=(struct travlist *) malloc(sizeof (struct travlist)); { t=travel[locc]=(struct travlist *) malloc(sizeof (struct travlist));
/* printf("New travel list for %d\n",locc); */ /* printf("New travel list for %d\n",locc); */
if (t == NULL)
errx(1, "Out of memory!");
entries=0; entries=0;
oldloc=locc; oldloc=locc;
} }
for (s=buf;; *s++) /* get the newloc number /ASCII */ for (s=buf;; *s++) /* get the newloc number /ASCII */
if ((*s=next())==TAB || *s==LF) break; if ((*s=next())==TAB || *s==LF) break;
*s=0; *s=0;
len=length(buf)-1; /* quad long number handling */ len=strlen(buf); /* quad long number handling */
/* printf("Newloc: %s (%d chars)\n",buf,len); */ /* printf("Newloc: %s (%d chars)\n",buf,len); */
if (len<4) /* no "m" conditions */ if (len<4) /* no "m" conditions */
{ m=0; { m=0;
@ -349,7 +348,11 @@ rtrav() /* read travel table */
m=atoi(buf); m=atoi(buf);
} }
while (breakch!=LF) /* only do one line at a time */ while (breakch!=LF) /* only do one line at a time */
{ if (entries++) t=t->next=(struct travlist *) malloc(sizeof (struct travlist)); { if (entries++) {
t=t->next=(struct travlist *) malloc(sizeof (struct travlist));
if (t == NULL)
errx(1, "Out of memory!");
}
t->tverb=rnum();/* get verb from the file */ t->tverb=rnum();/* get verb from the file */
t->tloc=n; /* table entry mod 1000 */ t->tloc=n; /* table entry mod 1000 */
t->conditions=m;/* table entry / 1000 */ t->conditions=m;/* table entry / 1000 */
@ -453,7 +456,7 @@ int msg;
speak(msg) /* read, decrypt, and print a message (not ptext) */ speak(msg) /* read, decrypt, and print a message (not ptext) */
struct text *msg;/* msg is a pointer to seek address and length of mess */ const struct text *msg;/* msg is a pointer to seek address and length of mess */
{ {
register char *s, nonfirst; register char *s, nonfirst;
@ -486,7 +489,8 @@ int skip; /* assumes object 1 doesn't have prop 1, obj 2 no prop 2 &c*/
char *tbuf; char *tbuf;
msg = &ptext[m]; msg = &ptext[m];
if ((tbuf=(char *) malloc(msg->txtlen + 1)) == 0) bug(108); if ((tbuf=(char *) malloc(msg->txtlen + 1)) == 0)
errx(1, "Out of memory!");
memcpy(tbuf, msg->seekadr, msg->txtlen + 1); /* Room to null */ memcpy(tbuf, msg->seekadr, msg->txtlen + 1); /* Room to null */
s = tbuf; s = tbuf;

View File

@ -51,6 +51,7 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93";
#include <sys/file.h> #include <sys/file.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "hdr.h" #include "hdr.h"
@ -68,7 +69,7 @@ char **argv;
setgid(getgid()); setgid(getgid());
init(); /* Initialize everything */ init(); /* Initialize everything */
signal(2,trapdel); signal(SIGINT,trapdel);
if (argc > 1) /* Restore file specified */ if (argc > 1) /* Restore file specified */
{ /* Restart is label 8305 (Fortran) */ { /* Restart is label 8305 (Fortran) */
@ -76,15 +77,15 @@ char **argv;
switch(i) switch(i)
{ {
case 0: /* The restore worked fine */ case 0: /* The restore worked fine */
yea=Start(0); yea=Start();
k=null; k=null;
unlink(argv[1]);/* Don't re-use the save */ unlink(argv[1]);/* Don't re-use the save */
goto l8; /* Get where we're going */ goto l8; /* Get where we're going */
case 1: /* Couldn't open it */ case 1: /* Couldn't open it */
exit(0); /* So give up */ exit(1); /* So give up */
case 2: /* Oops -- file was altered */ case 2: /* Oops -- file was altered */
rspeak(202); /* You dissolve */ rspeak(202); /* You dissolve */
exit(0); /* File could be non-adventure */ exit(1); /* File could be non-adventure */
} /* So don't unlink it. */ } /* So don't unlink it. */
} }
@ -105,7 +106,7 @@ char **argv;
kk = &stext[loc]; kk = &stext[loc];
if ((abb[loc]%abbnum)==0 || kk->seekadr==0) if ((abb[loc]%abbnum)==0 || kk->seekadr==0)
kk = &ltext[loc]; kk = &ltext[loc];
if (!forced(loc) && dark(0)) if (!forced(loc) && dark())
{ if (wzdark && pct(35)) { if (wzdark && pct(35))
{ die(90); { die(90);
goto l2000; goto l2000;
@ -118,7 +119,7 @@ char **argv;
if (forced(loc)) if (forced(loc))
goto l8; goto l8;
if (loc==33 && pct(25)&&!closng) rspeak(8); if (loc==33 && pct(25)&&!closng) rspeak(8);
if (!dark(0)) if (!dark())
{ abb[loc]++; { abb[loc]++;
for (i=atloc[loc]; i!=0; i=linkx[i]) /*2004 */ for (i=atloc[loc]; i!=0; i=linkx[i]) /*2004 */
{ obj=i; { obj=i;
@ -153,12 +154,12 @@ char **argv;
if (toting(i)&&prop[i]<0) /*2604 */ if (toting(i)&&prop[i]<0) /*2604 */
prop[i] = -1-prop[i]; prop[i] = -1-prop[i];
} }
wzdark=dark(0); /* 2605 */ wzdark=dark(); /* 2605 */
if (knfloc>0 && knfloc!=loc) knfloc=1; if (knfloc>0 && knfloc!=loc) knfloc=1;
getin(&wd1,&wd2); getin(&wd1,&wd2);
if (delhit) /* user typed a DEL */ if (delhit) /* user typed a DEL */
{ delhit=0; /* reset counter */ { delhit=0; /* reset counter */
copystr("quit",wd1); /* pretend he's quitting*/ strcpy(wd1,"quit"); /* pretend he's quitting*/
*wd2=0; *wd2=0;
} }
l2608: if ((foobar = -foobar)>0) foobar=0; /* 2608 */ l2608: if ((foobar = -foobar)>0) foobar=0; /* 2608 */
@ -210,16 +211,16 @@ char **argv;
} }
l19999: k=43; l19999: k=43;
if (liqloc(loc)==water) k=70; if (liqloc(loc)==water) k=70;
if (weq(wd1,"enter") && if (!strncmp(wd1,"enter",5) &&
(weq(wd2,"strea")||weq(wd2,"water"))) (!strncmp(wd2,"strea",5)||!strncmp(wd2,"water",5)))
goto l2010; goto l2010;
if (weq(wd1,"enter") && *wd2!=0) goto l2800; if (!strncmp(wd1,"enter",5) && *wd2!=0) goto l2800;
if ((!weq(wd1,"water")&&!weq(wd1,"oil")) if ((strncmp(wd1,"water",5)&&strncmp(wd1,"oil",3))
|| (!weq(wd2,"plant")&&!weq(wd2,"door"))) || (strncmp(wd2,"plant",5)&&strncmp(wd2,"door",4)))
goto l2610; goto l2610;
if (at(vocab(wd2,1))) copystr("pour",wd2); if (at(vocab(wd2,1))) strcpy(wd2,"pour");
l2610: if (weq(wd1,"west")) l2610: if (!strncmp(wd1,"west",4))
if (++iwest==10) rspeak(17); if (++iwest==10) rspeak(17);
l2630: i=vocab(wd1,-1); l2630: i=vocab(wd1,-1);
if (i== -1) if (i== -1)
@ -237,22 +238,19 @@ char **argv;
case 3: goto l4000; case 3: goto l4000;
case 4: goto l2010; case 4: goto l2010;
default: default:
printf("Error 22\n"); bug(22);
exit(0);
} }
l8: l8:
switch(march()) switch(march())
{ case 2: continue; /* i.e. goto l2 */ { case 2: continue; /* i.e. goto l2 */
case 99: case 99:
switch(die(99)) die(99);
{ case 2000: goto l2000; goto l2000;
default: bug(111);
}
default: bug(110); default: bug(110);
} }
l2800: copystr(wd2,wd1); l2800: strcpy(wd1,wd2);
*wd2=0; *wd2=0;
goto l2610; goto l2610;
@ -355,7 +353,7 @@ char **argv;
if (here(tablet)) obj=obj*100+tablet; if (here(tablet)) obj=obj*100+tablet;
if (here(messag)) obj=obj*100+messag; if (here(messag)) obj=obj*100+messag;
if (closed&&toting(oyster)) obj=oyster; if (closed&&toting(oyster)) obj=oyster;
if (obj>100||obj==0||dark(0)) goto l8000; if (obj>100||obj==0||dark()) goto l8000;
goto l9270; goto l9270;
case 30: /* suspend=8300 */ case 30: /* suspend=8300 */
spk=201; spk=201;
@ -366,7 +364,7 @@ char **argv;
printf(" %d minutes before continuing.",latncy); printf(" %d minutes before continuing.",latncy);
if (!yes(200,54,54)) goto l2012; if (!yes(200,54,54)) goto l2012;
datime(&saved,&savet); datime(&saved,&savet);
ciao(argv[0]); /* Do we quit? */ ciao(); /* Do we quit? */
continue; /* Maybe not */ continue; /* Maybe not */
case 31: /* hours=8310 */ case 31: /* hours=8310 */
printf("Colossal cave is closed 9am-5pm Mon "); printf("Colossal cave is closed 9am-5pm Mon ");
@ -418,7 +416,7 @@ char **argv;
l9080: if (!here(lamp)) goto l2011; l9080: if (!here(lamp)) goto l2011;
prop[lamp]=0; prop[lamp]=0;
rspeak(40); rspeak(40);
if (dark(0)) rspeak(16); if (dark()) rspeak(16);
goto l2012; goto l2012;
case 9: /* wave */ case 9: /* wave */
@ -443,7 +441,7 @@ char **argv;
default: bug(112); default: bug(112);
} }
l9130: case 13: /* pour */ l9130: case 13: /* pour */
if (obj==bottle||obj==0) obj=liq(0); if (obj==bottle||obj==0) obj=liq();
if (obj==0) goto l8000; if (obj==0) goto l8000;
if (!toting(obj)) goto l2011; if (!toting(obj)) goto l2011;
spk=78; spk=78;
@ -472,10 +470,10 @@ char **argv;
||obj==bear) spk=71; ||obj==bear) spk=71;
goto l2011; goto l2011;
l9150: case 15: /* 9150 - drink */ l9150: case 15: /* 9150 - drink */
if (obj==0&&liqloc(loc)!=water&&(liq(0)!=water if (obj==0&&liqloc(loc)!=water&&(liq()!=water
||!here(bottle))) goto l8000; ||!here(bottle))) goto l8000;
if (obj!=0&&obj!=water) spk=110; if (obj!=0&&obj!=water) spk=110;
if (spk==110||liq(0)!=water||!here(bottle)) if (spk==110||liq()!=water||!here(bottle))
goto l2011; goto l2011;
prop[bottle]=1; prop[bottle]=1;
place[water]=0; place[water]=0;
@ -494,7 +492,7 @@ char **argv;
default: bug(113); default: bug(113);
} }
case 19: case 20: /* 9190: find, invent */ case 19: case 20: /* 9190: find, invent */
if (at(obj)||(liq(0)==obj&&at(bottle)) if (at(obj)||(liq()==obj&&at(bottle))
||k==liqloc(loc)) spk=94; ||k==liqloc(loc)) spk=94;
for (i=1; i<=5; i++) for (i=1; i<=5; i++)
if (dloc[i]==loc&&dflag>=2&&obj==dwarf) if (dloc[i]==loc&&dflag>=2&&obj==dwarf)
@ -522,7 +520,7 @@ char **argv;
rspeak(bonus); rspeak(bonus);
done(2); done(2);
l9270: case 27: /* read */ l9270: case 27: /* read */
if (dark(0)) goto l5190; if (dark()) goto l5190;
if (obj==magzin) spk=190; if (obj==magzin) spk=190;
if (obj==tablet) spk=196; if (obj==tablet) spk=196;
if (obj==messag) spk=191; if (obj==messag) spk=191;
@ -566,7 +564,7 @@ char **argv;
l5110: if (k!=dwarf) goto l5120; l5110: if (k!=dwarf) goto l5120;
for (i=1; i<=5; i++) for (i=1; i<=5; i++)
if (dloc[i]==loc&&dflag>=2) goto l5010; if (dloc[i]==loc&&dflag>=2) goto l5010;
l5120: if ((liq(0)==k&&here(bottle))||k==liqloc(loc)) goto l5010; l5120: if ((liq()==k&&here(bottle))||k==liqloc(loc)) goto l5010;
if (obj!=plant||!at(plant2)||prop[plant2]==0) goto l5130; if (obj!=plant||!at(plant2)||prop[plant2]==0) goto l5130;
obj=plant2; obj=plant2;
goto l5010; goto l5010;

View File

@ -118,7 +118,7 @@ struct savestruct save_array[] =
}; };
save(outfile) /* Two passes on data: first to get checksum, second */ save(outfile) /* Two passes on data: first to get checksum, second */
char *outfile; /* to output the data using checksum to start random #s */ const char *outfile; /* to output the data using checksum to start random #s */
{ {
FILE *out; FILE *out;
struct savestruct *p; struct savestruct *p;
@ -151,7 +151,7 @@ char *outfile; /* to output the data using checksum to start random #s */
} }
restore(infile) restore(infile)
char *infile; const char *infile;
{ {
FILE *in; FILE *in;
struct savestruct *p; struct savestruct *p;

View File

@ -59,15 +59,14 @@ static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <err.h>
#include "hdr.h" /* SEED lives in there; keep them coordinated. */ #include "hdr.h" /* SEED lives in there; keep them coordinated. */
#define USAGE "Usage: setup file > data.c (file is typically glorkz)\n" #define USAGE "Usage: setup file > data.c (file is typically glorkz)"
#define YES 1 #define YES 1
#define NO 0 #define NO 0
void fatal();
#define LINE 10 /* How many values do we get on a line? */ #define LINE 10 /* How many values do we get on a line? */
main(argc, argv) main(argc, argv)
@ -77,10 +76,10 @@ char *argv[];
FILE *infile; FILE *infile;
int c, count, linestart; int c, count, linestart;
if (argc != 2) fatal(USAGE); if (argc != 2) errx(1, USAGE);
if ((infile = fopen(argv[1], "r")) == NULL) if ((infile = fopen(argv[1], "r")) == NULL)
fatal("Can't read file %s.\n", argv[1]); err(1, "Can't read file %s", argv[1]);
puts("/*\n * data.c: created by setup from the ascii data file."); puts("/*\n * data.c: created by setup from the ascii data file.");
puts(SIG1); puts(SIG1);
puts(SIG2); puts(SIG2);
@ -118,11 +117,3 @@ char *argv[];
fclose(infile); fclose(infile);
exit(0); exit(0);
} }
void fatal(format, arg)
char *format;
{
fprintf(stderr, format, arg);
exit(1);
}

View File

@ -43,6 +43,7 @@ static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93";
/* Re-coding of advent in C: subroutines from main */ /* Re-coding of advent in C: subroutines from main */
#include <stdio.h> #include <stdio.h>
#include <string.h>
# include "hdr.h" # include "hdr.h"
/* Statement functions */ /* Statement functions */
@ -69,7 +70,7 @@ int pbotl;
{ return((1-pbotl)*water+(pbotl/2)*(water+oil)); { return((1-pbotl)*water+(pbotl/2)*(water+oil));
} }
liq(foo) liq()
{ register int i; { register int i;
i=prop[bottle]; i=prop[bottle];
if (i>-1-i) return(liq2(i)); if (i>-1-i) return(liq2(i));
@ -98,7 +99,7 @@ int locc;
return(FALSE); return(FALSE);
} }
dark(foo) dark()
{ if ((cond[loc]%2)==0 && (prop[lamp]==0 || !here(lamp))) { if ((cond[loc]%2)==0 && (prop[lamp]==0 || !here(lamp)))
return(TRUE); return(TRUE);
return(FALSE); return(FALSE);
@ -373,6 +374,7 @@ trbridge() /* 30300 */
} }
int
badmove() /* 20 */ badmove() /* 20 */
{ spk=12; { spk=12;
if (k>=43 && k<=50) spk=9; if (k>=43 && k<=50) spk=9;
@ -383,16 +385,17 @@ badmove() /* 20 */
if (k==62||k==65) spk=42; if (k==62||k==65) spk=42;
if (k==17) spk=80; if (k==17) spk=80;
rspeak(spk); rspeak(spk);
return(2);
} }
int
bug(n) bug(n)
int n; int n;
{ printf("Please tell jim@rand.org that fatal bug %d happened.\n",n); { printf("Please tell jim@rand.org that fatal bug %d happened.\n",n);
exit(0); exit(1);
} }
void
checkhints() /* 2600 &c */ checkhints() /* 2600 &c */
{ register int hint; { register int hint;
for (hint=4; hint<=hntmax; hint++) for (hint=4; hint<=hntmax; hint++)
@ -433,7 +436,7 @@ checkhints() /* 2600 &c */
trsay() /* 9030 */ trsay() /* 9030 */
{ register int i; { register int i;
if (*wd2!=0) copystr(wd2,wd1); if (*wd2!=0) strcpy(wd1,wd2);
i=vocab(wd1,-1); i=vocab(wd1,-1);
if (i==62||i==65||i==71||i==2025) if (i==62||i==65||i==71||i==2025)
{ *wd2=0; { *wd2=0;
@ -454,7 +457,7 @@ trtake() /* 9010 */
if (obj==chain&&prop[bear]!=0) spk=170; if (obj==chain&&prop[bear]!=0) spk=170;
if (fixed[obj]!=0) return(2011); if (fixed[obj]!=0) return(2011);
if (obj==water||obj==oil) if (obj==water||obj==oil)
{ if (here(bottle)&&liq(0)==obj) { if (here(bottle)&&liq()==obj)
{ obj=bottle; { obj=bottle;
goto l9017; goto l9017;
} }
@ -484,14 +487,14 @@ l9017: if (holdng>=7)
l9014: if ((obj==bird||obj==cage)&&prop[bird]!=0) l9014: if ((obj==bird||obj==cage)&&prop[bird]!=0)
carry(bird+cage-obj,loc); carry(bird+cage-obj,loc);
carry(obj,loc); carry(obj,loc);
k=liq(0); k=liq();
if (obj==bottle && k!=0) place[k] = -1; if (obj==bottle && k!=0) place[k] = -1;
return(2009); return(2009);
} }
dropper() /* 9021 */ dropper() /* 9021 */
{ k=liq(0); { k=liq();
if (k==obj) obj=bottle; if (k==obj) obj=bottle;
if (obj==bottle&&k!=0) place[k]=0; if (obj==bottle&&k!=0) place[k]=0;
if (obj==cage&&prop[bird]!=0) drop(bird,loc); if (obj==cage&&prop[bird]!=0) drop(bird,loc);
@ -640,7 +643,7 @@ trkill() /* 9120 */
verb=0; verb=0;
obj=0; obj=0;
getin(&wd1,&wd2); getin(&wd1,&wd2);
if (!weq(wd1,"y")&&!weq(wd1,"yes")) return(2608); if (strncmp(wd1,"y",1)&&strncmp(wd1,"yes",3)) return(2608);
pspeak(dragon,1); pspeak(dragon,1);
prop[dragon]=2; prop[dragon]=2;
prop[rug]=0; prop[rug]=0;
@ -764,16 +767,17 @@ trfill() /* 9220 */
if (obj==0&&!here(bottle)) return(8000); if (obj==0&&!here(bottle)) return(8000);
spk=107; spk=107;
if (liqloc(loc)==0) spk=106; if (liqloc(loc)==0) spk=106;
if (liq(0)!=0) spk=105; if (liq()!=0) spk=105;
if (spk!=107) return(2011); if (spk!=107) return(2011);
prop[bottle]=((cond[loc]%4)/2)*2; prop[bottle]=((cond[loc]%4)/2)*2;
k=liq(0); k=liq();
if (toting(bottle)) place[k]= -1; if (toting(bottle)) place[k]= -1;
if (k==oil) spk=108; if (k==oil) spk=108;
return(2011); return(2011);
} }
void
closing() /* 10000 */ closing() /* 10000 */
{ register int i; { register int i;
@ -795,10 +799,10 @@ closing() /* 10000 */
rspeak(129); rspeak(129);
clock1 = -1; clock1 = -1;
closng=TRUE; closng=TRUE;
return(19999);
} }
void
caveclose() /* 11000 */ caveclose() /* 11000 */
{ register int i; { register int i;
prop[bottle]=put(bottle,115,1); prop[bottle]=put(bottle,115,1);
@ -825,5 +829,4 @@ caveclose() /* 11000 */
if (toting(i)) dstroy(i); if (toting(i)) dstroy(i);
rspeak(132); rspeak(132);
closed=TRUE; closed=TRUE;
return(2);
} }

View File

@ -44,6 +44,7 @@ static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93";
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <err.h>
#include "hdr.h" #include "hdr.h"
dstroy(object) dstroy(object)
@ -113,11 +114,12 @@ int object,where;
vocab(word,type,value) /* look up or store a word */ vocab(word,type,value) /* look up or store a word */
char *word; const char *word;
int type; /* -2 for store, -1 for user word, >=0 for canned lookup*/ int type; /* -2 for store, -1 for user word, >=0 for canned lookup*/
int value; /* used for storing only */ int value; /* used for storing only */
{ register int adr; { register int adr;
register char *s,*t; const char *s;
register char *t;
int hash, i; int hash, i;
struct hashtab *h; struct hashtab *h;
@ -134,13 +136,15 @@ int value; /* used for storing only */
if (h->val) /* already got an entry? */ if (h->val) /* already got an entry? */
goto exitloop2; goto exitloop2;
h->val=value; h->val=value;
h->atab=malloc(length(word)); h->atab=malloc(strlen(word)+1);
if (h->atab == NULL)
errx(1, "Out of memory!");
for (s=word,t=h->atab; *s;) for (s=word,t=h->atab; *s;)
*t++ = *s++ ^ '='; *t++ = *s++ ^ '=';
*t=0^'='; *t=0^'=';
/* encrypt slightly to thwart core reader */ /* encrypt slightly to thwart core reader */
/* printf("Stored \"%s\" (%d ch) as entry %d\n", */ /* printf("Stored \"%s\" (%d ch) as entry %d\n", */
/* word, length(word), adr); */ /* word, strlen(word)+1, adr); */
return(0); /* entry unused */ return(0); /* entry unused */
case -1: /* looking up user word */ case -1: /* looking up user word */
if (h->val==0) return(-1); /* not found */ if (h->val==0) return(-1); /* not found */
@ -152,8 +156,7 @@ int value; /* used for storing only */
return(h->val); return(h->val);
default: /* looking up known word */ default: /* looking up known word */
if (h->val==0) if (h->val==0)
{ printf("Unable to find %s in vocab\n",word); { errx(1, "Unable to find %s in vocab", word);
exit(0);
} }
for (s=word, t=h->atab;*t ^ '=';) for (s=word, t=h->atab;*t ^ '=';)
if ((*s++ ^ '=') != *t++) goto exitloop2; if ((*s++ ^ '=') != *t++) goto exitloop2;
@ -164,44 +167,11 @@ int value; /* used for storing only */
exitloop2: /* hashed entry does not match */ exitloop2: /* hashed entry does not match */
if (adr+1==hash || (adr==HTSIZE && hash==0)) if (adr+1==hash || (adr==HTSIZE && hash==0))
{ printf("Hash table overflow\n"); { errx(1, "Hash table overflow");
exit(0);
} }
} }
} }
copystr(w1,w2) /* copy one string to another */
char *w1,*w2;
{ register char *s,*t;
for (s=w1,t=w2; *s;)
*t++ = *s++;
*t=0;
}
weq(w1,w2) /* compare words */
char *w1,*w2; /* w1 is user, w2 is system */
{ register char *s,*t;
register int i;
s=w1;
t=w2;
for (i=0; i<5; i++) /* compare at most 5 chars */
{ if (*t==0 && *s==0)
return(TRUE);
if (*s++ != *t++) return(FALSE);
}
return(TRUE);
}
length(str) /* includes 0 at end */
char *str;
{ register char *s;
register int n;
for (n=0,s=str; *s++;) n++;
return(n+1);
}
prht() /* print hash table */ prht() /* print hash table */
{ register int i,j,l; { register int i,j,l;
char *c; char *c;

View File

@ -56,9 +56,15 @@ int *d,*t;
time(&tvec); time(&tvec);
tptr=localtime(&tvec); tptr=localtime(&tvec);
*d=tptr->tm_yday+365*(tptr->tm_year-77); /* day since 1977 (mod leap) */ /* day since 1977 */
*t=tptr->tm_hour*60+tptr->tm_min; /* and minutes since midnite */ *d = (tptr->tm_yday + 365 * (tptr->tm_year - 77)
} /* pretty painless */ + (tptr->tm_year - 77) / 4 - (tptr->tm_year - 1) / 100
+ (tptr->tm_year + 299) / 400);
/* bug: this will overflow in the year 2066 AD (with 16 bit int) */
/* it will be attributed to Wm the C's millenial celebration */
/* and minutes since midnite */
*t=tptr->tm_hour*60+tptr->tm_min;
}
char magic[6]; char magic[6];
@ -69,7 +75,7 @@ poof()
latncy = 45; latncy = 45;
} }
Start(n) Start()
{ int d,t,delay; { int d,t,delay;
datime(&d,&t); datime(&d,&t);
@ -100,7 +106,7 @@ wizard() /* not as complex as advent/10 (for now) */
if (!yesm(16,0,7)) return(FALSE); if (!yesm(16,0,7)) return(FALSE);
mspeak(17); mspeak(17);
getin(&word,&x); getin(&word,&x);
if (!weq(word,magic)) if (strncmp(word,magic,5))
{ mspeak(20); { mspeak(20);
return(FALSE); return(FALSE);
} }
@ -108,16 +114,21 @@ wizard() /* not as complex as advent/10 (for now) */
return(TRUE); return(TRUE);
} }
ciao(cmdfile) ciao()
char *cmdfile;
{ register char *c; { register char *c;
register int outfd, size; register int outfd, size;
char fname[80], buf[512]; char fname[80], buf[512];
extern unsigned filesize; extern unsigned filesize;
printf("What would you like to call the saved version?\n"); printf("What would you like to call the saved version?\n");
for (c=fname;; c++) /* XXX - should use fgetln to avoid arbitrary limit */
if ((*c=getchar())=='\n') break; for (c = fname; c < fname + sizeof fname - 1; c++) {
int ch;
ch = getchar();
if (ch == '\n' || ch == EOF)
break;
*c = ch;
}
*c=0; *c=0;
if (save(fname) != 0) return; /* Save failed */ if (save(fname) != 0) return; /* Save failed */
printf("To resume, say \"adventure %s\".\n", fname); printf("To resume, say \"adventure %s\".\n", fname);

View File

@ -79,9 +79,9 @@ static char sccsid[] = "@(#)arithmetic.c 8.1 (Berkeley) 5/31/93";
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
char keylist[] = "+-x/"; const char keylist[] = "+-x/";
char defaultkeys[] = "+-"; const char defaultkeys[] = "+-";
char *keys = defaultkeys; const char *keys = defaultkeys;
int nkeys = sizeof(defaultkeys) - 1; int nkeys = sizeof(defaultkeys) - 1;
int rangemax = 10; int rangemax = 10;
int nright, nwrong; int nright, nwrong;
@ -105,10 +105,13 @@ main(argc, argv)
int ch, cnt; int ch, cnt;
void intr(); void intr();
/* Revoke setgid privileges */
setgid(getgid());
while ((ch = getopt(argc, argv, "r:o:")) != -1) while ((ch = getopt(argc, argv, "r:o:")) != -1)
switch(ch) { switch(ch) {
case 'o': { case 'o': {
register char *p; register const char *p;
for (p = keys = optarg; *p; ++p) for (p = keys = optarg; *p; ++p)
if (!index(keylist, *p)) { if (!index(keylist, *p)) {

View File

@ -13,7 +13,5 @@ HIDEGAME=hidegame
beforeinstall: beforeinstall:
(cd ${.CURDIR}/games; ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 440 \ (cd ${.CURDIR}/games; ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 440 \
${GAMES} ${DESTDIR}${SHAREDIR}/games/atc) ${GAMES} ${DESTDIR}${SHAREDIR}/games/atc)
${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 664 ${.CURDIR}/games/ATC_scores \
${DESTDIR}/var/games/atc_score
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -47,7 +47,9 @@
#define AUTHOR_STR "ATC - by Ed James" #define AUTHOR_STR "ATC - by Ed James"
#define PI 3.14159654 #ifndef PI
#define PI 3.14159265358979323846
#endif
#define LOWFUEL 15 #define LOWFUEL 15

View File

@ -53,7 +53,7 @@ char GAMES[] = "Game_List";
int clck, safe_planes, start_time, test_mode; int clck, safe_planes, start_time, test_mode;
char *file; const char *file;
FILE *filein, *fileout; FILE *filein, *fileout;

View File

@ -45,7 +45,8 @@
* For more info on this and all of my stuff, mail edjames@berkeley.edu. * For more info on this and all of my stuff, mail edjames@berkeley.edu.
*/ */
extern char GAMES[], *file; extern char GAMES[];
extern const char *file;
extern int clck, safe_planes, start_time, test_mode; extern int clck, safe_planes, start_time, test_mode;

View File

@ -122,10 +122,11 @@ init_gr()
} }
setup_screen(scp) setup_screen(scp)
C_SCREEN *scp; const C_SCREEN *scp;
{ {
register int i, j; register int i, j;
char str[3], *airstr; char str[3];
const char *airstr;
str[2] = '\0'; str[2] = '\0';
@ -213,8 +214,9 @@ setup_screen(scp)
} }
draw_line(w, x, y, lx, ly, s) draw_line(w, x, y, lx, ly, s)
WINDOW *w; WINDOW *w;
char *s; int x, y, lx, ly;
const char *s;
{ {
int dx, dy; int dx, dy;
@ -246,7 +248,7 @@ iomove(pos)
} }
ioaddstr(pos, str) ioaddstr(pos, str)
char *str; const char *str;
{ {
wmove(input, 0, pos); wmove(input, 0, pos);
waddstr(input, str); waddstr(input, str);
@ -262,7 +264,7 @@ ioclrtobot()
} }
ioerror(pos, len, str) ioerror(pos, len, str)
char *str; const char *str;
{ {
int i; int i;
@ -359,8 +361,8 @@ planewin()
} }
loser(p, s) loser(p, s)
PLANE *p; const PLANE *p;
char *s; const char *s;
{ {
int c; int c;
#ifdef BSD #ifdef BSD

View File

@ -66,10 +66,10 @@ static char sccsid[] = "@(#)input.c 8.1 (Berkeley) 5/31/93";
#define NUMTOKEN 257 #define NUMTOKEN 257
typedef struct { typedef struct {
int token; int token;
int to_state; int to_state;
char *str; const char *str;
char *(*func)(); const char *(*func)();
} RULE; } RULE;
typedef struct { typedef struct {
@ -95,7 +95,7 @@ typedef struct {
#define NUMSTATES NUMELS(st) #define NUMSTATES NUMELS(st)
char *setplane(), *circle(), *left(), *right(), *Left(), *Right(), const char *setplane(), *circle(), *left(), *right(), *Left(), *Right(),
*beacon(), *ex_it(), *climb(), *descend(), *setalt(), *setrelalt(), *beacon(), *ex_it(), *climb(), *descend(), *setalt(), *setrelalt(),
*benum(), *to_dir(), *rel_dir(), *delayb(), *mark(), *unmark(), *benum(), *to_dir(), *rel_dir(), *delayb(), *mark(), *unmark(),
*airport(), *turn(), *ignore(); *airport(), *turn(), *ignore();
@ -241,9 +241,9 @@ push(ruleno, ch)
getcommand() getcommand()
{ {
int c, i, done; int c, i, done;
char *s, *(*func)(); const char *s, *(*func)();
PLANE *pp; PLANE *pp;
rezero(); rezero();
@ -368,7 +368,7 @@ gettoken()
return (tval); return (tval);
} }
char * const char *
setplane(c) setplane(c)
{ {
PLANE *pp; PLANE *pp;
@ -381,7 +381,7 @@ setplane(c)
return (NULL); return (NULL);
} }
char * const char *
turn(c) turn(c)
{ {
if (p.altitude == 0) if (p.altitude == 0)
@ -389,7 +389,7 @@ turn(c)
return (NULL); return (NULL);
} }
char * const char *
circle(c) circle(c)
{ {
if (p.altitude == 0) if (p.altitude == 0)
@ -398,7 +398,7 @@ circle(c)
return (NULL); return (NULL);
} }
char * const char *
left(c) left(c)
{ {
dir = D_LEFT; dir = D_LEFT;
@ -408,7 +408,7 @@ left(c)
return (NULL); return (NULL);
} }
char * const char *
right(c) right(c)
{ {
dir = D_RIGHT; dir = D_RIGHT;
@ -418,7 +418,7 @@ right(c)
return (NULL); return (NULL);
} }
char * const char *
Left(c) Left(c)
{ {
p.new_dir = p.dir - 2; p.new_dir = p.dir - 2;
@ -427,7 +427,7 @@ Left(c)
return (NULL); return (NULL);
} }
char * const char *
Right(c) Right(c)
{ {
p.new_dir = p.dir + 2; p.new_dir = p.dir + 2;
@ -436,7 +436,7 @@ Right(c)
return (NULL); return (NULL);
} }
char * const char *
delayb(c) delayb(c)
{ {
int xdiff, ydiff; int xdiff, ydiff;
@ -481,42 +481,42 @@ delayb(c)
return (NULL); return (NULL);
} }
char * const char *
beacon(c) beacon(c)
{ {
dest_type = T_BEACON; dest_type = T_BEACON;
return (NULL); return (NULL);
} }
char * const char *
ex_it(c) ex_it(c)
{ {
dest_type = T_EXIT; dest_type = T_EXIT;
return (NULL); return (NULL);
} }
char * const char *
airport(c) airport(c)
{ {
dest_type = T_AIRPORT; dest_type = T_AIRPORT;
return (NULL); return (NULL);
} }
char * const char *
climb(c) climb(c)
{ {
dir = D_UP; dir = D_UP;
return (NULL); return (NULL);
} }
char * const char *
descend(c) descend(c)
{ {
dir = D_DOWN; dir = D_DOWN;
return (NULL); return (NULL);
} }
char * const char *
setalt(c) setalt(c)
{ {
if ((p.altitude == c - '0') && (p.new_altitude == p.altitude)) if ((p.altitude == c - '0') && (p.new_altitude == p.altitude))
@ -525,7 +525,7 @@ setalt(c)
return (NULL); return (NULL);
} }
char * const char *
setrelalt(c) setrelalt(c)
{ {
if (c == 0) if (c == 0)
@ -549,7 +549,7 @@ setrelalt(c)
return (NULL); return (NULL);
} }
char * const char *
benum(c) benum(c)
{ {
dest_no = c -= '0'; dest_no = c -= '0';
@ -580,14 +580,14 @@ benum(c)
return (NULL); return (NULL);
} }
char * const char *
to_dir(c) to_dir(c)
{ {
p.new_dir = dir_no(c); p.new_dir = dir_no(c);
return (NULL); return (NULL);
} }
char * const char *
rel_dir(c) rel_dir(c)
{ {
int angle; int angle;
@ -611,7 +611,7 @@ rel_dir(c)
return (NULL); return (NULL);
} }
char * const char *
mark(c) mark(c)
{ {
if (p.altitude == 0) if (p.altitude == 0)
@ -622,7 +622,7 @@ mark(c)
return (NULL); return (NULL);
} }
char * const char *
unmark(c) unmark(c)
{ {
if (p.altitude == 0) if (p.altitude == 0)
@ -633,7 +633,7 @@ unmark(c)
return (NULL); return (NULL);
} }
char * const char *
ignore(c) ignore(c)
{ {
if (p.altitude == 0) if (p.altitude == 0)

View File

@ -51,9 +51,15 @@ static char sccsid[] = "@(#)log.c 8.1 (Berkeley) 5/31/93";
#include "include.h" #include "include.h"
#include "pathnames.h" #include "pathnames.h"
compar(a, b) int
SCORE *a, *b; compar(va, vb)
const void *va, *vb;
{ {
const SCORE *a, *b;
a = (const SCORE *)va;
b = (const SCORE *)vb;
if (b->planes == a->planes) if (b->planes == a->planes)
return (b->time - a->time); return (b->time - a->time);
else else
@ -70,7 +76,7 @@ compar(a, b)
#define MIN(t) (((t) % SECAHOUR) / SECAMIN) #define MIN(t) (((t) % SECAHOUR) / SECAMIN)
#define SEC(t) ((t) % SECAMIN) #define SEC(t) ((t) % SECAMIN)
char * const char *
timestr(t) timestr(t)
{ {
static char s[80]; static char s[80];
@ -152,7 +158,7 @@ log_score(list_em)
#endif #endif
#ifdef SYSV #ifdef SYSV
uname(&name); uname(&name);
strcpy(thisscore.host, name.sysname); strcpy(thisscore.host, name.nodename);
#endif #endif
cp = rindex(file, '/'); cp = rindex(file, '/');

View File

@ -58,17 +58,18 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#include "pathnames.h" #include "pathnames.h"
main(ac, av) main(ac, av)
int ac;
char *av[]; char *av[];
{ {
int seed = 0; int seed = 0;
int f_usage = 0, f_list = 0, f_showscore = 0; int f_usage = 0, f_list = 0, f_showscore = 0;
int f_printpath = 0; int f_printpath = 0;
char *file = NULL; const char *file = NULL;
char *name, *ptr; char *name, *ptr;
#ifdef BSD #ifdef BSD
struct itimerval itv; struct itimerval itv;
#endif #endif
extern char *default_game(), *okay_game(); extern const char *default_game(), *okay_game();
extern void log_score(), quit(), update(); extern void log_score(), quit(), update();
start_time = time(0); start_time = time(0);
@ -221,7 +222,7 @@ main(ac, av)
} }
read_file(s) read_file(s)
char *s; const char *s;
{ {
extern FILE *yyin; extern FILE *yyin;
int retval; int retval;
@ -241,7 +242,7 @@ read_file(s)
return (0); return (0);
} }
char * const char *
default_game() default_game()
{ {
FILE *fp; FILE *fp;
@ -266,13 +267,14 @@ default_game()
return (file); return (file);
} }
char * const char *
okay_game(s) okay_game(s)
char *s; char *s;
{ {
FILE *fp; FILE *fp;
static char file[256]; static char file[256];
char *ret = NULL, line[256], games[256]; const char *ret = NULL;
char line[256], games[256];
strcpy(games, _PATH_GAMES); strcpy(games, _PATH_GAMES);
strcat(games, GAMES); strcat(games, GAMES);

View File

@ -50,6 +50,8 @@ static char sccsid[] = "@(#)update.c 8.1 (Berkeley) 5/31/93";
#include <string.h> #include <string.h>
#include "include.h" #include "include.h"
char name();
update() update()
{ {
int i, dir_diff, mask, unclean; int i, dir_diff, mask, unclean;
@ -220,9 +222,9 @@ update()
#endif #endif
} }
char * const char *
command(pp) command(pp)
PLANE *pp; const PLANE *pp;
{ {
static char buf[50], *bp, *comm_start; static char buf[50], *bp, *comm_start;
char *index(); char *index();
@ -253,8 +255,9 @@ command(pp)
} }
/* char */ /* char */
char
name(p) name(p)
PLANE *p; const PLANE *p;
{ {
if (p->plane_type == 0) if (p->plane_type == 0)
return ('A' + p->plane_no); return ('A' + p->plane_no);
@ -372,6 +375,7 @@ addplane()
PLANE * PLANE *
findplane(n) findplane(n)
int n;
{ {
PLANE *pp; PLANE *pp;
@ -384,8 +388,10 @@ findplane(n)
return (NULL); return (NULL);
} }
int
too_close(p1, p2, dist) too_close(p1, p2, dist)
PLANE *p1, *p2; const PLANE *p1, *p2;
int dist;
{ {
if (ABS(p1->altitude - p2->altitude) <= dist && if (ABS(p1->altitude - p2->altitude) <= dist &&
ABS(p1->xpos - p2->xpos) <= dist && ABS(p1->ypos - p2->ypos) <= dist) ABS(p1->xpos - p2->xpos) <= dist && ABS(p1->ypos - p2->ypos) <= dist)

View File

@ -97,8 +97,6 @@ uses /etc/termcap
.B -s\fIfile .B -s\fIfile
recover previously saved game from recover previously saved game from
.IR file . .IR file .
(This can also be done by executing the saved file,
i.e., typing its name in as a command)
.ad .ad
.PP .PP
.PP .PP

View File

@ -45,55 +45,48 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <signal.h>
#include "back.h" #include "back.h"
#define MVPAUSE 5 /* time to sleep when stuck */ #define MVPAUSE 5 /* time to sleep when stuck */
#define MAXUSERS 35 /* maximum number of users */ #define MAXUSERS 35 /* maximum number of users */
extern char *instr[]; /* text of instructions */ extern const char *const instr[]; /* text of instructions */
extern char *message[]; /* update message */ extern const char *const message[]; /* update message */
char ospeed; /* tty output speed */ char ospeed; /* tty output speed */
char *helpm[] = { /* help message */ const char *helpm[] = { /* help message */
"Enter a space or newline to roll, or", "Enter a space or newline to roll, or",
" R to reprint the board\tD to double", " R to reprint the board\tD to double",
" S to save the game\tQ to quit", " S to save the game\tQ to quit",
0 0
}; };
char *contin[] = { /* pause message */ const char *contin[] = { /* pause message */
"(Type a newline to continue.)", "(Type a newline to continue.)",
"", "",
0 0
}; };
static char user1a[] = static const char rules[] = "\nDo you want the rules of the game?";
"Sorry, you cannot play backgammon when there are more than "; static const char noteach[] = "Teachgammon not available!\n\007";
static char user1b[] = static const char need[] = "Do you need instructions for this program?";
" users\non the system."; static const char askcol[] =
static char user2a[] =
"\nThere are now more than ";
static char user2b[] =
" users on the system, so you cannot play\nanother game. ";
static char rules[] = "\nDo you want the rules of the game?";
static char noteach[] = "Teachgammon not available!\n\007";
static char need[] = "Do you need instructions for this program?";
static char askcol[] =
"Enter 'r' to play red, 'w' to play white, 'b' to play both:"; "Enter 'r' to play red, 'w' to play white, 'b' to play both:";
static char rollr[] = "Red rolls a "; static const char rollr[] = "Red rolls a ";
static char rollw[] = ". White rolls a "; static const char rollw[] = ". White rolls a ";
static char rstart[] = ". Red starts.\n"; static const char rstart[] = ". Red starts.\n";
static char wstart[] = ". White starts.\n"; static const char wstart[] = ". White starts.\n";
static char toobad1[] = "Too bad, "; static const char toobad1[] = "Too bad, ";
static char unable[] = " is unable to use that roll.\n"; static const char unable[] = " is unable to use that roll.\n";
static char toobad2[] = ". Too bad, "; static const char toobad2[] = ". Too bad, ";
static char cantmv[] = " can't move.\n"; static const char cantmv[] = " can't move.\n";
static char bgammon[] = "Backgammon! "; static const char bgammon[] = "Backgammon! ";
static char gammon[] = "Gammon! "; static const char gammon[] = "Gammon! ";
static char again[] = ".\nWould you like to play again?"; static const char again[] = ".\nWould you like to play again?";
static char svpromt[] = "Would you like to save this game?"; static const char svpromt[] = "Would you like to save this game?";
static char password[] = "losfurng"; static const char password[] = "losfurng";
static char pbuf[10]; static char pbuf[10];
main (argc,argv) main (argc,argv)
@ -111,7 +104,7 @@ char **argv;
/* initialization */ /* initialization */
bflag = 2; /* default no board */ bflag = 2; /* default no board */
acnt = 1; /* Nuber of args */ acnt = 1; /* Nuber of args */
signal (2,getout); /* trap interrupts */ signal (SIGINT,getout); /* trap interrupts */
if (gtty (0,&tty) == -1) /* get old tty mode */ if (gtty (0,&tty) == -1) /* get old tty mode */
errexit ("backgammon(gtty)"); errexit ("backgammon(gtty)");
old = tty.sg_flags; old = tty.sg_flags;
@ -122,16 +115,6 @@ char **argv;
#endif #endif
ospeed = tty.sg_ospeed; /* for termlib */ ospeed = tty.sg_ospeed; /* for termlib */
/* check user count */
# ifdef CORY
if (ucount() > MAXUSERS) {
writel (user1a);
wrint (MAXUSERS);
writel (user1b);
getout();
}
# endif
/* get terminal /* get terminal
* capabilities, and * capabilities, and
* decide if it can * decide if it can
@ -222,7 +205,7 @@ char **argv;
else else
writec ('\n'); writec ('\n');
writel ("Password:"); writel ("Password:");
signal (14,getout); signal (SIGALRM,getout);
cflag = 1; cflag = 1;
alarm (10); alarm (10);
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
@ -550,17 +533,6 @@ char **argv;
/* write score */ /* write score */
wrscore(); wrscore();
/* check user count */
# ifdef CORY
if (ucount() > MAXUSERS) {
writel (user2a);
wrint (MAXUSERS);
writel (user2b);
rfl = 1;
break;
}
# endif
/* see if he wants /* see if he wants
* another game */ * another game */
writel (again); writel (again);

View File

@ -37,7 +37,7 @@ static char sccsid[] = "@(#)text.c 8.1 (Berkeley) 5/31/93";
#include "back.h" #include "back.h"
char *instr[] = { const char *const instr[] = {
" If you did not notice by now, this program reacts to things as", " If you did not notice by now, this program reacts to things as",
"soon as you type them, without waiting for a newline. This means that", "soon as you type them, without waiting for a newline. This means that",
"the special characters RUBOUT, ESC, and CONTROL-D, will not perform", "the special characters RUBOUT, ESC, and CONTROL-D, will not perform",
@ -104,12 +104,13 @@ char *instr[] = {
0}; 0};
int
text (t) text (t)
char **t; const char *const *t;
{ {
register int i; register int i;
register char *s, *a; const char *s, *a;
fixtty (noech); fixtty (noech);
while (*t != 0) { while (*t != 0) {

View File

@ -35,7 +35,7 @@
static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)version.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */ #endif /* not lint */
char *message[] = { const char *const message[] = {
"Last updated on Saturday, January 11, 1986.", "Last updated on Saturday, January 11, 1986.",
0 0
}; };

View File

@ -53,75 +53,75 @@
* *
*/ */
extern char EXEC[]; /* object for main program */ extern const char EXEC[]; /* object for main program */
extern char TEACH[]; /* object for tutorial program */ extern const char TEACH[];/* object for tutorial program */
int pnum; /* color of player: extern int pnum; /* color of player:
-1 = white -1 = white
1 = red 1 = red
0 = both 0 = both
2 = not yet init'ed */ 2 = not yet init'ed */
char *args[16]; /* args passed to teachgammon and back */ extern char *args[16]; /* args passed to teachgammon and back */
int acnt; /* number of args */ extern int acnt; /* number of args */
int aflag; /* flag to ask for rules or instructions */ extern int aflag; /* flag to ask for rules or instructions */
int bflag; /* flag for automatic board printing */ extern int bflag; /* flag for automatic board printing */
int cflag; /* case conversion flag */ extern int cflag; /* case conversion flag */
int hflag; /* flag for cleaning screen */ extern int hflag; /* flag for cleaning screen */
int mflag; /* backgammon flag */ extern int mflag; /* backgammon flag */
int raflag; /* 'roll again' flag for recovered game */ extern int raflag; /* 'roll again' flag for recovered game */
int rflag; /* recovered game flag */ extern int rflag; /* recovered game flag */
int tflag; /* cursor addressing flag */ extern int tflag; /* cursor addressing flag */
int rfl; /* saved value of rflag */ extern int rfl; /* saved value of rflag */
int iroll; /* special flag for inputting rolls */ extern int iroll; /* special flag for inputting rolls */
int board[26]; /* board: negative values are white, extern int board[26]; /* board: negative values are white,
positive are red */ positive are red */
int dice[2]; /* value of dice */ extern int dice[2]; /* value of dice */
int mvlim; /* 'move limit': max. number of moves */ extern int mvlim; /* 'move limit': max. number of moves */
int mvl; /* working copy of mvlim */ extern int mvl; /* working copy of mvlim */
int p[5]; /* starting position of moves */ extern int p[5]; /* starting position of moves */
int g[5]; /* ending position of moves (goals) */ extern int g[5]; /* ending position of moves (goals) */
int h[4]; /* flag for each move if a man was hit */ extern int h[4]; /* flag for each move if a man was hit */
int cturn; /* whose turn it currently is: extern int cturn; /* whose turn it currently is:
-1 = white -1 = white
1 = red 1 = red
0 = just quitted 0 = just quitted
-2 = white just lost -2 = white just lost
2 = red just lost */ 2 = red just lost */
int d0; /* flag if dice have been reversed from extern int d0; /* flag if dice have been reversed from
original position */ original position */
int table[6][6]; /* odds table for possible rolls */ extern int table[6][6]; /* odds table for possible rolls */
int rscore; /* red's score */ extern int rscore; /* red's score */
int wscore; /* white's score */ extern int wscore; /* white's score */
int gvalue; /* value of game (64 max.) */ extern int gvalue; /* value of game (64 max.) */
int dlast; /* who doubled last (0 = neither) */ extern int dlast; /* who doubled last (0 = neither) */
int bar; /* position of bar for current player */ extern int bar; /* position of bar for current player */
int home; /* position of home for current player */ extern int home; /* position of home for current player */
int off[2]; /* number of men off board */ extern int off[2]; /* number of men off board */
int *offptr; /* pointer to off for current player */ extern int *offptr; /* pointer to off for current player */
int *offopp; /* pointer to off for opponent */ extern int *offopp; /* pointer to off for opponent */
int in[2]; /* number of men in inner table */ extern int in[2]; /* number of men in inner table */
int *inptr; /* pointer to in for current player */ extern int *inptr; /* pointer to in for current player */
int *inopp; /* pointer to in for opponent */ extern int *inopp; /* pointer to in for opponent */
int ncin; /* number of characters in cin */ extern int ncin; /* number of characters in cin */
char cin[100]; /* input line of current move extern char cin[100]; /* input line of current move
(used for reconstructing input after (used for reconstructing input after
a backspace) */ a backspace) */
extern char *color[]; extern const char *const color[];
/* colors as strings */ /* colors as strings */
char **colorptr; /* color of current player */ extern const char *const *colorptr; /* color of current player */
char **Colorptr; /* color of current player, capitalized */ extern const char *const *Colorptr; /* color of current player, capitalized */
int colen; /* length of color of current player */ extern int colen; /* length of color of current player */
struct sgttyb tty; /* tty information buffer */ extern struct sgttyb tty; /* tty information buffer */
int old; /* original tty status */ extern int old; /* original tty status */
int noech; /* original tty status without echo */ extern int noech; /* original tty status without echo */
int raw; /* raw tty status, no echo */ extern int raw; /* raw tty status, no echo */
int curr; /* row position of cursor */ extern int curr; /* row position of cursor */
int curc; /* column position of cursor */ extern int curc; /* column position of cursor */
int begscr; /* 'beginning' of screen extern int begscr; /* 'beginning' of screen
(not including board) */ (not including board) */
int getout(); /* function to exit backgammon cleanly */ void getout(); /* function to exit backgammon cleanly */

View File

@ -43,9 +43,9 @@ static char ln[60];
wrboard () { wrboard () {
register int l; register int l;
static char bl[] = static const char bl[] =
"| | | |\n"; "| | | |\n";
static char sv[] = static const char sv[] =
"| | | | \n"; "| | | | \n";
fixtty (noech); fixtty (noech);

View File

@ -591,9 +591,6 @@ clear () {
tputs (CL,CO,addbuf); /* put CL in buffer */ tputs (CL,CO,addbuf); /* put CL in buffer */
} }
tos () { /* home cursor */
curmove (0,0);
}
fancyc (c) fancyc (c)
register char c; /* character to output */ register char c; /* character to output */
@ -703,8 +700,9 @@ newline () {
curmove (curr+1,0); curmove (curr+1,0);
} }
int
getcaps (s) getcaps (s)
register char *s; const char *s;
{ {
register char *code; /* two letter code */ register char *code; /* two letter code */
@ -712,7 +710,7 @@ register char *s;
char *bufp; /* pointer to cap buffer */ char *bufp; /* pointer to cap buffer */
char tentry[1024]; /* temporary uncoded caps buffer */ char tentry[1024]; /* temporary uncoded caps buffer */
tgetent (tentry,s); /* get uncoded termcap entry */ tgetent (tentry, (char *)s); /* get uncoded termcap entry */
LI = tgetnum ("li"); /* get number of lines */ LI = tgetnum ("li"); /* get number of lines */
if (LI == -1) if (LI == -1)

View File

@ -35,15 +35,16 @@
static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */ #endif /* not lint */
#include <sgtty.h> #include <sys/cdefs.h>
#include <termios.h>
/* /*
* variable initialization. * variable initialization.
*/ */
/* name of executable object programs */ /* name of executable object programs */
char EXEC[] = "/usr/games/backgammon"; const char EXEC[] = "/usr/games/backgammon";
char TEACH[] = "/usr/games/teachgammon"; const char TEACH[] = "/usr/games/teachgammon";
int pnum = 2; /* color of player: int pnum = 2; /* color of player:
-1 = white -1 = white
@ -62,4 +63,37 @@ int tflag = 0; /* cursor addressing flag */
int iroll = 0; /* special flag for inputting rolls */ int iroll = 0; /* special flag for inputting rolls */
int rfl = 0; int rfl = 0;
char *color[] = {"White","Red","white","red"}; const char *const color[] = {"White","Red","white","red"};
const char *const *Colorptr;
const char *const *colorptr;
int *inopp;
int *inptr;
int *offopp;
int *offptr;
char args[100];
int bar;
int begscr;
int board[26];
char cin[100];
int colen;
int cturn;
int curc;
int curr;
int d0;
int dice[2];
int dlast;
int g[5];
int gvalue;
int h[4];
int home;
int in[2];
int mvl;
int mvlim;
int ncin;
int off[2];
int p[5];
int rscore;
int table[6][6];
int wscore;
struct termios tty, old, noech, raw;

View File

@ -35,20 +35,20 @@
static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */ #endif /* not lint */
#include <fcntl.h>
#include <errno.h>
#include "back.h" #include "back.h"
extern int errno; static const char confirm[] = "Are you sure you want to leave now?";
static const char prompt[] = "Enter a file name: ";
static char confirm[] = "Are you sure you want to leave now?"; static const char exist1[] = "The file '";
static char prompt[] = "Enter a file name: "; static const char exist2[] =
static char exist1[] = "The file '";
static char exist2[] =
"' already exists.\nAre you sure you want to use this file?"; "' already exists.\nAre you sure you want to use this file?";
static char cantuse[] = "\nCan't use "; static const char cantuse[] = "\nCan't use ";
static char saved[] = "This game has been saved on the file '"; static const char saved[] = "This game has been saved on the file '";
static char type[] = "'.\nType \"backgammon "; static const char type[] = "'.\nType \"backgammon ";
static char rec[] = "\" to recover your game.\n\n"; static const char rec[] = "\" to recover your game.\n\n";
static char cantrec[] = "Can't recover file: "; static const char cantrec[] = "Can't recover file: ";
save (n) save (n)
register int n; register int n;
@ -87,8 +87,8 @@ register int n;
writec (*fs++); writec (*fs++);
} }
*fs = '\0'; *fs = '\0';
if ((fdesc = open(fname,2)) == -1 && errno == 2) { if ((fdesc = open(fname,O_RDWR)) == -1 && errno == ENOENT) {
if ((fdesc = creat (fname,0700)) != -1) if ((fdesc = creat (fname,0600)) != -1)
break; break;
} }
if (fdesc != -1) { if (fdesc != -1) {
@ -141,14 +141,15 @@ register int n;
getout (); getout ();
} }
int
recover (s) recover (s)
char *s; const char *s;
{ {
register int i; register int i;
int fdesc; int fdesc;
if ((fdesc = open (s,0)) == -1) if ((fdesc = open (s,O_RDONLY)) == -1)
norec (s); norec (s);
read (fdesc,board,sizeof board); read (fdesc,board,sizeof board);
read (fdesc,off,sizeof off); read (fdesc,off,sizeof off);
@ -165,11 +166,12 @@ char *s;
rflag = 1; rflag = 1;
} }
int
norec (s) norec (s)
register char *s; const char *s;
{ {
register char *c; const char *c;
tflag = 0; tflag = 0;
writel (cantrec); writel (cantrec);

View File

@ -43,11 +43,11 @@ static char sccsid[] = "@(#)subs.c 8.1 (Berkeley) 5/31/93";
int buffnum; int buffnum;
char outbuff[BUFSIZ]; char outbuff[BUFSIZ];
static char plred[] = "Player is red, computer is white."; static const char plred[] = "Player is red, computer is white.";
static char plwhite[] = "Player is white, computer is red."; static const char plwhite[] = "Player is white, computer is red.";
static char nocomp[] = "(No computer play.)"; static const char nocomp[] = "(No computer play.)";
char *descr[] = { const char *const descr[] = {
"Usage: backgammon [-h n r w b pr pw pb tterm sfile]\n", "Usage: backgammon [-h n r w b pr pw pb tterm sfile]\n",
"\t-h\tgets this list\n\t-n\tdon't ask for rules or instructions", "\t-h\tgets this list\n\t-n\tdon't ask for rules or instructions",
"\t-r\tplayer is red (implies -n)\n\t-w\tplayer is white (implies -n)", "\t-r\tplayer is red (implies -n)\n\t-w\tplayer is white (implies -n)",
@ -68,12 +68,6 @@ register char *s;
getout(); getout();
} }
strset (s1,s2)
register char *s1, *s2;
{
while ( (*s1++ = *s2++) != '\0');
}
int addbuf (c) int addbuf (c)
register int c; register int c;
@ -131,11 +125,12 @@ char c;
addbuf (c); addbuf (c);
} }
void
writel (l) writel (l)
register char *l; const char *l;
{ {
#ifdef DEBUG #ifdef DEBUG
register char *s; const char *s;
if (trace == NULL) if (trace == NULL)
trace = fopen ("bgtrace","w"); trace = fopen ("bgtrace","w");
@ -325,7 +320,7 @@ register char **argv;
args[acnt++] = strdup ("-n"); args[acnt++] = strdup ("-n");
break; break;
/* player is both read and white */ /* player is both red and white */
case 'b': case 'b':
if (rflag) if (rflag)
break; break;
@ -424,6 +419,7 @@ int mode;
errexit("fixtty"); errexit("fixtty");
} }
void
getout () { getout () {
/* go to bottom of screen */ /* go to bottom of screen */
if (tflag) { if (tflag) {

View File

@ -37,7 +37,7 @@ static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 5/31/93";
#include "back.h" #include "back.h"
char *help2[] = { const char *const help2[] = {
" Enter moves as <s>-<f> or <s>/<r> where <s> is the starting", " Enter moves as <s>-<f> or <s>/<r> where <s> is the starting",
"position, <f> is the finishing position, and <r> is the roll.", "position, <f> is the finishing position, and <r> is the roll.",
"Remember, each die roll must be moved separately.", "Remember, each die roll must be moved separately.",
@ -50,7 +50,7 @@ struct state {
int newst; int newst;
}; };
struct state atmata[] = { static const struct state atmata[] = {
'R', 1, 0, '?', 7, 0, 'Q', 0, -3, 'B', 8, 25, 'R', 1, 0, '?', 7, 0, 'Q', 0, -3, 'B', 8, 25,
'9', 2, 25, '8', 2, 25, '7', 2, 25, '6', 2, 25, '9', 2, 25, '8', 2, 25, '7', 2, 25, '6', 2, 25,

View File

@ -39,7 +39,7 @@ static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93";
int maxmoves = 23; int maxmoves = 23;
char *text0[] = { const char *const text0[] = {
"To start the game, I roll a 3, and you roll a 1. This means", "To start the game, I roll a 3, and you roll a 1. This means",
"that I get to start first. I move 8-5,6-5 since this makes a", "that I get to start first. I move 8-5,6-5 since this makes a",
"new point and helps to trap your back men on 1. You should be", "new point and helps to trap your back men on 1. You should be",
@ -47,7 +47,7 @@ char *text0[] = {
0 0
}; };
char *text1[] = { const char *const text1[] = {
"Now you shall see a move using doubles. I just rolled double", "Now you shall see a move using doubles. I just rolled double",
"5's. I will move two men from position 13 to position 3. The", "5's. I will move two men from position 13 to position 3. The",
"notation for this is 13-8,13-8,8-3,8-3. You will also roll dou-", "notation for this is 13-8,13-8,8-3,8-3. You will also roll dou-",
@ -55,7 +55,7 @@ char *text1[] = {
0 0
}; };
char *text2[] = { const char *const text2[] = {
"Excellent! As you can see, you are beginning to develop a wall", "Excellent! As you can see, you are beginning to develop a wall",
"which is trapping my men on position 24. Also, moving your back", "which is trapping my men on position 24. Also, moving your back",
"men forward not only improves your board position safely, but it", "men forward not only improves your board position safely, but it",
@ -68,7 +68,7 @@ char *text2[] = {
0 0
}; };
char *text3[] = { const char *const text3[] = {
"As you can see, although you left a man open, it is a rela-", "As you can see, although you left a man open, it is a rela-",
"tively safe move to an advantageous position, which might help", "tively safe move to an advantageous position, which might help",
"you make a point later. Only two rolls (4 5 or 5 4) will allow", "you make a point later. Only two rolls (4 5 or 5 4) will allow",
@ -77,13 +77,13 @@ char *text3[] = {
0 0
}; };
char *text4[] = { const char *const text4[] = {
"You're pretty lucky yourself, you know. I follow by rolling 2 3", "You're pretty lucky yourself, you know. I follow by rolling 2 3",
"and moving 25-22,24-22, forming a new point.", "and moving 25-22,24-22, forming a new point.",
0 0
}; };
char *text5[] = { const char *const text5[] = {
"Not a spectacular move, but a safe one. I follow by rolling 6 1.", "Not a spectacular move, but a safe one. I follow by rolling 6 1.",
"I decide to use this roll to move 22-16,16-15. It leaves me with", "I decide to use this roll to move 22-16,16-15. It leaves me with",
"one man still open, but the blot is farther back on the board, and", "one man still open, but the blot is farther back on the board, and",
@ -91,7 +91,7 @@ char *text5[] = {
0 0
}; };
char *text6[] = { const char *const text6[] = {
"By moving your two men from 17 to 20, you lessen my chance of", "By moving your two men from 17 to 20, you lessen my chance of",
"getting my man off the board. In fact, the odds are 5 to 4", "getting my man off the board. In fact, the odds are 5 to 4",
"against me getting off. I roll with the odds and helplessly", "against me getting off. I roll with the odds and helplessly",
@ -99,7 +99,7 @@ char *text6[] = {
0 0
}; };
char *text7[] = { const char *const text7[] = {
"Note that the blot on 7 cannot be hit unless I get off the bar", "Note that the blot on 7 cannot be hit unless I get off the bar",
"and have a 1 or a 6 left over, and doing so will leave two of", "and have a 1 or a 6 left over, and doing so will leave two of",
"my men open. Also, the blot on 16 cannot be hit at all! With", "my men open. Also, the blot on 16 cannot be hit at all! With",
@ -107,27 +107,27 @@ char *text7[] = {
0 0
}; };
char *text8[] = { const char *const text8[] = {
"See, you did not get hit and, you got to 'cover up' your open men.", "See, you did not get hit and, you got to 'cover up' your open men.",
"Quite an accomplishment. Finally, I get off the bar by rolling", "Quite an accomplishment. Finally, I get off the bar by rolling",
"6 2 and moving 25-23,23-17.", "6 2 and moving 25-23,23-17.",
0 0
}; };
char *text9[] = { const char *const text9[] = {
"My venture off the bar did not last long. However, I got lucky", "My venture off the bar did not last long. However, I got lucky",
"and rolled double 1's, allowing me to move 25-24,24-23,15-14,15-14.", "and rolled double 1's, allowing me to move 25-24,24-23,15-14,15-14.",
0 0
}; };
char *text10[] = { const char *const text10[] = {
"You are improving your position greatly and safely, and are well", "You are improving your position greatly and safely, and are well",
"on the way to winning the game. I roll a 6 2 and squeak past", "on the way to winning the game. I roll a 6 2 and squeak past",
"your back man. Now the game becomes a race to the finish.", "your back man. Now the game becomes a race to the finish.",
0 0
}; };
char *text11[] = { const char *const text11[] = {
"Now that it is merely a race, you are trying to get as many men", "Now that it is merely a race, you are trying to get as many men",
"as possible into the inner table, so you can start removing them.", "as possible into the inner table, so you can start removing them.",
"I roll a 3 4 and move my two men farthest back to position 11", "I roll a 3 4 and move my two men farthest back to position 11",
@ -135,20 +135,20 @@ char *text11[] = {
0 0
}; };
char *text12[] = { const char *const text12[] = {
"The race is still on, and you have seem to be doing all right.", "The race is still on, and you have seem to be doing all right.",
"I roll 6 1 and move 14-8,13-12.", "I roll 6 1 and move 14-8,13-12.",
0 0
}; };
char *text13[] = { const char *const text13[] = {
"Notice that you get to remove men the instant you have all of", "Notice that you get to remove men the instant you have all of",
"them at your inner table, even if it is the middle of a turn.", "them at your inner table, even if it is the middle of a turn.",
"I roll 1 2 and move 13-11,12-11.", "I roll 1 2 and move 13-11,12-11.",
0 0
}; };
char *text14[] = { const char *const text14[] = {
"Although you could have removed a man, this move illustrates two", "Although you could have removed a man, this move illustrates two",
"points: 1) You never have to remove men, and 2) You should try", "points: 1) You never have to remove men, and 2) You should try",
"to spread out your men on your inner table. Since you have one", "to spread out your men on your inner table. Since you have one",
@ -157,25 +157,25 @@ char *text14[] = {
0 0
}; };
char *text15[] = { const char *const text15[] = {
"This time you were able to remove men. I roll 3 4 and move", "This time you were able to remove men. I roll 3 4 and move",
"11-7,11-8. The race continues.", "11-7,11-8. The race continues.",
0 0
}; };
char *text16[] = { const char *const text16[] = {
"More holes are opening up in your inner table, but you are", "More holes are opening up in your inner table, but you are",
"still very much ahead. If we were doubling, you would have", "still very much ahead. If we were doubling, you would have",
"doubled long ago. I roll 2 6 and move 8-6,11-5.", "doubled long ago. I roll 2 6 and move 8-6,11-5.",
0 0
}; };
char *text17[] = { const char *const text17[] = {
"It pays to spread out your men. I roll 3 5 and move 7-4,8-3.", "It pays to spread out your men. I roll 3 5 and move 7-4,8-3.",
0 0
}; };
char *text18[] = { const char *const text18[] = {
"You can only remove some men, but you spread out more and", "You can only remove some men, but you spread out more and",
"more, in order to be able to remove men more efficiently.", "more, in order to be able to remove men more efficiently.",
"I roll double 3's, which help, but not that much. I move", "I roll double 3's, which help, but not that much. I move",
@ -183,30 +183,30 @@ char *text18[] = {
0 0
}; };
char *text19[] = { const char *const text19[] = {
"I roll 1 4 and move 5-4,4-0.", "I roll 1 4 and move 5-4,4-0.",
0 0
}; };
char *text20[] = { const char *const text20[] = {
"You are now nicely spread out to win a game. I roll 5 6 and", "You are now nicely spread out to win a game. I roll 5 6 and",
"move 5-0,6-0.", "move 5-0,6-0.",
0 0
}; };
char *text21[] = { const char *const text21[] = {
"Any minute now. Just a few short steps from victory. I roll", "Any minute now. Just a few short steps from victory. I roll",
"2 4 and move 6-4,4-0.", "2 4 and move 6-4,4-0.",
0 0
}; };
char *text22[] = { const char *const text22[] = {
"It looks pretty hopeless for me, but I play on, rolling 1 3 and", "It looks pretty hopeless for me, but I play on, rolling 1 3 and",
"moving 4-3,3-0.", "moving 4-3,3-0.",
0 0
}; };
char *text23[] = { const char *const text23[] = {
"Congratulations! You just won a game of backgammon against the", "Congratulations! You just won a game of backgammon against the",
"computer! You will now be able to play a game, but remember,", "computer! You will now be able to play a game, but remember,",
"when you start playing, that doubling will be enabled, which", "when you start playing, that doubling will be enabled, which",
@ -215,7 +215,7 @@ char *text23[] = {
0 0
}; };
struct situatn test[] = { const struct situatn test[] = {
{ {
{0,2,0,0,0,0,-5,0,-3,0,0,0,5,-5,0,0,0,3,0,5,0,0,0,0,-2,0}, {0,2,0,0,0,0,-5,0,-3,0,0,0,5,-5,0,0,0,3,0,5,0,0,0,0,-2,0},
3, 1, {8,6,0,0}, {5,5,0,0}, 4, 2, text0 3, 1, {8,6,0,0}, {5,5,0,0}, 4, 2, text0

View File

@ -44,6 +44,7 @@ static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93";
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h>
#include "back.h" #include "back.h"
extern char *hello[]; extern char *hello[];
@ -61,7 +62,7 @@ extern char *lastch[];
extern char ospeed; /* tty output speed for termlib */ extern char ospeed; /* tty output speed for termlib */
char *helpm[] = { const char *const helpm[] = {
"\nEnter a space or newline to roll, or", "\nEnter a space or newline to roll, or",
" b to display the board", " b to display the board",
" d to double", " d to double",
@ -69,7 +70,7 @@ char *helpm[] = {
0 0
}; };
char *contin[] = { const char *const contin[] = {
"", "",
0 0
}; };
@ -85,7 +86,7 @@ char **argv;
setgid(getgid()); setgid(getgid());
acnt = 1; acnt = 1;
signal (2,getout); signal (SIGINT,getout);
if (gtty (0,&tty) == -1) /* get old tty mode */ if (gtty (0,&tty) == -1) /* get old tty mode */
errexit ("teachgammon(gtty)"); errexit ("teachgammon(gtty)");
old = tty.sg_flags; old = tty.sg_flags;

View File

@ -37,10 +37,10 @@ static char sccsid[] = "@(#)ttext1.c 8.1 (Berkeley) 5/31/93";
#include "back.h" #include "back.h"
char *opts = " QIMRHEDSPT"; const char *opts = " QIMRHEDSPT";
char *prompt = "-->"; const char *prompt = "-->";
char *list[] = { const char *const list[] = {
"\n\n\tI\tIntroduction to Backgammon", "\n\n\tI\tIntroduction to Backgammon",
"\tM\tMoves and Points", "\tM\tMoves and Points",
"\tR\tRemoving Men from the Board", "\tR\tRemoving Men from the Board",
@ -56,7 +56,7 @@ char *list[] = {
0 0
}; };
char *hello[] = { const char *const hello[] = {
"\n\032 These rules consist of text describing how to play Backgammon", "\n\032 These rules consist of text describing how to play Backgammon",
"followed by a tutorial session where you play a practice game", "followed by a tutorial session where you play a practice game",
"against the computer. When using this program, think carefuly", "against the computer. When using this program, think carefuly",
@ -74,7 +74,7 @@ char *hello[] = {
0 0
}; };
char *intro1[] = { const char *const intro1[] = {
"\nIntroduction:", "\nIntroduction:",
"\n Backgammon is a game involving the skill of two players and", "\n Backgammon is a game involving the skill of two players and",
"the luck of two dice. There are two players, red and white, and", "the luck of two dice. There are two players, red and white, and",
@ -85,7 +85,7 @@ char *intro1[] = {
"", "",
0}; 0};
char *intro2[] = { const char *const intro2[] = {
"", "",
"\n Although not indicated on the board, the players' homes are", "\n Although not indicated on the board, the players' homes are",
"located just to the right of the board. A player's men are placed", "located just to the right of the board. A player's men are placed",
@ -99,7 +99,7 @@ char *intro2[] = {
"", "",
0}; 0};
char *moves[] = { const char *const moves[] = {
"\nMoves and Points:", "\nMoves and Points:",
"\n Moves are made along the positions on the board according to", "\n Moves are made along the positions on the board according to",
"their numbers. Red moves in the positive direction (clockwise", "their numbers. Red moves in the positive direction (clockwise",
@ -130,7 +130,7 @@ char *moves[] = {
"", "",
0}; 0};
char *remove[] = { const char *const remove[] = {
"\nRemoving Men from the Board:", "\nRemoving Men from the Board:",
"\n The most important part of the game is removing men, since", "\n The most important part of the game is removing men, since",
"that is how you win the game. Once a man is removed, he stays", "that is how you win the game. Once a man is removed, he stays",
@ -154,7 +154,7 @@ char *remove[] = {
"", "",
0}; 0};
char *hits[] = { const char *const hits[] = {
"\nHitting Blots:", "\nHitting Blots:",
"\n Although two men on a position form an impenetrable point, a", "\n Although two men on a position form an impenetrable point, a",
"lone man is not so secure. Such a man is called a 'blot' and has", "lone man is not so secure. Such a man is called a 'blot' and has",
@ -171,7 +171,7 @@ char *hits[] = {
"", "",
0}; 0};
char *endgame[] = { const char *const endgame[] = {
"\nEnding the Game and Scoring:", "\nEnding the Game and Scoring:",
"\n Winning a game usually wins one point, the normal value of a", "\n Winning a game usually wins one point, the normal value of a",
"game. However, if the losing player has not removed any men yet,", "game. However, if the losing player has not removed any men yet,",

View File

@ -39,7 +39,7 @@ static char sccsid[] = "@(#)ttext2.c 8.1 (Berkeley) 5/31/93";
char *prompt, *list, *opts; char *prompt, *list, *opts;
char *doubl[] = { const char *const doubl[] = {
"\nDoubling:", "\nDoubling:",
"\n If a player thinks he is in a good position, he may double the", "\n If a player thinks he is in a good position, he may double the",
"value of the game. However, his opponent may not accept the pro-", "value of the game. However, his opponent may not accept the pro-",
@ -54,7 +54,7 @@ char *doubl[] = {
"", "",
0}; 0};
char *stragy[] = { const char *const stragy[] = {
"\nStrategy:", "\nStrategy:",
"\n Some general hints when playing: Try not to leave men open", "\n Some general hints when playing: Try not to leave men open",
"unless absolutely necessary. Also, it is good to make as many", "unless absolutely necessary. Also, it is good to make as many",
@ -70,7 +70,7 @@ char *stragy[] = {
"", "",
0}; 0};
char *prog[] = { const char *const prog[] = {
"\nThe Program and How It Works:", "\nThe Program and How It Works:",
"\n A general rule of thumb is when you don't know what to do,", "\n A general rule of thumb is when you don't know what to do,",
"type a question mark, and you should get some help. When it is", "type a question mark, and you should get some help. When it is",
@ -104,7 +104,7 @@ char *prog[] = {
"", "",
0}; 0};
char *lastch[] = { const char *const lastch[] = {
"\nTutorial (Practice Game):", "\nTutorial (Practice Game):",
"\n This tutorial, for simplicity's sake, will let you play one", "\n This tutorial, for simplicity's sake, will let you play one",
"predetermined game. All the rolls have been pre-arranged, and", "predetermined game. All the rolls have been pre-arranged, and",
@ -123,14 +123,15 @@ char *lastch[] = {
"", "",
0}; 0};
int
text (txt) text (txt)
char **txt; const char *const *txt;
{ {
char **begin; const char *const *begin;
char *a; const char *a;
char b; char b;
char *c; const char *c;
int i; int i;
fixtty (noech); fixtty (noech);

View File

@ -39,12 +39,13 @@ static char sccsid[] = "@(#)tutor.c 8.1 (Berkeley) 5/31/93";
#include "tutor.h" #include "tutor.h"
extern int maxmoves; extern int maxmoves;
extern char *finis[]; extern const char *const finis[];
extern struct situatn test[]; extern const struct situatn test[];
static char better[] = "That is a legal move, but there is a better one.\n"; static const char better[] = "That is a legal move, but there is a better one.\n";
void
tutor () { tutor () {
register int i, j; register int i, j;
@ -141,11 +142,12 @@ clrest () {
curmove (r,c); curmove (r,c);
} }
int
brdeq (b1,b2) brdeq (b1,b2)
register int *b1, *b2; const int *b1, *b2;
{ {
register int *e; const int *e;
e = b1+26; e = b1+26;
while (b1 < e) while (b1 < e)

View File

@ -41,5 +41,23 @@ struct situatn {
int mg[4]; int mg[4];
int new1; int new1;
int new2; int new2;
char *(*com[8]); const char *const (*com[8]);
}; };
extern const char *const doubl[];
extern const char *const endgame[];
extern const char *const finis[];
extern const char *const hello[];
extern const char *const hits[];
extern const char *const intro1[];
extern const char *const intro2[];
extern const char *const lastch[];
extern const char *const list[];
extern int maxmoves;
extern const char *const moves[];
extern const char *const opts;
extern const char *const prog[];
extern const char *const prompt;
extern const char *const removepiece[];
extern const char *const stragy[];
extern const struct situatn test[];

View File

@ -44,7 +44,7 @@ battlestar \- a tropical adventure game
.fi .fi
.SH DESCRIPTION .SH DESCRIPTION
.I Battlestar .I Battlestar
is an adventure game in the classic style. However, It's slightly less is an adventure game in the classic style. However, it's slightly less
of a of a
puzzle and more a game of exploration. There are a few magical words puzzle and more a game of exploration. There are a few magical words
in the game, but on the whole, simple English in the game, but on the whole, simple English

View File

@ -91,6 +91,6 @@ char **argv;
case 0: case 0:
goto start; goto start;
default: default:
exit(0); exit(1); /* Shouldn't happen */
} }
} }

View File

@ -63,7 +63,7 @@ int thataway, token;
convert(tothis) /* Converts day to night and vice versa. */ convert(tothis) /* Converts day to night and vice versa. */
int tothis; /* Day objects are permanent. Night objects are added*/ int tothis; /* Day objects are permanent. Night objects are added*/
{ /* at dusk, and subtracted at dawn. */ { /* at dusk, and subtracted at dawn. */
register struct objs *p; const struct objs *p;
register i, j; register i, j;
if (tothis == TONIGHT) { if (tothis == TONIGHT) {

View File

@ -140,6 +140,7 @@ use()
else else
position = 229; position = 229;
gtime++; gtime++;
notes[CANTSEE] = 0;
return(0); return(0);
} }
else if (position == FINAL) else if (position == FINAL)

View File

@ -188,10 +188,10 @@ shoot()
int firstnumber, value; int firstnumber, value;
register int n; register int n;
firstnumber = wordnumber;
if (!testbit(inven,LASER)) if (!testbit(inven,LASER))
puts("You aren't holding a blaster."); puts("You aren't holding a blaster.");
else { else {
firstnumber = wordnumber;
while(wordtype[++wordnumber] == ADJS); while(wordtype[++wordnumber] == ADJS);
while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){ while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){
value = wordvalue[wordnumber]; value = wordvalue[wordnumber];

View File

@ -183,7 +183,7 @@ unsigned int from[];
} }
throw(name) throw(name)
char *name; const char *name;
{ {
int n; int n;
int deposit = 0; int deposit = 0;
@ -263,7 +263,7 @@ throw(name)
} }
drop(name) drop(name)
char *name; const char *name;
{ {
int firstnumber, value; int firstnumber, value;

View File

@ -247,6 +247,19 @@ give()
person = wordvalue[wordnumber]; person = wordvalue[wordnumber];
last2 = wordnumber; last2 = wordnumber;
} }
/* Setting wordnumber to last1 - 1 looks wrong if last1 is 0, e.g.,
* plain `give'. However, detecting this case is liable to detect
* `give foo' as well, which would give a confusing error. We
* need to make sure the -1 value can cause no problems if it arises.
* If in the below we get to the drop("Given") then drop will look
* at word 0 for an object to give, and fail, which is OK; then
* result will be -1 and we get to the end, where wordnumber gets
* set to something more sensible. If we get to "I don't think
* that is possible" then again wordnumber is set to something
* sensible. The wordnumber we leave with still isn't right if
* you include words the game doesn't know in your command, but
* that's no worse than what other commands than give do in
* the same place. */
wordnumber = last1 - 1; wordnumber = last1 - 1;
if (person && testbit(location[position].objects,person)) if (person && testbit(location[position].objects,person))
if (person == NORMGOD && godready < 2 && !(obj == RING || obj == BRACELET)) if (person == NORMGOD && godready < 2 && !(obj == RING || obj == BRACELET))
@ -255,6 +268,7 @@ give()
result = drop("Given"); result = drop("Given");
else { else {
puts("I don't think that is possible."); puts("I don't think that is possible.");
wordnumber = max(last1, last2) + 1;
return(0); return(0);
} }
if (result != -1 && (testbit(location[position].objects,obj) || obj == AMULET || obj == MEDALION || obj == TALISMAN)){ if (result != -1 && (testbit(location[position].objects,obj) || obj == AMULET || obj == MEDALION || obj == TALISMAN)){
@ -319,6 +333,6 @@ give()
break; break;
} }
} }
wordnumber = max(last1,last2); wordnumber = max(last1,last2) + 1;
return(firstnumber); return(firstnumber);
} }

View File

@ -123,7 +123,7 @@ char ch;
sigsetmask(s); sigsetmask(s);
} }
char * const char *
rate() rate()
{ {
int score; int score;

View File

@ -95,7 +95,7 @@ cypher()
case SHOOT: case SHOOT:
if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){ if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
for (n=0; n < NUMOFOBJECTS; n++) for (n=0; n < NUMOFOBJECTS; n++)
if (testbit(location[position].objects,n) && *objsht[n]){ if (testbit(location[position].objects,n) && objsht[n]){
wordvalue[wordnumber+1] = n; wordvalue[wordnumber+1] = n;
wordnumber = shoot(); wordnumber = shoot();
} }
@ -109,7 +109,7 @@ cypher()
case TAKE: case TAKE:
if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){ if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
for (n=0; n < NUMOFOBJECTS; n++) for (n=0; n < NUMOFOBJECTS; n++)
if (testbit(location[position].objects,n) && *objsht[n]){ if (testbit(location[position].objects,n) && objsht[n]){
wordvalue[wordnumber+1] = n; wordvalue[wordnumber+1] = n;
wordnumber = take(location[position].objects); wordnumber = take(location[position].objects);
} }
@ -141,7 +141,7 @@ cypher()
if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){ if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
for (n=0; n < NUMOFOBJECTS; n++) for (n=0; n < NUMOFOBJECTS; n++)
if (testbit(inven,n) || if (testbit(inven,n) ||
testbit(location[position].objects, n) && *objsht[n]){ testbit(location[position].objects, n) && objsht[n]){
wordvalue[wordnumber+1] = n; wordvalue[wordnumber+1] = n;
wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown"); wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
} }
@ -183,7 +183,7 @@ cypher()
if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){ if (wordnumber < wordcount && wordvalue[wordnumber+1] == EVERYTHING){
for (n=0; n < NUMOFOBJECTS; n++) for (n=0; n < NUMOFOBJECTS; n++)
if (testbit(location[position].objects,n) && *objsht[n]){ if (testbit(location[position].objects,n) && objsht[n]){
wordvalue[wordnumber+1] = n; wordvalue[wordnumber+1] = n;
wordnumber = puton(); wordnumber = puton();
} }

View File

@ -180,7 +180,7 @@ face downward on the carpet clutching his chest.*\n\
The hallway leads -.**\n" }, The hallway leads -.**\n" },
{ "You are in the dining hall.", { "You are in the dining hall.",
0, 30, 31, 23, 0, 0, 0, 0, 0, 30, 31, 23, 0, 0, 0, 0,
"This was the seen of a mass suicide. Hundreds of ambassadors and assorted\n\ "This was the scene of a mass suicide. Hundreds of ambassadors and assorted\n\
dignitaries sit slumped over their breakfast cereal. I suppose the news\n\ dignitaries sit slumped over their breakfast cereal. I suppose the news\n\
of the cylon attack killed them. There is a strange chill in this room. I\n\ of the cylon attack killed them. There is a strange chill in this room. I\n\
would not linger here. * The kitchen is +. Entrances + and +.\n" }, would not linger here. * The kitchen is +. Entrances + and +.\n" },
@ -445,7 +445,7 @@ outcroppings of lava to land. There is a nicer beach ***+.\n" },
{ "You are lost in a sea of fog.", { "You are lost in a sea of fog.",
97, 104, 97, 97, 97, 1, 0, 1, 97, 104, 97, 97, 97, 1, 0, 1,
"What have you gotten us into?\n\ "What have you gotten us into?\n\
I cant see a thing! ****\n" }, I can't see a thing! ****\n" },
{ "You are on a gravel wash.", { "You are on a gravel wash.",
125, 126, 127, 128, 84, 0, 0, 0, 125, 126, 127, 128, 84, 0, 0, 0,
"The sound of cascading water is the background for a diluted chorus of \n\ "The sound of cascading water is the background for a diluted chorus of \n\
@ -530,7 +530,7 @@ impossible to climb down to a small cave entrance below. Only at rare\n\
minus tides would it be possible to enter.*** The beach is better +.\n" }, minus tides would it be possible to enter.*** The beach is better +.\n" },
{ "You are on the coast road.", { "You are on the coast road.",
158, 161, 162, 91, 79, 0, 0, 0, 158, 161, 162, 91, 79, 0, 0, 0,
"The road is beginning to turn inland.* I can here the surf +. The road\n\ "The road is beginning to turn inland.* I can hear the surf +. The road\n\
continues +.*\n" }, continues +.*\n" },
{ "The road winds deeper into the trees.", { "The road winds deeper into the trees.",
163, 142, 91, 164, 79, 0, 0, 0, 163, 142, 91, 164, 79, 0, 0, 0,

View File

@ -37,7 +37,7 @@ static char sccsid[] = "@(#)dayobjs.c 8.1 (Berkeley) 5/31/93";
#include "externs.h" #include "externs.h"
struct objs dayobjs[] = { const struct objs dayobjs[] = {
{ 236, HORSE }, { 236, HORSE },
{ 237, CAR }, { 237, CAR },
{ 275, POT }, { 275, POT },

View File

@ -218,7 +218,7 @@
#define MAXCUMBER 10 #define MAXCUMBER 10
struct room { struct room {
char *name; const char *name;
int link[8]; int link[8];
#define north link[0] #define north link[0]
#define south link[1] #define south link[1]
@ -228,7 +228,7 @@ struct room {
#define access link[5] #define access link[5]
#define down link[6] #define down link[6]
#define flyhere link[7] #define flyhere link[7]
char *desc; const char *desc;
int objects[NUMOFWORDS]; int objects[NUMOFWORDS];
}; };
extern struct room dayfile[]; extern struct room dayfile[];
@ -236,11 +236,11 @@ extern struct room nightfile[];
struct room *location; struct room *location;
/* object characteristics */ /* object characteristics */
char *objdes[NUMOFOBJECTS]; const char *const objdes[NUMOFOBJECTS];
char *objsht[NUMOFOBJECTS]; const char *const objsht[NUMOFOBJECTS];
char *ouch[NUMOFINJURIES]; const char *const ouch[NUMOFINJURIES];
int objwt[NUMOFOBJECTS]; const int objwt[NUMOFOBJECTS];
int objcumber[NUMOFOBJECTS]; const int objcumber[NUMOFOBJECTS];
/* current input line */ /* current input line */
#define NWORD 20 /* words per line */ #define NWORD 20 /* words per line */
@ -249,7 +249,7 @@ int wordvalue[NWORD];
int wordtype[NWORD]; int wordtype[NWORD];
int wordcount, wordnumber; int wordcount, wordnumber;
char *truedirec(), *rate(); const char *truedirec(), *rate();
char *getcom(), *getword(); char *getcom(), *getword();
/* state of the game */ /* state of the game */
@ -284,7 +284,7 @@ char injuries[NUMOFINJURIES];
char uname[MAXLOGNAME]; char uname[MAXLOGNAME];
struct wlist { struct wlist {
char *string; const char *string;
int value, article; int value, article;
struct wlist *next; struct wlist *next;
}; };
@ -298,7 +298,7 @@ struct objs {
short room; short room;
short obj; short obj;
}; };
extern struct objs dayobjs[]; extern const struct objs dayobjs[];
extern struct objs nightobjs[]; extern const struct objs nightobjs[];
gid_t egid; gid_t egid;

View File

@ -42,7 +42,7 @@ char *
getcom(buf, size, prompt, error) getcom(buf, size, prompt, error)
char *buf; char *buf;
int size; int size;
char *prompt, *error; const char *prompt, *error;
{ {
for (;;) { for (;;) {
fputs(prompt, stdout); fputs(prompt, stdout);

View File

@ -40,7 +40,7 @@ static char sccsid[] = "@(#)globals.c 8.1 (Berkeley) 5/31/93";
int WEIGHT = MAXWEIGHT; int WEIGHT = MAXWEIGHT;
int CUMBER = MAXCUMBER; int CUMBER = MAXCUMBER;
char *objdes[NUMOFOBJECTS] = { const char *const objdes[NUMOFOBJECTS] = {
"There is a knife here", "There is a knife here",
"There is an exquisitely crafted sword and scabbard here.", "There is an exquisitely crafted sword and scabbard here.",
0, /* can land from here */ 0, /* can land from here */
@ -108,7 +108,7 @@ char *objdes[NUMOFOBJECTS] = {
}; };
char *objsht[NUMOFOBJECTS] = { const char *const objsht[NUMOFOBJECTS] = {
"knife", "knife",
"fine sword", "fine sword",
0, 0,
@ -175,7 +175,7 @@ char *objsht[NUMOFOBJECTS] = {
"diamond block" "diamond block"
}; };
char *ouch[NUMOFINJURIES] = { const char *const ouch[NUMOFINJURIES] = {
"some minor abrasions", "some minor abrasions",
"some minor lacerations", "some minor lacerations",
"a minor puncture wound", "a minor puncture wound",
@ -191,7 +191,7 @@ char *ouch[NUMOFINJURIES] = {
"a broken neck" "a broken neck"
}; };
int objwt[NUMOFOBJECTS] = { const int objwt[NUMOFOBJECTS] = {
1, 5, 0, 10, 15, 2, 10, 10, 1, 5, 0, 10, 15, 2, 10, 10,
3, 5, 50, 2500, 2, 1, 100, 1, 3, 5, 50, 2500, 2, 1, 100, 1,
2, 1, 1, 1, 60, 10, 5, 0, 2, 1, 1, 1, 60, 10, 5, 0,
@ -202,7 +202,7 @@ int objwt[NUMOFOBJECTS] = {
50, 45, 45, 100, 2000, 30, 20, 10 50, 45, 45, 100, 2000, 30, 20, 10
}; };
int objcumber[NUMOFOBJECTS] = { const int objcumber[NUMOFOBJECTS] = {
1, 5, 0, 150, 10, 1, 5, 2, 1, 5, 0, 150, 10, 1, 5, 2,
2, 1, 5, 10, 1, 1, 10, 1, 2, 1, 5, 10, 1, 1, 10, 1,
1, 1, 1, 1, 7, 5, 4, 0, 1, 1, 1, 1, 7, 5, 4, 0,

View File

@ -43,7 +43,7 @@ static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93";
initialize(startup) initialize(startup)
char startup; char startup;
{ {
register struct objs *p; const struct objs *p;
void die(); void die();
puts("Version 4.2, fall 1984."); puts("Version 4.2, fall 1984.");
@ -79,7 +79,7 @@ getutmp(uname)
strcpy(uname, ptr ? ptr->pw_name : ""); strcpy(uname, ptr ? ptr->pw_name : "");
} }
char *list[] = { /* hereditary wizards */ const char *const list[] = { /* hereditary wizards */
"riggle", "riggle",
"chris", "chris",
"edward", "edward",
@ -90,15 +90,16 @@ char *list[] = { /* hereditary wizards */
0 0
}; };
char *badguys[] = { const char *const badguys[] = {
"wnj", "wnj",
"root", "root",
"ted", "ted",
0 0
}; };
int
wizard(uname) wizard(uname)
char *uname; const char *uname;
{ {
char flag; char flag;
@ -107,10 +108,11 @@ wizard(uname)
return flag; return flag;
} }
int
checkout(uname) checkout(uname)
register char *uname; const char *uname;
{ {
register char **ptr; const char *const *ptr;
for (ptr = list; *ptr; ptr++) for (ptr = list; *ptr; ptr++)
if (strcmp(*ptr, uname) == 0) if (strcmp(*ptr, uname) == 0)

View File

@ -37,11 +37,12 @@ static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 5/31/93";
#include "externs.h" #include "externs.h"
int
card(array, size) /* for beenthere, injuries */ card(array, size) /* for beenthere, injuries */
register char *array; const char *array;
int size; int size;
{ {
register char *end = array + size; const char *end = array + size;
register int i = 0; register int i = 0;
while (array < end) while (array < end)
@ -50,8 +51,9 @@ card(array, size) /* for beenthere, injuries */
return (i); return (i);
} }
int
ucard(array) ucard(array)
register unsigned *array; const unsigned int *array;
{ {
register int j = 0, n; register int j = 0, n;

View File

@ -180,7 +180,7 @@ face downward on the carpet clutching his chest.*\n\
The hallway leads -.**\n" }, The hallway leads -.**\n" },
{ "You are in the dining hall.", { "You are in the dining hall.",
0, 30, 31, 23, 0, 0, 0, 0, 0, 30, 31, 23, 0, 0, 0, 0,
"This was the seen of a mass suicide. Hundreds of ambassadors and assorted\n\ "This was the scene of a mass suicide. Hundreds of ambassadors and assorted\n\
dignitaries sit slumped over their breakfast cereal. I suppose the news\n\ dignitaries sit slumped over their breakfast cereal. I suppose the news\n\
of the cylon attack killed them. There is a strange chill in this room. I\n\ of the cylon attack killed them. There is a strange chill in this room. I\n\
would not linger here. * The kitchen is +. Entrances + and +.\n" }, would not linger here. * The kitchen is +. Entrances + and +.\n" },
@ -433,7 +433,7 @@ The very tip of the island is +.*\n" },
{ "You are lost in a sea of fog.", { "You are lost in a sea of fog.",
97, 104, 97, 97, 97, 1, 0, 1, 97, 104, 97, 97, 97, 1, 0, 1,
"What have you gotten us into?\n\ "What have you gotten us into?\n\
I cant see a thing! ****\n" }, I can't see a thing! ****\n" },
{ "You are on a gravel wash.", { "You are on a gravel wash.",
125, 126, 127, 128, 84, 0, 0, 0, 125, 126, 127, 128, 84, 0, 0, 0,
"It is very dark here. A cool breeze is blowing from +. No moonlight can\n\ "It is very dark here. A cool breeze is blowing from +. No moonlight can\n\
@ -512,7 +512,7 @@ small cave entrance below. Large rocks would usually churn the waves\n\
asunder.*** The beach goes -.\n" }, asunder.*** The beach goes -.\n" },
{ "You are on the coast road.", { "You are on the coast road.",
158, 161, 162, 91, 79, 0, 0, 0, 158, 161, 162, 91, 79, 0, 0, 0,
"The road is beginning to turn slightly -. I can here the surf +. The road\n\ "The road is beginning to turn slightly -. I can hear the surf +. The road\n\
continues into the dark forest +.*\n" }, continues into the dark forest +.*\n" },
{ "The road winds deeper into the trees.", { "The road winds deeper into the trees.",
163, 142, 91, 164, 79, 0, 0, 0, 163, 142, 91, 164, 79, 0, 0, 0,

View File

@ -37,7 +37,7 @@ static char sccsid[] = "@(#)nightobjs.c 8.1 (Berkeley) 5/31/93";
#include "externs.h" #include "externs.h"
struct objs nightobjs[] = { const struct objs nightobjs[] = {
{ 218, PAJAMAS }, { 218, PAJAMAS },
{ 235, NATIVE }, { 235, NATIVE },
{ 92, PAPAYAS }, { 92, PAPAYAS },

View File

@ -45,8 +45,9 @@ wordinit()
install(w); install(w);
} }
int
hash(s) hash(s)
register char *s; const char *s;
{ {
register hashval = 0; register hashval = 0;
@ -60,7 +61,7 @@ hash(s)
struct wlist * struct wlist *
lookup(s) lookup(s)
char *s; const char *s;
{ {
register struct wlist *wp; register struct wlist *wp;

View File

@ -40,7 +40,7 @@ static char sccsid[] = "@(#)room.c 8.1 (Berkeley) 5/31/93";
writedes() writedes()
{ {
int compass; int compass;
register char *p; const char *p;
register c; register c;
printf("\n\t%s\n", location[position].name); printf("\n\t%s\n", location[position].name);
@ -104,7 +104,7 @@ struct room here;
} }
} }
char * const char *
truedirec(way, option) truedirec(way, option)
int way; int way;
char option; char option;

View File

@ -40,6 +40,7 @@ static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93";
#include <sys/param.h> /* MAXPATHLEN */ #include <sys/param.h> /* MAXPATHLEN */
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#include <err.h>
#include "externs.h" #include "externs.h"
void void
@ -93,7 +94,10 @@ restore()
fread(&loved, sizeof loved, 1, fp); fread(&loved, sizeof loved, 1, fp);
fread(&pleasure, sizeof pleasure, 1, fp); fread(&pleasure, sizeof pleasure, 1, fp);
fread(&power, sizeof power, 1, fp); fread(&power, sizeof power, 1, fp);
fread(&ego, sizeof ego, 1, fp); /* We must check the last read, to catch truncated save files. */
if (fread(&ego, sizeof ego, 1, fp) < 1)
errx(1, "save file %s too short", home1);
fclose(fp);
} }
void void

View File

@ -127,6 +127,9 @@ main(argc, argv)
{ {
char cardline[80]; char cardline[80];
/* revoke setgid privileges */
setgid(getgid());
/* /*
* The original bcd prompts with a "%" when reading from stdin, * The original bcd prompts with a "%" when reading from stdin,
* but this seems kind of silly. So this one doesn't. * but this seems kind of silly. So this one doesn't.

View File

@ -83,6 +83,9 @@ void main(argc, argv)
register char *inbuf; register char *inbuf;
int obs[26], try, winner; int obs[26], try, winner;
/* revoke setgid privileges */
setgid(getgid());
if (argc > 1) if (argc > 1)
printit(argv[1]); printit(argv[1]);

View File

@ -61,6 +61,7 @@ static char sccsid[] = "@(#)canfield.c 8.1 (Berkeley) 5/31/93";
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <fcntl.h>
#include "pathnames.h" #include "pathnames.h"
@ -1325,7 +1326,7 @@ suspend()
move(21, 0); move(21, 0);
refresh(); refresh();
if (dbfd != -1) { if (dbfd != -1) {
lseek(dbfd, uid * sizeof(struct betinfo), 0); lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET);
write(dbfd, (char *)&total, sizeof(total)); write(dbfd, (char *)&total, sizeof(total));
} }
kill(getpid(), SIGTSTP); kill(getpid(), SIGTSTP);
@ -1577,7 +1578,7 @@ initall()
initdeck(deck); initdeck(deck);
uid = getuid(); uid = getuid();
i = lseek(dbfd, uid * sizeof(struct betinfo), 0); i = lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET);
if (i < 0) { if (i < 0) {
close(dbfd); close(dbfd);
dbfd = -1; dbfd = -1;
@ -1640,7 +1641,7 @@ cleanup()
status = NOBOX; status = NOBOX;
updatebettinginfo(); updatebettinginfo();
if (dbfd != -1) { if (dbfd != -1) {
lseek(dbfd, uid * sizeof(struct betinfo), 0); lseek(dbfd, uid * sizeof(struct betinfo), SEEK_SET);
write(dbfd, (char *)&total, sizeof(total)); write(dbfd, (char *)&total, sizeof(total));
close(dbfd); close(dbfd);
} }
@ -1672,11 +1673,9 @@ askquit()
/* /*
* Can you tell that this used to be a Pascal program? * Can you tell that this used to be a Pascal program?
*/ */
main(argc, argv) main()
int argc;
char *argv[];
{ {
dbfd = open(_PATH_SCORE, 2); dbfd = open(_PATH_SCORE, O_RDWR);
/* revoke */ /* revoke */
setgid(getgid()); setgid(getgid());

View File

@ -43,6 +43,8 @@ static char sccsid[] = "@(#)cfscores.c 8.1 (Berkeley) 5/31/93";
#include <sys/types.h> #include <sys/types.h>
#include <pwd.h> #include <pwd.h>
#include <fcntl.h>
#include <unistd.h>
#include "pathnames.h" #include "pathnames.h"
struct betinfo { struct betinfo {
@ -69,7 +71,7 @@ main(argc, argv)
printf("Usage: cfscores [user]\n"); printf("Usage: cfscores [user]\n");
exit(1); exit(1);
} }
dbfd = open(_PATH_SCORE, 0); dbfd = open(_PATH_SCORE, O_RDONLY);
if (dbfd < 0) { if (dbfd < 0) {
perror(_PATH_SCORE); perror(_PATH_SCORE);
exit(2); exit(2);
@ -114,7 +116,7 @@ printuser(pw, printfail)
printf("Bad uid %d\n", pw->pw_uid); printf("Bad uid %d\n", pw->pw_uid);
return; return;
} }
i = lseek(dbfd, pw->pw_uid * sizeof(struct betinfo), 0); i = lseek(dbfd, pw->pw_uid * sizeof(struct betinfo), SEEK_SET);
if (i < 0) { if (i < 0) {
perror("lseek"); perror("lseek");
return; return;

View File

@ -78,6 +78,7 @@ main(argc, argv)
exit(0); exit(0);
gametty = ttyname(0); gametty = ttyname(0);
unsetenv("TZ");
(void)time(&now); (void)time(&now);
read_config(); read_config();
#ifdef LOG #ifdef LOG

View File

@ -37,6 +37,8 @@
/ /
*************************************************************************/ *************************************************************************/
void Error();
static char *files[] = { /* all files to create */ static char *files[] = { /* all files to create */
_SPATH_MONST, _SPATH_MONST,
_SPATH_PEOPLE, _SPATH_PEOPLE,
@ -221,6 +223,7 @@ main(argc, argv)
/ /
*************************************************************************/ *************************************************************************/
void
Error(str, file) Error(str, file)
char *str, *file; char *str, *file;
{ {

View File

@ -57,7 +57,9 @@ static const char sccsid[] = "@(#)pom.c 8.1 (Berkeley) 5/31/93";
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#define PI 3.141592654 #ifndef PI
#define PI 3.14159265358979323846
#endif
#define EPOCH 85 #define EPOCH 85
#define EPSILONg 279.611371 /* solar ecliptic long at EPOCH */ #define EPSILONg 279.611371 /* solar ecliptic long at EPOCH */
#define RHOg 282.680403 /* solar ecliptic long of perigee at EPOCH */ #define RHOg 282.680403 /* solar ecliptic long of perigee at EPOCH */

View File

@ -1,10 +1,15 @@
Albania:Tirana|Tirane" Albania:Tirana|Tirane"
Andorra:Andorra la V[ell|iej]a Andorra:Andorra la V[ell|iej]a
Austria:Vienna|Wien Austria:Vienna|Wien
Belarus|Byelorussia:M[i|e]nsk
Belgium:Brussel[s|]|Bruxelles Belgium:Brussel[s|]|Bruxelles
Bosnia[-Herzegovina|]:Sarajevo
Bulgaria:Sofi[a|ya] Bulgaria:Sofi[a|ya]
Czechoslovakia:Prague|Praha Croatia:Zagreb
Czech Republic:Prague|Praha
Denmark:Copenhagen|K[o|o/]benhavn Denmark:Copenhagen|K[o|o/]benhavn
Estonia:Tallinn
Georgia:Tbilisi
Germany:Berlin Germany:Berlin
United Kingdom|England|Great Britain|UK:London United Kingdom|England|Great Britain|UK:London
Finland:Helsinki Finland:Helsinki
@ -14,19 +19,26 @@ Hungary:Budapest
Iceland:Reykjavik Iceland:Reykjavik
Ireland|Eire:Dublin Ireland|Eire:Dublin
Italy:Rom[e|a] Italy:Rom[e|a]
Latvia:Riga
Liechtenstein:Vaduz Liechtenstein:Vaduz
Lithuania:Vilnius
Luxembourg:Luxembourg Luxembourg:Luxembourg
[|Former Yugoslav Republic Of ]Macedonia:Skop[|l]je
Malta:Valletta Malta:Valletta
Moldova:Chisinau|Kishinev
Monaco:Monte Carlo Monaco:Monte Carlo
Netherlands|Holland:The Hague|'sGravenhage|den Haag|Amsterdam Netherlands|Holland:The Hague|'sGravenhage|den Haag|Amsterdam
Norway:Oslo Norway:Oslo
Poland:Wars[aw|zawa] Poland:Wars[aw|zawa]
Portugal:Lisbo[n|a] Portugal:Lisbo[n|a]
R[u|o]mania:Bucharest|Bucuresti R[u|o]mania:Bucharest|Bucuresti
Russia:Mos[cow|kva]
San Marino:San Marino San Marino:San Marino
Slovakia|Slovak Republic:Bratislava
Slovenia:Ljubljana
Spain:Madrid Spain:Madrid
Sweden:Stockholm Sweden:Stockholm
Switzerland:Bern{e} Switzerland:Bern{e}
Turkey:Ankara Turkey:Ankara
Russia:Mos[cow|kva] Ukraine:Kiev|Kyiv
Yugoslavia:Belgrade|Beograd Yugoslavia:Belgrade|Beograd

View File

@ -2,7 +2,7 @@
PROG= rain PROG= rain
MAN6= rain.6 MAN6= rain.6
DPADD= ${LIBTERMCAP} ${LIBCOMPAT} DPADD= ${LIBCURSES} ${LIBCOMPAT}
LDADD= -ltermcap -lcompat LDADD= -lcurses -lcompat
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -60,7 +60,8 @@ get_move()
lastmove = *Next_move; lastmove = *Next_move;
else else
lastmove = -1; /* flag for "first time in" */ lastmove = -1; /* flag for "first time in" */
} } else
lastmove = 0; /* Shut up gcc */
#endif #endif
for (;;) { for (;;) {
if (Teleport && must_telep()) if (Teleport && must_telep())

View File

@ -63,7 +63,7 @@ mon_hit(monster)
register object *monster; register object *monster;
{ {
short damage, hit_chance; short damage, hit_chance;
char *mn; const char *mn;
float minus; float minus;
if (fight_monster && (monster != fight_monster)) { if (fight_monster && (monster != fight_monster)) {
@ -175,7 +175,7 @@ short other;
} }
get_damage(ds, r) get_damage(ds, r)
char *ds; const char *ds;
boolean r; boolean r;
{ {
register i = 0, j, n, d, total = 0; register i = 0, j, n, d, total = 0;
@ -201,7 +201,7 @@ boolean r;
} }
get_w_damage(obj) get_w_damage(obj)
object *obj; const object *obj;
{ {
char new_damage[12]; char new_damage[12];
register to_hit, damage; register to_hit, damage;
@ -220,7 +220,7 @@ object *obj;
} }
get_number(s) get_number(s)
register char *s; const char *s;
{ {
register i = 0; register i = 0;
register total = 0; register total = 0;
@ -234,7 +234,7 @@ register char *s;
long long
lget_number(s) lget_number(s)
char *s; const char *s;
{ {
short i = 0; short i = 0;
long total = 0; long total = 0;
@ -247,7 +247,7 @@ char *s;
} }
to_hit(obj) to_hit(obj)
object *obj; const object *obj;
{ {
if (!obj) { if (!obj) {
return(1); return(1);
@ -289,7 +289,7 @@ mon_damage(monster, damage)
object *monster; object *monster;
short damage; short damage;
{ {
char *mn; const char *mn;
short row, col; short row, col;
monster->hp_to_kill -= damage; monster->hp_to_kill -= damage;
@ -423,7 +423,7 @@ short allow_off_screen;
} }
get_hit_chance(weapon) get_hit_chance(weapon)
object *weapon; const object *weapon;
{ {
short hit_chance; short hit_chance;
@ -434,7 +434,7 @@ object *weapon;
} }
get_weapon_damage(weapon) get_weapon_damage(weapon)
object *weapon; const object *weapon;
{ {
short damage; short damage;

View File

@ -65,8 +65,8 @@ boolean ask_quit = 1;
boolean no_skull = 0; boolean no_skull = 0;
boolean passgo = 0; boolean passgo = 0;
boolean flush = 1; boolean flush = 1;
char *error_file = "rogue.esave"; const char *error_file = "rogue.esave";
char *byebye_string = "Okay, bye bye!"; const char *byebye_string = "Okay, bye bye!";
extern char *fruit; extern char *fruit;
extern char *save_file; extern char *save_file;
@ -77,7 +77,7 @@ init(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
{ {
char *pn; const char *pn;
int seed; int seed;
pn = md_gln(); pn = md_gln();
@ -173,7 +173,7 @@ player_init()
} }
clean_up(estr) clean_up(estr)
char *estr; const char *estr;
{ {
if (save_is_interactive) { if (save_is_interactive) {
if (init_curses) { if (init_curses) {
@ -310,7 +310,7 @@ char **s, *e;
boolean add_blank; boolean add_blank;
{ {
short i = 0; short i = 0;
char *t; const char *t;
t = e; t = e;
@ -332,7 +332,8 @@ boolean add_blank;
} }
init_str(str, dflt) init_str(str, dflt)
char **str, *dflt; char **str;
const char *dflt;
{ {
if (!(*str)) { if (!(*str)) {
*str = md_malloc(MAX_OPT_LEN + 2); *str = md_malloc(MAX_OPT_LEN + 2);

View File

@ -53,9 +53,9 @@ static char sccsid[] = "@(#)inventory.c 8.1 (Berkeley) 5/31/93";
#include "rogue.h" #include "rogue.h"
boolean is_wood[WANDS]; boolean is_wood[WANDS];
char *press_space = " --press space to continue--"; const char *press_space = " --press space to continue--";
char *wand_materials[WAND_MATERIALS] = { const char *const wand_materials[WAND_MATERIALS] = {
"steel ", "steel ",
"bronze ", "bronze ",
"gold ", "gold ",
@ -89,7 +89,7 @@ char *wand_materials[WAND_MATERIALS] = {
"wooden " "wooden "
}; };
char *gems[GEMS] = { const char *const gems[GEMS] = {
"diamond ", "diamond ",
"stibotantalite ", "stibotantalite ",
"lapi-lazuli ", "lapi-lazuli ",
@ -106,7 +106,7 @@ char *gems[GEMS] = {
"garnet " "garnet "
}; };
char *syllables[MAXSYLLABLES] = { const char *const syllables[MAXSYLLABLES] = {
"blech ", "blech ",
"foo ", "foo ",
"barf ", "barf ",
@ -153,10 +153,10 @@ char *syllables[MAXSYLLABLES] = {
struct id_com_s { struct id_com_s {
short com_char; short com_char;
char *com_desc; const char *com_desc;
}; };
struct id_com_s com_id_tab[COMS] = { const struct id_com_s com_id_tab[COMS] = {
'?', "? prints help", '?', "? prints help",
'r', "r read scroll", 'r', "r read scroll",
'/', "/ identify object", '/', "/ identify object",
@ -211,7 +211,7 @@ extern boolean wizard;
extern char *m_names[], *more; extern char *m_names[], *more;
inventory(pack, mask) inventory(pack, mask)
object *pack; const object *pack;
unsigned short mask; unsigned short mask;
{ {
object *obj; object *obj;
@ -441,10 +441,10 @@ make_scroll_titles()
} }
get_desc(obj, desc) get_desc(obj, desc)
object *obj; const object *obj;
char *desc; char *desc;
{ {
char *item_name; const char *item_name;
struct id *id_table; struct id *id_table;
char more_info[32]; char more_info[32];
short i; short i;
@ -657,7 +657,7 @@ short ichar;
struct id * struct id *
get_id_table(obj) get_id_table(obj)
object *obj; const object *obj;
{ {
switch(obj->what_is) { switch(obj->what_is) {
case SCROL: case SCROL:
@ -696,7 +696,7 @@ boolean is_weapon;
id_type() id_type()
{ {
char *id; const char *id;
int ch; int ch;
char buf[DCOLS]; char buf[DCOLS];

View File

@ -57,11 +57,11 @@ static char sccsid[] = "@(#)level.c 8.1 (Berkeley) 5/31/93";
short cur_level = 0; short cur_level = 0;
short max_level = 1; short max_level = 1;
short cur_room; short cur_room;
char *new_level_message = 0; const char *new_level_message = 0;
short party_room = NO_ROOM; short party_room = NO_ROOM;
short r_de; short r_de;
long level_points[MAX_EXP_LEVEL] = { const long level_points[MAX_EXP_LEVEL] = {
10L, 10L,
20L, 20L,
40L, 40L,
@ -572,7 +572,7 @@ boolean do_rec_de;
recursive_deadend(rn, offsets, srow, scol) recursive_deadend(rn, offsets, srow, scol)
short rn; short rn;
short *offsets; const short *offsets;
short srow, scol; short srow, scol;
{ {
short i, de; short i, de;

View File

@ -254,7 +254,7 @@ md_ignore_signals()
int int
md_get_file_id(fname) md_get_file_id(fname)
char *fname; const char *fname;
{ {
struct stat sbuf; struct stat sbuf;
@ -274,7 +274,7 @@ char *fname;
int int
md_link_count(fname) md_link_count(fname)
char *fname; const char *fname;
{ {
struct stat sbuf; struct stat sbuf;
@ -330,7 +330,7 @@ struct rogue_time *rt_buf;
*/ */
md_gfmt(fname, rt_buf) md_gfmt(fname, rt_buf)
char *fname; const char *fname;
struct rogue_time *rt_buf; struct rogue_time *rt_buf;
{ {
struct stat sbuf; struct stat sbuf;
@ -362,7 +362,7 @@ struct rogue_time *rt_buf;
boolean boolean
md_df(fname) md_df(fname)
char *fname; const char *fname;
{ {
if (unlink(fname)) { if (unlink(fname)) {
return(0); return(0);
@ -379,7 +379,7 @@ char *fname;
* function, but then the score file would only have one name in it. * function, but then the score file would only have one name in it.
*/ */
char * const char *
md_gln() md_gln()
{ {
struct passwd *p; struct passwd *p;
@ -446,7 +446,7 @@ int nsecs;
char * char *
md_getenv(name) md_getenv(name)
char *name; const char *name;
{ {
char *value; char *value;
@ -493,7 +493,10 @@ int n;
md_gseed() md_gseed()
{ {
return(getpid()); time_t seconds;
time(&seconds);
return((int) seconds);
} }
/* md_exit(): /* md_exit():
@ -550,7 +553,7 @@ boolean l;
*/ */
md_shell(shell) md_shell(shell)
char *shell; const char *shell;
{ {
long w[2]; long w[2];

View File

@ -57,14 +57,14 @@ char msgs[NMESSAGES][DCOLS] = {"", "", "", "", ""};
short msg_col = 0, imsg = -1; short msg_col = 0, imsg = -1;
boolean msg_cleared = 1, rmsg = 0; boolean msg_cleared = 1, rmsg = 0;
char hunger_str[8] = ""; char hunger_str[8] = "";
char *more = "-more-"; const char *more = "-more-";
extern boolean cant_int, did_int, interrupted, save_is_interactive, flush; extern boolean cant_int, did_int, interrupted, save_is_interactive, flush;
extern short add_strength; extern short add_strength;
extern short cur_level; extern short cur_level;
message(msg, intrpt) message(msg, intrpt)
char *msg; const char *msg;
boolean intrpt; boolean intrpt;
{ {
cant_int = 1; cant_int = 1;
@ -130,8 +130,9 @@ check_message()
} }
get_input_line(prompt, insert, buf, if_cancelled, add_blank, do_echo) get_input_line(prompt, insert, buf, if_cancelled, add_blank, do_echo)
char *prompt, *buf, *insert; const char *prompt, *insert;
char *if_cancelled; char *buf;
const char *if_cancelled;
boolean add_blank; boolean add_blank;
boolean do_echo; boolean do_echo;
{ {
@ -305,7 +306,7 @@ register stat_mask;
} }
pad(s, n) pad(s, n)
char *s; const char *s;
short n; short n;
{ {
short i; short i;
@ -357,7 +358,7 @@ short ch;
} }
r_index(str, ch, last) r_index(str, ch, last)
char *str; const char *str;
int ch; int ch;
boolean last; boolean last;
{ {

View File

@ -55,7 +55,7 @@ static char sccsid[] = "@(#)monster.c 8.1 (Berkeley) 5/31/93";
object level_monsters; object level_monsters;
boolean mon_disappeared; boolean mon_disappeared;
char *m_names[] = { const char *const m_names[] = {
"aquator", "aquator",
"bat", "bat",
"centaur", "centaur",
@ -171,7 +171,7 @@ register mn;
mv_mons() mv_mons()
{ {
register object *monster, *next_monster; register object *monster, *next_monster, *test_mons;
boolean flew; boolean flew;
if (haste_self % 2) { if (haste_self % 2) {
@ -210,7 +210,17 @@ mv_mons()
if (!(flew && mon_can_go(monster, rogue.row, rogue.col))) { if (!(flew && mon_can_go(monster, rogue.row, rogue.col))) {
mv_1_monster(monster, rogue.row, rogue.col); mv_1_monster(monster, rogue.row, rogue.col);
} }
NM: monster = next_monster; NM: test_mons = level_monsters.next_monster;
monster = NULL;
while(test_mons)
{
if(next_monster == test_mons)
{
monster = next_monster;
break;
}
test_mons = test_mons->next_monster;
}
} }
} }
@ -488,7 +498,7 @@ register short row, col;
} }
mon_can_go(monster, row, col) mon_can_go(monster, row, col)
register object *monster; const object *monster;
register short row, col; register short row, col;
{ {
object *obj; object *obj;
@ -572,9 +582,9 @@ short row, col;
} }
} }
char * const char *
mon_name(monster) mon_name(monster)
object *monster; const object *monster;
{ {
short ch; short ch;
@ -790,7 +800,7 @@ object *monster;
gr_obj_char() gr_obj_char()
{ {
short r; short r;
char *rs = "%!?]=/):*"; const char *rs = "%!?]=/):*";
r = get_rand(0, 8); r = get_rand(0, 8);
@ -832,7 +842,8 @@ aggravate()
boolean boolean
mon_sees(monster, row, col) mon_sees(monster, row, col)
object *monster; const object *monster;
int row, col;
{ {
short rn, rdif, cdif, retval; short rn, rdif, cdif, retval;

View File

@ -54,7 +54,7 @@ static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
short m_moves = 0; short m_moves = 0;
boolean jump = 0; boolean jump = 0;
char *you_can_move_again = "you can move again"; const char *you_can_move_again = "you can move again";
extern short cur_room, halluc, blind, levitate; extern short cur_room, halluc, blind, levitate;
extern short cur_level, max_level; extern short cur_level, max_level;

View File

@ -228,6 +228,7 @@ boolean is_maze;
place_at(obj, row, col) place_at(obj, row, col)
object *obj; object *obj;
int row, col;
{ {
obj->row = row; obj->row = row;
obj->col = col; obj->col = col;
@ -257,6 +258,7 @@ short row, col;
object * object *
get_letter_object(ch) get_letter_object(ch)
int ch;
{ {
object *obj; object *obj;
@ -281,11 +283,11 @@ object *objlist;
} }
} }
char * const char *
name_of(obj) name_of(obj)
object *obj; const object *obj;
{ {
char *retstring; const char *retstring;
switch(obj->what_is) { switch(obj->what_is) {
case SCROL: case SCROL:
@ -602,7 +604,7 @@ put_stairs()
} }
get_armor_class(obj) get_armor_class(obj)
object *obj; const object *obj;
{ {
if (obj) { if (obj) {
return(obj->class + obj->d_enchant); return(obj->class + obj->d_enchant);

View File

@ -52,13 +52,14 @@ static char sccsid[] = "@(#)pack.c 8.1 (Berkeley) 5/31/93";
#include "rogue.h" #include "rogue.h"
char *curse_message = "you can't, it appears to be cursed"; const char *curse_message = "you can't, it appears to be cursed";
extern short levitate; extern short levitate;
object * object *
add_to_pack(obj, pack, condense) add_to_pack(obj, pack, condense)
object *obj, *pack; object *obj, *pack;
int condense;
{ {
object *op; object *op;
@ -99,6 +100,7 @@ object *obj, *pack;
object * object *
pick_up(row, col, status) pick_up(row, col, status)
int row, col;
short *status; short *status;
{ {
object *obj; object *obj;
@ -270,7 +272,7 @@ wait_for_ack()
} }
pack_letter(prompt, mask) pack_letter(prompt, mask)
char *prompt; const char *prompt;
unsigned short mask; unsigned short mask;
{ {
short ch; short ch;
@ -460,7 +462,7 @@ call_it()
} }
pack_count(new_obj) pack_count(new_obj)
object *new_obj; const object *new_obj;
{ {
object *obj; object *obj;
short count = 0; short count = 0;
@ -488,7 +490,7 @@ object *new_obj;
boolean boolean
mask_pack(pack, mask) mask_pack(pack, mask)
object *pack; const object *pack;
unsigned short mask; unsigned short mask;
{ {
while (pack->next_object) { while (pack->next_object) {

View File

@ -53,7 +53,7 @@ static char sccsid[] = "@(#)play.c 8.1 (Berkeley) 5/31/93";
#include "rogue.h" #include "rogue.h"
boolean interrupted = 0; boolean interrupted = 0;
char *unknown_command = "unknown command"; const char *unknown_command = "unknown command";
extern short party_room, bear_trap; extern short party_room, bear_trap;
extern char hit_message[]; extern char hit_message[];

View File

@ -52,8 +52,8 @@ static char sccsid[] = "@(#)ring.c 8.1 (Berkeley) 5/31/93";
#include "rogue.h" #include "rogue.h"
char *left_or_right = "left or right hand?"; const char *left_or_right = "left or right hand?";
char *no_ring = "there's no ring on that hand"; const char *no_ring = "there's no ring on that hand";
short stealthy; short stealthy;
short r_rings; short r_rings;
short add_strength; short add_strength;

View File

@ -221,7 +221,7 @@ struct id {
struct obj { /* comment is monster meaning */ struct obj { /* comment is monster meaning */
unsigned long m_flags; /* monster flags */ unsigned long m_flags; /* monster flags */
char *damage; /* damage it does */ const char *damage; /* damage it does */
short quantity; /* hit points to kill */ short quantity; /* hit points to kill */
short ichar; /* 'A' is for aquatar */ short ichar; /* 'A' is for aquatar */
short kill_exp; /* exp for killing it */ short kill_exp; /* exp for killing it */
@ -427,10 +427,10 @@ extern object level_monsters;
/* external routine declarations. /* external routine declarations.
*/ */
char *mon_name(); const char *mon_name();
char *get_ench_color(); const char *get_ench_color();
char *name_of(); const char *name_of();
char *md_gln(); const char *md_gln();
char *md_getenv(); char *md_getenv();
char *md_malloc(); char *md_malloc();
boolean is_direction(); boolean is_direction();

View File

@ -62,7 +62,7 @@ extern char *nick_name, *fruit, *save_file, *press_space;
#define NOPTS 8 #define NOPTS 8
struct option { struct option {
char *prompt; const char *prompt;
boolean is_bool; boolean is_bool;
char **strval; char **strval;
boolean *bval; boolean *bval;
@ -129,6 +129,7 @@ int rn;
} }
light_passage(row, col) light_passage(row, col)
int row, col;
{ {
short i, j, i_end, j_end; short i, j, i_end, j_end;
@ -604,7 +605,7 @@ edit_opts()
opt_show(i) opt_show(i)
int i; int i;
{ {
char *s; const char *s;
struct option *opt = &options[i]; struct option *opt = &options[i];
opt_erase(i); opt_erase(i);
@ -635,7 +636,7 @@ int i;
do_shell() do_shell()
{ {
#ifdef UNIX #ifdef UNIX
char *sh; const char *sh;
md_ignore_signals(); md_ignore_signals();
if (!(sh = md_getenv("SHELL"))) { if (!(sh = md_getenv("SHELL"))) {

View File

@ -94,7 +94,7 @@ save_game()
} }
save_into_file(sfile) save_into_file(sfile)
char *sfile; const char *sfile;
{ {
FILE *fp; FILE *fp;
int file_id; int file_id;
@ -176,7 +176,7 @@ static del_save_file()
} }
restore(fname) restore(fname)
char *fname; const char *fname;
{ {
FILE *fp; FILE *fp;
struct rogue_time saved_time, mod_time; struct rogue_time saved_time, mod_time;
@ -257,16 +257,16 @@ char *fname;
} }
write_pack(pack, fp) write_pack(pack, fp)
object *pack; const object *pack;
FILE *fp; FILE *fp;
{ {
object t; object t;
while (pack = pack->next_object) { while (pack = pack->next_object) {
r_write(fp, (char *) pack, sizeof(object)); r_write(fp, (const char *) pack, sizeof(object));
} }
t.ichar = t.what_is = 0; t.ichar = t.what_is = 0;
r_write(fp, (char *) &t, sizeof(object)); r_write(fp, (const char *) &t, sizeof(object));
} }
read_pack(pack, fp, is_rogue) read_pack(pack, fp, is_rogue)
@ -333,8 +333,8 @@ boolean wr;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (wr) { if (wr) {
r_write(fp, (char *) &(id_table[i].value), sizeof(short)); r_write(fp, (const char *) &(id_table[i].value), sizeof(short));
r_write(fp, (char *) &(id_table[i].id_status), r_write(fp, (const char *) &(id_table[i].id_status),
sizeof(unsigned short)); sizeof(unsigned short));
write_string(id_table[i].title, fp); write_string(id_table[i].title, fp);
} else { } else {
@ -393,7 +393,7 @@ int n;
r_write(fp, buf, n) r_write(fp, buf, n)
FILE *fp; FILE *fp;
char *buf; const char *buf;
int n; int n;
{ {
if (!write_failed) { if (!write_failed) {
@ -407,7 +407,7 @@ int n;
boolean boolean
has_been_touched(saved_time, mod_time) has_been_touched(saved_time, mod_time)
struct rogue_time *saved_time, *mod_time; const struct rogue_time *saved_time, *mod_time;
{ {
if (saved_time->year < mod_time->year) { if (saved_time->year < mod_time->year) {
return(1); return(1);

View File

@ -61,7 +61,7 @@ extern boolean score_only, no_skull, msg_cleared;
extern char *byebye_string, *nick_name; extern char *byebye_string, *nick_name;
killed_by(monster, other) killed_by(monster, other)
object *monster; const object *monster;
short other; short other;
{ {
char buf[128]; char buf[128];
@ -193,7 +193,7 @@ boolean from_intrpt;
} }
put_scores(monster, other) put_scores(monster, other)
object *monster; const object *monster;
short other; short other;
{ {
short i, n, rank = 10, x, ne = 0, found_player = -1; short i, n, rank = 10, x, ne = 0, found_player = -1;
@ -321,9 +321,9 @@ short other;
insert_score(scores, n_names, n_name, rank, n, monster, other) insert_score(scores, n_names, n_name, rank, n, monster, other)
char scores[][82]; char scores[][82];
char n_names[][30]; char n_names[][30];
char *n_name; const char *n_name;
short rank, n; short rank, n;
object *monster; const object *monster;
{ {
short i; short i;
char buf[128]; char buf[128];
@ -423,7 +423,7 @@ sell_pack()
} }
get_value(obj) get_value(obj)
object *obj; const object *obj;
{ {
short wc; short wc;
int val; int val;
@ -491,7 +491,8 @@ id_all()
} }
name_cmp(s1, s2) name_cmp(s1, s2)
char *s1, *s2; char *s1;
const char *s2;
{ {
short i = 0; short i = 0;
int r; int r;
@ -540,7 +541,8 @@ boolean st;
} }
nickize(buf, score, n_name) nickize(buf, score, n_name)
char *buf, *score, *n_name; char *buf;
const char *score, *n_name;
{ {
short i = 15, j; short i = 15, j;
@ -566,7 +568,7 @@ char *buf, *score, *n_name;
center(row, buf) center(row, buf)
short row; short row;
char *buf; const char *buf;
{ {
short margin; short margin;

View File

@ -261,7 +261,7 @@ short row, col;
rand_around(i, r, c) rand_around(i, r, c)
short i, *r, *c; short i, *r, *c;
{ {
static char* pos = "\010\007\001\003\004\005\002\006\0"; static char pos[] = "\010\007\001\003\004\005\002\006\0";
static short row, col; static short row, col;
short j; short j;

View File

@ -56,7 +56,7 @@ trap traps[MAX_TRAPS];
boolean trap_door = 0; boolean trap_door = 0;
short bear_trap = 0; short bear_trap = 0;
char *trap_strings[TRAPS * 2] = { const char *const trap_strings[TRAPS * 2] = {
"trap door", "trap door",
"you fell down a trap", "you fell down a trap",
"bear trap", "bear trap",
@ -72,7 +72,7 @@ char *trap_strings[TRAPS * 2] = {
}; };
extern short cur_level, party_room; extern short cur_level, party_room;
extern char *new_level_message; extern const char *new_level_message;
extern boolean interrupted; extern boolean interrupted;
extern short ring_exp; extern short ring_exp;
extern boolean sustain_strength; extern boolean sustain_strength;

View File

@ -61,7 +61,7 @@ boolean see_invisible = 0;
short extra_hp = 0; short extra_hp = 0;
boolean detect_monster = 0; boolean detect_monster = 0;
boolean con_mon = 0; boolean con_mon = 0;
char *strange_feeling = "you have a strange feeling for a moment, then it passes"; const char *strange_feeling = "you have a strange feeling for a moment, then it passes";
extern short bear_trap; extern short bear_trap;
extern char hunger_str[]; extern char hunger_str[];
@ -580,7 +580,7 @@ go_blind()
mvaddch(rogue.row, rogue.col, rogue.fchar); mvaddch(rogue.row, rogue.col, rogue.fchar);
} }
char * const char *
get_ench_color() get_ench_color()
{ {
if (halluc) { if (halluc) {

View File

@ -275,7 +275,8 @@ bounce(ball, dir, row, col, r)
short ball, dir, row, col, r; short ball, dir, row, col, r;
{ {
short orow, ocol; short orow, ocol;
char buf[DCOLS], *s; char buf[DCOLS];
const char *s;
short i, ch, new_dir = -1, damage; short i, ch, new_dir = -1, damage;
static short btime; static short btime;

View File

@ -157,7 +157,7 @@ char onlytemp;
row = fp->row; row = fp->row;
col = fp->col; col = fp->col;
drift = fp->drift; drift = fp->drift;
move(movement, ship, &fp->dir, &fp->row, &fp->col, &drift); sail_move(movement, ship, &fp->dir, &fp->row, &fp->col, &drift);
if (!*movement) if (!*movement)
(void) strcpy(movement, "d"); (void) strcpy(movement, "d");
@ -176,7 +176,7 @@ char onlytemp;
return total; return total;
} }
move(p, ship, dir, row, col, drift) sail_move(p, ship, dir, row, col, drift)
register char *p; register char *p;
register struct ship *ship; register struct ship *ship;
register char *dir; register char *dir;
@ -222,7 +222,7 @@ register char *drift;
try(command, temp, ma, ta, af, vma, dir, f, t, high, rakeme) try(command, temp, ma, ta, af, vma, dir, f, t, high, rakeme)
register struct ship *f, *t; register struct ship *f, *t;
int ma, ta, af, *high, rakeme; int ma, ta, af, vma, dir, *high, rakeme;
char command[], temp[]; char command[], temp[];
{ {
register int new, n; register int new, n;

View File

@ -70,6 +70,7 @@ makesignal(from, fmt, ship, a, b, c)
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
sync_exists(game) sync_exists(game)
int game;
{ {
char buf[sizeof sync_file]; char buf[sizeof sync_file];
struct stat s; struct stat s;

View File

@ -35,6 +35,8 @@
static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)dumpgame.c 8.1 (Berkeley) 5/31/93";
#endif /* not lint */ #endif /* not lint */
#include <fcntl.h>
# include "trek.h" # include "trek.h"
/*** THIS CONSTANT MUST CHANGE AS THE DATA SPACES CHANGE ***/ /*** THIS CONSTANT MUST CHANGE AS THE DATA SPACES CHANGE ***/
@ -111,7 +113,7 @@ restartgame()
register int fd; register int fd;
int version; int version;
if ((fd = open("trek.dump", 0)) < 0 || if ((fd = open("trek.dump", O_RDONLY)) < 0 ||
read(fd, &version, sizeof version) != sizeof version || read(fd, &version, sizeof version) != sizeof version ||
version != VERSION || version != VERSION ||
readdump(fd)) readdump(fd))

View File

@ -51,8 +51,10 @@ static char sccsid[] = "@(#)wump.c 8.1 (Berkeley) 5/31/93";
* would care to remember. * would care to remember.
*/ */
#include <err.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/wait.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -679,7 +681,10 @@ int_compare(a, b)
instructions() instructions()
{ {
char buf[120], *p, *getenv(); const char *pager;
pid_t pid;
int status;
int fd;
/* /*
* read the instructions file, if needed, and show the user how to * read the instructions file, if needed, and show the user how to
@ -695,12 +700,26 @@ puff of greasy black smoke! (poof)\n");
return; return;
} }
if (!(p = getenv("PAGER")) || if (!isatty(1))
strlen(p) > sizeof(buf) + strlen(_PATH_WUMPINFO) + 5) pager = "cat";
p = _PATH_PAGER; else {
if (!(pager = getenv("PAGER")) || (*pager == 0))
(void)sprintf(buf, "%s %s", p, _PATH_WUMPINFO); pager = _PATH_PAGER;
(void)system(buf); }
switch (pid = fork()) {
case 0: /* child */
if ((fd = open(_PATH_WUMPINFO, O_RDONLY)) == -1)
err(1, "open %s", _PATH_WUMPINFO);
if (dup2(fd, 0) == -1)
err(1, "dup2");
(void)execl("/bin/sh", "sh", "-c", pager, NULL);
err(1, "exec sh -c %s", pager);
case -1:
err(1, "fork");
default:
(void)waitpid(pid, &status, 0);
break;
}
} }
usage() usage()