]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - berkeley/lpr.c
Remove all of the Subversion keywords from various source files.
[thirdparty/cups.git] / berkeley / lpr.c
index 1bfe11e4d8add8b11b31507743edbe8b4e903a27..eb58c8bd9f76180123c3eb1ce1970c3fca2658a0 100644 (file)
@@ -1,20 +1,14 @@
 /*
- * "$Id: lpr.c 7720 2008-07-11 22:46:21Z mike $"
+ * "lpr" command for CUPS.
  *
- *   "lpr" command for CUPS.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
  *
- *   Copyright 2007-2010 by Apple Inc.
- *   Copyright 1997-2007 by Easy Software Products.
- *
- *   These coded instructions, statements, and computer programs are the
- *   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/".
- *
- * Contents:
- *
- *   main() - Parse options and send files for printing.
+ * These coded instructions, statements, and computer programs are the
+ * 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/".
  */
 
 /*
@@ -61,6 +55,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
 
   for (i = 1; i < argc; i ++)
     if (argv[i][0] == '-')
+    {
       switch (ch = argv[i][1])
       {
         case 'E' : /* Encrypt */
@@ -89,7 +84,7 @@ main(int  argc,                               /* I - Number of command-line arguments */
               cupsSetUser(argv[i]);
            }
            break;
-           
+
         case 'H' : /* Connect to host */
            if (argv[i][2] != '\0')
               cupsSetServer(argv[i] + 2);
@@ -150,7 +145,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
              if (i >= argc)
              {
                _cupsLangPrintf(stderr,
-                               _("%s: error - expected option=value after "
+                               _("%s: Error - expected option=value after "
                                  "\"-o\" option."), argv[0]);
                return (1);
              }
@@ -226,6 +221,14 @@ main(int  argc,                            /* I - Number of command-line arguments */
                                              dest->options[j].value,
                                              num_options, &options);
            }
+           else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+                    cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+           {
+             _cupsLangPrintf(stderr,
+                             _("%s: Error - add '/version=1.1' to server "
+                               "name."), argv[0]);
+             return (1);
+           }
            break;
 
        case '#' : /* Number of copies */
@@ -237,7 +240,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
              if (i >= argc)
              {
                _cupsLangPrintf(stderr,
-                               _("%s: Error - expected copy count after "
+                               _("%s: Error - expected copies after "
                                  "\"-#\" option."), argv[0]);
                return (1);
              }
@@ -275,6 +278,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
                            argv[i][1]);
            return (1);
       }
+    }
     else if (num_files < 1000)
     {
      /*
@@ -284,7 +288,7 @@ main(int  argc,                             /* I - Number of command-line arguments */
       if (access(argv[i], R_OK) != 0)
       {
         _cupsLangPrintf(stderr,
-                       _("%s: Error - unable to access \"%s\" - %s."),
+                       _("%s: Error - unable to access \"%s\" - %s"),
                        argv[0], argv[i], strerror(errno));
         return (1);
       }
@@ -320,6 +324,14 @@ main(int  argc,                            /* I - Number of command-line arguments */
                                      dest->options[j].value,
                                      num_options, &options);
     }
+    else if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+            cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
+    {
+      _cupsLangPrintf(stderr,
+                     _("%s: Error - add '/version=1.1' to server "
+                       "name."), argv[0]);
+      return (1);
+    }
   }
 
   if (printer == NULL)
@@ -377,7 +389,6 @@ main(int  argc,                             /* I - Number of command-line arguments */
     const char         *format;        /* Document format */
     ssize_t            bytes;          /* Bytes read */
 
-
     if (cupsGetOption("raw", num_options, options))
       format = CUPS_FORMAT_RAW;
     else if ((format = cupsGetOption("document-format", num_options,
@@ -389,17 +400,23 @@ main(int  argc,                           /* I - Number of command-line arguments */
 
     while (status == HTTP_CONTINUE &&
            (bytes = read(0, buffer, sizeof(buffer))) > 0)
-      status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, bytes);
+      status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, (size_t)bytes);
 
     if (status != HTTP_CONTINUE)
     {
       _cupsLangPrintf(stderr, _("%s: Error - unable to queue from stdin - %s."),
                      argv[0], httpStatus(status));
+      cupsFinishDocument(CUPS_HTTP_DEFAULT, printer);
+      cupsCancelJob2(CUPS_HTTP_DEFAULT, printer, job_id, 0);
       return (1);
     }
 
     if (cupsFinishDocument(CUPS_HTTP_DEFAULT, printer) != IPP_OK)
-      job_id = 0;
+    {
+      _cupsLangPrintf(stderr, "%s: %s", argv[0], cupsLastErrorString());
+      cupsCancelJob2(CUPS_HTTP_DEFAULT, printer, job_id, 0);
+      return (1);
+    }
   }
 
   if (job_id < 1)
@@ -410,8 +427,3 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
   return (0);
 }
-
-
-/*
- * End of "$Id: lpr.c 7720 2008-07-11 22:46:21Z mike $".
- */