OSDN Git Service

updated codes.
[putex/putex.git] / src / dvisourc / dvipsone.h
1 /* Common header information for DVIPSONE 
2
3    Copyright 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999 Y&Y, Inc.
4    Copyright 2007 TeX Users Group
5    Copyright 2014 Clerk Ma
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful, but
13    WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20    02110-1301 USA.  */
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <malloc.h>
26 #include <setjmp.h>
27 #include <time.h>
28 #include <signal.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>   /* for _stat etc. */
31 #include <sys/utime.h>  /* for _utimbuf etc. */
32 #include <direct.h>     /* for _getcwd(); */
33 #include <conio.h>
34
35
36 #pragma warning(disable:4996)
37 #pragma warning(disable:4127) // conditional expression is constant
38
39 #ifdef _WINDOWS
40 #define PSputs(str,output) psputs(str,output)
41 #else
42 #define PSputs(str,output) fputs(str,output)
43 #endif
44
45 // PSputc done as macro for speed
46 #ifdef _WINDOWS
47 // #define PSputc(chr,output) psputc(str, output);
48 #define PSputc(chr,output)              \
49   do{                                   \
50     psbuffer[psbufpos++] = (char) chr;  \
51      if ((psbufpos+2 >= PSBUFLEN) ||    \
52          (chr == '\n'))                 \
53     sendpsbuffer(output);               \
54   } while(0)
55 #else
56 #define PSputc(chr,output) putc(chr,output)
57 #endif
58
59 #ifdef _WINDOWS
60 #define showline(str,flag) ShowLine(str,flag)
61 #else
62 #define showline(str,flag)  \
63   do{                       \
64     fputs(str,stdout);      \
65     if(logfileflag)         \
66     fputs(str,logfile);     \
67   } while(0)
68 #endif
69
70 //////////////////////////////////////////////////////////
71
72 #define ID_BYTE 2     /* for version of DVI files that we understand */
73
74 /* Introduce new convenient structure for color info 98/Jul/18 */
75
76 typedef struct
77 {
78   float A;
79   float B;
80   float C;
81   float D;
82 }
83 COLORSPEC;
84
85 /* #define FILENAME_MAX 128 */ /* 16 bit compiler stdio.h */
86 /* #define FILENAME_MAX 260 */ /* 32 bit compiler stdio.h */
87
88 #define MAXFILENAME FILENAME_MAX  /*  128 DOS stdio.h  *//*  260 NT  stdio.h  */
89 #define FNAMELEN    FILENAME_MAX  /* max file name length */
90 #define MAXPATHLEN  FILENAME_MAX  /* max path name length */
91 /* #define MAX_PATH   260 */      /* in NT windef.h ? */
92 /* #define FNAMELEN   80  */      /* max file name length in DOS ? */
93 /* #define MAXPATHLEN 64  */      /* max path name length in DOS ? */
94
95 #define MAXCOMMENT 256    /* max length of TeX comment in DVI file */
96 /* #define MAXLINE 256 */ /* max length of input line (afm - tfm) */
97 #define MAXLINE    512    /* max length of input line 1994/Feb/24 */
98
99 /* #define MAXTEXNAME  33 */ /* (16?) max length of font name in  TeX */
100 /* #define MAXTEXNAME  32 */ /* (16?) max length of font name in  TeX - align */
101 /* #define MAXTEXNAME  34 */ /* (16?) max length of font name in  TeX - align */
102 /* #define MAXFONTNAME 33 */ /* max length of substitute fontname */
103 /* #define MAXFONTNAME 32 */ /* max length of substitute fontname - align */
104 /* #define MAXFONTNAME 34 */ /* max length of substitute fontname - align */
105 /* NOTE: MAXFONTNAME >= MAXTEXNAME since we copy sometimes from one to other */
106 /* #define MAXVECNAME 9  */  /* max length of encoding vector name */
107 /* #define MAXVECNAME 10 */  /* max length of encoding vector name - align */
108 /* #define MAXVECNAME 24 */  /* compromise - why would anyone want... */
109
110 /* #define MAXCHARNAME 33 */ /* (25?) max length of character name */
111 #define MAXCHARNAME 32      /* (25?) max length of character name - align */
112 /* MAXCHARNAME no longer limits length of char name just space allocation */
113 #define MAXCHRS     256     /* max number of characters codes */
114 #define TEXCHRS     128     /* max number of characters in a TeX font */
115
116 /* maximum number assigned to a font by TeX + 1 */
117 /* fixed allocation sizeof(int) * MAXFONTNUMBERS */
118
119 /* #define MAXFONTNUMBERS 512 *//* >= 256 max number assigned to a font + 1 */
120 #define MAXFONTNUMBERS 1024 /* 1999/Feb/22 */
121 /* #define MAXFONTNUMBERS 256 */  /* >= 256 max number assigned TeX 82 */
122
123 /* maximum number of fonts allowed in any one DVI file */
124 /* careful MAXFONTS * MAXCHRS must fit in unsigned int in doallocation */
125
126 #define MAXFONTS 512U   /* 1999/Nov/3 for Larry Tseng */
127 /* #define MAXFONTS 256U */ /* 72 >= 64 max number of fonts in DVI file */
128 /* #define MAXFONTS 128U */ /* 72 >= 64 max number of fonts in DVI file */
129
130 #define MAXSUBSTITUTE 512   /* max fonts in substitution table */
131 /* #define MAXSUBSTITUTE 256 */ /* 128 max fonts in substitution table */
132
133 #define WRAPCOLUMN 64   /* were to start thinking about wrapping special */
134 #define MAXSHOWONLINE 6   /* max shows in a row before newline */
135 #define MAXERRORS 64    /* error count before giving up */
136
137 #define MAXRANGES 16    /* max number of page ranges - now expands */
138 /* #define MAXRANGES 12 */    /* max number of page ranges */
139
140 /* #define DVIDICT 256 */ /* allocation for DVIDICT in printer */
141 #define DVIDICT 300     /* allocation for DVIDICT in printer */
142 /* dvidict needs less to 256 (plus space for fonts */
143 /* but user may define a few extra things in dvidict ... */
144 /* can use command line -D=... to increase */
145
146 #define MAXREMAP 128      /* MAXREMAP can be 32 or 128 */
147 /* #define MAXREMAP 32 */   /* MAXREMAP can be 32 or 128 */
148
149 /* If it is 32, then code 32 does not get mapped to 195 and 127 not to 196 */
150
151 #define MAXSUBFILES 16      /* 1994/Feb/8 */
152 #define MAXPROLOGS 16     /* 1993/Dec/21 */
153
154 /* #define MAXSUBFILES 8 */   /* 1994/Feb/8 */
155 /* #define MAXPROLOGS 8 */    /* 1993/Dec/21 */
156
157 #define MAXCOLORSTACK 16    /* max depth of color stack */
158 /* #define MAXCOLORSTACK 8 */ /* max depth of color stack */
159
160 // #define BLANKFONT 255    /* this font number in DVIPSONE not used */
161 #define BLANKFONT -1    /* this font number in DVIPSONE not used */
162
163 #define INPUTEXT  "dvi"   /* default extension on input file */
164 #define OUTPUTEXT "ps"  /* extension on output file */
165
166 #define RESIDENT  "*reside*"    /* font resident in printer */
167 #define FORCESUB  "*force*"     /* force substitution */
168 #define REMAPIT   "*remap*"     /* remap to specified encoding */
169 #define ALIASED   "*alias*"     /* just another name for same thing */
170 #define SYNTHETIC "*synthetic*" /* don't mess with innards ! */
171 #define COMPOUND  "*compound*"  /* backward compatability */
172 #define HYBRID    "*hybrid*"    /* don't mess with innards */
173 #define MTMI      "*mtmi*"      /* font sucks rocks ! */
174 #define EPSF      "*epsf*"      /* allow use for EPSF %%IncludeFont: */
175 /* #define CONTROL    "*control*" */  /* remap control character range */
176
177 #define C_RESIDENT  1        /* code for RESIDENT font */
178 #define C_FORCESUB  2        /* code for FORCESUB font */
179 #define C_REMAPIT   4        /* code for REMAPIT font */
180 #define C_ALIASED   8        /* code for ALIASED font */
181 #define C_MISSING   16       /* code for missing font */
182 #define C_UNUSED    32       /* code for unused font */
183 #define C_DEPENDENT 64       /* code for font in other size */
184 /* #define C_COMPOUND 128 */ /* font is synthetic */
185 /* #define C_HYBRID 128 */   /* font is synthetic */
186 #define C_SYNTHETIC 128      /* font is synthetic */
187 #define C_MTMI      256      /* font sucks rocks */
188 #define C_EPSF      512      /* allow use for EPSF %%IncludeFont: */
189 #define C_MULTIPLE  1024     /* Multiple Master Base Font */
190 #define C_INSTANCE  2048     /* Multiple Master Instance */
191 #define C_NOTBASE   4096     /* subfontname is MM instance, not MM base */
192 /* #define C_CONTROL 8192 */ /* remap control character range */
193
194 #define CRYPT_MUL 52845u  /* pseudo-random number generator multiplier */
195 #define CRYPT_ADD 22719u  /* pseudo-random number generator addend */
196
197 #define REEXEC 55665      /* seed constant for eexec encryption */
198 /* #define RCHARSTRING 4330 */  /* seed constant for charstring encryption */
199
200 /* #define SINFINITY 32767 */ /* 2^{15} - 1 */
201 #define LINFINITY 2147483647  /* 2^{31} - 1 */
202
203 #define SUBDIRSEARCH  /* 1994/Aug/18 provide for sub-directory search */
204
205 #define TPIC      /* insert code for dealing with TPIC \specials */
206
207 #define TIFF      /* insert code for dealing with TIFF \specials */
208
209 #define ALLOWSCALE    /* allow scaling of output DVI coordinates */
210
211 /* DVI one byte commands: */
212
213 enum dvicom 
214 {
215   set1 = 128, set2, set3, set4,
216   set_rule = 132, 
217   put1 = 133, put2, put3, put4,
218   put_rule = 137,
219   nop = 138, bop, eop, push, pop,
220   right1 = 143, right2, right3, right4,
221   w0 = 147, w1, w2, w3, w4,
222   x0 = 152, x1, x2, x3, x4,
223   down1 = 157, down2, down3, down4,
224   y0 = 161, y1, y2, y3, y4,
225   z0 = 166, z1, z2, z3, z4,
226   /* fnt_num_0 = 171, font_num_1, font_num_2, font_num_3, */
227   fnt1 = 235, fnt2, fnt3, fnt4,
228   xxx1 = 239, xxx2, xxx3, xxx4,
229   fnt_def1 = 243, fnt_def2, fnt_def3, fnt_def4,
230   pre = 247, post, post_post
231 };
232
233 /* srefl = 250, erefl = 251 used for `right-to-left' languages in TeX-XeT */
234 /* need for these was later removed in TeX--XeT */
235
236 /* what DVI commands translate to: */
237
238 /*
239 #define SHOW      "s"
240 #define RIGHT     "r"
241 #define DOWN      "d"
242 #define WRIGHT    "w"
243 #define WSETRIGHT "W"
244 #define XRIGHT    "x"
245 #define XSETRIGHT "X"
246 #define YDOWN     "y"
247 #define YSETDOWN  "Y"
248 #define ZDOWN     "z"
249 #define ZSETDOWN  "Z"
250 #define PUSHSTATE "u"
251 #define POPSTATE  "o"
252 #define MAKEFONT  "mf"
253 */
254
255 /* AND: O => oo, U => u u, M => o u */
256
257 extern unsigned char decryptbyte(unsigned char, unsigned short *);
258 extern void preextract(void);            /* in dviextra.c */
259 extern void writetextext(FILE *);        /* in dviextra.c */
260 /* extern void writeansicode(FILE *); */      /* in dviextra.c */
261 extern void writeansicode(FILE *, char *);      /* in dviextra.c */
262 /* extern void writetextencode(FILE *, char *); */  /* in dviextra.c */
263 extern int readtextencode(char *);        /* in dviextra.c */
264 extern void writedviencode(FILE *);       /* in dviextra.c */
265 /*extern void extract(FILE *);  */        /* in dviextra.c */
266 extern int extractfonts(FILE *);        /* in dviextra.c */
267 extern void fontsetup(FILE *);          /* in dviextra.c */
268 extern unsigned long readlength(FILE*);     /* in dviextra.c */
269 extern void makefilename(char *, char *);   /* in dviextra.c */
270 extern int underscore(char *);          /* in dviextra.c */
271 extern int removeunder(char *);       /* in dviextra.c */
272 extern int ResidentFont(char *);        /* in dviextra.c */
273 extern int FindFileName (char *, char *);   /* in dviextra.c */
274 extern int MarkUnusedFonts(void);       /* in dviextra.c */
275 extern int GetSubstitutes(void);        /* in dviextra.c */
276
277 extern int scanlogfile(FILE *);       /* in dvipslog.c */
278 extern void resetpagerangehit (int);      /* in dvipslog.c */
279 extern char *alias (char *);          /* in dvipslog.c */
280 extern char *nextpathname(char *, char *);    /* in dvipslog.c */
281 extern int searchalongpath (char *, char *, char *, int);
282 extern FILE *findandopen(char *, char *, char *, char *, int);
283 // extern int ReadATMReg(char *, char *);     /* in dvipslog.c */
284 extern int LookupATMReg(char *, char *);      /* in dvipslog.c */
285 extern int SetupATMReg(void);         /* in dvipslog.c */
286 extern void freebackground (void);        /* in dvipslog.c */
287
288 extern int readtfm(char *, FILE *, long widths[]);
289 extern int readafm(char *, FILE *, long widths[]);
290 extern int readpfm(char *, FILE *, long widths[]);
291
292 /* extern int NamesFromPFM (FILE *, char *, int, char *, int); */
293 extern int NamesFromPFM (FILE *, char *, int, char *, int, char *);
294
295 extern int scandvifile(FILE *, FILE *, int);  /* in dvianal.c */
296 extern long gotopost(FILE *);     /* in dvianal.c */
297
298
299 /* extern FILE *findepsfile(char *, int); */  /* in dvispeci.c */
300 /* extern FILE *findepsfile(char *, int, char *); *//* in dvispeci.c */
301 extern FILE *findepsfile(char *, char *, int, int); /* in dvispeci.c */
302 extern int scan_special(FILE *, char *, int);  /* in dvispeci.c */
303 extern int scan_special_raw(FILE *, char *, int); /* in dvispeci.c */
304 extern FILE *fopenfont (char *, char *, int); /* in dvispeci.c */
305 extern int FindMMBaseFile (int k);        /* in dvispeci.c */
306 extern int checkCTM(FILE *);          /* in dvispeci.c */
307 extern int checkColorStack(FILE *);       /* in dvispeci.c */
308 extern int doColorPopAll(int);
309 extern int doColorPop(int);
310 extern int doColorPush(int);
311 extern void doColorSet(FILE *, int);
312 extern double decodeunits(char *);        /* in dvispeci.c */
313
314 extern int readcommands(char *filename);
315
316 // extern void errcount(void);
317 extern void errcount(int);
318 extern void giveup(int);
319 /* extern void tellwhere(FILE *); */
320 extern void tellwhere(FILE *, int);
321 extern void ShowLine(char *, int);      /* new in dvipsone.c */
322
323 extern int get_alpha_token(FILE *, char *, int);
324 extern int get_token(FILE *, char *, int);
325 extern void flush_special(FILE *);
326 extern int skip_this_page(long);
327 extern int readspecial(FILE *, FILE *, unsigned long);
328 extern void prereadspecial(FILE *, unsigned long);
329 extern void lowercase(char *, char *);
330 extern void uppercase(char *, char *);
331 extern void extension(char *, char *);
332 extern void forceexten(char *, char *);
333 char *extractfilename(char *);
334 extern void removeexten(char *);
335 extern int getline(FILE *, char *);
336 extern int getrealline(FILE *, char *);
337 /* extern char *nextpathname(char *, char *); */
338 extern char *removepath(char *);
339 extern int copyepssimple(FILE *, FILE *);
340 extern int setupatmini(void);     /* dvipsone.c */
341 extern void checkexit(int);       /* dvipsone.c */
342 extern char *zstrdup(char *);     /* dvipsone.c */
343
344 extern void abortjob(void);        /* dvipsone.c */
345 extern char *grabenv (char *);      /* dvipsone.c */
346
347 extern void setupinifilesub(char*, char *); /* in dvipsone.c */
348 extern int uexit (int);         /* in dvipsone.c */
349
350 extern void setupfontchar(int);     /* set up wantchrs for one font */
351
352 extern void map850topdf(char *, int); /* in dvispeci.c */
353 extern void complainspecial(FILE *); 
354
355 /* extern void initializeencoding(void); */ /* dviextra.c */
356 extern void initializeencoding(int);    /* dviextra.c */
357 extern int decompressfont(FILE *, FILE *, char *); /* dviextra.c */
358
359 extern int newspecials(FILE *, FILE *);   /* dvitiff.c */
360 extern int dohptag(FILE *, FILE *);     /* dvitiff.c */
361
362 extern unsigned long codefourty (char *);
363
364 extern void DeAllocStringsIn(void);     /* dvitiff.c */
365 extern void DeAllocStringsOut(void);    /* dvitiff.c */
366
367 extern void doColor (FILE *, FILE *, int, int); /* dvispeci.c */
368 extern void RestoreColorStack(int);       /* dvipslog.c */
369 extern void freecolorsave (void);     /* dvipslog.c */
370
371 extern void doClipBoxPopAll(FILE *);    /* dvispeci.c */
372
373 /* extern unsigned int ureadone(FILE *); */
374 /* extern unsigned int ureadtwo(FILE *); */
375 /* extern int sreadone(FILE *); */
376 /* extern int sreadtwo(FILE *); */
377 /* extern unsigned long ureadthree(FILE *); */
378 /* extern unsigned long ureadfour(FILE *); */
379 /* extern long sreadthree(FILE *); */
380 /* extern long sreadfour(FILE *); */
381
382 void scivilize (char *);
383
384 void lcivilize (char *);
385
386 void perrormod (char *);
387
388 FILE *OpenFont(char *font, int flag);
389
390 FILE *openpfm (char *font);
391
392 int LoadATMREG (void);
393
394 ////////////////////////////////////////////////////////////////////
395
396 extern FILE *errout;    /* where to send error output */
397
398 extern int logfileflag;   /* write log file 99/Apr/20 */
399 extern FILE *logfile;   /* 1999/Apr/20 */
400
401 extern FILE *input;       /* used by tellwhere */
402
403 extern int volatile bAbort;   /* set by user control-C */ /* 1992/Nov/24 */
404 extern int abortflag;
405
406 extern char *task;      /* current task -  for error message */
407
408 extern int const statisticsflag;  /* non-zero => output stack depth, fonts used */
409 extern int const complainflag;    /* non-zero implies complain sub table warnings */
410 extern int const timingflag;    /* non-zero => show timing information */
411
412 extern int verboseflag;   /* non-zero => lots of output */
413 extern int traceflag;   /* non-zero => lots of output */
414 extern int quietflag;     /* non-zero => suppress \special complaints */
415 extern int reverseflag;   /* non-zero => do pages in reverse order */
416 extern int skipflag;    /* on when page to be skipped reading forward */
417 extern int countzeroflag; /* non-zero => page limits based on TeX /count0 */
418 extern int stripcomment;  /* non-zero => strip comments */
419 extern int bUseCounters;  /* non-zero counter[1]-counter[2] 96/Jan/28 */
420 extern int bShortFont;    /* use shorter font numbers for /f... */
421 extern int bBackWardFlag; /* force long form of octal escape in strings */
422 extern int bForwardFlag;    /* use \b, \t, \n, ... \f, \r in strings 93/Sep/29 */
423 extern int textures;    /* non-zero => textures style DVI file */
424 extern int bBackGroundFlag; /* support \special{background ...} 98/Jun/30 */
425 extern int bBackUsed;   /* non-zero of \special{background ...} used */
426 extern int oddpageflag;   /* print only odd pages */
427 extern int evenpageflag;  /* print only even pages */
428 extern double xoffsete;     /* x offset even pages */
429 extern double yoffsete;     /* y offset even pages*/
430 extern double xoffseto;     /* x offset odd pages */
431 extern double yoffseto;     /* y offset odd pages */
432 extern int evenoddoff;    /* non-zero if offsets differ on even/odd page */
433 extern int pagetpic;    /* non-zero if TPIC special used on this page */
434 extern int complainedaboutj;  /* reset at top of page */
435 extern int colorindex;    /* color stack index 96/Nov/3 */
436 extern int clipstackindex;  /* clip push pop index 98/Sep/12 */
437 extern int bColorUsed;    /* non-zero if \special{color ...} seen */
438 extern int bCarryColor;   /* carry color across pages 98/Feb/14 */
439 extern int CTMstackindex; /* CTM stack index 96/Nov/3 */
440 extern int newbopflag;    /* want LogicalPage PhysicalPage */
441 extern int bOptionalDSC;  /* want %%PageTrailer comments */
442 extern int bRemapControl; /* non-zero => 0 - 32, 127 => 161 -- 196 */
443 extern int bRemapSpace;   /* non-zero => 32 => 195, 0 => 161 95/Oct/17 */
444 extern int bRemapFont;    /* remap just this one font ... 95/Oct/15 */
445 extern int nRepeatIndex;  /* 95/Aug/27 */
446 extern int nRepeatCount;  /* 95/Aug/27 */
447
448 extern long pageno;     /* for convenience in error messages dvipslog.c */
449 extern long pagenumber;   /* count of pages actually seen */
450 extern long numpages;   /* number of pages actually processed */
451 extern long dvistart;   /* where DVI part of Textures file starts */
452 extern long nMinRule;   /* min rule thickness (Adobe Reader fix) 95/Oct/10 */
453 extern long previous;   /* pointer to previous bop in this file */
454 extern int finish;      /* when seen last eop */
455
456 extern long counter[10];
457
458 extern char line[MAXLINE];  /* general purpose input `buffer' 512 bytes */
459 extern char logline[MAXLINE]; /* used for showline */
460
461 extern char *outputfile;    /* output file or empty */
462 extern char *filenamex;     /* remember file name here */
463 extern char *epspath;     /* directory to look for EPF files */
464 extern char *dvipath;     /* directory of dvi file */
465
466 extern char *fontsubpath;
467 extern char *fontsubrest;   /* font substitution file on command line */
468
469 extern char fontsubfile[FNAMELEN];    /* font substitution file */
470 extern char *subfontfile[MAXSUBFILES];  /* user subfile or empty (-s=...) */
471
472 extern int remaptable[MAXREMAP];  /* 1994/June/20 */
473
474 // extern int finx[MAXFONTNUMBERS];   /* indeces into next few */
475 extern short finx[MAXFONTNUMBERS];  /* indeces into next few */
476
477 extern int fontsubflag[MAXFONTS]; /* non-zero if substitute font used */
478 extern int fontproper[MAXFONTS];  /* code resident/forced/remap/alias */
479 extern unsigned long fc[MAXFONTS];  /* checksum of TFM file (encoding info) */
480 extern unsigned long fs[MAXFONTS];    /* at size */ 
481
482 // extern char *fontname;     /* 1994/Feb/2 */
483 extern char *fontname[MAXFONTS];  /* 1999/Nov/6 */
484 // extern char *subfontname;    /* 1994/Feb/2 */
485 extern char *subfontname[MAXFONTS]; /* 1999/Nov/6 */
486 // extern char *fontvector;     /* font remapping vector */
487 extern char *fontvector[MAXFONTS];      /* font remapping vector */
488 // extern char *fontchar;     /* which characters needed */
489 extern char *fontchar[MAXFONTS];      /* which characters needed */
490
491 // extern char *fontsubfrom;
492 extern char *fontsubfrom[MAXSUBSTITUTE];  /* 1999/Nov/6 */
493 // extern char *fontsubto;
494 extern char *fontsubto[MAXSUBSTITUTE];    /* 1999/Nov/6 */
495 // extern char *fontsubvec;
496 extern char *fontsubvec[MAXSUBSTITUTE];   /* 1999/Nov/6 */
497
498 extern int dvi_s, dvi_t;  /* stack depth & no of pages (bop) in DVI file */
499
500 extern unsigned long dvi_l, dvi_u;  /* max page height + depth & max width *//* NA */
501
502 extern unsigned long num, den;  /* from DVI file */
503 extern unsigned long mag;   /* Tex \mag => 1000 times desired magnification */
504
505 extern int ff;    /* current font - changed by fnt and fnt_num - reset by bop */
506 extern int fnt;   /* fnt =  finx[ff] */
507
508 extern int fnext;         /* next slot to use */
509 extern int flast;         /* last including MM fonts */
510
511 #ifdef ALLOWSCALE
512 extern int outscaleflag;
513 extern double outscale;
514 #endif
515
516 // dvitiff.c
517
518 extern int bTextColor;
519 extern double textred;
520 extern double textgreen;
521 extern double textblue; 
522 extern int bRuleColor;
523 extern double rulered;
524 extern double rulegreen;
525 extern double ruleblue; 
526 extern int bFigureColor;
527 extern double figurered;
528 extern double figuregreen;
529 extern double figureblue; 
530 extern int bReverseVideo;
531 extern int bDVICopyReduce;        /* 1995/Sep/16 */
532 extern long postposition; /* position of post op in DVI */
533
534 extern COLORSPEC CurrColor;
535 extern COLORSPEC *BackColors;
536
537 extern COLORSPEC ColorStack[MAXCOLORSTACK];   /* current stack 98/Jul/18 */
538
539 extern int bPDFmarks;   /* write pdfmarks into PS file 95/Feb/25 */
540 extern int bGhostHackFlag;
541 extern int bSuppressBack; /* suppress background in imagemask 95/Dec/31 */
542 extern int nDefaultTIFFDPI; /* use if resolution not specified in TIFF */
543 extern int bLevel2;     /* if allowed to use level 2 features 96/Dec/20 */ 
544 extern int bAllowCompression; /* allow use of compression of TIFF images */
545 extern int bAllowColor; /* allow use of colorimage operator */
546 extern int bKeepBlack;    /* suppress textcolor, rulecolor, figurecolor */
547 extern int bInsertImage;  /* if \special{insertimage: ... } seen */
548 extern int bLandScape;    /* asked for landscape mode -*O 95/Jun/24 */
549
550 extern int wantmagictiff;   /* TIFF: want to use our own screen function */
551 extern int frequency, angle;  /* frequency and angle */
552 extern int usealtGoToR;     /* use alternate /GoToR action in PDF */
553
554 // dvispeci.c
555
556 extern int directprint;     /* non-zero => output directly to printer */
557 extern int bSmartCopyFlag;    /* non-zero => look for %%EOF and such */
558 extern int bPassControls;   /* pass through control characters in EPSF */
559 extern int bKeepTermination;  /* keep line terminations intact in EPS */
560 extern int passcomments;    /* non-zero => do not flush comment lines EPS */
561 extern int verbatimflag;    /* non-zero => allow verbatim PostScript */
562 extern int preservefont;    /* preserve font across verbatim */
563 extern int bWrapSpecial;    /* prevent long linesin \special */
564
565 extern int bSciWord;      /* treat ps: filename case */
566 extern int bIgnoreSpecials;   /* non-zero => ignore \specials */
567 extern int bPassEPSF;     /* non-zero => pass EPSF files (normal) */
568 extern int allowtpic;     /* non-zero => allow TPIC \specials */
569 extern int needtpic;      /* non-zero => need TPIC header */
570 extern int bOldDVIPSFlag;   /* non-zero => wrap ps: code unlike ps:: */
571 extern int bOldDVIPSFlip;   /* flip coordinates in ps: code 96/Nov/7 */
572 extern int bQuotePage;      /* suppress showpage in \special{"..."} */
573 extern int bProtectStack;   /* add [ ... cleartomark 97/Nov/24 */
574 extern int bStoppedContext;   /* add { ... } stopped 97/Nov/24 */
575
576 extern int bAllowInclude;   /* expand %%IncludeResource: font ... */
577 extern int bAllowBadBox;    /* allow single % comment before BoundingBox */
578 extern int bConvertReturn;    /* convert isolated \r in EPS to \n */
579 extern int reverseflag;     /* non-zero => do pages in reverse order */
580 extern int showcount;     /* on when last sent out "set" or "put" */
581 extern int freshflag;     /* at start of new line from PS special 99/Dec/19 */
582
583 extern int useatmini;     /* use [Setup] section in `atm.ini' */
584 extern int useatmreg;     /* use armreg.atm */
585 extern int usepsfontname;   /* allow use of PS Fontnames in DVI TFM */
586 extern int bFirstNull;      /* non-zero => flush \special starts with null */
587
588 extern char *szATMRegAtm;   /* full file name of atmreg.atm */
589 extern char *atmini;      /* full file name for atm.ini, with path */
590 extern char *tpiccommands;
591 extern char *fontpath;      /* from PSFONTS env var in dvipsone.c */
592 extern char *afmpath;   /* default path for AFM font metric files */
593 extern char *tfmpath;   /* default path for TFM font metric files */
594 extern char *pfmpath;   /* default path for PFM font metric files */
595 extern char *vecpath;   /* default place for encoding vectors */
596 extern char *texfonts;    /* default place for TFM font metric files */
597
598 extern int currentfirst;  /* look in current directory for files */
599 extern int useatmfontsmap;  /* zero if tried and failed to find atmfonts.map */
600 extern char *atmfontsmap; /* file name and path to ATMFONTS.MAP */
601
602 extern int colortypeflag; /* 0 => gray, 1 => rgb, 2 => cmyk */
603 extern int colorindex;    /* points at next slot to push into */
604 extern int clipstackindex;        /* set to zero at start of page */
605
606 extern int columns;     /* maximum length of output line */
607 extern int subfontfileindex;      /* pointer into following */
608
609 extern int showsubflag;     /* non-zero => show substitution table */
610 extern int wantnotdef;      /* non-zero => want .notdef CharString */
611 extern int flushcr;       /* try and get rid of those pesky \r */
612 extern int stripinfo;     /* strip out rest of /FontInfo directory */
613 extern int substituteflag;    /* non-zero => do font substitution */
614 extern int forcereside;     /* non-zero => force printer resident */
615 extern int avoidreside;     /* non-zero => veto printer resident */
616 extern int bWindowsFlag;    /* reencode StandardEncoding to Windows ANSI */
617             /* *or* by specified textencoding - ENCODING env var */
618 extern int bCheckEncoding;    /* check checksum for match with encoding */
619 extern int insertmetrics;   /* insert new font metrics in substituted */
620
621 extern int tryunderscore;   /* try underscore form of font file name */
622 extern int bUseInternal;    /* non-zero => use internal number for /fn...*/
623 extern int bAllowShortEncode; /* allow name of Encoding instead of list */
624 extern int bAllowStandard;    /* allow use StandardEncoding if it works */
625 extern int bAllowTexText;   /* allow use TeXtext encoding if it works */
626 extern int bAllowANSI;      /* allow use ANSI encoding if it works */
627 extern int busedviencode;   /* use dvipsone reencoding of all fonts ! */
628 extern int accentedflag;      /* deal with accented / composite chars */
629 extern int syntheticsafe;   /* be paranoid about synthetic fonts */
630 extern int bSuppressPartial;  /* suppress partial font downloading */
631 extern int bForceFullArr;   /* force full 256 element Encoding array */
632 extern int keepgap;       /* keep space bytes before ND 93/Aug/5*/
633 extern int showfontflag;    /* non-zero => show font tables */
634 extern int stripchecking;   /* strip garbage from nasty old Adobe fonts */
635 extern int textextwritten;    /* non-zero textext encoding already written */
636 extern int ansiwritten;     /* non-zero ansi encoding already written */
637 extern int bTexFontsMap;    /* non-zero => allowed to use `texfonts.map'*/
638 extern int bForceFontsMap;    /* non-zero => replace aliases `texfonts.map'*/
639 extern int bMarkUnused;     /* non-zero => mark unused fonts early */
640 extern int bMMShortCut;     /* simple way to construct base file name */
641
642 extern int bSubRealName;    /* substitute file name for FontName in PFA */
643                 /* not good idea to set to zero ... */
644 extern int bRandomPrefix;   /* add random prefix to file names 95/Sep/30 */
645
646 extern int bAddBaseName;    /* add BaseFontName for Distiller 97/Jan/30 */
647
648 extern char *textencoding;    /* encoding used by plain vanilla text fonts */
649                 /* may override "ansinew" 94/Dec/17 */
650 extern char *textenconame;    /* just vector name itself 95/Feb/3 */
651
652 extern unsigned long nCheckSum; /* expected checksum ENCODING= *//* 95/Feb/3 */
653
654 extern int nfonts, nsubstitute, nremapped, nansified;
655
656 extern int uppercaseflag;   /* convert font names to upper case */
657 extern int maxsubstitute;   /* usually equal to MAXSUBSTITUTE */
658 extern int maxfonts;      /* usually equal to MAXFONTS */
659 extern int bStripBadEnd;    /* read to EOL at end of encrypted 96/Feb/22 */
660
661 extern char *fontprefix;    /* prefix to use on FontName */
662
663 extern int BBxll, BByll, BBxur, BByur;  /* crop box given 96/May/4 */
664
665 extern int rangeindex;      /* index into following table */
666
667 // extern long beginpages[MAXRANGES]; /* table of pagebegins */
668 extern long *beginpages;  /* table of pagebegins */
669 // extern long endpages[MAXRANGES]; /* table of pageends */
670 extern long *endpages;  /* table of pageends */
671
672 // extern int pagerangeseq[MAXRANGES];/* which instance of page range desired ? */
673 extern int *pagerangeseq;/* which instance of page range desired ? */
674
675 extern char fn_in[FNAMELEN], fn_out[FNAMELEN];    /* 1994/Mar/1 */
676
677 extern long nspecial;   /* byte count of special */
678 extern long nspecialsav;  /* byte count of special */
679 extern long specstart;    /* saved start of \special for error message */
680
681 extern char *comment;     /* pointer to place for TeX comment */
682
683 extern char *paper_size;     /* Custom paper size specified via special */
684
685 extern int nheaderlength;   // 99/July/14
686 extern char *headerfile;    /* name of user supplied header file(s) */
687
688 extern int headertextlen;   /* how much has been accumulated */
689 extern char *headertext;    /* accum header PS text from headertext= */
690
691 extern int commandspeclen;
692 extern char *commandspec;
693
694 extern int dsccustomlen;    /* how much has been accumulated */
695 extern char *dsccustom;     /* accum DSC header text from DSCcomment= */
696
697 extern int keywordslen;     /* how much has been accumulated in following */
698 extern char *keywords;      /* accumulated keywords from keywords= */
699
700 extern char *dscfile;     /* name of (single) DSC header file */
701
702 extern char *creatorstring;   /* creator for DocInfo in Adobe Reader */
703 extern char *titlestring;   /* title for DocInfo in Adobe Reader */
704 extern char *subjectstring;   /* Subject for DocInfo in Adobe Reader */
705 extern char *authorstring;    /* Author for DocInfo in Adobe Reader */
706 extern char *basestring;    /* Base for DocView in Adobe Reader */
707 extern char *pagemode;      /* Base for DocView in Adobe Reader */
708
709 extern int stinx;       /* stack index */ /* just for verification */
710 extern int maxstinx;      /* max stack index seen */
711 extern int usefontmap;      /* 1996/July/30 */
712
713 extern int dirindex;      // number of dir paths in ATMREG.ATM
714 extern int ATMfontindex;    // number of font entries from ATMREG.ATM
715
716 extern int usecallbackflag;
717
718 extern int ksubst;        // entries in substitution table
719
720 extern int fontsubprop[MAXSUBSTITUTE];  /* resident/forced/remapped/alias */
721
722 extern int badpathwarn;
723
724 extern char **DirPaths;
725
726 extern jmp_buf jumpbuffer;    // for non-local jumps