*
* "lpq" command for CUPS.
*
- * Copyright 2007-2012 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
all, /* All printers */
interval, /* Reporting interval */
longstatus; /* Show file details */
- int num_dests; /* Number of destinations */
- cups_dest_t *dests; /* Destinations */
+ cups_dest_t *named_dest; /* Named destination */
_cupsSetLocale(argv);
interval = 0;
longstatus = 0;
all = 0;
- num_dests = 0;
- dests = NULL;
for (i = 1; i < argc; i ++)
if (argv[i][0] == '+')
if (i >= argc)
{
httpClose(http);
- cupsFreeDests(num_dests, dests);
usage();
}
http = connect_server(argv[0], http);
- if (num_dests == 0)
- num_dests = cupsGetDests2(http, &dests);
-
- if (cupsGetDest(dest, instance, num_dests, dests) == NULL)
+ if ((named_dest = cupsGetNamedDest(http, dest, instance)) == NULL)
{
- if (instance)
+ 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]);
+ else if (instance)
_cupsLangPrintf(stderr,
_("%s: Error - unknown destination \"%s/%s\"."),
argv[0], dest, instance);
return (1);
}
+
+ cupsFreeDests(1, named_dest);
break;
case 'a' : /* All printers */
default :
httpClose(http);
- cupsFreeDests(num_dests, dests);
usage();
break;
if (dest == NULL && !all)
{
- if (num_dests == 0)
- num_dests = cupsGetDests2(http, &dests);
-
- for (i = 0; i < num_dests; i ++)
- if (dests[i].is_default)
- dest = dests[i].name;
-
- if (dest == NULL)
+ if ((named_dest = cupsGetNamedDest(http, NULL, NULL)) == NULL)
{
+ 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);
+ }
+
val = NULL;
if ((dest = getenv("LPDEST")) == NULL)
else
val = "LPDEST";
- if (dest && !cupsGetDest(dest, NULL, num_dests, dests))
+ if (dest && val)
_cupsLangPrintf(stderr,
_("%s: Error - %s environment variable names "
"non-existent destination \"%s\"."), argv[0], val,
_("%s: Error - no default destination available."),
argv[0]);
httpClose(http);
- cupsFreeDests(num_dests, dests);
return (1);
}
+
+ dest = named_dest->name;
}
/*
* Close the connection to the server and return...
*/
- cupsFreeDests(num_dests, dests);
httpClose(http);
return (0);
if ((instance = strrchr(printer, '/')) != NULL)
*instance++ = '\0';
- if ((dest = cupsGetNamedDest(NULL, printer, instance)) != NULL)
+ if ((dest = cupsGetNamedDest(CUPS_HTTP_DEFAULT, printer,
+ instance)) != NULL)
{
for (j = 0; j < dest->num_options; j ++)
if (cupsGetOption(dest->options[j].name, num_options,
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 'f' : /* Form */
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)
ippDelete(cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/jobs"));
- if (cupsLastError() > IPP_OK_CONFLICT)
+ 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);
+ return (1);
+ }
+ else if (cupsLastError() > IPP_OK_CONFLICT)
{
_cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
return (1);
ippDelete(cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/jobs"));
- if (cupsLastError() > IPP_OK_CONFLICT)
+ 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);
+ return (1);
+ }
+ else if (cupsLastError() > IPP_OK_CONFLICT)
{
_cupsLangPrintf(stderr, "%s: %s", command, cupsLastErrorString());
return (1);
*
* "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
{
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);
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);
{
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);
{
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));
{
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();
{
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);
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
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);
}
}
* 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
ippDelete(response);
}
- else
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- return (1);
- }
return (0);
}
* 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...");
ippDelete(response);
}
- else
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- return (1);
- }
return (0);
}
* 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
ippDelete(response);
}
- else
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- return (1);
- }
return (0);
}
* 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)
ippDelete(response);
}
- else
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- return (1);
- }
return (0);
}
* 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
ippDelete(response);
}
- else
- {
- _cupsLangPrintf(stderr, "lpstat: %s", cupsLastErrorString());
- return (1);
- }
return (0);
}