2 |
- |
1 |
#include <u.h>
|
|
|
2 |
#include <libc.h>
|
|
|
3 |
#include <bio.h>
|
|
|
4 |
#include <stdio.h>
|
|
|
5 |
#include "../common/common.h"
|
|
|
6 |
#include "tr2post.h"
|
|
|
7 |
|
|
|
8 |
char devname[20] = { 'u', 't', 'f', '\0' };
|
|
|
9 |
int resolution;
|
|
|
10 |
int minx, miny;
|
|
|
11 |
|
|
|
12 |
struct sjt {
|
|
|
13 |
char *str;
|
|
|
14 |
void (*func)(void *);
|
|
|
15 |
};
|
|
|
16 |
|
|
|
17 |
/* I won't need this if getfields can replace sscanf
|
|
|
18 |
|
|
|
19 |
extern void picture(Biobufhdr *);
|
|
|
20 |
extern void notavail(char *);
|
|
|
21 |
|
|
|
22 |
void
|
|
|
23 |
PSInclude(Biobufhdr *inp) {
|
|
|
24 |
char buf[256];
|
|
|
25 |
|
|
|
26 |
Bgetfield(inp, 's', buf, 256);
|
|
|
27 |
if(pageon()) {
|
|
|
28 |
endstring();
|
|
|
29 |
Bprint(Bstdout, "%s\n", buf);
|
|
|
30 |
}
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
struct sjt specialjumptable[] = {
|
|
|
34 |
{"PI", picture},
|
|
|
35 |
{"PictureInclusion", picture},
|
|
|
36 |
{"InlinePicture", NULL},
|
|
|
37 |
{"BeginPath", NULL},
|
|
|
38 |
{"DrawPath", NULL},
|
|
|
39 |
{"BeginObject", NULL},
|
|
|
40 |
{"EndObject", NULL},
|
|
|
41 |
{"NewBaseline", NULL},
|
|
|
42 |
{"DrawText", NULL},
|
|
|
43 |
{"SetText", NULL},
|
|
|
44 |
{"SetColor", NULL},
|
|
|
45 |
{"INFO", NULL},
|
|
|
46 |
{"PS", PSInclude},
|
|
|
47 |
{"Postscript", PSInclude},
|
|
|
48 |
{"ExportPS", notavail("ExportPS")},
|
|
|
49 |
{NULL, NULL}
|
|
|
50 |
};
|
|
|
51 |
*/
|
|
|
52 |
|
|
|
53 |
void
|
|
|
54 |
devcntl(Biobufhdr *inp) {
|
|
|
55 |
char cmd[50], buf[256], str[MAXTOKENSIZE], *line;
|
|
|
56 |
int c, n;
|
|
|
57 |
|
|
|
58 |
/*
|
|
|
59 |
*
|
|
|
60 |
* Interpret device control commands, ignoring any we don't recognize. The
|
|
|
61 |
* "x X ..." commands are a device dependent collection generated by troff's
|
|
|
62 |
* \X'...' request.
|
|
|
63 |
*
|
|
|
64 |
*/
|
|
|
65 |
|
|
|
66 |
Bgetfield(inp, 's', cmd, 50);
|
|
|
67 |
if (debug) Bprint(Bstderr, "devcntl(cmd=%s)\n", cmd);
|
|
|
68 |
switch (cmd[0]) {
|
|
|
69 |
case 'f': /* mount font in a position */
|
|
|
70 |
Bgetfield(inp, 'd', &n, 0);
|
|
|
71 |
Bgetfield(inp, 's', str, 100);
|
|
|
72 |
mountfont(n, str);
|
|
|
73 |
break;
|
|
|
74 |
|
|
|
75 |
case 'i': /* initialize */
|
|
|
76 |
initialize();
|
|
|
77 |
break;
|
|
|
78 |
|
|
|
79 |
case 'p': /* pause */
|
|
|
80 |
break;
|
|
|
81 |
|
|
|
82 |
case 'r': /* resolution assumed when prepared */
|
|
|
83 |
Bgetfield(inp, 'd', &resolution, 0);
|
|
|
84 |
Bgetfield(inp, 'd', &minx, 0);
|
|
|
85 |
Bgetfield(inp, 'd', &miny, 0);
|
|
|
86 |
break;
|
|
|
87 |
|
|
|
88 |
case 's': /* stop */
|
|
|
89 |
case 't': /* trailer */
|
|
|
90 |
/* flushtext(); */
|
|
|
91 |
break;
|
|
|
92 |
|
|
|
93 |
case 'H': /* char height */
|
|
|
94 |
Bgetfield(inp, 'd', &n, 0);
|
|
|
95 |
t_charht(n);
|
|
|
96 |
break;
|
|
|
97 |
|
|
|
98 |
case 'S': /* slant */
|
|
|
99 |
Bgetfield(inp, 'd', &n, 0);
|
|
|
100 |
t_slant(n);
|
|
|
101 |
break;
|
|
|
102 |
|
|
|
103 |
case 'T': /* device name */
|
|
|
104 |
Bgetfield(inp, 's', devname, 16);
|
|
|
105 |
if (debug) Bprint(Bstderr, "devname=%s\n", devname);
|
|
|
106 |
break;
|
|
|
107 |
|
|
|
108 |
case 'E': /* input encoding - not in troff yet */
|
|
|
109 |
Bgetfield(inp, 's', str, 100);
|
|
|
110 |
/*
|
|
|
111 |
if (strcmp(str, "UTF") == 0)
|
|
|
112 |
reading = UTFENCODING;
|
|
|
113 |
else
|
|
|
114 |
reading = ONEBYTE;
|
|
|
115 |
*/
|
|
|
116 |
break;
|
|
|
117 |
|
|
|
118 |
case 'X': /* copy through - from troff */
|
|
|
119 |
if (Bgetfield(inp, 's', str, MAXTOKENSIZE-1) <= 0)
|
|
|
120 |
error(FATAL, "incomplete devcntl line\n");
|
|
|
121 |
if ((line = Brdline(inp, '\n')) == 0)
|
|
|
122 |
error(FATAL, "incomplete devcntl line\n");
|
|
|
123 |
strncpy(buf, line, Blinelen(inp)-1);
|
|
|
124 |
buf[Blinelen(inp)-1] = '\0';
|
|
|
125 |
Bungetc(inp);
|
|
|
126 |
|
|
|
127 |
if (strncmp(str, "PI", sizeof("PI")-1) == 0 || strncmp(str, "PictureInclusion", sizeof("PictureInclusion")-1) == 0) {
|
|
|
128 |
picture(inp, str);
|
|
|
129 |
} else if (strncmp(str, "InlinePicture", sizeof("InlinePicture")-1) == 0) {
|
|
|
130 |
error(FATAL, "InlinePicture not implemented yet.\n");
|
|
|
131 |
/* inlinepic(inp, buf); */
|
|
|
132 |
} else if (strncmp(str, "BeginPath", sizeof("BeginPath")-1) == 0) {
|
|
|
133 |
beginpath(buf, FALSE);
|
|
|
134 |
} else if (strncmp(str, "DrawPath", sizeof("DrawPath")-1) == 0) {
|
|
|
135 |
drawpath(buf, FALSE);
|
|
|
136 |
} else if (strncmp(str, "BeginObject", sizeof("BeginObject")-1) == 0) {
|
|
|
137 |
beginpath(buf, TRUE);
|
|
|
138 |
} else if (strncmp(str, "EndObject", sizeof("EndObject")-1) == 0) {
|
|
|
139 |
drawpath(buf, TRUE);
|
|
|
140 |
} else if (strncmp(str, "NewBaseline", sizeof("NewBaseline")-1) == 0) {
|
|
|
141 |
error(FATAL, "NewBaseline not implemented yet.\n");
|
|
|
142 |
/* newbaseline(buf); */
|
|
|
143 |
} else if (strncmp(str, "DrawText", sizeof("DrawText")-1) == 0) {
|
|
|
144 |
error(FATAL, "DrawText not implemented yet.\n");
|
|
|
145 |
/* drawtext(buf); */
|
|
|
146 |
} else if (strncmp(str, "SetText", sizeof("SetText")-1) == 0) {
|
|
|
147 |
error(FATAL, "SetText not implemented yet.\n");
|
|
|
148 |
/* settext(buf); */
|
|
|
149 |
} else if (strncmp(str, "SetColor", sizeof("SetColor")-1) == 0) {
|
|
|
150 |
error(FATAL, "SetColor not implemented yet.\n");
|
|
|
151 |
/* newcolor(buf); */
|
|
|
152 |
/* setcolor(); */
|
|
|
153 |
} else if (strncmp(str, "INFO", sizeof("INFO")-1) == 0) {
|
|
|
154 |
error(FATAL, "INFO not implemented yet.\n");
|
|
|
155 |
/* flushtext(); */
|
|
|
156 |
/* Bprint(outp, "%%INFO%s", buf); */
|
|
|
157 |
} else if (strncmp(str, "PS", sizeof("PS")-1) == 0 || strncmp(str, "PostScript", sizeof("PostScript")-1) == 0) {
|
|
|
158 |
if(pageon()) {
|
|
|
159 |
endstring();
|
|
|
160 |
Bprint(Bstdout, "%s\n", buf);
|
|
|
161 |
}
|
|
|
162 |
} else if (strncmp(str, "ExportPS", sizeof("ExportPS")-1) == 0) { /* dangerous!! */
|
|
|
163 |
error(FATAL, "ExportPS not implemented yet.\n");
|
|
|
164 |
/* if (Bfildes(outp) == 1) { */
|
|
|
165 |
/* restore(); */
|
|
|
166 |
/* Bprint(outp, "%s", buf); */
|
|
|
167 |
/* save(); */
|
|
|
168 |
/* } */
|
|
|
169 |
}
|
|
|
170 |
/* else
|
|
|
171 |
error(WARNING, "Unknown string <%s %s> after x X\n", str, buf);
|
|
|
172 |
*/
|
|
|
173 |
|
|
|
174 |
break;
|
|
|
175 |
}
|
|
|
176 |
while ((c = Bgetc(inp)) != '\n' && c != Beof);
|
|
|
177 |
inputlineno++;
|
|
|
178 |
}
|