Mercurial > hg > early-roguelike
comparison srogue/main.c @ 173:78fa1d0e5d25
srogue: open the score and log files when the program starts.
Super-Rogue can now use the same privilege-dropping scheme as the other
games.
author | John "Elwin" Edwards |
---|---|
date | Sat, 01 Aug 2015 15:12:11 -0400 |
parents | e6c8652473fe |
children | 1863409c44cf |
comparison
equal
deleted
inserted
replaced
172:c199a15a2c70 | 173:78fa1d0e5d25 |
---|---|
32 #include <sys/time.h> | 32 #include <sys/time.h> |
33 #endif | 33 #endif |
34 | 34 |
35 #include "rogue.ext" | 35 #include "rogue.ext" |
36 | 36 |
37 void open_records(void); | |
38 | |
39 extern int scorefd; | |
40 extern FILE *logfile; | |
41 | |
37 main(argc, argv, envp) | 42 main(argc, argv, envp) |
38 char **argv; | 43 char **argv; |
39 char **envp; | 44 char **envp; |
40 { | 45 { |
41 register char *env; | 46 register char *env; |
68 | 73 |
69 if (*scorefile) | 74 if (*scorefile) |
70 strcat(scorefile,"/"); | 75 strcat(scorefile,"/"); |
71 strcat(scorefile, "srogue.scr"); | 76 strcat(scorefile, "srogue.scr"); |
72 #endif | 77 #endif |
78 open_records(); | |
73 | 79 |
74 if(argc >= 2 && strcmp(argv[1], "-s") == 0) | 80 if(argc >= 2 && strcmp(argv[1], "-s") == 0) |
75 { | 81 { |
76 showtop(0); | 82 showtop(0); |
77 exit(0); | 83 exit(0); |
470 return("/games/roguelik"); | 476 return("/games/roguelik"); |
471 | 477 |
472 return(NULL); | 478 return(NULL); |
473 } | 479 } |
474 | 480 |
481 void | |
482 open_records(void) | |
483 { | |
484 if (scorefd < 0) | |
485 scorefd = open(scorefile, O_RDWR | O_CREAT, 0666); | |
486 #ifdef LOGFILE | |
487 if (logfile == NULL) | |
488 logfile = fopen(LOGFILE, "a"); | |
489 #endif | |
490 } | |
491 |