Commit | Line | Data |
---|---|---|
c67fc77c | 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. | |
c67fc77c | 5 | * |
161423a6 RE |
6 | * @(#)wdfe.c 5.1 %G% |
7 | */ | |
8 | ||
9 | /* | |
c67fc77c DL |
10 | * write direct formatted external i/o |
11 | */ | |
12 | ||
13 | #include "fio.h" | |
14 | ||
15 | extern int w_ed(),w_ned(); | |
16 | int y_putc(),y_wnew(),y_tab(); | |
17 | ||
18 | LOCAL char wdfe[] = "write dfe"; | |
19 | ||
20 | s_wdfe(a) cilist *a; | |
21 | { | |
22 | int n; | |
23 | reading = NO; | |
24 | if(n=c_dfe(a,WRITE,wdfe)) return(n); | |
25 | curunit->uend = NO; | |
26 | if(!curunit->uwrt && ! nowwriting(curunit)) err(errflag, errno, wdfe) | |
27 | putn = y_putc; | |
28 | doed = w_ed; | |
29 | doned = w_ned; | |
30 | dotab = y_tab; | |
31 | dorevert = doend = donewrec = y_wnew; | |
32 | if(pars_f()) err(errflag,F_ERFMT,wdfe) | |
33 | fmt_bg(); | |
34 | return(OK); | |
35 | } | |
36 | ||
37 | e_wdfe() | |
38 | { | |
39 | en_fio(); | |
40 | return(OK); | |
41 | } | |
42 | ||
43 | LOCAL | |
44 | y_putc(c) | |
45 | { | |
46 | if(curunit->url!=1 && recpos++ >= curunit->url) err(errflag,F_EREREC,wdfe) | |
47 | putc(c,cf); | |
48 | return(OK); | |
49 | } | |
50 | ||
51 | LOCAL | |
52 | y_wnew() | |
53 | { if(curunit->url != 1) | |
54 | { if(reclen > recpos) | |
55 | { fseek(cf,(long)(reclen-recpos),1); | |
56 | recpos = reclen; | |
57 | } | |
58 | while(recpos < curunit->url) (*putn)(' '); | |
59 | recnum++; | |
60 | recpos = reclen = cursor = 0; | |
61 | } | |
62 | return(OK); | |
63 | } |