Bell 32V development
[unix-history] / usr / src / libI77 / wsfe.c
CommitLineData
7a517deb
TL
1/*write sequential formatted external*/
2#include "fio.h"
3#include "fmt.h"
4extern int x_putc(),w_ed(),w_ned();
5extern int xw_end(),xw_rev(),x_wSL();
6s_wsfe(a) cilist *a; /*start*/
7{ int n;
8 if(!init) f_init();
9 if(n=c_sfe(a,WRITE)) return(n);
10 reading=0;
11 sequential=1;
12 formatted=1;
13 external=1;
14 elist=a;
15 cursor=recpos=0;
16 scale=0;
17 fmtbuf=a->cifmt;
18 if(pars_f(fmtbuf)<0) err(a->cierr,100,"startio");
19 curunit = &units[a->ciunit];
20 cf=curunit->ufd;
21 putn= x_putc;
22 doed= w_ed;
23 doned= w_ned;
24 doend=xw_end;
25 dorevert=xw_rev;
26 donewrec=x_wSL;
27 fmt_bg();
28 cplus=0;
29 cblank=curunit->ublnk;
30 if(!curunit->uwrt) nowwriting(curunit);
31 return(0);
32}
33x_putc(c)
34{
35 recpos++;
36 putc(c,cf);
37}
38pr_put(c)
39{ static flag new = 1;
40 recpos++;
41 if(c=='\n')
42 { new=1;
43 putc(c,cf);
44 }
45 else if(new==1)
46 { new=0;
47 if(c=='0') putc('\n',cf);
48 else if(c=='1') putc('\f',cf);
49 }
50 else putc(c,cf);
51}
52x_wSL()
53{
54 recpos=0;
55 (*putn)('\n');
56 return(1);
57}
58xw_end()
59{
60 (*putn)('\n');
61 return(0);
62}
63xw_rev()
64{
65 if(workdone) (*putn)('\n');
66 return(workdone=0);
67}