1*32222Sbostic /* main.c */ 2*32222Sbostic #include "header.h" 3*32222Sbostic #include <pwd.h> 4*32222Sbostic static char copyright[]="\nLarn is copyrighted 1986 by Noah Morgan.\n"; 5*32222Sbostic int srcount=0; /* line counter for showstr() */ 6*32222Sbostic int dropflag=0; /* if 1 then don't lookforobject() next round */ 7*32222Sbostic int rmst=80; /* random monster creation counter */ 8*32222Sbostic int userid; /* the players login user id number */ 9*32222Sbostic char nowelcome=0,nomove=0; /* if (nomove) then don't count next iteration as a move */ 10*32222Sbostic static char viewflag=0; 11*32222Sbostic /* if viewflag then we have done a 99 stay here and don't showcell in the main loop */ 12*32222Sbostic char restorflag=0; /* 1 means restore has been done */ 13*32222Sbostic static char cmdhelp[] = "\ 14*32222Sbostic Cmd line format: larn [-slicnh] [-o<optsifle>] [-##] [++]\n\ 15*32222Sbostic -s show the scoreboard\n\ 16*32222Sbostic -l show the logfile (wizard id only)\n\ 17*32222Sbostic -i show scoreboard with inventories of dead characters\n\ 18*32222Sbostic -c create new scoreboard (wizard id only)\n\ 19*32222Sbostic -n suppress welcome message on starting game\n\ 20*32222Sbostic -## specify level of difficulty (example: -5)\n\ 21*32222Sbostic -h print this help text\n\ 22*32222Sbostic ++ restore game from checkpoint file\n\ 23*32222Sbostic -o<optsfile> specify .larnopts filename to be used instead of \"~/.larnopts\"\n\ 24*32222Sbostic "; 25*32222Sbostic #ifdef VT100 26*32222Sbostic static char *termtypes[] = { "vt100", "vt101", "vt102", "vt103", "vt125", 27*32222Sbostic "vt131", "vt140", "vt180", "vt220", "vt240", "vt241", "vt320", "vt340", 28*32222Sbostic "vt341" }; 29*32222Sbostic #endif VT100 30*32222Sbostic /* 31*32222Sbostic ************ 32*32222Sbostic MAIN PROGRAM 33*32222Sbostic ************ 34*32222Sbostic */ 35*32222Sbostic main(argc,argv) 36*32222Sbostic int argc; 37*32222Sbostic char **argv; 38*32222Sbostic { 39*32222Sbostic register int i,j; 40*32222Sbostic int hard; 41*32222Sbostic char *ptr=0,*ttype; 42*32222Sbostic struct passwd *pwe,*getpwuid(); 43*32222Sbostic 44*32222Sbostic /* 45*32222Sbostic * first task is to identify the player 46*32222Sbostic */ 47*32222Sbostic #ifndef VT100 48*32222Sbostic init_term(); /* setup the terminal (find out what type) for termcap */ 49*32222Sbostic #endif VT100 50*32222Sbostic if (((ptr = getlogin()) == 0) || (*ptr==0)) /* try to get login name */ 51*32222Sbostic if (pwe=getpwuid(getuid())) /* can we get it from /etc/passwd? */ 52*32222Sbostic ptr = pwe->pw_name; 53*32222Sbostic else 54*32222Sbostic if ((ptr = getenv("USER")) == 0) 55*32222Sbostic if ((ptr = getenv("LOGNAME")) == 0) 56*32222Sbostic { 57*32222Sbostic noone: write(2, "Can't find your logname. Who Are You?\n",39); 58*32222Sbostic exit(); 59*32222Sbostic } 60*32222Sbostic if (ptr==0) goto noone; 61*32222Sbostic if (strlen(ptr)==0) goto noone; 62*32222Sbostic /* 63*32222Sbostic * second task is to prepare the pathnames the player will need 64*32222Sbostic */ 65*32222Sbostic strcpy(loginname,ptr); /* save loginname of the user for logging purposes */ 66*32222Sbostic strcpy(logname,ptr); /* this will be overwritten with the players name */ 67*32222Sbostic if ((ptr = getenv("HOME")) == 0) ptr = "."; 68*32222Sbostic #ifdef SAVEINHOME 69*32222Sbostic strcpy(savefilename, ptr); 70*32222Sbostic strcat(savefilename, "/Larn.sav"); /* save file name in home directory */ 71*32222Sbostic #else 72*32222Sbostic strcat(savefilename,logname); /* prepare savefile name */ 73*32222Sbostic strcat(savefilename,".sav"); /* prepare savefile name */ 74*32222Sbostic #endif 75*32222Sbostic sprintf(optsfile, "%s/.larnopts",ptr); /* the .larnopts filename */ 76*32222Sbostic strcat(scorefile, SCORENAME); /* the larn scoreboard filename */ 77*32222Sbostic strcat(logfile, LOGFNAME); /* larn activity logging filename */ 78*32222Sbostic strcat(helpfile, HELPNAME); /* the larn on-line help file */ 79*32222Sbostic strcat(larnlevels, LEVELSNAME); /* the pre-made cave level data file */ 80*32222Sbostic strcat(fortfile, FORTSNAME); /* the fortune data file name */ 81*32222Sbostic strcat(playerids, PLAYERIDS); /* the playerid data file name */ 82*32222Sbostic strcat(holifile, HOLIFILE); /* the holiday data file name */ 83*32222Sbostic 84*32222Sbostic /* 85*32222Sbostic * now malloc the memory for the dungeon 86*32222Sbostic */ 87*32222Sbostic cell = (struct cel *)malloc(sizeof(struct cel)*(MAXLEVEL+MAXVLEVEL)*MAXX*MAXY); 88*32222Sbostic if (cell == 0) died(-285); /* malloc failure */ 89*32222Sbostic lpbuf = malloc((5* BUFBIG)>>2); /* output buffer */ 90*32222Sbostic inbuffer = malloc((5*MAXIBUF)>>2); /* output buffer */ 91*32222Sbostic if ((lpbuf==0) || (inbuffer==0)) died(-285); /* malloc() failure */ 92*32222Sbostic 93*32222Sbostic lcreat((char*)0); newgame(); /* set the initial clock */ hard= -1; 94*32222Sbostic 95*32222Sbostic #ifdef VT100 96*32222Sbostic /* 97*32222Sbostic * check terminal type to avoid users who have not vt100 type terminals 98*32222Sbostic */ 99*32222Sbostic ttype = getenv("TERM"); 100*32222Sbostic for (j=1, i=0; i<sizeof(termtypes)/sizeof(char *); i++) 101*32222Sbostic if (strcmp(ttype,termtypes[i]) == 0) { j=0; break; } 102*32222Sbostic if (j) 103*32222Sbostic { 104*32222Sbostic lprcat("Sorry, Larn needs a VT100 family terminal for all it's features.\n"); lflush(); 105*32222Sbostic exit(); 106*32222Sbostic } 107*32222Sbostic #endif VT100 108*32222Sbostic 109*32222Sbostic /* 110*32222Sbostic * now make scoreboard if it is not there (don't clear) 111*32222Sbostic */ 112*32222Sbostic /* if (access(scorefile,0) == -1) */ /* not there */ 113*32222Sbostic /* makeboard(); */ 114*32222Sbostic 115*32222Sbostic /* 116*32222Sbostic * now process the command line arguments 117*32222Sbostic */ 118*32222Sbostic for (i=1; i<argc; i++) 119*32222Sbostic { 120*32222Sbostic if (argv[i][0] == '-') 121*32222Sbostic switch(argv[i][1]) 122*32222Sbostic { 123*32222Sbostic case 's': showscores(); exit(); /* show scoreboard */ 124*32222Sbostic 125*32222Sbostic case 'l': /* show log file */ 126*32222Sbostic diedlog(); exit(); 127*32222Sbostic 128*32222Sbostic case 'i': showallscores(); exit(); /* show all scoreboard */ 129*32222Sbostic 130*32222Sbostic case 'c': /* anyone with password can create scoreboard */ 131*32222Sbostic lprcat("Preparing to initialize the scoreboard.\n"); 132*32222Sbostic if (getpassword() != 0) /*make new scoreboard*/ 133*32222Sbostic { 134*32222Sbostic makeboard(); lprc('\n'); showscores(); 135*32222Sbostic } 136*32222Sbostic exit(); 137*32222Sbostic 138*32222Sbostic case 'n': /* no welcome msg */ nowelcome=1; argv[i][0]=0; break; 139*32222Sbostic 140*32222Sbostic case '0': case '1': case '2': case '3': case '4': case '5': 141*32222Sbostic case '6': case '7': case '8': case '9': /* for hardness */ 142*32222Sbostic sscanf(&argv[i][1],"%d",&hard); 143*32222Sbostic break; 144*32222Sbostic 145*32222Sbostic case 'h': /* print out command line arguments */ 146*32222Sbostic write(1,cmdhelp,sizeof(cmdhelp)); exit(); 147*32222Sbostic 148*32222Sbostic case 'o': /* specify a .larnopts filename */ 149*32222Sbostic strncpy(optsfile,argv[i]+2,127); break; 150*32222Sbostic 151*32222Sbostic default: printf("Unknown option <%s>\n",argv[i]); exit(); 152*32222Sbostic }; 153*32222Sbostic 154*32222Sbostic if (argv[i][0] == '+') 155*32222Sbostic { 156*32222Sbostic clear(); restorflag = 1; 157*32222Sbostic if (argv[i][1] == '+') 158*32222Sbostic { 159*32222Sbostic hitflag=1; restoregame(ckpfile); /* restore checkpointed game */ 160*32222Sbostic } 161*32222Sbostic i = argc; 162*32222Sbostic } 163*32222Sbostic } 164*32222Sbostic 165*32222Sbostic readopts(); /* read the options file if there is one */ 166*32222Sbostic 167*32222Sbostic #ifdef TIMECHECK 168*32222Sbostic /* 169*32222Sbostic * this section of code checks to see if larn is allowed during working hours 170*32222Sbostic */ 171*32222Sbostic if (dayplay==0) /* check for not-during-daytime-hours */ 172*32222Sbostic if (playable()) 173*32222Sbostic { 174*32222Sbostic write(2,"Sorry, Larn can not be played during working hours.\n",52); 175*32222Sbostic exit(); 176*32222Sbostic } 177*32222Sbostic #endif TIMECHECK 178*32222Sbostic 179*32222Sbostic #ifdef UIDSCORE 180*32222Sbostic userid = geteuid(); /* obtain the user's effective id number */ 181*32222Sbostic #else UIDSCORE 182*32222Sbostic userid = getplid(logname); /* obtain the players id number */ 183*32222Sbostic #endif UIDSCORE 184*32222Sbostic if (userid < 0) { write(2,"Can't obtain playerid\n",22); exit(); } 185*32222Sbostic 186*32222Sbostic #ifdef HIDEBYLINK 187*32222Sbostic /* 188*32222Sbostic * this section of code causes the program to look like something else to ps 189*32222Sbostic */ 190*32222Sbostic if (strcmp(psname,argv[0])) /* if a different process name only */ 191*32222Sbostic { 192*32222Sbostic if ((i=access(psname,1)) < 0) 193*32222Sbostic { /* link not there */ 194*32222Sbostic if (link(argv[0],psname)>=0) 195*32222Sbostic { 196*32222Sbostic argv[0] = psname; execv(psname,argv); 197*32222Sbostic } 198*32222Sbostic } 199*32222Sbostic else 200*32222Sbostic unlink(psname); 201*32222Sbostic } 202*32222Sbostic 203*32222Sbostic for (i=1; i<argc; i++) 204*32222Sbostic { 205*32222Sbostic szero(argv[i]); /* zero the argument to avoid ps snooping */ 206*32222Sbostic } 207*32222Sbostic #endif HIDEBYLINK 208*32222Sbostic 209*32222Sbostic if (access(savefilename,0)==0) /* restore game if need to */ 210*32222Sbostic { 211*32222Sbostic clear(); restorflag = 1; 212*32222Sbostic hitflag=1; restoregame(savefilename); /* restore last game */ 213*32222Sbostic } 214*32222Sbostic sigsetup(); /* trap all needed signals */ 215*32222Sbostic sethard(hard); /* set up the desired difficulty */ 216*32222Sbostic setupvt100(); /* setup the terminal special mode */ 217*32222Sbostic if (c[HP]==0) /* create new game */ 218*32222Sbostic { 219*32222Sbostic makeplayer(); /* make the character that will play */ 220*32222Sbostic newcavelevel(0);/* make the dungeon */ 221*32222Sbostic predostuff = 1; /* tell signals that we are in the welcome screen */ 222*32222Sbostic if (nowelcome==0) welcome(); /* welcome the player to the game */ 223*32222Sbostic } 224*32222Sbostic drawscreen(); /* show the initial dungeon */ 225*32222Sbostic predostuff = 2; /* tell the trap functions that they must do a showplayer() 226*32222Sbostic from here on */ 227*32222Sbostic /* nice(1); /* games should be run niced */ 228*32222Sbostic yrepcount = hit2flag = 0; 229*32222Sbostic while (1) 230*32222Sbostic { 231*32222Sbostic if (dropflag==0) lookforobject(); /* see if there is an object here */ 232*32222Sbostic else dropflag=0; /* don't show it just dropped an item */ 233*32222Sbostic if (hitflag==0) { if (c[HASTEMONST]) movemonst(); movemonst(); } /* move the monsters */ 234*32222Sbostic if (viewflag==0) showcell(playerx,playery); else viewflag=0; /* show stuff around player */ 235*32222Sbostic if (hit3flag) flushall(); 236*32222Sbostic hitflag=hit3flag=0; nomove=1; 237*32222Sbostic bot_linex(); /* update bottom line */ 238*32222Sbostic while (nomove) 239*32222Sbostic { 240*32222Sbostic if (hit3flag) flushall(); 241*32222Sbostic nomove=0; parse(); 242*32222Sbostic } /* get commands and make moves */ 243*32222Sbostic regen(); /* regenerate hp and spells */ 244*32222Sbostic if (c[TIMESTOP]==0) 245*32222Sbostic if (--rmst <= 0) 246*32222Sbostic { rmst = 120-(level<<2); fillmonst(makemonst(level)); } 247*32222Sbostic } 248*32222Sbostic } 249*32222Sbostic 250*32222Sbostic /* 251*32222Sbostic showstr() 252*32222Sbostic 253*32222Sbostic show character's inventory 254*32222Sbostic */ 255*32222Sbostic showstr() 256*32222Sbostic { 257*32222Sbostic register int i,number; 258*32222Sbostic for (number=3, i=0; i<26; i++) 259*32222Sbostic if (iven[i]) number++; /* count items in inventory */ 260*32222Sbostic t_setup(number); qshowstr(); t_endup(number); 261*32222Sbostic } 262*32222Sbostic 263*32222Sbostic qshowstr() 264*32222Sbostic { 265*32222Sbostic register int i,j,k,sigsav; 266*32222Sbostic srcount=0; sigsav=nosignal; nosignal=1; /* don't allow ^c etc */ 267*32222Sbostic if (c[GOLD]) { lprintf(".) %d gold pieces",(long)c[GOLD]); srcount++; } 268*32222Sbostic for (k=26; k>=0; k--) 269*32222Sbostic if (iven[k]) 270*32222Sbostic { for (i=22; i<84; i++) 271*32222Sbostic for (j=0; j<=k; j++) if (i==iven[j]) show3(j); k=0; } 272*32222Sbostic 273*32222Sbostic lprintf("\nElapsed time is %d. You have %d mobuls left",(long)((gtime+99)/100+1),(long)((TIMELIMIT-gtime)/100)); 274*32222Sbostic more(); nosignal=sigsav; 275*32222Sbostic } 276*32222Sbostic 277*32222Sbostic /* 278*32222Sbostic * subroutine to clear screen depending on # lines to display 279*32222Sbostic */ 280*32222Sbostic t_setup(count) 281*32222Sbostic register int count; 282*32222Sbostic { 283*32222Sbostic if (count<20) /* how do we clear the screen? */ 284*32222Sbostic { 285*32222Sbostic cl_up(79,count); cursor(1,1); 286*32222Sbostic } 287*32222Sbostic else 288*32222Sbostic { 289*32222Sbostic resetscroll(); clear(); 290*32222Sbostic } 291*32222Sbostic } 292*32222Sbostic 293*32222Sbostic /* 294*32222Sbostic * subroutine to restore normal display screen depending on t_setup() 295*32222Sbostic */ 296*32222Sbostic t_endup(count) 297*32222Sbostic register int count; 298*32222Sbostic { 299*32222Sbostic if (count<18) /* how did we clear the screen? */ 300*32222Sbostic draws(0,MAXX,0,(count>MAXY) ? MAXY : count); 301*32222Sbostic else 302*32222Sbostic { 303*32222Sbostic drawscreen(); setscroll(); 304*32222Sbostic } 305*32222Sbostic } 306*32222Sbostic 307*32222Sbostic /* 308*32222Sbostic function to show the things player is wearing only 309*32222Sbostic */ 310*32222Sbostic showwear() 311*32222Sbostic { 312*32222Sbostic register int i,j,sigsav,count; 313*32222Sbostic sigsav=nosignal; nosignal=1; /* don't allow ^c etc */ 314*32222Sbostic srcount=0; 315*32222Sbostic 316*32222Sbostic for (count=2,j=0; j<=26; j++) /* count number of items we will display */ 317*32222Sbostic if (i=iven[j]) 318*32222Sbostic switch(i) 319*32222Sbostic { 320*32222Sbostic case OLEATHER: case OPLATE: case OCHAIN: 321*32222Sbostic case ORING: case OSTUDLEATHER: case OSPLINT: 322*32222Sbostic case OPLATEARMOR: case OSSPLATE: case OSHIELD: 323*32222Sbostic count++; 324*32222Sbostic }; 325*32222Sbostic 326*32222Sbostic t_setup(count); 327*32222Sbostic 328*32222Sbostic for (i=22; i<84; i++) 329*32222Sbostic for (j=0; j<=26; j++) 330*32222Sbostic if (i==iven[j]) 331*32222Sbostic switch(i) 332*32222Sbostic { 333*32222Sbostic case OLEATHER: case OPLATE: case OCHAIN: 334*32222Sbostic case ORING: case OSTUDLEATHER: case OSPLINT: 335*32222Sbostic case OPLATEARMOR: case OSSPLATE: case OSHIELD: 336*32222Sbostic show3(j); 337*32222Sbostic }; 338*32222Sbostic more(); nosignal=sigsav; t_endup(count); 339*32222Sbostic } 340*32222Sbostic 341*32222Sbostic /* 342*32222Sbostic function to show the things player can wield only 343*32222Sbostic */ 344*32222Sbostic showwield() 345*32222Sbostic { 346*32222Sbostic register int i,j,sigsav,count; 347*32222Sbostic sigsav=nosignal; nosignal=1; /* don't allow ^c etc */ 348*32222Sbostic srcount=0; 349*32222Sbostic 350*32222Sbostic for (count=2,j=0; j<=26; j++) /* count how many items */ 351*32222Sbostic if (i=iven[j]) 352*32222Sbostic switch(i) 353*32222Sbostic { 354*32222Sbostic case ODIAMOND: case ORUBY: case OEMERALD: case OSAPPHIRE: 355*32222Sbostic case OBOOK: case OCHEST: case OLARNEYE: case ONOTHEFT: 356*32222Sbostic case OSPIRITSCARAB: case OCUBEofUNDEAD: 357*32222Sbostic case OPOTION: case OSCROLL: break; 358*32222Sbostic default: count++; 359*32222Sbostic }; 360*32222Sbostic 361*32222Sbostic t_setup(count); 362*32222Sbostic 363*32222Sbostic for (i=22; i<84; i++) 364*32222Sbostic for (j=0; j<=26; j++) 365*32222Sbostic if (i==iven[j]) 366*32222Sbostic switch(i) 367*32222Sbostic { 368*32222Sbostic case ODIAMOND: case ORUBY: case OEMERALD: case OSAPPHIRE: 369*32222Sbostic case OBOOK: case OCHEST: case OLARNEYE: case ONOTHEFT: 370*32222Sbostic case OSPIRITSCARAB: case OCUBEofUNDEAD: 371*32222Sbostic case OPOTION: case OSCROLL: break; 372*32222Sbostic default: show3(j); 373*32222Sbostic }; 374*32222Sbostic more(); nosignal=sigsav; t_endup(count); 375*32222Sbostic } 376*32222Sbostic 377*32222Sbostic /* 378*32222Sbostic * function to show the things player can read only 379*32222Sbostic */ 380*32222Sbostic showread() 381*32222Sbostic { 382*32222Sbostic register int i,j,sigsav,count; 383*32222Sbostic sigsav=nosignal; nosignal=1; /* don't allow ^c etc */ 384*32222Sbostic srcount=0; 385*32222Sbostic 386*32222Sbostic for (count=2,j=0; j<=26; j++) 387*32222Sbostic switch(iven[j]) 388*32222Sbostic { 389*32222Sbostic case OBOOK: case OSCROLL: count++; 390*32222Sbostic }; 391*32222Sbostic t_setup(count); 392*32222Sbostic 393*32222Sbostic for (i=22; i<84; i++) 394*32222Sbostic for (j=0; j<=26; j++) 395*32222Sbostic if (i==iven[j]) 396*32222Sbostic switch(i) 397*32222Sbostic { 398*32222Sbostic case OBOOK: case OSCROLL: show3(j); 399*32222Sbostic }; 400*32222Sbostic more(); nosignal=sigsav; t_endup(count); 401*32222Sbostic } 402*32222Sbostic 403*32222Sbostic /* 404*32222Sbostic * function to show the things player can eat only 405*32222Sbostic */ 406*32222Sbostic showeat() 407*32222Sbostic { 408*32222Sbostic register int i,j,sigsav,count; 409*32222Sbostic sigsav=nosignal; nosignal=1; /* don't allow ^c etc */ 410*32222Sbostic srcount=0; 411*32222Sbostic 412*32222Sbostic for (count=2,j=0; j<=26; j++) 413*32222Sbostic switch(iven[j]) 414*32222Sbostic { 415*32222Sbostic case OCOOKIE: count++; 416*32222Sbostic }; 417*32222Sbostic t_setup(count); 418*32222Sbostic 419*32222Sbostic for (i=22; i<84; i++) 420*32222Sbostic for (j=0; j<=26; j++) 421*32222Sbostic if (i==iven[j]) 422*32222Sbostic switch(i) 423*32222Sbostic { 424*32222Sbostic case OCOOKIE: show3(j); 425*32222Sbostic }; 426*32222Sbostic more(); nosignal=sigsav; t_endup(count); 427*32222Sbostic } 428*32222Sbostic 429*32222Sbostic /* 430*32222Sbostic function to show the things player can quaff only 431*32222Sbostic */ 432*32222Sbostic showquaff() 433*32222Sbostic { 434*32222Sbostic register int i,j,sigsav,count; 435*32222Sbostic sigsav=nosignal; nosignal=1; /* don't allow ^c etc */ 436*32222Sbostic srcount=0; 437*32222Sbostic 438*32222Sbostic for (count=2,j=0; j<=26; j++) 439*32222Sbostic switch(iven[j]) 440*32222Sbostic { 441*32222Sbostic case OPOTION: count++; 442*32222Sbostic }; 443*32222Sbostic t_setup(count); 444*32222Sbostic 445*32222Sbostic for (i=22; i<84; i++) 446*32222Sbostic for (j=0; j<=26; j++) 447*32222Sbostic if (i==iven[j]) 448*32222Sbostic switch(i) 449*32222Sbostic { 450*32222Sbostic case OPOTION: show3(j); 451*32222Sbostic }; 452*32222Sbostic more(); nosignal=sigsav; t_endup(count); 453*32222Sbostic } 454*32222Sbostic 455*32222Sbostic show1(idx,str2) 456*32222Sbostic register int idx; 457*32222Sbostic register char *str2[]; 458*32222Sbostic { 459*32222Sbostic if (str2==0) lprintf("\n%c) %s",idx+'a',objectname[iven[idx]]); 460*32222Sbostic else if (*str2[ivenarg[idx]]==0) lprintf("\n%c) %s",idx+'a',objectname[iven[idx]]); 461*32222Sbostic else lprintf("\n%c) %s of%s",idx+'a',objectname[iven[idx]],str2[ivenarg[idx]]); 462*32222Sbostic } 463*32222Sbostic 464*32222Sbostic show3(index) 465*32222Sbostic register int index; 466*32222Sbostic { 467*32222Sbostic switch(iven[index]) 468*32222Sbostic { 469*32222Sbostic case OPOTION: show1(index,potionname); break; 470*32222Sbostic case OSCROLL: show1(index,scrollname); break; 471*32222Sbostic 472*32222Sbostic case OLARNEYE: case OBOOK: case OSPIRITSCARAB: 473*32222Sbostic case ODIAMOND: case ORUBY: case OCUBEofUNDEAD: 474*32222Sbostic case OEMERALD: case OCHEST: case OCOOKIE: 475*32222Sbostic case OSAPPHIRE: case ONOTHEFT: show1(index,(char **)0); break; 476*32222Sbostic 477*32222Sbostic default: lprintf("\n%c) %s",index+'a',objectname[iven[index]]); 478*32222Sbostic if (ivenarg[index]>0) lprintf(" + %d",(long)ivenarg[index]); 479*32222Sbostic else if (ivenarg[index]<0) lprintf(" %d",(long)ivenarg[index]); 480*32222Sbostic break; 481*32222Sbostic } 482*32222Sbostic if (c[WIELD]==index) lprcat(" (weapon in hand)"); 483*32222Sbostic if ((c[WEAR]==index) || (c[SHIELD]==index)) lprcat(" (being worn)"); 484*32222Sbostic if (++srcount>=22) { srcount=0; more(); clear(); } 485*32222Sbostic } 486*32222Sbostic 487*32222Sbostic /* 488*32222Sbostic subroutine to randomly create monsters if needed 489*32222Sbostic */ 490*32222Sbostic randmonst() 491*32222Sbostic { 492*32222Sbostic if (c[TIMESTOP]) return; /* don't make monsters if time is stopped */ 493*32222Sbostic if (--rmst <= 0) 494*32222Sbostic { 495*32222Sbostic rmst = 120 - (level<<2); fillmonst(makemonst(level)); 496*32222Sbostic } 497*32222Sbostic } 498*32222Sbostic 499*32222Sbostic 500*32222Sbostic /* 501*32222Sbostic parse() 502*32222Sbostic 503*32222Sbostic get and execute a command 504*32222Sbostic */ 505*32222Sbostic parse() 506*32222Sbostic { 507*32222Sbostic register int i,j,k,flag; 508*32222Sbostic while (1) 509*32222Sbostic { 510*32222Sbostic k = yylex(); 511*32222Sbostic switch(k) /* get the token from the input and switch on it */ 512*32222Sbostic { 513*32222Sbostic case 'h': moveplayer(4); return; /* west */ 514*32222Sbostic case 'H': run(4); return; /* west */ 515*32222Sbostic case 'l': moveplayer(2); return; /* east */ 516*32222Sbostic case 'L': run(2); return; /* east */ 517*32222Sbostic case 'j': moveplayer(1); return; /* south */ 518*32222Sbostic case 'J': run(1); return; /* south */ 519*32222Sbostic case 'k': moveplayer(3); return; /* north */ 520*32222Sbostic case 'K': run(3); return; /* north */ 521*32222Sbostic case 'u': moveplayer(5); return; /* northeast */ 522*32222Sbostic case 'U': run(5); return; /* northeast */ 523*32222Sbostic case 'y': moveplayer(6); return; /* northwest */ 524*32222Sbostic case 'Y': run(6); return; /* northwest */ 525*32222Sbostic case 'n': moveplayer(7); return; /* southeast */ 526*32222Sbostic case 'N': run(7); return; /* southeast */ 527*32222Sbostic case 'b': moveplayer(8); return; /* southwest */ 528*32222Sbostic case 'B': run(8); return; /* southwest */ 529*32222Sbostic 530*32222Sbostic case '.': if (yrepcount) viewflag=1; return; /* stay here */ 531*32222Sbostic 532*32222Sbostic case 'w': yrepcount=0; wield(); return; /* wield a weapon */ 533*32222Sbostic 534*32222Sbostic case 'W': yrepcount=0; wear(); return; /* wear armor */ 535*32222Sbostic 536*32222Sbostic case 'r': yrepcount=0; 537*32222Sbostic if (c[BLINDCOUNT]) { cursors(); lprcat("\nYou can't read anything when you're blind!"); } else 538*32222Sbostic if (c[TIMESTOP]==0) readscr(); return; /* to read a scroll */ 539*32222Sbostic 540*32222Sbostic case 'q': yrepcount=0; if (c[TIMESTOP]==0) quaff(); return; /* quaff a potion */ 541*32222Sbostic 542*32222Sbostic case 'd': yrepcount=0; if (c[TIMESTOP]==0) dropobj(); return; /* to drop an object */ 543*32222Sbostic 544*32222Sbostic case 'c': yrepcount=0; cast(); return; /* cast a spell */ 545*32222Sbostic 546*32222Sbostic case 'i': yrepcount=0; nomove=1; showstr(); return; /* status */ 547*32222Sbostic 548*32222Sbostic case 'e': yrepcount=0; 549*32222Sbostic if (c[TIMESTOP]==0) eatcookie(); return; /* to eat a fortune cookie */ 550*32222Sbostic 551*32222Sbostic case 'D': yrepcount=0; seemagic(0); nomove=1; return; /* list spells and scrolls */ 552*32222Sbostic 553*32222Sbostic case '?': yrepcount=0; help(); nomove=1; return; /* give the help screen*/ 554*32222Sbostic 555*32222Sbostic case 'S': clear(); lprcat("Saving . . ."); lflush(); 556*32222Sbostic savegame(savefilename); wizard=1; died(-257); /* save the game - doesn't return */ 557*32222Sbostic 558*32222Sbostic case 'Z': yrepcount=0; if (c[LEVEL]>9) { oteleport(1); return; } 559*32222Sbostic cursors(); lprcat("\nAs yet, you don't have enough experience to use teleportation"); 560*32222Sbostic return; /* teleport yourself */ 561*32222Sbostic 562*32222Sbostic case '^': /* identify traps */ flag=yrepcount=0; cursors(); 563*32222Sbostic lprc('\n'); for (j=playery-1; j<playery+2; j++) 564*32222Sbostic { 565*32222Sbostic if (j < 0) j=0; if (j >= MAXY) break; 566*32222Sbostic for (i=playerx-1; i<playerx+2; i++) 567*32222Sbostic { 568*32222Sbostic if (i < 0) i=0; if (i >= MAXX) break; 569*32222Sbostic switch(item[i][j]) 570*32222Sbostic { 571*32222Sbostic case OTRAPDOOR: case ODARTRAP: 572*32222Sbostic case OTRAPARROW: case OTELEPORTER: 573*32222Sbostic lprcat("\nIts "); lprcat(objectname[item[i][j]]); flag++; 574*32222Sbostic }; 575*32222Sbostic } 576*32222Sbostic } 577*32222Sbostic if (flag==0) lprcat("\nNo traps are visible"); 578*32222Sbostic return; 579*32222Sbostic 580*32222Sbostic #if WIZID 581*32222Sbostic case '_': /* this is the fudge player password for wizard mode*/ 582*32222Sbostic yrepcount=0; cursors(); nomove=1; 583*32222Sbostic if (userid!=wisid) 584*32222Sbostic { 585*32222Sbostic lprcat("Sorry, you are not empowered to be a wizard.\n"); 586*32222Sbostic scbr(); /* system("stty -echo cbreak"); */ 587*32222Sbostic lflush(); return; 588*32222Sbostic } 589*32222Sbostic if (getpassword()==0) 590*32222Sbostic { 591*32222Sbostic scbr(); /* system("stty -echo cbreak"); */ return; 592*32222Sbostic } 593*32222Sbostic wizard=1; scbr(); /* system("stty -echo cbreak"); */ 594*32222Sbostic for (i=0; i<6; i++) c[i]=70; iven[0]=iven[1]=0; 595*32222Sbostic take(OPROTRING,50); take(OLANCE,25); c[WIELD]=1; 596*32222Sbostic c[LANCEDEATH]=1; c[WEAR] = c[SHIELD] = -1; 597*32222Sbostic raiseexperience(6000000L); c[AWARENESS] += 25000; 598*32222Sbostic { 599*32222Sbostic register int i,j; 600*32222Sbostic for (i=0; i<MAXY; i++) 601*32222Sbostic for (j=0; j<MAXX; j++) know[j][i]=1; 602*32222Sbostic for (i=0; i<SPNUM; i++) spelknow[i]=1; 603*32222Sbostic for (i=0; i<MAXSCROLL; i++) scrollname[i][0]=' '; 604*32222Sbostic for (i=0; i<MAXPOTION; i++) potionname[i][0]=' '; 605*32222Sbostic } 606*32222Sbostic for (i=0; i<MAXSCROLL; i++) 607*32222Sbostic if (strlen(scrollname[i])>2) /* no null items */ 608*32222Sbostic { item[i][0]=OSCROLL; iarg[i][0]=i; } 609*32222Sbostic for (i=MAXX-1; i>MAXX-1-MAXPOTION; i--) 610*32222Sbostic if (strlen(potionname[i-MAXX+MAXPOTION])>2) /* no null items */ 611*32222Sbostic { item[i][0]=OPOTION; iarg[i][0]=i-MAXX+MAXPOTION; } 612*32222Sbostic for (i=1; i<MAXY; i++) 613*32222Sbostic { item[0][i]=i; iarg[0][i]=0; } 614*32222Sbostic for (i=MAXY; i<MAXY+MAXX; i++) 615*32222Sbostic { item[i-MAXY][MAXY-1]=i; iarg[i-MAXY][MAXY-1]=0; } 616*32222Sbostic for (i=MAXX+MAXY; i<MAXX+MAXY+MAXY; i++) 617*32222Sbostic { item[MAXX-1][i-MAXX-MAXY]=i; iarg[MAXX-1][i-MAXX-MAXY]=0; } 618*32222Sbostic c[GOLD]+=25000; drawscreen(); return; 619*32222Sbostic #endif 620*32222Sbostic 621*32222Sbostic case 'T': yrepcount=0; cursors(); if (c[SHIELD] != -1) { c[SHIELD] = -1; lprcat("\nYour shield is off"); bottomline(); } else 622*32222Sbostic if (c[WEAR] != -1) { c[WEAR] = -1; lprcat("\nYour armor is off"); bottomline(); } 623*32222Sbostic else lprcat("\nYou aren't wearing anything"); 624*32222Sbostic return; 625*32222Sbostic 626*32222Sbostic case 'g': cursors(); 627*32222Sbostic lprintf("\nThe stuff you are carrying presently weighs %d pounds",(long)packweight()); 628*32222Sbostic case ' ': yrepcount=0; nomove=1; return; 629*32222Sbostic 630*32222Sbostic case 'v': yrepcount=0; cursors(); 631*32222Sbostic lprintf("\nCaverns of Larn, Version %d.%d, Diff=%d",(long)VERSION,(long)SUBVERSION,(long)c[HARDGAME]); 632*32222Sbostic if (wizard) lprcat(" Wizard"); nomove=1; 633*32222Sbostic if (cheat) lprcat(" Cheater"); 634*32222Sbostic lprcat(copyright); 635*32222Sbostic return; 636*32222Sbostic 637*32222Sbostic case 'Q': yrepcount=0; quit(); nomove=1; return; /* quit */ 638*32222Sbostic 639*32222Sbostic case 'L'-64: yrepcount=0; drawscreen(); nomove=1; return; /* look */ 640*32222Sbostic 641*32222Sbostic #if WIZID 642*32222Sbostic #ifdef EXTRA 643*32222Sbostic case 'A': yrepcount=0; nomove=1; if (wizard) { diag(); return; } /* create diagnostic file */ 644*32222Sbostic return; 645*32222Sbostic #endif 646*32222Sbostic #endif 647*32222Sbostic case 'P': cursors(); 648*32222Sbostic if (outstanding_taxes>0) 649*32222Sbostic lprintf("\nYou presently owe %d gp in taxes.",(long)outstanding_taxes); 650*32222Sbostic else 651*32222Sbostic lprcat("\nYou do not owe any taxes."); 652*32222Sbostic return; 653*32222Sbostic }; 654*32222Sbostic } 655*32222Sbostic } 656*32222Sbostic 657*32222Sbostic parse2() 658*32222Sbostic { 659*32222Sbostic if (c[HASTEMONST]) movemonst(); movemonst(); /* move the monsters */ 660*32222Sbostic randmonst(); regen(); 661*32222Sbostic } 662*32222Sbostic 663*32222Sbostic run(dir) 664*32222Sbostic int dir; 665*32222Sbostic { 666*32222Sbostic register int i; 667*32222Sbostic i=1; while (i) 668*32222Sbostic { 669*32222Sbostic i=moveplayer(dir); 670*32222Sbostic if (i>0) { if (c[HASTEMONST]) movemonst(); movemonst(); randmonst(); regen(); } 671*32222Sbostic if (hitflag) i=0; 672*32222Sbostic if (i!=0) showcell(playerx,playery); 673*32222Sbostic } 674*32222Sbostic } 675*32222Sbostic 676*32222Sbostic /* 677*32222Sbostic function to wield a weapon 678*32222Sbostic */ 679*32222Sbostic wield() 680*32222Sbostic { 681*32222Sbostic register int i; 682*32222Sbostic while (1) 683*32222Sbostic { 684*32222Sbostic if ((i = whatitem("wield"))=='\33') return; 685*32222Sbostic if (i != '.') 686*32222Sbostic { 687*32222Sbostic if (i=='*') showwield(); 688*32222Sbostic else if (iven[i-'a']==0) { ydhi(i); return; } 689*32222Sbostic else if (iven[i-'a']==OPOTION) { ycwi(i); return; } 690*32222Sbostic else if (iven[i-'a']==OSCROLL) { ycwi(i); return; } 691*32222Sbostic else if ((c[SHIELD]!= -1) && (iven[i-'a']==O2SWORD)) { lprcat("\nBut one arm is busy with your shield!"); return; } 692*32222Sbostic else { c[WIELD]=i-'a'; if (iven[i-'a'] == OLANCE) c[LANCEDEATH]=1; else c[LANCEDEATH]=0; bottomline(); return; } 693*32222Sbostic } 694*32222Sbostic } 695*32222Sbostic } 696*32222Sbostic 697*32222Sbostic /* 698*32222Sbostic common routine to say you don't have an item 699*32222Sbostic */ 700*32222Sbostic ydhi(x) 701*32222Sbostic int x; 702*32222Sbostic { cursors(); lprintf("\nYou don't have item %c!",x); } 703*32222Sbostic ycwi(x) 704*32222Sbostic int x; 705*32222Sbostic { cursors(); lprintf("\nYou can't wield item %c!",x); } 706*32222Sbostic 707*32222Sbostic /* 708*32222Sbostic function to wear armor 709*32222Sbostic */ 710*32222Sbostic wear() 711*32222Sbostic { 712*32222Sbostic register int i; 713*32222Sbostic while (1) 714*32222Sbostic { 715*32222Sbostic if ((i = whatitem("wear"))=='\33') return; 716*32222Sbostic if (i != '.') 717*32222Sbostic { 718*32222Sbostic if (i=='*') showwear(); else 719*32222Sbostic switch(iven[i-'a']) 720*32222Sbostic { 721*32222Sbostic case 0: ydhi(i); return; 722*32222Sbostic case OLEATHER: case OCHAIN: case OPLATE: case OSTUDLEATHER: 723*32222Sbostic case ORING: case OSPLINT: case OPLATEARMOR: case OSSPLATE: 724*32222Sbostic if (c[WEAR] != -1) { lprcat("\nYou're already wearing some armor"); return; } 725*32222Sbostic c[WEAR]=i-'a'; bottomline(); return; 726*32222Sbostic case OSHIELD: if (c[SHIELD] != -1) { lprcat("\nYou are already wearing a shield"); return; } 727*32222Sbostic if (iven[c[WIELD]]==O2SWORD) { lprcat("\nYour hands are busy with the two handed sword!"); return; } 728*32222Sbostic c[SHIELD] = i-'a'; bottomline(); return; 729*32222Sbostic default: lprcat("\nYou can't wear that!"); 730*32222Sbostic }; 731*32222Sbostic } 732*32222Sbostic } 733*32222Sbostic } 734*32222Sbostic 735*32222Sbostic /* 736*32222Sbostic function to drop an object 737*32222Sbostic */ 738*32222Sbostic dropobj() 739*32222Sbostic { 740*32222Sbostic register int i; 741*32222Sbostic register char *p; 742*32222Sbostic long amt; 743*32222Sbostic p = &item[playerx][playery]; 744*32222Sbostic while (1) 745*32222Sbostic { 746*32222Sbostic if ((i = whatitem("drop"))=='\33') return; 747*32222Sbostic if (i=='*') showstr(); else 748*32222Sbostic { 749*32222Sbostic if (i=='.') /* drop some gold */ 750*32222Sbostic { 751*32222Sbostic if (*p) { lprcat("\nThere's something here already!"); return; } 752*32222Sbostic lprcat("\n\n"); 753*32222Sbostic cl_dn(1,23); 754*32222Sbostic lprcat("How much gold do you drop? "); 755*32222Sbostic if ((amt=readnum((long)c[GOLD])) == 0) return; 756*32222Sbostic if (amt>c[GOLD]) 757*32222Sbostic { lprcat("\nYou don't have that much!"); return; } 758*32222Sbostic if (amt<=32767) 759*32222Sbostic { *p=OGOLDPILE; i=amt; } 760*32222Sbostic else if (amt<=327670L) 761*32222Sbostic { *p=ODGOLD; i=amt/10; amt = 10*i; } 762*32222Sbostic else if (amt<=3276700L) 763*32222Sbostic { *p=OMAXGOLD; i=amt/100; amt = 100*i; } 764*32222Sbostic else if (amt<=32767000L) 765*32222Sbostic { *p=OKGOLD; i=amt/1000; amt = 1000*i; } 766*32222Sbostic else 767*32222Sbostic { *p=OKGOLD; i=32767; amt = 32767000L; } 768*32222Sbostic c[GOLD] -= amt; 769*32222Sbostic lprintf("You drop %d gold pieces",(long)amt); 770*32222Sbostic iarg[playerx][playery]=i; bottomgold(); 771*32222Sbostic know[playerx][playery]=0; dropflag=1; return; 772*32222Sbostic } 773*32222Sbostic drop_object(i-'a'); 774*32222Sbostic return; 775*32222Sbostic } 776*32222Sbostic } 777*32222Sbostic } 778*32222Sbostic 779*32222Sbostic /* 780*32222Sbostic * readscr() Subroutine to read a scroll one is carrying 781*32222Sbostic */ 782*32222Sbostic readscr() 783*32222Sbostic { 784*32222Sbostic register int i; 785*32222Sbostic while (1) 786*32222Sbostic { 787*32222Sbostic if ((i = whatitem("read"))=='\33') return; 788*32222Sbostic if (i != '.') 789*32222Sbostic { 790*32222Sbostic if (i=='*') showread(); else 791*32222Sbostic { 792*32222Sbostic if (iven[i-'a']==OSCROLL) { read_scroll(ivenarg[i-'a']); iven[i-'a']=0; return; } 793*32222Sbostic if (iven[i-'a']==OBOOK) { readbook(ivenarg[i-'a']); iven[i-'a']=0; return; } 794*32222Sbostic if (iven[i-'a']==0) { ydhi(i); return; } 795*32222Sbostic lprcat("\nThere's nothing on it to read"); return; 796*32222Sbostic } 797*32222Sbostic } 798*32222Sbostic } 799*32222Sbostic } 800*32222Sbostic 801*32222Sbostic /* 802*32222Sbostic * subroutine to eat a cookie one is carrying 803*32222Sbostic */ 804*32222Sbostic eatcookie() 805*32222Sbostic { 806*32222Sbostic register int i; 807*32222Sbostic char *p; 808*32222Sbostic while (1) 809*32222Sbostic { 810*32222Sbostic if ((i = whatitem("eat"))=='\33') return; 811*32222Sbostic if (i != '.') 812*32222Sbostic if (i=='*') showeat(); else 813*32222Sbostic { 814*32222Sbostic if (iven[i-'a']==OCOOKIE) 815*32222Sbostic { 816*32222Sbostic lprcat("\nThe cookie was delicious."); 817*32222Sbostic iven[i-'a']=0; 818*32222Sbostic if (!c[BLINDCOUNT]) 819*32222Sbostic { 820*32222Sbostic if (p=fortune(fortfile)) 821*32222Sbostic { 822*32222Sbostic lprcat(" Inside you find a scrap of paper that says:\n"); 823*32222Sbostic lprcat(p); 824*32222Sbostic } 825*32222Sbostic } 826*32222Sbostic return; 827*32222Sbostic } 828*32222Sbostic if (iven[i-'a']==0) { ydhi(i); return; } 829*32222Sbostic lprcat("\nYou can't eat that!"); return; 830*32222Sbostic } 831*32222Sbostic } 832*32222Sbostic } 833*32222Sbostic 834*32222Sbostic /* 835*32222Sbostic * subroutine to quaff a potion one is carrying 836*32222Sbostic */ 837*32222Sbostic quaff() 838*32222Sbostic { 839*32222Sbostic register int i; 840*32222Sbostic while (1) 841*32222Sbostic { 842*32222Sbostic if ((i = whatitem("quaff"))=='\33') return; 843*32222Sbostic if (i != '.') 844*32222Sbostic { 845*32222Sbostic if (i=='*') showquaff(); else 846*32222Sbostic { 847*32222Sbostic if (iven[i-'a']==OPOTION) { quaffpotion(ivenarg[i-'a']); iven[i-'a']=0; return; } 848*32222Sbostic if (iven[i-'a']==0) { ydhi(i); return; } 849*32222Sbostic lprcat("\nYou wouldn't want to quaff that, would you? "); return; 850*32222Sbostic } 851*32222Sbostic } 852*32222Sbostic } 853*32222Sbostic } 854*32222Sbostic 855*32222Sbostic /* 856*32222Sbostic function to ask what player wants to do 857*32222Sbostic */ 858*32222Sbostic whatitem(str) 859*32222Sbostic char *str; 860*32222Sbostic { 861*32222Sbostic int i; 862*32222Sbostic cursors(); lprintf("\nWhat do you want to %s [* for all] ? ",str); 863*32222Sbostic i=0; while (i>'z' || (i<'a' && i!='*' && i!='\33' && i!='.')) i=getchar(); 864*32222Sbostic if (i=='\33') lprcat(" aborted"); 865*32222Sbostic return(i); 866*32222Sbostic } 867*32222Sbostic 868*32222Sbostic /* 869*32222Sbostic subroutine to get a number from the player 870*32222Sbostic and allow * to mean return amt, else return the number entered 871*32222Sbostic */ 872*32222Sbostic unsigned long readnum(mx) 873*32222Sbostic long mx; 874*32222Sbostic { 875*32222Sbostic register int i; 876*32222Sbostic register unsigned long amt=0; 877*32222Sbostic sncbr(); 878*32222Sbostic if ((i=getchar()) == '*') amt = mx; /* allow him to say * for all gold */ 879*32222Sbostic else 880*32222Sbostic while (i != '\n') 881*32222Sbostic { 882*32222Sbostic if (i=='\033') { scbr(); lprcat(" aborted"); return(0); } 883*32222Sbostic if ((i <= '9') && (i >= '0') && (amt<99999999)) 884*32222Sbostic amt = amt*10+i-'0'; 885*32222Sbostic i = getchar(); 886*32222Sbostic } 887*32222Sbostic scbr(); return(amt); 888*32222Sbostic } 889*32222Sbostic 890*32222Sbostic #ifdef HIDEBYLINK 891*32222Sbostic /* 892*32222Sbostic * routine to zero every byte in a string 893*32222Sbostic */ 894*32222Sbostic szero(str) 895*32222Sbostic register char *str; 896*32222Sbostic { 897*32222Sbostic while (*str) 898*32222Sbostic *str++ = 0; 899*32222Sbostic } 900*32222Sbostic #endif HIDEBYLINK 901*32222Sbostic 902*32222Sbostic #ifdef TIMECHECK 903*32222Sbostic /* 904*32222Sbostic * routine to check the time of day and return 1 if its during work hours 905*32222Sbostic * checks the file ".holidays" for forms like "mmm dd comment..." 906*32222Sbostic */ 907*32222Sbostic int playable() 908*32222Sbostic { 909*32222Sbostic long g_time,time(); 910*32222Sbostic int hour,day,year; 911*32222Sbostic char *date,*month,*p; 912*32222Sbostic 913*32222Sbostic time(&g_time); /* get the time and date */ 914*32222Sbostic date = ctime(&g_time); /* format: Fri Jul 4 00:27:56 EDT 1986 */ 915*32222Sbostic year = atoi(date+20); 916*32222Sbostic hour = (date[11]-'0')*10 + date[12]-'0'; 917*32222Sbostic day = (date[8]!=' ') ? ((date[8]-'0')*10 + date[9]-'0') : (date[9]-'0'); 918*32222Sbostic month = date+4; date[7]=0; /* point to and NULL terminate month */ 919*32222Sbostic 920*32222Sbostic if (((hour>=8 && hour<17)) /* 8AM - 5PM */ 921*32222Sbostic && strncmp("Sat",date,3)!=0 /* not a Saturday */ 922*32222Sbostic && strncmp("Sun",date,3)!=0) /* not a Sunday */ 923*32222Sbostic { 924*32222Sbostic /* now check for a .holidays datafile */ 925*32222Sbostic lflush(); 926*32222Sbostic if (lopen(holifile) >= 0) 927*32222Sbostic for ( ; ; ) 928*32222Sbostic { 929*32222Sbostic if ((p=lgetw())==0) break; 930*32222Sbostic if (strlen(p)<6) continue; 931*32222Sbostic if ((strncmp(p,month,3)==0) && (day==atoi(p+4)) && (year==atoi(p+7))) 932*32222Sbostic return(0); /* a holiday */ 933*32222Sbostic } 934*32222Sbostic lrclose(); lcreat((char*)0); 935*32222Sbostic return(1); 936*32222Sbostic } 937*32222Sbostic return(0); 938*32222Sbostic } 939*32222Sbostic #endif TIMECHECK 940