/*
- * "$Id: pstops.c 6247 2007-02-07 20:54:37Z mike $"
+ * "$Id: pstops.c 6649 2007-07-11 21:46:42Z mike $"
*
* PostScript filter for the Common UNIX Printing System (CUPS).
*
+ * Copyright 2007 by Apple Inc.
* Copyright 1993-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products and are protected by Federal
- * copyright law. Distribution and use rights are outlined in the file
- * "LICENSE.txt" which should have been included with this file. If this
- * file is missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
* This file is subject to the Apple OS-Developed Software exception.
*
#include <math.h>
#include <cups/file.h>
#include <cups/array.h>
+#include <cups/i18n.h>
/*
if (argc < 6 || argc > 7)
{
- fputs("ERROR: pstops job-id user title copies options [file]\n", stderr);
+ fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
+ argv[0]);
return (1);
}
if ((fp = cupsFileOpen(argv[6], "r")) == NULL)
{
- fprintf(stderr, "ERROR: Unable to open print file \"%s\" - %s\n",
+ fprintf(stderr, _("ERROR: Unable to open file \"%s\" - %s\n"),
argv[6], strerror(errno));
return (1);
}
if ((len = cupsFileGetLine(fp, line, sizeof(line))) == 0)
{
- fputs("ERROR: Empty print file!\n", stderr);
+ fputs(_("ERROR: Empty print file!\n"), stderr);
return (1);
}
if (!doc->pages)
{
- fprintf(stderr, "EMERG: Unable to allocate memory for pages array: %s\n",
+ fprintf(stderr, _("EMERG: Unable to allocate memory for pages array: %s\n"),
strerror(errno));
exit(1);
}
if ((pageinfo = calloc(1, sizeof(pstops_page_t))) == NULL)
{
- fprintf(stderr, "EMERG: Unable to allocate memory for page info: %s\n",
+ fprintf(stderr, _("EMERG: Unable to allocate memory for page info: %s\n"),
strerror(errno));
exit(1);
}
if (cupsFileSeek(fp, offset) < 0)
{
- fprintf(stderr, "ERROR: Unable to seek to offset " CUPS_LLFMT
- " in file - %s\n",
+ fprintf(stderr,
+#ifdef HAVE_LONG_LONG
+ _("ERROR: Unable to seek to offset %lld in file - %s\n"),
+#else
+ _("ERROR: Unable to seek to offset %ld in file - %s\n"),
+#endif /* HAVE_LONG_LONG */
CUPS_LLCAST offset, strerror(errno));
return;
}
if (saw_pages)
- fputs("ERROR: Duplicate %%Pages: comment seen!\n", stderr);
+ fputs(_("ERROR: Duplicate %%Pages: comment seen!\n"), stderr);
saw_pages = 1;
else if (!strncmp(line, "%%BoundingBox:", 14))
{
if (saw_bounding_box)
- fputs("ERROR: Duplicate %%BoundingBox: comment seen!\n", stderr);
+ fputs(_("ERROR: Duplicate %%BoundingBox: comment seen!\n"), stderr);
else if (strstr(line + 14, "(atend)"))
{
/*
doc->bounding_box + 1, doc->bounding_box + 2,
doc->bounding_box + 3) != 4)
{
- fputs("ERROR: Bad %%BoundingBox: comment seen!\n", stderr);
+ fputs(_("ERROR: Bad %%BoundingBox: comment seen!\n"), stderr);
doc->bounding_box[0] = (int)PageLeft;
doc->bounding_box[1] = (int)PageBottom;
}
if (!saw_bounding_box)
- fputs("ERROR: No %%BoundingBox: comment in header!\n", stderr);
+ fputs(_("ERROR: No %%BoundingBox: comment in header!\n"), stderr);
if (!saw_pages)
- fputs("ERROR: No %%Pages: comment in header!\n", stderr);
+ fputs(_("ERROR: No %%Pages: comment in header!\n"), stderr);
if (!saw_for)
WriteTextComment("For", doc->user);
ppdEmitJCL(ppd, stdout, doc->job_id, doc->user, doc->title);
puts("%!PS-Adobe-3.0");
-
- pageinfo = (pstops_page_t *)cupsArrayFirst(doc->pages);
- copy_bytes(doc->temp, 0, pageinfo->offset);
number = 0;
}
+ /*
+ * Copy the prolog as needed...
+ */
+
+ if (!number)
+ {
+ pageinfo = (pstops_page_t *)cupsArrayFirst(doc->pages);
+ copy_bytes(doc->temp, 0, pageinfo->offset);
+ }
+
/*
* Then copy all of the pages...
*/
* that may not print correctly...
*/
- fputs("WARNING: This document does not conform to the Adobe Document "
- "Structuring Conventions and may not print correctly!\n", stderr);
+ fputs(_("WARNING: This document does not conform to the Adobe Document "
+ "Structuring Conventions and may not print correctly!\n"), stderr);
/*
* Then write a standard DSC comment section...
if (!parse_text(line + 7, &ptr, label, sizeof(label)))
{
- fputs("ERROR: Bad %%Page: comment in file!\n", stderr);
+ fputs(_("ERROR: Bad %%Page: comment in file!\n"), stderr);
label[0] = '\0';
number = doc->page;
}
else if (strtol(ptr, &ptr, 10) == LONG_MAX || !isspace(*ptr & 255))
{
- fputs("ERROR: Bad %%Page: comment in file!\n", stderr);
+ fputs(_("ERROR: Bad %%Page: comment in file!\n"), stderr);
number = doc->page;
}
pageinfo->num_options = cupsAddOption("InputSlot", doc->ap_input_slot,
pageinfo->num_options,
&(pageinfo->options));
- pageinfo->num_options = cupsAddOption("ManualFeed", doc->ap_manual_feed,
+ pageinfo->num_options = cupsAddOption("ManualFeed",
+ doc->ap_input_slot ? "False" :
+ doc->ap_manual_feed,
pageinfo->num_options,
&(pageinfo->options));
}
pageinfo->num_options = cupsAddOption("InputSlot", doc->input_slot,
pageinfo->num_options,
&(pageinfo->options));
- pageinfo->num_options = cupsAddOption("ManualFeed", doc->manual_feed,
+ pageinfo->num_options = cupsAddOption("ManualFeed",
+ doc->input_slot ? "False" :
+ doc->manual_feed,
pageinfo->num_options,
&(pageinfo->options));
}
bounding_box + 1, bounding_box + 2,
bounding_box + 3) != 4)
{
- fputs("ERROR: Bad %%PageBoundingBox: comment in file!\n", stderr);
+ fputs(_("ERROR: Bad %%PageBoundingBox: comment in file!\n"), stderr);
memcpy(bounding_box, doc->bounding_box,
sizeof(bounding_box));
}
if (doc->number_up > 1 || doc->fitplot)
continue;
}
- else if (!strncmp(line, "%%EndFeature:", 13))
+ else if (!strncmp(line, "%%EndFeature", 12))
{
feature = 0;
if (!strncmp(line, "%%EndProlog", 11))
linelen = cupsFileGetLine(fp, line, linesize);
else
- fputs("ERROR: Missing %%EndProlog!\n", stderr);
+ fputs(_("ERROR: Missing %%EndProlog!\n"), stderr);
}
doc_puts(doc, "%%EndProlog\n");
if (!strncmp(line, "%%EndSetup", 10))
linelen = cupsFileGetLine(fp, line, linesize);
else
- fputs("ERROR: Missing %%EndSetup!\n", stderr);
+ fputs(_("ERROR: Missing %%EndSetup!\n"), stderr);
}
doc_puts(doc, "%%EndSetup\n");
if (bytes > sizeof(buffer))
{
fprintf(stderr,
- "ERROR: doc_printf overflow (%d bytes) detected, aborting!\n",
+ _("ERROR: doc_printf overflow (%d bytes) detected, aborting!\n"),
(int)bytes);
exit(1);
}
if (sscanf(line + 17, "%254s%254s", name, value) != 2)
{
- fputs("ERROR: Bad %%IncludeFeature: comment!\n", stderr);
+ fputs(_("ERROR: Bad %%IncludeFeature: comment!\n"), stderr);
return (num_options);
}
if ((option = ppdFindOption(ppd, name + 1)) == NULL)
{
- fprintf(stderr, "WARNING: Unknown option \"%s\"!\n", name + 1);
+ fprintf(stderr, _("WARNING: Unknown option \"%s\"!\n"), name + 1);
return (num_options);
}
if (option->section == PPD_ORDER_EXIT ||
option->section == PPD_ORDER_JCL)
{
- fprintf(stderr, "WARNING: Option \"%s\" cannot be included via "
- "IncludeFeature!\n", name + 1);
+ fprintf(stderr, _("WARNING: Option \"%s\" cannot be included via "
+ "IncludeFeature!\n"), name + 1);
return (num_options);
}
if ((choice = ppdFindChoice(option, value)) == NULL)
{
- fprintf(stderr, "WARNING: Unknown choice \"%s\" for option \"%s\"!\n",
+ fprintf(stderr, _("WARNING: Unknown choice \"%s\" for option \"%s\"!\n"),
value, name + 1);
return (num_options);
}
if (intval < 10 || intval > 1000)
{
- fprintf(stderr, "ERROR: Unsupported brightness value %s, using "
- "brightness=100!\n", val);
+ fprintf(stderr, _("ERROR: Unsupported brightness value %s, using "
+ "brightness=100!\n"), val);
doc->brightness = 1.0f;
}
else
if (intval < 1 || intval > 10000)
{
- fprintf(stderr, "ERROR: Unsupported gamma value %s, using "
- "gamma=1000!\n", val);
+ fprintf(stderr, _("ERROR: Unsupported gamma value %s, using "
+ "gamma=1000!\n"), val);
doc->gamma = 1.0f;
}
else
if ((choice = ppdFindMarkedChoice(ppd, "ManualFeed")) != NULL)
doc->manual_feed = choice->choice;
- if ((val = cupsGetOption("mirror", num_options, options)) != NULL &&
- (!strcasecmp(val, "true") || !strcasecmp(val, "on") ||
- !strcasecmp(val, "yes")))
+ if ((choice = ppdFindMarkedChoice(ppd, "MirrorPrint")) != NULL)
+ {
+ val = choice->choice;
+ choice->marked = 0;
+ }
+ else
+ val = cupsGetOption("mirror", num_options, options);
+
+ if (val && (!strcasecmp(val, "true") || !strcasecmp(val, "on") ||
+ !strcasecmp(val, "yes")))
doc->mirror = 1;
/*
break;
default :
fprintf(stderr,
- "ERROR: Unsupported number-up value %d, using number-up=1!\n",
- intval);
+ _("ERROR: Unsupported number-up value %d, using "
+ "number-up=1!\n"), intval);
doc->number_up = 1;
break;
}
doc->number_up_layout = PSTOPS_LAYOUT_BTRL;
else
{
- fprintf(stderr, "ERROR: Unsupported number-up-layout value %s, using "
- "number-up-layout=lrtb!\n", val);
+ fprintf(stderr, _("ERROR: Unsupported number-up-layout value %s, using "
+ "number-up-layout=lrtb!\n"), val);
doc->number_up_layout = PSTOPS_LAYOUT_LRTB;
}
}
doc->page_border = PSTOPS_BORDERDOUBLE2;
else
{
- fprintf(stderr, "ERROR: Unsupported page-border value %s, using "
- "page-border=none!\n", val);
+ fprintf(stderr, _("ERROR: Unsupported page-border value %s, using "
+ "page-border=none!\n"), val);
doc->page_border = PSTOPS_BORDERNONE;
}
}
if ((doc->temp = cupsTempFile2(doc->tempfile,
sizeof(doc->tempfile))) == NULL)
{
- fprintf(stderr, "ERROR: Unable to create temporary file: %s\n",
+ fprintf(stderr, _("ERROR: Unable to create temporary file: %s\n"),
strerror(errno));
exit(1);
}
/*
- * End of "$Id: pstops.c 6247 2007-02-07 20:54:37Z mike $".
+ * End of "$Id: pstops.c 6649 2007-07-11 21:46:42Z mike $".
*/