Commit | Line | Data |
---|---|---|
bae7117f WH |
1 | #include "f2c.h" |
2 | #include "fio.h" | |
3 | #include "fmt.h" | |
4 | extern char *f__icptr; | |
5 | char *f__icend; | |
6 | extern icilist *f__svic; | |
7 | int f__icnum; | |
8 | extern int f__hiwater; | |
9 | z_getc(Void) | |
10 | { | |
11 | if(f__recpos++ < f__svic->icirlen) { | |
12 | if(f__icptr >= f__icend) err(f__svic->iciend,(EOF),"endfile"); | |
13 | return(*f__icptr++); | |
14 | } | |
15 | return '\n'; | |
16 | } | |
17 | #ifdef KR_headers | |
18 | z_putc(c) | |
19 | #else | |
20 | z_putc(int c) | |
21 | #endif | |
22 | { | |
23 | if(f__icptr >= f__icend) err(f__svic->icierr,110,"inwrite"); | |
24 | if(f__recpos++ < f__svic->icirlen) | |
25 | *f__icptr++ = c; | |
26 | else err(f__svic->icierr,110,"recend"); | |
27 | return 0; | |
28 | } | |
29 | z_rnew(Void) | |
30 | { | |
31 | f__icptr = f__svic->iciunit + (++f__icnum)*f__svic->icirlen; | |
32 | f__recpos = 0; | |
33 | f__cursor = 0; | |
34 | f__hiwater = 0; | |
35 | return 1; | |
36 | } | |
37 | ||
38 | static int | |
39 | z_endp(Void) | |
40 | { | |
41 | (*f__donewrec)(); | |
42 | return 0; | |
43 | } | |
44 | ||
45 | #ifdef KR_headers | |
46 | c_si(a) icilist *a; | |
47 | #else | |
48 | c_si(icilist *a) | |
49 | #endif | |
50 | { | |
51 | f__elist = (cilist *)a; | |
52 | f__fmtbuf=a->icifmt; | |
53 | if(pars_f(f__fmtbuf)<0) | |
54 | err(a->icierr,100,"startint"); | |
55 | fmt_bg(); | |
56 | f__sequential=f__formatted=1; | |
57 | f__external=0; | |
58 | f__cblank=f__cplus=f__scale=0; | |
59 | f__svic=a; | |
60 | f__icnum=f__recpos=0; | |
61 | f__cursor = 0; | |
62 | f__hiwater = 0; | |
63 | f__icptr = a->iciunit; | |
64 | f__icend = f__icptr + a->icirlen*a->icirnum; | |
65 | f__curunit = 0; | |
66 | f__cf = 0; | |
67 | return(0); | |
68 | } | |
69 | ||
70 | int | |
71 | iw_rev(Void) | |
72 | { | |
73 | if(f__workdone) | |
74 | z_endp(); | |
75 | f__hiwater = f__recpos = f__cursor = 0; | |
76 | return(f__workdone=0); | |
77 | } | |
78 | ||
79 | #ifdef KR_headers | |
80 | integer s_rsfi(a) icilist *a; | |
81 | #else | |
82 | integer s_rsfi(icilist *a) | |
83 | #endif | |
84 | { int n; | |
85 | if(n=c_si(a)) return(n); | |
86 | f__reading=1; | |
87 | f__doed=rd_ed; | |
88 | f__doned=rd_ned; | |
89 | f__getn=z_getc; | |
90 | f__dorevert = z_endp; | |
91 | f__donewrec = z_rnew; | |
92 | f__doend = z_endp; | |
93 | return(0); | |
94 | } | |
95 | ||
96 | z_wnew(Void) | |
97 | { | |
98 | while(f__recpos++ < f__svic->icirlen) | |
99 | *f__icptr++ = ' '; | |
100 | f__recpos = 0; | |
101 | f__cursor = 0; | |
102 | f__hiwater = 0; | |
103 | f__icnum++; | |
104 | return 1; | |
105 | } | |
106 | #ifdef KR_headers | |
107 | integer s_wsfi(a) icilist *a; | |
108 | #else | |
109 | integer s_wsfi(icilist *a) | |
110 | #endif | |
111 | { int n; | |
112 | if(n=c_si(a)) return(n); | |
113 | f__reading=0; | |
114 | f__doed=w_ed; | |
115 | f__doned=w_ned; | |
116 | f__putn=z_putc; | |
117 | f__dorevert = iw_rev; | |
118 | f__donewrec = z_wnew; | |
119 | f__doend = z_endp; | |
120 | return(0); | |
121 | } | |
122 | integer e_rsfi(Void) | |
123 | { int n; | |
124 | n = en_fio(); | |
125 | f__fmtbuf = NULL; | |
126 | return(n); | |
127 | } | |
128 | integer e_wsfi(Void) | |
129 | { | |
130 | int n; | |
131 | n = en_fio(); | |
132 | f__fmtbuf = NULL; | |
133 | if(f__icnum >= f__svic->icirnum) | |
134 | return(n); | |
135 | while(f__recpos++ < f__svic->icirlen) | |
136 | *f__icptr++ = ' '; | |
137 | return(n); | |
138 | } |