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