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.
This commit is contained in:
John "Elwin" Edwards 2015-08-01 15:12:11 -04:00
parent 2d3d25c5e9
commit bc5b26fece
3 changed files with 28 additions and 7 deletions

View file

@ -34,6 +34,11 @@
#include "rogue.ext"
void open_records(void);
extern int scorefd;
extern FILE *logfile;
main(argc, argv, envp)
char **argv;
char **envp;
@ -70,6 +75,7 @@ char **envp;
strcat(scorefile,"/");
strcat(scorefile, "srogue.scr");
#endif
open_records();
if(argc >= 2 && strcmp(argv[1], "-s") == 0)
{
@ -472,3 +478,14 @@ roguehome()
return(NULL);
}
void
open_records(void)
{
if (scorefd < 0)
scorefd = open(scorefile, O_RDWR | O_CREAT, 0666);
#ifdef LOGFILE
if (logfile == NULL)
logfile = fopen(LOGFILE, "a");
#endif
}