Mercurial > hg > early-roguelike
comparison rogue4/mach_dep.c @ 215:1b73a8641b37
rogue4: fix most GCC5 warnings.
Converting all function definitions to ANSI style accounts for most of
the change. This has exposed other problems, such as daemons not
actually being their stated type, that will require more careful
solutions.
author | John "Elwin" Edwards |
---|---|
date | Wed, 27 Jan 2016 19:41:05 -0500 |
parents | 5926ec314fd4 |
children | d3968e9cb98d |
comparison
equal
deleted
inserted
replaced
214:e5a15b09ce1d | 215:1b73a8641b37 |
---|---|
45 #ifdef LOCKFILE | 45 #ifdef LOCKFILE |
46 static char *lockfile = LOCKFILE; | 46 static char *lockfile = LOCKFILE; |
47 #endif | 47 #endif |
48 #endif | 48 #endif |
49 | 49 |
50 int too_much(void); | |
51 bool author(void); | |
52 void checkout(int s); | |
53 void chmsg(char *fmt, int arg); | |
54 | |
50 /* | 55 /* |
51 * init_check: | 56 * init_check: |
52 * Check out too see if it is proper to play the game now | 57 * Check out too see if it is proper to play the game now |
53 */ | 58 */ |
54 init_check() | 59 void |
60 init_check(void) | |
55 { | 61 { |
56 if (too_much()) | 62 if (too_much()) |
57 { | 63 { |
58 printf("Sorry, %s, but the system is too loaded now.\n", whoami); | 64 printf("Sorry, %s, but the system is too loaded now.\n", whoami); |
59 printf("Try again later. Meanwhile, why not enjoy a%s %s?\n", | 65 printf("Try again later. Meanwhile, why not enjoy a%s %s?\n", |
68 /* | 74 /* |
69 * open_score: | 75 * open_score: |
70 * Open up the score file for future use, and then | 76 * Open up the score file for future use, and then |
71 * setuid(getuid()) in case we are running setuid. | 77 * setuid(getuid()) in case we are running setuid. |
72 */ | 78 */ |
73 open_score() | 79 void |
80 open_score(void) | |
74 { | 81 { |
75 #ifdef SCOREFILE | 82 #ifdef SCOREFILE |
76 fd = open(SCOREFILE, O_RDWR | O_CREAT, 0666 ); | 83 fd = open(SCOREFILE, O_RDWR | O_CREAT, 0666 ); |
77 #else | 84 #else |
78 fd = -1; | 85 fd = -1; |
80 if (!use_savedir) | 87 if (!use_savedir) |
81 md_normaluser(); | 88 md_normaluser(); |
82 return; | 89 return; |
83 } | 90 } |
84 | 91 |
85 void open_log(void) | 92 void |
93 open_log(void) | |
86 { | 94 { |
87 #ifdef LOGFILE | 95 #ifdef LOGFILE |
88 lfd = open(LOGFILE, O_WRONLY | O_APPEND | O_CREAT, 0666); | 96 lfd = open(LOGFILE, O_WRONLY | O_APPEND | O_CREAT, 0666); |
89 #else | 97 #else |
90 lfd = -1; | 98 lfd = -1; |
94 | 102 |
95 /* | 103 /* |
96 * setup: | 104 * setup: |
97 * Get starting setup for all games | 105 * Get starting setup for all games |
98 */ | 106 */ |
99 setup() | 107 void |
108 setup(void) | |
100 { | 109 { |
101 void auto_save(), quit(), endit(), tstp(); | 110 void auto_save(), quit(), endit(), tstp(); |
102 #ifdef CHECKTIME | |
103 int checkout(); | |
104 #endif | |
105 | 111 |
106 /* | 112 /* |
107 * make sure that large terminals don't overflow the bounds | 113 * make sure that large terminals don't overflow the bounds |
108 * of the program | 114 * of the program |
109 */ | 115 */ |
156 | 162 |
157 /* | 163 /* |
158 * start_score: | 164 * start_score: |
159 * Start the scoring sequence | 165 * Start the scoring sequence |
160 */ | 166 */ |
161 start_score() | 167 void |
168 start_score(void) | |
162 { | 169 { |
163 #ifdef SIGALRM | 170 #ifdef SIGALRM |
164 signal(SIGALRM, SIG_IGN); | 171 signal(SIGALRM, SIG_IGN); |
165 #endif | 172 #endif |
166 } | 173 } |
167 | 174 |
168 /* | 175 /* |
169 * issymlink: | 176 * issymlink: |
170 * See if the file has a symbolic link | 177 * See if the file has a symbolic link |
171 */ | 178 */ |
172 issymlink(sp) | 179 bool |
173 char *sp; | 180 issymlink(char *sp) |
174 { | 181 { |
175 #ifdef S_IFLNK | 182 #ifdef S_IFLNK |
176 struct stat sbuf2; | 183 struct stat sbuf2; |
177 | 184 |
178 if (lstat(sp, &sbuf2) < 0) | 185 if (lstat(sp, &sbuf2) < 0) |
186 | 193 |
187 /* | 194 /* |
188 * too_much: | 195 * too_much: |
189 * See if the system is being used too much for this game | 196 * See if the system is being used too much for this game |
190 */ | 197 */ |
191 too_much() | 198 int |
199 too_much(void) | |
192 { | 200 { |
193 #ifdef MAXLOAD | 201 #ifdef MAXLOAD |
194 double avec[3]; | 202 double avec[3]; |
195 | 203 |
196 if (md_getloadavg(avec) == 0) | 204 if (md_getloadavg(avec) == 0) |
206 | 214 |
207 /* | 215 /* |
208 * author: | 216 * author: |
209 * See if a user is an author of the program | 217 * See if a user is an author of the program |
210 */ | 218 */ |
211 author() | 219 bool |
220 author(void) | |
212 { | 221 { |
213 #ifdef WIZARD | 222 #ifdef WIZARD |
214 if (wizard) | 223 if (wizard) |
215 return TRUE; | 224 return TRUE; |
216 #endif | 225 #endif |
244 if (too_much()) | 253 if (too_much()) |
245 { | 254 { |
246 if (author()) | 255 if (author()) |
247 { | 256 { |
248 num_checks = 1; | 257 num_checks = 1; |
249 chmsg("The load is rather high, O exaulted one"); | 258 chmsg("The load is rather high, O exaulted one", 0); |
250 } | 259 } |
251 else if (num_checks++ == 3) | 260 else if (num_checks++ == 3) |
252 fatal("Sorry. You took to long. You are dead\n"); | 261 fatal("Sorry. You took to long. You are dead\n"); |
253 | 262 |
254 #ifdef CHECKTIME | 263 #ifdef CHECKTIME |
263 else | 272 else |
264 { | 273 { |
265 if (num_checks) | 274 if (num_checks) |
266 { | 275 { |
267 num_checks = 0; | 276 num_checks = 0; |
268 chmsg("The load has dropped back down. You have a reprieve"); | 277 chmsg("The load has dropped back down. You have a reprieve", 0); |
269 } | 278 } |
270 #ifdef CHECKTIME | 279 #ifdef CHECKTIME |
271 #ifdef SIGALRM | 280 #ifdef SIGALRM |
272 alarm(CHECKTIME * 60); | 281 alarm(CHECKTIME * 60); |
273 #endif | 282 #endif |
278 /* | 287 /* |
279 * chmsg: | 288 * chmsg: |
280 * checkout()'s version of msg. If we are in the middle of a | 289 * checkout()'s version of msg. If we are in the middle of a |
281 * shell, do a printf instead of a msg to avoid the refresh. | 290 * shell, do a printf instead of a msg to avoid the refresh. |
282 */ | 291 */ |
283 chmsg(fmt, arg) | 292 void |
284 char *fmt; | 293 chmsg(char *fmt, int arg) |
285 int arg; | |
286 { | 294 { |
287 if (in_shell) | 295 if (in_shell) |
288 { | 296 { |
289 printf(fmt, arg); | 297 printf(fmt, arg); |
290 putchar('\n'); | 298 putchar('\n'); |
297 /* | 305 /* |
298 * lock_sc: | 306 * lock_sc: |
299 * lock the score file. If it takes too long, ask the user if | 307 * lock the score file. If it takes too long, ask the user if |
300 * they care to wait. Return TRUE if the lock is successful. | 308 * they care to wait. Return TRUE if the lock is successful. |
301 */ | 309 */ |
302 lock_sc() | 310 bool |
311 lock_sc(void) | |
303 { | 312 { |
304 #ifdef SCOREFILE | 313 #ifdef SCOREFILE |
305 #ifdef LOCKFILE | 314 #ifdef LOCKFILE |
306 register int cnt; | 315 register int cnt; |
307 static struct stat sbuf; | 316 static struct stat sbuf; |
359 | 368 |
360 /* | 369 /* |
361 * unlock_sc: | 370 * unlock_sc: |
362 * Unlock the score file | 371 * Unlock the score file |
363 */ | 372 */ |
364 unlock_sc() | 373 void |
374 unlock_sc(void) | |
365 { | 375 { |
366 #ifdef SCOREFILE | 376 #ifdef SCOREFILE |
367 #ifdef LOCKFILE | 377 #ifdef LOCKFILE |
368 md_unlink(lockfile); | 378 md_unlink(lockfile); |
369 #endif | 379 #endif |
372 | 382 |
373 /* | 383 /* |
374 * flush_type: | 384 * flush_type: |
375 * Flush typeahead for traps, etc. | 385 * Flush typeahead for traps, etc. |
376 */ | 386 */ |
377 flush_type() | 387 void |
388 flush_type(void) | |
378 { | 389 { |
379 flushinp(); | 390 flushinp(); |
380 } | 391 } |