10 |
|
#include <string.h> |
11 |
|
|
12 |
|
#include "rholo.h" |
13 |
+ |
#include "platform.h" |
14 |
|
#include "random.h" |
15 |
|
|
16 |
|
#ifndef FRAGWARN |
270 |
|
} |
271 |
|
/* set up signal handling */ |
272 |
|
sigdie(SIGINT, "Interrupt"); |
272 |
– |
sigdie(SIGHUP, "Hangup"); |
273 |
|
sigdie(SIGTERM, "Terminate"); |
274 |
+ |
#ifdef SIGHUP |
275 |
+ |
sigdie(SIGHUP, "Hangup"); |
276 |
+ |
#endif |
277 |
+ |
#ifdef SIGPIPE |
278 |
|
sigdie(SIGPIPE, "Broken pipe"); |
279 |
+ |
#endif |
280 |
+ |
#ifdef SIGALRM |
281 |
|
sigdie(SIGALRM, "Alarm clock"); |
282 |
+ |
#endif |
283 |
|
#ifdef SIGXCPU |
284 |
|
sigdie(SIGXCPU, "CPU limit exceeded"); |
285 |
+ |
#endif |
286 |
+ |
#ifdef SIGXFSZ |
287 |
|
sigdie(SIGXFSZ, "File size exceeded"); |
288 |
|
#endif |
289 |
|
/* protect holodeck file */ |
442 |
|
putw(HOLOMAGIC, fp); /* put magic number */ |
443 |
|
fd = dup(fileno(fp)); |
444 |
|
fclose(fp); /* flush and close stdio stream */ |
445 |
< |
lastloc = lseek(fd, (off_t)0, 2); |
445 |
> |
lastloc = lseek(fd, (off_t)0, SEEK_END); |
446 |
|
for (n = vdef(SECTION); n--; gp++) { /* initialize each section */ |
447 |
|
nextloc = 0L; |
448 |
|
write(fd, (char *)&nextloc, sizeof(nextloc)); |
450 |
|
if (!n) |
451 |
|
break; |
452 |
|
nextloc = hdfilen(fd); /* write section pointer */ |
453 |
< |
if (lseek(fd, (off_t)lastloc, 0) < 0) |
453 |
> |
if (lseek(fd, (off_t)lastloc, SEEK_SET) < 0) |
454 |
|
error(SYSTEM, |
455 |
|
"cannot seek on holodeck file in creatholo"); |
456 |
|
write(fd, (char *)&nextloc, sizeof(nextloc)); |
457 |
< |
lseek(fd, (off_t)(lastloc=nextloc), 0); |
457 |
> |
lseek(fd, (off_t)(lastloc=nextloc), SEEK_SET); |
458 |
|
} |
459 |
|
} |
460 |
|
|
521 |
|
fd = dup(fileno(fp)); |
522 |
|
fclose(fp); /* done with stdio */ |
523 |
|
for (n = 0; nextloc > 0L; n++) { /* initialize each section */ |
524 |
< |
lseek(fd, (off_t)nextloc, 0); |
524 |
> |
lseek(fd, (off_t)nextloc, SEEK_SET); |
525 |
|
read(fd, (char *)&nextloc, sizeof(nextloc)); |
526 |
|
hdinit(fd, NULL); |
527 |
|
} |