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