ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/mx80.c
Revision: 1.3
Committed: Mon Oct 27 10:28:59 2003 UTC (20 years, 6 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: mx80.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 mx80 mx80.c mplot.o plot.o mfio.o syscalls.o palloc.o misc.o
8 *
9 * Epson MX-80 printer
10 */
11
12
13 #define MAXALLOC 5000
14
15 #define DXSIZE 480 /* x resolution */
16
17 #define DYSIZE 616 /* y resolution */
18
19 #define LINWIDT DXSIZE /* line width */
20
21 #define LINHITE 8 /* line height */
22
23 #define NLINES (DYSIZE/LINHITE) /* number of lines */
24
25 #define CHARWIDTH 6
26
27 #define PNORM ""
28
29 #define PINIT "\033@\033#\0331\033U1"
30
31 #define PUNINIT "\033@\033="
32
33 #define OUTPUT "\033K"
34
35 #define XCOM "pexpand +vOCIsp %s | psort -Y +x"
36
37
38
39 #include "rtprocess.h"
40 #include "meta.h"
41 #include "plot.h"
42 #include "span.h"
43
44
45 char *progname;
46
47 struct span outspan;
48
49 int dxsize = DXSIZE, dysize = DYSIZE,
50 linwidt = LINWIDT, linhite = LINHITE,
51 nrows = (LINHITE-1)/8+1;
52
53 int maxalloc = MAXALLOC;
54
55 int spanmin = 0, spanmax = LINWIDT-1;
56
57 int charwidth = CHARWIDTH;
58
59 static int lineno = 0;
60
61 static short condonly = FALSE,
62 conditioned = FALSE;
63
64
65 main(argc, argv)
66
67 int argc;
68 char **argv;
69
70 {
71 FILE *fp;
72 char comargs[200], command[300];
73
74 progname = *argv++;
75 argc--;
76
77 condonly = FALSE;
78 conditioned = FALSE;
79
80 while (argc && **argv == '-') {
81 switch (*(*argv+1)) {
82 case 'c':
83 condonly = TRUE;
84 break;
85 case 'r':
86 conditioned = TRUE;
87 break;
88 default:
89 error(WARNING, "unknown option");
90 break;
91 }
92 argv++;
93 argc--;
94 }
95
96 if (conditioned) {
97 fputs(PINIT, stdout);
98 if (argc)
99 while (argc) {
100 fp = efopen(*argv, "r");
101 plot(fp);
102 fclose(fp);
103 argv++;
104 argc--;
105 }
106 else
107 plot(stdin);
108 fputs(PUNINIT, stdout);
109 } else {
110 comargs[0] = '\0';
111 while (argc) {
112 strcat(comargs, " ");
113 strcat(comargs, *argv);
114 argv++;
115 argc--;
116 }
117 sprintf(command, XCOM, comargs);
118 if (condonly)
119 return(system(command));
120 else {
121 fputs(PINIT, stdout);
122 if ((fp = popen(command, "r")) == NULL)
123 error(SYSTEM, "cannot execute input filter");
124 plot(fp);
125 pclose(fp);
126 fputs(PUNINIT, stdout);
127 }
128 }
129
130 return(0);
131 }
132
133
134
135
136
137
138
139 thispage() /* rewind and initialize current page */
140
141 {
142
143 if (lineno)
144 error(USER, "cannot restart page in thispage");
145
146 }
147
148
149
150
151 nextpage() /* advance to next page */
152
153 {
154
155 fputs("\f\r", stdout);
156
157 lineno = 0;
158
159 }
160
161
162
163
164 contpage() /* continue new plot on current page */
165
166 {
167
168 while (lineno++ < NLINES)
169 putc('\n', stdout);
170
171 lineno = 0;
172
173 }
174
175
176
177 printspan() /* output span to printer */
178
179 {
180 register int k;
181
182 if (spanmin <= spanmax) {
183
184 k = spanmin/charwidth;
185 while (k--)
186 putc(' ', stdout);
187
188 k = spanmin%charwidth;
189 fputs(OUTPUT, stdout);
190 putc((spanmax-spanmin+k+1)%256, stdout);
191 putc((spanmax-spanmin+k+1)/256, stdout);
192 while (k--)
193 putc('\0', stdout);
194
195 for (k = spanmin; k <= spanmax; k++)
196 putc(outspan.cols[k], stdout);
197
198 putc('\r', stdout);
199 }
200 putc('\n', stdout);
201 lineno++;
202
203 }
204
205
206
207
208
209 printstr(p) /* output a string to the printer */
210
211 PRIMITIVE *p;
212
213 {
214 int i;
215
216 i = CONV(p->xy[XMN], dxsize)/charwidth;
217 while (i--)
218 putc(' ', stdout);
219
220 fputs(p->args, stdout);
221 fputs(PNORM, stdout);
222 putc('\r', stdout);
223
224 }