]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - filter/imagetops.c
Merge changes from CUPS 1.5.1-r9875.
[thirdparty/cups.git] / filter / imagetops.c
index 666a91453d088ca8caddd4c93d7def0639e2fbf9..d8638b25ad24cef85bb7c16d03f3c7a7b10f2c42 100644 (file)
@@ -1,25 +1,16 @@
 /*
- * "$Id: imagetops.c 6003 2006-10-02 16:26:04Z mike $"
+ * "$Id: imagetops.c 6649 2007-07-11 21:46:42Z mike $"
  *
- *   Image file to PostScript filter for the Common UNIX Printing System (CUPS).
+ *   Image file to PostScript filter for CUPS.
  *
- *   Copyright 1993-2006 by Easy Software Products.
+ *   Copyright 2007-2011 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.
  *
@@ -37,6 +28,8 @@
 #include "common.h"
 #include "image.h"
 #include <math.h>
+#include <cups/language-private.h>
+#include <signal.h>
 
 
 /*
@@ -114,19 +107,24 @@ main(int  argc,                           /* I - Number of command-line arguments */
 
   setbuf(stderr, NULL);
 
+ /*
+  * Ignore broken pipe signals...
+  */
+
+  signal(SIGPIPE, SIG_IGN);
+
  /*
   * Check command-line...
   */
 
   if (argc < 6 || argc > 7)
   {
-    fputs("ERROR: imagetops job-id user title copies options [file]\n", stderr);
+    _cupsLangPrintf(stderr,
+                    _("Usage: %s job-id user title copies options file"),
+                    argv[0]);
     return (1);
   }
 
-  fprintf(stderr, "INFO: %s %s %s %s %s %s %s\n", argv[0], argv[1], argv[2],
-          argv[3], argv[4], argv[5], argv[6] ? argv[6] : "(null)");
-
  /*
   * Copy stdin as needed...
   */
@@ -140,11 +138,11 @@ main(int  argc,                           /* I - Number of command-line arguments */
 
     if ((fd = cupsTempFd(filename, sizeof(filename))) < 0)
     {
-      perror("ERROR: Unable to copy image file");
+      _cupsLangPrintError("ERROR", _("Unable to copy print file"));
       return (1);
     }
 
-    fprintf(stderr, "DEBUG: imagetoraster - copying to temp print file \"%s\"\n",
+    fprintf(stderr, "DEBUG: imagetops - copying to temp print file \"%s\".\n",
             filename);
 
     while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0)
@@ -185,11 +183,11 @@ main(int  argc,                           /* I - Number of command-line arguments */
     *   separate-documents-uncollated-copies allows for uncollated copies.
     */
 
-    Collate = strcasecmp(val, "separate-documents-uncollated-copies") != 0;
+    Collate = _cups_strcasecmp(val, "separate-documents-uncollated-copies") != 0;
   }
 
   if ((val = cupsGetOption("Collate", num_options, options)) != NULL &&
-      strcasecmp(val, "True") == 0)
+      _cups_strcasecmp(val, "True") == 0)
     Collate = 1;
 
   if ((val = cupsGetOption("gamma", num_options, options)) != NULL)
@@ -222,7 +220,11 @@ main(int  argc,                            /* I - Number of command-line arguments */
 
   if ((val = cupsGetOption("scaling", num_options, options)) != NULL)
     zoom = atoi(val) * 0.01;
-  else if (cupsGetOption("fitplot", num_options, options))
+  else if ((val = cupsGetOption("fitplot", num_options, options)) != NULL &&
+           !_cups_strcasecmp(val, "true"))
+    zoom = 1.0;
+  else if ((val = cupsGetOption("fit-to-page", num_options, options)) != NULL &&
+           !_cups_strcasecmp(val, "true"))
     zoom = 1.0;
 
   if ((val = cupsGetOption("ppi", num_options, options)) != NULL)
@@ -231,47 +233,47 @@ main(int  argc,                           /* I - Number of command-line arguments */
 
   if ((val = cupsGetOption("position", num_options, options)) != NULL)
   {
-    if (strcasecmp(val, "center") == 0)
+    if (_cups_strcasecmp(val, "center") == 0)
     {
       XPosition = 0;
       YPosition = 0;
     }
-    else if (strcasecmp(val, "top") == 0)
+    else if (_cups_strcasecmp(val, "top") == 0)
     {
       XPosition = 0;
       YPosition = 1;
     }
-    else if (strcasecmp(val, "left") == 0)
+    else if (_cups_strcasecmp(val, "left") == 0)
     {
       XPosition = -1;
       YPosition = 0;
     }
-    else if (strcasecmp(val, "right") == 0)
+    else if (_cups_strcasecmp(val, "right") == 0)
     {
       XPosition = 1;
       YPosition = 0;
     }
-    else if (strcasecmp(val, "top-left") == 0)
+    else if (_cups_strcasecmp(val, "top-left") == 0)
     {
       XPosition = -1;
       YPosition = 1;
     }
-    else if (strcasecmp(val, "top-right") == 0)
+    else if (_cups_strcasecmp(val, "top-right") == 0)
     {
       XPosition = 1;
       YPosition = 1;
     }
-    else if (strcasecmp(val, "bottom") == 0)
+    else if (_cups_strcasecmp(val, "bottom") == 0)
     {
       XPosition = 0;
       YPosition = -1;
     }
-    else if (strcasecmp(val, "bottom-left") == 0)
+    else if (_cups_strcasecmp(val, "bottom-left") == 0)
     {
       XPosition = -1;
       YPosition = -1;
     }
-    else if (strcasecmp(val, "bottom-right") == 0)
+    else if (_cups_strcasecmp(val, "bottom-right") == 0)
     {
       XPosition = 1;
       YPosition = -1;
@@ -284,13 +286,21 @@ main(int  argc,                           /* I - Number of command-line arguments */
   if ((val = cupsGetOption("hue", num_options, options)) != NULL)
     hue = atoi(val);
 
-  if ((val = cupsGetOption("mirror", num_options, options)) != NULL &&
-      strcasecmp(val, "True") == 0)
+  if ((choice = ppdFindMarkedChoice(ppd, "MirrorPrint")) != NULL)
+  {
+    val = choice->choice;
+    choice->marked = 0;
+  }
+  else
+    val = cupsGetOption("mirror", num_options, options);
+
+  if (val && (!_cups_strcasecmp(val, "true") || !_cups_strcasecmp(val, "on") ||
+              !_cups_strcasecmp(val, "yes")))
     Flip = 1;
 
   if ((val = cupsGetOption("emit-jcl", num_options, options)) != NULL &&
-      (!strcasecmp(val, "false") || !strcasecmp(val, "off") ||
-       !strcasecmp(val, "no") || !strcmp(val, "0")))
+      (!_cups_strcasecmp(val, "false") || !_cups_strcasecmp(val, "off") ||
+       !_cups_strcasecmp(val, "no") || !strcmp(val, "0")))
     emit_jcl = 0;
   else
     emit_jcl = 1;
@@ -308,7 +318,8 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
   if (img == NULL)
   {
-    fputs("ERROR: Unable to open image file for printing!\n", stderr);
+    _cupsLangPrintFilter(stderr, "ERROR",
+                         _("The print file could not be opened."));
     ppdClose(ppd);
     return (1);
   }
@@ -336,7 +347,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
    /*
     * Scale the image as neccesary to match the desired pixels-per-inch.
     */
-    
+
     if (Orientation & 1)
     {
       xprint = (PageTop - PageBottom) / 72.0;
@@ -501,7 +512,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
   */
 
   if ((choice = ppdFindMarkedChoice(ppd, "PageSize")) != NULL &&
-      strcasecmp(choice->choice, "Custom") == 0)
+      _cups_strcasecmp(choice->choice, "Custom") == 0)
   {
     float      width,          /* New width in points */
                length;         /* New length in points */
@@ -803,7 +814,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
         if (ppd && ppd->num_filters == 0)
           fprintf(stderr, "PAGE: %d %d\n", page, realcopies);
 
-       fprintf(stderr, "INFO: Printing page %d...\n", page);
+       _cupsLangPrintFilter(stderr, "INFO", _("Printing page %d."), page);
 
         printf("%%%%Page: %d %d\n", page, page);
 
@@ -1063,5 +1074,5 @@ ps_ascii85(cups_ib_t *data,               /* I - Data to print */
 
 
 /*
- * End of "$Id: imagetops.c 6003 2006-10-02 16:26:04Z mike $".
+ * End of "$Id: imagetops.c 6649 2007-07-11 21:46:42Z mike $".
  */