comparison arogue7/state.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 b49d8b963df3
children e52a8a7ad4c5
comparison
equal deleted inserted replaced
278:c222f9d56776 279:d3968e9cb98d
73 static int endian = 0x01020304; 73 static int endian = 0x01020304;
74 #define big_endian ( *((char *)&endian) == 0x01 ) 74 #define big_endian ( *((char *)&endian) == 0x01 )
75 75
76 int list_size(struct linked_list *l); 76 int list_size(struct linked_list *l);
77 int rs_write_int(FILE *savef, int c); 77 int rs_write_int(FILE *savef, int c);
78 int rs_read_int(int inf, int *i); 78 int rs_read_int(FILE *inf, int *i);
79 int rs_write_object_list(FILE *savef, struct linked_list *l); 79 int rs_write_object_list(FILE *savef, struct linked_list *l);
80 int rs_read_object_list(int inf, struct linked_list **list); 80 int rs_read_object_list(FILE *inf, struct linked_list **list);
81 81
82 int 82 int
83 rs_write(FILE *savef, void *ptr, size_t size) 83 rs_write(FILE *savef, void *ptr, size_t size)
84 { 84 {
85 if (write_error) 85 if (write_error)
86 return(WRITESTAT); 86 return(WRITESTAT);
87 87
88 if (encwrite(ptr, size, md_fileno(savef)) != size) 88 if (encwrite(ptr, size, savef) != size)
89 write_error = 1; 89 write_error = 1;
90 90
91 return(WRITESTAT); 91 return(WRITESTAT);
92 } 92 }
93 93
94 int 94 int
95 rs_read(int inf, void *ptr, size_t size) 95 rs_read(FILE *inf, void *ptr, size_t size)
96 { 96 {
97 if (read_error || format_error) 97 if (read_error || format_error)
98 return(READSTAT); 98 return(READSTAT);
99 99
100 if (encread(ptr, size, inf) != size) 100 if (encread(ptr, size, inf) != size)
113 113
114 return(WRITESTAT); 114 return(WRITESTAT);
115 } 115 }
116 116
117 int 117 int
118 rs_read_uchar(int inf, unsigned char *c) 118 rs_read_uchar(FILE *inf, unsigned char *c)
119 { 119 {
120 if (read_error || format_error) 120 if (read_error || format_error)
121 return(READSTAT); 121 return(READSTAT);
122 122
123 rs_read(inf, c, 1); 123 rs_read(inf, c, 1);
135 135
136 return(WRITESTAT); 136 return(WRITESTAT);
137 } 137 }
138 138
139 int 139 int
140 rs_read_char(int inf, char *c) 140 rs_read_char(FILE *inf, char *c)
141 { 141 {
142 if (read_error || format_error) 142 if (read_error || format_error)
143 return(READSTAT); 143 return(READSTAT);
144 144
145 rs_read(inf, c, 1); 145 rs_read(inf, c, 1);
158 158
159 return(WRITESTAT); 159 return(WRITESTAT);
160 } 160 }
161 161
162 int 162 int
163 rs_read_chars(int inf, char *i, int count) 163 rs_read_chars(FILE *inf, char *i, int count)
164 { 164 {
165 int value = 0; 165 int value = 0;
166 166
167 if (read_error || format_error) 167 if (read_error || format_error)
168 return(READSTAT); 168 return(READSTAT);
199 199
200 return(WRITESTAT); 200 return(WRITESTAT);
201 } 201 }
202 202
203 int 203 int
204 rs_read_int(int inf, int *i) 204 rs_read_int(FILE *inf, int *i)
205 { 205 {
206 unsigned char bytes[4]; 206 unsigned char bytes[4];
207 int input = 0; 207 int input = 0;
208 unsigned char *buf = (unsigned char *)&input; 208 unsigned char *buf = (unsigned char *)&input;
209 209
242 242
243 return(WRITESTAT); 243 return(WRITESTAT);
244 } 244 }
245 245
246 int 246 int
247 rs_read_ints(int inf, int *i, int count) 247 rs_read_ints(FILE *inf, int *i, int count)
248 { 248 {
249 int n, value; 249 int n, value;
250 250
251 if (read_error || format_error) 251 if (read_error || format_error)
252 return(READSTAT); 252 return(READSTAT);
275 275
276 return(WRITESTAT); 276 return(WRITESTAT);
277 } 277 }
278 278
279 int 279 int
280 rs_read_boolean(int inf, bool *i) 280 rs_read_boolean(FILE *inf, bool *i)
281 { 281 {
282 unsigned char buf = 0; 282 unsigned char buf = 0;
283 283
284 if (read_error || format_error) 284 if (read_error || format_error)
285 return(READSTAT); 285 return(READSTAT);
307 307
308 return(WRITESTAT); 308 return(WRITESTAT);
309 } 309 }
310 310
311 int 311 int
312 rs_read_booleans(int inf, bool *i, int count) 312 rs_read_booleans(FILE *inf, bool *i, int count)
313 { 313 {
314 int n = 0, value = 0; 314 int n = 0, value = 0;
315 315
316 if (read_error || format_error) 316 if (read_error || format_error)
317 return(READSTAT); 317 return(READSTAT);
348 348
349 return(WRITESTAT); 349 return(WRITESTAT);
350 } 350 }
351 351
352 int 352 int
353 rs_read_short(int inf, short *i) 353 rs_read_short(FILE *inf, short *i)
354 { 354 {
355 unsigned char bytes[2]; 355 unsigned char bytes[2];
356 short input; 356 short input;
357 unsigned char *buf = (unsigned char *)&input; 357 unsigned char *buf = (unsigned char *)&input;
358 358
389 389
390 return(WRITESTAT); 390 return(WRITESTAT);
391 } 391 }
392 392
393 int 393 int
394 rs_read_shorts(int inf, short *i, int count) 394 rs_read_shorts(FILE *inf, short *i, int count)
395 { 395 {
396 int n = 0, value = 0; 396 int n = 0, value = 0;
397 397
398 if (read_error || format_error) 398 if (read_error || format_error)
399 return(READSTAT); 399 return(READSTAT);
430 430
431 return(WRITESTAT); 431 return(WRITESTAT);
432 } 432 }
433 433
434 int 434 int
435 rs_read_ushort(int inf, unsigned short *i) 435 rs_read_ushort(FILE *inf, unsigned short *i)
436 { 436 {
437 unsigned char bytes[2]; 437 unsigned char bytes[2];
438 unsigned short input; 438 unsigned short input;
439 unsigned char *buf = (unsigned char *)&input; 439 unsigned char *buf = (unsigned char *)&input;
440 440
477 477
478 return(WRITESTAT); 478 return(WRITESTAT);
479 } 479 }
480 480
481 int 481 int
482 rs_read_uint(int inf, unsigned int *i) 482 rs_read_uint(FILE *inf, unsigned int *i)
483 { 483 {
484 unsigned char bytes[4]; 484 unsigned char bytes[4];
485 int input; 485 int input;
486 unsigned char *buf = (unsigned char *)&input; 486 unsigned char *buf = (unsigned char *)&input;
487 487
533 533
534 return(WRITESTAT); 534 return(WRITESTAT);
535 } 535 }
536 536
537 int 537 int
538 rs_read_long(int inf, long *i) 538 rs_read_long(FILE *inf, long *i)
539 { 539 {
540 unsigned char bytes[4]; 540 unsigned char bytes[4];
541 long input; 541 long input;
542 unsigned char *buf = (unsigned char *) &input; 542 unsigned char *buf = (unsigned char *) &input;
543 543
578 578
579 return(WRITESTAT); 579 return(WRITESTAT);
580 } 580 }
581 581
582 int 582 int
583 rs_read_longs(int inf, long *i, int count) 583 rs_read_longs(FILE *inf, long *i, int count)
584 { 584 {
585 int n = 0, value = 0; 585 int n = 0, value = 0;
586 586
587 if (read_error || format_error) 587 if (read_error || format_error)
588 return(READSTAT); 588 return(READSTAT);
628 628
629 return(WRITESTAT); 629 return(WRITESTAT);
630 } 630 }
631 631
632 int 632 int
633 rs_read_ulong(int inf, unsigned long *i) 633 rs_read_ulong(FILE *inf, unsigned long *i)
634 { 634 {
635 unsigned char bytes[4]; 635 unsigned char bytes[4];
636 unsigned long input; 636 unsigned long input;
637 unsigned char *buf = (unsigned char *) &input; 637 unsigned char *buf = (unsigned char *) &input;
638 638
674 674
675 return(WRITESTAT); 675 return(WRITESTAT);
676 } 676 }
677 677
678 int 678 int
679 rs_read_ulongs(int inf, unsigned long *i, int count) 679 rs_read_ulongs(FILE *inf, unsigned long *i, int count)
680 { 680 {
681 int n = 0, value = 0; 681 int n = 0, value = 0;
682 682
683 if (read_error || format_error) 683 if (read_error || format_error)
684 return(READSTAT); 684 return(READSTAT);
705 705
706 return(WRITESTAT); 706 return(WRITESTAT);
707 } 707 }
708 708
709 int 709 int
710 rs_read_marker(int inf, int id) 710 rs_read_marker(FILE *inf, int id)
711 { 711 {
712 int nid; 712 int nid;
713 713
714 if (read_error || format_error) 714 if (read_error || format_error)
715 return(READSTAT); 715 return(READSTAT);
740 740
741 return(WRITESTAT); 741 return(WRITESTAT);
742 } 742 }
743 743
744 int 744 int
745 rs_read_string(int inf, char *s, int max) 745 rs_read_string(FILE *inf, char *s, int max)
746 { 746 {
747 int len = 0; 747 int len = 0;
748 748
749 if (read_error || format_error) 749 if (read_error || format_error)
750 return(READSTAT); 750 return(READSTAT);
758 758
759 return(READSTAT); 759 return(READSTAT);
760 } 760 }
761 761
762 int 762 int
763 rs_read_new_string(int inf, char **s) 763 rs_read_new_string(FILE *inf, char **s)
764 { 764 {
765 int len=0; 765 int len=0;
766 char *buf=0; 766 char *buf=0;
767 767
768 if (read_error || format_error) 768 if (read_error || format_error)
803 803
804 return(WRITESTAT); 804 return(WRITESTAT);
805 } 805 }
806 806
807 int 807 int
808 rs_read_strings(int inf, char **s, int count, int max) 808 rs_read_strings(FILE *inf, char **s, int count, int max)
809 { 809 {
810 int n = 0; 810 int n = 0;
811 int value = 0; 811 int value = 0;
812 812
813 if (read_error || format_error) 813 if (read_error || format_error)
824 824
825 return(READSTAT); 825 return(READSTAT);
826 } 826 }
827 827
828 int 828 int
829 rs_read_new_strings(int inf, char **s, int count) 829 rs_read_new_strings(FILE *inf, char **s, int count)
830 { 830 {
831 int n = 0; 831 int n = 0;
832 int value = 0; 832 int value = 0;
833 833
834 if (read_error || format_error) 834 if (read_error || format_error)
860 860
861 return( rs_write_int(savef,-1) ); 861 return( rs_write_int(savef,-1) );
862 } 862 }
863 863
864 int 864 int
865 rs_read_string_index(int inf, char *master[], int maxindex, char **str) 865 rs_read_string_index(FILE *inf, char *master[], int maxindex, char **str)
866 { 866 {
867 int i; 867 int i;
868 868
869 if (read_error || format_error) 869 if (read_error || format_error)
870 return(READSTAT); 870 return(READSTAT);
892 892
893 return(WRITESTAT); 893 return(WRITESTAT);
894 } 894 }
895 895
896 int 896 int
897 rs_read_coord(int inf, coord *c) 897 rs_read_coord(FILE *inf, coord *c)
898 { 898 {
899 coord in; 899 coord in;
900 900
901 if (read_error || format_error) 901 if (read_error || format_error)
902 return(READSTAT); 902 return(READSTAT);
927 927
928 return(WRITESTAT); 928 return(WRITESTAT);
929 } 929 }
930 930
931 int 931 int
932 rs_read_coord_list(int inf, struct linked_list **list) 932 rs_read_coord_list(FILE *inf, struct linked_list **list)
933 { 933 {
934 int i, cnt; 934 int i, cnt;
935 struct linked_list *l = NULL, *previous = NULL, *head = NULL; 935 struct linked_list *l = NULL, *previous = NULL, *head = NULL;
936 936
937 rs_read_marker(inf, RSID_COORDLIST); 937 rs_read_marker(inf, RSID_COORDLIST);
985 985
986 return(WRITESTAT); 986 return(WRITESTAT);
987 } 987 }
988 988
989 int 989 int
990 rs_read_window(int inf, WINDOW *win) 990 rs_read_window(FILE *inf, WINDOW *win)
991 { 991 {
992 int row,col,maxlines,maxcols,value,width,height; 992 int row,col,maxlines,maxcols,value,width,height;
993 993
994 if (read_error || format_error) 994 if (read_error || format_error)
995 return(READSTAT); 995 return(READSTAT);
1073 1073
1074 return(WRITESTAT); 1074 return(WRITESTAT);
1075 } 1075 }
1076 1076
1077 int 1077 int
1078 rs_read_levtype(int inf, LEVTYPE *l) 1078 rs_read_levtype(FILE *inf, LEVTYPE *l)
1079 { 1079 {
1080 int lt; 1080 int lt;
1081 1081
1082 rs_read_int(inf, &lt); 1082 rs_read_int(inf, &lt);
1083 1083
1118 1118
1119 return(WRITESTAT); 1119 return(WRITESTAT);
1120 } 1120 }
1121 1121
1122 int 1122 int
1123 rs_read_stats(int inf, struct stats *s) 1123 rs_read_stats(FILE *inf, struct stats *s)
1124 { 1124 {
1125 if (read_error || format_error) 1125 if (read_error || format_error)
1126 return(READSTAT); 1126 return(READSTAT);
1127 1127
1128 rs_read_marker(inf, RSID_STATS); 1128 rs_read_marker(inf, RSID_STATS);
1163 1163
1164 return(WRITESTAT); 1164 return(WRITESTAT);
1165 } 1165 }
1166 1166
1167 int 1167 int
1168 rs_read_magic_items(int inf, struct magic_item *mi, int count) 1168 rs_read_magic_items(FILE *inf, struct magic_item *mi, int count)
1169 { 1169 {
1170 int n; 1170 int n;
1171 int value; 1171 int value;
1172 1172
1173 rs_read_marker(inf, RSID_MAGICITEMS); 1173 rs_read_marker(inf, RSID_MAGICITEMS);
1208 1208
1209 return(WRITESTAT); 1209 return(WRITESTAT);
1210 } 1210 }
1211 1211
1212 int 1212 int
1213 rs_read_scrolls(int inf) 1213 rs_read_scrolls(FILE *inf)
1214 { 1214 {
1215 int i; 1215 int i;
1216 1216
1217 if (read_error || format_error) 1217 if (read_error || format_error)
1218 return(READSTAT); 1218 return(READSTAT);
1244 1244
1245 return(WRITESTAT); 1245 return(WRITESTAT);
1246 } 1246 }
1247 1247
1248 int 1248 int
1249 rs_read_potions(int inf) 1249 rs_read_potions(FILE *inf)
1250 { 1250 {
1251 int i; 1251 int i;
1252 1252
1253 if (read_error || format_error) 1253 if (read_error || format_error)
1254 return(READSTAT); 1254 return(READSTAT);
1280 1280
1281 return(WRITESTAT); 1281 return(WRITESTAT);
1282 } 1282 }
1283 1283
1284 int 1284 int
1285 rs_read_rings(int inf) 1285 rs_read_rings(FILE *inf)
1286 { 1286 {
1287 int i; 1287 int i;
1288 1288
1289 if (read_error || format_error) 1289 if (read_error || format_error)
1290 return(READSTAT); 1290 return(READSTAT);
1315 1315
1316 return(READSTAT); 1316 return(READSTAT);
1317 } 1317 }
1318 1318
1319 int 1319 int
1320 rs_read_misc(int inf) 1320 rs_read_misc(FILE *inf)
1321 { 1321 {
1322 int i; 1322 int i;
1323 1323
1324 if (write_error) 1324 if (write_error)
1325 return(WRITESTAT); 1325 return(WRITESTAT);
1362 1362
1363 return(WRITESTAT); 1363 return(WRITESTAT);
1364 } 1364 }
1365 1365
1366 int 1366 int
1367 rs_read_sticks(int inf) 1367 rs_read_sticks(FILE *inf)
1368 { 1368 {
1369 int i = 0, j = 0, list = 0; 1369 int i = 0, j = 0, list = 0;
1370 1370
1371 if (read_error || format_error) 1371 if (read_error || format_error)
1372 return(READSTAT); 1372 return(READSTAT);
1586 1586
1587 return(WRITESTAT); 1587 return(WRITESTAT);
1588 } 1588 }
1589 1589
1590 int 1590 int
1591 rs_read_daemons(int inf, struct delayed_action *d_list, int count) 1591 rs_read_daemons(FILE *inf, struct delayed_action *d_list, int count)
1592 { 1592 {
1593 int i = 0; 1593 int i = 0;
1594 int func = 0; 1594 int func = 0;
1595 int value = 0; 1595 int value = 0;
1596 int dummy = 0; 1596 int dummy = 0;
1772 1772
1773 return(WRITESTAT); 1773 return(WRITESTAT);
1774 } 1774 }
1775 1775
1776 int 1776 int
1777 rs_read_room(int inf, struct room *r) 1777 rs_read_room(FILE *inf, struct room *r)
1778 { 1778 {
1779 int value = 0, n = 0, i = 0, index = 0, id = 0; 1779 int value = 0, n = 0, i = 0, index = 0, id = 0;
1780 struct linked_list *fires=NULL, *item = NULL; 1780 struct linked_list *fires=NULL, *item = NULL;
1781 1781
1782 if (read_error || format_error) 1782 if (read_error || format_error)
1829 1829
1830 return(WRITESTAT); 1830 return(WRITESTAT);
1831 } 1831 }
1832 1832
1833 int 1833 int
1834 rs_read_rooms(int inf, struct room *r, int count) 1834 rs_read_rooms(FILE *inf, struct room *r, int count)
1835 { 1835 {
1836 int value = 0, n = 0; 1836 int value = 0, n = 0;
1837 1837
1838 if (read_error || format_error) 1838 if (read_error || format_error)
1839 return(READSTAT); 1839 return(READSTAT);
1865 1865
1866 return(WRITESTAT); 1866 return(WRITESTAT);
1867 } 1867 }
1868 1868
1869 int 1869 int
1870 rs_read_room_reference(int inf, struct room **rp) 1870 rs_read_room_reference(FILE *inf, struct room **rp)
1871 { 1871 {
1872 int i; 1872 int i;
1873 1873
1874 if (read_error || format_error) 1874 if (read_error || format_error)
1875 return(READSTAT); 1875 return(READSTAT);
1909 1909
1910 return(WRITESTAT); 1910 return(WRITESTAT);
1911 } 1911 }
1912 1912
1913 int 1913 int
1914 rs_read_door_reference(int inf, coord **exit) 1914 rs_read_door_reference(FILE *inf, coord **exit)
1915 { 1915 {
1916 int i, idx; 1916 int i, idx;
1917 1917
1918 rs_read_int(inf, &i); 1918 rs_read_int(inf, &i);
1919 rs_read_int(inf, &idx); 1919 rs_read_int(inf, &idx);
1943 } 1943 }
1944 return (WRITESTAT); 1944 return (WRITESTAT);
1945 } 1945 }
1946 1946
1947 int 1947 int
1948 rs_read_traps(int inf, struct trap *trap, int count) 1948 rs_read_traps(FILE *inf, struct trap *trap, int count)
1949 { 1949 {
1950 int id = 0, value = 0, n = 0; 1950 int id = 0, value = 0, n = 0;
1951 1951
1952 if (rs_read_int(inf,&id) != 0) 1952 if (rs_read_int(inf,&id) != 0)
1953 format_error = TRUE; 1953 format_error = TRUE;
1990 1990
1991 return(WRITESTAT); 1991 return(WRITESTAT);
1992 } 1992 }
1993 1993
1994 int 1994 int
1995 rs_read_monsters(int inf, struct monster *m, int count) 1995 rs_read_monsters(FILE *inf, struct monster *m, int count)
1996 { 1996 {
1997 int value = 0, n = 0; 1997 int value = 0, n = 0;
1998 1998
1999 if (read_error || format_error) 1999 if (read_error || format_error)
2000 return(READSTAT); 2000 return(READSTAT);
2042 2042
2043 return(WRITESTAT); 2043 return(WRITESTAT);
2044 } 2044 }
2045 2045
2046 int 2046 int
2047 rs_read_object(int inf, struct object *o) 2047 rs_read_object(FILE *inf, struct object *o)
2048 { 2048 {
2049 if (read_error || format_error) 2049 if (read_error || format_error)
2050 return(READSTAT); 2050 return(READSTAT);
2051 2051
2052 rs_read_marker(inf, RSID_OBJECT); 2052 rs_read_marker(inf, RSID_OBJECT);
2083 2083
2084 return(WRITESTAT); 2084 return(WRITESTAT);
2085 } 2085 }
2086 2086
2087 int 2087 int
2088 rs_read_object_list(int inf, struct linked_list **list) 2088 rs_read_object_list(FILE *inf, struct linked_list **list)
2089 { 2089 {
2090 int i, cnt; 2090 int i, cnt;
2091 struct linked_list *l = NULL, *previous = NULL, *head = NULL; 2091 struct linked_list *l = NULL, *previous = NULL, *head = NULL;
2092 2092
2093 if (read_error || format_error) 2093 if (read_error || format_error)
2135 2135
2136 return(WRITESTAT); 2136 return(WRITESTAT);
2137 } 2137 }
2138 2138
2139 int 2139 int
2140 rs_read_object_reference(int inf, struct linked_list *list, struct object **item) 2140 rs_read_object_reference(FILE *inf, struct linked_list *list, struct object **item)
2141 { 2141 {
2142 int i; 2142 int i;
2143 2143
2144 if (read_error || format_error) 2144 if (read_error || format_error)
2145 return(READSTAT); 2145 return(READSTAT);
2278 2278
2279 return(WRITESTAT); 2279 return(WRITESTAT);
2280 } 2280 }
2281 2281
2282 int 2282 int
2283 rs_read_thing(int inf, struct thing *t) 2283 rs_read_thing(FILE *inf, struct thing *t)
2284 { 2284 {
2285 int listid = 0, index = -1; 2285 int listid = 0, index = -1;
2286 2286
2287 if (read_error || format_error) 2287 if (read_error || format_error)
2288 return(READSTAT); 2288 return(READSTAT);
2393 2393
2394 return(WRITESTAT); 2394 return(WRITESTAT);
2395 } 2395 }
2396 2396
2397 int 2397 int
2398 rs_read_thing_list(int inf, struct linked_list **list) 2398 rs_read_thing_list(FILE *inf, struct linked_list **list)
2399 { 2399 {
2400 int i, cnt; 2400 int i, cnt;
2401 struct linked_list *l = NULL, *previous = NULL, *head = NULL; 2401 struct linked_list *l = NULL, *previous = NULL, *head = NULL;
2402 2402
2403 if (read_error || format_error) 2403 if (read_error || format_error)
2460 2460
2461 return(WRITESTAT); 2461 return(WRITESTAT);
2462 } 2462 }
2463 2463
2464 int 2464 int
2465 rs_read_thing_reference(int inf, struct linked_list *list, struct thing **item) 2465 rs_read_thing_reference(FILE *inf, struct linked_list *list, struct thing **item)
2466 { 2466 {
2467 int i; 2467 int i;
2468 2468
2469 if (read_error || format_error) 2469 if (read_error || format_error)
2470 return(READSTAT); 2470 return(READSTAT);
2492 2492
2493 return(WRITESTAT); 2493 return(WRITESTAT);
2494 } 2494 }
2495 2495
2496 int 2496 int
2497 rs_read_thing_references(int inf, struct linked_list *list, struct thing *items[], int count) 2497 rs_read_thing_references(FILE *inf, struct linked_list *list, struct thing *items[], int count)
2498 { 2498 {
2499 int i; 2499 int i;
2500 2500
2501 if (read_error || format_error) 2501 if (read_error || format_error)
2502 return(READSTAT); 2502 return(READSTAT);
2633 2633
2634 return(WRITESTAT); 2634 return(WRITESTAT);
2635 } 2635 }
2636 2636
2637 int 2637 int
2638 rs_restore_file(int inf) 2638 rs_restore_file(FILE *inf)
2639 { 2639 {
2640 int i; 2640 int i;
2641 2641
2642 if (read_error || format_error) 2642 if (read_error || format_error)
2643 return(READSTAT); 2643 return(READSTAT);