Go to the documentation of this file.00001 #include "f2c.h"
00002 #include "fio.h"
00003 #ifdef __cplusplus
00004 extern "C" {
00005 #endif
00006
00007 int
00008 #ifdef KR_headers
00009 c_due(a) cilist *a;
00010 #else
00011 c_due(cilist *a)
00012 #endif
00013 {
00014 if(!f__init) f_init();
00015 f__sequential=f__formatted=f__recpos=0;
00016 f__external=1;
00017 f__curunit = &f__units[a->ciunit];
00018 if(a->ciunit>=MXUNIT || a->ciunit<0)
00019 err(a->cierr,101,"startio");
00020 f__elist=a;
00021 if(f__curunit->ufd==NULL && fk_open(DIR,UNF,a->ciunit) ) err(a->cierr,104,"due");
00022 f__cf=f__curunit->ufd;
00023 if(f__curunit->ufmt) err(a->cierr,102,"cdue")
00024 if(!f__curunit->useek) err(a->cierr,104,"cdue")
00025 if(f__curunit->ufd==NULL) err(a->cierr,114,"cdue")
00026 if(a->cirec <= 0)
00027 err(a->cierr,130,"due")
00028 FSEEK(f__cf,(OFF_T)(a->cirec-1)*f__curunit->url,SEEK_SET);
00029 f__curunit->uend = 0;
00030 return(0);
00031 }
00032 #ifdef KR_headers
00033 integer s_rdue(a) cilist *a;
00034 #else
00035 integer s_rdue(cilist *a)
00036 #endif
00037 {
00038 int n;
00039 f__reading=1;
00040 if(n=c_due(a)) return(n);
00041 if(f__curunit->uwrt && f__nowreading(f__curunit))
00042 err(a->cierr,errno,"read start");
00043 return(0);
00044 }
00045 #ifdef KR_headers
00046 integer s_wdue(a) cilist *a;
00047 #else
00048 integer s_wdue(cilist *a)
00049 #endif
00050 {
00051 int n;
00052 f__reading=0;
00053 if(n=c_due(a)) return(n);
00054 if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
00055 err(a->cierr,errno,"write start");
00056 return(0);
00057 }
00058 integer e_rdue(Void)
00059 {
00060 if(f__curunit->url==1 || f__recpos==f__curunit->url)
00061 return(0);
00062 FSEEK(f__cf,(OFF_T)(f__curunit->url-f__recpos),SEEK_CUR);
00063 if(FTELL(f__cf)%f__curunit->url)
00064 err(f__elist->cierr,200,"syserr");
00065 return(0);
00066 }
00067 integer e_wdue(Void)
00068 {
00069 #ifdef ALWAYS_FLUSH
00070 if (fflush(f__cf))
00071 err(f__elist->cierr,errno,"write end");
00072 #endif
00073 return(e_rdue());
00074 }
00075 #ifdef __cplusplus
00076 }
00077 #endif