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