Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / pcc / dist / pcc-libs / libI77 / rsfe.c
blob5504453601595019f94bc293c7ea88665d165eca
1 /* $Id: rsfe.c,v 1.1.1.1 2008/08/24 05:34:48 gmcgarry Exp $ */
2 /*
3 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
9 * Redistributions of source code and documentation must retain the above
10 * copyright notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditionsand the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed or owned by Caldera
17 * International, Inc.
18 * Neither the name of Caldera International, Inc. nor the names of other
19 * contributors may be used to endorse or promote products derived from
20 * this software without specific prior written permission.
22 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
23 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE
27 * FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OFLIABILITY, WHETHER IN CONTRACT,
31 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
32 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
35 /* read sequential formatted external */
36 #include "fio.h"
37 #include "fmt.h"
38 static int x_getc(void), x_endp(void), x_rev(void);
39 static int xrd_SL(void);
41 int
42 s_rsfe(cilist *a) /* start */
43 { int n;
44 if(!init) f_init();
45 if((n=c_sfe(a,READ))) return(n);
46 reading=1;
47 sequential=1;
48 formatted=1;
49 external=1;
50 elist=a;
51 cursor=recpos=0;
52 scale=0;
53 fmtbuf=a->cifmt;
54 if(pars_f(fmtbuf)<0) err(a->cierr,100,"startio");
55 curunit= &units[a->ciunit];
56 cf=curunit->ufd;
57 getn= x_getc;
58 doed= rd_ed;
59 doned= rd_ned;
60 fmt_bg();
61 doend=x_endp;
62 donewrec=xrd_SL;
63 dorevert=x_rev;
64 cblank=curunit->ublnk;
65 cplus=0;
66 if(curunit->uwrt) nowreading(curunit);
67 return(0);
70 int
71 xrd_SL()
72 { int ch;
73 if(!curunit->uend)
74 while((ch=getc(cf))!='\n' && ch!=EOF);
75 cursor=recpos=0;
76 return(1);
79 int
80 x_getc()
81 { int ch;
82 if(curunit->uend) return(EOF);
83 if((ch=getc(cf))!=EOF && ch!='\n')
84 { recpos++;
85 return(ch);
87 if(ch=='\n')
88 { ungetc(ch,cf);
89 return(ch);
91 if(feof(cf))
92 { errno=0;
93 curunit->uend=1;
94 return(-1);
96 return(-1);
99 int
100 x_endp()
102 xrd_SL();
103 return(0);
107 x_rev()
109 xrd_SL();
110 return(0);