/*
- * "$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/".
*/
/*
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-')
+ {
switch (ch = argv[i][1])
{
case 'E' : /* Encrypt */
cupsSetUser(argv[i]);
}
break;
-
+
case 'H' : /* Connect to host */
if (argv[i][2] != '\0')
cupsSetServer(argv[i] + 2);
if (i >= argc)
{
_cupsLangPrintf(stderr,
- _("%s: error - expected option=value after "
+ _("%s: Error - expected option=value after "
"\"-o\" option."), argv[0]);
return (1);
}
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 */
if (i >= argc)
{
_cupsLangPrintf(stderr,
- _("%s: Error - expected copy count after "
+ _("%s: Error - expected copies after "
"\"-#\" option."), argv[0]);
return (1);
}
argv[i][1]);
return (1);
}
+ }
else if (num_files < 1000)
{
/*
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);
}
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)
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,
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)
return (0);
}
-
-
-/*
- * End of "$Id: lpr.c 7720 2008-07-11 22:46:21Z mike $".
- */