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

Defined variables

ambsize defined in line 452; used 11 times
antibase defined in line 438; used 3 times
apolloflag defined in line 417; used 13 times
basemax defined in line 446; used 4 times
buf defined in line 335; used 44 times
cantopen defined in line 364; used 2 times
cumsmarts defined in line 435; used 10 times
cwd defined in line 337; used 1 times
deados defined in line 422; used 18 times
enemshields defined in line 447; used 3 times
entmax defined in line 445; used 8 times
filestat defined in line 320; used 7 times
ibase defined in line 430; used 3 times
ient defined in line 428; used 3 times
inumamoebas defined in line 407; used 4 times
inumcrushes defined in line 418; used 5 times
inumgorns defined in line 420; used 4 times
inuminhab defined in line 432; used 7 times
inumpirates defined in line 403; used 5 times
inumroms defined in line 413; used 3 times
inumstars defined in line 409; used 31 times
ismarts defined in line 425; used 11 times
nocd defined in line 369; used 1 times
nullstr defined in line 362; used 6 times
numpirates defined in line 404; used 2 times
prescene defined in line 436; used 5 times
readerr defined in line 363; used 1 times
scandist defined in line 437; used 24 times
sm35 defined in line 439; used 1 times
sm45 defined in line 440; used 1 times
sm50 defined in line 441; used 8 times
sm55 defined in line 442; used 2 times
sm80 defined in line 443; used 4 times
sm95 defined in line 444; used 2 times
spbuf defined in line 454; used 126 times
super defined in line 448; used 18 times
warplib defined in line 58; used 4 times
wave defined in line 434; used 8 times
whenok defined in line 449; used 3 times
xamblast defined in line 451; used 3 times
yamblast defined in line 450; used 3 times

Defined typedef's

MEM_SIZE defined in line 312; used 3 times

Defined macros

BACKTICK defined in line 234; used 2 times
BITSPERBYTE defined in line 124; never used
BSD42 defined in line 162; never used
CBUFLEN defined in line 131; used 2 times
CONDSUB defined in line 233; used 4 times
Cpytill defined in line 466; used 1 times
Ctl defined in line 150; never used
DEBUGGING defined in line 231; used 15 times
DEB_FILEXP defined in line 343; used 8 times
ELSE defined in line 265; used 2 times
FINISHCMD defined in line 139; used 1 times
FSCOREBOARD defined in line 45; used 2 times
FULLNAMEFILE defined in line 301; used 3 times
GCOSFIELD defined in line 225; used 1 times
GETLOGIN defined in line 236; used 1 times
GETWD defined in line 239; used 1 times
HELPFILE defined in line 40; used 1 times
IF defined in line 264; used 2 times
LBUFLEN defined in line 125; used 1 times
LOCKFILE defined in line 41; used 2 times
LOGDIRFIELD defined in line 218; used 2 times
LOGFILE defined in line 42; used 2 times
LSCOREBOARD defined in line 44; used 2 times
MAPS defined in line 61; used 2 times
MAXFILENAME defined in line 137; never used
Make_object defined in line 468; used 1 times
NEWSFILE defined in line 39; used 1 times
NOMARKING defined in line 356; never used
Nullch defined in line 147; used 23 times
Nullfp defined in line 148; used 7 times
PENDING defined in line 172; used 3 times
PERMMAPS defined in line 60; used 2 times
PREFSHELL defined in line 283; used 1 times
PROMPTTTY defined in line 235; used 2 times
PUSHBACK defined in line 232; used 10 times
PUSHSIZE defined in line 132; used 6 times
ROOTID defined in line 209; used 1 times
Read_tty defined in line 469; used 2 times
SAVEDIR defined in line 38; used 5 times
SCOREBOARD defined in line 43; used 2 times
SETUIDGID defined in line 240; used 2 times
SH defined in line 288; used 1 times
STANDOUT defined in line 357; never used
Safecpy defined in line 465; used 1 times
Signal defined in line 464; used 2 times
Sprintf defined in line 463; used 47 times
TCSIZE defined in line 274; used 1 times
TERSE defined in line 262; used 5 times
TILDENAME defined in line 238; used 2 times
TMPSCOREBOARD defined in line 46; used 4 times
Tract defined in line 467; used 15 times
UNDERLINE defined in line 358; never used
UNLINK defined in line 180; never used
VERBOSE defined in line 243; used 9 times
WARPLIB defined in line 54; used 2 times
WARPMACRO defined in line 294; used 2 times
WARPNEWSNAME defined in line 307; used 1 times
XSIZE01 defined in line 85; used 4 times
XSIZE02 defined in line 87; used 1 times
XSIZE03 defined in line 89; used 1 times
XSIZE08 defined in line 91; used 1 times
XSIZE92 defined in line 92; used 1 times
XSIZE97 defined in line 90; used 1 times
XSIZE98 defined in line 88; used 1 times
XYSIZE defined in line 75; never used
XYSIZEx4 defined in line 76; used 1 times
YSIZE01 defined in line 80; never used
eaccess defined in line 249; used 1 times
isalnum defined in line 101; used 1 times
sgn defined in line 157; used 2 times
sigignore defined in line 214; used 3 times
sigset defined in line 213; used 17 times
strEQ defined in line 153; used 3 times
strNE defined in line 152; never used
strnEQ defined in line 155; used 1 times
strnNE defined in line 154; used 2 times

Usage of this include

Last modified: 1995-01-22
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 5636
Valid CSS Valid XHTML 1.0 Strict