ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/psmeta.c
Revision: 1.4
Committed: Sat Nov 15 02:13:37 2003 UTC (20 years, 11 months ago) by schorsch
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R4, rad5R2, rad4R2P2, rad5R0, rad5R1, rad3R7P2, rad3R7P1, rad4R2, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9, rad4R2P1, rad5R3, HEAD
Changes since 1.3: +23 -25 lines
Log Message:
Continued ANSIfication, and reduced other compile warnings.

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: psmeta.c,v 1.3 2003/07/21 22:30:18 schorsch Exp $";
3 #endif
4 /*
5 * Program to convert meta-files to PostScript.
6 *
7 * 9/23/88
8 */
9
10
11 #include "meta.h"
12 #include "plot.h"
13 #include "psplot.h"
14
15
16 char *progname;
17
18 static short newpage = TRUE;
19
20 static void doprim(PRIMITIVE *p);
21 static int doglobal(PRIMITIVE *g);
22
23 int
24 main(
25 int argc,
26 char **argv
27 )
28 {
29 FILE *fp;
30
31 progname = *argv++;
32 argc--;
33
34 init(progname);
35 if (argc)
36 while (argc) {
37 fp = efopen(*argv, "r");
38 plot(fp);
39 fclose(fp);
40 argv++;
41 argc--;
42 }
43 else
44 plot(stdin);
45
46 if (!newpage)
47 endpage();
48
49 done();
50 return(0);
51 }
52
53
54
55 void
56 plot( /* plot meta-file */
57 FILE *infp
58 )
59 {
60 PRIMITIVE nextp;
61
62 do {
63 readp(&nextp, infp);
64 while (isprim(nextp.com)) {
65 doprim(&nextp);
66 readp(&nextp, infp);
67 }
68 } while (doglobal(&nextp));
69
70 }
71
72
73 int
74 doglobal( /* execute a global command */
75 PRIMITIVE *g
76 )
77 {
78 FILE *fp = NULL;
79
80 switch (g->com) {
81
82 case PEOF:
83 return(0);
84
85 case PPAUS:
86 break;
87
88 case PINCL:
89 if (g->args == NULL)
90 error(USER, "missing include file name in include");
91 if (g->arg0 == 2 || (fp = fopen(g->args, "r")) == NULL) {
92 if (g->arg0 != 0)
93 fp = mfopen(g->args, "r");
94 else {
95 sprintf(errmsg, "cannot open user include file \"%s\"",
96 g->args);
97 error(USER, errmsg);
98 }
99 }
100 plot(fp);
101 fclose(fp);
102 break;
103
104 case PDRAW:
105 fflush(stdout);
106 break;
107
108 case PEOP:
109 endpage();
110 newpage = TRUE;
111 break;
112
113 case PSET:
114 set(g->arg0, g->args);
115 break;
116
117 case PUNSET:
118 unset(g->arg0);
119 break;
120
121 case PRESET:
122 reset(g->arg0);
123 break;
124
125 case POPEN:
126 segopen(g->args);
127 break;
128
129 case PCLOSE:
130 segclose();
131 break;
132
133 default:
134 sprintf(errmsg, "unknown command '%c' in doglobal", g->com);
135 error(WARNING, errmsg);
136 break;
137 }
138
139 return(1);
140 }
141
142
143
144 void
145 doprim( /* plot primitive */
146 PRIMITIVE *p
147 )
148 {
149
150 switch (p->com) {
151
152 case PMSTR:
153 printstr(p);
154 break;
155
156 case PVSTR:
157 plotvstr(p);
158 break;
159
160 case PLSEG:
161 plotlseg(p);
162 break;
163
164 case PRFILL:
165 fillrect(p);
166 break;
167
168 case PTFILL:
169 filltri(p);
170 break;
171
172 case PPFILL:
173 fillpoly(p);
174 break;
175
176 case PSEG:
177 doseg(p);
178 break;
179
180 default:
181 sprintf(errmsg, "unknown command '%c' in doprim", p->com);
182 error(WARNING, errmsg);
183 return;
184 }
185 newpage = FALSE;
186 }
187