comparison arogue5/main.c @ 279:d3968e9cb98d

Use C stdio functions for score files and save files. Switching from Unix file descriptor operations to C standard FILE* functions will reduce portability problems.
author John "Elwin" Edwards
date Fri, 15 Sep 2017 19:57:54 -0400
parents 3d4252fa2ed3
children 17005af49963
comparison
equal deleted inserted replaced
278:c222f9d56776 279:d3968e9cb98d
18 #include <fcntl.h> 18 #include <fcntl.h>
19 #include <sys/stat.h> 19 #include <sys/stat.h>
20 #include <limits.h> 20 #include <limits.h>
21 #include <signal.h> 21 #include <signal.h>
22 #include <time.h> 22 #include <time.h>
23 #include <errno.h>
23 #include "mach_dep.h" 24 #include "mach_dep.h"
24 #include "network.h" 25 #include "network.h"
25 #include "rogue.h" 26 #include "rogue.h"
26 27
27 #ifdef CHECKTIME 28 #ifdef CHECKTIME
243 mpos = 0; 244 mpos = 0;
244 playit(); 245 playit();
245 } 246 }
246 247
247 void 248 void
249 reopen_score(void)
250 {
251 if (scoreboard != NULL)
252 fclose(scoreboard);
253 scoreboard = fopen(score_file, "r+");
254 if (scoreboard == NULL && errno == ENOENT) {
255 scoreboard = fopen(score_file, "w+");
256 }
257 }
258
259
260 void
248 open_records(void) 261 open_records(void)
249 { 262 {
250 if (scorefd == -1) 263 if (scoreboard == NULL)
251 md_reopen_score(); 264 reopen_score();
252 #ifdef LOGFILE 265 #ifdef LOGFILE
253 if (logfile == NULL) 266 if (logfile == NULL)
254 logfile = fopen(LOGFILE, "a"); 267 logfile = fopen(LOGFILE, "a");
255 #endif 268 #endif
256 return; 269 return;