*/
if (!http)
- http = _cupsConnect();
+ {
+ /*
+ * See if we are connected to the same server...
+ */
+
+ if (cg->http)
+ {
+ /*
+ * Compare the connection hostname, port, and encryption settings to
+ * the cached defaults; these were initialized the first time we
+ * connected...
+ */
+
+ if (strcmp(cg->http->hostname, cg->server) ||
+ cg->ipp_port != _httpAddrPort(cg->http->hostaddr) ||
+ (cg->http->encryption != cg->encryption &&
+ cg->http->encryption == HTTP_ENCRYPT_NEVER))
+ {
+ /*
+ * Need to close the current connection because something has changed...
+ */
+
+ httpClose(cg->http);
+ cg->http = NULL;
+ }
+ }
+
+ /*
+ * (Re)connect as needed...
+ */
+
+ if (!cg->http)
+ {
+ if ((cg->http = _httpCreate(cupsServer(), ippPort(),
+ cupsEncryption())) == NULL)
+ {
+ if (errno)
+ _cupsSetError(IPP_SERVICE_UNAVAILABLE, NULL, 0);
+ else
+ _cupsSetError(IPP_SERVICE_UNAVAILABLE,
+ _("Unable to connect to host."), 1);
+
+ if (num_settings)
+ *num_settings = 0;
+
+ if (settings)
+ *settings = NULL;
+
+ return (0);
+ }
+ }
+ }
if (!http || !num_settings || !settings)
{
extern int cupsResolveConflicts(ppd_file_t *ppd, const char *option,
const char *choice,
int *num_options,
- cups_option_t **options);
+ cups_option_t **options)
+ _CUPS_API_1_4;
extern http_status_t cupsSendRequest(http_t *http, ipp_t *request,
const char *resource,
size_t length) _CUPS_API_1_4;
*
* Contents:
*
+ * debug_vsnprintf() - Format a string into a fixed size buffer.
* _cups_debug_printf() - Write a formatted line to the log.
* _cups_debug_puts() - Write a single line to the log.
*/
*/
if (!dests)
+ {
+ _cupsSetError(IPP_INTERNAL_ERROR, _("Bad NULL dests pointer"), 1);
return (0);
+ }
/*
* Initialize destination array...
* Return the number of destinations...
*/
+ if (num_dests > 0)
+ _cupsSetError(IPP_OK, NULL, 0);
+
return (num_dests);
}
*
* HTTP address routines for the Common UNIX Printing System (CUPS).
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
* httpAddrEqual() - Compare two addresses.
* httpAddrLocalhost() - Check for the local loopback address.
* httpAddrLookup() - Lookup the hostname associated with the address.
+ * _httpAddrPort() - Get the port number associated with an address.
* httpAddrString() - Convert an IP address to a dotted string.
* httpGetHostByName() - Lookup a hostname or IP address, and return
* address records for the specified name.
}
+/*
+ * '_httpAddrPort()' - Get the port number associated with an address.
+ */
+
+int /* O - Port number */
+_httpAddrPort(http_addr_t *addr) /* I - Address */
+{
+#ifdef AF_INET6
+ if (addr->addr.sa_family == AF_INET6)
+ return (ntohs(addr->ipv6.sin6_port));
+ else
+#endif /* AF_INET6 */
+ if (addr->addr.sa_family == AF_INET)
+ return (ntohs(addr->ipv4.sin_port));
+ else
+ return (ippPort());
+}
+
+
/*
* 'httpAddrString()' - Convert an address to a numeric string.
*
#include "globals.h"
#include "debug.h"
#include <stdlib.h>
+#include <errno.h>
/*
int *sock) /* O - Socket */
{
int val; /* Socket option value */
+#ifdef DEBUG
+ char temp[256]; /* Temporary address string */
+#endif /* DEBUG */
+
+ DEBUG_printf(("httpAddrConnect(addrlist=%p, sock=%p)\n", addrlist, sock));
+
+ if (!sock)
+ {
+ errno = EINVAL;
+ return (NULL);
+ }
/*
* Loop through each address until we connect or run out of addresses...
* Create the socket...
*/
- if ((*sock = (int)socket(addrlist->addr.addr.sa_family, SOCK_STREAM, 0)) < 0)
+ DEBUG_printf(("httpAddrConnect: Trying %s:%d...\n",
+ httpAddrString(&(addrlist->addr), temp, sizeof(temp)),
+ _httpAddrPort(&(addrlist->addr))));
+
+ if ((*sock = (int)socket(addrlist->addr.addr.sa_family, SOCK_STREAM,
+ 0)) < 0)
{
/*
* Don't abort yet, as this could just be an issue with the local
if (!connect(*sock, &(addrlist->addr.addr),
httpAddrLength(&(addrlist->addr))))
+ {
+ DEBUG_printf(("httpAddrConnect: Connected to %s:%d...\n",
+ httpAddrString(&(addrlist->addr), temp, sizeof(temp)),
+ _httpAddrPort(&(addrlist->addr))));
break;
+ }
+
+ DEBUG_printf(("httpAddrConnect: Unable to connect to %s:%d: %s\n",
+ httpAddrString(&(addrlist->addr), temp, sizeof(temp)),
+ _httpAddrPort(&(addrlist->addr)), strerror(errno)));
/*
* Close this socket and move to the next address...
close(*sock);
#endif /* WIN32 */
+ *sock = -1;
addrlist = addrlist->next;
}
# endif /* !WIN32 */
/*
- * Common URI functions...
+ * Prototypes...
*/
+extern int _httpAddrPort(http_addr_t *addr);
+extern http_t *_httpCreate(const char *host, int port,
+ http_encryption_t encryption);
extern char *_httpEncodeURI(char *dst, const char *src,
size_t dstsize);
extern const char *_httpResolveURI(const char *uri, char *resolved_uri,
/*
* 'httpConnect()' - Connect to a HTTP server.
+ *
+ * This function is deprecated - use @link httpConnectEncrypt@ instead.
+ *
+ * @deprecated@
*/
http_t * /* O - New HTTP connection */
httpConnect(const char *host, /* I - Host to connect to */
int port) /* I - Port number */
{
- http_encryption_t encryption; /* Type of encryption to use */
+ return (httpConnectEncrypt(host, port, HTTP_ENCRYPT_IF_REQUESTED));
+}
+
+
+/*
+ * 'httpConnectEncrypt()' - Connect to a HTTP server using encryption.
+ */
+
+http_t * /* O - New HTTP connection */
+httpConnectEncrypt(
+ const char *host, /* I - Host to connect to */
+ int port, /* I - Port number */
+ http_encryption_t encryption) /* I - Type of encryption to use */
+{
+ http_t *http; /* New HTTP connection */
+ DEBUG_printf(("httpConnectEncrypt(host=\"%s\", port=%d, encryption=%d)\n",
+ host, port, encryption));
+
/*
- * Set the default encryption status...
+ * Create the HTTP structure...
*/
- if (port == 443)
- encryption = HTTP_ENCRYPT_ALWAYS;
- else
- encryption = HTTP_ENCRYPT_IF_REQUESTED;
+ if ((http = _httpCreate(host, port, encryption)) == NULL)
+ return (NULL);
- return (httpConnectEncrypt(host, port, encryption));
+ /*
+ * Connect to the remote system...
+ */
+
+ if (!httpReconnect(http))
+ return (http);
+
+ /*
+ * Could not connect to any known address - bail out!
+ */
+
+ httpAddrFreeList(http->addrlist);
+
+ free(http);
+
+ return (NULL);
}
/*
- * 'httpConnectEncrypt()' - Connect to a HTTP server using encryption.
+ * '_httpCreate()' - Create an unconnected HTTP connection.
*/
-http_t * /* O - New HTTP connection */
-httpConnectEncrypt(
- const char *host, /* I - Host to connect to */
+http_t * /* O - HTTP connection */
+_httpCreate(
+ const char *host, /* I - Hostname */
int port, /* I - Port number */
- http_encryption_t encryption) /* I - Type of encryption to use */
+ http_encryption_t encryption) /* I - Encryption to use */
{
http_t *http; /* New HTTP connection */
http_addrlist_t *addrlist; /* Host address data */
char service[255]; /* Service name */
- DEBUG_printf(("httpConnectEncrypt(host=\"%s\", port=%d, encryption=%d)\n",
- host ? host : "(null)", port, encryption));
+ DEBUG_printf(("_httpCreate(host=\"%s\", port=%d, encryption=%d)\n",
+ host, port, encryption));
if (!host)
return (NULL);
return (NULL);
}
- http->version = HTTP_1_1;
- http->blocking = 1;
+ /*
+ * Initialize the HTTP data...
+ */
+
http->activity = time(NULL);
+ http->addrlist = addrlist;
+ http->blocking = 1;
http->fd = -1;
-
#ifdef HAVE_GSSAPI
- http->gssctx = GSS_C_NO_CONTEXT;
- http->gssname = GSS_C_NO_NAME;
+ http->gssctx = GSS_C_NO_CONTEXT;
+ http->gssname = GSS_C_NO_NAME;
#endif /* HAVE_GSSAPI */
+ http->version = HTTP_1_1;
- /*
- * Set the encryption status...
- */
+ strlcpy(http->hostname, host, sizeof(http->hostname));
if (port == 443) /* Always use encryption for https */
http->encryption = HTTP_ENCRYPT_ALWAYS;
http->encryption = encryption;
/*
- * Loop through the addresses we have until one of them connects...
+ * Return the new structure...
*/
- strlcpy(http->hostname, host, sizeof(http->hostname));
-
- /*
- * Connect to the remote system...
- */
-
- http->addrlist = addrlist;
-
- if (!httpReconnect(http))
- return (http);
-
- /*
- * Could not connect to any known address - bail out!
- */
-
- httpAddrFreeList(addrlist);
-
- free(http);
-
- return (NULL);
+ return (http);
}
httpReconnect(http_t *http) /* I - Connection to server */
{
http_addrlist_t *addr; /* Connected address */
+#ifdef DEBUG
+ http_addrlist_t *current; /* Current address */
+ char temp[256]; /* Temporary address string */
+#endif /* DEBUG */
DEBUG_printf(("httpReconnect(http=%p)\n", http));
#ifdef HAVE_SSL
if (http->tls)
+ {
+ DEBUG_puts("httpReconnect: Shutting down SSL/TLS...");
http_shutdown_ssl(http);
+ }
#endif /* HAVE_SSL */
/*
if (http->fd >= 0)
{
+ DEBUG_printf(("httpReconnect: Closing socket %d...\n", http->fd));
+
#ifdef WIN32
closesocket(http->fd);
#else
close(http->fd);
#endif /* WIN32 */
+ usleep(100000);
+
http->fd = -1;
}
* Connect to the server...
*/
+#ifdef DEBUG
+ for (current = http->addrlist; current; current = current->next)
+ DEBUG_printf(("httpReconnect: Address %s:%d\n",
+ httpAddrString(&(current->addr), temp, sizeof(temp)),
+ _httpAddrPort(&(current->addr))));
+#endif /* DEBUG */
+
if ((addr = httpAddrConnect(http->addrlist, &(http->fd))) == NULL)
{
/*
#endif /* WIN32 */
http->status = HTTP_ERROR;
+ DEBUG_printf(("httpReconnect: httpAddrConnect failed: %s\n",
+ strerror(http->error)));
+
return (-1);
}
+ DEBUG_printf(("httpReconnect: New socket=%d\n", http->fd));
+
http->hostaddr = &(addr->addr);
http->error = 0;
http->status = HTTP_CONTINUE;
return (http_upgrade(http));
#endif /* HAVE_SSL */
+ DEBUG_printf(("httpReconnect: Connected to %s:%d...\n",
+ httpAddrString(http->hostaddr, temp, sizeof(temp)),
+ _httpAddrPort(http->hostaddr)));
+
return (0);
}
/*
- * "$Id: ipp-support.c 7460 2008-04-16 02:19:54Z mike $"
+ * "$Id: ipp-support.c 7847 2008-08-19 04:22:14Z mike $"
*
* Internet Printing Protocol support functions for the Common UNIX
* Printing System (CUPS).
* const ipp_cups_ops2[] =
{
"CUPS-Get-Document"
+ },
+ * const ipp_tag_names[] =
+ { /* Value/group tag names */
+ "zero", /* 0x00 */
+ "operation-attributes-tag",
+ /* 0x01 */
+ "job-attributes-tag", /* 0x02 */
+ "end-of-attributes-tag",
+ /* 0x03 */
+ "printer-attributes-tag",
+ /* 0x04 */
+ "unsupported-attributes-tag",
+ /* 0x05 */
+ "subscription-attributes-tag",
+ /* 0x06 */
+ "event-notification-attributes-tag",
+ /* 0x07 */
+ "unknown-08", /* 0x08 */
+ "unknown-09", /* 0x09 */
+ "unknown-0a", /* 0x0a */
+ "unknown-0b", /* 0x0b */
+ "unknown-0c", /* 0x0c */
+ "unknown-0d", /* 0x0d */
+ "unknown-0e", /* 0x0e */
+ "unknown-0f", /* 0x0f */
+ "unsupported", /* 0x10 */
+ "default", /* 0x11 */
+ "unknown", /* 0x12 */
+ "no-value", /* 0x13 */
+ "unknown-14", /* 0x14 */
+ "not-settable", /* 0x15 */
+ "delete-attribute", /* 0x16 */
+ "admin-define", /* 0x17 */
+ "unknown-18", /* 0x18 */
+ "unknown-19", /* 0x19 */
+ "unknown-1a", /* 0x1a */
+ "unknown-1b", /* 0x1b */
+ "unknown-1c", /* 0x1c */
+ "unknown-1d", /* 0x1d */
+ "unknown-1e", /* 0x1e */
+ "unknown-1f", /* 0x1f */
+ "unknown-20", /* 0x20 */
+ "integer", /* 0x21 */
+ "boolean", /* 0x22 */
+ "enum", /* 0x23 */
+ "unknown-24", /* 0x24 */
+ "unknown-25", /* 0x25 */
+ "unknown-26", /* 0x26 */
+ "unknown-27", /* 0x27 */
+ "unknown-28", /* 0x28 */
+ "unknown-29", /* 0x29 */
+ "unknown-2a", /* 0x2a */
+ "unknown-2b", /* 0x2b */
+ "unknown-2c", /* 0x2c */
+ "unknown-2d", /* 0x2d */
+ "unknown-2e", /* 0x2e */
+ "unknown-2f", /* 0x2f */
+ "octetString", /* 0x30 */
+ "dateTime", /* 0x31 */
+ "resolution", /* 0x32 */
+ "rangeOfInteger", /* 0x33 */
+ "begCollection", /* 0x34 */
+ "textWithLanguage", /* 0x35 */
+ "nameWithLanguage", /* 0x36 */
+ "endCollection", /* 0x37 */
+ "unknown-38", /* 0x38 */
+ "unknown-39", /* 0x39 */
+ "unknown-3a", /* 0x3a */
+ "unknown-3b", /* 0x3b */
+ "unknown-3c", /* 0x3c */
+ "unknown-3d", /* 0x3d */
+ "unknown-3e", /* 0x3e */
+ "unknown-3f", /* 0x3f */
+ "unknown-40", /* 0x40 */
+ "textWithoutLanguage",/* 0x41 */
+ "nameWithoutLanguage",/* 0x42 */
+ "unknown-43", /* 0x43 */
+ "keyword", /* 0x44 */
+ "uri", /* 0x45 */
+ "uriScheme", /* 0x46 */
+ "charset", /* 0x47 */
+ "naturalLanguage", /* 0x48 */
+ "mimeMediaType", /* 0x49 */
+ "memberAttrName" /* 0x4a */
};
/*
- * End of "$Id: ipp-support.c 7460 2008-04-16 02:19:54Z mike $".
+ * 'ippTagString()' - Return the tag name corresponding to a tag value.
+ *
+ * The returned names are defined in RFC 2911 and 3382.
+ *
+ * @since CUPS 1.4@
+ */
+
+const char * /* O - Tag name */
+ippTagString(ipp_tag_t tag) /* I - Tag value */
+{
+ if (tag < (ipp_tag_t)(sizeof(ipp_tag_names) / sizeof(ipp_tag_names[0])))
+ return (ipp_tag_names[tag]);
+ else
+ return ("UNKNOWN");
+}
+
+
+/*
+ * 'ippTagValue()' - Return the tag value corresponding to a tag name.
+ *
+ * The tag names are defined in RFC 2911 and 3382.
+ *
+ * @since CUPS 1.4@
+ */
+
+ipp_tag_t /* O - Tag value */
+ippTagValue(const char *name) /* I - Tag name */
+{
+ int i; /* Looping var */
+
+
+ for (i = 0; i < (sizeof(ipp_tag_names) / sizeof(ipp_tag_names[0])); i ++)
+ if (!strcasecmp(name, ipp_tag_names[i]))
+ return ((ipp_tag_t)i);
+
+ if (!strcasecmp(name, "operation"))
+ return (IPP_TAG_OPERATION);
+ else if (!strcasecmp(name, "job"))
+ return (IPP_TAG_JOB);
+ else if (!strcasecmp(name, "printer"))
+ return (IPP_TAG_PRINTER);
+ else if (!strcasecmp(name, "subscription"))
+ return (IPP_TAG_SUBSCRIPTION);
+ else if (!strcasecmp(name, "language"))
+ return (IPP_TAG_LANGUAGE);
+ else if (!strcasecmp(name, "mimetype"))
+ return (IPP_TAG_MIMETYPE);
+ else if (!strcasecmp(name, "name"))
+ return (IPP_TAG_NAME);
+ else if (!strcasecmp(name, "text"))
+ return (IPP_TAG_TEXT);
+ else
+ return (IPP_TAG_ZERO);
+}
+
+
+/*
+ * End of "$Id: ipp-support.c 7847 2008-08-19 04:22:14Z mike $".
*/
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddBoolean(%p, %02x, \'%s\', %d)\n", ipp, group, name, value));
+ DEBUG_printf(("ippAddBoolean(ipp=%p, group=%02x(%s), name=\"%s\", value=%d)\n",
+ ipp, group, ippTagString(group), name, value));
- if (ipp == NULL || name == NULL)
+ if (!ipp || !name)
return (NULL);
if ((attr = _ippAddAttr(ipp, 1)) == NULL)
ipp_value_t *value; /* Current value */
- DEBUG_printf(("ippAddBooleans(%p, %02x, \'%s\', %d, %p)\n", ipp,
- group, name, num_values, values));
+ DEBUG_printf(("ippAddBooleans(ipp=%p, group=%02x(%s), name=\"%s\", "
+ "num_values=%d, values=%p)\n", ipp, group, ippTagString(group),
+ name, num_values, values));
- if (ipp == NULL || name == NULL || num_values < 1)
+ if (!ipp || !name || num_values < 1)
return (NULL);
if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddCollection(%p, %02x, \'%s\', %p)\n", ipp, group, name,
- value));
+ DEBUG_printf(("ippAddCollection(ipp=%p, group=%02x(%s), name=\"%s\", "
+ "value=%p)\n", ipp, group, ippTagString(group), name, value));
- if (ipp == NULL || name == NULL)
+ if (!ipp || !name)
return (NULL);
if ((attr = _ippAddAttr(ipp, 1)) == NULL)
ipp_value_t *value; /* Current value */
- DEBUG_printf(("ippAddCollections(%p, %02x, \'%s\', %d, %p)\n", ipp,
- group, name, num_values, values));
+ DEBUG_printf(("ippAddCollections(ipp=%p, group=%02x(%s), name=\"%s\", "
+ "num_values=%d, values=%p)\n", ipp, group, ippTagString(group),
+ name, num_values, values));
- if (ipp == NULL || name == NULL || num_values < 1)
+ if (!ipp || !name || num_values < 1)
return (NULL);
if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddDate(%p, %02x, \'%s\', %p)\n", ipp, group, name,
- value));
+ DEBUG_printf(("ippAddDate(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)\n",
+ ipp, group, ippTagString(group), name, value));
- if (ipp == NULL || name == NULL || value == NULL)
+ if (!ipp || !name || !value)
return (NULL);
if ((attr = _ippAddAttr(ipp, 1)) == NULL)
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddInteger(%p, %d, \'%s\', %d)\n", ipp, group, name,
- value));
+ DEBUG_printf(("ippAddInteger(ipp=%p, group=%02x(%s), type=%02x(%s), "
+ "name=\"%s\", value=%d)\n", ipp, group, ippTagString(group),
+ type, ippTagString(type), name, value));
- if (ipp == NULL || name == NULL)
+ if (!ipp || !name)
return (NULL);
if ((attr = _ippAddAttr(ipp, 1)) == NULL)
ipp_value_t *value; /* Current value */
- if (ipp == NULL || name == NULL || num_values < 1)
+ DEBUG_printf(("ippAddIntegers(ipp=%p, group=%02x(%s), type=%02x(%s), "
+ "name=\"%s\", num_values=%d, values=%p)\n", ipp,
+ group, ippTagString(group), type, ippTagString(type), name,
+ num_values, values));
+
+ if (!ipp || !name || num_values < 1)
return (NULL);
if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
*bufptr; /* Pointer into buffer */
- if (ipp == NULL || name == NULL)
+ DEBUG_printf(("ippAddString(ipp=%p, group=%02x(%s), type=%02x(%s), "
+ "name=\"%s\", charset=\"%s\", value=\"%s\")\n", ipp,
+ group, ippTagString(group), type, ippTagString(type), name,
+ charset, value));
+
+ if (!ipp || !name)
return (NULL);
if ((attr = _ippAddAttr(ipp, 1)) == NULL)
ipp_value_t *value; /* Current value */
- if (ipp == NULL || name == NULL || num_values < 1)
+ DEBUG_printf(("ippAddStrings(ipp=%p, group=%02x(%s), type=%02x(%s), "
+ "name=\"%s\", num_values=%d, charset=\"%s\", values=%p)\n", ipp,
+ group, ippTagString(group), type, ippTagString(type), name,
+ num_values, charset, values));
+
+ if (!ipp || !name || num_values < 1)
return (NULL);
if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
ipp_attribute_t *attr; /* New attribute */
- if (ipp == NULL || name == NULL)
+ DEBUG_printf(("ippAddRange(ipp=%p, group=%02x(%s), name=\"%s\", lower=%d, "
+ "upper=%d)\n", ipp, group, ippTagString(group), name, lower,
+ upper));
+
+ if (!ipp || !name)
return (NULL);
if ((attr = _ippAddAttr(ipp, 1)) == NULL)
ipp_value_t *value; /* Current value */
- if (ipp == NULL || name == NULL || num_values < 1)
+ DEBUG_printf(("ippAddRanges(ipp=%p, group=%02x(%s), name=\"%s\", "
+ "num_values=%d, lower=%p, upper=%p)\n", ipp, group,
+ ippTagString(group), name, num_values, lower, upper));
+
+ if (!ipp || !name || num_values < 1)
return (NULL);
if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
ipp_attribute_t *attr; /* New attribute */
- if (ipp == NULL || name == NULL)
+ DEBUG_printf(("ippAddResolution(ipp=%p, group=%02x(%s), name=\"%s\", "
+ "units=%d, xres=%d, yres=%d)\n", ipp, group,
+ ippTagString(group), name, units, xres, yres));
+
+ if (!ipp || !name)
return (NULL);
if ((attr = _ippAddAttr(ipp, 1)) == NULL)
ipp_value_t *value; /* Current value */
- if (ipp == NULL || name == NULL || num_values < 1)
+ DEBUG_printf(("ippAddResolutions(ipp=%p, group=%02x(%s), name=\"%s\", "
+ "num_value=%d, units=%d, xres=%p, yres=%p)\n", ipp, group,
+ ippTagString(group), name, num_values, units, xres, yres));
+
+ if (!ipp || !name || num_values < 1)
return (NULL);
if ((attr = _ippAddAttr(ipp, num_values)) == NULL)
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddSeparator(%p)\n", ipp));
+ DEBUG_printf(("ippAddSeparator(ipp=%p)\n", ipp));
- if (ipp == NULL)
+ if (!ipp)
return (NULL);
if ((attr = _ippAddAttr(ipp, 0)) == NULL)
time_t t; /* Computed time */
+ if (!date)
+ return (0);
+
memset(&unixdate, 0, sizeof(unixdate));
/*
*next; /* Next attribute */
- DEBUG_printf(("ippDelete(): %p\n", ipp));
+ DEBUG_printf(("ippDelete(ipp=%p)\n", ipp));
- if (ipp == NULL)
+ if (!ipp)
return;
for (attr = ipp->attrs; attr != NULL; attr = next)
*prev; /* Previous attribute */
+ DEBUG_printf(("ippDeleteAttribute(ipp=%p, attr=%p)\n", ipp, attr));
+
/*
* Find the attribute in the list...
*/
const char *name, /* I - Name of attribute */
ipp_tag_t type) /* I - Type of attribute */
{
- DEBUG_printf(("ippFindAttribute(%p, \'%s\')\n", ipp, name));
+ DEBUG_printf(("ippFindAttribute(ipp=%p, name=\"%s\", type=%02x(%s))\n", ipp,
+ name, type, ippTagString(type)));
- if (ipp == NULL || name == NULL)
+ if (!ipp || !name)
return (NULL);
/*
ipp_tag_t value_tag; /* Value tag */
- DEBUG_printf(("ippFindNextAttribute(%p, \'%s\')\n", ipp, name));
+ DEBUG_printf(("ippFindNextAttribute(ipp=%p, name=\"%s\", type=%02x(%s))\n",
+ ipp, name, type, ippTagString(type)));
- if (ipp == NULL || name == NULL)
+ if (!ipp || !name)
return (NULL);
if (ipp->current)
for (; attr != NULL; ipp->prev = attr, attr = attr->next)
{
- DEBUG_printf(("ippFindAttribute: attr = %p, name = \'%s\'\n", attr,
+ DEBUG_printf(("ippFindAttribute: attr=%p, name=\"%s\"\n", attr,
attr->name));
value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_MASK);
cups_lang_t *language; /* Current language localization */
+ DEBUG_printf(("ippNewRequest(op=%02x(%s))\n", op, ippOpString(op)));
+
/*
* Create a new IPP message...
*/
DEBUG_printf(("ippRead(http=%p, ipp=%p), data_remaining=" CUPS_LLFMT "\n",
http, ipp, CUPS_LLCAST (http ? http->data_remaining : -1)));
- if (http == NULL)
+ if (!http)
return (IPP_ERROR);
DEBUG_printf(("ippRead: http->state=%d, http->used=%d\n", http->state,
ippReadFile(int fd, /* I - HTTP data */
ipp_t *ipp) /* I - IPP data */
{
- DEBUG_printf(("ippReadFile(%d, %p)\n", fd, ipp));
+ DEBUG_printf(("ippReadFile(fd=%d, ipp=%p)\n", fd, ipp));
return (ippReadIO(&fd, (ipp_iocb_t)ipp_read_file, 1, NULL, ipp));
}
src, cb, blocking, parent, ipp));
DEBUG_printf(("ippReadIO: ipp->state=%d\n", ipp->state));
- if (src == NULL || ipp == NULL)
+ if (!src || !ipp)
return (IPP_ERROR);
switch (ipp->state)
if (buffer[0] != 1)
{
- DEBUG_printf(("ippReadIO: version number (%d.%d) is bad.\n", buffer[0],
- buffer[1]));
+ DEBUG_printf(("ippReadIO: version number (%d.%d) is bad.\n",
+ buffer[0], buffer[1]));
return (IPP_ERROR);
}
ipp->curtag = tag;
ipp->current = NULL;
- DEBUG_printf(("ippReadIO: group tag = %x, ipp->prev=%p\n", tag,
- ipp->prev));
+ DEBUG_printf(("ippReadIO: group tag=%x(%s), ipp->prev=%p\n", tag,
+ ippTagString(tag), ipp->prev));
continue;
}
- DEBUG_printf(("ippReadIO: value tag = %x\n", tag));
+ DEBUG_printf(("ippReadIO: value tag=%x(%s)\n", tag,
+ ippTagString(tag)));
/*
* Get the name...
return (IPP_ERROR);
}
- DEBUG_printf(("ippReadIO: name length = %d\n", n));
+ DEBUG_printf(("ippReadIO: name length=%d\n", n));
if (n == 0 && tag != IPP_TAG_MEMBERNAME &&
tag != IPP_TAG_END_COLLECTION)
attr->value_tag = tag;
}
- else if (value_tag >= IPP_TAG_TEXTLANG &&
- value_tag <= IPP_TAG_MIMETYPE)
+ else if ((value_tag >= IPP_TAG_TEXTLANG &&
+ value_tag <= IPP_TAG_MIMETYPE))
{
/*
* String values can sometimes come across in different
* forms; accept sets of differing values...
*/
- if (tag < IPP_TAG_TEXTLANG || tag > IPP_TAG_MIMETYPE)
+ if ((tag < IPP_TAG_TEXTLANG || tag > IPP_TAG_MIMETYPE) &&
+ tag != IPP_TAG_NOVALUE)
+ {
+ DEBUG_printf(("ippReadIO: 1setOf value tag %x(%s) != %x(%s)\n",
+ value_tag, ippTagString(value_tag), tag,
+ ippTagString(tag)));
return (IPP_ERROR);
+ }
}
else if (value_tag != tag)
+ {
+ DEBUG_printf(("ippReadIO: value tag %x(%s) != %x(%s)\n",
+ value_tag, ippTagString(value_tag), tag,
+ ippTagString(tag)));
return (IPP_ERROR);
+ }
/*
* Finally, reallocate the attribute array as needed...
attr = ipp->current = _ippAddAttr(ipp, 1);
- DEBUG_printf(("ippReadIO: membername, ipp->current=%p, ipp->prev=%p\n",
- ipp->current, ipp->prev));
+ DEBUG_printf(("ippReadIO: membername, ipp->current=%p, "
+ "ipp->prev=%p\n", ipp->current, ipp->prev));
attr->group_tag = ipp->curtag;
attr->value_tag = IPP_TAG_ZERO;
return (IPP_ERROR);
}
- DEBUG_printf(("ippReadIO: name=\'%s\', ipp->current=%p, ipp->prev=%p\n",
- buffer, ipp->current, ipp->prev));
+ DEBUG_printf(("ippReadIO: name=\"%s\", ipp->current=%p, "
+ "ipp->prev=%p\n", buffer, ipp->current, ipp->prev));
attr->group_tag = ipp->curtag;
attr->value_tag = tag;
}
n = (buffer[0] << 8) | buffer[1];
- DEBUG_printf(("ippReadIO: value length = %d\n", n));
+ DEBUG_printf(("ippReadIO: value length=%d\n", n));
switch (tag)
{
value->boolean = buffer[0];
break;
+ case IPP_TAG_NOVALUE :
+ if (attr->value_tag == IPP_TAG_NOVALUE)
+ {
+ if (n == 0)
+ break;
+
+ attr->value_tag = IPP_TAG_TEXT;
+ }
+
case IPP_TAG_TEXT :
case IPP_TAG_NAME :
case IPP_TAG_KEYWORD :
buffer[n] = '\0';
value->string.text = _cupsStrAlloc((char *)buffer);
- DEBUG_printf(("ippReadIO: value = \'%s\'\n",
+ DEBUG_printf(("ippReadIO: value=\"%s\"\n",
value->string.text));
break;
if (n > 0)
{
- DEBUG_puts("ippReadIO: begCollection tag with value length > 0!");
+ DEBUG_puts("ippReadIO: begCollection tag with value length "
+ "> 0!");
return (IPP_ERROR);
}
case IPP_TAG_END_COLLECTION :
if (n > 0)
{
- DEBUG_puts("ippReadIO: endCollection tag with value length > 0!");
+ DEBUG_puts("ippReadIO: endCollection tag with value length "
+ "> 0!");
return (IPP_ERROR);
}
attr->num_values --;
- DEBUG_printf(("ippReadIO: member name = \"%s\"\n", attr->name));
+ DEBUG_printf(("ippReadIO: member name=\"%s\"\n", attr->name));
break;
default : /* Other unsupported values */
ippWrite(http_t *http, /* I - HTTP connection */
ipp_t *ipp) /* I - IPP data */
{
- DEBUG_printf(("ippWrite(%p, %p)\n", http, ipp));
+ DEBUG_printf(("ippWrite(http=%p, ipp=%p)\n", http, ipp));
- if (http == NULL)
+ if (!http)
return (IPP_ERROR);
return (ippWriteIO(http, (ipp_iocb_t)httpWrite2,
ippWriteFile(int fd, /* I - HTTP data */
ipp_t *ipp) /* I - IPP data */
{
- DEBUG_printf(("ippWriteFile(%d, %p)\n", fd, ipp));
+ DEBUG_printf(("ippWriteFile(fd=%d, ipp=%p)\n", fd, ipp));
ipp->state = IPP_IDLE;
ipp_value_t *value; /* Current value */
- DEBUG_printf(("ippWriteIO(%p, %p, %d, %p, %p)\n", dst, cb, blocking,
- parent, ipp));
+ DEBUG_printf(("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)\n",
+ dst, cb, blocking, parent, ipp));
- if (dst == NULL || ipp == NULL)
+ if (!dst || !ipp)
return (IPP_ERROR);
switch (ipp->state)
ipp->curtag = IPP_TAG_ZERO;
DEBUG_printf(("ippWriteIO: version=%d.%d\n", buffer[0], buffer[1]));
- DEBUG_printf(("ippWriteIO: op_status=%04x\n", ipp->request.any.op_status));
- DEBUG_printf(("ippWriteIO: request_id=%d\n", ipp->request.any.request_id));
+ DEBUG_printf(("ippWriteIO: op_status=%04x\n",
+ ipp->request.any.op_status));
+ DEBUG_printf(("ippWriteIO: request_id=%d\n",
+ ipp->request.any.request_id));
/*
* If blocking is disabled, stop here...
if (attr->group_tag == IPP_TAG_ZERO)
continue;
- DEBUG_printf(("ippWriteIO: wrote group tag = %x\n", attr->group_tag));
+ DEBUG_printf(("ippWriteIO: wrote group tag=%x(%s)\n",
+ attr->group_tag, ippTagString(attr->group_tag)));
*bufptr++ = attr->group_tag;
}
else if (attr->group_tag == IPP_TAG_ZERO)
* Write the value tag, name length, and name string...
*/
- DEBUG_printf(("ippWriteIO: writing value tag = %x\n", attr->value_tag));
- DEBUG_printf(("ippWriteIO: writing name = %d, \'%s\'\n", n, attr->name));
+ DEBUG_printf(("ippWriteIO: writing value tag=%x(%s)\n",
+ attr->value_tag, ippTagString(attr->value_tag)));
+ DEBUG_printf(("ippWriteIO: writing name=%d,\"%s\"\n", n,
+ attr->name));
*bufptr++ = attr->value_tag;
*bufptr++ = n >> 8;
* and empty name for the collection member attribute...
*/
- DEBUG_printf(("ippWriteIO: writing value tag = %x\n",
+ DEBUG_printf(("ippWriteIO: writing value tag=%x(memberName)\n",
IPP_TAG_MEMBERNAME));
- DEBUG_printf(("ippWriteIO: writing name = %d, \'%s\'\n", n, attr->name));
- DEBUG_printf(("ippWriteIO: writing value tag = %x\n", attr->value_tag));
- DEBUG_puts("ippWriteIO: writing name = 0, \'\'\n");
+ DEBUG_printf(("ippWriteIO: writing name=%d,\"%s\"\n", n,
+ attr->name));
+ DEBUG_printf(("ippWriteIO: writing value tag=%x(%s)\n",
+ attr->value_tag, ippTagString(attr->value_tag)));
+ DEBUG_puts("ippWriteIO: writing name=0,\"\"\n");
*bufptr++ = IPP_TAG_MEMBERNAME;
*bufptr++ = 0;
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
* values with a zero-length name...
*/
- DEBUG_printf(("ippWriteIO: writing value tag = %x\n",
- attr->value_tag));
- DEBUG_printf(("ippWriteIO: writing name = 0, \'\'\n"));
+ DEBUG_printf(("ippWriteIO: writing value tag=%x(%s)\n",
+ attr->value_tag,
+ ippTagString(attr->value_tag)));
+ DEBUG_printf(("ippWriteIO: writing name=0,\"\"\n"));
if ((sizeof(buffer) - (bufptr - buffer)) < 3)
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
if (n > (sizeof(buffer) - 2))
return (IPP_ERROR);
- DEBUG_printf(("ippWriteIO: writing string = %d, \'%s\'\n", n,
+ DEBUG_printf(("ippWriteIO: writing string=%d,\"%s\"\n", n,
value->string.text));
if ((int)(sizeof(buffer) - (bufptr - buffer)) < (n + 2))
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
{
if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
{
- DEBUG_puts("ippWriteIO: Could not write IPP attribute...");
+ DEBUG_puts("ippWriteIO: Could not write IPP "
+ "attribute...");
return (IPP_ERROR);
}
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("_ippAddAttr(%p, %d)\n", ipp, num_values));
+ DEBUG_printf(("_ippAddAttr(ipp=%p, num_values=%d)\n", ipp, num_values));
- if (ipp == NULL || num_values < 0)
+ if (!ipp || num_values < 0)
return (NULL);
attr = calloc(sizeof(ipp_attribute_t) +
ipp_value_t *value; /* Current value */
- DEBUG_printf(("_ippFreeAttr(): %p\n", attr));
+ DEBUG_printf(("_ippFreeAttr(attr=%p)\n", attr));
switch (attr->value_tag)
{
extern ipp_state_t ippWriteIO(void *dst, ipp_iocb_t cb, int blocking,
ipp_t *parent, ipp_t *ipp) _CUPS_API_1_2;
+/**** New in CUPS 1.4 ****/
+extern const char *ippTagString(ipp_tag_t tag) _CUPS_API_1_4;
+extern ipp_tag_t ippTagValue(const char *name) _CUPS_API_1_4;
+
/*
* C++ magic...
__cupsStrFree
__cupsStrScand
__cupsStrStatistics
+__httpAddrPort
+__httpCreate
__httpEncodeURI
__httpReadCDSA
__httpResolveURI
_cups_strcpy
_cups_strlcat
_cups_strlcpy
+_httpAddrPort
_httpBIOMethods
+_httpCreate
_httpEncodeURI
_httpResolveURI
_ippAddAttr
* Wait for a response from the server...
*/
- DEBUG_puts("cupsGetResponse: Update loop...");
+ DEBUG_printf(("cupsGetResponse: Update loop, http->status=%d...\n",
+ http->status));
- while ((status = httpUpdate(http)) == HTTP_CONTINUE)
- /* Do nothing but update */;
+ status = http->status;
+ while (status == HTTP_CONTINUE)
+ status = httpUpdate(http);
DEBUG_printf(("cupsGetResponse: status=%d\n", status));
return (HTTP_SERVICE_UNAVAILABLE);
#endif /* HAVE_SSL */
+ /*
+ * Reconnect if the last response had a "Connection: close"...
+ */
+
+ if (!strcasecmp(http->fields[HTTP_FIELD_CONNECTION], "close"))
+ if (httpReconnect(http))
+ return (HTTP_SERVICE_UNAVAILABLE);
+
/*
* Loop until we can send the request without authorization problems.
*/
unsigned char buffer[CUPS_SNMP_MAX_PACKET];
/* SNMP message buffer */
int bytes; /* Size of message */
+ http_addr_t temp; /* Copy of address */
/*
* Send the message...
*/
+ temp = *address;
+
#ifdef AF_INET6
- if (address->addr.sa_family == AF_INET6)
- address->ipv6.sin6_port = htons(CUPS_SNMP_PORT);
+ if (temp.addr.sa_family == AF_INET6)
+ temp.ipv6.sin6_port = htons(CUPS_SNMP_PORT);
else
#endif /* AF_INET6 */
- address->ipv4.sin_port = htons(CUPS_SNMP_PORT);
+ temp.ipv4.sin_port = htons(CUPS_SNMP_PORT);
- return (sendto(fd, buffer, bytes, 0, (void *)address,
- httpAddrLength(address)) == bytes);
+ return (sendto(fd, buffer, bytes, 0, (void *)&temp,
+ httpAddrLength(&temp)) == bytes);
}
resource, sizeof(resource), 0))
return (HTTP_NOT_FOUND);
- DEBUG_printf(("cupsGetPPD3: Printer hostname=\"%s\", port=%d\n", hostname, port));
+ DEBUG_printf(("cupsGetPPD3: Printer hostname=\"%s\", port=%d\n", hostname,
+ port));
/*
* Remap local hostname to localhost...
httpGetHostname(NULL, localhost, sizeof(localhost));
- DEBUG_printf(("Local hostname=\"%s\"\n", localhost));
+ DEBUG_printf(("cupsGetPPD3: Local hostname=\"%s\"\n", localhost));
if (!strcasecmp(localhost, hostname))
strcpy(hostname, "localhost");
*/
httpGetHostname(http, http_hostname, sizeof(http_hostname));
+ http_port = _httpAddrPort(http->hostaddr);
-#ifdef AF_INET6
- if (http->hostaddr->addr.sa_family == AF_INET6)
- http_port = ntohs(http->hostaddr->ipv6.sin6_port);
- else
-#endif /* AF_INET6 */
- if (http->hostaddr->addr.sa_family == AF_INET)
- http_port = ntohs(http->hostaddr->ipv4.sin_port);
- else
- http_port = ippPort();
-
- DEBUG_printf(("Connection hostname=\"%s\", port=%d\n", http_hostname,
- http_port));
+ DEBUG_printf(("cupsGetPPD3: Connection hostname=\"%s\", port=%d\n",
+ http_hostname, http_port));
/*
* Reconnect to the correct server as needed...
else if ((http2 = httpConnectEncrypt(hostname, port,
cupsEncryption())) == NULL)
{
- DEBUG_puts("Unable to connect to server!");
+ DEBUG_puts("cupsGetPPD3: Unable to connect to server!");
return (HTTP_SERVICE_UNAVAILABLE);
}
break;
default :
- DEBUG_printf(("HTTP error %d mapped to IPP_SERVICE_UNAVAILABLE!\n",
- status));
+ DEBUG_printf(("cupsGetPPD3: HTTP error %d mapped to "
+ "IPP_SERVICE_UNAVAILABLE!\n", status));
_cupsSetError(IPP_SERVICE_UNAVAILABLE, httpStatus(status), 0);
break;
}
if (cg->http)
{
- int port; /* Port for connection */
-
-
- /*
- * Get the port associated with the current connection...
- */
-
-#ifdef AF_INET6
- if (cg->http->hostaddr->addr.sa_family == AF_INET6)
- port = ntohs(cg->http->hostaddr->ipv6.sin6_port);
- else
-#endif /* AF_INET6 */
- if (cg->http->hostaddr->addr.sa_family == AF_INET)
- port = ntohs(cg->http->hostaddr->ipv4.sin_port);
- else
- port = cg->ipp_port;
-
/*
* Compare the connection hostname, port, and encryption settings to
* the cached defaults; these were initialized the first time we
* connected...
*/
- if (strcmp(cg->http->hostname, cg->server) || cg->ipp_port != port ||
+ if (strcmp(cg->http->hostname, cg->server) ||
+ cg->ipp_port != _httpAddrPort(cg->http->hostaddr) ||
(cg->http->encryption != cg->encryption &&
cg->http->encryption == HTTP_ENCRYPT_NEVER))
{
*/
httpGetHostname(http, http_hostname, sizeof(http_hostname));
-
-#ifdef AF_INET6
- if (http->hostaddr->addr.sa_family == AF_INET6)
- http_port = ntohs(http->hostaddr->ipv6.sin6_port);
- else
-#endif /* AF_INET6 */
- if (http->hostaddr->addr.sa_family == AF_INET)
- http_port = ntohs(http->hostaddr->ipv4.sin_port);
- else
- http_port = ippPort();
+ http_port = _httpAddrPort(http->hostaddr);
/*
* Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
{ "BrowseInterval", &BrowseInterval, CUPSD_VARTYPE_INTEGER },
#ifdef HAVE_LDAP
{ "BrowseLDAPBindDN", &BrowseLDAPBindDN, CUPSD_VARTYPE_STRING },
+# ifdef HAVE_LDAP_SSL
{ "BrowseLDAPCACertFile", &BrowseLDAPCACertFile, CUPSD_VARTYPE_PATHNAME },
+# endif /* HAVE_LDAP_SSL */
{ "BrowseLDAPDN", &BrowseLDAPDN, CUPSD_VARTYPE_STRING },
{ "BrowseLDAPPassword", &BrowseLDAPPassword, CUPSD_VARTYPE_STRING },
{ "BrowseLDAPServer", &BrowseLDAPServer, CUPSD_VARTYPE_STRING },
cupsdClearString(&BrowseLDAPDN);
cupsdClearString(&BrowseLDAPPassword);
cupsdClearString(&BrowseLDAPServer);
+# ifdef HAVE_LDAP_SSL
cupsdClearString(&BrowseLDAPCACertFile);
+# endif /* HAVE_LDAP_SSL */
#endif /* HAVE_LDAP */
JobHistory = DEFAULT_HISTORY;
* Directory services definitions for the Common UNIX Printing System
* (CUPS) scheduler.
*
- * Copyright 2007 by Apple Inc.
+ * Copyright 2007-2008 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
/* Next LDAP refresh time */
VAR char *BrowseLDAPBindDN VALUE(NULL),
/* LDAP login DN */
- *BrowseLDAPCACertFile VALUE(NULL),
- /* LDAP CA cert file */
*BrowseLDAPDN VALUE(NULL),
/* LDAP search DN */
*BrowseLDAPPassword VALUE(NULL),
*
* main() - Parse options and do tests.
* do_tests() - Do tests as specified in the test file.
- * get_tag() - Get an IPP value or group tag from a name...
+ * ippTagValue() - Get an IPP value or group tag from a name...
* get_token() - Get a token from a file.
* print_attr() - Print an attribute on the screen.
* usage() - Show program usage.
*/
int Verbosity = 0; /* Show all attributes? */
-const char * const TagNames[] =
- { /* Value/group tag names */
- "zero", /* 0x00 */
- "operation", /* 0x01 */
- "job", /* 0x02 */
- "end", /* 0x03 */
- "printer", /* 0x04 */
- "unsupported-group", /* 0x05 */
- "subscription", /* 0x06 */
- "event-notification", /* 0x07 */
- "", "", "", "", "", "", "", "",
- "unsupported-value", /* 0x10 */
- "default", /* 0x11 */
- "unknown", /* 0x12 */
- "novalue", /* 0x13 */
- "",
- "notsettable", /* 0x15 */
- "deleteattr", /* 0x16 */
- "anyvalue", /* 0x17 */
- "", "", "", "", "", "", "", "", "",
- "integer", /* 0x21 */
- "boolean", /* 0x22 */
- "enum", /* 0x23 */
- "", "", "", "", "", "", "", "", "", "", "", "",
- "string", /* 0x30 */
- "date", /* 0x31 */
- "resolution", /* 0x32 */
- "range", /* 0x33 */
- "collection", /* 0x34 */
- "textlang", /* 0x35 */
- "namelang", /* 0x36 */
- "", "", "", "", "", "", "", "", "", "",
- "text", /* 0x41 */
- "name", /* 0x42 */
- "",
- "keyword", /* 0x44 */
- "uri", /* 0x45 */
- "urischeme", /* 0x46 */
- "charset", /* 0x47 */
- "language", /* 0x48 */
- "mimetype" /* 0x49 */
- };
-
-
/*
int do_tests(const char *, const char *);
ipp_op_t ippOpValue(const char *);
ipp_status_t ippErrorValue(const char *);
-ipp_tag_t get_tag(const char *);
-const char *get_tag_string(ipp_tag_t tag);
char *get_token(FILE *, char *, int, int *linenum);
void print_attr(ipp_attribute_t *);
void usage(const char *option);
*/
get_token(fp, token, sizeof(token), &linenum);
- value = get_tag(token);
+ value = ippTagValue(token);
if (value == group)
ippAddSeparator(request);
*/
get_token(fp, token, sizeof(token), &linenum);
- value = get_tag(token);
+ value = ippTagValue(token);
get_token(fp, attr, sizeof(attr), &linenum);
get_token(fp, temp, sizeof(temp), &linenum);
}
-/*
- * 'get_tag()' - Get an IPP value or group tag from a name...
- */
-
-ipp_tag_t /* O - Value/group tag */
-get_tag(const char *name) /* I - Name of value/group tag */
-{
- int i; /* Looping var */
-
-
- for (i = 0; i < (sizeof(TagNames) / sizeof(TagNames[0])); i ++)
- if (!strcasecmp(name, TagNames[i]))
- return ((ipp_tag_t)i);
-
- return (IPP_TAG_ZERO);
-}
-
-
-/*
- * 'get_tag_string()' - Get the string associated with a tag.
- */
-
-const char * /* O - Tag name string */
-get_tag_string(ipp_tag_t tag) /* I - IPP tag */
-{
- if (tag < (ipp_tag_t)(sizeof(TagNames) / sizeof(TagNames[0])))
- return (TagNames[tag]);
- else
- return ("UNKNOWN");
-}
-
-
/*
* 'get_token()' - Get a token from a file.
*/
printf(" %s (%s%s) = ", attr->name,
attr->num_values > 1 ? "1setOf " : "",
- get_tag_string(attr->value_tag));
+ ippTagString(attr->value_tag));
switch (attr->value_tag)
{
# Error log messages
count=`grep '^E ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
-if test $count != 9; then
- echo "FAIL: $count error messages, expected 9."
+if test $count != 17; then
+ echo "FAIL: $count error messages, expected 17."
grep '^E ' /tmp/cups-$user/log/error_log
echo "<P>FAIL: $count error messages, expected 9.</P>" >>$strfile
echo "<PRE>" >>$strfile