string.h is ANSI C include file
[unix-history] / usr / src / usr.bin / f77 / libI77 / rsfe.c
CommitLineData
813dcd74 1/*
161423a6
RE
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.
813dcd74 5 *
089a8031 6 * @(#)rsfe.c 5.2 %G%
161423a6
RE
7 */
8
9/*
813dcd74
DL
10 * read sequential formatted external
11 */
12
13#include "fio.h"
14
15extern int rd_ed(),rd_ned();
16int x_rnew(),x_getc(),x_tab();
17
18LOCAL char rsfe[] = "read sfe";
19
20s_rsfe(a) cilist *a; /* start */
21{ int n;
22 reading = YES;
089a8031 23 sequential = YES;
813dcd74
DL
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
37LOCAL
38x_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
51LOCAL
52x_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
67e_rsfe()
68{ int n;
69 n=en_fio();
70 fmtbuf=NULL;
71 return(n);
72}