xref: /csrg-svn/old/games.vax/zork/zork.c (revision 8877)
1*8877Smckusick 
2*8877Smckusick static char sccsid[] = "	zork.c	4.1	82/10/24	";
3*8877Smckusick 
4*8877Smckusick #include <stdio.h>
5*8877Smckusick /*
6*8877Smckusick  * Dungeon - open UP dungeon
7*8877Smckusick  */
8*8877Smckusick 
9*8877Smckusick #ifdef CHECKUID
10*8877Smckusick int users[] = {
11*8877Smckusick 	522,    /* sa */
12*8877Smckusick 	164,    /* Leiby */
13*8877Smckusick 	229,    /* richards */
14*8877Smckusick 	264,    /* marshall */
15*8877Smckusick 	1099,   /* wizard */
16*8877Smckusick 	425,    /* clm */
17*8877Smckusick 	15,     /* mowle */
18*8877Smckusick 	32,     /* ghg */
19*8877Smckusick 	27,	/* qtip (zager) */
20*8877Smckusick 	530,	/* mike */
21*8877Smckusick 	16,	/* bc */
22*8877Smckusick 	333,	/* pdh */
23*8877Smckusick 	230,	/* wa1yyn */
24*8877Smckusick 	19,	/* joe
25*8877Smckusick 	43,	/* bruner */
26*8877Smckusick 	308,	/* gedeon (watch him closely!) */
27*8877Smckusick 	429,	/* mayhew */
28*8877Smckusick 	743,	/* alicia */
29*8877Smckusick 	367,	/* feather */
30*8877Smckusick 	85,	/* clark bar */
31*8877Smckusick 	382,	/* malcolm */
32*8877Smckusick 	99,	/* jones */
33*8877Smckusick 	636,    /* gfg */
34*8877Smckusick 	0 };
35*8877Smckusick #endif
36*8877Smckusick 
main()37*8877Smckusick main()
38*8877Smckusick {
39*8877Smckusick 
40*8877Smckusick 	register int *up;
41*8877Smckusick 	register uid;
42*8877Smckusick 	int fd3, fd4, fd5;
43*8877Smckusick 
44*8877Smckusick #ifdef CHECKUID
45*8877Smckusick 
46*8877Smckusick 	uid = getuid();
47*8877Smckusick 	for (up=users; *up; up++)
48*8877Smckusick 		if (*up == uid)
49*8877Smckusick 			goto ok;
50*8877Smckusick 	printf("You are not a Wizard!\n");
51*8877Smckusick 	exit();
52*8877Smckusick #endif
53*8877Smckusick 	/*
54*8877Smckusick 	 * open up files needed by program
55*8877Smckusick 	 * look in current directory first, then try default names
56*8877Smckusick 	 * The following files must be as follows:
57*8877Smckusick 	 * "dtext.dat" open read-only on fd 3
58*8877Smckusick 	 * "dindex.dat open read-only on fd 4 (maybe this file isn't used)
59*8877Smckusick 	 * "doverlay" open read-only on fd 5 (put this file on fast disk)
60*8877Smckusick 	 */
61*8877Smckusick 	close(3);
62*8877Smckusick 	close(4);
63*8877Smckusick 	close(5);
64*8877Smckusick 	if ((fd3 = open("dtext.dat", 0)) < 0)
65*8877Smckusick 		if ((fd3 = open("/usr/games/lib/dtext.dat", 0)) < 0)
66*8877Smckusick 			error("Can't open dtext.dat\n");
67*8877Smckusick 
68*8877Smckusick 	if ((fd4 = open("dindex.dat", 0)) < 0)
69*8877Smckusick 		if ((fd4 = open("/usr/games/lib/dindex.dat", 0)) < 0)
70*8877Smckusick 			error("Can' open dindex.dat\n");
71*8877Smckusick 
72*8877Smckusick 	if ((fd5 = open("doverlay", 0)) < 0)
73*8877Smckusick 		if ((fd5 = open("/tmp/nedtmp/doverlay", 0)) < 0)
74*8877Smckusick 			if ((fd5 = open("/usr/games/lib/doverlay", 0)) < 0)
75*8877Smckusick 				error("Can't open doverlay\n");
76*8877Smckusick 
77*8877Smckusick 	if (fd3 != 3 || fd4 != 4 || fd5 != 5)
78*8877Smckusick 		error("Files opened on wrong descriptors\n");
79*8877Smckusick 
80*8877Smckusick 	signal(2,1);
81*8877Smckusick 
82*8877Smckusick 	printf("You are in an open field west of a big white house with a boarded\n");
83*8877Smckusick 	printf("front door.\n");
84*8877Smckusick 	printf("There is a small mailbox here.\n>");
85*8877Smckusick 	fflush(stdout);
86*8877Smckusick #ifdef pdp11
87*8877Smckusick 	execl("dungeon","zork", 0);
88*8877Smckusick 	execl("/usr/games/lib/dungeon","zork", 0);
89*8877Smckusick #else
90*8877Smckusick 	if( (uid=open("dungeon", 0)) > 0 ) {
91*8877Smckusick 		close(uid);
92*8877Smckusick 		execlp("compat", "zork", "dungeon", 0);
93*8877Smckusick 		execlp("/usr/games/lib/compat", "zork", "dungeon", 0);
94*8877Smckusick 	}
95*8877Smckusick 	execlp("compat", "zork", "/usr/games/lib/dungeon", 0);
96*8877Smckusick 	execlp("/usr/games/lib/compat", "zork", "/usr/games/lib/dungeon", 0);
97*8877Smckusick #endif
98*8877Smckusick 	printf("Can't start dungeons.\n");
99*8877Smckusick 	exit(0);
100*8877Smckusick }
error(s)101*8877Smckusick error(s)
102*8877Smckusick char *s;
103*8877Smckusick {
104*8877Smckusick 	printf("%s", s);
105*8877Smckusick 	exit(1);
106*8877Smckusick }
107