ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/okimate.c
Revision: 1.3
Committed: Mon Oct 27 10:28:59 2003 UTC (20 years, 7 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 1.2: +2 -8 lines
Log Message:
Various compatibility fixes.

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: okimate.c,v 1.2 2003/08/01 14:14:24 schorsch Exp $";
3 #endif
4 /*
5 * Program to print meta-files on a dot-matrix printer
6 *
7 * cc -o okimate okimate.c mplot.o plot.o mfio.o syscalls.o palloc.o misc.o
8 *
9 * Okimate 20 printer (version for black ribbon)
10 */
11
12
13 #define MAXALLOC 5000
14
15 #define DXSIZE 960 /* x resolution */
16
17 #define DYSIZE 1152 /* y resolution */
18
19 #define LINWIDT DXSIZE /* line width */
20
21 #define LINHITE 24 /* line height */
22
23 #define NLINES (DYSIZE/LINHITE) /* number of lines */
24
25 #define CHARWIDTH 12
26
27 #define PNORM "\024\022\033%H"
28
29 #define PINIT "\033O\033T\033I\002\033%H\033T\022\033A\014\0332"
30
31 #define PUNINIT ""
32
33 #define DBLON "\033%G"
34
35 #define GRPH "\033%O"
36
37 #define XCOM "pexpand +vOCIsp %s | psort -Y +x"
38
39
40 #include "rtprocess.h"
41 #include "meta.h"
42 #include "plot.h"
43 #include "span.h"
44
45
46 char *progname;
47
48 struct span outspan;
49
50 int dxsize = DXSIZE, dysize = DYSIZE,
51 linwidt = LINWIDT, linhite = LINHITE,
52 nrows = (LINHITE-1)/8+1;
53
54 int maxalloc = MAXALLOC;
55
56 int spanmin = 0, spanmax = LINWIDT-1;
57
58 int charwidth = CHARWIDTH;
59
60 static char chrtype[16][4] = {
61 "",
62 "\016",
63 "",
64 "\016",
65 "\033:",
66 "\033:\016",
67 "\033:",
68 "\033:\016",
69 "\017",
70 "\017\016",
71 "\017",
72 "\017\016",
73 "\017",
74 "",
75 "\017",
76 ""
77 };
78
79 static int lineno = 0;
80
81 static short condonly = FALSE,
82 conditioned = FALSE;
83
84
85 main(argc, argv)
86
87 int argc;
88 char **argv;
89
90 {
91 FILE *fp;
92 char comargs[200], command[300];
93
94 progname = *argv++;
95 argc--;
96
97 condonly = FALSE;
98 conditioned = FALSE;
99
100 minwidth = 1; /* so lines aren't invisible */
101
102 while (argc && **argv == '-') {
103 switch (*(*argv+1)) {
104 case 'c':
105 condonly = TRUE;
106 break;
107 case 'r':
108 conditioned = TRUE;
109 break;
110 default:
111 error(WARNING, "unknown option");
112 break;
113 }
114 argv++;
115 argc--;
116 }
117
118 if (conditioned) {
119 fputs(PINIT, stdout);
120 if (argc)
121 while (argc) {
122 fp = efopen(*argv, "r");
123 plot(fp);
124 fclose(fp);
125 argv++;
126 argc--;
127 }
128 else
129 plot(stdin);
130 if (lineno)
131 nextpage();
132 fputs(PUNINIT, stdout);
133 } else {
134 comargs[0] = '\0';
135 while (argc) {
136 strcat(comargs, " ");
137 strcat(comargs, *argv);
138 argv++;
139 argc--;
140 }
141 sprintf(command, XCOM, comargs);
142 if (condonly)
143 return(system(command));
144 else {
145 fputs(PINIT, stdout);
146 if ((fp = popen(command, "r")) == NULL)
147 error(SYSTEM, "cannot execute input filter");
148 plot(fp);
149 pclose(fp);
150 if (lineno)
151 nextpage();
152 fputs(PUNINIT, stdout);
153 }
154 }
155
156 return(0);
157 }
158
159
160
161
162
163
164
165 thispage() /* rewind and initialize current page */
166
167 {
168
169 if (lineno)
170 error(USER, "cannot restart page in thispage");
171
172 }
173
174
175
176
177 nextpage() /* advance to next page */
178
179 {
180
181 fputs("\r\f", stdout);
182
183 lineno = 0;
184
185 }
186
187
188
189
190 contpage() /* continue new plot on current page */
191
192 {
193
194 while (lineno++ < NLINES)
195 putc('\n', stdout);
196
197 lineno = 0;
198
199 }
200
201
202
203 printspan() /* output span to printer */
204
205 {
206 register int i,j;
207
208 if (spanmin <= spanmax) {
209 j = spanmin/charwidth;
210 while (j--)
211 putc(' ', stdout);
212
213 fputs(GRPH, stdout);
214 j = spanmin%charwidth;
215 putc((spanmax-spanmin+j+1)%256, stdout);
216 putc((spanmax-spanmin+j+1)/256, stdout);
217
218 j *= 3;
219 while (j--)
220 putc('\0', stdout);
221
222 for (i = spanmin; i <= spanmax; i++)
223 for (j = 2; j >= 0; j--)
224 putc(outspan.cols[j*dxsize + i], stdout);
225 }
226 fputs("\r\n", stdout);
227 lineno++;
228
229 }
230
231
232
233
234
235 printstr(p) /* output a string to the printer */
236
237 PRIMITIVE *p;
238
239 {
240 int i;
241
242 i = CONV(p->xy[XMN], dxsize)/charwidth;
243 while (i--)
244 putc(' ', stdout);
245
246 if (p->arg0 & 0100) /* double strike */
247 fputs(DBLON, stdout);
248
249 fputs(chrtype[(p->arg0 >> 2) & 017], stdout);
250 fputs(p->args, stdout);
251 fputs(PNORM, stdout);
252 putc('\r', stdout);
253
254 }