|
|
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: * @(#)due.c 5.2 2/25/90 ! 7: */ ! 8: ! 9: /* ! 10: * direct unformatted external i/o ! 11: */ ! 12: ! 13: #include "fio.h" ! 14: ! 15: LOCAL char rdue[] = "read due"; ! 16: LOCAL char wdue[] = "write due"; ! 17: ! 18: s_rdue(a) cilist *a; ! 19: { ! 20: int n; ! 21: reading = YES; ! 22: if(n=c_due(a,READ)) return(n); ! 23: if(curunit->uwrt && ! nowreading(curunit)) err(errflag, errno, rdue); ! 24: return(OK); ! 25: } ! 26: ! 27: s_wdue(a) cilist *a; ! 28: { ! 29: int n; ! 30: reading = NO; ! 31: if(n=c_due(a,WRITE)) return(n); ! 32: curunit->uend = NO; ! 33: if(!curunit->uwrt && ! nowwriting(curunit)) err(errflag, errno, wdue) ! 34: return(OK); ! 35: } ! 36: ! 37: LOCAL ! 38: c_due(a,flg) cilist *a; ! 39: { int n; ! 40: lfname = NULL; ! 41: elist = NO; ! 42: sequential=formatted=NO; ! 43: recpos = reclen = 0; ! 44: external = YES; ! 45: errflag = a->cierr; ! 46: endflag = a->ciend; ! 47: lunit = a->ciunit; ! 48: if(not_legal(lunit)) err(errflag,F_ERUNIT,rdue+5); ! 49: curunit = &units[lunit]; ! 50: if (!curunit->ufd && (n=fk_open(flg,DIR,UNF,(ftnint)lunit)) ) ! 51: err(errflag,n,rdue+5) ! 52: cf = curunit->ufd; ! 53: elist = YES; ! 54: lfname = curunit->ufnm; ! 55: if (curunit->ufmt) err(errflag,F_ERNOUIO,rdue+5) ! 56: if (!curunit->useek || !curunit->url) err(errflag,F_ERNODIO,rdue+5) ! 57: if (fseek(cf, (long)((a->cirec-1)*curunit->url), 0) < 0) ! 58: return(due_err(rdue+5)); ! 59: else ! 60: return(OK); ! 61: } ! 62: ! 63: e_rdue() ! 64: { ! 65: return(OK); ! 66: } ! 67: ! 68: e_wdue() ! 69: {/* This is to ensure full records. It is really necessary. */ ! 70: int n = 0; ! 71: if (curunit->url!=1 && recpos!=curunit->url && ! 72: (fseek(cf, (long)(curunit->url-recpos-1), 1) < 0 ! 73: || fwrite(&n, 1, 1, cf) != 1)) ! 74: return(due_err(rdue+5)); ! 75: return(OK); ! 76: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.