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