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

dvips.h
Go to the documentation of this file.
1 /* $Id: dvips.h 57769 2021-02-17 03:03:54Z karl $
2  * Copyright 1986-2021 Tomas Rokicki.
3  * This is dvips, a freely redistributable PostScript driver
4  * for dvi files. You may freely use, modify and/or distribute this
5  * program or any portion thereof.
6  */
7 
8 /* This file is the header for dvips's global data structures. */
9 
10 #define CREATIONDATE
11 
12 #define MAX_CODE 0x110000
13 #define MAX_2BYTES_CODE 0x10000
14 #define VF_MEM_UNIT 0x10000
15 #define CD_IDX(i) ((i>=MAX_2BYTES_CODE ? MAX_2BYTES_CODE : i))
16 
17 #define BANNER \
18 "This is dvips(k) 2021.1 Copyright 2021 Radical Eye Software"
19 #define BANNER2 "(www.radicaleye.com)"
20 #ifdef KPATHSEA
21 #include "config.h"
22 #include "debug.h"
23 #endif
24 /* Please don't turn debugging off! */
25 #ifndef DEBUG
26 #define DEBUG
27 #endif
28 
29 #ifndef KPATHSEA
30 #include <stdio.h>
31 #if defined(SYSV) || defined(VMS) || defined(__THINK__) || defined(MSDOS) || defined(OS2) || defined(ATARIST) || defined(WIN32)
32 #include <string.h>
33 #else
34 #include <strings.h>
35 #endif
36 #endif
37 #if defined(lint) && defined(sun)
38 extern char *sprintf();
39 #endif
40 #include "paths.h"
41 #include "debug.h"
42 #ifdef VMS
43 #include "[.vms]vms.h"
44 #endif /* VMS */
45 #include <stdlib.h>
46 /*
47  * Is your malloc big?
48  */
49 #if defined(MSDOS) && !defined(__EMX__) && !defined(DJGPP)
50 #define SMALLMALLOC
51 #endif
52 #if defined(OS2) && defined(_MSC_VER)
53 #define SMALLMALLOC
54 #endif
55 /*
56  * Constants, used to increase or decrease the capacity of this program.
57  *
58  * Strings are now more dynamically allocated, so STRINGSIZE is not the
59  * strict limit it once was. However, it still sets the maximum size
60  * of a string that can be handled in specials, so it should not be
61  * set too small.
62  */
63 #define STRINGSIZE (200000) /* maximum total chars in strings in program */
64 #define RASTERCHUNK (8192) /* size of chunk of raster */
65 #define MINCHUNK (240) /* minimum size char to get own raster */
66 #define STACKSIZE (500) /* maximum stack size for dvi files */
67 #define MAXFRAME (50) /* maximum depth of virtual font recursion */
68 #define MAXFONTHD (1024) /* number of unique names of included fonts */
69 #define STDOUTSIZE (75) /* width of a standard output line */
70 #define DOWNLOADEDPSSIZE (1000) /* max number of downloaded fonts to check */
71 /*
72  * Other constants, which define printer-dependent stuff.
73  */
74 #define SWMEM (180000) /* available virtual memory in PostScript printer */
75 #define DPI (actualdpi) /* dots per inch */
76 #define VDPI (vactualdpi) /* dots per inch */
77 #define RES_TOLERANCE(dpi) ((int)(1+dpi/500))
78  /* error in file name resolution versus desired */
79 #define FONTCOST (298) /* overhead cost of each sw font */
80 #define PSFONTCOST (1100) /* overhead cost for PostScript fonts */
81 #define PSCHARCOST (20) /* overhead cost for PostScript font chars */
82 #define DNFONTCOST (35000) /* overhead cost for downloaded PS font */
83 #define CHARCOST (15) /* overhead cost for each character */
84 #define OVERCOST (30000) /* cost of overhead */
85 #define DICTITEMCOST (20) /* cost per key, value in dictionary */
86 #define NAMECOST (40) /* overhead cost of each new name */
87 /*
88  * Type declarations. integer must be a 32-bit signed; shalfword must
89  * be a sixteen-bit signed; halfword must be a sixteen-bit unsigned;
90  * quarterword must be an eight-bit unsigned.
91  */
92 #if (defined(MSDOS) && !defined(DJGPP)) || (defined(OS2) && defined(_MSC_VER)) || defined(ATARIST)
93 typedef long integer;
94 typedef unsigned long uinteger;
95 #else
96 typedef int integer;
97 typedef unsigned int uinteger;
98 #endif
99 #ifndef KPATHSEA
100 typedef char boolean;
101 #endif
102 typedef double real;
103 typedef short shalfword;
104 typedef unsigned short halfword;
105 typedef unsigned char quarterword;
106 #ifdef WIN32
107 #define Boolean boolean
108 #else
109 #ifndef __THINK__
110 typedef short Boolean;
111 #endif
112 #endif
113 /*
114  * If the machine has a default integer size of 16 bits, and 32-bit
115  * integers must be manipulated with %ld, set the macro SHORTINT.
116  */
117 #ifdef XENIX
118 #define SHORTINT
119 #else
120 #undef SHORTINT
121 #endif
122 #if defined(MSDOS) && !defined(__EMX__) && !defined(DJGPP) || defined(ATARIST)
123 #define SHORTINT
124 #endif
125 #if defined(OS2) && defined(_MSC_VER)
126 #define SHORTINT
127 #endif
128 
129 /*
130  * This is the structure definition for resident fonts. We use
131  * a small and simple hash table to handle these. We don't need
132  * a big hash table.
133  */
134 #define RESHASHPRIME (73)
135 struct resfont {
136  struct resfont *next;
139  char *downloadheader; /* possibly multiple files */
141 };
142 
143 /*
144  * A chardesc describes an individual character. Before the fonts are
145  * downloaded, the flags indicate that the character has already been used
146  * with the following meanings:
147  */
148 typedef struct tcd {
154 #define EXISTS (1)
155 #define PREVPAGE (2)
156 #define THISPAGE (4)
157 #define TOOBIG (8) /* not used at the moment */
158 #define REPACKED (16)
159 #define BIGCHAR (32)
160 #define STATUSFLAGS (EXISTS|REPACKED|BIGCHAR)
161 /*
162  * The new field flags2 above is now an immutable field (once a font is
163  * loaded); for now it only indicates whether a character EXISTS or not.
164  * This fixes a problem with -G.
165  */
166 /*
167  * A fontdesc describes a font. The name, area, and scalename are located in
168  * the string pool. The nextsize pointer is used to link fonts that are used
169  * in included psfiles and differ only in scaledsize. Such fonts also have
170  * a non-NULL scalename that gives the scaledsize as found in the included
171  * file. The psflag indicates that the font has been used in an included
172  * psfile. It can be 0, PREVPAGE, THISPAGE, or EXISTS.
173  */
174 typedef struct tfd {
184  char *name, *area;
185  struct resfont *resfont;
186  struct tft *localfonts;
187  struct tfd *next;
188  struct tfd *nextsize;
189  char *scalename;
191  int iswide, kind;
193 
194 #define VF_TEX (1)
195 #define VF_OMEGA (2)
196 #define VF_PTEX (3)
197 
198 /* A fontmap associates a fontdesc with a font number.
199  */
200 typedef struct tft {
203  struct tft *next;
205 
206 /* Virtual fonts require a `macro' capability that is implemented by
207  * using a stack of `frames'.
208  */
209 typedef struct {
210  quarterword *curp, *curl;
213 } frametype;
214 
215 /*
216  * The next type holds the font usage information in a 256-bit table;
217  * there's a 1 for each character that was used in a section.
218  */
219 typedef struct {
223 } charusetype;
224 
225 /* Next we want to record the relevant data for a section. A section is
226  * a largest portion of the document whose font usage does not overflow
227  * the capacity of the printer. (If a single page does overflow the
228  * capacity all by itself, it is made into its own section and a warning
229  * message is printed; the page is still printed.)
230  *
231  * The sections are in a linked list, built during the prescan phase and
232  * processed in proper order (so that pages stack correctly on output) during
233  * the second phase.
234  */
235 typedef struct t {
237  struct t *next;
240 
241 /*
242  * Sections are actually represented not by sectiontype but by a more
243  * complex data structure of variable size, having the following layout:
244  * sectiontype sect;
245  * charusetype charuse[numfonts];
246  * fontdesctype *sentinel = NULL;
247  * (Here numfonts is the number of bitmap fonts currently defined.)
248  * Since we can't declare this or take a sizeof it, we build it and
249  * manipulate it ourselves (see the end of the prescan routine).
250  */
251 /*
252  * This is how we build up headers and other lists.
253  */
254 struct header_list {
255  struct header_list *next;
256  const char *Hname;
257  char *precode;
258  char *postcode;
259  char *name;
260 };
261 /*
262  * Some machines define putlong in their library.
263  * We get around this here.
264  */
265 #define putlong was_putlong
266 /*
267  * Information on available paper sizes is stored here.
268  */
269 struct papsiz {
270  struct papsiz *next;
272  const char *name;
273  const char *specdat;
274 };
275 #ifdef MVSXA /* IBM: MVS/XA */
276 /* this is where we fix problems with conflicts for truncation
277  of long names (we might only do this if LONGNAME not set but ...) */
278 # define pprescanpages pprscnpgs /* confict with pprescan */
279 # define flushDashedPath flshDshdPth /* conflict with flushDash */
280 # define PageList PgList /* re-definition conflict with pagelist */
281 /* adding ascii2ebcdic conversion table to extern */
282  extern char ascii2ebcdic[];
283 #endif /* IBM: MVS/XA */
284 #ifdef VMCMS /* IBM: VM/CMS */
285 /* this is where we fix problems with conflicts for truncation
286  of long names (we might only do this if LONGNAME not set but ...) */
287 # define pprescanpages pprscnpgs /* confict with pprescan */
288 # define flushDashedPath flshDshdPth /* conflict with flushDash */
289 /* adding ascii2ebcdic conversion table to extern */
290  extern char ascii2ebcdic[];
291 /* redefining fopen for VMCMS, see DVIPSCMS.C */
292  extern FILE *cmsfopen();
293 # ifdef fopen
294 # undef fopen
295 # endif
296 # define fopen cmsfopen
297 #define downloadpspk dnldpspk
298 #endif /* IBM: VM/CMS */
299 /*
300  * Remove namespace conflict with standard library on Macintosh
301  */
302 #ifdef __THINK__
303 #define newstring newpoolstring
304 #endif
305 
306 #ifndef VOID
307 #define VOID void
308 #endif
309 
310 #define USE_PCLOSE (801)
311 #define USE_FCLOSE (802)
312 
313 /* output Unicode string on console in windows */
314 #if defined(KPATHSEA) && defined(WIN32)
315 #undef perror
316 #define fprintf_str win32_fprintf
317 #define fputs_str win32_fputs
318 #define putc_str win32_putc
319 #define perror win32_perror
320 #else
321 #define fprintf_str fprintf
322 #define fputs_str fputs
323 #define putc_str putc
324 #endif
325 
326 /* Things that KPATHSEA knows, and are useful even without it. */
327 #if !defined(KPATHSEA)
328 
329 #if defined(MSDOS) || defined(OS2) || defined(WIN32)
330 #define FOPEN_ABIN_MODE "ab"
331 #define FOPEN_RBIN_MODE "rb"
332 #else
333 #define FOPEN_ABIN_MODE "a"
334 #define FOPEN_RBIN_MODE "r"
335 #endif
336 
337 #if (defined MSDOS || defined OS2 || defined WIN32)
338 #define WRITEBIN "wb"
339 #else
340 #ifdef VMCMS
341 #define WRITEBIN "wb, lrecl=1024, recfm=f"
342 #else
343 #define WRITEBIN "w"
344 #endif
345 #endif
346 
347 #if defined(WIN32)
348 #define STDC_HEADERS
349 #include <io.h>
350 #include <fcntl.h>
351 #define O_BINARY _O_BINARY
352 #define register
353 #define SET_BINARY(fd) (void)_setmode((fd), _O_BINARY)
354 #else /* !WIN32 */
355 #define SET_BINARY(fd) (void)0
356 #endif
357 
358 #if defined(DEVICESEP)
359 #define IS_DEVICE_SEP(c) ((c) == DEVICESEP)
360 #else
361 #define IS_DEVICE_SEP(c) 0
362 #endif
363 #define STREQ(s1, s2) (((s1) != NULL) && ((s2) != NULL) && !strcmp((s1), (s2)))
364 
365 #if defined(MSDOS) || defined(OS2) || defined(WIN32)
366 #define NAME_BEGINS_WITH_DEVICE(name) (*(name) && IS_DEVICE_SEP((name)[1]))
367 #define IS_DIR_SEP(c) ((c) == '/' || (c) == '\\')
368 #define FILESTRCASEEQ(s1, s2) (strcasecmp (s1, s2) == 0)
369 #else
370 #define NAME_BEGINS_WITH_DEVICE(name) 0
371 #define IS_DIR_SEP(c) ((c) == DIRSEP)
372 #define FILESTRCASEEQ STREQ
373 #endif
374 
375 #define TOLOWER(c) tolower(c)
376 #define ISALNUM(c) isalnum(c)
377 #define ISXDIGIT(c) (isascii (c) && isxdigit(c))
378 
379 #endif
double real
Definition: dvips.h:66
char boolean
Definition: dvips.h:64
int integer
Definition: dvips.h:61
short shalfword
Definition: dvips.h:67
short Boolean
Definition: dvips.h:74
unsigned short halfword
Definition: dvips.h:68
unsigned char quarterword
Definition: dvips.h:69
struct tft fontmaptype
unsigned int uinteger
Definition: dvips.h:97
struct tfd fontdesctype
struct tcd chardesctype
struct t sectiontype
#define sprintf
Definition: snprintf.c:44
int integer
Definition: pbmtopk.c:38
char quarterword
Definition: pbmtopk.c:39
Definition: gf2pbm.c:137
fontdesctype * fd
Definition: dvips.h:220
halfword psfused
Definition: dvips.h:221
quarterword * curl
Definition: dvips.h:210
fontdesctype * curf
Definition: dvips.h:211
fontmaptype * ff
Definition: dvips.h:212
char * precode
Definition: dvips.h:257
char * name
Definition: dvips.h:259
char * postcode
Definition: dvips.h:258
struct header_list * next
Definition: dvips.h:255
const char * Hname
Definition: dvips.h:256
Definition: dvips.h:269
integer xsize
Definition: dvips.h:271
integer ysize
Definition: dvips.h:271
const char * name
Definition: dvips.h:272
struct papsiz * next
Definition: dvips.h:270
const char * specdat
Definition: dvips.h:273
Definition: dvips.h:135
char * Fontfile
Definition: dvips.h:137
char * Vectfile
Definition: dvips.h:137
char * TeXname
Definition: dvips.h:137
char * Keyname
Definition: dvips.h:137
quarterword sent
Definition: dvips.h:140
char * specialinstructions
Definition: dvips.h:138
char * PSname
Definition: dvips.h:137
char * downloadheader
Definition: dvips.h:139
struct resfont * next
Definition: dvips.h:136
Definition: dvips.h:235
halfword numpages
Definition: dvips.h:238
integer bos
Definition: dvips.h:236
struct t * next
Definition: dvips.h:237
Definition: dvips.h:148
quarterword * packptr
Definition: dvips.h:150
quarterword flags2
Definition: dvips.h:152
quarterword flags
Definition: dvips.h:152
shalfword pixelwidth
Definition: dvips.h:151
integer TFMwidth
Definition: dvips.h:149
Definition: dvips.h:174
integer scaledsize
Definition: dvips.h:175
quarterword psflag
Definition: dvips.h:180
halfword alreadyscaled
Definition: dvips.h:177
integer urx
Definition: dvips.h:183
chardesctype * chardesc
Definition: dvips.h:190
struct resfont * resfont
Definition: dvips.h:185
integer ury
Definition: dvips.h:183
halfword loaded
Definition: dvips.h:179
int iswide
Definition: dvips.h:191
int kind
Definition: dvips.h:191
char * area
Definition: dvips.h:184
char * scalename
Definition: dvips.h:189
integer designsize
Definition: dvips.h:175
integer thinspace
Definition: dvips.h:175
halfword loadeddpi
Definition: dvips.h:176
halfword psname
Definition: dvips.h:178
quarterword codewidth
Definition: dvips.h:181
integer lly
Definition: dvips.h:183
halfword dpi
Definition: dvips.h:176
integer checksum
Definition: dvips.h:175
integer dir
Definition: dvips.h:175
char * name
Definition: dvips.h:184
struct tfd * next
Definition: dvips.h:187
struct tft * localfonts
Definition: dvips.h:186
integer maxchars
Definition: dvips.h:182
struct tfd * nextsize
Definition: dvips.h:188
integer llx
Definition: dvips.h:183
Definition: dvips.h:200
fontdesctype * desc
Definition: dvips.h:202
struct tft * next
Definition: dvips.h:203
integer fontnum
Definition: dvips.h:201
#define FILE
Definition: t1stdio.h:34