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
|
|
@ -71,7 +71,7 @@
|
|||
#define WRITESTAT (write_error == 0)
|
||||
|
||||
int rs_write_int(FILE *savef, int c);
|
||||
int rs_read_int(int inf, int *i);
|
||||
int rs_read_int(FILE *inf, int *i);
|
||||
|
||||
int read_error = FALSE;
|
||||
int write_error = FALSE;
|
||||
|
|
@ -421,7 +421,7 @@ rs_write_strings(FILE *savef, char *s[], int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read(int inf, void *ptr, int size)
|
||||
rs_read(FILE *inf, void *ptr, int size)
|
||||
{
|
||||
int actual;
|
||||
|
||||
|
|
@ -451,14 +451,14 @@ rs_read(int inf, void *ptr, int size)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_char(int inf, char *c)
|
||||
rs_read_char(FILE *inf, char *c)
|
||||
{
|
||||
rs_read(inf, c, 1);
|
||||
|
||||
return(READSTAT);
|
||||
}
|
||||
int
|
||||
rs_read_uchar(int inf, unsigned char *c)
|
||||
rs_read_uchar(FILE *inf, unsigned char *c)
|
||||
{
|
||||
rs_read(inf, c, 1);
|
||||
|
||||
|
|
@ -466,7 +466,7 @@ rs_read_uchar(int inf, unsigned char *c)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_boolean(int inf, bool *i)
|
||||
rs_read_boolean(FILE *inf, bool *i)
|
||||
{
|
||||
unsigned char buf;
|
||||
|
||||
|
|
@ -478,7 +478,7 @@ rs_read_boolean(int inf, bool *i)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_booleans(int inf, bool *i, int count)
|
||||
rs_read_booleans(FILE *inf, bool *i, int count)
|
||||
{
|
||||
int n = 0, value = 0;
|
||||
|
||||
|
|
@ -500,7 +500,7 @@ rs_read_booleans(int inf, bool *i, int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_shint(int inf, shint *i)
|
||||
rs_read_shint(FILE *inf, shint *i)
|
||||
{
|
||||
unsigned char buf;
|
||||
|
||||
|
|
@ -512,7 +512,7 @@ rs_read_shint(int inf, shint *i)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_short(int inf, short *i)
|
||||
rs_read_short(FILE *inf, short *i)
|
||||
{
|
||||
unsigned char bytes[2];
|
||||
short input;
|
||||
|
|
@ -533,7 +533,7 @@ rs_read_short(int inf, short *i)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_shorts(int inf, short *i, int count)
|
||||
rs_read_shorts(FILE *inf, short *i, int count)
|
||||
{
|
||||
int n = 0, value = 0;
|
||||
|
||||
|
|
@ -552,7 +552,7 @@ rs_read_shorts(int inf, short *i, int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_ushort(int inf, unsigned short *i)
|
||||
rs_read_ushort(FILE *inf, unsigned short *i)
|
||||
{
|
||||
unsigned char bytes[2];
|
||||
unsigned short input;
|
||||
|
|
@ -573,7 +573,7 @@ rs_read_ushort(int inf, unsigned short *i)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_int(int inf, int *i)
|
||||
rs_read_int(FILE *inf, int *i)
|
||||
{
|
||||
unsigned char bytes[4];
|
||||
int input;
|
||||
|
|
@ -596,7 +596,7 @@ rs_read_int(int inf, int *i)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_ints(int inf, int *i, int count)
|
||||
rs_read_ints(FILE *inf, int *i, int count)
|
||||
{
|
||||
int n = 0, value = 0;
|
||||
|
||||
|
|
@ -615,7 +615,7 @@ rs_read_ints(int inf, int *i, int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_uint(int inf, unsigned int *i)
|
||||
rs_read_uint(FILE *inf, unsigned int *i)
|
||||
{
|
||||
unsigned char bytes[4];
|
||||
int input;
|
||||
|
|
@ -638,7 +638,7 @@ rs_read_uint(int inf, unsigned int *i)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_long(int inf, long *i)
|
||||
rs_read_long(FILE *inf, long *i)
|
||||
{
|
||||
unsigned char bytes[4];
|
||||
long input;
|
||||
|
|
@ -661,7 +661,7 @@ rs_read_long(int inf, long *i)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_longs(int inf, long *i, int count)
|
||||
rs_read_longs(FILE *inf, long *i, int count)
|
||||
{
|
||||
int n = 0, value = 0;
|
||||
|
||||
|
|
@ -680,7 +680,7 @@ rs_read_longs(int inf, long *i, int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_ulong(int inf, unsigned long *i)
|
||||
rs_read_ulong(FILE *inf, unsigned long *i)
|
||||
{
|
||||
unsigned char bytes[4];
|
||||
unsigned long input;
|
||||
|
|
@ -703,7 +703,7 @@ rs_read_ulong(int inf, unsigned long *i)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_ulongs(int inf, unsigned long *i, int count)
|
||||
rs_read_ulongs(FILE *inf, unsigned long *i, int count)
|
||||
{
|
||||
int n = 0, value = 0;
|
||||
|
||||
|
|
@ -722,7 +722,7 @@ rs_read_ulongs(int inf, unsigned long *i, int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_string(int inf, char *s, int max)
|
||||
rs_read_string(FILE *inf, char *s, int max)
|
||||
{
|
||||
int len = 0;
|
||||
|
||||
|
|
@ -742,7 +742,7 @@ rs_read_string(int inf, char *s, int max)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_new_string(int inf, char **s)
|
||||
rs_read_new_string(FILE *inf, char **s)
|
||||
{
|
||||
int len=0;
|
||||
char *buf=0;
|
||||
|
|
@ -769,7 +769,7 @@ rs_read_new_string(int inf, char **s)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_string_index(int inf, const char *master[], int maxindex,
|
||||
rs_read_string_index(FILE *inf, const char *master[], int maxindex,
|
||||
const char **str)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -792,7 +792,7 @@ rs_read_string_index(int inf, const char *master[], int maxindex,
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_strings(int inf, char **s, int count, int max)
|
||||
rs_read_strings(FILE *inf, char **s, int count, int max)
|
||||
{
|
||||
int n = 0;
|
||||
int value = 0;
|
||||
|
|
@ -819,7 +819,7 @@ rs_read_strings(int inf, char **s, int count, int max)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_new_strings(int inf, char **s, int count)
|
||||
rs_read_new_strings(FILE *inf, char **s, int count)
|
||||
{
|
||||
int len = 0;
|
||||
int n = 0;
|
||||
|
|
@ -863,7 +863,7 @@ rs_write_str_t(FILE *savef, str_t st)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_str_t(int inf, str_t *st)
|
||||
rs_read_str_t(FILE *inf, str_t *st)
|
||||
{
|
||||
rs_read_uint(inf,st);
|
||||
|
||||
|
|
@ -880,7 +880,7 @@ rs_write_coord(FILE *savef, coord c)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_coord(int inf, coord *c)
|
||||
rs_read_coord(FILE *inf, coord *c)
|
||||
{
|
||||
rs_read_shint(inf,&c->x);
|
||||
rs_read_shint(inf,&c->y);
|
||||
|
|
@ -907,7 +907,7 @@ rs_write_window(FILE *savef, WINDOW *win)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_window(int inf, WINDOW *win)
|
||||
rs_read_window(FILE *inf, WINDOW *win)
|
||||
{
|
||||
int id,row,col,maxlines,maxcols,value,width,height;
|
||||
|
||||
|
|
@ -987,7 +987,7 @@ rs_write_daemons(FILE *savef, struct delayed_action *d_list, int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_daemons(int inf, struct delayed_action *d_list, int count)
|
||||
rs_read_daemons(FILE *inf, struct delayed_action *d_list, int count)
|
||||
{
|
||||
int i = 0;
|
||||
int func = 0;
|
||||
|
|
@ -1083,7 +1083,7 @@ rs_write_magic_items(FILE *savef, struct magic_item *i, int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_magic_items(int inf, struct magic_item *mi, int count)
|
||||
rs_read_magic_items(FILE *inf, struct magic_item *mi, int count)
|
||||
{
|
||||
int id;
|
||||
int n;
|
||||
|
|
@ -1161,7 +1161,7 @@ rs_write_rooms(FILE *savef, struct room r[], int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_room(int inf, struct room *r)
|
||||
rs_read_room(FILE *inf, struct room *r)
|
||||
{
|
||||
rs_read_coord(inf,&r->r_pos);
|
||||
rs_read_coord(inf,&r->r_max);
|
||||
|
|
@ -1186,7 +1186,7 @@ rs_read_room(int inf, struct room *r)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_rooms(int inf, struct room *r, int count)
|
||||
rs_read_rooms(FILE *inf, struct room *r, int count)
|
||||
{
|
||||
int value = 0, n = 0;
|
||||
|
||||
|
|
@ -1222,7 +1222,7 @@ rs_write_room_reference(FILE *savef, struct room *rp)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_room_reference(int inf, struct room **rp)
|
||||
rs_read_room_reference(FILE *inf, struct room **rp)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -1252,7 +1252,7 @@ rs_write_stats(FILE *savef, struct stats *s)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_stats(int inf, struct stats *s)
|
||||
rs_read_stats(FILE *inf, struct stats *s)
|
||||
{
|
||||
int id;
|
||||
|
||||
|
|
@ -1290,7 +1290,7 @@ rs_write_object(FILE *savef, THING *o)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_object(int inf, THING *o)
|
||||
rs_read_object(FILE *inf, THING *o)
|
||||
{
|
||||
int id;
|
||||
|
||||
|
|
@ -1339,7 +1339,7 @@ rs_write_object_list(FILE *savef, THING *l)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_object_list(int inf, THING **list)
|
||||
rs_read_object_list(FILE *inf, THING **list)
|
||||
{
|
||||
int id;
|
||||
int i, cnt;
|
||||
|
|
@ -1390,7 +1390,7 @@ rs_write_object_reference(FILE *savef, THING *list, THING *item)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_object_reference(int inf, THING *list, THING **item)
|
||||
rs_read_object_reference(FILE *inf, THING *list, THING **item)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -1566,7 +1566,7 @@ rs_fix_thing_list(THING *list)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_thing(int inf, THING *t)
|
||||
rs_read_thing(FILE *inf, THING *t)
|
||||
{
|
||||
int id;
|
||||
int listid = 0, index = -1;
|
||||
|
|
@ -1666,7 +1666,7 @@ rs_write_thing_list(FILE *savef, THING *l)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_thing_list(int inf, THING **list)
|
||||
rs_read_thing_list(FILE *inf, THING **list)
|
||||
{
|
||||
int id;
|
||||
int i, cnt;
|
||||
|
|
@ -1730,7 +1730,7 @@ rs_write_monsters(FILE *savef, struct monster *m, int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_monsters(int inf, struct monster *m, int count)
|
||||
rs_read_monsters(FILE *inf, struct monster *m, int count)
|
||||
{
|
||||
int id = 0, value = 0, n = 0;
|
||||
|
||||
|
|
@ -1774,11 +1774,11 @@ rs_write_scrolls(FILE *savef)
|
|||
rs_write_string(savef,s_guess[i]);
|
||||
}
|
||||
|
||||
return(READSTAT);
|
||||
return(WRITESTAT);
|
||||
}
|
||||
|
||||
int
|
||||
rs_read_scrolls(int inf)
|
||||
rs_read_scrolls(FILE *inf)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -1808,7 +1808,7 @@ rs_write_potions(FILE *savef)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_potions(int inf)
|
||||
rs_read_potions(FILE *inf)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -1843,7 +1843,7 @@ rs_write_rings(FILE *savef)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_rings(int inf)
|
||||
rs_read_rings(FILE *inf)
|
||||
{
|
||||
int i;
|
||||
const char *stones_list[NSTONES];
|
||||
|
|
@ -1886,7 +1886,7 @@ rs_write_sticks(FILE *savef)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_sticks(int inf)
|
||||
rs_read_sticks(FILE *inf)
|
||||
{
|
||||
int i = 0, list = 0;
|
||||
|
||||
|
|
@ -1931,7 +1931,7 @@ rs_write_thing_reference(FILE *savef, THING *list, THING *item)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_thing_reference(int inf, THING *list, THING **item)
|
||||
rs_read_thing_reference(FILE *inf, THING *list, THING **item)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -1961,7 +1961,7 @@ rs_write_thing_references(FILE *savef, THING *list, THING *items[], int count)
|
|||
}
|
||||
|
||||
int
|
||||
rs_read_thing_references(int inf, THING *list, THING *items[], int count)
|
||||
rs_read_thing_references(FILE *inf, THING *list, THING *items[], int count)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -2076,7 +2076,7 @@ rs_save_file(FILE *savef)
|
|||
}
|
||||
|
||||
int
|
||||
rs_restore_file(int inf)
|
||||
rs_restore_file(FILE *inf)
|
||||
{
|
||||
bool junk;
|
||||
THING *mitem;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue