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.
This commit is contained in:
John "Elwin" Edwards 2017-09-15 19:57:54 -04:00
parent f8d1f422c8
commit c661fd79d4
33 changed files with 426 additions and 439 deletions

View file

@ -16,6 +16,7 @@
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#ifdef BSD
#include <sys/time.h>
#else
@ -550,11 +551,21 @@ setup(void)
nonl();
}
void
reopen_score(void)
{
if (scoreboard != NULL)
fclose(scoreboard);
scoreboard = fopen(score_file, "r+");
if (scoreboard == NULL && errno == ENOENT)
scoreboard = fopen(score_file, "w+");
}
void
open_records(void)
{
if (scorefd == -1)
md_reopen_score();
if (scoreboard == NULL)
reopen_score();
#ifdef LOGFILE
if (logfile == NULL)
logfile = fopen(LOGFILE, "a");