home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d7xx / d795 / pstools.lha / PSTools / PSTools1.lha / source / structures.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-14  |  6.5 KB  |  207 lines

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