/*
- * "$Id: cups-lpd.c 6327 2007-03-12 14:32:10Z mike $"
+ * "$Id: cups-lpd.c 6670 2007-07-13 23:15:02Z mike $"
*
* Line Printer Daemon interface for the Common UNIX Printing System (CUPS).
*
+ * Copyright 2007 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products 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 missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44141 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * 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:
*
*options = NULL;
/*
- * If the queue name contains a space, lookup the printer-name using
- * the printer-info value...
+ * See if the name is a queue name optionally with an instance name.
+ */
+
+ strlcpy(dest, name, destsize);
+ if ((value = strchr(dest, '/')) != NULL)
+ *value = '\0';
+
+ /*
+ * Setup the Get-Printer-Attributes request...
*/
- if (strchr(name, ' '))
+ request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
+
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ "localhost", 0, "/printers/%s", dest);
+
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
+ NULL, uri);
+
+ ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "requested-attributes",
+ (int)(sizeof(requested) / sizeof(requested[0])),
+ NULL, requested);
+
+ /*
+ * Do the request...
+ */
+
+ response = cupsDoRequest(http, request, "/");
+
+ if (!response || cupsLastError() > IPP_OK_CONFLICT)
{
/*
- * Lookup the printer-info...
+ * If we can't find the printer by name, look up the printer-name
+ * using the printer-info values...
*/
ipp_attribute_t *accepting_attr,/* printer-is-accepting-jobs */
*state_attr; /* printer-state */
+ ippDelete(response);
+
/*
* Setup the CUPS-Get-Printers request...
*/
name = dest;
}
- else
- {
- /*
- * Otherwise treat it as a queue name optionally with an instance name.
- */
-
- strlcpy(dest, name, destsize);
- if ((value = strchr(dest, '/')) != NULL)
- *value = '\0';
-
- /*
- * Setup the Get-Printer-Attributes request...
- */
-
- request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
-
- httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
- "localhost", 0, "/printers/%s", dest);
-
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
- NULL, uri);
-
- ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
- "requested-attributes",
- (int)(sizeof(requested) / sizeof(requested[0])),
- NULL, requested);
-
- /*
- * Do the request...
- */
-
- response = cupsDoRequest(http, request, "/");
- if (!response || cupsLastError() > IPP_OK_CONFLICT)
- {
- syslog(LOG_ERR, "Unable to check printer status - %s",
- cupsLastErrorString());
-
- ippDelete(response);
-
- return (-1);
- }
-
- /*
- * Get values from the response...
- */
-
- if (accepting)
- {
- if ((attr = ippFindAttribute(response, "printer-is-accepting-jobs",
- IPP_TAG_BOOLEAN)) == NULL)
- syslog(LOG_ERR, "No printer-is-accepting-jobs attribute found in "
- "response from server!");
- else
- *accepting = attr->values[0].boolean;
- }
+ /*
+ * Get values from the response...
+ */
- if (shared)
- {
- if ((attr = ippFindAttribute(response, "printer-is-shared",
- IPP_TAG_BOOLEAN)) == NULL)
- {
- syslog(LOG_ERR, "No printer-is-shared attribute found in "
- "response from server!");
- *shared = 1;
- }
- else
- *shared = attr->values[0].boolean;
- }
+ if (accepting)
+ {
+ if ((attr = ippFindAttribute(response, "printer-is-accepting-jobs",
+ IPP_TAG_BOOLEAN)) == NULL)
+ syslog(LOG_ERR, "No printer-is-accepting-jobs attribute found in "
+ "response from server!");
+ else
+ *accepting = attr->values[0].boolean;
+ }
- if (state)
+ if (shared)
+ {
+ if ((attr = ippFindAttribute(response, "printer-is-shared",
+ IPP_TAG_BOOLEAN)) == NULL)
{
- if ((attr = ippFindAttribute(response, "printer-state",
- IPP_TAG_ENUM)) == NULL)
- syslog(LOG_ERR, "No printer-state attribute found in "
- "response from server!");
- else
- *state = (ipp_pstate_t)attr->values[0].integer;
+ syslog(LOG_ERR, "No printer-is-shared attribute found in "
+ "response from server!");
+ *shared = 1;
}
+ else
+ *shared = attr->values[0].boolean;
+ }
- ippDelete(response);
+ if (state)
+ {
+ if ((attr = ippFindAttribute(response, "printer-state",
+ IPP_TAG_ENUM)) == NULL)
+ syslog(LOG_ERR, "No printer-state attribute found in "
+ "response from server!");
+ else
+ *state = (ipp_pstate_t)attr->values[0].integer;
}
+ ippDelete(response);
+
/*
* Override shared value for LPD using system-specific APIs...
*/
/*
- * End of "$Id: cups-lpd.c 6327 2007-03-12 14:32:10Z mike $".
+ * End of "$Id: cups-lpd.c 6670 2007-07-13 23:15:02Z mike $".
*/