ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/macprt.c
Revision: 1.2
Committed: Tue Jul 1 21:21:40 2003 UTC (20 years, 10 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

# User Rev Content
1 greg 1.1 #ifndef lint
2 greg 1.2 static const char RCSid[] = "$Id: macprt.c,v 1.1 2003/02/22 02:07:26 greg Exp $";
3 greg 1.1 #endif
4     /*
5     * Program to send meta-files to MacIntosh printer
6     *
7     * cc -o macprt macprt.c macplot.o mfio.o syscalls.o misc.o -lplot
8     */
9    
10    
11     #include <fcntl.h>
12    
13     #include "meta.h"
14    
15     #include "macplot.h"
16    
17     #include <print.h>
18    
19    
20    
21     char *progname;
22    
23     int dxsize, dysize; /* plot dimensions */
24    
25     static short newpage = TRUE;
26    
27     static PRIMITIVE nextp;
28    
29     static GrafPort ourPort;
30    
31    
32    
33     main(argc, argv)
34    
35     int argc;
36     char **argv;
37    
38     {
39     FILE *fp;
40    
41     progname = *argv++;
42     argc--;
43    
44     while (argc && **argv == '-') {
45     switch (*(*argv+1)) {
46     default:
47     error(WARNING, "unknown option");
48     break;
49     }
50     argv++;
51     argc--;
52     }
53    
54     InitGraf(&thePort);
55    
56     if (argc)
57     while (argc) {
58     fp = efopen(*argv, "r");
59     plot(fp);
60     fclose(fp);
61     argv++;
62     argc--;
63     }
64     else
65     plot(stdin);
66    
67     return(0);
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     fflush(stdout);
120     break;
121    
122     case PEOP:
123     newpage = TRUE;
124     /* fall through */
125    
126 greg 1.2 case PPAUS:
127 greg 1.1 fflush(stdout);
128     tty = open(TTY, O_RDWR);
129     if (g->args != NULL) {
130     write(tty, g->args, strlen(g->args));
131     write(tty, " - (hit return to continue)", 27);
132     } else
133     write(tty, "\007", 1);
134     do {
135     c = '\n';
136     read(tty, &c, 1);
137     } while (c != '\n' && c != '\r');
138     close(tty);
139     break;
140    
141     case PSET:
142     set(g->arg0, g->args);
143     break;
144    
145     case PUNSET:
146     unset(g->arg0);
147     break;
148    
149     case PRESET:
150     reset(g->arg0);
151     break;
152    
153     default:
154     sprintf(errmsg, "unknown command '%c' in doglobal", g->com);
155     error(WARNING, errmsg);
156     break;
157     }
158    
159     }
160    
161    
162    
163    
164     doprim(p) /* plot primitive */
165    
166     register PRIMITIVE *p;
167    
168     {
169    
170     if (newpage) {
171     EraseRgn(ourPort.visRgn);
172     newpage = FALSE;
173     }
174    
175     switch (p->com) {
176    
177     case PLSEG:
178     plotlseg(p);
179     break;
180    
181     case PMSTR:
182     printstr(p);
183     break;
184    
185     case PRFILL:
186     fillrect(p);
187     break;
188    
189     case PTFILL:
190     filltri(p);
191     break;
192    
193     case PPFILL:
194     fillpoly(p);
195     break;
196    
197     default:
198     sprintf(errmsg, "unknown command '%c' in doprim", p->com);
199     error(WARNING, errmsg);
200     return;
201     }
202    
203     }