Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

dfe.c

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

Powered by Plone

This site conforms to the following standards: