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