ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/psmeta.c
Revision: 1.3
Committed: Mon Jul 21 22:30:18 2003 UTC (21 years, 3 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 1.2: +3 -2 lines
Log Message:
Eliminated copystruct() macro, which is unnecessary in ANSI.
Reduced ambiguity warnings for nested if/if/else clauses.

File Contents

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