1: /*
2: char id_sue[] = "@(#)sue.c 1.3";
3: *
4: * sequential unformatted external read/write routines
5: */
6:
7: #include "fio.h"
8:
9: extern int reclen;
10: long recloc;
11: char rsue[] = "read sue";
12: char wsue[] = "write sue";
13:
14: s_rsue(a) cilist *a;
15: {
16: int n;
17: reading = YES;
18: if(n=c_sue(a,READ)) return(n);
19: if(curunit->uwrt && ! nowreading(curunit)) err(errflag, errno, rsue)
20: recpos = 0;
21: if(fread(&reclen,sizeof(int),1,cf) == 1) return(OK);
22: if(feof(cf))
23: { curunit->uend = YES;
24: err(endflag, EOF, rsue)
25: }
26: clearerr(cf);
27: err(errflag, errno, rsue)
28: }
29:
30: s_wsue(a) cilist *a;
31: {
32: int n;
33: reading = NO;
34: if(n=c_sue(a,WRITE)) return(n);
35: if(!curunit->uwrt && ! nowwriting(curunit)) err(errflag, errno, wsue)
36: reclen = 0;
37: recloc=ftell(cf);
38: fseek(cf,(long)sizeof(int),1);
39: curunit->uend = NO;
40: return(OK);
41: }
42:
43: c_sue(a,flag) cilist *a;
44: { int n;
45: external = sequential = YES;
46: formatted = NO;
47: lfname = NULL;
48: elist = NO;
49: errflag = a->cierr;
50: endflag = a->ciend;
51: lunit = a->ciunit;
52: if(not_legal(lunit)) err(errflag,F_ERUNIT,rsue+5)
53: curunit = &units[lunit];
54: if(!curunit->ufd && (n=fk_open(flag,SEQ,UNF,(ftnint)lunit)))
55: err(errflag,n,rsue+5)
56: cf = curunit->ufd;
57: elist = YES;
58: lfname = curunit->ufnm;
59: if(curunit->ufmt) err(errflag,F_ERNOUIO,rsue+5)
60: if(curunit->url) err(errflag,F_ERNOSIO,rsue+5)
61: if(!curunit->useek) err(errflag,F_ERSEEK,rsue+5)
62: return(OK);
63: }
64:
65: e_wsue()
66: { long loc;
67: fwrite(&reclen,sizeof(int),1,cf);
68: loc=ftell(cf);
69: fseek(cf,recloc,0);
70: fwrite(&reclen,sizeof(int),1,cf);
71: fseek(cf,loc,0);
72: return(OK);
73: }
74:
75: e_rsue()
76: {
77: fseek(cf,(long)(reclen-recpos+sizeof(int)),1);
78: return(OK);
79: }
Defined functions
c_sue
defined in line
43; used 2 times
Defined variables
rsue
defined in line
11; used 8 times
wsue
defined in line
12; used 1 times