ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/mac.c
Revision: 1.2
Committed: Tue Jul 1 21:21:40 2003 UTC (20 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R6P1, rad3R6
Changes since 1.1: +2 -2 lines
Log Message:
Compile fixes for gcc 3.3

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: mac.c,v 1.1 2003/02/22 02:07:26 greg Exp $";
3 #endif
4 /*
5 * Program to send meta-files to MacIntosh display routines
6 *
7 * cc -o mac mac.c macplot.o mqdraw.o mfio.o syscalls.o misc.o
8 */
9
10
11 #include <fcntl.h>
12
13 #include "meta.h"
14
15 #include "macplot.h"
16
17
18
19 char *progname;
20
21 int dxsize, dysize; /* screen dimensions */
22
23 static short newpage = TRUE;
24
25 static PRIMITIVE nextp;
26
27 static GrafPort ourPort;
28
29
30
31 main(argc, argv)
32
33 int argc;
34 char **argv;
35
36 {
37 FILE *fp;
38
39 progname = *argv++;
40 argc--;
41
42 while (argc && **argv == '-') {
43 switch (*(*argv+1)) {
44 default:
45 error(WARNING, "unknown option");
46 break;
47 }
48 argv++;
49 argc--;
50 }
51
52 /*
53 ******************** Unnecessary with shcroot and mixcroot
54 InitGraf(&thePort);
55 */
56
57 if (argc)
58 while (argc) {
59 fp = efopen(*argv, "r");
60 plot(fp);
61 fclose(fp);
62 argv++;
63 argc--;
64 }
65 else
66 plot(stdin);
67
68 }
69
70
71
72
73 plot(infp) /* plot meta-file */
74
75 register FILE *infp;
76
77 {
78
79 OpenPort(&ourPort);
80 TextFont(4); /* 9-point Monaco */
81 TextSize(9);
82
83 dxsize = dysize = min(ourPort.portRect.right - ourPort.portRect.left,
84 ourPort.portRect.bottom - ourPort.portRect.top);
85
86 do {
87 readp(&nextp, infp);
88 while (isprim(nextp.com)) {
89 doprim(&nextp);
90 fargs(&nextp);
91 readp(&nextp, infp);
92 }
93 doglobal(&nextp);
94 fargs(&nextp);
95 } while (nextp.com != PEOF);
96
97 ClosePort(&ourPort);
98
99 }
100
101
102
103
104
105 doglobal(g) /* execute a global command */
106
107 register PRIMITIVE *g;
108
109 {
110 int tty;
111 char c;
112
113 switch (g->com) {
114
115 case PEOF:
116 break;
117
118 case PDRAW:
119 break;
120
121 case PEOP:
122 newpage = TRUE;
123 /* fall through */
124
125 case PPAUS:
126 fflush(stdout);
127 tty = open(TTY, O_RDWR);
128 if (g->args != NULL) {
129 write(tty, g->args, strlen(g->args));
130 write(tty, " - (hit return to continue)", 27);
131 } else
132 write(tty, "\007", 1);
133 do {
134 c = '\n';
135 read(tty, &c, 1);
136 } while (c != '\n' && c != '\r');
137 close(tty);
138 break;
139
140 case PSET:
141 set(g->arg0, g->args);
142 break;
143
144 case PUNSET:
145 unset(g->arg0);
146 break;
147
148 case PRESET:
149 reset(g->arg0);
150 break;
151
152 default:
153 sprintf(errmsg, "unknown command '%c' in doglobal", g->com);
154 error(WARNING, errmsg);
155 break;
156 }
157
158 }
159
160
161
162
163 doprim(p) /* plot primitive */
164
165 register PRIMITIVE *p;
166
167 {
168
169 if (newpage) {
170 EraseRgn(ourPort.visRgn);
171 newpage = FALSE;
172 }
173
174 switch (p->com) {
175
176 case PLSEG:
177 plotlseg(p);
178 break;
179
180 case PMSTR:
181 printstr(p);
182 break;
183
184 case PRFILL:
185 fillrect(p);
186 break;
187
188 case PTFILL:
189 filltri(p);
190 break;
191
192 case PPFILL:
193 fillpoly(p);
194 break;
195
196 default:
197 sprintf(errmsg, "unknown command '%c' in doprim", p->com);
198 error(WARNING, errmsg);
199 return;
200 }
201
202 }