comparison arogue7/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 827441d05b3e
comparison
equal deleted inserted replaced
278:c222f9d56776 279:d3968e9cb98d
14 14
15 #include "curses.h" 15 #include "curses.h"
16 #include <stdlib.h> 16 #include <stdlib.h>
17 #include <string.h> 17 #include <string.h>
18 #include <signal.h> 18 #include <signal.h>
19 #include <errno.h>
19 #ifdef BSD 20 #ifdef BSD
20 #include <sys/time.h> 21 #include <sys/time.h>
21 #else 22 #else
22 #include <time.h> 23 #include <time.h>
23 #endif 24 #endif
549 noecho(); /* Echo off */ 550 noecho(); /* Echo off */
550 nonl(); 551 nonl();
551 } 552 }
552 553
553 void 554 void
555 reopen_score(void)
556 {
557 if (scoreboard != NULL)
558 fclose(scoreboard);
559 scoreboard = fopen(score_file, "r+");
560 if (scoreboard == NULL && errno == ENOENT)
561 scoreboard = fopen(score_file, "w+");
562 }
563
564 void
554 open_records(void) 565 open_records(void)
555 { 566 {
556 if (scorefd == -1) 567 if (scoreboard == NULL)
557 md_reopen_score(); 568 reopen_score();
558 #ifdef LOGFILE 569 #ifdef LOGFILE
559 if (logfile == NULL) 570 if (logfile == NULL)
560 logfile = fopen(LOGFILE, "a"); 571 logfile = fopen(LOGFILE, "a");
561 #endif 572 #endif
562 return; 573 return;