|
|
1.1 root 1: #include "idfilt.h"
2:
3: FILE *infile;
4: char *filename;
5: int lineno = 0;
6:
7: float maxx, maxy;
8: float minx, miny;
9: float width = 4.0;
10: float height;
11: float colwid = 6.0;
12:
13: boolean maxxset, maxyset;
14: boolean minxset, minyset;
15: boolean widset, heightset, colset;
16: boolean boundset;
17:
18: boolean veryfirst = TRUE;
19:
20: boolean wantquality = FALSE;
21: boolean banzai = FALSE;
22: boolean samescale = FALSE;
23:
24: main (argc, argv)
25: int argc;
26: char *argv[];
27: {
28: while (argc > 1 && argv[1][0] == '-') {
29: switch (argv[1][1]) {
30: case 'q':
31: wantquality = TRUE;
32: break;
33: case 'b':
34: banzai = TRUE;
35: break;
36: default:
37: fprintf (stderr, "ideal filter: unknown flag %c\n", argv[1][1]);
38: break;
39: }
40: argc--;
41: argv++;
42: }
43: if (argc < 2) {
44: infile = stdin;
45: lineno = 0;
46: interpret (infile);
47: } else {
48: while (argc-- > 1) {
49: if (!(infile = fopen (*++argv, "r"))) {
50: fprintf (stderr, "ideal filter: can't open %s\n", *argv);
51: exit (1);
52: }
53: filename = *argv;
54: lineno = 0;
55: interpret (infile);
56: fclose (infile);
57: }
58: }
59: exit (0);
60: }
61:
62: interpret (infile)
63: register FILE *infile;
64: {
65: char buf[250];
66:
67: int numitems, inIS = FALSE;
68: char cmd[10];
69: int i[10];
70: float f[30];
71: char *string;
72:
73:
74: while (fgets (buf, sizeof buf, infile)) {
75: lineno++;
76: idjusttext (buf);
77: if (buf[0] == '.') {
78: if (buf[1] == 'I') {
79: switch (buf[2]) {
80: case 'S':
81: numitems = sscanf (buf, "%s %d %d %d %d %d %d",
82: cmd, &i[0], &i[1], &i[2], &i[3], &i[4], &i[5]
83: );
84: idstart (numitems, i);
85: maxxset = minxset = FALSE;
86: maxyset = minyset = FALSE;
87: colset = widset = heightset = FALSE;
88: boundset = samescale = FALSE;
89: inIS = TRUE;
90: break;
91: case 'E':
92: idendE ();
93: boundset = FALSE;
94: inIS = FALSE;
95: break;
96: case 'F':
97: idendF ();
98: inIS = FALSE;
99: break;
100: default:
101: break;
102: }
103: } else if (inIS && buf[1] == '.' && buf[2] == '.') {
104: sscanf (buf, "%s", cmd);
105: if (!boundset) {
106: if (strcmp (cmd, "...maxx") == 0) {
107: sscanf (buf, "%s %f",
108: cmd, &f[0]
109: );
110: idmaxx (f[0]);
111: } else if (strcmp (cmd, "...maxy") == 0) {
112: sscanf (buf, "%s %f",
113: cmd, &f[0]
114: );
115: idmaxy (f[0]);
116: } else if (strcmp (cmd, "...minx") == 0) {
117: sscanf (buf, "%s %f",
118: cmd, &f[0]
119: );
120: idminx (f[0]);
121: } else if (strcmp (cmd, "...miny") == 0) {
122: sscanf (buf, "%s %f",
123: cmd, &f[0]
124: );
125: idminy (f[0]);
126: } else if (strcmp (cmd, "...width") == 0) {
127: sscanf (buf, "%s %f",
128: cmd, &f[0]
129: );
130: idwidth (f[0]);
131: } else if (strcmp (cmd, "...height") == 0) {
132: sscanf (buf, "%s %f",
133: cmd, &f[0]
134: );
135: idheight (f[0]);
136: } else if (strcmp (cmd, "...colwid") == 0) {
137: sscanf (buf, "%s %f",
138: cmd, &f[0]
139: );
140: idcolwid (f[0]);
141: } else if (strcmp (cmd, "...obbox") == 0) {
142: if (!veryfirst) {
143: maxxset = maxyset = TRUE;
144: minxset = minyset = TRUE;
145: boundset = TRUE;
146: }
147: } else if (strcmp (cmd, "...samescale") == 0) {
148: if (!veryfirst)
149: samescale = TRUE;
150: } else if (strcmp (cmd, "...noerase") == 0) {
151: idnoerase ();
152: } else if (strcmp (cmd, "...yeserase") == 0) {
153: idyeserase ();
154: } else {
155: idendbound ();
156: veryfirst = FALSE;
157: }
158: }
159: if (boundset) {
160: if (strcmp (cmd, "...line") == 0) {
161: sscanf (buf, "%s %f %f %f %f",
162: cmd, &f[0], &f[1], &f[2], &f[3]
163: );
164: idline (f[0], f[1], f[2], f[3]);
165: } else if (strcmp (cmd, "...circle") == 0) {
166: sscanf (buf, "%s %f %f %f",
167: cmd, &f[0], &f[1], &f[2]
168: );
169: idcircle (f[0], f[1], f[2]);
170: } else if (strcmp (cmd, "...arc") == 0) {
171: sscanf (buf, "%s %f %f %f %f %f %f %f %f %f",
172: cmd, &f[0], &f[1], &f[2], &f[3], &f[4], &f[5], &f[6], &f[7], &f[8]
173: );
174: idarc (f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], f[8]);
175: } else if (strcmp (cmd, "...left") == 0) {
176: sscanf (buf, "%s %f %f",
177: cmd, &f[0], &f[1]
178: );
179: buf[strlen(buf)-1] = '\0';
180: string = buf;
181: while (*string != '\'')
182: string ++;
183: idleft (f[0], f[1], string);
184: } else if (strcmp (cmd, "...center") == 0) {
185: sscanf (buf, "%s %f %f",
186: cmd, &f[0], &f[1]
187: );
188: buf[strlen(buf)-1] = '\0';
189: string = buf;
190: while (*string != '\'')
191: string ++;
192: idcenter (f[0], f[1], string);
193: } else if (strcmp (cmd, "...right") == 0) {
194: sscanf (buf, "%s %f %f",
195: cmd, &f[0], &f[1]
196: );
197: buf[strlen(buf)-1] = '\0';
198: string = buf;
199: while (*string != '\'')
200: string ++;
201: idright (f[0], f[1], string);
202: } else if (strcmp (cmd, "...spline") == 0) {
203: sscanf (buf, "%s %f %f",
204: cmd, &f[0], &f[1]
205: );
206: idspline (f[0], f[1]);
207: } else if (strcmp (cmd, "...knot") == 0) {
208: sscanf (buf, "%s %f %f",
209: cmd, &f[0], &f[1]
210: );
211: idknot (f[0], f[1]);
212: } else if (strcmp (cmd, "...endspline") == 0) {
213: idendspline ();
214: }
215: }
216: }
217: }
218: }
219: }
220:
221: void idmaxx (x)
222: float x;
223: {
224: if (!maxxset) {
225: maxx = x;
226: maxxset = TRUE;
227: }
228: }
229:
230: void idmaxy (y)
231: float y;
232: {
233: if (!maxyset) {
234: maxy = y;
235: maxyset = TRUE;
236: }
237: }
238:
239: void idminx (x)
240: float x;
241: {
242: if (!minxset) {
243: minx = x;
244: minxset = TRUE;
245: }
246: }
247:
248: void idminy (y)
249: float y;
250: {
251: if (!minyset) {
252: miny = y;
253: minyset = TRUE;
254: }
255: }
256:
257: void idwidth (wid)
258: float wid;
259: {
260: if (!widset) {
261: width = wid;
262: widset = TRUE;
263: }
264: }
265:
266: void idheight (ht)
267: float ht;
268: {
269: if (!heightset) {
270: height = ht;
271: heightset = TRUE;
272: }
273: }
274:
275: void idcolwid (wid)
276: float wid;
277: {
278: if (!colset) {
279: colwid = wid;
280: colset = TRUE;
281: }
282: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.