|
|
1.1 ! root 1: /* ! 2: * Backspace records ! 3: */ ! 4: ! 5: #include "fio.h" ! 6: ! 7: char *bksp = "backspace"; ! 8: char last_char(); ! 9: ! 10: f_back(a) alist *a; ! 11: { unit *b; ! 12: int n,i; ! 13: long x,y; ! 14: lfname = NULL; ! 15: elist = NO; ! 16: external = YES; ! 17: errflag = a->aerr; ! 18: lunit = a->aunit; ! 19: if (not_legal(lunit)) err(errflag,101,bksp) ! 20: b= &units[lunit]; ! 21: if(!b->ufd) err(errflag,114,bksp) ! 22: lfname = b->ufnm; ! 23: if(b->uend) ! 24: { b->uend = NO; ! 25: return(OK); ! 26: } ! 27: if((x=ftell(b->ufd))==0) return(OK); ! 28: if(!b->useek) err(errflag,106,bksp) ! 29: if(b->uwrt) t_runc(b,errflag); ! 30: if(b->url) /* direct access, purely academic */ ! 31: { y = x%(long)b->url; ! 32: x -= y?y:b->url; ! 33: fseek(b->ufd,x,0); ! 34: return(OK); ! 35: } ! 36: if(!b->ufmt) /* unformatted sequential */ ! 37: { fseek(b->ufd,-(long)sizeof(int),1); ! 38: fread((char *)&n,sizeof(int),1,b->ufd); ! 39: fseek(b->ufd,-(long)n-2*sizeof(int),1); ! 40: return(OK); ! 41: } ! 42: if(x==1) /* formatted sequential */ ! 43: { rewind(b->ufd); ! 44: return(OK); ! 45: } ! 46: while(last_char(b->ufd)!='\n'); /* slow but simple */ ! 47: return(OK); ! 48: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.