OSDN Git Service

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