|
|
1.1 root 1: #include "fio.h"
2: #include "fmt.h"
3: extern int rd_ed(),rd_ned(),y_getc(),y_putc(),y_err();
4: extern int y_rev(), y_rsk();
5: extern int w_ed(),w_ned();
6: s_rdfe(a) cilist *a;
7: {
8: int n;
9: if(!init) f_init();
10: if(n=c_dfe(a))return(n);
11: reading=1;
12: if(curunit->uwrt) (void) nowreading(curunit);
13: getn = y_getc;
14: doed = rd_ed;
15: doned = rd_ned;
16: dorevert = donewrec = y_err;
17: doend = y_rsk;
18: if(pars_f(fmtbuf)<0)
19: err(a->cierr,100,"startio");
20: fmt_bg();
21: return(0);
22: }
23: s_wdfe(a) cilist *a;
24: {
25: int n;
26: if(!init) f_init();
27: if(n=c_dfe(a)) return(n);
28: reading=0;
29: if(!curunit->uwrt) (void) nowwriting(curunit);
30: putn = y_putc;
31: doed = w_ed;
32: doned= w_ned;
33: dorevert = donewrec = y_err;
34: doend = y_rev;
35: if(pars_f(fmtbuf)<0)
36: err(a->cierr,100,"startwrt");
37: fmt_bg();
38: return(0);
39: }
40: e_rdfe()
41: {
42: (void) en_fio();
43: return(0);
44: }
45: e_wdfe()
46: {
47: (void) en_fio();
48: return(0);
49: }
50: c_dfe(a) cilist *a;
51: {
52: sequential=0;
53: formatted=external=1;
54: elist=a;
55: cursor=scale=recpos=0;
56: if(a->ciunit>MXUNIT || a->ciunit<0)
57: err(a->cierr,101,"startchk");
58: curunit = &units[a->ciunit];
59: if(curunit->ufd==NULL && fk_open(DIR,FMT,a->ciunit))
60: err(a->cierr,104,"dfe");
61: cf=curunit->ufd;
62: if(!curunit->ufmt) err(a->cierr,102,"dfe")
63: if(!curunit->useek) err(a->cierr,104,"dfe")
64: fmtbuf=a->cifmt;
65: (void) fseek(cf,(long)curunit->url * (a->cirec-1),0);
66: curunit->uend = 0;
67: return(0);
68: }
69: y_rsk()
70: {
71: if(curunit->uend || curunit->url <= recpos
72: || curunit->url == 1) return;
73: do {
74: getc(cf);
75: } while(++recpos < curunit->url);
76: }
77: y_getc()
78: {
79: int ch;
80: if(curunit->uend) return(-1);
81: if((ch=getc(cf))!=EOF)
82: {
83: recpos++;
84: if(curunit->url>=recpos ||
85: curunit->url==1)
86: return(ch);
87: else return(' ');
88: }
89: if(feof(cf))
90: {
91: curunit->uend=1;
92: errno=0;
93: return(-1);
94: }
95: err(elist->cierr,errno,"readingd");
96: }
97: y_putc(c)
98: {
99: recpos++;
100: if(recpos <= curunit->url || curunit->url==1)
101: putc(c,cf);
102: else
103: err(elist->cierr,110,"dout");
104: return(0);
105: }
106: y_rev()
107: { /*what about work done?*/
108: if(curunit->url==1 || recpos==curunit->url)
109: return(0);
110: while(recpos<curunit->url)
111: (*putn)(' ');
112: recpos=0;
113: return(0);
114: }
115: y_err()
116: {
117: err(elist->cierr, 110, "dfe");
118: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.