1: /* $Header: warp.h,v 7.0.1.3 95/21/1 17:08:42 lwall Exp $ */ 2: 3: /* $Log: warp.h,v $ 4: * Revision 7.0.1.3 95/21/1 18:40:00 sms 5: * Remove ifdefs around pwd.h 6: * 7: * Revision 7.0.1.2 86/12/12 17:08:42 lwall 8: * Baseline for net release. 9: * 10: * Revision 7.0.1.1 86/10/16 10:54:26 lwall 11: * Added Damage. Fixed random bugs. 12: * 13: * Revision 7.0 86/10/08 15:17:55 lwall 14: * Split into separate files. Added amoebas and pirates. 15: * 16: */ 17: 18: extern int errno; 19: 20: #include "config.h" /* generated by Configure script */ 21: 22: #include <stdio.h> 23: #include <signal.h> 24: #include <ctype.h> 25: #include <sys/types.h> 26: #include <sys/stat.h> 27: #include <errno.h> 28: 29: /* WARPLIB must be readable and writeable by warp, but not by anyone who you 30: * don't trust. In other words, to set up warp so everyone can play and 31: * no one can cheat, give warp a uid of its own and make warp setuid to 32: * that uid. WARPLIB must then NOT be made writeable by the world, 33: * since no attempt is made to encrypt saved games or anything. 34: * (It must be readable by the world, however, due to a strangeness in 35: * access.) 36: */ 37: 38: #define SAVEDIR "./" 39: #define NEWSFILE "warp.news" 40: #define HELPFILE "warp.doc" 41: #define LOCKFILE ".warp.lock" 42: #define LOGFILE "warp.log" 43: #define SCOREBOARD "warp.top" 44: #define LSCOREBOARD "warp.lowtop" 45: #define FSCOREBOARD "warp.funtop" 46: #define TMPSCOREBOARD "warp.topnew" 47: #define WARPMACRO "%X/Kbmap.%{TERM}" 48: 49: /* warp library */ 50: #ifndef WARPLIB /* ~ and %l only ("~%l" is permissable) */ 51: # ifdef PRIVLIB 52: # define WARPLIB PRIVLIB 53: # else 54: # define WARPLIB "/usr/games/warp" 55: # endif 56: #endif 57: 58: EXT char *warplib; 59: 60: #define PERMMAPS 8 /* how many starmaps are permanent */ 61: #define MAPS 20 /* how many starmaps to choose from */ 62: /* (MAPS - PERMMAPS is # of half-gone universes) */ 63: 64: /* 65: * Screen size info, minimum screen size is 23x40 (actually 24x80). 66: * YSIZE and XSIZE should be relatively prime so that a torpedo launched 67: * at an angle will eventually cover the whole screen. 68: * To calculate a new position for something: 69: * new_position = (current_position + delta + ?SIZE00) % ?SIZE 70: * This allows for negative deltas of up to ?SIZE00 (% doesn't work right 71: * on negative numbers). 72: * ?SIZE01, etc. are fudges for efficiency--they already include a delta. 73: */ 74: 75: #define XYSIZE 920 76: #define XYSIZEx4 3680 77: 78: #define YSIZE 23 79: #define YSIZE00 2300 80: #define YSIZE01 2301 81: #define YSIZE99 2299 82: 83: #define XSIZE 40 84: #define XSIZE00 4000 85: #define XSIZE01 4001 86: #define XSIZE99 3999 87: #define XSIZE02 4002 88: #define XSIZE98 3998 89: #define XSIZE03 4003 90: #define XSIZE97 3997 91: #define XSIZE08 4008 92: #define XSIZE92 3992 93: 94: EXT char amb[YSIZE][XSIZE]; 95: 96: #ifdef WHOAMI 97: # include <whoami.h> 98: #endif 99: 100: #ifndef isalnum 101: # define isalnum(c) (isalpha(c) || isdigit(c)) 102: #endif 103: 104: #ifdef IOCTL 105: #include <sys/ioctl.h> 106: #endif /* IOCTL */ 107: 108: #ifdef FCNTL 109: # include <fcntl.h> 110: #endif 111: 112: #ifdef TERMIO 113: # include <termio.h> 114: #else 115: # include <sgtty.h> 116: #endif 117: 118: #ifdef FTIMER 119: #include <sys/timeb.h> 120: #endif 121: 122: # include <pwd.h> 123: 124: #define BITSPERBYTE 8 125: #define LBUFLEN 512 /* line buffer length */ 126: 127: #ifdef pdp11 128: # define CBUFLEN 256 /* command buffer length */ 129: # define PUSHSIZE 128 130: #else 131: # define CBUFLEN 512 /* command buffer length */ 132: # define PUSHSIZE 256 133: #endif 134: #ifdef pdp11 135: # define MAXFILENAME 128 136: #else 137: # define MAXFILENAME 512 138: #endif 139: #define FINISHCMD 0177 140: 141: /* some handy defs */ 142: 143: #define bool char 144: #define TRUE (1) 145: #define FALSE (0) 146: #define Null(t) ((t)0) 147: #define Nullch Null(char *) 148: #define Nullfp Null(FILE *) 149: 150: #define Ctl(ch) (ch & 037) 151: 152: #define strNE(s1,s2) (strcmp(s1,s2)) 153: #define strEQ(s1,s2) (!strcmp(s1,s2)) 154: #define strnNE(s1,s2,l) (strncmp(s1,s2,l)) 155: #define strnEQ(s1,s2,l) (!strncmp(s1,s2,l)) 156: 157: #define sgn(x) ((x) < 0 ? -1 : (x) > 0) 158: 159: /* Things we can figure out ourselves */ 160: 161: #ifdef SIGPROF 162: # define BSD42 /* do we have Berkeley 4.2? */ 163: #endif 164: 165: #ifdef FIONREAD 166: # define PENDING 167: #else 168: # ifdef O_NDELAY 169: # define PENDING 170: # else 171: # ifdef RDCHK 172: # define PENDING 173: # endif 174: # endif 175: #endif 176: 177: #ifdef EUNICE 178: # define UNLINK(victim) while (!unlink(victim)) 179: #else 180: # define UNLINK(victim) unlink(victim) 181: #endif 182: 183: /* Valid substitutions for strings marked with % comment are: 184: * %H Host name (yours) 185: * %L Login name (yours) 186: * %N Full name (yours) 187: * %O Original working directory (where you ran warp from) 188: * %X Warp library directory 189: * %~ Home directory 190: * %. Directory containing . files 191: * %$ current process number 192: * %{name} Environment variable "name". %{name-default} form allowed. 193: * %"prompt" 194: * Print prompt and insert what is typed. 195: * %`command` 196: * Insert output of command. 197: * %(test_text=pattern?if_text:else_text) 198: * Substitute if_text if test_text matches pattern, otherwise 199: * substitute else_text. Use != for negated match. 200: * % substitutions are done on test_text, if_text, and else_text. 201: * (Note: %() only works if CONDSUB defined.) 202: */ 203: 204: /* *** System Dependent Stuff *** */ 205: 206: /* NOTE: many of these are defined in the config.h file */ 207: 208: #ifndef ROOTID 209: # define ROOTID 0 /* uid of superuser */ 210: #endif 211: 212: #ifdef NORMSIG 213: # define sigset Signal 214: # define sigignore(sig) Signal(sig,SIG_IGN) 215: #endif 216: 217: #ifndef LOGDIRFIELD 218: # define LOGDIRFIELD 6 /* Which field (origin 1) is the */ 219: /* login directory in /etc/passwd? */ 220: /* (If it is not kept in passwd, */ 221: /* but getpwnam() returns it, */ 222: /* define the symbol GETPWENT) */ 223: #endif 224: #ifndef GCOSFIELD 225: # define GCOSFIELD 5 226: #endif 227: 228: /* Undefine any of the following features to save both I and D space */ 229: /* In general, earlier ones are easier to get along without */ 230: /* Pdp11's without split I and D may have to undefine them all */ 231: #define DEBUGGING /* include debugging code */ 232: #define PUSHBACK /* macros and keymaps using pushback buffer */ 233: #define CONDSUB /* allow %(cond?text:text) */ 234: #define BACKTICK /* allow %`command` */ 235: #define PROMPTTTY /* allow %"prompt" */ 236: #define GETLOGIN /* use getlogin() routine as backup to environment */ 237: /* variables USER or LOGNAME */ 238: #define TILDENAME /* allow ~logname expansion */ 239: #define GETWD /* use our getwd() instead of piped in pwd */ 240: #define SETUIDGID /* substitute eaccess() for access() so that rn */ 241: /* can run setuid or setgid */ 242: /* if not setuid or setgid, you don't need it */ 243: #define VERBOSE /* compile in more informative messages */ 244: #define TERSE /* compile in shorter messages */ 245: 246: /* some dependencies among options */ 247: 248: #ifndef SETUIDGID 249: # define eaccess access 250: #endif 251: 252: #ifdef VERBOSE 253: # ifdef TERSE 254: # define IF(c) if (c) 255: # define ELSE else 256: # else /* !TERSE */ 257: # define IF(c) 258: # define ELSE 259: # endif 260: #else /* !VERBOSE */ 261: # ifndef TERSE 262: # define TERSE 263: # endif 264: # define IF(c) "IF" outside of VERBOSE??? 265: # define ELSE "ELSE" outside of VERBOSE??? 266: #endif 267: 268: #ifdef DEBUGGING 269: # define assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\r\n", __FILE__, __LINE__);sig_catcher(0);}} 270: #else 271: # define assert(ex) ; 272: #endif 273: 274: #define TCSIZE 512 /* capacity for termcap strings */ 275: 276: /* End of Space Conservation Section */ 277: 278: /* More System Dependencies */ 279: 280: /* preferred shell for use in doshell routine */ 281: /* ksh or sh would be okay here */ 282: #ifndef PREFSHELL 283: # define PREFSHELL "/bin/csh" 284: #endif 285: 286: /* path to fastest starting shell */ 287: #ifndef SH 288: # define SH "/bin/sh" 289: #endif 290: 291: /* location of macro file */ 292: #ifndef WARPMACRO 293: # ifdef PUSHBACK 294: # define WARPMACRO "%./.warpmac" 295: # endif 296: #endif 297: 298: /* location of full name */ 299: #ifndef FULLNAMEFILE 300: # ifndef PASSNAMES 301: # define FULLNAMEFILE "%./.fullname" 302: # endif 303: #endif 304: 305: /* a motd-like file for warp */ 306: #ifndef WARPNEWSNAME /* % and ~ */ 307: # define WARPNEWSNAME "%X/warp.news" 308: #endif 309: 310: /* typedefs */ 311: 312: typedef unsigned int MEM_SIZE; /* for passing to malloc */ 313: 314: /* *** end of the machine dependent stuff *** */ 315: 316: /* GLOBAL THINGS */ 317: 318: /* file statistics area */ 319: 320: EXT struct stat filestat; 321: 322: /* various things of type char */ 323: 324: char *index(); 325: char *rindex(); 326: char *getenv(); 327: char *strcat(); 328: char *strcpy(); 329: #ifdef CHARSPRINTF 330: char *sprintf(); 331: #else 332: int sprintf(); 333: #endif 334: 335: EXT char buf[LBUFLEN+1]; /* general purpose line buffer */ 336: 337: EXT char *cwd INIT(Nullch); /* current working directory */ 338: 339: /* switches */ 340: 341: #ifdef DEBUGGING 342: EXT int debug INIT(0); /* -D */ 343: # define DEB_FILEXP 64 344: #endif 345: 346: #ifdef VERBOSE 347: # ifdef TERSE 348: EXT bool verbose INIT(TRUE); /* +t */ 349: # endif 350: #endif 351: 352: /* miscellania */ 353: 354: EXT FILE *tmpfp INIT(Nullfp); /* scratch fp */ 355: 356: #define NOMARKING 0 357: #define STANDOUT 1 358: #define UNDERLINE 2 359: 360: /* Factored strings */ 361: 362: EXT char nullstr[] INIT(""); 363: EXT char readerr[] INIT("warp read error"); 364: EXT char cantopen[] INIT("Can't open %s\r\n"); 365: 366: #ifdef VERBOSE 367: EXT char nocd[] INIT("Can't chdir to directory %s\r\n"); 368: #else 369: EXT char nocd[] INIT("Can't find %s\r\n"); 370: #endif 371: 372: extern int errno; 373: 374: EXT bool justonemoretime INIT(TRUE); 375: EXT bool keepgoing INIT(TRUE); 376: 377: EXT bool friendspec INIT(FALSE); 378: EXT bool piratespec INIT(FALSE); 379: EXT bool amoebaspec INIT(FALSE); 380: EXT bool starspec INIT(FALSE); 381: EXT bool klingspec INIT(FALSE); 382: EXT bool apolspec INIT(FALSE); 383: EXT bool crushspec INIT(FALSE); 384: EXT bool romspec INIT(FALSE); 385: EXT bool prespec INIT(FALSE); 386: EXT bool tholspec INIT(FALSE); 387: EXT bool gornspec INIT(FALSE); 388: EXT bool beginner INIT(FALSE); 389: EXT bool massacre INIT(FALSE); 390: EXT bool lowspeed INIT(FALSE); 391: EXT bool debugging INIT(FALSE); 392: EXT bool didkill INIT(FALSE); 393: EXT bool experimenting INIT(FALSE); 394: EXT bool scorespec INIT(FALSE); 395: EXT bool metakey INIT(FALSE); 396: 397: EXT bool bombed_out; 398: EXT bool panic INIT(FALSE); 399: EXT bool madgorns; 400: 401: EXT int madfriends; 402: 403: EXT int inumpirates; 404: EXT int numpirates; 405: EXT int inumfriends; 406: EXT int numfriends; 407: EXT int inumamoebas; 408: EXT int numamoebas; 409: EXT int inumstars; 410: EXT int numstars; 411: EXT int inumenemies; 412: EXT int numenemies; 413: EXT int inumroms; 414: EXT int inumthols; 415: EXT int inumapollos; 416: EXT int numapollos; 417: EXT int apolloflag; 418: EXT int inumcrushes; 419: EXT int numcrushes; 420: EXT int inumgorns; 421: EXT int numgorns; 422: EXT int deados; 423: EXT int deadmudds; 424: EXT int smarts; 425: EXT int ismarts INIT(0); 426: EXT int numos INIT(0); 427: EXT int numxes INIT(0); 428: EXT int ient; 429: EXT int numents; 430: EXT int ibase; 431: EXT int numbases; 432: EXT int inuminhab; 433: EXT int numinhab; 434: EXT int wave; 435: EXT int cumsmarts; 436: EXT int prescene INIT(-1); 437: EXT int scandist; 438: EXT int antibase; 439: EXT int sm35; 440: EXT int sm45; 441: EXT int sm50; 442: EXT int sm55; 443: EXT int sm80; 444: EXT int sm95; 445: EXT int entmax; 446: EXT int basemax; 447: EXT int enemshields; 448: EXT int super; 449: EXT int whenok; 450: EXT int yamblast; 451: EXT int xamblast; 452: EXT int ambsize; 453: 454: EXT char spbuf[512]; 455: 456: char *index(), *ttyname(), *malloc(), *ctime(), *strcpy(); 457: char *getenv(), cmstore(), *tgoto(); 458: long atol(); 459: 460: #define Fclose (void)fclose 461: #define Fflush (void)fflush 462: #define Fgets (void)fgets 463: #define Sprintf (void)sprintf 464: #define Signal (void)signal 465: #define Safecpy (void)safecpy 466: #define Cpytill (void)cpytill 467: #define Tract (void)tract 468: #define Make_object (void)make_object 469: #define Read_tty (void)read_tty