dfe.c
Go to the documentation of this file.
00001 #include "f2c.h"
00002 #include "fio.h"
00003 #include "fmt.h"
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00008  int
00009 y_rsk(Void)
00010 {
00011         if(f__curunit->uend || f__curunit->url <= f__recpos
00012                 || f__curunit->url == 1) return 0;
00013         do {
00014                 getc(f__cf);
00015         } while(++f__recpos < f__curunit->url);
00016         return 0;
00017 }
00018 
00019  int
00020 y_getc(Void)
00021 {
00022         int ch;
00023         if(f__curunit->uend) return(-1);
00024         if((ch=getc(f__cf))!=EOF)
00025         {
00026                 f__recpos++;
00027                 if(f__curunit->url>=f__recpos ||
00028                         f__curunit->url==1)
00029                         return(ch);
00030                 else    return(' ');
00031         }
00032         if(feof(f__cf))
00033         {
00034                 f__curunit->uend=1;
00035                 errno=0;
00036                 return(-1);
00037         }
00038         err(f__elist->cierr,errno,"readingd");
00039 }
00040 
00041  static int
00042 y_rev(Void)
00043 {
00044         if (f__recpos < f__hiwater)
00045                 f__recpos = f__hiwater;
00046         if (f__curunit->url > 1)
00047                 while(f__recpos < f__curunit->url)
00048                         (*f__putn)(' ');
00049         if (f__recpos)
00050                 f__putbuf(0);
00051         f__recpos = 0;
00052         return(0);
00053 }
00054 
00055  static int
00056 y_err(Void)
00057 {
00058         err(f__elist->cierr, 110, "dfe");
00059 }
00060 
00061  static int
00062 y_newrec(Void)
00063 {
00064         y_rev();
00065         f__hiwater = f__cursor = 0;
00066         return(1);
00067 }
00068 
00069  int
00070 #ifdef KR_headers
00071 c_dfe(a) cilist *a;
00072 #else
00073 c_dfe(cilist *a)
00074 #endif
00075 {
00076         f__sequential=0;
00077         f__formatted=f__external=1;
00078         f__elist=a;
00079         f__cursor=f__scale=f__recpos=0;
00080         f__curunit = &f__units[a->ciunit];
00081         if(a->ciunit>MXUNIT || a->ciunit<0)
00082                 err(a->cierr,101,"startchk");
00083         if(f__curunit->ufd==NULL && fk_open(DIR,FMT,a->ciunit))
00084                 err(a->cierr,104,"dfe");
00085         f__cf=f__curunit->ufd;
00086         if(!f__curunit->ufmt) err(a->cierr,102,"dfe")
00087         if(!f__curunit->useek) err(a->cierr,104,"dfe")
00088         f__fmtbuf=a->cifmt;
00089         if(a->cirec <= 0)
00090                 err(a->cierr,130,"dfe")
00091         FSEEK(f__cf,(OFF_T)f__curunit->url * (a->cirec-1),SEEK_SET);
00092         f__curunit->uend = 0;
00093         return(0);
00094 }
00095 #ifdef KR_headers
00096 integer s_rdfe(a) cilist *a;
00097 #else
00098 integer s_rdfe(cilist *a)
00099 #endif
00100 {
00101         int n;
00102         if(!f__init) f_init();
00103         f__reading=1;
00104         if(n=c_dfe(a))return(n);
00105         if(f__curunit->uwrt && f__nowreading(f__curunit))
00106                 err(a->cierr,errno,"read start");
00107         f__getn = y_getc;
00108         f__doed = rd_ed;
00109         f__doned = rd_ned;
00110         f__dorevert = f__donewrec = y_err;
00111         f__doend = y_rsk;
00112         if(pars_f(f__fmtbuf)<0)
00113                 err(a->cierr,100,"read start");
00114         fmt_bg();
00115         return(0);
00116 }
00117 #ifdef KR_headers
00118 integer s_wdfe(a) cilist *a;
00119 #else
00120 integer s_wdfe(cilist *a)
00121 #endif
00122 {
00123         int n;
00124         if(!f__init) f_init();
00125         f__reading=0;
00126         if(n=c_dfe(a)) return(n);
00127         if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
00128                 err(a->cierr,errno,"startwrt");
00129         f__putn = x_putc;
00130         f__doed = w_ed;
00131         f__doned= w_ned;
00132         f__dorevert = y_err;
00133         f__donewrec = y_newrec;
00134         f__doend = y_rev;
00135         if(pars_f(f__fmtbuf)<0)
00136                 err(a->cierr,100,"startwrt");
00137         fmt_bg();
00138         return(0);
00139 }
00140 integer e_rdfe(Void)
00141 {
00142         en_fio();
00143         return 0;
00144 }
00145 integer e_wdfe(Void)
00146 {
00147         return en_fio();
00148 }
00149 #ifdef __cplusplus
00150 }
00151 #endif


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:43