| 1 |
#include "f2c.h" |
| 2 |
#include "fio.h" |
| 3 |
#ifdef __cplusplus |
| 4 |
extern "C" { |
| 5 |
#endif |
| 6 |
|
| 7 |
int |
| 8 |
#ifdef KR_headers |
| 9 |
c_due(a) cilist *a; |
| 10 |
#else |
| 11 |
c_due(cilist *a) |
| 12 |
#endif |
| 13 |
{ |
| 14 |
if(!f__init) f_init(); |
| 15 |
f__sequential=f__formatted=f__recpos=0; |
| 16 |
f__external=1; |
| 17 |
f__curunit = &f__units[a->ciunit]; |
| 18 |
if(a->ciunit>=MXUNIT || a->ciunit<0) |
| 19 |
err(a->cierr,101,"startio"); |
| 20 |
f__elist=a; |
| 21 |
if(f__curunit->ufd==NULL && fk_open(DIR,UNF,a->ciunit) ) err(a->cierr,104,"due"); |
| 22 |
f__cf=f__curunit->ufd; |
| 23 |
if(f__curunit->ufmt) err(a->cierr,102,"cdue") |
| 24 |
if(!f__curunit->useek) err(a->cierr,104,"cdue") |
| 25 |
if(f__curunit->ufd==NULL) err(a->cierr,114,"cdue") |
| 26 |
if(a->cirec <= 0) |
| 27 |
err(a->cierr,130,"due") |
| 28 |
FSEEK(f__cf,(OFF_T)(a->cirec-1)*f__curunit->url,SEEK_SET); |
| 29 |
f__curunit->uend = 0; |
| 30 |
return(0); |
| 31 |
} |
| 32 |
#ifdef KR_headers |
| 33 |
integer s_rdue(a) cilist *a; |
| 34 |
#else |
| 35 |
integer s_rdue(cilist *a) |
| 36 |
#endif |
| 37 |
{ |
| 38 |
int n; |
| 39 |
f__reading=1; |
| 40 |
if(n=c_due(a)) return(n); |
| 41 |
if(f__curunit->uwrt && f__nowreading(f__curunit)) |
| 42 |
err(a->cierr,errno,"read start"); |
| 43 |
return(0); |
| 44 |
} |
| 45 |
#ifdef KR_headers |
| 46 |
integer s_wdue(a) cilist *a; |
| 47 |
#else |
| 48 |
integer s_wdue(cilist *a) |
| 49 |
#endif |
| 50 |
{ |
| 51 |
int n; |
| 52 |
f__reading=0; |
| 53 |
if(n=c_due(a)) return(n); |
| 54 |
if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit)) |
| 55 |
err(a->cierr,errno,"write start"); |
| 56 |
return(0); |
| 57 |
} |
| 58 |
integer e_rdue(Void) |
| 59 |
{ |
| 60 |
if(f__curunit->url==1 || f__recpos==f__curunit->url) |
| 61 |
return(0); |
| 62 |
FSEEK(f__cf,(OFF_T)(f__curunit->url-f__recpos),SEEK_CUR); |
| 63 |
if(FTELL(f__cf)%f__curunit->url) |
| 64 |
err(f__elist->cierr,200,"syserr"); |
| 65 |
return(0); |
| 66 |
} |
| 67 |
integer e_wdue(Void) |
| 68 |
{ |
| 69 |
#ifdef ALWAYS_FLUSH |
| 70 |
if (fflush(f__cf)) |
| 71 |
err(f__elist->cierr,errno,"write end"); |
| 72 |
#endif |
| 73 |
return(e_rdue()); |
| 74 |
} |
| 75 |
#ifdef __cplusplus |
| 76 |
} |
| 77 |
#endif |