1: /*
   2:  * Dungeon - open UP dungeon
   3:  */
   4: #include    <stdio.h>
   5: #include <time.h>
   6: 
   7: #define GUEST 16
   8: 
   9: int users[] = {
  10:     3,  /* bin */
  11: /*	17,*/
  12:     22,
  13:     0 };
  14: 
  15: main(argc,argv)
  16:     int argc;
  17:     char    *argv[];
  18: {
  19: 
  20:     register char   *pname = "zork";
  21:     register int *up;
  22:     register uid;
  23:     int fd3, fd4, fd5;
  24: 
  25:     int wizard = 0;
  26: 
  27:     uid = getuid();
  28:     for (up=users; *up; up++)
  29:         if (*up == uid)
  30:             wizard++;
  31: 
  32:     if(argc == 2)
  33:         if(wizard != 0)
  34:             pname = argv[0];
  35:     /*
  36: 	 * open up files needed by program
  37: 	 * look in current directory first, then try default names
  38: 	 * The following files must be as follows:
  39: 	 * "dtext.dat" open read-only on fd 3
  40: 	 * "dindex.dat" open read-only on fd 4
  41: 	 * "doverlay" open read-only on fd 5 (put this file on fast disk)
  42: 	 */
  43:     close(3);
  44:     close(4);
  45:     close(5);
  46: 
  47:     if ((fd3 = open("dtext.dat",0)) < 0)
  48:         if ((fd3 = open("/usr/games/lib/dtext.dat", 0)) < 0)
  49:         error("Can't open dtext.dat\n");
  50: 
  51:     if ((fd4 = open("dindex.dat", 0)) < 0)
  52:         if ((fd4 = open("/usr/games/lib/dindex.dat", 0)) < 0)
  53:         error("Can't open dindex.dat\n");
  54: 
  55:     if ((fd5 = open("doverlay",0)) < 0)
  56:         if ((fd5 = open("/usr/games/lib/doverlay", 0)) < 0)
  57:         error("Can't open doverlay\n");
  58: 
  59:     if (fd3 != 3 || fd4 != 4 || fd5 != 5)
  60:         error("Files opened on wrong descriptors\n");
  61: 
  62:     signal (2,1);
  63: 
  64: /*	if(wizard == 0)
  65: 		datecheck();*/
  66: 
  67:     printf(">\t\t\tSaves game on file dsave.dat\n");
  68:     printf("<\t\t\tRestores game from file dsave.dat\n");
  69:     printf("!command\t\tExecute shell command from Dungeon\n");
  70:     printf("\n\n");
  71: 
  72:     printf("Welcome to Dungeon.\t\tThis version created 10-SEP-78.\n");
  73:     printf("You are in an open field west of a big white house with a boarded\n");
  74:     printf("front door.\n");
  75:     printf("There is a small mailbox here.\n>");
  76:     fflush(stdout);
  77:     nice(2);
  78:     execl("/usr/games/lib/zork",pname, 0);
  79:     execl("zork",pname, 0);
  80:     printf("Can't start zork.\n");
  81:     fflush(stdout);
  82:     exit(1);
  83: }
  84: error(s)
  85: char *s;
  86: {
  87:     printf("%s", s);
  88:     fflush(stdout);
  89:     exit(1);
  90: }
  91: 
  92: struct  hol_dom
  93:     {
  94:         int m_month;
  95:         int m_day;
  96:         char    *m_msg;
  97:     };
  98: 
  99: struct hol_dom  hol_dom[] =
 100:     {
 101:          0,  1, "Happy New Year",
 102:          6,  4, "Happy Fourth of July",
 103:         11, 25, "Merry Christmas",
 104:         -1,  0, 0,
 105:     };
 106: 
 107: struct hol_dow
 108:     {
 109:         int w_month;
 110:         int w_day;
 111:         int w_weekskip;
 112:         char    *w_msg;
 113:     };
 114: 
 115: struct hol_dow  hol_dow[] =
 116:     {
 117:          8,  1,  0, "Happy Labor Day",
 118:         10,  4,  3, "Happy Thanksgiving",
 119:         10,  5,  3, "Happy Day-After-Thanksgiving",
 120:         -1,  0,  0, 0,
 121:     };
 122: 
 123: datecheck() {
 124:     long tm;
 125:     register struct tm *l;
 126:     register struct hol_dom *m;
 127:     register struct hol_dow *w;
 128: 
 129:     time(&tm);
 130:     l = localtime(&tm);
 131:     if(l->tm_wday == 0 || l->tm_wday == 6)
 132:         return;
 133:     if(l->tm_hour <= 8 || l->tm_hour >= 17)
 134:         return;
 135:     for(m = hol_dom ; m->m_month < 0 ; m++)
 136:     {
 137:         if(l->tm_mon == m->m_month && l->tm_mday == m->m_day)
 138:             return;
 139:     }
 140:     for(w = hol_dow ; w->w_month < 0 ; w++)
 141:     {
 142:         if(l->tm_mon == w->w_month
 143:           && l->tm_mday == w->w_day
 144:           && (7 * w->w_weekskip) < l->tm_mday
 145:           && l->tm_mday >= (7 * (w->w_weekskip + 1)))
 146:             return;
 147:     }
 148:     goaway();
 149: }
 150: 
 151: goaway () {
 152:     printf("\nThere appears before you a threatening figure clad all over\n");
 153:     printf("in heavy black armor.  His legs seem like the massive trunk\n");
 154:     printf("of the oak tree.  His broad shoulders and helmeted head loom\n");
 155:     printf("high over your own puny frame, and you realize that his powerful\n");
 156:     printf("arms could easily crush the very life from your body.  There\n");
 157:     printf("hangs from his belt a veritable arsenal of deadly weapons:\n");
 158:     printf("sword, mace, ball and chain, dagger, lance, and trident.\n");
 159:     printf("He speaks with a commanding voice:\n\n");
 160:     printf("                    You shall not pass.\n\n");
 161:     printf("As he grabs you by the neck all grows dim about you.\n");
 162:     sleep (2);
 163:     fflush(stdout);
 164:     exit(1);
 165: }

Defined functions

datecheck defined in line 123; never used
error defined in line 84; used 4 times
goaway defined in line 151; used 1 times
main defined in line 15; never used

Defined variables

hol_dom defined in line 99; used 1 times
hol_dow defined in line 115; used 1 times
users defined in line 9; used 1 times
  • in line 28

Defined struct's

hol_dom defined in line 92; used 4 times
hol_dow defined in line 107; used 4 times

Defined macros

GUEST defined in line 7; never used
Last modified: 1987-08-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3197
Valid CSS Valid XHTML 1.0 Strict