1: /* 2: char id_rsfe[] = "@(#)rsfe.c 1.1"; 3: * 4: * read sequential formatted external routines 5: */ 6: 7: #include "fio.h" 8: 9: int x_getc(), x_rnew(); 10: extern int rd_ed(), rd_ned(), x_tab(); 11: 12: char rsfe[] = "read sfe"; 13: 14: s_rsfe(a) cilist *a; /* start */ 15: { int n; 16: reading = YES; 17: if(n=c_sfe(a,READ)) return(n); 18: if(curunit->uwrt && ! nowreading(curunit)) err(errflag, errno, rsfe) 19: getn= x_getc; 20: doed= rd_ed; 21: doned= rd_ned; 22: donewrec = dorevert = doend = x_rnew; 23: dotab = x_tab; 24: if(pars_f(fmtbuf)) err(errflag,F_ERFMT,rsfe) 25: fmt_bg(); 26: return(OK); 27: } 28: 29: x_rnew() /* find next record */ 30: { int ch; 31: if(curunit->uend) 32: return(EOF); 33: while((ch=getc(cf))!='\n' && ch!=EOF); 34: if(feof(cf)) 35: { curunit->uend = YES; 36: if (recpos==0) return(EOF); 37: } 38: cursor=recpos=reclen=0; 39: return(OK); 40: } 41: 42: x_getc() 43: { int ch; 44: if(curunit->uend) return(EOF); 45: if((ch=getc(cf))!=EOF && ch!='\n') 46: { recpos++; 47: return(ch); 48: } 49: if(ch=='\n') 50: { ungetc(ch,cf); 51: return(ch); 52: } 53: if(feof(cf)) curunit->uend = YES; 54: return(EOF); 55: }