5 #include "../common/common.h"
8 char devname[20] = { 'u', 't', 'f', '\0' };
17 /* I won't need this if getfields can replace sscanf
19 extern void picture(Biobufhdr *);
20 extern void notavail(char *);
23 PSInclude(Biobufhdr *inp) {
26 Bgetfield(inp, 's', buf, 256);
29 Bprint(Bstdout, "%s\n", buf);
33 struct sjt specialjumptable[] = {
35 {"PictureInclusion", picture},
36 {"InlinePicture", NULL},
39 {"BeginObject", NULL},
41 {"NewBaseline", NULL},
47 {"Postscript", PSInclude},
48 {"ExportPS", notavail("ExportPS")},
54 devcntl(Biobuf *inp) {
56 char cmd[50], buf[256], str[MAXTOKENSIZE], *line;
61 * Interpret device control commands, ignoring any we don't recognize. The
62 * "x X ..." commands are a device dependent collection generated by troff's
67 Bgetfield(inp, 's', cmd, 50);
68 if (debug) Bprint(Bstderr, "devcntl(cmd=%s)\n", cmd);
70 case 'f': /* mount font in a position */
71 Bgetfield(inp, 'd', &n, 0);
72 Bgetfield(inp, 's', str, 100);
76 case 'i': /* initialize */
83 case 'r': /* resolution assumed when prepared */
84 Bgetfield(inp, 'd', &resolution, 0);
85 Bgetfield(inp, 'd', &minx, 0);
86 Bgetfield(inp, 'd', &miny, 0);
90 case 't': /* trailer */
94 case 'H': /* char height */
95 Bgetfield(inp, 'd', &n, 0);
100 Bgetfield(inp, 'd', &n, 0);
104 case 'T': /* device name */
105 Bgetfield(inp, 's', &devname, 16);
106 if (debug) Bprint(Bstderr, "devname=%s\n", devname);
109 case 'E': /* input encoding - not in troff yet */
110 Bgetfield(inp, 's', &str, 100);
111 /* if ( strcmp(str, "UTF") == 0 )
112 reading = UTFENCODING;
113 else reading = ONEBYTE;
117 case 'X': /* copy through - from troff */
118 if (Bgetfield(inp, 's', str, MAXTOKENSIZE-1) <= 0)
119 error(FATAL, "incomplete devcntl line\n");
120 if ((line = Brdline(inp, '\n')) == 0)
121 error(FATAL, "incomplete devcntl line\n");
122 strncpy(buf, line, Blinelen(inp)-1);
123 buf[Blinelen(inp)-1] = '\0';
126 if (strncmp(str, "PI", sizeof("PI")-1) == 0 || strncmp(str, "PictureInclusion", sizeof("PictureInclusion")-1) == 0) {
128 } else if (strncmp(str, "InlinePicture", sizeof("InlinePicture")-1) == 0) {
129 error(FATAL, "InlinePicture not implemented yet.\n");
130 /* inlinepic(inp, buf); */
131 } else if (strncmp(str, "BeginPath", sizeof("BeginPath")-1) == 0) {
132 beginpath(buf, FALSE);
133 } else if (strncmp(str, "DrawPath", sizeof("DrawPath")-1) == 0) {
134 drawpath(buf, FALSE);
135 } else if (strncmp(str, "BeginObject", sizeof("BeginObject")-1) == 0) {
136 beginpath(buf, TRUE);
137 } else if (strncmp(str, "EndObject", sizeof("EndObject")-1) == 0) {
139 } else if (strncmp(str, "NewBaseline", sizeof("NewBaseline")-1) == 0) {
140 error(FATAL, "NewBaseline not implemented yet.\n");
141 /* newbaseline(buf); */
142 } else if (strncmp(str, "DrawText", sizeof("DrawText")-1) == 0) {
143 error(FATAL, "DrawText not implemented yet.\n");
145 } else if (strncmp(str, "SetText", sizeof("SetText")-1) == 0) {
146 error(FATAL, "SetText not implemented yet.\n");
148 } else if (strncmp(str, "SetColor", sizeof("SetColor")-1) == 0) {
149 error(FATAL, "SetColor not implemented yet.\n");
152 } else if (strncmp(str, "INFO", sizeof("INFO")-1) == 0) {
153 error(FATAL, "INFO not implemented yet.\n");
155 /* Bprint(outp, "%%INFO%s", buf); */
156 } else if (strncmp(str, "PS", sizeof("PS")-1) == 0 || strncmp(str, "PostScript", sizeof("PostScript")-1) == 0) {
159 Bprint(Bstdout, "%s\n", buf);
161 } else if (strncmp(str, "ExportPS", sizeof("ExportPS")-1) == 0) { /* dangerous!! */
162 error(FATAL, "ExportPS not implemented yet.\n");
163 /* if (Bfildes(outp) == 1) { */
165 /* Bprint(outp, "%s", buf); */
170 error(WARNING, "Unknown string <%s %s> after x X\n", str, buf);
175 while ((c = Bgetc(inp)) != '\n' && c != Beof);