w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

dviconv.c
Go to the documentation of this file.
1 #include "defs.h"
2 #include "commands.h"
3 #include "dconv.h"
4 #include "set.h"
5 #include "global.h"
6 
7 void setdir(int d, int dev);
8 
9 int h; /* current horizontal position */
10 int v; /* current vertical position */
11 int dir; /* current direction */
12 int *move; /* &h or &v */
13 int chmove; /* TRUE if char moves */
14 
15 #define MoveDown DC_movedown
16 #define MoveOver DC_moveover
17 #define SetRule DC_setrule
18 
19 /*
20  * convert dvi to printer language
21  */
22 
23 int command; /* current command */
24 int sp = 0; /* stack pointer */
25 struct {
26  int h, v, w, x, y, z; /* what's on stack */
27  int d; /* pTeX */
28 } stack[STACKSIZE]; /* stack */
29 
30 void dviconv(struct font_index *hdfidx)
31 {
32  int SkipMode = FALSE; /* in skip mode flag */
33  int count[10]; /* the 10 counters at begining of each page */
34  int basedir;
35  int i; /* command parameter; loop index */
36  int k; /* temporary parameter */
37  int val, val2; /* temporarys to hold command information*/
38  byte par[4], par2[4]; /* temporarys to hold command information*/
39  int w; /* current horizontal spacing */
40  int x; /* current horizontal spacing */
41  int y; /* current vertical spacing */
42  int z; /* current vertical spacing */
43  /*long cpagep; /* current page pointer */
44  long ppagep; /* previous page pointer */
45 
46  /* initialize for virtual font */
47  w = x = y = z = 0;
48  basedir = dir;
49 
50  while (TRUE)
51  switch (command=DC_getcommand()) {
52 
53  case SET1:case SET2:case SET3:case SET4:
55  if (!SkipMode) SetChar(val, TRUE);
56  break;
57 
58  case SET_RULE:
59  DC_getbytes(par, 4);
60  DC_getbytes(par2, 4);
61  if (!SkipMode) SetRule(par, par2, TRUE);
62  break;
63 
64  case PUT1:case PUT2:case PUT3:case PUT4:
66  if (!SkipMode) SetChar(val, FALSE);
67  break;
68 
69  case PUT_RULE:
70  DC_getbytes(par, 4);
71  DC_getbytes(par2, 4);
72  if (!SkipMode) SetRule(par, par2, FALSE);
73  break;
74 
75  case NOP:
76  break;
77 
78  case BOP:
79  /*cpagep = ftell(dc_file) - 1;*/
80  for (i=0; i<=9; i++)
81  count[i] = DC_getuint(4);
82  ppagep = DC_getuint(4);
83 
84  h = v = w = x = y = z = 0;
85  setdir(HOR, FALSE);
86  basedir = HOR;
87  sp = 0;
88  setcurfont((struct font_entry *)NULL);
89  dev_initpage();
90 
91  SkipMode = (count[0] < FirstPage || count[0] > LastPage);
92 
93  if (!SkipMode) {
94  dev_bop(count);
95  if (!G_quiet)
96  (void)fprintf(stderr, "[%d", count[0]);
97  }
98  break;
99 
100  case EOP:
101  if (!SkipMode) {
102  dev_eop();
103 #ifdef STATS
104  if (Stats)
105  (void)fprintf(stderr,
106  " - %d total ch, %d diff ch, %d pxl bytes]\n",
108  else
109 #endif
110  if (!G_quiet) {
111  (void)fprintf(stderr,"] ");
112  if ((++ndone % 10) == 0) (void)putc('\n', stderr);
113  (void)fflush(stderr);
114  }
115  }
116  if (Reverse)
117  if (ppagep > 0)
118  (void)fseek(dc_file, ppagep, 0);
119  else
120  return;
121  break;
122 
123  case PUSH:
124  if (sp >= STACKSIZE)
125  Fatal("stack overflow");
126  stack[sp].h = h;
127  stack[sp].v = v;
128  stack[sp].w = w;
129  stack[sp].x = x;
130  stack[sp].y = y;
131  stack[sp].z = z;
132  stack[sp].d = dir;
133  sp++;
134  dev_push();
135  break;
136 
137  case POP:
138  --sp;
139  if (sp < 0)
140  Fatal("stack underflow");
141  h = stack[sp].h;
142  v = stack[sp].v;
143  w = stack[sp].w;
144  x = stack[sp].x;
145  y = stack[sp].y;
146  z = stack[sp].z;
147  setdir(stack[sp].d, FALSE);
148  dev_pop();
149  break;
150 
151  case RIGHT1:case RIGHT2:case RIGHT3:case RIGHT4:
152  DC_getbytes(par, command-RIGHT1+1);
153  if (!SkipMode) MoveOver(par, command-RIGHT1+1, 0);
154  break;
155 
156  case W0:
157  if (!SkipMode) MoveOver(par, 0, w);
158  break;
159 
160  case W1:case W2:case W3:case W4:
161  DC_getbytes(par, command-W1+1);
162  w = makeint(par, command-W1+1);
163  if (!SkipMode) MoveOver(par, command-W1+1, w);
164  break;
165 
166  case X0:
167  if (!SkipMode) MoveOver(par, 0, x);
168  break;
169 
170  case X1:case X2:case X3:case X4:
171  DC_getbytes(par, command-X1+1);
172  x = makeint(par, command-X1+1);
173  if (!SkipMode) MoveOver(par, command-X1+1, x);
174  break;
175 
176  case DOWN1:case DOWN2:case DOWN3:case DOWN4:
177  DC_getbytes(par, command-DOWN1+1);
178  if (!SkipMode) MoveDown(par, command-DOWN1+1, 0);
179  break;
180 
181  case Y0:
182  if (!SkipMode) MoveDown(par, 0, y);
183  break;
184 
185  case Y1:case Y2:case Y3:case Y4:
186  DC_getbytes(par, command-Y1+1);
187  y = makeint(par, command-Y1+1);
188  if (!SkipMode) MoveDown(par, command-Y1+1, y);
189  break;
190 
191  case Z0:
192  if (!SkipMode) MoveDown(par, 0, z);
193  break;
194 
195  case Z1:case Z2:case Z3:case Z4:
196  DC_getbytes(par, command-Z1+1);
197  z = makeint(par, command-Z1+1);
198  if (!SkipMode) MoveDown(par, command-Z1+1, z);
199  break;
200 
201  case FNT1:case FNT2:case FNT3:case FNT4:
202  k = DC_getuint(command-FNT1+1);
203  if (!SkipMode) SetFntNum(k, hdfidx);
204  break;
205 
206  case XXX1:case XXX2:case XXX3:case XXX4:
207  k = DC_getuint(command-XXX1+1);
209  if (!SkipMode) dev_dospecial(SpecialStr, k);
210  break;
211 
212  case FNT_DEF1:case FNT_DEF2:case FNT_DEF3:case FNT_DEF4:
214  SkipFontDef();
215  break;
216 
217  case PRE:
218  Fatal("PRE occurs within file");
219  break;
220 
221  case POST:
222  return;
223 
224  case POST_POST:
225  Fatal("POST_POST with no preceding POST");
226  break;
227 
228  case DIR:
229  setdir(basedir+DC_getuint(1), TRUE);
230  break;
231 
232  default:
233  if (command >= FONT_00 && command <= FONT_63) {
234  if (!SkipMode) SetFntNum(command-FONT_00, hdfidx);
235  } else if (command >= SETC_000 && command <= SETC_127) {
236  if (!SkipMode) SetString(command);
237  } else
238  Fatal("%d is an undefined command", command);
239  break;
240 
241  }
242 }
243 
245 {
246  dir = VER;
247  setdir(HOR, FALSE);
248 }
249 
250 void setdir(int d, int dev)
251 {
252  d = d%NDIR;
253  if (dir != d) {
254  dir = d;
255  if (d == HOR) {
256  move = &h;
257  setdirhor();
258  } else if (d == VER) {
259  move = &v;
260  setdirver();
261  } else
262  Fatal("direction %d not supported", d);
263  if (dev)
264  dev_dir(d);
265  }
266 }
#define count(a)
Definition: aptex-macros.h:781
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define POP
Definition: dtl.h:135
#define Y0
Definition: dtl.h:159
#define PUT2
Definition: dtl.h:127
#define X4
Definition: dtl.h:152
#define DOWN4
Definition: dtl.h:157
#define X1
Definition: dtl.h:149
#define RIGHT4
Definition: dtl.h:140
#define Y1
Definition: dtl.h:160
#define Y2
Definition: dtl.h:161
#define Z2
Definition: dtl.h:167
#define W3
Definition: dtl.h:145
#define PUSH
Definition: dtl.h:134
#define Z1
Definition: dtl.h:166
#define Z0
Definition: dtl.h:165
#define DOWN3
Definition: dtl.h:156
#define Z3
Definition: dtl.h:168
#define RIGHT2
Definition: dtl.h:138
#define Y4
Definition: dtl.h:163
#define W0
Definition: dtl.h:142
#define Y3
Definition: dtl.h:162
#define SET3
Definition: dtl.h:122
#define PUT3
Definition: dtl.h:128
#define EOP
Definition: dtl.h:133
#define X2
Definition: dtl.h:150
#define RIGHT1
Definition: dtl.h:137
#define X0
Definition: dtl.h:148
#define BOP
Definition: dtl.h:132
#define SET4
Definition: dtl.h:123
#define SET1
Definition: dtl.h:120
#define RIGHT3
Definition: dtl.h:139
#define DOWN2
Definition: dtl.h:155
#define PUT4
Definition: dtl.h:129
#define W1
Definition: dtl.h:143
#define W2
Definition: dtl.h:144
#define PUT1
Definition: dtl.h:126
#define W4
Definition: dtl.h:146
#define DOWN1
Definition: dtl.h:154
#define SET2
Definition: dtl.h:121
#define X3
Definition: dtl.h:151
#define Z4
Definition: dtl.h:169
FILE * dc_file
Definition: dconv.c:12
setdirver()
Definition: dconv.c:52
setdirhor()
Definition: dconv.c:45
#define DC_skipbytes
Definition: dconv.h:23
#define DC_getcommand
Definition: dconv.h:20
#define DC_getbytes
Definition: dconv.h:22
#define DC_getuint
Definition: dconv.h:24
#define STACKSIZE
Definition: defs.h:139
#define HOR
Definition: defs.h:230
#define VER
Definition: defs.h:231
#define setcurfont(fe)
Definition: defs.h:217
#define NDIR
Definition: defs.h:229
void SkipFontDef()
Definition: dfdcom.c:109
int G_quiet
Definition: dvi2.c:78
int LastPage
Definition: dvi2.c:46
int Snbpxl
Definition: dvi2.c:88
int Stnc
Definition: dvi2.c:91
int Stats
Definition: dvi2.c:87
int FirstPage
Definition: dvi2.c:45
char * SpecialStr
Definition: dvi2.c:85
int Snbpx0
Definition: dvi2.c:92
int ndone
Definition: dvi2.c:69
int Stnc0
Definition: dvi2.c:92
int Sndc0
Definition: dvi2.c:92
int Sndc
Definition: dvi2.c:90
int sp
Definition: dviconv.c:24
int y
Definition: dviconv.c:26
int z
Definition: dviconv.c:26
int d
Definition: dviconv.c:27
void dviconv(struct font_index *hdfidx)
Definition: dviconv.c:30
int chmove
Definition: dviconv.c:13
int x
Definition: dviconv.c:26
int w
Definition: dviconv.c:26
#define MoveDown
Definition: dviconv.c:15
int dir
Definition: dviconv.c:11
int v
Definition: dviconv.c:10
#define SetRule
Definition: dviconv.c:17
#define MoveOver
Definition: dviconv.c:16
initdir()
Definition: dviconv.c:244
void setdir(int d, int dev)
Definition: dviconv.c:250
int command
Definition: dviconv.c:23
int * move
Definition: dviconv.c:12
int h
Definition: dviconv.c:9
void SetFntNum(int k, struct font_index *hdfidx)
Definition: fontcom.c:115
void Fatal()
int makeint()
#define fflush
Definition: xxstdio.h:24
#define fseek
Definition: xxstdio.h:30
#define SetString
Definition: set.h:4
#define SetChar
Definition: set.h:3
long ppagep
Definition: dvi2xx.h:598
static void
Definition: fpif.c:118
#define PRE
Definition: hbf2gf.c:42
#define XXX3
Definition: hbf2gf.c:55
#define XXX2
Definition: hbf2gf.c:54
#define POST
Definition: hbf2gf.c:60
#define XXX1
Definition: hbf2gf.c:53
#define XXX4
Definition: hbf2gf.c:56
#define putc
Definition: jbib.h:20
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
#define POST_POST
Definition: commands.h:259
#define FNT_DEF1
Definition: commands.h:253
#define FNT2
Definition: commands.h:246
#define FNT_DEF3
Definition: commands.h:255
#define SETC_000
Definition: commands.h:10
#define FNT1
Definition: commands.h:245
#define FNT3
Definition: commands.h:247
#define DIR
Definition: commands.h:261
#define FNT4
Definition: commands.h:248
#define SETC_127
Definition: commands.h:137
#define FNT_DEF2
Definition: commands.h:254
#define PUT_RULE
Definition: commands.h:147
#define FONT_63
Definition: commands.h:244
#define FONT_00
Definition: commands.h:181
#define SET_RULE
Definition: commands.h:142
#define FNT_DEF4
Definition: commands.h:256
void dev_dospecial(byte *str, int n)
Definition: dvi.c:405
dev_bop(count)
Definition: dvi.c:137
dev_eop()
Definition: dvi.c:151
dev_push()
Definition: dvi.c:168
dev_pop()
Definition: dvi.c:180
dev_dir(int d)
Definition: dvi.c:285
dev_initpage()
Definition: dvi.c:131
#define fprintf
Definition: mendex.h:64
#define Reverse(p)
Definition: paths.h:45
#define NOP
Definition: tif_getimage.c:684
int k
Definition: otp-parser.c:70
Definition: defs.h:190
Definition: spc_misc.c:56
Definition: strexpr.c:21
val
Definition: tex4ht.c:3227