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