home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / PRINTING / DVIPS386.ZIP / STRUCTUR.H < prev    next >
C/C++ Source or Header  |  1990-11-25  |  7KB  |  204 lines

  1. /*
  2.  *   This is dvips, a freely redistributable PostScript driver
  3.  *   for dvi files.  It is (C) Copyright 1986-90 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 "This is dvips, version 5.4 (C) 1986-90 Radical Eye Software\n" 
  15. #include <stdio.h>
  16. #ifdef SYSV
  17. #include <string.h>
  18. #else
  19. #ifdef VMS
  20. #include <string.h>
  21. #else
  22. #include <strings.h>
  23. #endif
  24. #endif
  25. #if defined(lint) && defined(sun)
  26. extern char *sprintf() ;
  27. #endif
  28. #include "paths.h"
  29. #include "debug.h"
  30. #ifdef VMS
  31. #include "vms.h"
  32. #endif /* VMS */
  33. /*
  34.  *   Constants, used to increase or decrease the capacity of this program.
  35.  */
  36. #define STRINGSIZE (25000)  /* maximum number of strings in program */
  37. #define RASTERCHUNK (8192)  /* size of chunk of raster */
  38. #define MINCHUNK (256)      /* minimum size char to get own raster */
  39. #define STACKSIZE (100)     /* maximum stack size for dvi files */
  40. #define MAXFRAME (5)        /* maximum depth of virtual font recursion */
  41. #define MAXFONTHD (100)     /* number of unique names of included fonts */
  42. /*
  43.  *   Other constants, which define printer-dependent stuff.
  44.  */
  45. #define SWMEM (180000)      /* available virtual memory in PostScript printer */
  46. #define DPI (actualdpi)     /* dots per inch */
  47. #define VDPI (vactualdpi)   /* dots per inch */
  48. #define RES_TOLERANCE(dpi) ((int)(1+dpi/500))
  49.                             /* error in file name resolution versus desired */
  50. #define FONTCOST (298)      /* overhead cost of each sw font */
  51. #define PSFONTCOST (8300)   /* overhead cost for PostScript fonts */
  52. #define DNFONTCOST (35000)  /* overhead cost for downloaded PS font */
  53. #define CHARCOST (15)       /* overhead cost for each character */
  54. #define OVERCOST (40000)    /* cost of overhead */
  55. #define DICTITEMCOST (20)   /* cost per key, value in dictionary */
  56. #define NAMECOST (40)       /* overhead cost of each new name */
  57. /*
  58.  *   Type declarations.  integer must be a 32-bit signed; shalfword must
  59.  *   be a sixteen-bit signed; halfword must be a sixteen-bit unsigned;
  60.  *   quarterword must be an eight-bit unsigned.
  61.  */
  62. typedef long integer;
  63. typedef char boolean;
  64. typedef double real;
  65. typedef short shalfword ;
  66. typedef unsigned short halfword ;
  67. typedef unsigned char quarterword ;
  68. typedef short Boolean ;
  69. /*
  70.  *   If the machine has a default integer size of 16 bits, and 32-bit
  71.  *   integers must be manipulated with %ld, set the macro SHORTINT.
  72.  */
  73. #ifdef XENIX
  74. #define SHORTINT
  75. #else
  76. #undef SHORTINT
  77. #endif
  78. #ifdef MSDOS
  79. #define SHORTINT
  80. #endif
  81.  
  82. /*
  83.  *   This is the structure definition for resident fonts.  We use
  84.  *   a small and simple hash table to handle these.  We don't need
  85.  *   a big hash table.
  86.  */
  87. #define RESHASHPRIME (23)
  88. struct resfont {
  89.    char *Keyname, *PSname, *TeXname ;
  90.    char *specialinstructions ;
  91.    char *downloadheader ;
  92.    struct resfont *next ;
  93.    quarterword sent ;
  94. } ;
  95.  
  96. /*
  97.  *   A chardesc describes an individual character.  Before the fonts are
  98.  *   downloaded, the flags indicate that the character has already been used
  99.  *   with the following meanings:
  100.  */
  101. typedef struct {
  102.    integer TFMwidth ;
  103.    shalfword pixelwidth ;
  104.    quarterword *packptr ;
  105.    quarterword flags ;
  106. } chardesctype ;
  107. #define EXISTS (1)
  108. #define PREVPAGE (2)
  109. #define THISPAGE (4)
  110. #define TOOBIG (8) /* not used at the moment */
  111. #define REPACKED (16)
  112. #define BIGCHAR (32)
  113. #define STATUSFLAGS (EXISTS|REPACKED|BIGCHAR)
  114. /*
  115.  *   A fontdesc describes a font.  The name, area, and scalename are located in
  116.  *   the string pool. The nextsize pointer is used to link fonts that are used
  117.  *   in included psfiles and differ only in scaledsize.  Such fonts also have
  118.  *   a non-NULL scalename that gives the scaledsize as found in the included
  119.  *   file.  The psflag indicates that the font has been used in an included
  120.  *   psfile.  It can be 0, PREVPAGE, THISPAGE, or EXISTS.
  121.  */
  122. typedef struct tfd {
  123.    integer checksum, scaledsize, designsize, thinspace ;
  124.    halfword dpi, loadeddpi ;
  125.    halfword alreadyscaled ;
  126.    halfword psname ;
  127.    halfword loaded ;
  128.    halfword maxchars ;
  129.    char *name, *area ;
  130.    struct resfont *resfont ;
  131.    struct tft *localfonts ;
  132.    struct tfd *next ;
  133.    struct tfd *nextsize;
  134.    char *scalename;
  135.    quarterword psflag;
  136.    chardesctype chardesc[256] ;
  137. } fontdesctype ;
  138.  
  139. /*  A fontmap associates a fontdesc with a font number.
  140.  */
  141. typedef struct tft {
  142.    integer fontnum ;
  143.    fontdesctype *desc ;
  144.    struct tft *next ;
  145. } fontmaptype ;
  146.  
  147. /*   Virtual fonts require a `macro' capability that is implemented by
  148.  *   using a stack of `frames'. 
  149.  */
  150. typedef struct {
  151.    quarterword *curp, *curl ;
  152.    fontdesctype *curf ;
  153.    fontmaptype *ff ;
  154. } frametype ;
  155.  
  156. /*
  157.  *   The next type holds the font usage information in a 256-bit table;
  158.  *   there's a 1 for each character that was used in a section.
  159.  */
  160. typedef struct {
  161.    fontdesctype *fd ;
  162.    halfword psfused ;
  163.    halfword bitmap[16] ;
  164. } charusetype ;
  165.  
  166. /*   Next we want to record the relevant data for a section.  A section is
  167.  *   a largest portion of the document whose font usage does not overflow
  168.  *   the capacity of the printer.  (If a single page does overflow the
  169.  *   capacity all by itself, it is made into its own section and a warning
  170.  *   message is printed; the page is still printed.)
  171.  *
  172.  *   The sections are in a linked list, built during the prescan phase and
  173.  *   processed in proper order (so that pages stack correctly on output) during
  174.  *   the second phase.
  175.  */
  176. typedef struct t {
  177.    integer bos ;
  178.    struct t *next ;
  179.    halfword numpages ;
  180. } sectiontype ;
  181.  
  182. /*
  183.  *   Sections are actually represented not by sectiontype but by a more
  184.  *   complex data structure of variable size, having the following layout:
  185.  *      sectiontype sect ;
  186.  *      charusetype charuse[numfonts] ;
  187.  *      fontdesctype *sentinel = NULL ;
  188.  *   (Here numfonts is the number of bitmap fonts currently defined.)
  189.  *    Since we can't declare this or take a sizeof it, we build it and
  190.  *   manipulate it ourselves (see the end of the prescan routine).
  191.  */
  192. /*
  193.  *   This is how we build up headers and other lists.
  194.  */
  195. struct header_list {
  196.    char *name ;
  197.    struct header_list *next ;
  198. } ;
  199. /*
  200.  *   Some machines define putlong in their library.
  201.  *   We get around this here.
  202.  */
  203. #define putlong was_putlong
  204.