Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / pcc / dist / pcc-libs / libI77 / iio.c
blobf44f7adac8ca8cada46e22e052a0fb95aa6358fe
1 /* $Id: iio.c,v 1.1.1.1 2008/08/24 05:34:47 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 #include "fio.h"
36 #include "fmt.h"
37 char *icptr,*icend;
38 icilist *svic;
39 static int y_err(void), z_wnew(void), z_rnew(void), c_si(icilist *);
40 int icnum,icpos;
42 int
43 z_getc()
45 if(icptr >= icend) err(svic->iciend,(EOF),"endfile");
46 if(icpos++ < svic->icirlen)
47 return(*icptr++);
48 else err(svic->icierr,110,"recend");
51 int
52 z_putc(int c)
54 if(icptr >= icend) err(svic->icierr,110,"inwrite");
55 if(icpos++ < svic->icirlen)
56 *icptr++ = c;
57 else err(svic->icierr,110,"recend");
58 return(0);
61 int
62 z_rnew()
64 icptr = svic->iciunit + (++icnum)*svic->icirlen;
65 icpos = 0;
66 return 0;
69 int
70 s_rsfi(icilist *a)
71 { int n;
72 if((n=c_si(a))) return(n);
73 reading=1;
74 doed=rd_ed;
75 doned=rd_ned;
76 getn=z_getc;
77 dorevert = donewrec = y_err;
78 doend = z_rnew;
79 return(0);
82 int
83 s_wsfi(icilist *a)
84 { int n;
85 if((n=c_si(a))) return(n);
86 reading=0;
87 doed=w_ed;
88 doned=w_ned;
89 putn=z_putc;
90 dorevert = donewrec = y_err;
91 doend = z_wnew;
92 return(0);
95 int
96 c_si(icilist *a)
98 fmtbuf=a->icifmt;
99 if(pars_f(fmtbuf)<0)
100 err(a->icierr,100,"startint");
101 fmt_bg();
102 sequential=formatted=1;
103 external=0;
104 cblank=cplus=scale=0;
105 svic=a;
106 icnum=icpos=0;
107 icptr=svic->iciunit;
108 icend=icptr+svic->icirlen*svic->icirnum;
109 return(0);
113 z_wnew()
115 while(icpos++ < svic->icirlen)
116 *icptr++ = ' ';
117 icpos = 0;
118 icnum++;
119 return 0;
123 e_rsfi()
124 { int n;
125 n = en_fio();
126 fmtbuf = NULL;
127 return(n);
131 e_wsfi()
133 int n;
134 n = en_fio();
135 fmtbuf = NULL;
136 while(icpos++ < svic->icirlen)
137 *icptr++ = ' ';
138 return(n);
142 y_err()
144 err(elist->cierr, 110, "iio");