1 #include "v3p_f2c.h"
2 #include "fio.h"
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 uiolen f__reclen;
7
8 int
9 #ifdef KR_headers
do_us(number,ptr,len)10 do_us(number,ptr,len) ftnint *number; char *ptr; ftnlen len;
11 #else
12 do_us(ftnint *number, char *ptr, ftnlen len)
13 #endif
14 {
15 if(f__reading)
16 {
17 f__recpos += (int)(*number * len);
18 if(f__recpos>f__reclen)
19 err(f__elist->cierr, 110, "do_us");
20 if (fread(ptr,(int)len,(int)(*number),f__cf) != *number)
21 err(f__elist->ciend, EOF, "do_us");
22 return(0);
23 }
24 else
25 {
26 f__reclen += *number * len;
27 (void) fwrite(ptr,(int)len,(int)(*number),f__cf);
28 return(0);
29 }
30 }
31 #ifdef KR_headers
do_ud(number,ptr,len)32 integer do_ud(number,ptr,len) ftnint *number; char *ptr; ftnlen len;
33 #else
34 integer do_ud(ftnint *number, char *ptr, ftnlen len)
35 #endif
36 {
37 f__recpos += (int)(*number * len);
38 if(f__recpos > f__curunit->url && f__curunit->url!=1)
39 err(f__elist->cierr,110,"do_ud");
40 if(f__reading)
41 {
42 #ifdef Pad_UDread
43 #ifdef KR_headers
44 int i;
45 #else
46 size_t i;
47 #endif
48 if (!(i = fread(ptr,(int)len,(int)(*number),f__cf))
49 && !(f__recpos - *number*len))
50 err(f__elist->cierr,EOF,"do_ud")
51 if (i < *number)
52 memset(ptr + i*len, 0, (*number - i)*len);
53 return 0;
54 #else
55 if(fread(ptr,(int)len,(int)(*number),f__cf) != *number)
56 err(f__elist->cierr,EOF,"do_ud")
57 else return(0);
58 #endif
59 }
60 (void) fwrite(ptr,(int)len,(int)(*number),f__cf);
61 return(0);
62 }
63 #ifdef KR_headers
do_uio(number,ptr,len)64 integer do_uio(number,ptr,len) ftnint *number; char *ptr; ftnlen len;
65 #else
66 integer do_uio(ftnint *number, char *ptr, ftnlen len)
67 #endif
68 {
69 if(f__sequential)
70 return(do_us(number,ptr,len));
71 else return(do_ud(number,ptr,len));
72 }
73 #ifdef __cplusplus
74 }
75 #endif
76