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:
parent
f8d1f422c8
commit
c661fd79d4
33 changed files with 426 additions and 439 deletions
|
|
@ -151,7 +151,7 @@ save_file(FILE *savef)
|
|||
bool
|
||||
restore(char *file, char **envp)
|
||||
{
|
||||
register int inf;
|
||||
FILE *inf;
|
||||
#ifndef _AIX
|
||||
extern char **environ;
|
||||
#endif
|
||||
|
|
@ -162,7 +162,7 @@ restore(char *file, char **envp)
|
|||
if (strcmp(file, "-r") == 0)
|
||||
file = file_name;
|
||||
|
||||
if ((inf = open(file, O_RDONLY)) < 0)
|
||||
if ((inf = fopen(file, "r")) == NULL)
|
||||
{
|
||||
if (use_savedir && errno == ENOENT)
|
||||
{
|
||||
|
|
@ -189,7 +189,7 @@ restore(char *file, char **envp)
|
|||
|
||||
encread(buf, 80, inf);
|
||||
sscanf(buf, "%d x %d\n", &oldline, &oldcol);
|
||||
fstat(inf, &sbuf2);
|
||||
stat(file, &sbuf2);
|
||||
fflush(stdout);
|
||||
|
||||
/*
|
||||
|
|
@ -235,7 +235,7 @@ restore(char *file, char **envp)
|
|||
if (!wizard)
|
||||
{
|
||||
if (md_unlink(file) < 0) {
|
||||
close(inf); /* only close if system insists */
|
||||
fclose(inf); /* only close if system insists */
|
||||
if (md_unlink(file) < 0) {
|
||||
endwin();
|
||||
printf("\nCannot unlink file\n");
|
||||
|
|
@ -287,12 +287,12 @@ encwrite(char *start, unsigned int size, FILE *outf)
|
|||
* perform an encrypted read
|
||||
*/
|
||||
int
|
||||
encread(char *start, unsigned int size, int inf)
|
||||
encread(char *start, unsigned int size, FILE *inf)
|
||||
{
|
||||
register char *ep;
|
||||
register int read_size;
|
||||
|
||||
if ((read_size = read(inf, start, size)) == -1 || read_size == 0)
|
||||
if ((read_size = fread(start, 1, size, inf)) == 0)
|
||||
return read_size;
|
||||
|
||||
ep = encstr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue