1 61f5c35c 2004-05-15 devnull #include <u.h>
2 61f5c35c 2004-05-15 devnull #include <libc.h>
3 61f5c35c 2004-05-15 devnull #include <bio.h>
4 61f5c35c 2004-05-15 devnull #include "../common/common.h"
5 61f5c35c 2004-05-15 devnull #include "tr2post.h"
8 e8fb1d3e 2004-05-17 devnull conv(Biobuf *Bp) {
11 61f5c35c 2004-05-15 devnull char special[10];
12 61f5c35c 2004-05-15 devnull int save;
14 61f5c35c 2004-05-15 devnull inputlineno = 1;
15 b855148c 2004-05-16 devnull if (debug) Bprint(Bstderr, "conv(Biobufhdr *Bp=0x%x)\n", Bp);
16 61f5c35c 2004-05-15 devnull while ((r = Bgetrune(Bp)) >= 0) {
17 61f5c35c 2004-05-15 devnull /* Bprint(Bstderr, "r=<%c>,0x%x\n", r, r); */
18 61f5c35c 2004-05-15 devnull /* Bflush(Bstderr); */
19 61f5c35c 2004-05-15 devnull switch (r) {
20 61f5c35c 2004-05-15 devnull case 's': /* set point size */
21 61f5c35c 2004-05-15 devnull Bgetfield(Bp, 'd', &fontsize, 0);
23 61f5c35c 2004-05-15 devnull case 'f': /* set font to postion */
24 61f5c35c 2004-05-15 devnull Bgetfield(Bp, 'd', &fontpos, 0);
25 61f5c35c 2004-05-15 devnull save = inputlineno;
26 61f5c35c 2004-05-15 devnull settrfont();
27 61f5c35c 2004-05-15 devnull inputlineno = save; /* ugh */
29 61f5c35c 2004-05-15 devnull case 'c': /* print rune */
30 61f5c35c 2004-05-15 devnull r = Bgetrune(Bp);
31 61f5c35c 2004-05-15 devnull runeout(r);
33 61f5c35c 2004-05-15 devnull case 'C': /* print special character */
34 61f5c35c 2004-05-15 devnull Bgetfield(Bp, 's', special, 10);
35 61f5c35c 2004-05-15 devnull specialout(special);
37 61f5c35c 2004-05-15 devnull case 'N': /* print character with numeric value from current font */
38 61f5c35c 2004-05-15 devnull Bgetfield(Bp, 'd', &n, 0);
40 61f5c35c 2004-05-15 devnull case 'H': /* go to absolute horizontal position */
41 61f5c35c 2004-05-15 devnull Bgetfield(Bp, 'd', &n, 0);
42 61f5c35c 2004-05-15 devnull hgoto(n);
44 61f5c35c 2004-05-15 devnull case 'V': /* go to absolute vertical position */
45 61f5c35c 2004-05-15 devnull Bgetfield(Bp, 'd', &n, 0);
46 61f5c35c 2004-05-15 devnull vgoto(n);
48 61f5c35c 2004-05-15 devnull case 'h': /* go to relative horizontal position */
49 61f5c35c 2004-05-15 devnull Bgetfield(Bp, 'd', &n, 0);
52 61f5c35c 2004-05-15 devnull case 'v': /* go to relative vertical position */
53 61f5c35c 2004-05-15 devnull Bgetfield(Bp, 'd', &n, 0);
56 61f5c35c 2004-05-15 devnull case '0': case '1': case '2': case '3': case '4':
57 61f5c35c 2004-05-15 devnull case '5': case '6': case '7': case '8': case '9':
58 61f5c35c 2004-05-15 devnull /* move right nn units, then print character c */
59 61f5c35c 2004-05-15 devnull n = (r - '0') * 10;
60 61f5c35c 2004-05-15 devnull r = Bgetrune(Bp);
61 61f5c35c 2004-05-15 devnull if (r < 0)
62 61f5c35c 2004-05-15 devnull error(FATAL, "EOF or error reading input\n");
63 61f5c35c 2004-05-15 devnull else if (r < '0' || r > '9')
64 61f5c35c 2004-05-15 devnull error(FATAL, "integer expected\n");
65 61f5c35c 2004-05-15 devnull n += r - '0';
66 61f5c35c 2004-05-15 devnull r = Bgetrune(Bp);
68 61f5c35c 2004-05-15 devnull runeout(r);
70 61f5c35c 2004-05-15 devnull case 'p': /* begin page */
71 61f5c35c 2004-05-15 devnull Bgetfield(Bp, 'd', &n, 0);
72 61f5c35c 2004-05-15 devnull endpage();
73 61f5c35c 2004-05-15 devnull startpage();
75 61f5c35c 2004-05-15 devnull case 'n': /* end of line (information only 'b a' follows) */
76 61f5c35c 2004-05-15 devnull Brdline(Bp, '\n'); /* toss rest of line */
77 61f5c35c 2004-05-15 devnull inputlineno++;
79 61f5c35c 2004-05-15 devnull case 'w': /* paddable word space (information only) */
81 61f5c35c 2004-05-15 devnull case 'D': /* graphics function */
82 61f5c35c 2004-05-15 devnull draw(Bp);
84 61f5c35c 2004-05-15 devnull case 'x': /* device control functions */
85 61f5c35c 2004-05-15 devnull devcntl(Bp);
87 61f5c35c 2004-05-15 devnull case '#': /* comment */
88 61f5c35c 2004-05-15 devnull Brdline(Bp, '\n'); /* toss rest of line */
89 61f5c35c 2004-05-15 devnull case '\n':
90 61f5c35c 2004-05-15 devnull inputlineno++;
93 61f5c35c 2004-05-15 devnull error(WARNING, "unknown troff function <%c>\n", r);
97 61f5c35c 2004-05-15 devnull endpage();
98 61f5c35c 2004-05-15 devnull if (debug) Bprint(Bstderr, "r=0x%x\n", r);
99 61f5c35c 2004-05-15 devnull if (debug) Bprint(Bstderr, "leaving conv\n");