/*
- * "$Id$"
- *
* HTTP support routines for CUPS.
*
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
if (!ptr)
goto assemble_overflow;
- if (!strcmp(scheme, "mailto") || !strcmp(scheme, "tel"))
+ if (!strcmp(scheme, "geo") || !strcmp(scheme, "mailto") || !strcmp(scheme, "tel"))
{
/*
- * mailto: and tel: only have :, no //...
+ * geo:, mailto:, and tel: only have :, no //...
*/
if (ptr < end)
else
{
/*
- * Schemes other than mailto: and tel: all have //...
+ * Schemes other than geo:, mailto:, and tel: typically have //...
*/
if ((ptr + 2) < end)
if (port > 0)
{
- snprintf(ptr, end - ptr + 1, ":%d", port);
+ snprintf(ptr, (size_t)(end - ptr + 1), ":%d", port);
ptr += strlen(ptr);
if (ptr >= end)
break;
case 3 :
if (outptr < outend)
- *outptr++ |= base64;
+ *outptr++ |= (char)base64;
pos = 0;
break;
}
tdate = gmtime(&t);
if (tdate)
- snprintf(s, slen, "%s, %02d %s %d %02d:%02d:%02d GMT",
- http_days[tdate->tm_wday], tdate->tm_mday,
- http_months[tdate->tm_mon], tdate->tm_year + 1900,
- tdate->tm_hour, tdate->tm_min, tdate->tm_sec);
+ snprintf(s, (size_t)slen, "%s, %02d %s %d %02d:%02d:%02d GMT", http_days[tdate->tm_wday], tdate->tm_mday, http_months[tdate->tm_mon], tdate->tm_year + 1900, tdate->tm_hour, tdate->tm_min, tdate->tm_sec);
else
s[0] = '\0';
* Workaround for HP IPP client bug...
*/
- strlcpy(scheme, "ipp", schemelen);
+ strlcpy(scheme, "ipp", (size_t)schemelen);
status = HTTP_URI_STATUS_MISSING_SCHEME;
}
else if (*uri == '/')
* Filename...
*/
- strlcpy(scheme, "file", schemelen);
+ strlcpy(scheme, "file", (size_t)schemelen);
status = HTTP_URI_STATUS_MISSING_SCHEME;
}
else
*port = (int)strtol(uri + 1, (char **)&uri, 10);
+ if (*port <= 0 || *port > 65535)
+ {
+ *port = 0;
+ return (HTTP_URI_STATUS_BAD_PORT);
+ }
+
if (*uri != '/' && *uri)
{
*port = 0;
/*
* 'httpStateString()' - Return the string describing a HTTP state value.
*
- * @since CUPS 2.0@
+ * @since CUPS 2.0/OS 10.10@
*/
const char * /* O - State string */
/*
* 'httpURIStatusString()' - Return a string describing a URI status code.
*
- * @since CUPS 2.0@
+ * @since CUPS 2.0/OS 10.10@
*/
const char * /* O - Localized status string */
#endif /* DEBUG */
- DEBUG_printf(("4_httpResolveURI(uri=\"%s\", resolved_uri=%p, "
- "resolved_size=" CUPS_LLFMT ")", uri, resolved_uri,
- CUPS_LLCAST resolved_size));
+ DEBUG_printf(("_httpResolveURI(uri=\"%s\", resolved_uri=%p, resolved_size=" CUPS_LLFMT ", options=0x%x, cb=%p, context=%p)", uri, (void *)resolved_uri, CUPS_LLCAST resolved_size, options, (void *)cb, context));
/*
* Get the device URI...
if (options & _HTTP_RESOLVE_STDERR)
_cupsLangPrintFilter(stderr, "ERROR", _("Bad device-uri \"%s\"."), uri);
- DEBUG_printf(("6_httpResolveURI: httpSeparateURI returned %d!", status));
- DEBUG_puts("5_httpResolveURI: Returning NULL");
+ DEBUG_printf(("2_httpResolveURI: httpSeparateURI returned %d!", status));
+ DEBUG_puts("2_httpResolveURI: Returning NULL");
return (NULL);
}
# endif /* WIN32 */
DNSServiceRef ref, /* DNS-SD master service reference */
domainref = NULL,/* DNS-SD service reference for domain */
+ ippref = NULL, /* DNS-SD service reference for network IPP */
+ ippsref = NULL, /* DNS-SD service reference for network IPPS */
localref; /* DNS-SD service reference for .local */
- int domainsent = 0; /* Send the domain resolve? */
+ int extrasent = 0; /* Send the domain/IPP/IPPS resolves? */
# ifdef HAVE_POLL
struct pollfd polldata; /* Polling data */
# else /* select() */
if (regtype <= hostname)
{
- DEBUG_puts("5_httpResolveURI: Bad hostname, returning NULL");
+ DEBUG_puts("2_httpResolveURI: Bad hostname, returning NULL");
return (NULL);
}
uribuf.resource = resource;
uribuf.uuid = uuid;
- DEBUG_printf(("6_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", "
+ DEBUG_printf(("2_httpResolveURI: Resolving hostname=\"%s\", regtype=\"%s\", "
"domain=\"%s\"\n", hostname, regtype, domain));
if (options & _HTTP_RESOLVE_STDERR)
{
while (time(NULL) < end_time)
{
if (options & _HTTP_RESOLVE_STDERR)
- _cupsLangPrintFilter(stderr, "INFO", _("Looking for printer."));
+ _cupsLangPrintFilter(stderr, "INFO", _("Looking for printer..."));
if (cb && !(*cb)(context))
{
- DEBUG_puts("5_httpResolveURI: callback returned 0 (stop)");
+ DEBUG_puts("2_httpResolveURI: callback returned 0 (stop)");
break;
}
{
if (errno != EINTR && errno != EAGAIN)
{
- DEBUG_printf(("5_httpResolveURI: poll error: %s", strerror(errno)));
+ DEBUG_printf(("2_httpResolveURI: poll error: %s", strerror(errno)));
break;
}
}
* comes in, do an additional domain resolution...
*/
- if (domainsent == 0 && domain && _cups_strcasecmp(domain, "local."))
+ if (extrasent == 0 && domain && _cups_strcasecmp(domain, "local."))
{
if (options & _HTTP_RESOLVE_STDERR)
fprintf(stderr,
myinterface, hostname, regtype, domain,
http_resolve_cb,
&uribuf) == kDNSServiceErr_NoError)
- domainsent = 1;
+ extrasent = 1;
+ }
+ else if (extrasent == 0 && !strcmp(scheme, "ippusb"))
+ {
+ if (options & _HTTP_RESOLVE_STDERR)
+ fprintf(stderr, "DEBUG: Resolving \"%s\", regtype=\"_ipps._tcp\", domain=\"local.\"...\n", hostname);
+
+ ippsref = ref;
+ if (DNSServiceResolve(&ippsref,
+ kDNSServiceFlagsShareConnection,
+ kDNSServiceInterfaceIndexAny, hostname,
+ "_ipps._tcp", domain, http_resolve_cb,
+ &uribuf) == kDNSServiceErr_NoError)
+ extrasent = 1;
+ }
+ else if (extrasent == 1 && !strcmp(scheme, "ippusb"))
+ {
+ if (options & _HTTP_RESOLVE_STDERR)
+ fprintf(stderr, "DEBUG: Resolving \"%s\", regtype=\"_ipp._tcp\", domain=\"local.\"...\n", hostname);
+
+ ippref = ref;
+ if (DNSServiceResolve(&ippref,
+ kDNSServiceFlagsShareConnection,
+ kDNSServiceInterfaceIndexAny, hostname,
+ "_ipp._tcp", domain, http_resolve_cb,
+ &uribuf) == kDNSServiceErr_NoError)
+ extrasent = 2;
}
/*
}
}
- if (domainsent)
- DNSServiceRefDeallocate(domainref);
+ if (extrasent)
+ {
+ if (domainref)
+ DNSServiceRefDeallocate(domainref);
+ if (ippref)
+ DNSServiceRefDeallocate(ippref);
+ if (ippsref)
+ DNSServiceRefDeallocate(ippsref);
+ }
DNSServiceRefDeallocate(localref);
}
uri = resolved_uri;
}
- DEBUG_printf(("5_httpResolveURI: Returning \"%s\"", uri));
+ DEBUG_printf(("2_httpResolveURI: Returning \"%s\"", uri));
return (uri);
}
uint8_t valueLen; /* Length of value */
- DEBUG_printf(("7http_resolve_cb(sdRef=%p, flags=%x, interfaceIndex=%u, "
- "errorCode=%d, fullName=\"%s\", hostTarget=\"%s\", port=%u, "
- "txtLen=%u, txtRecord=%p, context=%p)", sdRef, flags,
- interfaceIndex, errorCode, fullName, hostTarget, port, txtLen,
- txtRecord, context));
+ DEBUG_printf(("4http_resolve_cb(sdRef=%p, flags=%x, interfaceIndex=%u, errorCode=%d, fullName=\"%s\", hostTarget=\"%s\", port=%u, txtLen=%u, txtRecord=%p, context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, fullName, hostTarget, port, txtLen, (void *)txtRecord, context));
/*
* If we have a UUID, compare it...
fprintf(stderr, "DEBUG: Found UUID %s, looking for %s.", uuid,
uribuf->uuid);
- DEBUG_printf(("7http_resolve_cb: Found UUID %s, looking for %s.", uuid,
+ DEBUG_printf(("5http_resolve_cb: Found UUID %s, looking for %s.", uuid,
uribuf->uuid));
return;
}
http_addrlist_t *addrlist, /* List of addresses */
*addr; /* Current address */
- DEBUG_printf(("8http_resolve_cb: Looking up \"%s\".", hostTarget));
+ DEBUG_printf(("5http_resolve_cb: Looking up \"%s\".", hostTarget));
snprintf(fqdn, sizeof(fqdn), "%d", ntohs(port));
if ((addrlist = httpAddrGetList(hostTarget, AF_UNSPEC, fqdn)) != NULL)
if (!error)
{
- DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
+ DEBUG_printf(("5http_resolve_cb: Found \"%s\".", fqdn));
if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
_cups_strcasecmp(hostptr, ".local"))
}
#ifdef DEBUG
else
- DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
+ DEBUG_printf(("5http_resolve_cb: \"%s\" did not resolve: %d",
httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
error));
#endif /* DEBUG */
else
httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, (int)uribuf->bufsize, scheme, NULL, hostTarget, ntohs(port), resource);
- DEBUG_printf(("8http_resolve_cb: Resolved URI is \"%s\"...", uribuf->buffer));
+ DEBUG_printf(("5http_resolve_cb: Resolved URI is \"%s\"...", uribuf->buffer));
}
#elif defined(HAVE_AVAHI)
size_t valueLen = 0; /* Length of "rp" key */
- DEBUG_printf(("7http_resolve_cb(resolver=%p, "
+ DEBUG_printf(("4http_resolve_cb(resolver=%p, "
"interface=%d, protocol=%d, event=%d, name=\"%s\", "
"type=\"%s\", domain=\"%s\", hostTarget=\"%s\", address=%p, "
"port=%d, txt=%p, flags=%d, context=%p)",
fprintf(stderr, "DEBUG: Found UUID %s, looking for %s.", uuid,
uribuf->uuid);
- DEBUG_printf(("7http_resolve_cb: Found UUID %s, looking for %s.", uuid,
+ DEBUG_printf(("5http_resolve_cb: Found UUID %s, looking for %s.", uuid,
uribuf->uuid));
return;
}
http_addrlist_t *addrlist, /* List of addresses */
*addr; /* Current address */
- DEBUG_printf(("8http_resolve_cb: Looking up \"%s\".", hostTarget));
+ DEBUG_printf(("5http_resolve_cb: Looking up \"%s\".", hostTarget));
snprintf(fqdn, sizeof(fqdn), "%d", ntohs(port));
if ((addrlist = httpAddrGetList(hostTarget, AF_UNSPEC, fqdn)) != NULL)
{
for (addr = addrlist; addr; addr = addr->next)
{
- int error = getnameinfo(&(addr->addr.addr),
- httpAddrLength(&(addr->addr)),
- fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
+ int error = getnameinfo(&(addr->addr.addr), (socklen_t)httpAddrLength(&(addr->addr)), fqdn, sizeof(fqdn), NULL, 0, NI_NAMEREQD);
if (!error)
{
- DEBUG_printf(("8http_resolve_cb: Found \"%s\".", fqdn));
+ DEBUG_printf(("5http_resolve_cb: Found \"%s\".", fqdn));
if ((hostptr = fqdn + strlen(fqdn) - 6) <= fqdn ||
_cups_strcasecmp(hostptr, ".local"))
}
#ifdef DEBUG
else
- DEBUG_printf(("8http_resolve_cb: \"%s\" did not resolve: %d",
+ DEBUG_printf(("5http_resolve_cb: \"%s\" did not resolve: %d",
httpAddrString(&(addr->addr), fqdn, sizeof(fqdn)),
error));
#endif /* DEBUG */
httpAssembleURI(HTTP_URI_CODING_ALL, uribuf->buffer, uribuf->bufsize, scheme,
NULL, hostTarget, port, resource);
- DEBUG_printf(("8http_resolve_cb: Resolved URI is \"%s\".", uribuf->buffer));
+ DEBUG_printf(("5http_resolve_cb: Resolved URI is \"%s\".", uribuf->buffer));
avahi_simple_poll_quit(uribuf->poll);
}
#endif /* HAVE_DNSSD */
-
-
-/*
- * End of "$Id$".
- */