]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - filter/rastertolabel.c
Update svn:keyword properties.
[thirdparty/cups.git] / filter / rastertolabel.c
index d5564e626a363febd1eeee48ec902e45c424e237..f5d80256aecc8be827df7e19f5d1c28f98c9d76a 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * "$Id: rastertolabel.c 6819 2007-08-20 21:11:57Z mike $"
+ * "$Id$"
  *
- *   Label printer filter for the Common UNIX Printing System (CUPS).
+ *   Label printer filter for CUPS.
  *
- *   Copyright 2007-2008 by Apple Inc.
+ *   Copyright 2007-2012 by Apple Inc.
  *   Copyright 2001-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
  */
 
 #include <cups/cups.h>
-#include <cups/string.h>
-#include <cups/i18n.h>
+#include <cups/ppd.h>
+#include <cups/string-private.h>
+#include <cups/language-private.h>
 #include <cups/raster.h>
-#include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <signal.h>
@@ -777,17 +777,6 @@ OutputLine(ppd_file_t         *ppd,        /* I - PPD file */
           putchar(0x16);
          fwrite(Buffer, header->cupsBytesPerLine, 1, stdout);
          fflush(stdout);
-
-#ifdef __sgi
-        /*
-          * This hack works around a bug in the IRIX serial port driver when
-         * run at high baud rates (e.g. 115200 baud)...  This results in
-         * slightly slower label printing, but at least the labels come
-         * out properly.
-         */
-
-         sginap(1);
-#endif /* __sgi */
        }
        else
           Feed ++;
@@ -1030,9 +1019,6 @@ PCLCompress(unsigned char *line,  /* I - Line to compress */
     comp_ptr += count;
   }
 
-  line_ptr = CompBuffer;
-  line_end = comp_ptr;
-
  /*
   * Set the length of the data and write it...
   */
@@ -1061,8 +1047,8 @@ ZPLCompress(char repeat_char,             /* I - Character to repeat */
   {
    /*
     * Print as many z's as possible - they are the largest denomination
-    * representing 400 characters (zC stands for 400 adjacent C's)     
-    */ 
+    * representing 400 characters (zC stands for 400 adjacent C's)
+    */
 
     while (repeat_count >= 400)
     {
@@ -1133,8 +1119,9 @@ main(int  argc,                           /* I - Number of command-line arguments */
     * and return.
     */
 
-    fprintf(stderr, _("Usage: %s job-id user title copies options [file]\n"),
-            argv[0]);
+    _cupsLangPrintFilter(stderr, "ERROR",
+                         _("%s job-id user title copies options [file]"),
+                        "rastertolabel");
     return (1);
   }
 
@@ -1146,7 +1133,7 @@ main(int  argc,                           /* I - Number of command-line arguments */
   {
     if ((fd = open(argv[6], O_RDONLY)) == -1)
     {
-      perror("ERROR: Unable to open raster file - ");
+      _cupsLangPrintError("ERROR", _("Unable to open raster file"));
       sleep(1);
       return (1);
     }
@@ -1181,12 +1168,25 @@ main(int  argc,                         /* I - Number of command-line arguments */
 
   num_options = cupsParseOptions(argv[5], 0, &options);
 
-  if ((ppd = ppdOpenFile(getenv("PPD"))) != NULL)
+  ppd = ppdOpenFile(getenv("PPD"));
+  if (!ppd)
   {
-    ppdMarkDefaults(ppd);
-    cupsMarkOptions(ppd, num_options, options);
+    ppd_status_t       status;         /* PPD error */
+    int                        linenum;        /* Line number */
+
+    _cupsLangPrintFilter(stderr, "ERROR",
+                         _("The PPD file could not be opened."));
+
+    status = ppdLastError(&linenum);
+
+    fprintf(stderr, "DEBUG: %s on line %d.\n", ppdErrorString(status), linenum);
+
+    return (1);
   }
 
+  ppdMarkDefaults(ppd);
+  cupsMarkOptions(ppd, num_options, options);
+
  /*
   * Initialize the print device...
   */
@@ -1211,6 +1211,7 @@ main(int  argc,                           /* I - Number of command-line arguments */
     Page ++;
 
     fprintf(stderr, "PAGE: %d 1\n", Page);
+    _cupsLangPrintFilter(stderr, "INFO", _("Starting page %d."), Page);
 
    /*
     * Start the page...
@@ -1232,8 +1233,13 @@ main(int  argc,                          /* I - Number of command-line arguments */
        break;
 
       if ((y & 15) == 0)
-        fprintf(stderr, _("INFO: Printing page %d, %d%% complete...\n"), Page,
-               100 * y / header.cupsHeight);
+      {
+        _cupsLangPrintFilter(stderr, "INFO",
+                            _("Printing page %d, %d%% complete."),
+                            Page, 100 * y / header.cupsHeight);
+        fprintf(stderr, "ATTR: job-media-progress=%d\n",
+               100 * y / header.cupsHeight);
+      }
 
      /*
       * Read a line of graphics...
@@ -1253,6 +1259,8 @@ main(int  argc,                           /* I - Number of command-line arguments */
     * Eject the page...
     */
 
+    _cupsLangPrintFilter(stderr, "INFO", _("Finished page %d."), Page);
+
     EndPage(ppd, &header);
 
     if (Canceled)
@@ -1279,14 +1287,15 @@ main(int  argc,                         /* I - Number of command-line arguments */
   */
 
   if (Page == 0)
-    fputs(_("ERROR: No pages found!\n"), stderr);
+  {
+    _cupsLangPrintFilter(stderr, "ERROR", _("No pages were found."));
+    return (1);
+  }
   else
-    fputs(_("INFO: Ready to print.\n"), stderr);
-
-  return (Page == 0);
+    return (0);
 }
 
 
 /*
- * End of "$Id: rastertolabel.c 6819 2007-08-20 21:11:57Z mike $".
+ * End of "$Id$".
  */