Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / pcc / dist / pcc-libs / libI77 / wsfe.c
blobbdfb955414fab341a7c49e2379895c4869be3b40
1 /* $Id: wsfe.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 /*write sequential formatted external*/
36 #include "fio.h"
37 #include "fmt.h"
38 static int x_putc(int);
39 static int xw_end(void),xw_rev(void),x_wSL(void);
42 int
43 s_wsfe(cilist *a)
44 { int n;
45 if(!init) f_init();
46 if((n=c_sfe(a,WRITE))) return(n);
47 reading=0;
48 sequential=1;
49 formatted=1;
50 external=1;
51 elist=a;
52 cursor=recpos=0;
53 scale=0;
54 fmtbuf=a->cifmt;
55 if(pars_f(fmtbuf)<0) err(a->cierr,100,"startio");
56 curunit = &units[a->ciunit];
57 cf=curunit->ufd;
58 putn= x_putc;
59 doed= w_ed;
60 doned= w_ned;
61 doend=xw_end;
62 dorevert=xw_rev;
63 donewrec=x_wSL;
64 fmt_bg();
65 cplus=0;
66 cblank=curunit->ublnk;
67 if(!curunit->uwrt) nowwriting(curunit);
68 return(0);
71 int
72 x_putc(c)
74 recpos++;
75 putc(c,cf);
76 return 0;
79 void
80 pr_put(c)
81 { static flag new = 1;
82 recpos++;
83 if(c=='\n')
84 { new=1;
85 putc(c,cf);
87 else if(new==1)
88 { new=0;
89 if(c=='0') putc('\n',cf);
90 else if(c=='1') putc('\f',cf);
92 else putc(c,cf);
95 int
96 x_wSL()
98 recpos=0;
99 (*putn)('\n');
100 return(1);
104 xw_end()
106 (*putn)('\n');
107 return(0);
111 xw_rev()
113 if(workdone) (*putn)('\n');
114 return(workdone=0);