File: vfdcom.c

package info (click to toggle)
dvi2dvi 2.0alpha-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 404 kB
  • ctags: 1,164
  • sloc: ansic: 6,398; makefile: 130; sh: 8
file content (160 lines) | stat: -rw-r--r-- 2,473 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
 * funtions for analyzing dvi in vf-file (vfd stands for vf-file dvi)
 */

#include	"defs.h"
#include	"commands.h"
#include	"dconv.h"
#include	"global.h"

int vfd_getcommand();
void vfd_backupone();
void vfd_getbytes();
void vfd_skipbytes();
int vfd_getuint();
int vfd_getint();
void vfd_movedown();
void vfd_movedown_v();
void vfd_moveover();
void vfd_moveover_v();
void vfd_setrule();
void vfd_setrule_v();
struct dconv vfd_dconv_templ = {
    vfd_getcommand,
    vfd_backupone,
    vfd_getbytes,
    vfd_skipbytes,
    vfd_getuint,
    vfd_getint,
    NULL,
    NULL,
    NULL,
    vfd_movedown,
    vfd_movedown_v,
    vfd_moveover,
    vfd_moveover_v,
    vfd_setrule,
    vfd_setrule_v,
    0
};

vfd_dirkeep()
{
    vfd_dconv_templ.dc_movedown_v = vfd_dconv_templ.dc_movedown;
    vfd_dconv_templ.dc_moveover_v = vfd_dconv_templ.dc_moveover;
    vfd_dconv_templ.dc_setrule_v = vfd_dconv_templ.dc_setrule;
}

int
vfd_getcommand()
{
    dc_bufbeg++;
    return (dc_bufbeg > dc_bufend ? POST : *(dc_bufbeg-1));
}

void
vfd_backupone()
{
    --dc_bufbeg;
}

void
vfd_getbytes(cp, n)
char *cp;
int n;
{
    (void)strncpy(cp, (char *)dc_bufbeg, n);
    dc_bufbeg += n;
}

void
vfd_skipbytes(n)
int n;
{
    dc_bufbeg += n;
}

int
vfd_getuint(n)
int n;
{
    int x;

    x = makeuint(dc_bufbeg, n);
    dc_bufbeg += n;
    return x;
}

int
vfd_getint(n)
int n;
{
    int x;

    x = makeint(dc_bufbeg, n);
    dc_bufbeg += n;
    return x;
}


extern int command;

void
vfd_movedown(a, n)
byte *a;
int n;
{
    if (n == 0)
	dev_move0(command);
    else
	dev_makemove(scale(makeint(a, n), dc_scale), command-n);
}

void
vfd_movedown_v(a, n, l)
byte *a;
int n, l;
{
    if (DOWN1 <= command && command <= DOWN4)
	l = makeint(a, n);
    dev_makemove(-scale(l, dc_scale), RIGHT1-1);
}

void
vfd_moveover(b, n)
byte *b;
int n;
{
    if (n == 0)
	dev_move0(command);
    else
	dev_makemove(scale(makeint(b, n), dc_scale), command-n);
}

void
vfd_moveover_v(b, n, l)
byte *b;
int n, l;
{
    if (RIGHT1 <= command && command <= RIGHT4)
	l = makeint(b, n);
    dev_makemove(scale(l, dc_scale), DOWN1-1);
}

void
vfd_setrule(a, b, Set)	/* this routine will draw a rule */
byte *a, *b;
BOOLEAN Set;
{
    dev_setrule(scale(makeint(a, 4), dc_scale),
		scale(makeint(b, 4), dc_scale), command);
}

void
vfd_setrule_v(a, b, Set)	/* this routine will draw a rule */
byte *a, *b;
BOOLEAN Set;
{
    d_setrule_v(scale(makeint(a, 4), dc_scale),
		scale(makeint(b, 4), dc_scale), Set);
}