home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / unixtex-6.1b-src.tgz / tar.out / contrib / unixtex / dvipsk / dvips.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  8KB  |  252 lines

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