source: vendor/gcc/3.3.4/libf2c/libI77/due.c

Last change on this file was 1391, checked in by bird, 21 years ago

GCC v3.3.3 sources.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#include "config.h"
2#include "f2c.h"
3#include "fio.h"
4
5int
6c_due (cilist * a)
7{
8 if (f__init != 1)
9 f_init ();
10 f__init = 3;
11 if (a->ciunit >= MXUNIT || a->ciunit < 0)
12 err (a->cierr, 101, "startio");
13 f__sequential = f__formatted = f__recpos = 0;
14 f__external = 1;
15 f__curunit = &f__units[a->ciunit];
16 if (a->ciunit >= MXUNIT || a->ciunit < 0)
17 err (a->cierr, 101, "startio");
18 f__elist = a;
19 if (f__curunit->ufd == NULL && fk_open (DIR, UNF, a->ciunit))
20 err (a->cierr, 104, "due");
21 f__cf = f__curunit->ufd;
22 if (f__curunit->ufmt)
23 err (a->cierr, 102, "cdue");
24 if (!f__curunit->useek)
25 err (a->cierr, 104, "cdue");
26 if (f__curunit->ufd == NULL)
27 err (a->cierr, 114, "cdue");
28 if (a->cirec <= 0)
29 err (a->cierr, 130, "due");
30 FSEEK (f__cf, (off_t) (a->cirec - 1) * f__curunit->url, SEEK_SET);
31 f__curunit->uend = 0;
32 return (0);
33}
34
35integer
36s_rdue (cilist * a)
37{
38 int n;
39 f__reading = 1;
40 if ((n = c_due (a)))
41 return (n);
42 if (f__curunit->uwrt && f__nowreading (f__curunit))
43 err (a->cierr, errno, "read start");
44 return (0);
45}
46
47integer
48s_wdue (cilist * a)
49{
50 int n;
51 f__reading = 0;
52 if ((n = c_due (a)))
53 return (n);
54 if (f__curunit->uwrt != 1 && f__nowwriting (f__curunit))
55 err (a->cierr, errno, "write start");
56 return (0);
57}
58
59integer
60e_rdue (void)
61{
62 f__init = 1;
63 if (f__curunit->url == 1 || f__recpos == f__curunit->url)
64 return (0);
65 FSEEK (f__cf, (off_t) (f__curunit->url - f__recpos), SEEK_CUR);
66 if (FTELL (f__cf) % f__curunit->url)
67 err (f__elist->cierr, 200, "syserr");
68 return (0);
69}
70
71integer
72e_wdue (void)
73{
74 f__init = 1;
75#ifdef ALWAYS_FLUSH
76 if (fflush (f__cf))
77 err (f__elist->cierr, errno, "write end");
78#endif
79 return (e_rdue ());
80}
Note: See TracBrowser for help on using the repository browser.