Commit | Line | Data |
---|---|---|
bae7117f WH |
1 | #include "f2c.h" |
2 | #include "fio.h" | |
3 | extern uiolen f__reclen; | |
4 | long f__recloc; | |
5 | ||
6 | #ifdef KR_headers | |
7 | c_sue(a) cilist *a; | |
8 | #else | |
9 | c_sue(cilist *a) | |
10 | #endif | |
11 | { | |
12 | if(a->ciunit >= MXUNIT || a->ciunit < 0) | |
13 | err(a->cierr,101,"startio"); | |
14 | f__external=f__sequential=1; | |
15 | f__formatted=0; | |
16 | f__curunit = &f__units[a->ciunit]; | |
17 | f__elist=a; | |
18 | if(f__curunit->ufd==NULL && fk_open(SEQ,UNF,a->ciunit)) | |
19 | err(a->cierr,114,"sue"); | |
20 | f__cf=f__curunit->ufd; | |
21 | if(f__curunit->ufmt) err(a->cierr,103,"sue") | |
22 | if(!f__curunit->useek) err(a->cierr,103,"sue") | |
23 | return(0); | |
24 | } | |
25 | #ifdef KR_headers | |
26 | integer s_rsue(a) cilist *a; | |
27 | #else | |
28 | integer s_rsue(cilist *a) | |
29 | #endif | |
30 | { | |
31 | int n; | |
32 | if(!f__init) f_init(); | |
33 | f__reading=1; | |
34 | if(n=c_sue(a)) return(n); | |
35 | f__recpos=0; | |
36 | if(f__curunit->uwrt && f__nowreading(f__curunit)) | |
37 | err(a->cierr, errno, "read start"); | |
38 | if(fread((char *)&f__reclen,sizeof(uiolen),1,f__cf) | |
39 | != 1) | |
40 | { if(feof(f__cf)) | |
41 | { f__curunit->uend = 1; | |
42 | err(a->ciend, EOF, "start"); | |
43 | } | |
44 | clearerr(f__cf); | |
45 | err(a->cierr, errno, "start"); | |
46 | } | |
47 | return(0); | |
48 | } | |
49 | #ifdef KR_headers | |
50 | integer s_wsue(a) cilist *a; | |
51 | #else | |
52 | integer s_wsue(cilist *a) | |
53 | #endif | |
54 | { | |
55 | int n; | |
56 | if(!f__init) f_init(); | |
57 | if(n=c_sue(a)) return(n); | |
58 | f__reading=0; | |
59 | f__reclen=0; | |
60 | if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) | |
61 | err(a->cierr, errno, "write start"); | |
62 | f__recloc=ftell(f__cf); | |
63 | (void) fseek(f__cf,(long)sizeof(uiolen),SEEK_CUR); | |
64 | return(0); | |
65 | } | |
66 | integer e_wsue(Void) | |
67 | { long loc; | |
68 | (void) fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf); | |
69 | loc=ftell(f__cf); | |
70 | (void) fseek(f__cf,f__recloc,SEEK_SET); | |
71 | (void) fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf); | |
72 | (void) fseek(f__cf,loc,SEEK_SET); | |
73 | return(0); | |
74 | } | |
75 | integer e_rsue(Void) | |
76 | { | |
77 | (void) fseek(f__cf,(long)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR); | |
78 | return(0); | |
79 | } |