1 | #include "config.h"
|
---|
2 | #include "f2c.h"
|
---|
3 | #include "fio.h"
|
---|
4 | extern uiolen f__reclen;
|
---|
5 | off_t f__recloc;
|
---|
6 |
|
---|
7 | #ifdef KR_headers
|
---|
8 | c_sue(a) cilist *a;
|
---|
9 | #else
|
---|
10 | c_sue(cilist *a)
|
---|
11 | #endif
|
---|
12 | {
|
---|
13 | f__external=f__sequential=1;
|
---|
14 | f__formatted=0;
|
---|
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(SEQ,UNF,a->ciunit))
|
---|
20 | err(a->cierr,114,"sue");
|
---|
21 | f__cf=f__curunit->ufd;
|
---|
22 | if(f__curunit->ufmt) err(a->cierr,103,"sue");
|
---|
23 | if(!f__curunit->useek) err(a->cierr,103,"sue");
|
---|
24 | return(0);
|
---|
25 | }
|
---|
26 | #ifdef KR_headers
|
---|
27 | integer s_rsue(a) cilist *a;
|
---|
28 | #else
|
---|
29 | integer s_rsue(cilist *a)
|
---|
30 | #endif
|
---|
31 | {
|
---|
32 | int n;
|
---|
33 | if(f__init != 1) f_init();
|
---|
34 | f__init = 3;
|
---|
35 | f__reading=1;
|
---|
36 | if(n=c_sue(a)) return(n);
|
---|
37 | f__recpos=0;
|
---|
38 | if(f__curunit->uwrt && f__nowreading(f__curunit))
|
---|
39 | err(a->cierr, errno, "read start");
|
---|
40 | if(fread((char *)&f__reclen,sizeof(uiolen),1,f__cf)
|
---|
41 | != 1)
|
---|
42 | { if(feof(f__cf))
|
---|
43 | { f__curunit->uend = 1;
|
---|
44 | err(a->ciend, EOF, "start");
|
---|
45 | }
|
---|
46 | clearerr(f__cf);
|
---|
47 | err(a->cierr, errno, "start");
|
---|
48 | }
|
---|
49 | return(0);
|
---|
50 | }
|
---|
51 | #ifdef KR_headers
|
---|
52 | integer s_wsue(a) cilist *a;
|
---|
53 | #else
|
---|
54 | integer s_wsue(cilist *a)
|
---|
55 | #endif
|
---|
56 | {
|
---|
57 | int n;
|
---|
58 | if(f__init != 1) f_init();
|
---|
59 | f__init = 3;
|
---|
60 | if(n=c_sue(a)) return(n);
|
---|
61 | f__reading=0;
|
---|
62 | f__reclen=0;
|
---|
63 | if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
|
---|
64 | err(a->cierr, errno, "write start");
|
---|
65 | f__recloc=FTELL(f__cf);
|
---|
66 | FSEEK(f__cf,(off_t)sizeof(uiolen),SEEK_CUR);
|
---|
67 | return(0);
|
---|
68 | }
|
---|
69 | integer e_wsue(Void)
|
---|
70 | { off_t loc;
|
---|
71 | f__init = 1;
|
---|
72 | fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
|
---|
73 | #ifdef ALWAYS_FLUSH
|
---|
74 | if (fflush(f__cf))
|
---|
75 | err(f__elist->cierr, errno, "write end");
|
---|
76 | #endif
|
---|
77 | loc=FTELL(f__cf);
|
---|
78 | FSEEK(f__cf,f__recloc,SEEK_SET);
|
---|
79 | fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
|
---|
80 | FSEEK(f__cf,loc,SEEK_SET);
|
---|
81 | return(0);
|
---|
82 | }
|
---|
83 | integer e_rsue(Void)
|
---|
84 | {
|
---|
85 | f__init = 1;
|
---|
86 | FSEEK(f__cf,(off_t)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR);
|
---|
87 | return(0);
|
---|
88 | }
|
---|