ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/mt160.c
Revision: 1.2
Committed: Fri Aug 1 14:14:24 2003 UTC (20 years, 10 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 1.1: +1 -15 lines
Log Message:
Eliminated CPM, MAC, and UNIX conditional compiles.

File Contents

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