ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/meta/okimate.c
Revision: 1.2
Committed: Fri Aug 1 14:14:24 2003 UTC (20 years, 9 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: okimate.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 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    
41    
42     #include "meta.h"
43    
44     #include "plot.h"
45    
46     #include "span.h"
47    
48    
49    
50    
51     char *progname;
52    
53     struct span outspan;
54    
55     int dxsize = DXSIZE, dysize = DYSIZE,
56     linwidt = LINWIDT, linhite = LINHITE,
57     nrows = (LINHITE-1)/8+1;
58    
59     int maxalloc = MAXALLOC;
60    
61     int spanmin = 0, spanmax = LINWIDT-1;
62    
63     int charwidth = CHARWIDTH;
64    
65     static char chrtype[16][4] = {
66     "",
67     "\016",
68     "",
69     "\016",
70     "\033:",
71     "\033:\016",
72     "\033:",
73     "\033:\016",
74     "\017",
75     "\017\016",
76     "\017",
77     "\017\016",
78     "\017",
79     "",
80     "\017",
81     ""
82     };
83    
84     static int lineno = 0;
85    
86     static short condonly = FALSE,
87     conditioned = FALSE;
88    
89    
90     main(argc, argv)
91    
92     int argc;
93     char **argv;
94    
95     {
96     FILE *fp;
97     FILE *popen();
98     char comargs[200], command[300];
99    
100     progname = *argv++;
101     argc--;
102    
103     condonly = FALSE;
104     conditioned = FALSE;
105    
106     minwidth = 1; /* so lines aren't invisible */
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    
171     thispage() /* rewind and initialize current page */
172    
173     {
174    
175     if (lineno)
176     error(USER, "cannot restart page in thispage");
177    
178     }
179    
180    
181    
182    
183     nextpage() /* advance to next page */
184    
185     {
186    
187     fputs("\r\f", stdout);
188    
189     lineno = 0;
190    
191     }
192    
193    
194    
195    
196     contpage() /* continue new plot on current page */
197    
198     {
199    
200     while (lineno++ < NLINES)
201     putc('\n', stdout);
202    
203     lineno = 0;
204    
205     }
206    
207    
208    
209     printspan() /* output span to printer */
210    
211     {
212     register int i,j;
213    
214     if (spanmin <= spanmax) {
215     j = spanmin/charwidth;
216     while (j--)
217     putc(' ', stdout);
218    
219     fputs(GRPH, stdout);
220     j = spanmin%charwidth;
221     putc((spanmax-spanmin+j+1)%256, stdout);
222     putc((spanmax-spanmin+j+1)/256, stdout);
223    
224     j *= 3;
225     while (j--)
226     putc('\0', stdout);
227    
228     for (i = spanmin; i <= spanmax; i++)
229     for (j = 2; j >= 0; j--)
230     putc(outspan.cols[j*dxsize + i], stdout);
231     }
232     fputs("\r\n", stdout);
233     lineno++;
234    
235     }
236    
237    
238    
239    
240    
241     printstr(p) /* output a string to the printer */
242    
243     PRIMITIVE *p;
244    
245     {
246     int i;
247    
248     i = CONV(p->xy[XMN], dxsize)/charwidth;
249     while (i--)
250     putc(' ', stdout);
251    
252     if (p->arg0 & 0100) /* double strike */
253     fputs(DBLON, stdout);
254    
255     fputs(chrtype[(p->arg0 >> 2) & 017], stdout);
256     fputs(p->args, stdout);
257     fputs(PNORM, stdout);
258     putc('\r', stdout);
259    
260     }