home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fonts 1 / freshfonts1.bin / bbs / programs / amiga / pastex13.lha / DVIPS / dvips5519.lha / dvips / dvips.c < prev    next >
C/C++ Source or Header  |  1993-09-04  |  35KB  |  1,081 lines

  1. /*
  2.  *   This is the main routine.
  3.  */
  4. #ifndef DEFRES
  5. #define DEFRES (300)
  6. #endif
  7.  
  8. #include "dvips.h" /* The copyright notice there is included too! */
  9. #ifndef SYSV
  10. extern char *strtok() ; /* some systems don't have this in strings.h */
  11. #endif
  12. #ifdef VMS
  13. #define GLOBAL globaldef
  14. #ifdef __GNUC__
  15. #include "climsgdef.h"    /* created by hand, extracted from STARLET.MLB */
  16.             /* and put in GNU_CC:[INCLUDE.LOCAL]           */
  17. #include "ctype.h"
  18. #include "descrip.h"
  19. #else
  20. #include climsgdef
  21. #include ctype
  22. #include descrip
  23. #endif
  24. #endif
  25. /*
  26.  *   First we define some globals.
  27.  */
  28. #ifdef VMS
  29.     static char ofnme[252],infnme[252],pap[40],thh[20];
  30. #endif
  31. fontdesctype *fonthead ;      /* list of all fonts mentioned so far */
  32. fontdesctype *curfnt ;        /* the currently selected font */
  33. sectiontype *sections ;       /* sections to process document in */
  34. Boolean manualfeed ;          /* manual feed? */
  35. Boolean compressed ;          /* compressed? */
  36. Boolean safetyenclose ;
  37.                           /* enclose in save/restore for stupid spoolers? */
  38. Boolean removecomments = 1 ;  /* remove comments from included PS? */
  39. Boolean nosmallchars ;        /* disable small char optimization for X4045? */
  40. Boolean cropmarks ;           /* add cropmarks? */
  41. Boolean abspage = 0 ;         /* are page numbers absolute? */
  42. Boolean tryepsf = 0 ;         /* should we try to make it espf? */
  43. Boolean secure = 0 ;          /* make safe for suid */
  44. int collatedcopies = 1 ;      /* how many collated copies? */
  45. int sectioncopies = 1 ;       /* how many times to repeat each section? */
  46. integer pagecopies = 1 ;          /* how many times to repeat each page? */
  47. shalfword linepos = 0 ;       /* where are we on the line being output? */
  48. integer maxpages ;            /* the maximum number of pages */
  49. Boolean notfirst, notlast ;   /* true if a first page was specified */
  50. Boolean evenpages, oddpages ; /* true if doing only even/only odd pages */
  51. Boolean pagelist ;            /* true if using page ranges */
  52. Boolean sendcontrolD ;        /* should we send a control D at end? */
  53. integer firstpage ;           /* the number of the first page if specified */
  54. integer lastpage ;
  55. integer firstseq ;
  56. integer lastseq ;
  57. integer hpapersize, vpapersize ; /* horizontal and vertical paper size */
  58. integer hoff, voff ;          /* horizontal and vertical offsets */
  59. integer maxsecsize ;          /* the maximum size of a section */
  60. integer firstboploc ;         /* where the first bop is */
  61. Boolean sepfiles ;            /* each section in its own file? */
  62. int numcopies ;               /* number of copies of each page to print */
  63. char *oname ;                 /* output file name */
  64. char *iname ;                 /* dvi file name */
  65. char *fulliname ;             /* same, with current working directory */
  66. char *strings ;               /* strings for program */
  67. char *nextstring, *maxstring ; /* string pointers */
  68. FILE *dvifile, *bitfile ;     /* dvi and output files */
  69. quarterword *curpos ;        /* current position in virtual character packet */
  70. quarterword *curlim ;         /* final byte in virtual character packet */
  71. fontmaptype *ffont ;          /* first font in current frame */
  72. real conv ;                   /* conversion ratio, pixels per DVI unit */
  73. real vconv ;                  /* conversion ratio, pixels per DVI unit */
  74. real alpha ;                  /* conversion ratio, DVI unit per TFM unit */
  75. integer mag ;                 /* the magnification of this document */
  76. integer num, den ;            /* the numerator and denominator */
  77. int overridemag ;             /* substitute for mag value in DVI file? */
  78. int actualdpi = DEFRES ;      /* the actual resolution of the printer */
  79. int vactualdpi = DEFRES ;     /* the actual resolution of the printer */
  80. int maxdrift ;                /* max pixels away from true rounded position */
  81. int vmaxdrift ;               /* max pixels away from true rounded position */
  82. char *paperfmt ;              /* command-line paper format */
  83. int landscape = 0 ;           /* landscape mode */
  84. integer fontmem ;             /* memory remaining in printer */
  85. integer pagecount ;           /* page counter for the sections */
  86. integer pagenum ;             /* the page number we currently look at */
  87. long bytesleft ;              /* number of bytes left in raster */
  88. quarterword *raster ;         /* area for raster manipulations */
  89. integer hh, vv ;              /* horizontal and vertical pixel positions */
  90.  
  91. /*-----------------------------------------------------------------------*
  92.  * The PATH definitions cannot be defined on the command line because so many
  93.  * DEFINE's overflow the DCL buffer when using the GNU CC compiler.
  94.  *-----------------------------------------------------------------------*/
  95. #if defined(VMS) && defined(__GNUC__)
  96. #include "vms_gcc_paths.h"
  97. #endif
  98.  
  99. char *tfmpath = TFMPATH ;     /* pointer to directories for tfm files */
  100. char *pkpath = PKPATH ;       /* pointer to directories for pk files */
  101. char *vfpath = VFPATH ;       /* pointer to directories for vf files */
  102. char *figpath = FIGPATH ;     /* pointer to directories for figure files */
  103. char *headerpath = HEADERPATH ; /* pointer to directories for header files */
  104. char *configpath = CONFIGPATH ; /* where to find config files */
  105. char *infont ;                /* is the file we are downloading a font? */
  106. #ifndef PICTPATH
  107. #ifndef __THINK__
  108. #define PICTPATH "."
  109. #else
  110. #define PICTPATH ":"
  111. #endif
  112. #endif
  113. char *pictpath = PICTPATH ;   /* where IFF/etc. pictures are found */
  114. #ifdef SEARCH_SUBDIRECTORIES
  115. char *fontsubdirpath = FONTSUBDIRPATH ;
  116. #endif
  117. #ifdef FONTLIB
  118. char *flipath = FLIPATH ;     /* pointer to directories for fli files */
  119. char *fliname = FLINAME ;     /* pointer to names of fli files */
  120. #endif
  121. integer swmem ;               /* font memory in the PostScript printer */
  122. int quiet ;                   /* should we only print errors to stderr? */
  123. int filter ;                  /* act as filter default output to stdout,
  124.                                                default input to stdin? */
  125. int prettycolumn ;            /* the column we are at when running pretty */
  126. int gargc ;                   /* global argument count */
  127. char **gargv ;                /* global argument vector */
  128. int totalpages = 0 ;          /* total number of pages */
  129. Boolean reverse ;             /* are we going reverse? */
  130. Boolean usesPSfonts ;         /* do we use local PostScript fonts? */
  131. Boolean usesspecial ;         /* do we use \special? */
  132. Boolean headers_off ;         /* do we send headers or not? */
  133. Boolean usescolor ;           /* IBM: color - do we use colors? */
  134. char *headerfile ;            /* default header file */
  135. char *warningmsg ;            /* a message to write, if set in config file */
  136. Boolean multiplesects ;       /* more than one section? */
  137. Boolean disablecomments ;     /* should we suppress any EPSF comments? */
  138. char *printer ;               /* what printer to send this to? */
  139. char *mfmode ;                /* default MF mode */
  140. frametype frames[MAXFRAME] ;  /* stack for virtual fonts */
  141. fontdesctype *baseFonts[256] ; /* base fonts for dvi file */
  142. integer pagecost;               /* memory used on the page being prescanned */
  143. int delchar;                    /* characters to delete from prescanned page */
  144. integer fsizetol;               /* max dvi units error for psfile font sizes */
  145. Boolean includesfonts;          /* are fonts used in included psfiles? */
  146. fontdesctype *fonthd[MAXFONTHD];/* list headers for included fonts of 1 name */
  147. int nextfonthd;                 /* next unused fonthd[] index */
  148. char xdig[256];                 /* table for reading hexadecimal digits */
  149. char banner[] = BANNER ;        /* our startup message */
  150. Boolean noenv = 0 ;             /* ignore PRINTER envir variable? */
  151. Boolean dopprescan = 0 ;        /* do we do a scan before the prescan? */
  152. integer lastheadermem ;         /* how much mem did the last header require? */
  153. extern int dontmakefont ;
  154. struct papsiz *papsizes ;       /* all available paper size */
  155. int headersready ;              /* ready to check headers? */
  156. #if defined MSDOS || defined OS2
  157. char *mfjobname = NULL;         /* name of mfjob file if given */
  158. FILE *mfjobfile = NULL;         /* mfjob f