| 1 |
/* |
| 2 |
* This is the main routine. |
| 3 |
*/ |
| 4 |
#include "dvips.h" /* The copyright notice there is included too! */ |
| 5 |
#ifdef KPATHSEA |
| 6 |
#include <kpathsea/c-pathch.h> |
| 7 |
#include <kpathsea/proginit.h> |
| 8 |
#include <kpathsea/progname.h> |
| 9 |
#include <kpathsea/tex-hush.h> |
| 10 |
#include <kpathsea/tex-make.h> |
| 11 |
#include <kpathsea/variable.h> |
| 12 |
#include <kpathsea/version.h> |
| 13 |
#include <kpathsea/lib.h> |
| 14 |
#ifdef strdup |
| 15 |
#undef strdup |
| 16 |
#endif |
| 17 |
#define strdup xstrdup |
| 18 |
#include "paths.h" |
| 19 |
#else /* ! KPATHSEA */ |
| 20 |
#include <stdlib.h> /* for malloc, etc. */ |
| 21 |
#if !defined(SYSV) && !defined(WIN32) |
| 22 |
extern char *strtok(); /* some systems don't have this in strings.h */ |
| 23 |
#endif |
| 24 |
#if defined(WIN32) |
| 25 |
#include <io.h> |
| 26 |
#include <fcntl.h> |
| 27 |
#include <string.h> |
| 28 |
#define O_BINARY _O_BINARY |
| 29 |
#endif |
| 30 |
#define DIR_SEP DIRSEP |
| 31 |
#endif /* KPATHSEA */ |
| 32 |
#ifdef VMS |
| 33 |
#define GLOBAL globaldef |
| 34 |
#ifdef __GNUC__ |
| 35 |
#include "climsgdef.h" /* created by hand, extracted from STARLET.MLB */ |
| 36 |
/* and put in GNU_CC:[INCLUDE.LOCAL] */ |
| 37 |
#include "ctype.h" |
| 38 |
#include "descrip.h" |
| 39 |
#else |
| 40 |
#include climsgdef |
| 41 |
#include ctype |
| 42 |
#include descrip |
| 43 |
#endif |
| 44 |
#endif |
| 45 |
#ifdef __APPLE__ /* for Mac OS X, T. Uchiyama */ |
| 46 |
#include <sys/types.h> |
| 47 |
#include <sys/time.h> |
| 48 |
#include <sys/resource.h> |
| 49 |
#endif |
| 50 |
|
| 51 |
#if defined(WIN32) && defined(KPATHSEA) |
| 52 |
FILE *generic_fsyscp_fopen(const char *filename, const char *mode) |
| 53 |
{ |
| 54 |
FILE *f; |
| 55 |
|
| 56 |
f = fsyscp_fopen (filename, mode); |
| 57 |
|
| 58 |
if (f == NULL && file_system_codepage != win32_codepage) { |
| 59 |
int tmpcp = file_system_codepage; |
| 60 |
file_system_codepage = win32_codepage; |
| 61 |
f = fsyscp_fopen (filename, mode); |
| 62 |
file_system_codepage = tmpcp; |
| 63 |
} |
| 64 |
|
| 65 |
return f; |
| 66 |
} |
| 67 |
#undef fopen |
| 68 |
#define fopen(file, fmode) generic_fsyscp_fopen(file, fmode) |
| 69 |
#endif |
| 70 |
|
| 71 |
#ifndef DEFRES |
| 72 |
#define DEFRES (600) |
| 73 |
#endif |
| 74 |
|
| 75 |
/* |
| 76 |
* The external declarations: |
| 77 |
*/ |
| 78 |
#include "protos.h" |
| 79 |
|
| 80 |
/* |
| 81 |
* First we define some globals. |
| 82 |
*/ |
| 83 |
#ifdef VMS |
| 84 |
static char ofnme[252],infnme[252],pap[40],thh[20]; |
| 85 |
#endif |
| 86 |
|
| 87 |
/* PS fonts fully downloaded as headers */ |
| 88 |
char *downloadedpsnames[DOWNLOADEDPSSIZE]; |
| 89 |
|
| 90 |
int found_problems = 0; /* should we exit successfully? */ |
| 91 |
int unused_top_of_psnames; /* unused top number of downloadedpsnames[#] */ |
| 92 |
fontdesctype *fonthead; /* list of all fonts mentioned so far */ |
| 93 |
fontdesctype *curfnt; /* the currently selected font */ |
| 94 |
sectiontype *sections; /* sections to process document in */ |
| 95 |
Boolean partialdownload = 1; /* turn on partial downloading */ |
| 96 |
Boolean manualfeed; /* manual feed? */ |
| 97 |
Boolean landscaperotate = 0; /* when picking paper sizes allow rotated media */ |
| 98 |
Boolean compressed; /* compressed? */ |
| 99 |
Boolean downloadpspk; /* use PK for downloaded PS fonts? */ |
| 100 |
Boolean safetyenclose; /* enclose in save/restore for stupid spoolers? */ |
| 101 |
Boolean removecomments = 0; /* remove comments from included PS? */ |
| 102 |
Boolean nosmallchars; /* disable small char optimization for X4045? */ |
| 103 |
Boolean cropmarks; /* add cropmarks? */ |
| 104 |
Boolean abspage = 0; /* are page numbers absolute? */ |
| 105 |
Boolean tryepsf = 0; /* should we try to make it espf? */ |
| 106 |
int secure = 1; /* make safe for suid */ |
| 107 |
int secure_option = 0; /* set by -R */ |
| 108 |
int collatedcopies = 1; /* how many collated copies? */ |
| 109 |
int sectioncopies = 1; /* how many times to repeat each section? */ |
| 110 |
integer pagecopies = 1; /* how many times to repeat each page? */ |
| 111 |
shalfword linepos = 0; /* where are we on the line being output? */ |
| 112 |
integer maxpages; /* the maximum number of pages */ |
| 113 |
Boolean notfirst, notlast; /* true if a first page was specified */ |
| 114 |
Boolean evenpages, oddpages; /* true if doing only even/only odd pages */ |
| 115 |
Boolean pagelist; /* true if using page ranges */ |
| 116 |
Boolean sendcontrolD; /* should we send a control D at end? */ |
| 117 |
Boolean shiftlowchars; /* shift [0-32, 127] characters higher? */ |
| 118 |
integer firstpage; /* the number of the first page if specified */ |
| 119 |
integer lastpage; |
| 120 |
integer firstseq; |
| 121 |
integer lastseq; |
| 122 |
integer hpapersize, vpapersize; /* horizontal and vertical paper size */ |
| 123 |
integer hoff, voff; /* horizontal and vertical offsets */ |
| 124 |
integer maxsecsize = 0; /* the maximum size of a section */ |
| 125 |
integer firstboploc; /* where the first bop is */ |
| 126 |
Boolean sepfiles; /* each section in its own file? */ |
| 127 |
int numcopies; /* number of copies of each page to print */ |
| 128 |
char *titlename=""; /* if given, used for %%Title */ |
| 129 |
const char *oname; /* output file name */ |
| 130 |
char *iname; /* dvi file name */ |
| 131 |
char *fulliname; /* same, with current working directory */ |
| 132 |
char *strings; /* strings for program */ |
| 133 |
char *nextstring, *maxstring; /* string pointers */ |
| 134 |
FILE *dvifile, *bitfile; /* dvi and output files */ |
| 135 |
quarterword *curpos; /* current position in virtual character packet */ |
| 136 |
quarterword *curlim; /* final byte in virtual character packet */ |
| 137 |
fontmaptype *ffont; /* first font in current frame */ |
| 138 |
real conv; /* conversion ratio, pixels per DVI unit */ |
| 139 |
real vconv; /* conversion ratio, pixels per DVI unit */ |
| 140 |
real alpha; /* conversion ratio, DVI unit per TFM unit */ |
| 141 |
double mag; /* the magnification of this document */ |
| 142 |
integer num, den; /* the numerator and denominator */ |
| 143 |
int overridemag; /* substitute for mag value in DVI file? */ |
| 144 |
int actualdpi = DEFRES; /* the actual resolution of the printer */ |
| 145 |
int vactualdpi = DEFRES; /* the actual resolution of the printer */ |
| 146 |
int maxdrift; /* max pixels away from true rounded position */ |
| 147 |
int vmaxdrift; /* max pixels away from true rounded position */ |
| 148 |
char *paperfmt; /* command-line paper format */ |
| 149 |
int landscape = 0; /* landscape mode */ |
| 150 |
integer fontmem; /* memory remaining in printer */ |
| 151 |
integer pagecount; /* page counter for the sections */ |
| 152 |
integer pagenum; /* the page number we currently look at */ |
| 153 |
long bytesleft; /* number of bytes left in raster */ |
| 154 |
quarterword *raster; /* area for raster manipulations */ |
| 155 |
integer hh, vv; /* horizontal and vertical pixel positions */ |
| 156 |
Boolean noomega = 0; /* Omega extensions are enabled */ |
| 157 |
Boolean noptex = 0; /* pTeX extensions are enabled */ |
| 158 |
Boolean lastpsizwins = 1; /* if 1, last \special{papersize=w,h} wins */ |
| 159 |
|
| 160 |
/*-----------------------------------------------------------------------* |
| 161 |
* The PATH definitions cannot be defined on the command line because so many |
| 162 |
* DEFINE's overflow the DCL buffer when using the GNU CC compiler. |
| 163 |
*-----------------------------------------------------------------------*/ |
| 164 |
#if defined(VMS) && defined(__GNUC__) |
| 165 |
#include "vms_gcc_paths.h" |
| 166 |
#endif |
| 167 |
|
| 168 |
const char *infont; /* is the file we are downloading a font? */ |
| 169 |
#ifndef KPATHSEA |
| 170 |
#ifdef ATARIST |
| 171 |
# define TFMPATH "." |
| 172 |
# define PKPATH "." |
| 173 |
# define VFPATH "." |
| 174 |
# define FIGPATH "." |
| 175 |
# define HEADERPATH "." |
| 176 |
# define CONFIGPATH "." |
| 177 |
#endif |
| 178 |
char *tfmpath = TFMPATH; /* pointer to directories for tfm files */ |
| 179 |
char *pkpath = PKPATH; /* pointer to directories for pk files */ |
| 180 |
char *vfpath = VFPATH; /* pointer to directories for vf files */ |
| 181 |
char *figpath = FIGPATH; /* pointer to directories for figure files */ |
| 182 |
char *headerpath = HEADERPATH; /* pointer to directories for header files */ |
| 183 |
char *configpath = CONFIGPATH; /* where to find config files */ |
| 184 |
#ifndef PICTPATH |
| 185 |
#ifndef __THINK__ |
| 186 |
#define PICTPATH "." |
| 187 |
#else |
| 188 |
#define PICTPATH ":" |
| 189 |
#endif |
| 190 |
#endif |
| 191 |
char *pictpath = PICTPATH; /* where IFF/etc. pictures are found */ |
| 192 |
#ifdef SEARCH_SUBDIRECTORIES |
| 193 |
char *fontsubdirpath = FONTSUBDIRPATH; |
| 194 |
#endif |
| 195 |
#endif /* ! KPATHSEA */ |
| 196 |
#ifdef FONTLIB |
| 197 |
char *flipath = FLIPATH; /* pointer to directories for fli files */ |
| 198 |
char *fliname = FLINAME; /* pointer to names of fli files */ |
| 199 |
#endif |
| 200 |
integer swmem; /* font memory in the PostScript printer */ |
| 201 |
int quiet; /* should we only print errors to stderr? */ |
| 202 |
int filter; /* act as filter default output to stdout, |
| 203 |
default input to stdin? */ |
| 204 |
int dvips_debug_flag; /* output config and map files to stderr if 1 */ |
| 205 |
int prettycolumn; /* the column we are at when running pretty */ |
| 206 |
int gargc; /* global argument count */ |
| 207 |
char **gargv; /* global argument vector */ |
| 208 |
int totalpages = 0; /* total number of pages */ |
| 209 |
Boolean reverse; /* are we going reverse? */ |
| 210 |
Boolean usesPSfonts; /* do we use local PostScript fonts? */ |
| 211 |
Boolean usesspecial; /* do we use \special? */ |
| 212 |
Boolean headers_off; /* do we send headers or not? */ |
| 213 |
Boolean usescolor; /* IBM: color - do we use colors? */ |
| 214 |
const char *headerfile; /* default header file */ |
| 215 |
char *warningmsg; /* a message to write, if set in config file */ |
| 216 |
Boolean multiplesects; /* more than one section? */ |
| 217 |
Boolean disablecomments; /* should we suppress any EPSF comments? */ |
| 218 |
char *printer; /* what printer to send this to? */ |
| 219 |
char *mfmode; /* default MF mode */ |
| 220 |
char *mflandmode; /* allow an optional landscape mode def */ |
| 221 |
int mfmode_option; /* set by -mode command-line option */ |
| 222 |
int oname_option; /* set by -o option */ |
| 223 |
frametype frames[MAXFRAME]; /* stack for virtual fonts */ |
| 224 |
integer pagecost; /* memory used on the page being prescanned */ |
| 225 |
int delchar; /* characters to delete from prescanned page */ |
| 226 |
integer fsizetol; /* max dvi units error for psfile font sizes */ |
| 227 |
Boolean includesfonts; /* are fonts used in included psfiles? */ |
| 228 |
fontdesctype *fonthd[MAXFONTHD];/* list headers for included fonts of 1 name */ |
| 229 |
int nextfonthd; /* next unused fonthd[] index */ |
| 230 |
char xdig[256]; /* table for reading hexadecimal digits */ |
| 231 |
char banner[] = BANNER; /* our startup message */ |
| 232 |
char banner2[] = BANNER2; /* our second startup message */ |
| 233 |
Boolean noenv = 0; /* ignore PRINTER envir variable? */ |
| 234 |
Boolean dopprescan = 0; /* do we do a scan before the prescan? */ |
| 235 |
struct papsiz *papsizes; /* all available paper size */ |
| 236 |
int headersready; /* ready to check headers? */ |
| 237 |
#if defined(MSDOS) || defined(OS2) || defined(ATARIST) |
| 238 |
char *mfjobname = NULL; /* name of mfjob file if given */ |
| 239 |
FILE *mfjobfile = NULL; /* mfjob file for font making instructions */ |
| 240 |
#endif |
| 241 |
#ifdef DEBUG |
| 242 |
integer debug_flag = 0; |
| 243 |
#endif /* DEBUG */ |
| 244 |
char queryline[256]; /* interactive query of options */ |
| 245 |
int qargc; |
| 246 |
char *qargv[32]; |
| 247 |
char queryoptions; |
| 248 |
#ifdef HPS |
| 249 |
Boolean HPS_FLAG = 0; |
| 250 |
#endif |
| 251 |
|
| 252 |
/* Declare the routine to get the current working directory. */ |
| 253 |
|
| 254 |
/* The getwd/getcwd stuff here is not portable, and I don't think it's |
| 255 |
worth it to include xgetcwd.d just so we can print the full pathname |
| 256 |
of the DVI file in the output. --karl */ |
| 257 |
#define IGNORE_CWD |
| 258 |
|
| 259 |
#ifndef IGNORE_CWD |
| 260 |
#ifndef HAVE_GETCWD |
| 261 |
extern char *getwd (); /* said to be faster than getcwd (SunOS man page) */ |
| 262 |
#define getcwd(b, len) getwd(b) /* used here only when b nonnull */ |
| 263 |
#else |
| 264 |
#ifdef ANSI |
| 265 |
extern char *getcwd (char *, int); |
| 266 |
#else |
| 267 |
extern char *getcwd (); |
| 268 |
#endif /* not ANSI */ |
| 269 |
#endif /* not HAVE_GETWD */ |
| 270 |
#if defined(SYSV) || defined(VMS) || (defined(MSDOS) && !defined(__DJGPP__)) || defined(OS2) || defined(ATARIST) |
| 271 |
#define MAXPATHLEN (256) |
| 272 |
#else |
| 273 |
#include <sys/param.h> /* for MAXPATHLEN */ |
| 274 |
#endif |
| 275 |
#endif /* not IGNORE_CWD */ |
| 276 |
|
| 277 |
static const char *helparr[] = { |
| 278 |
#ifndef VMCMS |
| 279 |
"Usage: dvips [OPTION]... FILENAME[.dvi]", |
| 280 |
#else |
| 281 |
" VM/CMS Usage:", |
| 282 |
" dvips fname [ftype [fmode]] [options]", |
| 283 |
"or", |
| 284 |
" dvips fname[.ftype[.fmode]] [options]", |
| 285 |
#endif |
| 286 |
"Convert DVI input files to PostScript.", |
| 287 |
"See http://tug.org/dvips/ for the full manual and other information.", |
| 288 |
"", |
| 289 |
"Options:", |
| 290 |
"-a* Conserve memory, not time -A Print only odd (TeX) pages", |
| 291 |
"-b # Page copies, for posters e.g. -B Print only even (TeX) pages", |
| 292 |
"-bitmapfontenc [on,off,strict] control bitmap font encoding", |
| 293 |
"-c # Uncollated copies -C # Collated copies", |
| 294 |
"-d # Debugging -D # Resolution", |
| 295 |
"-e # Maxdrift value -E* Try to create EPSF", |
| 296 |
"-f* Run as filter -F* Send control-D at end", |
| 297 |
#ifdef SHIFTLOWCHARS |
| 298 |
" -G* Shift low chars to higher pos.", |
| 299 |
#endif |
| 300 |
"-h f Add header file", |
| 301 |
"-i* Separate file per section", |
| 302 |
"-j* Download fonts partially", |
| 303 |
"-k* Print crop marks -K* Pull comments from inclusions", |
| 304 |
"-l # Last page -L* Last special papersize wins", |
| 305 |
"-landscaperotate* Allow landscape to print rotated on portrait papersizes", |
| 306 |
"-m* Manual feed -M* Don't make fonts", |
| 307 |
"-mode s Metafont device name", |
| 308 |
"-n # Maximum number of pages -N* No structured comments", |
| 309 |
"-noomega Disable Omega extensions", |
| 310 |
"-noptex Disable pTeX extensions", |
| 311 |
"-o f Output file -O c Set/change paper offset", |
| 312 |
#if defined(MSDOS) || defined(OS2) |
| 313 |
"-p # First page -P s Load $s.cfg", |
| 314 |
#else |
| 315 |
"-p # First page -P s Load config.$s", |
| 316 |
#endif |
| 317 |
"-pp l Print only pages listed", |
| 318 |
"-q* Run quietly", |
| 319 |
"-r* Reverse order of pages -R* Run securely", |
| 320 |
"-s* Enclose output in save/restore -S # Max section size in pages", |
| 321 |
"-t s Paper format -T c Specify desired page size", |
| 322 |
"-title s Title in comment", |
| 323 |
"-u s PS mapfile -U* Disable string param trick", |
| 324 |
"-v Print version number and quit -V* Send downloadable PS fonts as PK", |
| 325 |
"-x # Override dvi magnification -X # Horizontal resolution", |
| 326 |
"-y # Multiply by dvi magnification -Y # Vertical resolution", |
| 327 |
#ifdef HPS |
| 328 |
"-z* Hyper PS -Z* Compress bitmap fonts", |
| 329 |
#else |
| 330 |
" -Z* Compress bitmap fonts", |
| 331 |
#endif |
| 332 |
/*"- Interactive query of options", */ |
| 333 |
" # = number f = file s = string * = suffix, `0' to turn off", |
| 334 |
" c = comma-separated dimension pair (e.g., 3.2in,-32.1cm)", |
| 335 |
" l = comma-separated list of page ranges (e.g., 1-4,7-9)", 0}; |
| 336 |
|
| 337 |
void |
| 338 |
help(int status) |
| 339 |
{ |
| 340 |
const char **p; |
| 341 |
FILE *f = status == 0 ? stdout : stderr; |
| 342 |
for (p=helparr; *p; p++) |
| 343 |
fprintf (f, "%s\n", *p); |
| 344 |
|
| 345 |
putc ('\n', f); |
| 346 |
#ifdef KPATHSEA |
| 347 |
fputs (kpse_bug_address, f); |
| 348 |
#endif |
| 349 |
} |
| 350 |
|
| 351 |
static void |
| 352 |
freememforpsnames(void) |
| 353 |
{ |
| 354 |
int i; |
| 355 |
|
| 356 |
for (i = 0; i < unused_top_of_psnames && downloadedpsnames[i]; i++) |
| 357 |
free (downloadedpsnames[i]); |
| 358 |
} |
| 359 |
|
| 360 |
/* |
| 361 |
* This error routine prints an error message; if the first |
| 362 |
* character is !, it aborts the job. |
| 363 |
*/ |
| 364 |
|
| 365 |
static char *progname; |
| 366 |
|
| 367 |
void |
| 368 |
error_with_perror(const char *s, const char *fname) |
| 369 |
{ |
| 370 |
if (prettycolumn > 0) |
| 371 |
fprintf(stderr,"\n"); |
| 372 |
prettycolumn = 0; |
| 373 |
fprintf_str(stderr, "%s: %s", progname, s); |
| 374 |
if (fname) { |
| 375 |
putc (' ', stderr); |
| 376 |
perror (fname); |
| 377 |
} else { |
| 378 |
putc ('\n', stderr); |
| 379 |
} |
| 380 |
|
| 381 |
if (*s=='!') { |
| 382 |
freememforpsnames(); |
| 383 |
if (bitfile != NULL) { |
| 384 |
cleanprinter(); |
| 385 |
} |
| 386 |
exit(1); /* fatal */ |
| 387 |
} |
| 388 |
} |
| 389 |
|
| 390 |
/* |
| 391 |
* This error routine prints an error message; if the first |
| 392 |
* character is !, it aborts the job. |
| 393 |
*/ |
| 394 |
void |
| 395 |
error(const char *s) |
| 396 |
{ |
| 397 |
error_with_perror (s, NULL); |
| 398 |
} |
| 399 |
|
| 400 |
#ifndef KPATHSEA |
| 401 |
char * |
| 402 |
concat(char *s1, char *s2) |
| 403 |
{ |
| 404 |
char *s = malloc(strlen(s1)+strlen(s2)+1); |
| 405 |
if (s == NULL) { |
| 406 |
fprintf(stderr, "Malloc failed to give %d bytes.\nAborting\n", |
| 407 |
strlen(s1)+strlen(s2)+1); |
| 408 |
exit(1); |
| 409 |
} |
| 410 |
strcpy(s, s1); |
| 411 |
strcat(s, s2); |
| 412 |
} |
| 413 |
#endif |
| 414 |
|
| 415 |
/* Report a warning if both checksums are nonzero, they don't match, and |
| 416 |
the user hasn't turned it off. */ |
| 417 |
|
| 418 |
void |
| 419 |
check_checksum(unsigned c1, unsigned c2, const char *name) |
| 420 |
{ |
| 421 |
if (c1 && c2 && c1 != c2 |
| 422 |
#ifdef KPATHSEA |
| 423 |
&& !kpse_tex_hush ("checksum") |
| 424 |
#endif |
| 425 |
) { |
| 426 |
char *msg = concat ("Checksum mismatch in %s", name); |
| 427 |
error (msg); |
| 428 |
free (msg); |
| 429 |
} |
| 430 |
} |
| 431 |
|
| 432 |
/* |
| 433 |
* This is our malloc that checks the results. We debug the |
| 434 |
* allocations but not the frees, since memory fragmentation |
| 435 |
* might be such that we can never use the free'd memory and |
| 436 |
* it's wise to be conservative. The only real place we free |
| 437 |
* is when repacking *huge* characters anyway. |
| 438 |
*/ |
| 439 |
#ifdef DEBUG |
| 440 |
static integer totalalloc = 0; |
| 441 |
#endif |
| 442 |
char * |
| 443 |
mymalloc(integer n) |
| 444 |
{ |
| 445 |
char *p; |
| 446 |
|
| 447 |
#ifdef SMALLMALLOC |
| 448 |
if (n > 65500L) |
| 449 |
error("! can't allocate more than 64K!"); |
| 450 |
#endif |
| 451 |
if (n <= 0) /* catch strange 0 mallocs in flib.c without breaking code */ |
| 452 |
n = 1; |
| 453 |
#ifdef DEBUG |
| 454 |
totalalloc += n; |
| 455 |
if (dd(D_MEM)) { |
| 456 |
#ifdef SHORTINT |
| 457 |
fprintf(stderr, "Alloc %ld\n", n); |
| 458 |
#else |
| 459 |
fprintf(stderr, "Alloc %d\n", n); |
| 460 |
#endif |
| 461 |
} |
| 462 |
#endif |
| 463 |
p = (char *) malloc(n); |
| 464 |
if (p == NULL) |
| 465 |
error("! no memory"); |
| 466 |
return p; |
| 467 |
} |
| 468 |
static void |
| 469 |
morestrings(void) { |
| 470 |
strings = mymalloc((integer)STRINGSIZE); |
| 471 |
nextstring = strings; |
| 472 |
maxstring = strings + STRINGSIZE - 200; |
| 473 |
*nextstring++ = 0; |
| 474 |
} |
| 475 |
void |
| 476 |
checkstrings(void) { |
| 477 |
if (nextstring - strings > STRINGSIZE / 2) |
| 478 |
morestrings(); |
| 479 |
} |
| 480 |
/* |
| 481 |
* Initialize sets up all the globals and data structures. |
| 482 |
*/ |
| 483 |
static void |
| 484 |
initialize(void) |
| 485 |
{ |
| 486 |
int i; |
| 487 |
const char *s; |
| 488 |
|
| 489 |
nextfonthd = 0; |
| 490 |
for (i=0; i<256; i++) |
| 491 |
xdig[i] = 0; |
| 492 |
i = 0; |
| 493 |
for (s="0123456789ABCDEF"; *s!=0; s++) |
| 494 |
xdig[(int)*s] = i++; |
| 495 |
i = 10; |
| 496 |
for (s="abcdef"; *s!=0; s++) |
| 497 |
xdig[(int)*s] = i++; |
| 498 |
for(i=0; i < DOWNLOADEDPSSIZE; i++) |
| 499 |
downloadedpsnames[i] = NULL; |
| 500 |
unused_top_of_psnames = 0; |
| 501 |
morestrings(); |
| 502 |
maxpages = 100000; |
| 503 |
numcopies = 1; |
| 504 |
iname = fulliname = strings; |
| 505 |
bitfile = NULL; |
| 506 |
bytesleft = 0; |
| 507 |
swmem = SWMEM; |
| 508 |
oname = OUTPATH; |
| 509 |
sendcontrolD = 0; |
| 510 |
shiftlowchars = 0; |
| 511 |
multiplesects = 0; |
| 512 |
disablecomments = 0; |
| 513 |
maxdrift = -1; |
| 514 |
vmaxdrift = -1; |
| 515 |
dontmakefont = !MAKE_TEX_PK_BY_DEFAULT; |
| 516 |
} |
| 517 |
/* |
| 518 |
* This routine copies a string into the string `pool', safely. |
| 519 |
*/ |
| 520 |
char * |
| 521 |
newstring(const char *s) |
| 522 |
{ |
| 523 |
int l; |
| 524 |
char *q; |
| 525 |
|
| 526 |
if (s == NULL) |
| 527 |
return(NULL); |
| 528 |
l = strlen(s); |
| 529 |
if (nextstring + l >= maxstring) |
| 530 |
morestrings(); |
| 531 |
if (nextstring + l >= maxstring) |
| 532 |
error("! out of string space"); |
| 533 |
strcpy(nextstring, s); |
| 534 |
q = nextstring; |
| 535 |
nextstring += l + 1; |
| 536 |
return(q); |
| 537 |
} |
| 538 |
static void |
| 539 |
newoutname(void) { |
| 540 |
static int seq = 0; |
| 541 |
static char *seqptr = 0; |
| 542 |
char *p, *q; |
| 543 |
|
| 544 |
if (oname == 0 || *oname == 0) |
| 545 |
error("! need an output file name to specify separate files"); |
| 546 |
if (*oname != '!' && *oname != '|') { |
| 547 |
if (seqptr == 0) { |
| 548 |
q = newstring(oname); |
| 549 |
for (p = q; *p; p++) /* find last dot after last slash */ |
| 550 |
if (*p == '.') |
| 551 |
seqptr = p + 1; |
| 552 |
else if (IS_DIR_SEP (*p)) |
| 553 |
seqptr = 0; |
| 554 |
#ifdef WIN32 |
| 555 |
else if (IS_KANJI(p)) |
| 556 |
p++; |
| 557 |
#endif |
| 558 |
if (seqptr == 0) |
| 559 |
seqptr = p; |
| 560 |
nextstring += 5; /* make room for the number, up to five digits */ |
| 561 |
oname = q; |
| 562 |
} |
| 563 |
sprintf(seqptr, "%03d", ++seq); |
| 564 |
} |
| 565 |
} |
| 566 |
/* |
| 567 |
* This routine reverses a list, where a list is defined to be any |
| 568 |
* structure whose first element is a pointer to another such structure. |
| 569 |
*/ |
| 570 |
VOID * |
| 571 |
revlist(VOID *p) |
| 572 |
{ |
| 573 |
struct list { |
| 574 |
struct list *next; |
| 575 |
} *pp = (struct list *)p, *qq = 0, *tt; |
| 576 |
|
| 577 |
while (pp) { |
| 578 |
tt = pp->next; |
| 579 |
pp->next = qq; |
| 580 |
qq = pp; |
| 581 |
pp = tt; |
| 582 |
} |
| 583 |
return (VOID *)qq; |
| 584 |
} |
| 585 |
/* this asks for a new set of arguments from the command line */ |
| 586 |
static void |
| 587 |
queryargs(void) |
| 588 |
{ |
| 589 |
fputs("Options: ",stdout); |
| 590 |
fgets(queryline,256,stdin); |
| 591 |
qargc=1; |
| 592 |
if ( (qargv[1] = strtok(queryline," \n")) != (char *)NULL ) { |
| 593 |
qargc=2; |
| 594 |
while ( ((qargv[qargc] = strtok((char *)NULL," \n")) != (char *)NULL) |
| 595 |
&& (qargc < 31) ) |
| 596 |
qargc++; |
| 597 |
} |
| 598 |
qargv[qargc] = (char *)NULL; |
| 599 |
} |
| 600 |
|
| 601 |
/* |
| 602 |
* Finally, our main routine. |
| 603 |
*/ |
| 604 |
#ifdef VMS |
| 605 |
main(void) |
| 606 |
#else |
| 607 |
int |
| 608 |
main(int argc, char **argv) |
| 609 |
#endif |
| 610 |
{ |
| 611 |
int i, lastext = -1; |
| 612 |
#ifdef MVSXA |
| 613 |
int firstext = -1; |
| 614 |
#endif |
| 615 |
sectiontype *sects; |
| 616 |
|
| 617 |
#ifdef WIN32 |
| 618 |
#if defined(KPATHSEA) |
| 619 |
int ac; |
| 620 |
char **av, *enc; |
| 621 |
#endif |
| 622 |
SET_BINARY(fileno(stdin)); |
| 623 |
SET_BINARY(fileno(stdout)); |
| 624 |
#endif |
| 625 |
|
| 626 |
#ifdef __APPLE__ /* for Mac OS X, T. Uchiyama */ |
| 627 |
struct rlimit rl; |
| 628 |
getrlimit(RLIMIT_STACK, &rl); |
| 629 |
rl.rlim_cur = 2048 * 1024; |
| 630 |
setrlimit(RLIMIT_STACK, &rl); |
| 631 |
#endif |
| 632 |
#ifdef KPATHSEA |
| 633 |
if (argc > 1) { |
| 634 |
if (argc == 2 && strncmp(argv[1], "-?", 2) == 0) { |
| 635 |
printf("%s %s\n", banner, banner2); |
| 636 |
help(0); |
| 637 |
exit(0); |
| 638 |
} |
| 639 |
if (argc == 2 && strncmp(argv[1], "-v", 2) == 0) { |
| 640 |
printf("%s %s\n", banner, banner2); |
| 641 |
exit(0); |
| 642 |
} |
| 643 |
/* print information and exit if dvips finds options --help or --version */ |
| 644 |
if (strlen(argv[1]) == 6 && strcmp(argv[1], "--help") == 0) { |
| 645 |
help (0); |
| 646 |
exit (0); |
| 647 |
} |
| 648 |
if (strlen (argv[1]) == 9 && strcmp(argv[1], "--version") == 0) { |
| 649 |
puts (BANNER); |
| 650 |
puts (kpathsea_version_string); |
| 651 |
puts ("There is NO warranty. You may redistribute this software\n\ |
| 652 |
under the terms of the GNU General Public License\n\ |
| 653 |
and the Dvips copyright.\n\ |
| 654 |
For more information about these matters, see the files\n\ |
| 655 |
named COPYING and dvips.h.\n\ |
| 656 |
Primary author of Dvips: T. Rokicki."); |
| 657 |
exit (0); |
| 658 |
} |
| 659 |
} |
| 660 |
kpse_set_program_name (argv[0], "dvips"); |
| 661 |
kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile); |
| 662 |
#ifdef WIN32 |
| 663 |
enc = kpse_var_value("command_line_encoding"); |
| 664 |
if (get_command_line_args_utf8(enc, &ac, &av)) { |
| 665 |
argc = ac; |
| 666 |
argv = av; |
| 667 |
} |
| 668 |
#endif |
| 669 |
#endif |
| 670 |
|
| 671 |
#ifdef __THINK__ |
| 672 |
argc = dcommand(&argv); /* do I/O stream redirection */ |
| 673 |
#endif |
| 674 |
#ifdef VMS /* Grab the command-line buffer */ |
| 675 |
short len_arg; |
| 676 |
$DESCRIPTOR( verb_dsc, "DVIPS "); /* assume the verb is always DVIPS */ |
| 677 |
struct dsc$descriptor_d temp_dsc = { 0, DSC$K_DTYPE_T, DSC$K_CLASS_D, 0}; |
| 678 |
|
| 679 |
progname = &thh[0]; |
| 680 |
strcpy(progname,"DVIPS%ERROR"); |
| 681 |
|
| 682 |
lib$get_foreign( &temp_dsc, 0, &len_arg, 0); /* Get the command line */ |
| 683 |
str$prefix(&temp_dsc, &verb_dsc); /* prepend the VERB */ |
| 684 |
len_arg += verb_dsc.dsc$w_length; /* update the length */ |
| 685 |
temp_dsc.dsc$a_pointer[len_arg] = '\0'; /* terminate the string */ |
| 686 |
gargv = &temp_dsc.dsc$a_pointer; /* point to the buffer */ |
| 687 |
gargc = 1; /* only one big argv */ |
| 688 |
#else |
| 689 |
progname = argv[0]; |
| 690 |
gargv = argv; |
| 691 |
gargc = argc; |
| 692 |
/* we sneak a look at the first arg in case it's debugging */ |
| 693 |
#ifdef DEBUG |
| 694 |
if (argc > 1 && strncmp(argv[1], "-d", 2)==0) { |
| 695 |
if (argv[1][2]==0 && argc > 2) { |
| 696 |
if (sscanf(argv[2], "%d", &debug_flag)==0) |
| 697 |
debug_flag = 0; |
| 698 |
} else { |
| 699 |
if (sscanf(argv[1]+2, "%d", &debug_flag)==0) |
| 700 |
debug_flag = 0; |
| 701 |
} |
| 702 |
} |
| 703 |
#if defined(KPATHSEA) && defined(KPSE_DEBUG) |
| 704 |
if (dd(D_FILES)) KPSE_DEBUG_SET (KPSE_DEBUG_FOPEN); |
| 705 |
if (dd(D_PATHS)) KPSE_DEBUG_SET (KPSE_DEBUG_PATHS); |
| 706 |
if (dd(D_STAT)) KPSE_DEBUG_SET (KPSE_DEBUG_STAT); |
| 707 |
if (dd(D_HASH)) KPSE_DEBUG_SET (KPSE_DEBUG_HASH); |
| 708 |
if (dd(D_EXPAND)) KPSE_DEBUG_SET (KPSE_DEBUG_EXPAND); |
| 709 |
if (dd(D_SEARCH)) KPSE_DEBUG_SET (KPSE_DEBUG_SEARCH); |
| 710 |
#endif /* KPATHSEA && KPSE_DEBUG */ |
| 711 |
#endif /* DEBUG */ |
| 712 |
#endif /* VMS */ |
| 713 |
dvips_debug_flag = 0; |
| 714 |
{ /* for compilers incompatible with c99 */ |
| 715 |
char *s = getenv ("DVIPSDEBUG"); |
| 716 |
if (s) { |
| 717 |
dvips_debug_flag = 1; |
| 718 |
} else { |
| 719 |
s = getenv ("KPATHSEA_DEBUG"); |
| 720 |
if (s) { |
| 721 |
dvips_debug_flag = 1; |
| 722 |
} |
| 723 |
} |
| 724 |
} |
| 725 |
initialize(); |
| 726 |
checkenv(0); |
| 727 |
getdefaults(CONFIGFILE); |
| 728 |
getdefaults((char *)0); |
| 729 |
/* |
| 730 |
* This next whole big section of code is straightforward; we just scan |
| 731 |
* the options. An argument can either immediately follow its option letter |
| 732 |
* or be separated by spaces. Any argument not preceded by '-' and an |
| 733 |
* option letter is considered a file name; the program complains if more |
| 734 |
* than one file name is given, and uses stdin if none is given. |
| 735 |
*/ |
| 736 |
#ifdef VMS |
| 737 |
vmscli(void); |
| 738 |
papsizes = (struct papsiz *)revlist((void *)papsizes); /* Added by PWD 21-Mar-1997 */ |
| 739 |
#else |
| 740 |
queryoptions = 0; |
| 741 |
do |
| 742 |
{ |
| 743 |
for (i=1; i<argc; i++) { |
| 744 |
if (*argv[i]=='-') { |
| 745 |
char *p=argv[i]+2; |
| 746 |
char c=argv[i][1]; |
| 747 |
switch (c) { |
| 748 |
case '-': |
| 749 |
queryoptions = 1; |
| 750 |
break; |
| 751 |
case 'a': |
| 752 |
dopprescan = (*p != '0'); |
| 753 |
break; |
| 754 |
case 'b': |
| 755 |
if (strcmp(p, "itmapfontenc") == 0) { |
| 756 |
p = argv[++i] ; |
| 757 |
if (strcmp(p, "off") == 0) { |
| 758 |
bitmapencopt(0) ; // disable bitmap font enc feature |
| 759 |
} else if (strcmp(p, "on") == 0) { |
| 760 |
bitmapencopt(1) ; // try to include bitmap font encs |
| 761 |
} else if (strcmp(p, "strict") == 0) { |
| 762 |
bitmapencopt(2) ; // issue warnings for missing encs |
| 763 |
} else { |
| 764 |
error( |
| 765 |
"! -bitmapfontenc option only supports off, on, and strict") ; |
| 766 |
} |
| 767 |
break ; |
| 768 |
} |
| 769 |
if (*p == 0 && argv[i+1]) |
| 770 |
p = argv[++i]; |
| 771 |
if (sscanf(p, "%d", &pagecopies)==0) |
| 772 |
error("! Bad number of page copies option (-b)."); |
| 773 |
if (pagecopies < 1 || pagecopies > 1000) |
| 774 |
error("! can only print one to a thousand page copies"); |
| 775 |
break; |
| 776 |
case 'c' : |
| 777 |
if (*p == 0 && argv[i+1]) |
| 778 |
p = argv[++i]; |
| 779 |
if (sscanf(p, "%d", &numcopies)==0) |
| 780 |
error("! Bad number of copies option (-c)."); |
| 781 |
break; |
| 782 |
case 'd' : |
| 783 |
#ifdef DEBUG |
| 784 |
{ |
| 785 |
int old_debug = debug_flag; |
| 786 |
static int warned_already = 0; |
| 787 |
|
| 788 |
if (*p == 0 && argv[i+1]) |
| 789 |
p = argv[++i]; |
| 790 |
if (sscanf(p, "%d", &debug_flag)==0) |
| 791 |
error("! Bad debug option (-d)."); |
| 792 |
if (debug_flag != old_debug && warned_already++ == 0) { |
| 793 |
fprintf(stderr, |
| 794 |
"I found a debug option that was not the first argument to the dvips\n"); |
| 795 |
fprintf(stderr, |
| 796 |
"command. Some debugging output may have been lost because of this.\n"); |
| 797 |
} |
| 798 |
break; |
| 799 |
} |
| 800 |
#else |
| 801 |
error("not compiled in debug mode"); |
| 802 |
break; |
| 803 |
#endif /* DEBUG */ |
| 804 |
case 'e' : |
| 805 |
if (*p == 0 && argv[i+1]) |
| 806 |
p = argv[++i]; |
| 807 |
if (sscanf(p, "%d", &maxdrift)==0 || maxdrift<0) |
| 808 |
error("! Bad maxdrift option (-e)."); |
| 809 |
vmaxdrift = maxdrift; |
| 810 |
break; |
| 811 |
case 'f' : |
| 812 |
filter = (*p != '0'); |
| 813 |
if (filter) |
| 814 |
oname = ""; |
| 815 |
noenv = 1; |
| 816 |
sendcontrolD = 0; |
| 817 |
break; |
| 818 |
case 'u' : |
| 819 |
{ |
| 820 |
char PSname[300]; |
| 821 |
if (*p == 0 && argv[i+1]) |
| 822 |
p = argv[++i]; |
| 823 |
strcpy(PSname, p); |
| 824 |
if (!strchr(PSname, '.')) |
| 825 |
strcat(PSname, ".map"); /* default extension */ |
| 826 |
if (PSname[0] == '+') |
| 827 |
getpsinfo(PSname+1); |
| 828 |
else |
| 829 |
psmapfile = strdup(PSname); /* a cute small memory leak (just as in 'p' option handling in resident.c) */ |
| 830 |
} |
| 831 |
break; |
| 832 |
case 'h' : case 'H' : |
| 833 |
if (*p == 0 && argv[i+1]) |
| 834 |
p = argv[++i]; |
| 835 |
if (strcmp(p, "-") == 0) |
| 836 |
headers_off = 1; |
| 837 |
else |
| 838 |
add_header(p); |
| 839 |
break; |
| 840 |
case 'i': |
| 841 |
sepfiles = (*p != '0'); |
| 842 |
if (sepfiles && maxsecsize == 0) { |
| 843 |
maxsecsize = 1; /* default section size to one page/file */ |
| 844 |
} |
| 845 |
break; |
| 846 |
case 'j': |
| 847 |
partialdownload = (*p != '0'); |
| 848 |
break; |
| 849 |
case 'k': |
| 850 |
cropmarks = (*p != '0'); |
| 851 |
break; |
| 852 |
case 'R': |
| 853 |
if (*p == '0') { |
| 854 |
secure = 0; |
| 855 |
} else if (*p == '2') { |
| 856 |
secure = 2; |
| 857 |
} else { |
| 858 |
secure = 1; |
| 859 |
} |
| 860 |
if (secure) |
| 861 |
secure_option = 1; /* Never used */ |
| 862 |
break; |
| 863 |
case 'S': |
| 864 |
if (*p == 0 && argv[i+1]) |
| 865 |
p = argv[++i]; |
| 866 |
if (sscanf(p, "%d", &maxsecsize)==0) |
| 867 |
error("! Bad section size arg (-S)."); |
| 868 |
break; |
| 869 |
case 'm' : |
| 870 |
if (STREQ (p, "ode") && argv[i+1]) { |
| 871 |
mfmode = argv[++i]; |
| 872 |
mfmode_option = 1; |
| 873 |
} else |
| 874 |
manualfeed = (*p != '0'); |
| 875 |
break; |
| 876 |
case 'n' : |
| 877 |
if (STREQ (p, "oomega")) { |
| 878 |
noomega = 1; |
| 879 |
} else if (STREQ (p, "optex")) { |
| 880 |
noptex = 1; |
| 881 |
} else { |
| 882 |
if (*p == 0 && argv[i+1]) |
| 883 |
p = argv[++i]; |
| 884 |
#ifdef SHORTINT |
| 885 |
if (sscanf(p, "%ld", &maxpages)==0) |
| 886 |
#else /* ~SHORTINT */ |
| 887 |
if (sscanf(p, "%d", &maxpages)==0) |
| 888 |
#endif /* ~SHORTINT */ |
| 889 |
error("! Bad number of pages option (-n)."); |
| 890 |
} |
| 891 |
break; |
| 892 |
case 'o' : |
| 893 |
if (*p == 0 && argv[i+1] && |
| 894 |
(STREQ (argv[i+1], "-") || argv[i+1][0] != '-')) |
| 895 |
p = argv[++i]; |
| 896 |
oname_option = 1; |
| 897 |
oname = p; |
| 898 |
noenv = 1; |
| 899 |
sendcontrolD = 0; |
| 900 |
#if defined(MSDOS) || defined(OS2) |
| 901 |
if (*oname && oname[strlen(oname)-1] == ':') |
| 902 |
oname[strlen(oname)-1] = 0; /* strip ':' off */ |
| 903 |
#endif |
| 904 |
break; |
| 905 |
case 'O' : |
| 906 |
if (*p == 0 && argv[i+1]) |
| 907 |
p = argv[++i]; |
| 908 |
handlepapersize(p, &hoff, &voff); |
| 909 |
break; |
| 910 |
case 'T' : |
| 911 |
if (*p == 0 && argv[i+1]) |
| 912 |
p = argv[++i]; |
| 913 |
handlepapersize(p, &hpapersize, &vpapersize); |
| 914 |
if (landscape) { |
| 915 |
error( |
| 916 |
"both landscape and papersize specified; ignoring landscape"); |
| 917 |
landscape = 0; |
| 918 |
} |
| 919 |
lastpsizwins = 0; |
| 920 |
break; |
| 921 |
case 'p' : |
| 922 |
#if defined(MSDOS) || defined(OS2) || defined(ATARIST) |
| 923 |
/* check for emTeX job file (-pj=filename) */ |
| 924 |
if (*p == 'j') { |
| 925 |
p++; |
| 926 |
if (*p == '=' || *p == ':') |
| 927 |
p++; |
| 928 |
mfjobname = newstring(p); |
| 929 |
break; |
| 930 |
} |
| 931 |
/* must be page number instead */ |
| 932 |
#endif |
| 933 |
if (*p == 'p') { /* a -pp specifier for a page list? */ |
| 934 |
p++; |
| 935 |
if (*p == 0 && argv[i+1]) |
| 936 |
p = argv[++i]; |
| 937 |
if (ParsePages(p)) |
| 938 |
error("! Bad page list specifier (-pp)."); |
| 939 |
pagelist = 1; |
| 940 |
break; |
| 941 |
} |
| 942 |
if (*p == 0 && argv[i+1]) |
| 943 |
p = argv[++i]; |
| 944 |
if (*p == '=') { |
| 945 |
abspage = 1; |
| 946 |
p++; |
| 947 |
} |
| 948 |
#ifdef SHORTINT |
| 949 |
switch(sscanf(p, "%ld.%ld", &firstpage, &firstseq)) { |
| 950 |
#else /* ~SHORTINT */ |
| 951 |
switch(sscanf(p, "%d.%d", &firstpage, &firstseq)) { |
| 952 |
#endif /* ~SHORTINT */ |
| 953 |
case 1: firstseq = 0; |
| 954 |
case 2: break; |
| 955 |
default: |
| 956 |
#ifdef KPATHSEA |
| 957 |
error(concat3 ("! Bad first page option (-p ", p, ").")); |
| 958 |
#else |
| 959 |
error("! Bad first page option (-p)."); |
| 960 |
#endif |
| 961 |
} |
| 962 |
notfirst = 1; |
| 963 |
break; |
| 964 |
case 'l': |
| 965 |
if (strncmp(p, "andscaperotate", 14) == 0) { |
| 966 |
p += 14 ; |
| 967 |
if (*p == 0 || *p == '1') { |
| 968 |
landscaperotate = 1 ; |
| 969 |
} else if (*p == '0') { |
| 970 |
landscaperotate = 0 ; |
| 971 |
} else { |
| 972 |
error("! -landscaperotate command ended with junk") ; |
| 973 |
} |
| 974 |
} else { |
| 975 |
if (*p == 0 && argv[i+1]) |
| 976 |
p = argv[++i]; |
| 977 |
if (*p == '=') { |
| 978 |
abspage = 1; |
| 979 |
p++; |
| 980 |
} |
| 981 |
#ifdef SHORTINT |
| 982 |
switch(sscanf(p, "%ld.%ld", &lastpage, &lastseq)) { |
| 983 |
#else /* ~SHORTINT */ |
| 984 |
switch(sscanf(p, "%d.%d", &lastpage, &lastseq)) { |
| 985 |
#endif /* ~SHORTINT */ |
| 986 |
case 1: lastseq = 0; |
| 987 |
case 2: break; |
| 988 |
default: |
| 989 |
#ifdef KPATHSEA |
| 990 |
error(concat3 ("! Bad last page option (-l ", p, ").")); |
| 991 |
#else |
| 992 |
error("! Bad last page option (-l)."); |
| 993 |
#endif |
| 994 |
} |
| 995 |
notlast = 1; |
| 996 |
} |
| 997 |
break; |
| 998 |
case 'A': |
| 999 |
oddpages = 1; |
| 1000 |
break; |
| 1001 |
case 'B': |
| 1002 |
evenpages = 1; |
| 1003 |
break; |
| 1004 |
case 'q' : case 'Q' : |
| 1005 |
quiet = (*p != '0'); |
| 1006 |
break; |
| 1007 |
case 'r' : |
| 1008 |
reverse = (*p != '0'); |
| 1009 |
break; |
| 1010 |
case 't' : |
| 1011 |
if (STREQ (p, "itle") && argv[i+1]) { |
| 1012 |
titlename = argv[++i]; |
| 1013 |
} else { |
| 1014 |
if (*p == 0 && argv[i+1]) |
| 1015 |
p = argv[++i]; |
| 1016 |
if (strcmp(p, "landscape") == 0) { |
| 1017 |
if (hpapersize || vpapersize) |
| 1018 |
error("both landscape and papersize specified; ignoring landscape"); |
| 1019 |
else |
| 1020 |
landscape = 1; |
| 1021 |
} else |
| 1022 |
paperfmt = p; |
| 1023 |
} |
| 1024 |
break; |
| 1025 |
case 'v': |
| 1026 |
printf ("%s %s\n", banner, banner2); |
| 1027 |
exit (0); |
| 1028 |
break; |
| 1029 |
case 'x' : case 'y' : |
| 1030 |
if (*p == 0 && argv[i+1]) |
| 1031 |
p = argv[++i]; |
| 1032 |
if (sscanf(p, "%lg", &mag)==0 || mag < 1 || |
| 1033 |
mag > 1000000) |
| 1034 |
error("! Bad magnification parameter (-x or -y)."); |
| 1035 |
overridemag = (c == 'x' ? 1 : -1); |
| 1036 |
break; |
| 1037 |
case 'C' : |
| 1038 |
if (*p == 0 && argv[i+1]) |
| 1039 |
p = argv[++i]; |
| 1040 |
if (sscanf(p, "%d", &collatedcopies)==0) |
| 1041 |
error("! Bad number of collated copies option (-C)."); |
| 1042 |
break; |
| 1043 |
case 'D' : |
| 1044 |
if (*p == 0 && argv[i+1]) |
| 1045 |
p = argv[++i]; |
| 1046 |
if (sscanf(p, "%d", &actualdpi)==0 || actualdpi < 10 || |
| 1047 |
actualdpi > 10000) |
| 1048 |
error("! Bad dpi parameter (-D)."); |
| 1049 |
vactualdpi = actualdpi; |
| 1050 |
/* If we had the mode from config.ps, don't use it. |
| 1051 |
If they specified one with -mode, keep it. */ |
| 1052 |
if (!mfmode_option) |
| 1053 |
mfmode = NULL; |
| 1054 |
break; |
| 1055 |
case 'E' : |
| 1056 |
tryepsf = (*p != '0'); |
| 1057 |
removecomments = disablecomments = 0; |
| 1058 |
if (tryepsf && maxsecsize == 0) |
| 1059 |
maxsecsize = 1; |
| 1060 |
break; |
| 1061 |
case 'K' : |
| 1062 |
removecomments = (*p != '0'); |
| 1063 |
break; |
| 1064 |
case 'L' : |
| 1065 |
lastpsizwins = (*p != '0'); |
| 1066 |
break; |
| 1067 |
case 'U' : |
| 1068 |
nosmallchars = (*p != '0'); |
| 1069 |
break; |
| 1070 |
case 'X' : |
| 1071 |
if (*p == 0 && argv[i+1]) |
| 1072 |
p = argv[++i]; |
| 1073 |
if (sscanf(p, "%d", &actualdpi)==0 || actualdpi < 10 || |
| 1074 |
actualdpi > 10000) |
| 1075 |
error("! Bad dpi parameter (-D)."); |
| 1076 |
break; |
| 1077 |
case 'Y' : |
| 1078 |
if (*p == 0 && argv[i+1]) |
| 1079 |
p = argv[++i]; |
| 1080 |
if (sscanf(p, "%d", &vactualdpi)==0 || vactualdpi < 10 || |
| 1081 |
vactualdpi > 10000) |
| 1082 |
error("! Bad dpi parameter (-D)."); |
| 1083 |
vactualdpi = vactualdpi; |
| 1084 |
break; |
| 1085 |
case 'F' : |
| 1086 |
sendcontrolD = (*p != '0'); |
| 1087 |
break; |
| 1088 |
case 'G' : |
| 1089 |
shiftlowchars = (*p != '0'); |
| 1090 |
break; |
| 1091 |
case 'M': |
| 1092 |
dontmakefont = (*p != '0'); |
| 1093 |
#ifdef KPATHSEA |
| 1094 |
kpse_set_program_enabled (kpse_pk_format, !dontmakefont, |
| 1095 |
kpse_src_cmdline); |
| 1096 |
#endif |
| 1097 |
break; |
| 1098 |
case 'N' : |
| 1099 |
disablecomments = (*p != '0'); |
| 1100 |
break; |
| 1101 |
case 'P' : |
| 1102 |
{ |
| 1103 |
struct papsiz *opapsiz = papsizes; |
| 1104 |
struct papsiz *npapsiz; |
| 1105 |
papsizes = 0; |
| 1106 |
if (*p == 0 && argv[i+1]) |
| 1107 |
p = argv[++i]; |
| 1108 |
printer = p; |
| 1109 |
noenv = 1; |
| 1110 |
if (!getdefaults("")) { |
| 1111 |
/* If no config file, default the output name. */ |
| 1112 |
oname = concat ("| lpr -P", printer); |
| 1113 |
} |
| 1114 |
npapsiz = opapsiz; |
| 1115 |
while (npapsiz && npapsiz->next) |
| 1116 |
npapsiz = npapsiz->next; |
| 1117 |
if (npapsiz) { |
| 1118 |
npapsiz->next = papsizes; |
| 1119 |
papsizes = opapsiz; |
| 1120 |
} |
| 1121 |
} |
| 1122 |
break; |
| 1123 |
case 's': |
| 1124 |
safetyenclose = (*p != '0'); |
| 1125 |
break; |
| 1126 |
case 'V': |
| 1127 |
downloadpspk = (*p != '0'); |
| 1128 |
break; |
| 1129 |
case 'Z': |
| 1130 |
compressed = (*p != '0'); |
| 1131 |
break; |
| 1132 |
#ifdef HPS |
| 1133 |
case 'z': |
| 1134 |
HPS_FLAG = (*p != '0'); |
| 1135 |
break; |
| 1136 |
#endif |
| 1137 |
case '?': |
| 1138 |
break; /* We print the banner and help msg below. */ |
| 1139 |
default: |
| 1140 |
#ifdef KPATHSEA |
| 1141 |
error(concat3 ("! Invalid option `", argv[i], |
| 1142 |
"'. Try --help for more information.")); |
| 1143 |
#else |
| 1144 |
error( |
| 1145 |
"! Bad option, not one of acdefhijklmnopqrstxyzABCDEFKMNOPSTUXYZ?"); |
| 1146 |
#endif |
| 1147 |
} |
| 1148 |
} else { |
| 1149 |
if (*iname == 0) { |
| 1150 |
register char *p; |
| 1151 |
|
| 1152 |
lastext = 0; |
| 1153 |
iname = nextstring; |
| 1154 |
p = argv[i]; |
| 1155 |
if (NAME_BEGINS_WITH_DEVICE(p)) { /* get past DOSISH drive */ |
| 1156 |
*nextstring++ = *p++; |
| 1157 |
*nextstring++ = *p++; |
| 1158 |
} |
| 1159 |
while (*p) { |
| 1160 |
*nextstring = *p++; |
| 1161 |
if (*nextstring == '.') |
| 1162 |
lastext = nextstring - iname; |
| 1163 |
else if (IS_DIR_SEP(*nextstring)) |
| 1164 |
lastext = 0; |
| 1165 |
#ifdef WIN32 |
| 1166 |
else if (IS_KANJI(p-1)) { |
| 1167 |
nextstring++; |
| 1168 |
*nextstring = *p++; |
| 1169 |
} |
| 1170 |
#endif |
| 1171 |
nextstring++; |
| 1172 |
} |
| 1173 |
*nextstring++ = '.'; |
| 1174 |
*nextstring++ = 'd'; |
| 1175 |
*nextstring++ = 'v'; |
| 1176 |
*nextstring++ = 'i'; |
| 1177 |
*nextstring++ = 0; |
| 1178 |
} else |
| 1179 |
#ifdef KPATHSEA |
| 1180 |
error(concat3("! Second input filename (", argv[i], |
| 1181 |
") specified.")); |
| 1182 |
#else |
| 1183 |
error("! Two input file names specified."); |
| 1184 |
#endif |
| 1185 |
} |
| 1186 |
} |
| 1187 |
if (noenv == 0) { |
| 1188 |
register char *p; |
| 1189 |
struct papsiz *opapsiz = papsizes; |
| 1190 |
papsizes = 0; |
| 1191 |
if (0 != (p = getenv("PRINTER"))) { |
| 1192 |
#if defined(MSDOS) || defined(OS2) |
| 1193 |
strcpy(nextstring, p); |
| 1194 |
strcat(nextstring, ".cfg"); |
| 1195 |
#else |
| 1196 |
strcpy(nextstring, "config."); |
| 1197 |
strcat(nextstring, p); |
| 1198 |
#endif |
| 1199 |
getdefaults(nextstring); |
| 1200 |
} |
| 1201 |
{ |
| 1202 |
struct papsiz *npapsiz = opapsiz; |
| 1203 |
while (npapsiz && npapsiz->next) |
| 1204 |
npapsiz = npapsiz->next; |
| 1205 |
if (npapsiz) { |
| 1206 |
npapsiz->next = papsizes; |
| 1207 |
papsizes = opapsiz; |
| 1208 |
} |
| 1209 |
} |
| 1210 |
} |
| 1211 |
papsizes = (struct papsiz *)revlist((void *)papsizes); |
| 1212 |
if (queryoptions != 0) { /* get new options */ |
| 1213 |
fprintf(stderr, "%s %s\n", banner, banner2); |
| 1214 |
help(1); |
| 1215 |
queryargs(); |
| 1216 |
if (qargc == 1) |
| 1217 |
queryoptions = 0; |
| 1218 |
else { |
| 1219 |
qargv[0] = argv[0]; |
| 1220 |
argc=qargc; |
| 1221 |
argv=qargv; |
| 1222 |
} |
| 1223 |
} |
| 1224 |
} while (queryoptions != 0); |
| 1225 |
#endif |
| 1226 |
#if defined(KPATHSEA) && defined(KPSE_DEBUG) && defined(DEBUG) /* this should really be part of a subroutine */ |
| 1227 |
if (dd(D_FILES)) KPSE_DEBUG_SET (KPSE_DEBUG_FOPEN); |
| 1228 |
if (dd(D_PATHS)) KPSE_DEBUG_SET (KPSE_DEBUG_PATHS); |
| 1229 |
if (dd(D_STAT)) KPSE_DEBUG_SET (KPSE_DEBUG_STAT); |
| 1230 |
if (dd(D_HASH)) KPSE_DEBUG_SET (KPSE_DEBUG_HASH); |
| 1231 |
if (dd(D_EXPAND)) KPSE_DEBUG_SET (KPSE_DEBUG_EXPAND); |
| 1232 |
if (dd(D_SEARCH)) KPSE_DEBUG_SET (KPSE_DEBUG_SEARCH); |
| 1233 |
#endif /* KPATHSEA && KPSE_DEBUG && DEBUG */ |
| 1234 |
checkenv(1); |
| 1235 |
#ifdef KPATHSEA |
| 1236 |
kpse_init_prog ("DVIPS", actualdpi, mfmode, "cmr10"); |
| 1237 |
kpse_make_tex_discard_errors = quiet; |
| 1238 |
#endif |
| 1239 |
/* |
| 1240 |
* The logic here is a bit convoluted. Since all `additional' |
| 1241 |
* PostScript font information files are loaded *before* the master |
| 1242 |
* one, and yet they should be able to override the master one, we |
| 1243 |
* have to add the information in the master list to the *ends* of |
| 1244 |
* the hash chain. We do this by reversing the lists, adding them |
| 1245 |
* to the front, and then reversing them again. |
| 1246 |
*/ |
| 1247 |
revpslists(); |
| 1248 |
getpsinfo((char *)NULL); |
| 1249 |
revpslists(); |
| 1250 |
if (dvips_debug_flag) { |
| 1251 |
if (!quiet) |
| 1252 |
fprintf(stderr, "\n%s %s\n", banner, banner2); |
| 1253 |
prettycolumn = 0; |
| 1254 |
} else { |
| 1255 |
if (!quiet) |
| 1256 |
fprintf(stderr, "%s %s\n", banner, banner2); |
| 1257 |
} |
| 1258 |
if (*iname) { |
| 1259 |
dvifile = fopen(iname, READBIN); |
| 1260 |
/* |
| 1261 |
* Allow names like a.b. |
| 1262 |
*/ |
| 1263 |
if (dvifile == 0) { |
| 1264 |
iname[strlen(iname)-4] = 0; /* remove the .dvi suffix */ |
| 1265 |
dvifile = fopen(iname, READBIN); |
| 1266 |
} |
| 1267 |
} |
| 1268 |
if (oname[0] == '-' && oname[1] == 0) |
| 1269 |
oname = ""; |
| 1270 |
else if (*oname == 0 && ! filter && *iname) { |
| 1271 |
/* determine output name from input name */ |
| 1272 |
oname = nextstring; |
| 1273 |
#ifndef VMCMS /* get stuff before LAST "." */ |
| 1274 |
lastext = strlen(iname) - 1; |
| 1275 |
while (iname[lastext] != '.' && lastext > 0) |
| 1276 |
lastext--; |
| 1277 |
if (iname[lastext] != '.') |
| 1278 |
lastext = strlen(iname) - 1; |
| 1279 |
#else /* for VM/CMS we take the stuff before FIRST "." */ |
| 1280 |
lastext = strchr(iname,'.') - iname; |
| 1281 |
if ( lastext <= 0 ) /* if no '.' in "iname" */ |
| 1282 |
lastext = strlen(iname) -1; |
| 1283 |
#endif |
| 1284 |
#ifdef MVSXA /* IBM: MVS/XA */ |
| 1285 |
if (strchr(iname, '(') != NULL && |
| 1286 |
strchr(iname, ')') != NULL) { |
| 1287 |
firstext = strchr(iname, '(') - iname + 1; |
| 1288 |
lastext = strrchr(iname, ')') - iname - 1; |
| 1289 |
} |
| 1290 |
else { |
| 1291 |
if (strrchr(iname, '.') != NULL) { |
| 1292 |
lastext = strrchr(iname, '.') - iname - 1; |
| 1293 |
} |
| 1294 |
else lastext = strlen(iname) - 1; |
| 1295 |
if (strchr(iname, '\'') != NULL) |
| 1296 |
firstext = strchr(iname, '.') - iname + 1; |
| 1297 |
else firstext = 0; |
| 1298 |
} |
| 1299 |
#endif /* IBM: MVS/XA */ |
| 1300 |
#ifdef MVSXA /* IBM: MVS/XA */ |
| 1301 |
for (i=firstext; i<=lastext; i++) |
| 1302 |
#else |
| 1303 |
for (i=0; i<=lastext; i++) |
| 1304 |
#endif |
| 1305 |
*nextstring++ = iname[i]; |
| 1306 |
if (iname[lastext] != '.') |
| 1307 |
*nextstring++ = '.'; |
| 1308 |
#ifndef VMCMS |
| 1309 |
*nextstring++ = 'p'; |
| 1310 |
*nextstring++ = 's'; |
| 1311 |
#else /* might as well keep things uppercase */ |
| 1312 |
*nextstring++ = 'P'; |
| 1313 |
*nextstring++ = 'S'; |
| 1314 |
#endif |
| 1315 |
*nextstring++ = 0; |
| 1316 |
/* |
| 1317 |
* Now we check the name, and `throw away' any prefix information. |
| 1318 |
* This means throwing away anything before (and including) a colon |
| 1319 |
* or slash. |
| 1320 |
*/ |
| 1321 |
{ |
| 1322 |
const char *p = NAME_BEGINS_WITH_DEVICE(oname) ? oname + 2 : oname; |
| 1323 |
|
| 1324 |
for (oname=p; *p && p[1]; p++) |
| 1325 |
if (IS_DIR_SEP(*p)) |
| 1326 |
oname = p + 1; |
| 1327 |
#ifdef WIN32 |
| 1328 |
else if (IS_KANJI(p)) |
| 1329 |
p++; |
| 1330 |
#endif |
| 1331 |
} |
| 1332 |
} |
| 1333 |
#ifdef DEBUG |
| 1334 |
if (dd(D_PATHS)) { |
| 1335 |
#ifdef SHORTINT |
| 1336 |
fprintf_str(stderr,"input file %s output file %s swmem %ld\n", |
| 1337 |
#else /* ~SHORTINT */ |
| 1338 |
fprintf_str(stderr,"input file %s output file %s swmem %d\n", |
| 1339 |
#endif /* ~SHORTINT */ |
| 1340 |
iname, oname, swmem); |
| 1341 |
#ifndef KPATHSEA |
| 1342 |
fprintf_str(stderr,"tfm path %s\npk path %s\n", tfmpath, pkpath); |
| 1343 |
fprintf_str(stderr,"fig path %s\nvf path %s\n", figpath, vfpath); |
| 1344 |
fprintf_str(stderr,"config path %s\nheader path %s\n", |
| 1345 |
configpath, headerpath); |
| 1346 |
#endif |
| 1347 |
#ifdef FONTLIB |
| 1348 |
fprintf_str(stderr,"fli path %s\nfli names %s\n", flipath, fliname); |
| 1349 |
#endif |
| 1350 |
} /* dd(D_PATHS) */ |
| 1351 |
#endif /* DEBUG */ |
| 1352 |
|
| 1353 |
/* |
| 1354 |
* Check if oname != iname |
| 1355 |
*/ |
| 1356 |
if (iname && *iname && oname && *oname) { |
| 1357 |
#ifdef DOSISH |
| 1358 |
if (strcasecmp (iname, oname) == 0) { |
| 1359 |
#else |
| 1360 |
if (strcmp (iname, oname) == 0) { |
| 1361 |
#endif |
| 1362 |
fprintf (stderr, "! Output name should be different from input name.\n"); |
| 1363 |
exit (20); |
| 1364 |
} |
| 1365 |
} |
| 1366 |
/* |
| 1367 |
* Now we try to open the dvi file. |
| 1368 |
*/ |
| 1369 |
if (!quiet && warningmsg) |
| 1370 |
error(warningmsg); |
| 1371 |
headersready = 1; |
| 1372 |
headerfile = (compressed? CHEADERFILE : HEADERFILE); |
| 1373 |
add_header(headerfile); |
| 1374 |
if (*iname != 0) { |
| 1375 |
fulliname = nextstring; |
| 1376 |
#ifndef IGNORE_CWD |
| 1377 |
if (!IS_DIR_SEP(*iname) && !NAME_BEGINS_WITH_DEVICE(iname)) { |
| 1378 |
getcwd(nextstring, MAXPATHLEN + 2); |
| 1379 |
while (*nextstring++); |
| 1380 |
#ifdef VMS /* VMS doesn't need the '/' character appended */ |
| 1381 |
nextstring--; /* so just back up one byte. */ |
| 1382 |
#else |
| 1383 |
*(nextstring-1) = '/'; |
| 1384 |
#endif |
| 1385 |
} |
| 1386 |
#endif |
| 1387 |
strcpy(nextstring,iname); |
| 1388 |
while (*nextstring++); /* advance nextstring past iname */ |
| 1389 |
} else if (filter) { |
| 1390 |
dvifile = stdin; |
| 1391 |
if (O_BINARY && !isatty(fileno(stdin))) |
| 1392 |
SET_BINARY(fileno(stdin)); |
| 1393 |
} else { |
| 1394 |
#ifdef KPATHSEA |
| 1395 |
fprintf (stderr, "dvips: Missing DVI file argument (or -f).\n"); |
| 1396 |
fprintf (stderr, "dvips: Try --help for more information.\n"); |
| 1397 |
#else |
| 1398 |
help(1); |
| 1399 |
#endif |
| 1400 |
exit(1); |
| 1401 |
} |
| 1402 |
if (dvifile==NULL) { |
| 1403 |
error_with_perror("DVI file can't be opened:", iname); |
| 1404 |
exit(1); |
| 1405 |
} |
| 1406 |
if (fseek(dvifile, 0L, 0) < 0) |
| 1407 |
error("! DVI file must not be a pipe."); |
| 1408 |
|
| 1409 |
initcolor(); |
| 1410 |
#ifdef FONTLIB |
| 1411 |
fliload(); /* read the font libaries */ |
| 1412 |
#endif |
| 1413 |
/* |
| 1414 |
* Now we do our main work. |
| 1415 |
*/ |
| 1416 |
swmem += fontmem; |
| 1417 |
if (maxdrift < 0) { |
| 1418 |
if (actualdpi <= 599) |
| 1419 |
maxdrift = actualdpi / 100; |
| 1420 |
else if (actualdpi < 1199) |
| 1421 |
maxdrift = actualdpi / 200 + 3; |
| 1422 |
else |
| 1423 |
maxdrift = actualdpi / 400 + 6; |
| 1424 |
} |
| 1425 |
if (vmaxdrift < 0) { |
| 1426 |
if (vactualdpi <= 599) |
| 1427 |
vmaxdrift = vactualdpi / 100; |
| 1428 |
else if (vactualdpi < 1199) |
| 1429 |
vmaxdrift = vactualdpi / 200 + 3; |
| 1430 |
else |
| 1431 |
vmaxdrift = vactualdpi / 400 + 6; |
| 1432 |
} |
| 1433 |
if (dopprescan) |
| 1434 |
pprescanpages(); |
| 1435 |
prescanpages(); |
| 1436 |
#if defined MSDOS || defined OS2 || defined(ATARIST) |
| 1437 |
if (mfjobfile != (FILE*)NULL) { |
| 1438 |
char answer[5]; |
| 1439 |
fputs("}\n",mfjobfile); |
| 1440 |
fclose(mfjobfile); |
| 1441 |
fputs("Exit to make missing fonts now (y/n)? ",stdout); |
| 1442 |
fgets(answer,4,stdin); |
| 1443 |
if (*answer=='y' || *answer=='Y') |
| 1444 |
exit(8); /* exit with errorlevel 8 for emTeX dvidrv */ |
| 1445 |
} |
| 1446 |
#endif |
| 1447 |
if (includesfonts) |
| 1448 |
add_header(IFONTHEADER); |
| 1449 |
if (usesPSfonts) |
| 1450 |
add_header(PSFONTHEADER); |
| 1451 |
if (usesspecial) |
| 1452 |
add_header(SPECIALHEADER); |
| 1453 |
if (usescolor) /* IBM: color */ |
| 1454 |
add_header(COLORHEADER); |
| 1455 |
#ifdef HPS |
| 1456 |
if (HPS_FLAG) |
| 1457 |
add_header(HPSHEADER); |
| 1458 |
#endif |
| 1459 |
sects = sections; |
| 1460 |
totalpages *= collatedcopies; |
| 1461 |
if (sects == NULL || sects->next == NULL) { |
| 1462 |
sectioncopies = collatedcopies; |
| 1463 |
collatedcopies = 1; |
| 1464 |
} else { |
| 1465 |
if (! sepfiles) |
| 1466 |
multiplesects = 1; |
| 1467 |
} |
| 1468 |
totalpages *= pagecopies; |
| 1469 |
if (tryepsf) { |
| 1470 |
if (paperfmt || landscape || manualfeed || |
| 1471 |
collatedcopies > 1 || numcopies > 1 || cropmarks || |
| 1472 |
*iname == 0 || |
| 1473 |
(totalpages > 1 && !(sepfiles && maxsecsize == 1))) { |
| 1474 |
error("Can't make it EPSF, sorry"); |
| 1475 |
tryepsf = 0; |
| 1476 |
} |
| 1477 |
} |
| 1478 |
#ifdef HPS |
| 1479 |
if (HPS_FLAG) |
| 1480 |
set_bitfile("head.tmp", 0); |
| 1481 |
#endif |
| 1482 |
if (! sepfiles) { |
| 1483 |
initprinter(sections); |
| 1484 |
outbangspecials(); |
| 1485 |
} |
| 1486 |
|
| 1487 |
for (i=0; i<collatedcopies; i++) { |
| 1488 |
sects = sections; |
| 1489 |
while (sects != NULL) { |
| 1490 |
if (sepfiles) { |
| 1491 |
newoutname(); |
| 1492 |
if (! quiet) { |
| 1493 |
if (prettycolumn + strlen(oname) + 6 > STDOUTSIZE) { |
| 1494 |
fprintf(stderr, "\n"); |
| 1495 |
prettycolumn = 0; |
| 1496 |
} |
| 1497 |
fprintf_str(stderr, "(-> %s) ", oname); |
| 1498 |
prettycolumn += strlen(oname) + 6; |
| 1499 |
} |
| 1500 |
#ifdef HPS |
| 1501 |
if (HPS_FLAG) |
| 1502 |
set_bitfile("head.tmp", 0); |
| 1503 |
#endif |
| 1504 |
initprinter(sects); |
| 1505 |
outbangspecials(); |
| 1506 |
} else if (! quiet) { |
| 1507 |
if (prettycolumn > STDOUTSIZE) { |
| 1508 |
fprintf(stderr, "\n"); |
| 1509 |
prettycolumn = 0; |
| 1510 |
} |
| 1511 |
fprintf(stderr, ". "); |
| 1512 |
prettycolumn += 2; |
| 1513 |
} |
| 1514 |
fflush(stderr); |
| 1515 |
dosection(sects, sectioncopies); |
| 1516 |
sects = sects->next; |
| 1517 |
if (sepfiles) { |
| 1518 |
#ifdef HPS |
| 1519 |
if (HPS_FLAG) |
| 1520 |
finish_hps(); |
| 1521 |
#endif |
| 1522 |
cleanprinter(); |
| 1523 |
} |
| 1524 |
} |
| 1525 |
} |
| 1526 |
freememforpsnames(); |
| 1527 |
if (! sepfiles) { |
| 1528 |
#ifdef HPS |
| 1529 |
if (HPS_FLAG) |
| 1530 |
finish_hps(); |
| 1531 |
#endif |
| 1532 |
cleanprinter(); |
| 1533 |
} |
| 1534 |
if (! quiet) |
| 1535 |
fprintf(stderr, "\n"); |
| 1536 |
#ifdef DEBUG |
| 1537 |
if (dd(D_MEM)) { |
| 1538 |
#ifdef SHORTINT |
| 1539 |
fprintf(stderr, "Total memory allocated: %ld\n", totalalloc); |
| 1540 |
#else |
| 1541 |
fprintf(stderr, "Total memory allocated: %d\n", totalalloc); |
| 1542 |
#endif |
| 1543 |
} |
| 1544 |
#endif |
| 1545 |
return found_problems ? EXIT_FAILURE : EXIT_SUCCESS; |
| 1546 |
/*NOTREACHED*/ |
| 1547 |
} |
| 1548 |
#ifdef VMS |
| 1549 |
#include "[.vms]vmscli.c" |
| 1550 |
#endif |
| 1551 |
|
| 1552 |
#ifdef VMCMS /* IBM: VM/CMS */ |
| 1553 |
#include "dvipscms.h" |
| 1554 |
#endif |
| 1555 |
|
| 1556 |
#ifdef MVSXA /* IBM: MVS/XA */ |
| 1557 |
#include "dvipsmvs.h" |
| 1558 |
#endif |