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: * @(#)rsfe.c 5.2 7/30/85
7: */
8:
9: /*
10: * read sequential formatted external
11: */
12:
13: #include "fio.h"
14:
15: extern int rd_ed(),rd_ned();
16: int x_rnew(),x_getc(),x_tab();
17:
18: LOCAL char rsfe[] = "read sfe";
19:
20: s_rsfe(a) cilist *a; /* start */
21: { int n;
22: reading = YES;
23: sequential = YES;
24: if(n=c_sfe(a,READ,SEQ,rsfe)) return (n);
25: if(curunit->url) err(errflag,F_ERNOSIO,rsfe)
26: if(curunit->uwrt && ! nowreading(curunit)) err(errflag, errno, rsfe)
27: getn= x_getc;
28: doed= rd_ed;
29: doned= rd_ned;
30: donewrec = dorevert = doend = x_rnew;
31: dotab = x_tab;
32: if(pars_f()) err(errflag,F_ERFMT,rsfe)
33: fmt_bg();
34: return(OK);
35: }
36:
37: LOCAL
38: x_rnew() /* find next record */
39: { int ch;
40: if(curunit->uend)
41: return(EOF);
42: while((ch=getc(cf))!='\n' && ch!=EOF);
43: if(feof(cf))
44: { curunit->uend = YES;
45: if (recpos==0) return(EOF);
46: }
47: cursor=recpos=reclen=0;
48: return(OK);
49: }
50:
51: LOCAL
52: x_getc()
53: { int ch;
54: if(curunit->uend) return(EOF);
55: if((ch=getc(cf))!=EOF && ch!='\n')
56: { recpos++;
57: return(ch);
58: }
59: if(ch=='\n')
60: { ungetc(ch,cf);
61: return(ch);
62: }
63: if(feof(cf)) curunit->uend = YES;
64: return(EOF);
65: }
66:
67: e_rsfe()
68: { int n;
69: n=en_fio();
70: fmtbuf=NULL;
71: return(n);
72: }
Defined functions
Defined variables
rsfe
defined in line
18; used 4 times