9 |
|
* 2/26/86 |
10 |
|
*/ |
11 |
|
|
12 |
< |
|
12 |
> |
#include "rtprocess.h" |
13 |
> |
#include "string.h" |
14 |
|
#include "meta.h" |
14 |
– |
|
15 |
|
#include "plot.h" |
16 |
|
|
17 |
|
|
31 |
|
|
32 |
|
int maxalloc = 0; /* no limit */ |
33 |
|
|
34 |
+ |
extern void pXFlush(void); |
35 |
|
|
36 |
|
|
37 |
< |
main(argc, argv) |
37 |
< |
|
38 |
< |
int argc; |
39 |
< |
char **argv; |
40 |
< |
|
41 |
< |
{ |
42 |
< |
FILE *fp; |
43 |
< |
FILE *popen(); |
44 |
< |
char *geometry = NULL; |
45 |
< |
short condonly, conditioned; |
46 |
< |
char comargs[500], command[600]; |
47 |
< |
|
48 |
< |
progname = *argv++; |
49 |
< |
argc--; |
50 |
< |
|
51 |
< |
condonly = FALSE; |
52 |
< |
conditioned = FALSE; |
53 |
< |
|
54 |
< |
for ( ; argc; argv++, argc--) |
55 |
< |
if (!strcmp(*argv, "-c")) |
56 |
< |
condonly = TRUE; |
57 |
< |
else if (!strcmp(*argv, "-r")) |
58 |
< |
conditioned = TRUE; |
59 |
< |
else if (**argv == '=') |
60 |
< |
geometry = *argv; |
61 |
< |
else |
62 |
< |
break; |
63 |
< |
|
64 |
< |
if (conditioned) { |
65 |
< |
init(progname, geometry); |
66 |
< |
if (argc) |
67 |
< |
while (argc) { |
68 |
< |
fp = efopen(*argv, "r"); |
69 |
< |
plot(fp); |
70 |
< |
fclose(fp); |
71 |
< |
argv++; |
72 |
< |
argc--; |
73 |
< |
} |
74 |
< |
else |
75 |
< |
plot(stdin); |
76 |
< |
} else { |
77 |
< |
comargs[0] = '\0'; |
78 |
< |
while (argc) { |
79 |
< |
strcat(comargs, " "); |
80 |
< |
strcat(comargs, *argv); |
81 |
< |
argv++; |
82 |
< |
argc--; |
83 |
< |
} |
84 |
< |
sprintf(command, XCOM, comargs); |
85 |
< |
if (condonly) |
86 |
< |
return(system(command)); |
87 |
< |
else { |
88 |
< |
init(progname, geometry); |
89 |
< |
if ((fp = popen(command, "r")) == NULL) |
90 |
< |
error(SYSTEM, "cannot execute input filter"); |
91 |
< |
plot(fp); |
92 |
< |
pclose(fp); |
93 |
< |
} |
94 |
< |
} |
95 |
< |
|
96 |
< |
if (!newpage) |
97 |
< |
endpage(); |
98 |
< |
|
99 |
< |
return(0); |
100 |
< |
} |
101 |
< |
|
102 |
< |
|
103 |
< |
|
104 |
< |
|
105 |
< |
plot(infp) /* plot meta-file */ |
106 |
< |
|
107 |
< |
FILE *infp; |
108 |
< |
|
109 |
< |
{ |
110 |
< |
PRIMITIVE nextp; |
111 |
< |
|
112 |
< |
set(SALL, NULL); |
113 |
< |
do { |
114 |
< |
readp(&nextp, infp); |
115 |
< |
while (isprim(nextp.com)) { |
116 |
< |
doprim(&nextp, 1); |
117 |
< |
readp(&nextp, infp); |
118 |
< |
} |
119 |
< |
doglobal(&nextp, 1); |
120 |
< |
} while (nextp.com != PEOF); |
121 |
< |
|
122 |
< |
} |
123 |
< |
|
124 |
< |
|
125 |
< |
|
126 |
< |
replay(xmin, ymin, xmax, ymax) /* play back region */ |
127 |
< |
int xmin, ymin, xmax, ymax; |
128 |
< |
{ |
129 |
< |
register PRIMITIVE *p; |
130 |
< |
|
131 |
< |
unset(SALL); |
132 |
< |
set(SALL, NULL); |
133 |
< |
for (p = recording.ptop; p != NULL; p = p->pnext) |
134 |
< |
if (isprim(p->com)) { |
135 |
< |
if (overlap(p, xmin, ymin, xmax, ymax)) |
136 |
< |
doprim(p, 0); |
137 |
< |
} else |
138 |
< |
doglobal(p, 0); |
139 |
< |
|
140 |
< |
} |
141 |
< |
|
142 |
< |
|
143 |
< |
|
144 |
< |
|
37 |
> |
void |
38 |
|
save(p) /* record primitive */ |
39 |
|
PRIMITIVE *p; |
40 |
|
{ |
42 |
|
|
43 |
|
if ((pnew = palloc()) == NULL) |
44 |
|
error(SYSTEM, "out of memory in save"); |
45 |
< |
mcopy(pnew, p, sizeof(PRIMITIVE)); |
45 |
> |
mcopy((char *)pnew, (char *)p, sizeof(PRIMITIVE)); |
46 |
|
add(pnew, &recording); |
47 |
|
} |
48 |
|
|
49 |
|
|
50 |
< |
|
158 |
< |
|
50 |
> |
void |
51 |
|
doglobal(g, sf) /* execute a global command */ |
160 |
– |
|
52 |
|
register PRIMITIVE *g; |
53 |
|
int sf; |
163 |
– |
|
54 |
|
{ |
55 |
|
|
56 |
|
switch (g->com) { |
59 |
|
return; |
60 |
|
|
61 |
|
case PDRAW: |
62 |
< |
XFlush(); |
62 |
> |
pXFlush(); |
63 |
|
break; |
64 |
|
|
65 |
|
case PEOP: |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
< |
|
206 |
< |
|
95 |
> |
void |
96 |
|
doprim(p, sf) /* plot primitive */ |
208 |
– |
|
97 |
|
register PRIMITIVE *p; |
98 |
|
int sf; |
211 |
– |
|
99 |
|
{ |
100 |
|
|
101 |
|
switch (p->com) { |
131 |
|
} |
132 |
|
|
133 |
|
} |
134 |
+ |
|
135 |
+ |
|
136 |
+ |
void |
137 |
+ |
plot(infp) /* plot meta-file */ |
138 |
+ |
FILE *infp; |
139 |
+ |
{ |
140 |
+ |
PRIMITIVE nextp; |
141 |
+ |
|
142 |
+ |
set(SALL, NULL); |
143 |
+ |
do { |
144 |
+ |
readp(&nextp, infp); |
145 |
+ |
while (isprim(nextp.com)) { |
146 |
+ |
doprim(&nextp, 1); |
147 |
+ |
readp(&nextp, infp); |
148 |
+ |
} |
149 |
+ |
doglobal(&nextp, 1); |
150 |
+ |
} while (nextp.com != PEOF); |
151 |
+ |
|
152 |
+ |
} |
153 |
+ |
|
154 |
+ |
|
155 |
+ |
void |
156 |
+ |
replay(xmin, ymin, xmax, ymax) /* play back region */ |
157 |
+ |
int xmin, ymin, xmax, ymax; |
158 |
+ |
{ |
159 |
+ |
register PRIMITIVE *p; |
160 |
+ |
|
161 |
+ |
unset(SALL); |
162 |
+ |
set(SALL, NULL); |
163 |
+ |
for (p = recording.ptop; p != NULL; p = p->pnext) |
164 |
+ |
if (isprim(p->com)) { |
165 |
+ |
if (overlap(p, xmin, ymin, xmax, ymax)) |
166 |
+ |
doprim(p, 0); |
167 |
+ |
} else |
168 |
+ |
doglobal(p, 0); |
169 |
+ |
|
170 |
+ |
} |
171 |
+ |
|
172 |
+ |
|
173 |
+ |
int |
174 |
+ |
main(argc, argv) |
175 |
+ |
int argc; |
176 |
+ |
char **argv; |
177 |
+ |
{ |
178 |
+ |
FILE *fp; |
179 |
+ |
char *geometry = NULL; |
180 |
+ |
short condonly, conditioned; |
181 |
+ |
char comargs[500], command[600]; |
182 |
+ |
|
183 |
+ |
progname = *argv++; |
184 |
+ |
argc--; |
185 |
+ |
|
186 |
+ |
condonly = FALSE; |
187 |
+ |
conditioned = FALSE; |
188 |
+ |
|
189 |
+ |
for ( ; argc; argv++, argc--) |
190 |
+ |
if (!strcmp(*argv, "-c")) |
191 |
+ |
condonly = TRUE; |
192 |
+ |
else if (!strcmp(*argv, "-r")) |
193 |
+ |
conditioned = TRUE; |
194 |
+ |
else if (**argv == '=') |
195 |
+ |
geometry = *argv; |
196 |
+ |
else |
197 |
+ |
break; |
198 |
+ |
|
199 |
+ |
if (conditioned) { |
200 |
+ |
init(progname, geometry); |
201 |
+ |
if (argc) |
202 |
+ |
while (argc) { |
203 |
+ |
fp = efopen(*argv, "r"); |
204 |
+ |
plot(fp); |
205 |
+ |
fclose(fp); |
206 |
+ |
argv++; |
207 |
+ |
argc--; |
208 |
+ |
} |
209 |
+ |
else |
210 |
+ |
plot(stdin); |
211 |
+ |
} else { |
212 |
+ |
comargs[0] = '\0'; |
213 |
+ |
while (argc) { |
214 |
+ |
strcat(comargs, " "); |
215 |
+ |
strcat(comargs, *argv); |
216 |
+ |
argv++; |
217 |
+ |
argc--; |
218 |
+ |
} |
219 |
+ |
sprintf(command, XCOM, comargs); |
220 |
+ |
if (condonly) |
221 |
+ |
return(system(command)); |
222 |
+ |
else { |
223 |
+ |
init(progname, geometry); |
224 |
+ |
if ((fp = popen(command, "r")) == NULL) |
225 |
+ |
error(SYSTEM, "cannot execute input filter"); |
226 |
+ |
plot(fp); |
227 |
+ |
pclose(fp); |
228 |
+ |
} |
229 |
+ |
} |
230 |
+ |
|
231 |
+ |
if (!newpage) |
232 |
+ |
endpage(); |
233 |
+ |
|
234 |
+ |
return(0); |
235 |
+ |
} |