summaryrefslogtreecommitdiff
path: root/systemv/lpstat.c
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2013-07-08 11:20:33 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2013-07-08 11:20:33 +0000
commitc606bcae4e922757fea8e87faf5e3cbbee06a4d4 (patch)
tree7be851e1c656e3e0f5f1263e24b61bc540f18009 /systemv/lpstat.c
parent83385e29978f3c6d2ed0b3e82f38b937783bbbdf (diff)
downloadcups-c606bcae4e922757fea8e87faf5e3cbbee06a4d4.tar.gz
<rdar://problem/14290628> cups.org: cupsGetNamedDest returns the wrong default printer, lpr/lpq/lp/lpstat use different defaults!
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11101 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'systemv/lpstat.c')
-rw-r--r--systemv/lpstat.c239
1 files changed, 175 insertions, 64 deletions
diff --git a/systemv/lpstat.c b/systemv/lpstat.c
index 4d6495637..8ead3f143 100644
--- a/systemv/lpstat.c
+++ b/systemv/lpstat.c
@@ -3,7 +3,7 @@
*
* "lpstat" command for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
+ * Copyright 2007-2013 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
@@ -199,6 +199,16 @@ main(int argc, /* I - Number of command-line arguments */
{
cupsFreeDests(num_dests, dests);
num_dests = cupsGetDests(&dests);
+
+ if (num_dests == 0 &&
+ (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);
+ }
}
status |= show_accepting(NULL, num_dests, dests);
@@ -235,6 +245,16 @@ main(int argc, /* I - Number of command-line arguments */
dests = cupsGetNamedDest(CUPS_HTTP_DEFAULT, NULL, NULL);
num_dests = dests ? 1 : 0;
+
+ if (num_dests == 0 &&
+ (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);
+ }
}
show_default(dests);
@@ -316,6 +336,16 @@ main(int argc, /* I - Number of command-line arguments */
{
cupsFreeDests(num_dests, dests);
num_dests = cupsGetDests(&dests);
+
+ if (num_dests == 0 &&
+ (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);
+ }
}
status |= show_printers(NULL, num_dests, dests, long_status);
@@ -335,6 +365,16 @@ main(int argc, /* I - Number of command-line arguments */
{
cupsFreeDests(num_dests, dests);
num_dests = cupsGetDests(&dests);
+
+ if (num_dests == 0 &&
+ (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);
+ }
}
show_default(cupsGetDest(NULL, NULL, num_dests, dests));
@@ -349,6 +389,16 @@ main(int argc, /* I - Number of command-line arguments */
{
cupsFreeDests(num_dests, dests);
num_dests = cupsGetDests(&dests);
+
+ if (num_dests == 0 &&
+ (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);
+ }
}
show_scheduler();
@@ -398,6 +448,16 @@ main(int argc, /* I - Number of command-line arguments */
{
cupsFreeDests(num_dests, dests);
num_dests = cupsGetDests(&dests);
+
+ if (num_dests == 0 &&
+ (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);
+ }
}
status |= show_devices(NULL, num_dests, dests);
@@ -457,9 +517,16 @@ check_dest(const char *command, /* I - Command name */
if ((*dests = cupsGetNamedDest(CUPS_HTTP_DEFAULT, printer, pptr)) == NULL)
{
- _cupsLangPrintf(stderr,
- _("%s: Invalid destination name in list \"%s\"."),
- command, name);
+ 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."),
+ command);
+ else
+ _cupsLangPrintf(stderr,
+ _("%s: Invalid destination name in list \"%s\"."),
+ command, name);
+
exit(1);
}
else
@@ -511,8 +578,15 @@ check_dest(const char *command, /* I - Command name */
if (!cupsGetDest(printer, NULL, *num_dests, *dests))
{
- _cupsLangPrintf(stderr,
- _("%s: Unknown destination \"%s\"."), command, printer);
+ 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."),
+ command);
+ else
+ _cupsLangPrintf(stderr,
+ _("%s: Unknown destination \"%s\"."), command, printer);
+
exit(1);
}
}
@@ -627,16 +701,27 @@ show_accepting(const char *printers, /* I - Destinations */
* Do the request and get back a response...
*/
- if ((response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/")) != NULL)
+ response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
+
+ if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
- DEBUG_puts("show_accepting: request succeeded...");
+ _cupsLangPrintf(stderr,
+ _("%s: Error - add '/version=1.1' to server name."),
+ "lpstat");
+ ippDelete(response);
+ return (1);
+ }
+ else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ {
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ ippDelete(response);
+ return (1);
+ }
- if (response->request.status.status_code > IPP_OK_CONFLICT)
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- ippDelete(response);
- return (1);
- }
+ if (response)
+ {
+ DEBUG_puts("show_accepting: request succeeded...");
/*
* Loop through the printers returned in the list and display
@@ -739,11 +824,6 @@ show_accepting(const char *printers, /* I - Destinations */
ippDelete(response);
}
- else
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- return (1);
- }
return (0);
}
@@ -806,7 +886,25 @@ show_classes(const char *dests) /* I - Destinations */
* Do the request and get back a response...
*/
- if ((response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/")) != NULL)
+ response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
+
+ 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."),
+ "lpstat");
+ ippDelete(response);
+ return (1);
+ }
+ else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ {
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ ippDelete(response);
+ return (1);
+ }
+
+ if (response)
{
DEBUG_puts("show_classes: request succeeded...");
@@ -944,11 +1042,6 @@ show_classes(const char *dests) /* I - Destinations */
ippDelete(response);
}
- else
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- return (1);
- }
return (0);
}
@@ -1054,16 +1147,27 @@ show_devices(const char *printers, /* I - Destinations */
* Do the request and get back a response...
*/
- if ((response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/")) != NULL)
+ response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
+
+ if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
- DEBUG_puts("show_devices: request succeeded...");
+ _cupsLangPrintf(stderr,
+ _("%s: Error - add '/version=1.1' to server name."),
+ "lpstat");
+ ippDelete(response);
+ return (1);
+ }
+ else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ {
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ ippDelete(response);
+ return (1);
+ }
- if (response->request.status.status_code > IPP_OK_CONFLICT)
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- ippDelete(response);
- return (1);
- }
+ if (response)
+ {
+ DEBUG_puts("show_devices: request succeeded...");
/*
* Loop through the printers returned in the list and display
@@ -1203,11 +1307,6 @@ show_devices(const char *printers, /* I - Destinations */
ippDelete(response);
}
- else
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- return (1);
- }
return (0);
}
@@ -1291,19 +1390,30 @@ show_jobs(const char *dests, /* I - Destinations */
* Do the request and get back a response...
*/
- if ((response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/")) != NULL)
+ response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
+
+ 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."),
+ "lpstat");
+ ippDelete(response);
+ return (1);
+ }
+ else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ {
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ ippDelete(response);
+ return (1);
+ }
+
+ if (response)
{
/*
* Loop through the job list and display them...
*/
- if (response->request.status.status_code > IPP_OK_CONFLICT)
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- ippDelete(response);
- return (1);
- }
-
rank = -1;
for (attr = response->attrs; attr != NULL; attr = attr->next)
@@ -1449,11 +1559,6 @@ show_jobs(const char *dests, /* I - Destinations */
ippDelete(response);
}
- else
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- return (1);
- }
return (0);
}
@@ -1544,16 +1649,27 @@ show_printers(const char *printers, /* I - Destinations */
* Do the request and get back a response...
*/
- if ((response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/")) != NULL)
+ response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");
+
+ if (cupsLastError() == IPP_STATUS_ERROR_BAD_REQUEST ||
+ cupsLastError() == IPP_STATUS_ERROR_VERSION_NOT_SUPPORTED)
{
- DEBUG_puts("show_printers: request succeeded...");
+ _cupsLangPrintf(stderr,
+ _("%s: Error - add '/version=1.1' to server name."),
+ "lpstat");
+ ippDelete(response);
+ return (1);
+ }
+ else if (cupsLastError() > IPP_STATUS_OK_CONFLICTING)
+ {
+ _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
+ ippDelete(response);
+ return (1);
+ }
- if (response->request.status.status_code > IPP_OK_CONFLICT)
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- ippDelete(response);
- return (1);
- }
+ if (response)
+ {
+ DEBUG_puts("show_printers: request succeeded...");
/*
* Loop through the printers returned in the list and display
@@ -1975,11 +2091,6 @@ show_printers(const char *printers, /* I - Destinations */
ippDelete(response);
}
- else
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- return (1);
- }
return (0);
}