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  

sue.c

Go to the documentation of this file.
00001 #include "f2c.h"
00002 #include "fio.h"
00003 extern uiolen f__reclen;
00004 long f__recloc;
00005 
00006 #ifdef KR_headers
00007 c_sue(a) cilist *a;
00008 #else
00009 c_sue(cilist *a)
00010 #endif
00011 {
00012         if(a->ciunit >= MXUNIT || a->ciunit < 0)
00013                 err(a->cierr,101,"startio");
00014         f__external=f__sequential=1;
00015         f__formatted=0;
00016         f__curunit = &f__units[a->ciunit];
00017         f__elist=a;
00018         if(f__curunit->ufd==NULL && fk_open(SEQ,UNF,a->ciunit))
00019                 err(a->cierr,114,"sue");
00020         f__cf=f__curunit->ufd;
00021         if(f__curunit->ufmt) err(a->cierr,103,"sue")
00022         if(!f__curunit->useek) err(a->cierr,103,"sue")
00023         return(0);
00024 }
00025 #ifdef KR_headers
00026 integer s_rsue(a) cilist *a;
00027 #else
00028 integer s_rsue(cilist *a)
00029 #endif
00030 {
00031         int n;
00032         if(!f__init) f_init();
00033         f__reading=1;
00034         if(n=c_sue(a)) return(n);
00035         f__recpos=0;
00036         if(f__curunit->uwrt && f__nowreading(f__curunit))
00037                 err(a->cierr, errno, "read start");
00038         if(fread((char *)&f__reclen,sizeof(uiolen),1,f__cf)
00039                 != 1)
00040         {       if(feof(f__cf))
00041                 {       f__curunit->uend = 1;
00042                         err(a->ciend, EOF, "start");
00043                 }
00044                 clearerr(f__cf);
00045                 err(a->cierr, errno, "start");
00046         }
00047         return(0);
00048 }
00049 #ifdef KR_headers
00050 integer s_wsue(a) cilist *a;
00051 #else
00052 integer s_wsue(cilist *a)
00053 #endif
00054 {
00055         int n;
00056         if(!f__init) f_init();
00057         if(n=c_sue(a)) return(n);
00058         f__reading=0;
00059         f__reclen=0;
00060         if(f__curunit->uwrt != 1 && f__nowwriting(f__curunit))
00061                 err(a->cierr, errno, "write start");
00062         f__recloc=ftell(f__cf);
00063         (void) fseek(f__cf,(long)sizeof(uiolen),SEEK_CUR);
00064         return(0);
00065 }
00066 integer e_wsue(Void)
00067 {       long loc;
00068         fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
00069 #ifdef ALWAYS_FLUSH
00070         if (fflush(f__cf))
00071                 err(f__elist->cierr, errno, "write end");
00072 #endif
00073         loc=ftell(f__cf);
00074         fseek(f__cf,f__recloc,SEEK_SET);
00075         fwrite((char *)&f__reclen,sizeof(uiolen),1,f__cf);
00076         fseek(f__cf,loc,SEEK_SET);
00077         return(0);
00078 }
00079 integer e_rsue(Void)
00080 {
00081         (void) fseek(f__cf,(long)(f__reclen-f__recpos+sizeof(uiolen)),SEEK_CUR);
00082         return(0);
00083 }
 

Powered by Plone

This site conforms to the following standards: