Back to index

tetex-bin  3.0
Defines | Functions | Variables
dvips.c File Reference
#include "dvips.h"
#include <stdlib.h>
#include "protos.h"

Go to the source code of this file.

Defines

#define DEFRES   (600)
#define DIR_SEP   DIRSEP
#define PICTPATH   "."
#define IGNORE_CWD

Functions

char * strtok ()
void help P1C (int, status)
void error_with_perror P2C (char *, s, char *, fname)
void error P1C (char *, s)
char *concat P2C (char *, s1, char *, s2)
void check_checksum P3C (unsigned, c1, unsigned, c2, const char *, name)
char *mymalloc P1C (integer, n)
void morestrings P1H (void)
VOID *revlist P1C (VOID *, p)
void handlepapersize ()
int main P2C (int, argc, char **, argv)

Variables

fontdesctypefonthead
fontdesctypecurfnt
sectiontypesections
Boolean partialdownload = 1
Boolean manualfeed
Boolean compressed
Boolean downloadpspk
Boolean safetyenclose
Boolean removecomments = 0
Boolean nosmallchars
Boolean cropmarks
Boolean abspage = 0
Boolean tryepsf = 0
Boolean secure = 0
int collatedcopies = 1
int sectioncopies = 1
integer pagecopies = 1
shalfword linepos = 0
integer maxpages
Boolean notfirst
Boolean notlast
Boolean evenpages
Boolean oddpages
Boolean pagelist
Boolean sendcontrolD
Boolean shiftlowchars
integer firstpage
integer lastpage
integer firstseq
integer lastseq
integer hpapersize
integer vpapersize
integer hoff
integer voff
integer maxsecsize = 0
integer firstboploc
Boolean sepfiles
int numcopies
char * oname
char * iname
char * fulliname
char * strings
char * nextstring
char * maxstring
FILEdvifile
FILEbitfile
quarterwordcurpos
quarterwordcurlim
fontmaptypeffont
real conv
real vconv
real alpha
double mag
integer num
integer den
int overridemag
int actualdpi = DEFRES
int vactualdpi = DEFRES
int maxdrift
int vmaxdrift
char * paperfmt
int landscape = 0
integer fontmem
integer pagecount
integer pagenum
long bytesleft
quarterwordraster
integer hh
integer vv
Boolean noomega = 0
char * infont
char * tfmpath = TFMPATH
char * pkpath = PKPATH
char * vfpath = VFPATH
char * figpath = FIGPATH
char * headerpath = HEADERPATH
char * configpath = CONFIGPATH
char * pictpath = PICTPATH
integer swmem
int quiet
int filter
int prettycolumn
int gargc
char ** gargv
int totalpages = 0
Boolean reverse
Boolean usesPSfonts
Boolean usesspecial
Boolean headers_off
Boolean usescolor
char * headerfile
char * warningmsg
Boolean multiplesects
Boolean disablecomments
char * printer
char * mfmode
char * mflandmode
int mfmode_option
int oname_option
frametype frames [MAXFRAME]
integer pagecost
int delchar
integer fsizetol
Boolean includesfonts
fontdesctypefonthd [MAXFONTHD]
int nextfonthd
char xdig [256]
char banner [] = BANNER
char banner2 [] = BANNER2
Boolean noenv = 0
Boolean dopprescan = 0
int dontmakefont
struct papsizpapsizes
int headersready
integer debug_flag = 0
char queryline [256]
int qargc
char * qargv [32]
char queryoptions
int lastresortsizes []
char errbuf []
static char * helparr []
static char * progname
static integer totalalloc = 0

Define Documentation

#define DEFRES   (600)

Definition at line 5 of file dvips.c.

#define DIR_SEP   DIRSEP

Definition at line 32 of file dvips.c.

#define IGNORE_CWD

Definition at line 220 of file dvips.c.

#define PICTPATH   "."

Definition at line 143 of file dvips.c.


Function Documentation

void help P1C ( int  ,
status   
)

Definition at line 293 of file dvips.c.

{
   char **p;
   FILE *f = status == 0 ? stdout : stderr;
#ifdef KPATHSEA
   extern KPSEDLL char *kpse_bug_address;
#endif   
   for (p=helparr; *p; p++)
      fprintf (f, "%s\n", *p);

   putc ('\n', f);
#ifdef KPATHSEA
   fputs (kpse_bug_address, f);
#endif
}

Here is the call graph for this function:

void error P1C ( char *  ,
s   
)

Definition at line 342 of file dvips.c.

{
   error_with_perror (s, NULL);
}
char* mymalloc P1C ( integer  ,
n   
)

Definition at line 387 of file dvips.c.

{
   char *p ;

#ifdef SMALLMALLOC
   if (n > 65500L)
      error("! can't allocate more than 64K!") ;
#endif
   if (n <= 0) /* catch strange 0 mallocs in flib.c without breaking code */
      n = 1 ;
#ifdef DEBUG
   totalalloc += n ;
   if (dd(D_MEM)) {
#ifdef SHORTINT
      fprintf(stderr, "Alloc %ld\n", n) ;
#else
      fprintf(stderr, "Alloc %d\n", n) ;
#endif
   }
#endif
   p = (char *) malloc(n) ;
   if (p == NULL)
      error("! no memory") ;
   return p ;
}

Here is the call graph for this function:

VOID* revlist P1C ( VOID ,
p   
)

Definition at line 509 of file dvips.c.

{
   struct list {
      struct list *next ;
   } *pp = (struct list *)p, *qq = 0, *tt ;

   while (pp) {
      tt = pp->next ;
      pp->next = qq ;
      qq = pp ;
      pp = tt ;
   }
   return (VOID *)qq ;
}
void morestrings P1H ( void  ) [read]

Definition at line 413 of file dvips.c.

                      {
   strings = mymalloc((integer)STRINGSIZE) ;
   nextstring = strings ;
   maxstring = strings + STRINGSIZE - 200 ;
   *nextstring++ = 0 ;
}
void error_with_perror P2C ( char *  ,
s  ,
char *  ,
fname   
)

Definition at line 316 of file dvips.c.

{
   if (prettycolumn > 0)
        fprintf(stderr,"\n");
   prettycolumn = 0;
   (void)fprintf(stderr, "%s: %s", progname, s) ;
   if (fname) {
     putc (' ', stderr);
     perror (fname);
   } else {
     putc ('\n', stderr);
   }
   
   if (*s=='!') {
      if (bitfile != NULL) {
         cleanprinter() ;
      }
      exit(1) ; /* fatal */
   }
}

Here is the call graph for this function:

char* concat P2C ( char *  ,
s1  ,
char *  ,
s2   
)

Definition at line 348 of file dvips.c.

{ 
  char *s = malloc(strlen(s1)+strlen(s2)+1);
  if (s == NULL) {
    fprintf(stderr, "Malloc failed to give %d bytes.\nAborting\n",
           strlen(s1)+strlen(s2)+1);
    exit(1);
  }
  strcpy(s, s1);
  strcat(s, s2);
}

Here is the call graph for this function:

int main P2C ( int  ,
argc  ,
char **  ,
argv   
)

Definition at line 547 of file dvips.c.

{
   int i, lastext = -1 ;
#ifdef MVSXA
   int firstext = -1 ;
#endif
   register sectiontype *sects ;

#ifdef KPATHSEA
   kpse_set_program_name (argv[0], "dvips");
   kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile);
#endif
   
#ifdef __THINK__
   argc = dcommand(&argv) ; /* do I/O stream redirection */
#endif
#ifdef VMS           /* Grab the command-line buffer */
   short len_arg;
   $DESCRIPTOR( verb_dsc, "DVIPS ");      /* assume the verb is always DVIPS */
   struct dsc$descriptor_d temp_dsc = { 0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0};

   progname = &thh[0] ;
   strcpy(progname,"DVIPS%ERROR");

   lib$get_foreign( &temp_dsc, 0, &len_arg, 0);  /* Get the command line */
   str$prefix(&temp_dsc, &verb_dsc);             /* prepend the VERB     */
   len_arg += verb_dsc.dsc$w_length;             /* update the length    */
   temp_dsc.dsc$a_pointer[len_arg] = '\0';       /* terminate the string */
   gargv = &temp_dsc.dsc$a_pointer;              /* point to the buffer  */
   gargc = 1 ;                                   /* only one big argv    */
#else
   progname = argv[0] ;
   gargv = argv ;
   gargc = argc ;
/* we sneak a look at the first arg in case it's debugging */
#ifdef DEBUG
   if (argc > 1 && strncmp(argv[1], "-d", 2)==0) {
      if (argv[1][2]==0 && argc > 2) {
         if (sscanf(argv[2], "%d", &debug_flag)==0)
            debug_flag = 0 ;
      } else {
         if (sscanf(argv[1]+2, "%d", &debug_flag)==0)
            debug_flag = 0 ;
      }
   }
#ifdef KPATHSEA
   if (dd(D_FILES)) KPSE_DEBUG_SET (KPSE_DEBUG_FOPEN);
   if (dd(D_PATHS)) KPSE_DEBUG_SET (KPSE_DEBUG_PATHS);
   if (dd(D_STAT)) KPSE_DEBUG_SET (KPSE_DEBUG_STAT);
   if (dd(D_HASH)) KPSE_DEBUG_SET (KPSE_DEBUG_HASH);
   if (dd(D_EXPAND)) KPSE_DEBUG_SET (KPSE_DEBUG_EXPAND);
   if (dd(D_SEARCH)) KPSE_DEBUG_SET (KPSE_DEBUG_SEARCH);
#endif /* KPATHSEA */
#endif /* DEBUG */
#ifdef KPATHSEA
   if (argc > 1) {
      if (strcmp (argv[1], "--help") == 0) {
        help (0);
        exit (0);
      } else if (strcmp (argv[1], "--version") == 0) {
        extern KPSEDLL char *kpathsea_version_string;
        puts ("dvips(k) 5.95a");
        puts (kpathsea_version_string);
        puts ("Copyright (C) 2005 Radical Eye Software.\n\
There is NO warranty.  You may redistribute this software\n\
under the terms of the GNU General Public License\n\
and the Dvips copyright.\n\
For more information about these matters, see the files\n\
named COPYING and dvips.h.\n\
Primary author of Dvips: T. Rokicki; -k maintainer: T. Kacvinsky/ S. Rahtz.");
        exit (0);
      }
      if (argc == 2 && strncmp(argv[1], "-?", 2) == 0) {
         printf("%s %s\n", banner, banner2) ;
         help(0);
         exit(0);
      }
      if (argc == 2 && strncmp(argv[1], "-v", 2) == 0) {
         printf("%s %s\n", banner, banner2) ;
         exit(0);
      }
   }
#endif
#endif
   initialize() ;
   checkenv(0) ;
   getdefaults(CONFIGFILE) ;
   getdefaults((char *)0) ;
/*
 *   This next whole big section of code is straightforward; we just scan
 *   the options.  An argument can either immediately follow its option letter
 *   or be separated by spaces.  Any argument not preceded by '-' and an
 *   option letter is considered a file name; the program complains if more
 *   than one file name is given, and uses stdin if none is given.
 */
#ifdef VMS
   vmscli P1H(void);
   papsizes = (struct papsiz *)revlist((void *)papsizes) ; /* Added by PWD 21-Mar-1997 */
#else
   queryoptions = 0;
   do
   {
      for (i=1; i<argc; i++) {
         if (*argv[i]=='-') {
            char *p=argv[i]+2 ;
            char c=argv[i][1] ;
            switch (c) {
case '-':
               queryoptions = 1;
               break;
case 'a':
               dopprescan = (*p != '0') ;
               break ;
case 'b':
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (sscanf(p, "%d", &pagecopies)==0)
                  error("! Bad number of page copies option (-b).") ;
               if (pagecopies < 1 || pagecopies > 1000)
                  error("! can only print one to a thousand page copies") ;
               break ;
case 'c' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (sscanf(p, "%d", &numcopies)==0)
                  error("! Bad number of copies option (-c).") ;
               break ;
case 'd' :
#ifdef DEBUG
               {
                  int old_debug = debug_flag ;
                  static int warned_already = 0 ;

                  if (*p == 0 && argv[i+1])
                     p = argv[++i];
                  if (sscanf(p, "%d", &debug_flag)==0)
                     error("! Bad debug option (-d).");
                  if (debug_flag != old_debug && warned_already++ == 0) {
                     fprintf(stderr,
  "I found a debug option that was not the first argument to the dvips\n") ;
                     fprintf(stderr,
  "command.  Some debugging output may have been lost because of this.\n") ;
                  }
                  break;
               }
#else
               error("not compiled in debug mode") ;
               break ;
#endif /* DEBUG */
case 'e' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (sscanf(p, "%d", &maxdrift)==0 || maxdrift<0)
                  error("! Bad maxdrift option (-e).") ;
               vmaxdrift = maxdrift;
               break ;
case 'f' :
               filter = (*p != '0') ;
               if (filter)
                  oname = "" ;
               noenv = 1 ;
               sendcontrolD = 0 ;
               break ;
case 'u' :
               {
                  extern char *psmapfile;
                  char PSname[300] ;               
                  if (*p == 0 && argv[i+1])
                     p = argv[++i] ;
                  strcpy(PSname, p) ;
                  if (!strchr(PSname, '.'))        
                     strcat(PSname, ".map") ;     /* default extension */
                  if (PSname[0] == '+')
                     getpsinfo(PSname+1) ;
                  else 
                     psmapfile = strdup(PSname) ; /* a cute small memory leak (just as in 'p' option handling in resident.c) */
               }
               break ;
case 'h' : case 'H' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (strcmp(p, "-") == 0)
                  headers_off = 1 ;
               else
                  (void)add_header(p) ;
               break ;
case 'i':
               sepfiles = (*p != '0') ;
               if (sepfiles && maxsecsize == 0) {
                 maxsecsize = 1; /* default section size to one page/file */
               }
               break ;
case 'j':
               partialdownload = (*p != '0') ;
               break ;
case 'k':
               cropmarks = (*p != '0') ;
               break ;
case 'R':
               secure = (*p != '0') ;
               break ;
case 'S':
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (sscanf(p, "%d", &maxsecsize)==0)
                  error("! Bad section size arg (-S).") ;
               break ;
case 'm' :
               if (STREQ (p, "ode") && argv[i+1]) {
                 mfmode = argv[++i];
                 mfmode_option = 1;
               } else
                 manualfeed = (*p != '0') ;
               break ;
case 'n' :
               if (STREQ (p, "oomega")) {
                 noomega = 1 ;
               } else {
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
#ifdef SHORTINT
               if (sscanf(p, "%ld", &maxpages)==0)
#else        /* ~SHORTINT */
               if (sscanf(p, "%d", &maxpages)==0)
#endif        /* ~SHORTINT */
                  error("! Bad number of pages option (-n).") ;
               }
               break ;
case 'o' :
               if (*p == 0 && argv[i+1] && 
                   (STREQ (argv[i+1], "-") || argv[i+1][0] != '-'))
                  p = argv[++i] ;
               oname_option = 1;
               oname = p ;
               noenv = 1 ;
               sendcontrolD = 0 ;
#if defined(MSDOS) || defined(OS2)
                if (*oname && oname[strlen(oname)-1] == ':')
                    oname[strlen(oname)-1] = 0;     /* strip ':' off */
#endif
               break ;
case 'O' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               handlepapersize(p, &hoff, &voff) ;
               break ;
case 'T' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               handlepapersize(p, &hpapersize, &vpapersize) ;
               if (landscape) {
                  error(
              "both landscape and papersize specified; ignoring landscape") ;
                  landscape = 0 ;
               }
               break ;
case 'p' :
#if defined(MSDOS) || defined(OS2) || defined(ATARIST)
               /* check for emTeX job file (-pj=filename) */
               if (*p == 'j') {
                 p++;
                 if (*p == '=' || *p == ':')
                   p++;
                 mfjobname = newstring(p);
                 break;
               }
               /* must be page number instead */
#endif
               if (*p == 'p') {  /* a -pp specifier for a page list? */
                  p++ ;
                  if (*p == 0 && argv[i+1])
                     p = argv[++i] ;
                  if (ParsePages(p))
                     error("! Bad page list specifier (-pp).") ;
                  pagelist = 1 ;
                  break ;
               }
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (*p == '=') {
                  abspage = 1 ;
                  p++ ;
               }
#ifdef SHORTINT
               switch(sscanf(p, "%ld.%ld", &firstpage, &firstseq)) {
#else        /* ~SHORTINT */
               switch(sscanf(p, "%d.%d", &firstpage, &firstseq)) {
#endif        /* ~SHORTINT */
case 1:           firstseq = 0 ;
case 2:           break ;
default:
#ifdef KPATHSEA
                  error(concat3 ("! Bad first page option (-p ", p, ").")) ;
#else
                  error("! Bad first page option (-p).") ;
#endif
               }
               notfirst = 1 ;
               break ;
case 'l':
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (*p == '=') {
                  abspage = 1 ;
                  p++ ;
               }
#ifdef SHORTINT
               switch(sscanf(p, "%ld.%ld", &lastpage, &lastseq)) {
#else        /* ~SHORTINT */
               switch(sscanf(p, "%d.%d", &lastpage, &lastseq)) {
#endif        /* ~SHORTINT */
case 1:           lastseq = 0 ;
case 2:           break ;
default:
#ifdef KPATHSEA
                  error(concat3 ("! Bad last page option (-l ", p, ").")) ;
#else
                  error("! Bad last page option (-l).") ;
#endif
               }
               notlast = 1 ;
               break ;
case 'A':
               oddpages = 1 ;
               break ;
case 'B':
               evenpages = 1 ;
               break ;
case 'q' : case 'Q' :
               quiet = (*p != '0') ;
               break ;
case 'r' :
               reverse = (*p != '0') ;
               break ;
case 't' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (strcmp(p, "landscape") == 0) {
                  if (hpapersize || vpapersize)
                     error(
             "both landscape and papersize specified; ignoring landscape") ;
                  else
                     landscape = 1 ;
               } else
                  paperfmt = p ;
               break ;
case 'v':
                printf ("%s %s\n", banner, banner2);
                exit (0);
                break;
case 'x' : case 'y' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (sscanf(p, "%lg", &mag)==0 || mag < 1 ||
                          mag > 1000000)
                  error("! Bad magnification parameter (-x or -y).") ;
               overridemag = (c == 'x' ? 1 : -1) ;
               break ;
case 'C' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (sscanf(p, "%d", &collatedcopies)==0)
                  error("! Bad number of collated copies option (-C).") ;
               break ;
case 'D' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (sscanf(p, "%d", &actualdpi)==0 || actualdpi < 10 ||
                          actualdpi > 10000)
                  error("! Bad dpi parameter (-D).") ;
               vactualdpi = actualdpi;
               /* If we had the mode from config.ps, don't use it.
                  If they specified one with -mode, keep it.  */
               if (!mfmode_option)
                 mfmode = NULL;
               break ;
case 'E' :
               tryepsf = (*p != '0') ;
               removecomments = disablecomments = 0;
               if (tryepsf && maxsecsize == 0)
                  maxsecsize = 1 ;
               break ;
case 'K' :
               removecomments = (*p != '0') ;
               break ;
case 'U' :
               nosmallchars = (*p != '0') ;
               break ;
case 'X' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (sscanf(p, "%d", &actualdpi)==0 || actualdpi < 10 ||
                          actualdpi > 10000)
                  error("! Bad dpi parameter (-D).") ;
               break ;
case 'Y' :
               if (*p == 0 && argv[i+1])
                  p = argv[++i] ;
               if (sscanf(p, "%d", &vactualdpi)==0 || vactualdpi < 10 ||
                          vactualdpi > 10000)
                  error("! Bad dpi parameter (-D).") ;
               vactualdpi = vactualdpi;
               break ;
case 'F' :
               sendcontrolD = (*p != '0') ;
               break ;
case 'G' :
               shiftlowchars = (*p != '0');
              break;
case 'M':
               dontmakefont = (*p != '0') ;
#ifdef KPATHSEA
               kpse_set_program_enabled (kpse_pk_format, !dontmakefont,
                                         kpse_src_cmdline);
#endif
               break ;
case 'N' :
               disablecomments = (*p != '0') ;
               break ;
case 'P' :
               {
                  struct papsiz *opapsiz = papsizes ;
                  struct papsiz *npapsiz ;
                  papsizes = 0 ;
                  if (*p == 0 && argv[i+1])
                     p = argv[++i] ;
                  printer = p ;
                  noenv = 1 ;
                  if (!getdefaults("")) {
                    /* If no config file, default the output name.  */
                    oname = concat ("| lpr -P", printer);
                  }
                  npapsiz = opapsiz ;
                  while (npapsiz && npapsiz->next)
                     npapsiz = npapsiz->next ;
                  if (npapsiz) {
                     npapsiz->next = papsizes ;
                     papsizes = opapsiz ;
                  }
              }
               break ;
case 's':
               safetyenclose = (*p != '0') ;
               break ;
case 'V':
               downloadpspk = (*p != '0') ;
               break ;
case 'Z':
               compressed = (*p != '0') ;
               break ;
#ifdef HPS
case 'z':
               HPS_FLAG = (*p != '0') ;
               break ;
#endif
case '?':
               break ; /* We print the banner and help msg below.  */
default:
#ifdef KPATHSEA
               error(concat3 ("! Invalid option `", argv[i],
                              "'. Try --help for more information."));
#else
               error(
     "! Bad option, not one of acdefhijklmnopqrstxyzABCDEFKMNOPSTUXYZ?") ;
#endif
            }
         } else {
            if (*iname == 0) {
               register char *p ;
   
               lastext = 0 ;
               iname = nextstring ;
               p = argv[i] ;
              if (NAME_BEGINS_WITH_DEVICE(p)) { /* get past DOSISH drive */
                *nextstring++ = *p++ ;
                *nextstring++ = *p++ ;
              }
               while (*p) {
                  *nextstring = *p++ ;
                  if (*nextstring == '.')
                     lastext = nextstring - iname ;
                  else if (IS_DIR_SEP(*nextstring))
                     lastext = 0 ;
                  nextstring++ ;
               }
               *nextstring++ = '.' ;
               *nextstring++ = 'd' ;
               *nextstring++ = 'v' ;
               *nextstring++ = 'i' ;
               *nextstring++ = 0 ;
            } else
#ifdef KPATHSEA
               error(concat3("! Second input filename (", argv[i],
                             ") specified.")) ;
#else
               error("! Two input file names specified.") ;
#endif
         }
      }
      if (noenv == 0) {
         register char *p ;
         struct papsiz *opapsiz = papsizes ;
         papsizes = 0 ;
        if (0 != (p = getenv("PRINTER"))) {
#if defined(MSDOS) || defined(OS2)
            strcpy(nextstring, p) ;
            strcat(nextstring, ".cfg") ;
#else
            strcpy(nextstring, "config.") ;
            strcat(nextstring, p) ;
#endif
            getdefaults(nextstring) ;
         }
         {
            struct papsiz *npapsiz = opapsiz ;
            while (npapsiz && npapsiz->next)
               npapsiz = npapsiz->next ;
            if (npapsiz) {
               npapsiz->next = papsizes ;
               papsizes = opapsiz ;
            }
         }
      }
      papsizes = (struct papsiz *)revlist((void *)papsizes) ;
      if (queryoptions != 0) {            /* get new options */
         (void)fprintf(stderr, "%s %s\n", banner, banner2) ;
         help(1) ;
         queryargs();
         if (qargc == 1)
           queryoptions = 0;
         else {
           qargv[0] = argv[0];
           argc=qargc;
           argv=qargv;
         }
      }
   } while (queryoptions != 0) ;
#endif
#if (defined(KPATHSEA) && defined(DEBUG)) /* this should really be part of a subroutine */
   if (dd(D_FILES)) KPSE_DEBUG_SET (KPSE_DEBUG_FOPEN);
   if (dd(D_PATHS)) KPSE_DEBUG_SET (KPSE_DEBUG_PATHS);
   if (dd(D_STAT)) KPSE_DEBUG_SET (KPSE_DEBUG_STAT);
   if (dd(D_HASH)) KPSE_DEBUG_SET (KPSE_DEBUG_HASH);
   if (dd(D_EXPAND)) KPSE_DEBUG_SET (KPSE_DEBUG_EXPAND);
   if (dd(D_SEARCH)) KPSE_DEBUG_SET (KPSE_DEBUG_SEARCH);
#endif /* DEBUG */
   checkenv(1) ;
#ifdef KPATHSEA
   kpse_init_prog ("DVIPS", actualdpi, mfmode, "cmr10");
   kpse_make_tex_discard_errors = quiet;
#endif   
/*
 *   The logic here is a bit convoluted.  Since all `additional'
 *   PostScript font information files are loaded *before* the master
 *   one, and yet they should be able to override the master one, we
 *   have to add the information in the master list to the *ends* of
 *   the hash chain.  We do this by reversing the lists, adding them
 *   to the front, and then reversing them again.
 */
   revpslists() ;
   getpsinfo((char *)NULL) ;
   revpslists() ;
   if (!quiet)
      (void)fprintf(stderr, "%s %s\n", banner, banner2) ;
   if (*iname) {
      dvifile = fopen(iname, READBIN) ;
/*
 *   Allow names like a.b.
 */
      if (dvifile == 0) {
         iname[strlen(iname)-4] = 0 ; /* remove the .dvi suffix */
         dvifile = fopen(iname, READBIN) ;
      }
   }
   if (oname[0] == '-' && oname[1] == 0)
      oname[0] = 0 ;
   else if (*oname == 0 && ! filter) {
      oname = nextstring ;
#ifndef VMCMS  /* get stuff before LAST "." */
      lastext = strlen(iname) - 1 ;
      while (iname[lastext] != '.' && lastext > 0)
         lastext-- ;
      if (iname[lastext] != '.')
         lastext = strlen(iname) - 1 ;
#else   /* for VM/CMS we take the stuff before FIRST "." */
      lastext = strchr(iname,'.') - iname ;
      if ( lastext <= 0 )     /* if no '.' in "iname" */
         lastext = strlen(iname) -1 ;
#endif
#ifdef MVSXA /* IBM: MVS/XA */
      if (strchr(iname, '(') != NULL  &&
          strchr(iname, ')') != NULL) {
      firstext = strchr(iname, '(') - iname + 1;
      lastext = strrchr(iname, ')') - iname - 1;
         }
      else {
      if (strrchr(iname, '.') != NULL) {
      lastext = strrchr(iname, '.') - iname - 1;
           }
         else lastext = strlen(iname) - 1 ;
      if (strchr(iname, '\'') != NULL)
         firstext = strchr(iname, '.') - iname + 1;
         else firstext = 0;
      }
#endif  /* IBM: MVS/XA */
#ifdef MVSXA /* IBM: MVS/XA */
      for (i=firstext; i<=lastext; i++)
#else
      for (i=0; i<=lastext; i++)
#endif
         *nextstring++ = iname[i] ;
      if (iname[lastext] != '.')
         *nextstring++ = '.' ;
#ifndef VMCMS
      *nextstring++ = 'p' ;
      *nextstring++ = 's' ;
#else  /* might as well keep things uppercase */
      *nextstring++ = 'P' ;
      *nextstring++ = 'S' ;
#endif
      *nextstring++ = 0 ;
/*
 *   Now we check the name, and `throw away' any prefix information.
 *   This means throwing away anything before (and including) a colon
 *   or slash.
 */
      {
         char *p = NAME_BEGINS_WITH_DEVICE(oname) ? oname + 2 : oname ;

         for (oname=p; *p && p[1]; p++)
            if (IS_DIR_SEP(*p))
               oname = p + 1 ;
      }
   }
#ifdef DEBUG
   if (dd(D_PATHS)) {
#ifdef SHORTINT
        (void)fprintf(stderr,"input file %s output file %s swmem %ld\n",
#else /* ~SHORTINT */
           (void)fprintf(stderr,"input file %s output file %s swmem %d\n",
#endif /* ~SHORTINT */
           iname, oname, swmem) ;
#ifndef KPATHSEA
   (void)fprintf(stderr,"tfm path %s\npk path %s\n", tfmpath, pkpath) ;
   (void)fprintf(stderr,"fig path %s\nvf path %s\n", figpath, vfpath) ;
   (void)fprintf(stderr,"config path %s\nheader path %s\n",
                  configpath, headerpath) ;
#endif
#ifdef FONTLIB
   (void)fprintf(stderr,"fli path %s\nfli names %s\n", flipath, fliname) ;
#endif
   } /* dd(D_PATHS) */
#endif /* DEBUG */
/*
 *   Now we try to open the dvi file.
 */
   if (!quiet && warningmsg)
      error(warningmsg) ;
   headersready = 1 ;
   headerfile = (char *) (compressed? CHEADERFILE : HEADERFILE) ;
   (void)add_header(headerfile) ;
   if (*iname != 0) {
      fulliname = nextstring ;
#ifndef IGNORE_CWD
      if (!IS_DIR_SEP(*iname) && !NAME_BEGINS_WITH_DEVICE(iname)) {
        getcwd(nextstring, MAXPATHLEN + 2);
        while (*nextstring++) ;
#ifdef VMS           /* VMS doesn't need the '/' character appended */
        nextstring--;       /* so just back up one byte. */
#else
        *(nextstring-1) = '/' ;
#endif
      }
#endif
      strcpy(nextstring,iname) ;
      while (*nextstring++) ; /* advance nextstring past iname */
   } else if (filter) {
      dvifile = stdin ;
      if (O_BINARY && !isatty(fileno(stdin)))
        SET_BINARY(fileno(stdin)) ;
   } else {
#ifdef KPATHSEA
      fprintf (stderr, "Missing DVI file argument (or -f).\n");
      fprintf (stderr, "Try --help for more information.\n");
#else
      help(1) ;
#endif
      exit(1) ;
   }
   initcolor() ;
   if (dvifile==NULL) {
      extern char errbuf[];
      (void)sprintf(errbuf,"! DVI file <%s> can't be opened.", iname) ;
      error("! DVI file can't be opened.") ;
   }
   if (fseek(dvifile, 0L, 0) < 0)
      error("! DVI file must not be a pipe.") ;
#ifdef FONTLIB
   fliload();    /* read the font libaries */
#endif
/*
 *   Now we do our main work.
 */
   swmem += fontmem ;
   if (maxdrift < 0) {
      if (actualdpi <= 599)
         maxdrift = actualdpi / 100 ;
      else if (actualdpi < 1199)
         maxdrift = actualdpi / 200 + 3 ;
      else
         maxdrift = actualdpi / 400 + 6 ;
   }
   if (vmaxdrift < 0) {
      if (vactualdpi <= 599)
         vmaxdrift = vactualdpi / 100 ;
      else if (vactualdpi < 1199)
         vmaxdrift = vactualdpi / 200 + 3 ;
      else
         vmaxdrift = vactualdpi / 400 + 6 ;
   }
   if (dopprescan)
      pprescanpages() ;
   prescanpages() ;
#if defined MSDOS || defined OS2 || defined(ATARIST)
   if (mfjobfile != (FILE*)NULL) {
     char answer[5];
     fputs("}\n",mfjobfile);
     fclose(mfjobfile);
     fputs("Exit to make missing fonts now (y/n)? ",stdout);
     fgets(answer,4,stdin);
     if (*answer=='y' || *answer=='Y')
       exit(8); /* exit with errorlevel 8 for emTeX dvidrv */
   }
#endif
   if (includesfonts)
      (void)add_header(IFONTHEADER) ;
   if (usesPSfonts)
      (void)add_header(PSFONTHEADER) ;
   if (usesspecial)
      (void)add_header(SPECIALHEADER) ;
   if (usescolor)  /* IBM: color */
      (void)add_header(COLORHEADER) ;
#ifdef HPS
   if (HPS_FLAG)
      (void)add_header(HPSHEADER) ;
#endif
   sects = sections ;
   totalpages *= collatedcopies ;
   if (sects == NULL || sects->next == NULL) {
      sectioncopies = collatedcopies ;
      collatedcopies = 1 ;
   } else {
      if (! sepfiles)
         multiplesects = 1 ;
   }
   totalpages *= pagecopies ;
   if (tryepsf) {
      if (paperfmt || landscape || manualfeed ||
          collatedcopies > 1 || numcopies > 1 || cropmarks ||
          *iname == 0 ||
           (totalpages > 1 && !(sepfiles && maxsecsize == 1))) {
         error("Can't make it EPSF, sorry") ;
         tryepsf = 0 ;
      }
   }
#ifdef HPS
   if (HPS_FLAG)
      set_bitfile("head.tmp", 0) ;
#endif
   if (! sepfiles) {
      initprinter(sections) ;
      outbangspecials() ;
   }

   for (i=0; i<collatedcopies; i++) {
      sects = sections ;
      while (sects != NULL) {
         if (sepfiles) {
            newoutname() ;
            if (! quiet) {
               if (prettycolumn + strlen(oname) + 6 > STDOUTSIZE) {
                  fprintf(stderr, "\n") ;
                  prettycolumn = 0 ;
               }
               (void)fprintf(stderr, "(-> %s) ", oname) ;
               prettycolumn += strlen(oname) + 6 ;
            }
#ifdef HPS
            if (HPS_FLAG)
               set_bitfile("head.tmp", 0) ;
#endif
            initprinter(sects) ;
            outbangspecials() ;
         } else if (! quiet) {
            if (prettycolumn > STDOUTSIZE) {
               fprintf(stderr, "\n") ;
               prettycolumn = 0 ;
            }
            (void)fprintf(stderr, ". ") ;
            prettycolumn += 2 ;
         }
         (void)fflush(stderr) ;
         dosection(sects, sectioncopies) ;
         sects = sects->next ;
         if (sepfiles) {
#ifdef HPS
            if (HPS_FLAG)
               finish_hps() ;
#endif
            cleanprinter() ;
        }
      }
   }
   if (! sepfiles) {
#ifdef HPS
      if (HPS_FLAG)
         finish_hps() ;
#endif
      cleanprinter() ;
   }
   if (! quiet)
      (void)fprintf(stderr, "\n") ;
#ifdef DEBUG
   if (dd(D_MEM)) {
#ifdef SHORTINT
      fprintf(stderr, "Total memory allocated:  %ld\n", totalalloc) ;
#else
      fprintf(stderr, "Total memory allocated:  %d\n", totalalloc) ;
#endif
   }
#endif
   return 0 ;
   /*NOTREACHED*/
}

Here is the call graph for this function:

void check_checksum P3C ( unsigned  ,
c1  ,
unsigned  ,
c2  ,
const char *  ,
name   
)

Definition at line 365 of file dvips.c.

{
  if (c1 && c2 && c1 != c2 
#ifdef KPATHSEA
      && !kpse_tex_hush ("checksum")
#endif
      ) {
     sprintf (errbuf, "Checksum mismatch in %s", name);
     error (errbuf);
   }
}

Here is the call graph for this function:

char* strtok ( )

Here is the caller graph for this function:


Variable Documentation

Definition at line 65 of file dvips.c.

Definition at line 103 of file dvips.c.

Definition at line 99 of file dvips.c.

char banner[] = BANNER

Definition at line 187 of file dvips.c.

char banner2[] = BANNER2

Definition at line 188 of file dvips.c.

Definition at line 93 of file dvips.c.

long bytesleft

Definition at line 112 of file dvips.c.

Definition at line 68 of file dvips.c.

Definition at line 58 of file dvips.c.

Definition at line 140 of file dvips.c.

Definition at line 97 of file dvips.c.

Definition at line 64 of file dvips.c.

Definition at line 54 of file dvips.c.

Definition at line 95 of file dvips.c.

Definition at line 94 of file dvips.c.

Definition at line 199 of file dvips.c.

Definition at line 181 of file dvips.c.

Definition at line 101 of file dvips.c.

Definition at line 173 of file dvips.c.

Definition at line 114 of file loadfont.c.

Definition at line 190 of file dvips.c.

Definition at line 59 of file dvips.c.

Definition at line 93 of file dvips.c.

char errbuf[]

Definition at line 42 of file loadfont.c.

Definition at line 74 of file dvips.c.

Definition at line 96 of file dvips.c.

char* figpath = FIGPATH

Definition at line 138 of file dvips.c.

Definition at line 159 of file dvips.c.

Definition at line 85 of file dvips.c.

Definition at line 78 of file dvips.c.

Definition at line 80 of file dvips.c.

Definition at line 184 of file dvips.c.

Definition at line 53 of file dvips.c.

Definition at line 109 of file dvips.c.

Definition at line 179 of file dvips.c.

Definition at line 182 of file dvips.c.

char* fulliname

Definition at line 90 of file dvips.c.

Definition at line 162 of file dvips.c.

char** gargv

Definition at line 163 of file dvips.c.

char* headerfile

Definition at line 170 of file dvips.c.

Definition at line 139 of file dvips.c.

Definition at line 168 of file dvips.c.

Definition at line 193 of file dvips.c.

char* helparr[] [static]

Definition at line 240 of file dvips.c.

Definition at line 114 of file dvips.c.

Definition at line 83 of file dvips.c.

Definition at line 82 of file dvips.c.

char* iname

Definition at line 89 of file dvips.c.

Definition at line 183 of file dvips.c.

char* infont

Definition at line 125 of file dvips.c.

Definition at line 108 of file dvips.c.

Definition at line 79 of file dvips.c.

Definition at line 43 of file loadfont.c.

Definition at line 81 of file dvips.c.

Definition at line 71 of file dvips.c.

double mag

Definition at line 100 of file dvips.c.

Definition at line 57 of file dvips.c.

Definition at line 105 of file dvips.c.

Definition at line 72 of file dvips.c.

Definition at line 84 of file dvips.c.

char * maxstring

Definition at line 92 of file dvips.c.

char* mflandmode

Definition at line 176 of file dvips.c.

char* mfmode

Definition at line 175 of file dvips.c.

Definition at line 177 of file dvips.c.

Definition at line 172 of file dvips.c.

Definition at line 185 of file dvips.c.

char* nextstring

Definition at line 92 of file dvips.c.

Definition at line 189 of file dvips.c.

Definition at line 115 of file dvips.c.

Definition at line 63 of file dvips.c.

Definition at line 73 of file dvips.c.

Definition at line 73 of file dvips.c.

Definition at line 101 of file dvips.c.

Definition at line 87 of file dvips.c.

Definition at line 74 of file dvips.c.

char* oname

Definition at line 88 of file dvips.c.

Definition at line 178 of file dvips.c.

Definition at line 102 of file dvips.c.

Definition at line 70 of file dvips.c.

Definition at line 180 of file dvips.c.

Definition at line 110 of file dvips.c.

Definition at line 75 of file dvips.c.

Definition at line 111 of file dvips.c.

char* paperfmt

Definition at line 107 of file dvips.c.

struct papsiz* papsizes

Definition at line 192 of file dvips.c.

Definition at line 56 of file dvips.c.

char* pictpath = PICTPATH

Definition at line 148 of file dvips.c.

char* pkpath = PKPATH

Definition at line 136 of file dvips.c.

Definition at line 161 of file dvips.c.

char* printer

Definition at line 174 of file dvips.c.

char* progname [static]

Definition at line 313 of file dvips.c.

Definition at line 202 of file dvips.c.

char* qargv[32]

Definition at line 203 of file dvips.c.

char queryline[256]

Definition at line 201 of file dvips.c.

Definition at line 204 of file dvips.c.

Definition at line 158 of file dvips.c.

Definition at line 113 of file dvips.c.

Definition at line 62 of file dvips.c.

Definition at line 165 of file dvips.c.

Definition at line 60 of file dvips.c.

Definition at line 69 of file dvips.c.

Definition at line 55 of file dvips.c.

Definition at line 67 of file dvips.c.

Definition at line 76 of file dvips.c.

Definition at line 86 of file dvips.c.

Definition at line 77 of file dvips.c.

char* strings

Definition at line 91 of file dvips.c.

Definition at line 157 of file dvips.c.

char* tfmpath = TFMPATH

Definition at line 135 of file dvips.c.

integer totalalloc = 0 [static]

Definition at line 385 of file dvips.c.

Definition at line 164 of file dvips.c.

Definition at line 66 of file dvips.c.

Definition at line 169 of file dvips.c.

Definition at line 166 of file dvips.c.

Definition at line 167 of file dvips.c.

Definition at line 104 of file dvips.c.

Definition at line 98 of file dvips.c.

char* vfpath = VFPATH

Definition at line 137 of file dvips.c.

Definition at line 106 of file dvips.c.

Definition at line 83 of file dvips.c.

Definition at line 82 of file dvips.c.

Definition at line 114 of file dvips.c.

char* warningmsg

Definition at line 171 of file dvips.c.

char xdig[256]

Definition at line 186 of file dvips.c.