|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)c_dfe.c 5.3 2/25/90 ! 7: */ ! 8: ! 9: /* ! 10: * direct formatted external i/o - common read/write routines ! 11: */ ! 12: ! 13: #include "fio.h" ! 14: ! 15: c_dfe(a,flg,str) cilist *a; char *str; ! 16: { int n; ! 17: sequential = NO; ! 18: external = YES; ! 19: formatted = FORMATTED; ! 20: lfname = NULL; ! 21: elist = NO; ! 22: cursor=scale=recpos=reclen=0; ! 23: radix = 10; ! 24: signit = YES; ! 25: fmtbuf = a->cifmt; ! 26: errflag = a->cierr; ! 27: endflag = a->ciend; ! 28: lunit = a->ciunit; ! 29: if(not_legal(lunit)) err(errflag,F_ERUNIT,str); ! 30: curunit = &units[lunit]; ! 31: if(!curunit->ufd && (n=fk_open(flg,DIR,FMT,(ftnint)lunit))) ! 32: err(errflag,n,str) ! 33: cf = curunit->ufd; ! 34: elist = YES; ! 35: lfname = curunit->ufnm; ! 36: if(!curunit->ufmt) err(errflag,F_ERNOFIO,str) ! 37: if(!curunit->useek || !curunit->url) err(errflag,F_ERNODIO,str) ! 38: recnum = a->cirec - 1; ! 39: fseek(cf, (long)curunit->url * recnum, 0); ! 40: cblank = curunit->ublnk; ! 41: cplus = NO; ! 42: return(OK); ! 43: } ! 44: ! 45: y_tab() ! 46: { int n; ! 47: if(curunit->url==1) ! 48: { ! 49: if(cursor < 0 && -cursor > ftell(cf)) rewind(cf); ! 50: else fseek(cf,(long)cursor,1); ! 51: return(cursor=0); ! 52: } ! 53: else ! 54: { if(reclen < recpos) reclen = recpos; ! 55: if((recpos + cursor) < 0) cursor = -recpos; /* BOR */ ! 56: n = reclen - recpos; /* n >= 0 */ ! 57: if(!reading && (cursor-n) > 0) ! 58: { recpos = reclen; ! 59: cursor -= n; ! 60: fseek(cf,(long)n,1); ! 61: while(cursor--) if(n=(*putn)(' ')) return(n); ! 62: return(cursor=0); ! 63: } ! 64: recpos += cursor; ! 65: if(recpos >= curunit->url) err(errflag,F_EREREC,"dfe") ! 66: } ! 67: fseek(cf,(long)cursor,1); ! 68: return(cursor=0); ! 69: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.