]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/ipp.c
Remove old files.
[thirdparty/cups.git] / backend / ipp.c
index 3dc0991fe0b1149cbcb2cd5358703934005be121..1feb6fdb1d70fc48e0dcd625c4764ac19011e132 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   IPP backend for the Common UNIX Printing System (CUPS).
  *
- *   Copyright 2007 by Apple Inc.
+ *   Copyright 2007-2008 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products, all rights reserved.
  *
  *   These coded instructions, statements, and computer programs are the
@@ -236,6 +236,9 @@ main(int  argc,                             /* I - Number of command-line args */
     return (CUPS_BACKEND_STOP);
   }
 
+  if (!port)
+    port = IPP_PORT;                   /* Default to port 631 */
+
   if (!strcmp(method, "https"))
     cupsSetEncryption(HTTP_ENCRYPT_ALWAYS);
   else
@@ -404,13 +407,13 @@ main(int  argc,                           /* I - Number of command-line args */
 
     if ((fd = cupsTempFd(tmpfilename, sizeof(tmpfilename))) < 0)
     {
-      perror("ERROR: unable to create temporary file");
+      _cupsLangPrintError(_("ERROR: Unable to create temporary file"));
       return (CUPS_BACKEND_FAILED);
     }
 
     if ((fp = cupsFileOpenFd(fd, compression ? "w9" : "w")) == NULL)
     {
-      perror("ERROR: unable to open temporary file");
+      _cupsLangPrintError(_("ERROR: Unable to open temporary file"));
       close(fd);
       unlink(tmpfilename);
       return (CUPS_BACKEND_FAILED);
@@ -419,7 +422,7 @@ main(int  argc,                             /* I - Number of command-line args */
     while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0)
       if (cupsFileWrite(fp, buffer, bytes) < bytes)
       {
-        perror("ERROR: unable to write to temporary file");
+        _cupsLangPrintError(_("ERROR: Unable to write to temporary file"));
        cupsFileClose(fp);
        unlink(tmpfilename);
        return (CUPS_BACKEND_FAILED);
@@ -518,8 +521,8 @@ main(int  argc,                             /* I - Number of command-line args */
                      _("INFO: Unable to contact printer, queuing on next "
                        "printer in class...\n"));
 
-        if (argc == 6 || strcmp(filename, argv[6]))
-         unlink(filename);
+        if (tmpfilename[0])
+         unlink(tmpfilename);
 
        /*
         * Sleep 5 seconds to keep the job from requeuing too rapidly...
@@ -576,8 +579,8 @@ main(int  argc,                             /* I - Number of command-line args */
 
   if (job_cancelled)
   {
-    if (argc == 6 || strcmp(filename, argv[6]))
-      unlink(filename);
+    if (tmpfilename[0])
+      unlink(tmpfilename);
 
     return (CUPS_BACKEND_FAILED);
   }
@@ -762,8 +765,8 @@ main(int  argc,                             /* I - Number of command-line args */
       ippDelete(supported);
       httpClose(http);
 
-      if (argc == 6 || strcmp(filename, argv[6]))
-       unlink(filename);
+      if (tmpfilename[0])
+       unlink(tmpfilename);
 
      /*
       * Sleep 5 seconds to keep the job from requeuing too rapidly...
@@ -862,12 +865,13 @@ main(int  argc,                           /* I - Number of command-line args */
     num_options = cupsParseOptions(argv[5], 0, &options);
 
 #ifdef __APPLE__
-    if (!strcasecmp(content_type, "application/pictwps") && num_files == 1)
+    if (!strcasecmp(final_content_type, "application/pictwps") &&
+        num_files == 1)
     {
       if (format_sup != NULL)
       {
        for (i = 0; i < format_sup->num_values; i ++)
-         if (!strcasecmp(content_type, format_sup->values[i].string.text))
+         if (!strcasecmp(final_content_type, format_sup->values[i].string.text))
            break;
       }
 
@@ -878,10 +882,18 @@ main(int  argc,                           /* I - Number of command-line args */
        * so convert the document to PostScript...
        */
 
-       if (run_pictwps_filter(argv, filename))
+       if (run_pictwps_filter(argv, files[0]))
+       {
+         if (pstmpname[0])
+           unlink(pstmpname);
+
+         if (tmpfilename[0])
+           unlink(tmpfilename);
+
          return (CUPS_BACKEND_FAILED);
+        }
 
-        filename = pstmpname;
+        files[0] = pstmpname;
 
        /*
        * Change the MIME type to application/postscript and change the
@@ -1398,7 +1410,7 @@ password_cb(const char *prompt)           /* I - Prompt (not used) */
 {
   (void)prompt;
 
-  if (password && password_tries < 3)
+  if (password && *password && password_tries < 3)
   {
     password_tries ++;
 
@@ -1481,7 +1493,7 @@ report_printer_state(ipp_t *ipp,  /* I - IPP response */
     else if (!strncmp(reason, "moving-to-paused", 16) ||
              !strncmp(reason, "paused", 6) ||
             !strncmp(reason, "shutdown", 8))
-      message = _("Printer off-line.");
+      message = _("Printer offline.");
     else if (!strncmp(reason, "toner-low", 9))
       message = _("Toner low.");
     else if (!strncmp(reason, "toner-empty", 11))
@@ -1677,7 +1689,6 @@ run_pictwps_filter(char       **argv,     /* I - Command-line arguments */
 
     _cupsLangPrintf(stderr, _("ERROR: Unable to fork pictwpstops: %s\n"),
                    strerror(errno));
-    unlink(filename);
     if (ppdfile)
       unlink(ppdfile);
     return (-1);
@@ -1692,7 +1703,6 @@ run_pictwps_filter(char       **argv,     /* I - Command-line arguments */
     _cupsLangPrintf(stderr, _("ERROR: Unable to wait for pictwpstops: %s\n"),
                    strerror(errno));
     close(fd);
-    unlink(filename);
     if (ppdfile)
       unlink(ppdfile);
     return (-1);
@@ -1712,7 +1722,6 @@ run_pictwps_filter(char       **argv,     /* I - Command-line arguments */
       _cupsLangPrintf(stderr, _("ERROR: pictwpstops exited on signal %d!\n"),
                      status);
 
-    unlink(filename);
     return (status);
   }