Mercurial > hg > early-roguelike
annotate rogue4/mach_dep.c @ 12:9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
author | edwarj4 |
---|---|
date | Sat, 24 Oct 2009 16:52:52 +0000 |
parents | |
children | 63b9fd7d70ce |
rev | line source |
---|---|
12
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
1 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
2 * Various installation dependent routines |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
3 * |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
4 * @(#)mach_dep.c 4.23 (Berkeley) 5/19/82 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
5 * |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
6 * Rogue: Exploring the Dungeons of Doom |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
7 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
8 * All rights reserved. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
9 * |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
10 * See the file LICENSE.TXT for full copyright and licensing information. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
11 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
12 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
13 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
14 * The various tuneable defines are: |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
15 * |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
16 * SCOREFILE Where/if the score file should live. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
17 * MAXLOAD What (if any) the maximum load average should be |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
18 * when people are playing. If defined, then |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
19 * LOADAV Should rogue define it's own routine to |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
20 * get the load average? |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
21 * NAMELIST If so, where does the system namelist hide? |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
22 * MAXUSERS What (if any) the maximum user count should be |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
23 * when people are playing. If defined, then |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
24 * UCOUNT Should rogue define it's own routine to |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
25 * count users? |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
26 * UTMP If so, where does the user list hide? |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
27 * CHECKTIME How often/if rogue should check during the game |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
28 * for high load average. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
29 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
30 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
31 #include <limits.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
32 #include <stdlib.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
33 #include <stdio.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
34 #include <curses.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
35 #include <time.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
36 #include <signal.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
37 #include <sys/stat.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
38 #include <fcntl.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
39 #include <string.h> |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
40 #include "rogue.h" |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
41 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
42 int num_checks; /* times we've gone over in checkout() */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
43 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
44 #ifdef SCOREFILE |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
45 #ifdef LOCKFILE |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
46 static char *lockfile = LOCKFILE; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
47 #endif |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
48 #endif |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
49 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
50 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
51 * init_check: |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
52 * Check out too see if it is proper to play the game now |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
53 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
54 init_check() |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
55 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
56 if (too_much()) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
57 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
58 printf("Sorry, %s, but the system is too loaded now.\n", whoami); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
59 printf("Try again later. Meanwhile, why not enjoy a%s %s?\n", |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
60 vowelstr(fruit), fruit); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
61 if (author()) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
62 printf("However, since you're a good guy, it's up to you\n"); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
63 else |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
64 exit(1); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
65 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
66 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
67 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
68 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
69 * open_score: |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
70 * Open up the score file for future use, and then |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
71 * setuid(getuid()) in case we are running setuid. |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
72 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
73 open_score() |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
74 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
75 #ifdef SCOREFILE |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
76 fd = open(SCOREFILE, O_RDWR | O_CREAT, 0666 ); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
77 #else |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
78 fd = -1; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
79 #endif |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
80 md_normaluser(); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
81 } |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
82 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
83 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
84 * setup: |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
85 * Get starting setup for all games |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
86 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
87 setup() |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
88 { |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
89 void auto_save(), quit(), endit(), tstp(); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
90 #ifdef CHECKTIME |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
91 int checkout(); |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
92 #endif |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
93 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
94 /* |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
95 * make sure that large terminals don't overflow the bounds |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
96 * of the program |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
97 */ |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
98 if (LINES > MAXLINES) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
99 LINES = MAXLINES; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
100 if (COLS > MAXCOLS) |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
101 COLS = MAXCOLS; |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff
changeset
|
102 |
9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490) |