mkdev: remove devutf/C*
[troff.git] / tr2ps / devcntl.c
blobbd9da6f7f22f2e66e8a74fbff4e9bc7f84986b05
1 #include <stdio.h>
2 #include <string.h>
3 #include "ustr.h"
4 #include "common.h"
5 #include "tr2ps.h"
7 char devname[20] = "utf";
8 int resolution;
9 int minx, miny;
11 struct sjt {
12 char *str;
13 void (*func)(void *);
17 * Interpret device control commands, ignoring any we don't recognize. The
18 * "x X ..." commands are a device dependent collection generated by troff's
19 * \X'...' request.
22 void devcntl(struct ustr *ustr)
24 char cmd[50], buf[256], str[MAXTOKENSIZE];
25 int n;
26 ustr_str(ustr, cmd, 50);
27 if (debug)
28 fprintf(ferr, "devcntl(cmd=%s)\n", cmd);
29 switch (cmd[0]) {
30 case 'f': /* mount font in a position */
31 ustr_int(ustr, &n);
32 ustr_str(ustr, str, 100);
33 mountfont(n, str);
34 break;
36 case 'i': /* initialize */
37 initialize();
38 break;
40 case 'p': /* pause */
41 break;
43 case 'r': /* resolution assumed when prepared */
44 ustr_int(ustr, &resolution);
45 ustr_int(ustr, &minx);
46 ustr_int(ustr, &miny);
47 break;
49 case 's': /* stop */
50 case 't': /* trailer */
51 /* flushtext(); */
52 break;
54 case 'H': /* char height */
55 ustr_int(ustr, &n);
56 t_charht(n);
57 break;
59 case 'S': /* slant */
60 ustr_int(ustr, &n);
61 t_slant(n);
62 break;
64 case 'T': /* device name */
65 ustr_str(ustr, devname, 16);
66 if (debug)
67 fprintf(ferr, "devname=%s\n", devname);
68 readDESC();
69 break;
71 case 'E': /* input encoding - not in troff yet */
72 ustr_str(ustr, str, 100);
73 break;
75 case 'X': /* copy through - from troff */
76 if (ustr_str(ustr, str, MAXTOKENSIZE - 1) <= 0)
77 error(FATAL, "incomplete devcntl line\n");
78 if (ustr_line(ustr, buf, sizeof(buf)) < 0)
79 error(FATAL, "incomplete devcntl line\n");
80 ustr_back(ustr);
82 if (str[0] == 'P' && str[1] == 'I' ||
83 strncmp(str, "PictureInclusion", strlen("PictureInclusion")) == 0) {
84 picture(ustr, str);
85 } else if (strncmp(str, "InlinePicture", strlen("InlinePicture")) == 0) {
86 error(FATAL, "InlinePicture not implemented yet.\n");
87 /* inlinepic(inp, buf); */
88 } else if (strncmp(str, "BeginPath", strlen("BeginPath")) == 0) {
89 beginpath(buf, FALSE);
90 } else if (strncmp(str, "DrawPath", strlen("DrawPath")) == 0) {
91 drawpath(buf, FALSE);
92 } else if (strncmp(str, "BeginObject", strlen("BeginObject")) == 0) {
93 beginpath(buf, TRUE);
94 } else if (strncmp(str, "EndObject", strlen("EndObject")) == 0) {
95 drawpath(buf, TRUE);
96 } else if (strncmp(str, "NewBaseline", strlen("NewBaseline")) == 0) {
97 error(FATAL, "NewBaseline not implemented yet.\n");
98 /* newbaseline(buf); */
99 } else if (strncmp(str, "DrawText", strlen("DrawText") - 1) == 0) {
100 error(FATAL, "DrawText not implemented yet.\n");
101 /* drawtext(buf); */
102 } else if (strncmp(str, "SetText", strlen("SetText")) == 0) {
103 error(FATAL, "SetText not implemented yet.\n");
104 /* settext(buf); */
105 } else if (strncmp(str, "SetColor", strlen("SetColor")) == 0) {
106 error(FATAL, "SetColor not implemented yet.\n");
107 /* newcolor(buf); */
108 /* setcolor(); */
109 } else if (strncmp(str, "INFO", strlen("INFO")) == 0) {
110 error(FATAL, "INFO not implemented yet.\n");
111 } else if (strncmp(str, "PS", strlen("PS")) == 0 ||
112 strncmp(str, "PostScript", strlen("PostScript")) == 0) {
113 if (pageon()) {
114 endstring();
115 fprintf(fout, "%s\n", buf);
117 } else if (strncmp(str, "ExportPS", strlen("ExportPS")) == 0) { /* dangerous!! */
118 error(FATAL, "ExportPS not implemented yet.\n");
120 break;
122 ustr_eol(ustr);
123 inputlineno++;