srogue: add and use md_fdopen().

The implementation was copied from rogue4.  Using fdopen() is necessary
because the scorefile needs both encread() and encwrite().  For some
reason I have failed to discover, one of them uses FILE *'s and the
other uses file descriptors.
This commit is contained in:
John "Elwin" Edwards 2015-08-03 09:27:43 -04:00
parent e857a2cec6
commit 00142507db
3 changed files with 12 additions and 1 deletions

View file

@ -358,6 +358,16 @@ md_unlink(char *file)
#endif
}
FILE *
md_fdopen(int fd, char *mode)
{
#ifdef _WIN32
return( _fdopen(fd, mode) );
#else
return( fdopen(fd, mode) );
#endif
}
int
md_chmod(const char *filename, int mode)
{

View file

@ -145,7 +145,7 @@ int amount, aflag;
*/
if ((fd = scorefd) < 0)
return;
outf = (FILE *) fdopen(fd, "w");
outf = (FILE *) md_fdopen(fd, "w");
for (scp = top_ten; scp <= &top_ten[9]; scp++) {
scp->sc_score = 0;
for (i = 0; i < 80; i++)

View file

@ -40,6 +40,7 @@ int md_chmod(const char *filename, int mode);
char *md_crypt(const char *key, const char *salt);
int md_dsuspchar(void);
int md_erasechar(void);
FILE * md_fdopen(int fd, char *mode);
char *md_gethomedir(void);
char *md_getusername(void);
uid_t md_getuid(void);