* Makefile.am (nat_source_files): Remove
[official-gcc.git] / libf2c / libI77 / uio.c
blob706b5dd3d9c231df7e1c9f7aa43294a2c53b268a
1 #include "config.h"
2 #include "f2c.h"
3 #include "fio.h"
4 #include <sys/types.h>
5 uiolen f__reclen;
7 int
8 do_us (ftnint * number, char *ptr, ftnlen len)
10 if (f__reading)
12 f__recpos += (int) (*number * len);
13 if (f__recpos > f__reclen)
14 err (f__elist->cierr, 110, "do_us");
15 if (fread (ptr, (size_t) len, (size_t) (*number), f__cf) != (size_t) *number)
16 err (f__elist->ciend, EOF, "do_us");
17 return (0);
19 else
21 f__reclen += *number * len;
22 (void) fwrite (ptr, (size_t) len, (size_t) (*number), f__cf);
23 return (0);
26 integer
27 do_ud (ftnint * number, char *ptr, ftnlen len)
29 f__recpos += (int) (*number * len);
30 if (f__recpos > f__curunit->url && f__curunit->url != 1)
31 err (f__elist->cierr, 110, "do_ud");
32 if (f__reading)
34 #ifdef Pad_UDread
35 size_t i;
36 if (!(i = fread (ptr, (size_t) len, (size_t) (*number), f__cf))
37 && !(f__recpos - *number * len))
38 err (f__elist->cierr, EOF, "do_ud");
39 if (i < (size_t) *number)
40 memset (ptr + i * len, 0, (*number - i) * len);
41 return 0;
42 #else
43 if (fread (ptr, (size_t) len, (size_t) (*number), f__cf) != *number)
44 err (f__elist->cierr, EOF, "do_ud");
45 else
46 return (0);
47 #endif
49 (void) fwrite (ptr, (size_t) len, (size_t) (*number), f__cf);
50 return (0);
53 integer
54 do_uio (ftnint * number, char *ptr, ftnlen len)
56 if (f__sequential)
57 return (do_us (number, ptr, len));
58 else
59 return (do_ud (number, ptr, len));