/*
- * "$Id: cups-lpd.c 5455 2006-04-24 13:49:59Z 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:
*
int destsize, cups_option_t **options,
int *accepting, int *shared, ipp_pstate_t *state);
static int print_file(http_t *http, int id, const char *filename,
- const char *docname, const char *user, int last);
+ const char *docname, const char *user,
+ const char *format, int last);
static int recv_print_job(const char *name, int num_defaults,
cups_option_t *defaults);
static int remove_jobs(const char *name, const char *agent,
num_defaults = 0;
defaults = NULL;
hostlookups = 1;
- num_defaults = cupsAddOption("job-originating-host-name", hostname,
- num_defaults, &defaults);
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-')
hostip);
}
+ num_defaults = cupsAddOption("job-originating-host-name", hostname,
+ num_defaults, &defaults);
+
/*
* RFC1179 specifies that only 1 daemon command can be received for
* every connection.
*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...
+ */
+
+ 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...
*/
- if (strchr(name, ' '))
+ 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...
*/
request = ippNewRequest(CUPS_GET_PRINTERS);
- ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+ ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes",
(int)(sizeof(requested) / sizeof(requested[0])),
NULL, requested);
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_NAME,
- "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_INTEGER)) == 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...
*/
const char *filename, /* I - File to print */
const char *docname, /* I - document-name */
const char *user, /* I - requesting-user-name */
+ const char *format, /* I - document-format */
int last) /* I - 1 = last file in job */
{
ipp_t *request; /* IPP request */
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"document-name", NULL, docname);
+ if (format)
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_MIMETYPE,
+ "document-format", NULL, format);
+
if (last)
ippAddBoolean(request, IPP_TAG_OPERATION, "last-document", 1);
docnumber ++;
if (print_file(http, id, temp[i], docname, user,
+ cupsGetOption("document-format", num_options,
+ options),
docnumber == doccount))
status = 1;
else
return (1);
}
else
- syslog(LOG_INFO, "Job ID %d cancelled", id);
+ syslog(LOG_INFO, "Job ID %d canceled", id);
}
httpClose(http);
/*
- * End of "$Id: cups-lpd.c 5455 2006-04-24 13:49:59Z mike $".
+ * End of "$Id: cups-lpd.c 6670 2007-07-13 23:15:02Z mike $".
*/