|
|
1.1 ! root 1: /* read sequential formatted external */ ! 2: #include "fio.h" ! 3: #include "fmt.h" ! 4: extern int x_getc(),rd_ed(),rd_ned(); ! 5: extern int x_endp(),x_rev(),xrd_SL(); ! 6: s_rsfe(a) cilist *a; /* start */ ! 7: { int n; ! 8: if(!init) f_init(); ! 9: if(n=c_sfe(a,READ)) return(n); ! 10: reading=1; ! 11: sequential=1; ! 12: formatted=1; ! 13: external=1; ! 14: elist=a; ! 15: cursor=recpos=0; ! 16: scale=0; ! 17: fmtbuf=a->cifmt; ! 18: curunit= &units[a->ciunit]; ! 19: cf=curunit->ufd; ! 20: if(pars_f(fmtbuf)<0) err(a->cierr,100,"startio"); ! 21: getn= x_getc; ! 22: doed= rd_ed; ! 23: doned= rd_ned; ! 24: fmt_bg(); ! 25: doend=x_endp; ! 26: donewrec=xrd_SL; ! 27: dorevert=x_rev; ! 28: cblank=curunit->ublnk; ! 29: cplus=0; ! 30: if(curunit->uwrt) nowreading(curunit); ! 31: return(0); ! 32: } ! 33: xrd_SL() ! 34: { int ch; ! 35: if(!curunit->uend) ! 36: while((ch=getc(cf))!='\n' && ch!=EOF); ! 37: cursor=recpos=0; ! 38: return(1); ! 39: } ! 40: x_getc() ! 41: { int ch; ! 42: if(curunit->uend) return(EOF); ! 43: if((ch=getc(cf))!=EOF && ch!='\n') ! 44: { recpos++; ! 45: return(ch); ! 46: } ! 47: if(ch=='\n') ! 48: { ungetc(ch,cf); ! 49: return(ch); ! 50: } ! 51: if(feof(cf)) ! 52: { errno=0; ! 53: curunit->uend=1; ! 54: return(-1); ! 55: } ! 56: return(-1); ! 57: } ! 58: x_endp() ! 59: { ! 60: xrd_SL(); ! 61: return(0); ! 62: } ! 63: x_rev() ! 64: { ! 65: xrd_SL(); ! 66: return(0); ! 67: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.