1 /*
2 *
3 * dver: VAX Versatec driver for the new troff
4 *
5 * Authors: BWK(BELL)
6 * VCAT(berkley)
7 * Richard L. Hyde, Perdue University
8 * and David Slattengren, U.C. Berkeley
9 *
10 * Jaap Akkerhuis
11 * added Versatec80 support
12 * removed Berkeley specific stuff (like nstips)
13 * by #ifdef BERK, allthough a lot of things are
14 * around (like polygon and gremlin...)
15 *
16 * Carol Orange and Denise Draper
17 * Changed to make the versatec a Harris typesetter
18 * look-alike.
19 */
20 #ifndef LINT
21 static char sccsid[] = "@(#)ndver80 1.2 (CWI) 87/07/10";
22 #endif
23 /*******************************************************************************
24
25 output language from troff:
26 all numbers are character strings
27
28 #..\n comment
29 sn size in points
30 fn font as number from 1 to n
31 cx ascii character x
32 Cxyz funny char \(xyz. terminated by white space
33 Hn go to absolute horizontal position n
34 Vn go to absolute vertical position n (down is positive)
35 hn go n units horizontally (relative)
36 vn ditto vertically
37 nnc move right nn, then print c (exactly 2 digits!)
38 (this wart is an optimization that shrinks output file size
39 about 35% and run-time about 15% while preserving ascii-ness)
40 pn new page begins (number n) -- set v to 0
41 P spread ends -- output it. (Put in by vsort).
42 nb a end of line (information only -- no action needed)
43 b = space before line, a = after
44 w paddable word space -- no action needed
45
46 Dt ..\n draw operation 't':
47 Dl x y . line from here by x,y (drawing char .)
48 Dc d circle of diameter d with left side here
49 De x y ellipse of axes x,y with left side here
50 Da x y r arc counter-clockwise by x,y of radius r
51 D~ x y x y ... B-spline curve by x,y then x,y ...
52 vectors, with extents from miny to maxy (no border)
53
54 x ..\n device control functions:
55 x i init
56 x T s name of device is s
57 x r n h v resolution is n/inch h = min horizontal motion, v = min vert
58 x p pause (can restart)
59 x s stop -- done for ever
60 x t generate trailer
61 x f n s font position n contains font s
62 x H n set character height to n
63 x S n set slant to N
64
65 Subcommands like "i" are often spelled out like "init".
66
67 *******************************************************************************/
68
69 #include <sys/vcmd.h>
70 #include "the.h"
71
72 public char *devname = "har";
73 public char *fontdir = "/usr/local/lib/ditroff/font";
74
75 public int debug = 0; /* two different debugging modes */
76 public int dbg = 0;
77
78 extern int virtRES;
79 /* externs: set here, used elsewhere */
80 extern int nolist, olist[];
81 extern int pltmode[], prtmode[];
82
83 char *operand();
84
85
86
main(argc,argv)87 main(argc, argv)
88 char *argv[];
89 {
90 register FILE *fp;
91 char *dummy;
92
93 while (--argc > 0 && **++argv == '-') {
94 switch ((*argv)[1]) {
95 case 'F':
96 dummy = operand(&argc, &argv); /* ignore */
97 break;
98 case 'D':
99 debug = 1;
100 break;
101 case 'f':
102 fontdir = operand(&argc, &argv);
103 break;
104 case 'o':
105 outlist(operand(&argc, &argv));
106 break;
107 #ifdef DEBUGABLE
108 case 'd':
109 dbg = atoi(operand(&argc, &argv));
110 if (dbg == 0) dbg = 1;
111 break;
112 #endif
113 case 'n':
114 dummy = operand(&argc, &argv); /* ignore */
115 break;
116
117 case 'h':
118 dummy = operand(&argc, &argv); /* ignore */
119 break;
120 case 'x':
121 case 'y':
122 dummy = operand(&argc, &argv); /* ignore */
123 break;
124
125 }
126 }
127 /* ignore accounting argument... */
128 argc--;
129 argv++;
130
131 #ifdef DRIVER
132 ioctl(OUTFILE, VSETSTATE, pltmode);
133 #endif
134
135 initfonts();
136 initgraph(virtRES);
137
138 if (argc < 1)
139 conv(stdin);
140 else
141 while (argc-- > 0) {
142 if (strcmp(*argv, "-") == 0)
143 fp = stdin;
144 else if ((fp = fopen(*argv, "r")) == NULL)
145 error(FATAL, "can't open %s", *argv);
146 conv(fp);
147 fclose(fp);
148 argv++;
149 }
150 exit(0);
151 }
152
153
154 /*----------------------------------------------------------------------------*
155 | Routine: char * operand (& argc, & argv)
156 |
157 | Results: returns address of the operand given with a command-line
158 | option. It uses either "-Xoperand" or "-X operand", whichever
159 | is present. The program is terminated if no option is present.
160 |
161 | Side Efct: argc and argv are updated as necessary.
162 *----------------------------------------------------------------------------*/
163
operand(argcp,argvp)164 char *operand(argcp, argvp)
165 int * argcp;
166 char ***argvp;
167 {
168 if ((**argvp)[2]) return(**argvp + 2); /* operand immediately follows */
169 if ((--*argcp) <= 0) { /* no operand */
170 error (FATAL, "command-line option operand missing.");
171 }
172 return(*(++(*argvp))); /* operand next word */
173 }
174
175
outlist(s)176 outlist(s) /* process list of page numbers to be printed */
177 char *s;
178 {
179 int n1, n2;
180 #ifdef DEBUGABLE
181 int i;
182 #endif
183
184 nolist = 0;
185 while (*s) {
186 n1 = 0;
187 if (isdigit(*s))
188 do
189 n1 = 10 * n1 + *s++ - '0';
190 while (isdigit(*s));
191 else
192 n1 = -9999;
193 n2 = n1;
194 if (*s == '-') {
195 s++;
196 n2 = 0;
197 if (isdigit(*s))
198 do
199 n2 = 10 * n2 + *s++ - '0';
200 while (isdigit(*s));
201 else
202 n2 = 9999;
203 }
204 olist[nolist++] = n1;
205 olist[nolist++] = n2;
206 if (*s != '\0')
207 s++;
208 }
209 olist[nolist] = 0;
210 #ifdef DEBUGABLE
211 if (dbg)
212 for (i=0; i<nolist; i += 2)
213 fprintf(stderr,"%3d %3d\n", olist[i], olist[i+1]);
214 #endif
215 }
216
217
218
219 /*VARARGS1*/
220
error(f,s,a1,a2,a3,a4,a5,a6,a7)221 error(f, s, a1, a2, a3, a4, a5, a6, a7)
222 {
223 fprintf(stderr, "dver: ");
224 /*NOSTRICT*/
225 fprintf(stderr, s, a1, a2, a3, a4, a5, a6, a7);
226 fprintf(stderr, "\n");
227 if (f) exit(ABORT);
228 }
229
230
231
232
233 /*VARARGS*/
234 /*NOSTRICT*/
235
eprintf(s1,s2,s3,s4,s5,s6,s7,s8)236 eprintf(s1, s2, s3, s4, s5, s6, s7, s8)
237 {
238 /*NOSTRICT*/
239 fprintf(stderr, s1, s2, s3, s4, s5, s6, s7, s8);
240 }
241