home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / dvips549.zip / DVIPS / STRUCTUR.H < prev    next >
C/C++ Source or Header  |  1992-10-14  |  8KB  |  265 lines

  1. /*
  2.  *   This is dvips, a freely redistributable PostScript driver
  3.  *   for dvi files.  It is (C) Copyright 1986-92 by Tomas Rokicki.
  4.  *   You may modify and use this program to your heart's content,
  5.  *   so long as you send modifications to Tomas Rokicki.  It can
  6.  *   be included in any distribution, commercial or otherwise, so
  7.  *   long as the banner string defined below is not modified (except
  8.  *   for the version number) and this banner is printed on program
  9.  *   invocation, or can be printed on program invocation with the -? option.
  10.  */
  11.  
  12. /*   This file is the header for dvips's global data structures. */
  13.  
  14. #define BANNER \
  15.              "This is dvips 5.495 Copyright 1986, 1992 Radical Eye Software\n"
  16. #include <stdio.h>
  17. #ifdef SYSV
  18. #include <string.h>
  19. #else
  20. #ifdef VMS
  21. #include <string.h>
  22. #else
  23. #ifdef __THINK__
  24. #include <string.h>
  25. #else
  26. #include <strings.h>
  27. #endif
  28. #endif
  29. #endif
  30. #if defined(lint) && defined(sun)
  31. extern char *sprintf() ;
  32. #endif
  33. #include "paths.h"
  34. #include "debug.h"
  35. #ifdef VMS
  36. #include "[]vms.h"
  37. #endif /* VMS */
  38. /*
  39.  *   We use malloc and free; these may need to be customized for your
  40.  *   site.
  41.  */
  42. #ifdef MSDOS
  43. void *malloc() ;
  44. #else
  45. #ifndef IBM6000
  46. char *malloc() ;
  47. #endif
  48. #endif
  49. void free() ;
  50. char *mymalloc() ;
  51. /*
  52.  *   Is your malloc big?
  53.  */
  54. #ifdef MSDOS
  55. #ifndef DJGPP
  56. #define SMALLMALLOC
  57. #endif
  58. #endif
  59. /*
  60.  *   Constants, used to increase or decrease the capacity of this program.
  61.  */
  62. #define STRINGSIZE (25000)  /* maximum number of strings in program */
  63. #define RASTERCHUNK (8192)  /* size of chunk of raster */
  64. #define MINCHUNK (240)      /* minimum size char to get own raster */
  65. #define STACKSIZE (100)     /* maximum stack size for dvi files */
  66. #define MAXFRAME (10)       /* maximum depth of virtual font recursion */
  67. #define MAXFONTHD (100)     /* number of unique names of included fonts */
  68. #define STDOUTSIZE (75)     /* width of a standard output line */
  69. /*
  70.  *   Other constants, which define printer-dependent stuff.
  71.  */
  72. #define SWMEM (180000)      /* available virtual memory in PostScript printer */
  73. #define DPI (actualdpi)     /* dots per inch */
  74. #define VDPI (vactualdpi)   /* dots per inch */
  75. #define RES_TOLERANCE(dpi) ((int)(1+dpi/500))
  76.                             /* error in file name resolution versus desired */
  77. #define FONTCOST (298)      /* overhead cost of each sw font */
  78. #define PSFONTCOST (1100)   /* overhead cost for PostScript fonts */
  79. #define PSCHARCOST (20)     /* overhead cost for PostScript font chars */
  80. #define DNFONTCOST (35000)  /* overhead cost for downloaded PS font */
  81. #define CHARCOST (15)       /* overhead cost for each character */
  82. #define OVERCOST (30000)    /* cost of overhead */
  83. #define DICTITEMCOST (20)   /* cost per key, value in dictionary */
  84. #define NAMECOST (40)       /* overhead cost of each new name */
  85. /*
  86.  *   Type declarations.  integer must be a 32-bit signed; shalfword must
  87.  *   be a sixteen-bit signed; halfword must be a sixteen-bit unsigned;
  88.  *   quarterword must be an eight-bit unsigned.
  89.  */
  90. #ifdef MSDOS
  91. typedef long integer;
  92. #else
  93. typedef int integer;
  94. #endif
  95. typedef char boolean;
  96. typedef double real;
  97. typedef short shalfword ;
  98. typedef unsigned short halfword ;
  99. typedef unsigned char quarterword ;
  100. #ifndef __THINK__
  101. typedef short Boolean ;
  102. #endif
  103. /*
  104.  *   If the machine has a default integer size of 16 bits, and 32-bit
  105.  *   integers must be manipulated with %ld, set the macro SHORTINT.
  106.  */
  107. #ifdef XENIX
  108. #define SHORTINT
  109. #else
  110. #undef SHORTINT
  111. #endif
  112. #ifdef MSDOS
  113. #ifndef DJGPP
  114. #define SHORTINT
  115. #endif
  116. #endif
  117.  
  118. /*
  119.  *   This is the structure definition for resident fonts.  We use
  120.  *   a small and simple hash table to handle these.  We don't need
  121.  *   a big hash table.
  122.  */
  123. #define RESHASHPRIME (73)
  124. struct resfont {
  125.    struct resfont *next ;
  126.    char *Keyname, *PSname, *TeXname ;
  127.    char *specialinstructions ;
  128.    char *downloadheader ; /* possibly multiple files */
  129.    quarterword sent ;
  130. } ;
  131.  
  132. /*
  133.  *   A chardesc describes an individual character.  Before the fonts are
  134.  *   downloaded, the flags indicate that the character has already been used
  135.  *   with the following meanings:
  136.  */
  137. typedef struct {
  138.    integer TFMwidth ;
  139.    quarterword *packptr ;
  140.    shalfword pixelwidth ;
  141.    quarterword flags, dmy ;
  142. } chardesctype ;
  143. #define EXISTS (1)
  144. #define PREVPAGE (2)
  145. #define THISPAGE (4)
  146. #define TOOBIG (8) /* not used at the moment */
  147. #define REPACKED (16)
  148. #define BIGCHAR (32)
  149. #define STATUSFLAGS (EXISTS|REPACKED|BIGCHAR)
  150. /*
  151.  *   A fontdesc describes a font.  The name, area, and scalename are located in
  152.  *   the string pool. The nextsize pointer is used to link fonts that are used
  153.  *   in included psfiles and differ only in scaledsize.  Such fonts also have
  154.  *   a non-NULL scalename that gives the scaledsize as found in the included
  155.  *   file.  The psflag indicates that the font has been used in an included
  156.  *   psfile.  It can be 0, PREVPAGE, THISPAGE, or EXISTS.
  157.  */
  158. typedef struct tfd {
  159.    integer checksum, scaledsize, designsize, thinspace ;
  160.    halfword dpi, loadeddpi ;
  161.    halfword alreadyscaled ;
  162.    halfword psname ;
  163.    halfword loaded ;
  164.    halfword maxchars ;
  165.    char *name, *area ;
  166.    struct resfont *resfont ;
  167.    struct tft *localfonts ;
  168.    struct tfd *next ;
  169.    struct tfd *nextsize;
  170.    char *scalename;
  171.    quarterword psflag;
  172.    chardesctype chardesc[256] ;
  173. } fontdesctype ;
  174.  
  175. /*  A fontmap associates a fontdesc with a font number.
  176.  */
  177. typedef struct tft {
  178.    integer fontnum ;
  179.    fontdesctype *desc ;
  180.    struct tft *next ;
  181. } fontmaptype ;
  182.  
  183. /*   Virtual fonts require a `macro' capability that is implemented by
  184.  *   using a stack of `frames'. 
  185.  */
  186. typedef struct {
  187.    quarterword *curp, *curl ;
  188.    fontdesctype *curf ;
  189.    fontmaptype *ff ;
  190. } frametype ;
  191.  
  192. /*
  193.  *   The next type holds the font usage information in a 256-bit table;
  194.  *   there's a 1 for each character that was used in a section.
  195.  */
  196. typedef struct {
  197.    fontdesctype *fd ;
  198.    halfword psfused ;
  199.    halfword bitmap[16] ;
  200. } charusetype ;
  201.  
  202. /*   Next we want to record the relevant data for a section.  A section is
  203.  *   a largest portion of the document whose font usage does not overflow
  204.  *   the capacity of the printer.  (If a single page does overflow the
  205.  *   capacity all by itself, it is made into its own section and a warning
  206.  *   message is printed; the page is still printed.)
  207.  *
  208.  *   The sections are in a linked list, built during the prescan phase and
  209.  *   processed in proper order (so that pages stack correctly on output) during
  210.  *   the second phase.
  211.  */
  212. typedef struct t {
  213.    integer bos ;
  214.    struct t *next ;
  215.    halfword numpages ;
  216. } sectiontype ;
  217.  
  218. /*
  219.  *   Sections are actually represented not by sectiontype but by a more
  220.  *   complex data structure of variable size, having the following layout:
  221.  *      sectiontype sect ;
  222.  *      charusetype charuse[numfonts] ;
  223.  *      fontdesctype *sentinel = NULL ;
  224.  *   (Here numfonts is the number of bitmap fonts currently defined.)
  225.  *    Since we can't declare this or take a sizeof it, we build it and
  226.  *   manipulate it ourselves (see the end of the prescan routine).
  227.  */
  228. /*
  229.  *   This is how we build up headers and other lists.
  230.  */
  231. struct header_list {
  232.    struct header_list *next ;
  233.    char name[1] ;
  234. } ;
  235. /*
  236.  *   Some machines define putlong in their library.
  237.  *   We get around this here.
  238.  */
  239. #define putlong was_putlong
  240. /*
  241.  *   Information on available paper sizes is stored here.
  242.  */
  243. struct papsiz {
  244.    struct papsiz *next ;
  245.    integer xsize, ysize ;
  246.    char *name ;
  247.    char *specdat ;
  248. } ;
  249. #ifdef VMCMS /* IBM: VM/CMS */
  250. /* adding ascii2ebcdic conversion table to extern */
  251. extern char ascii2ebcdic[] ;
  252. /* redefining fopen for VMCMS, see DVIPSCMS.C */
  253. extern FILE *cmsfopen() ;
  254. #ifdef fopen
  255. #undef fopen
  256. #endif
  257. #define fopen cmsfopen
  258. #endif  /* IBM: VM/CMS */
  259. /*
  260.  *   Remove namespace conflict with standard library on Macintosh
  261.  */
  262. #ifdef __THINK__
  263. #define newstring newpoolstring
  264. #endif
  265.