/*
* IPP data file parsing functions.
*
- * Copyright © 2007-2018 by Apple Inc.
+ * Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* Include necessary headers...
*/
-#include <cups/cups.h>
+#include "cups-private.h"
#include "ipp-private.h"
#include "string-private.h"
+#include "debug-internal.h"
/*
_ippVarsGet(_ipp_vars_t *v, /* I - IPP variables */
const char *name) /* I - Variable name */
{
- if (!strcmp(name, "uri"))
+ if (!v)
+ return (NULL);
+ else if (!strcmp(name, "uri"))
return (v->uri);
else if (!strcmp(name, "uriuser") || !strcmp(name, "username"))
return (v->username[0] ? v->username : NULL);
*/
void
-_ippVarsInit(_ipp_vars_t *v) /* I - IPP variables */
+_ippVarsInit(_ipp_vars_t *v, /* I - IPP variables */
+ _ipp_fattr_cb_t attrcb, /* I - Attribute (filter) callback */
+ _ipp_ferror_cb_t errorcb, /* I - Error callback */
+ _ipp_ftoken_cb_t tokencb) /* I - Token callback */
{
memset(v, 0, sizeof(_ipp_vars_t));
- v->family = AF_UNSPEC;
+ v->attrcb = attrcb;
+ v->errorcb = errorcb;
+ v->tokencb = tokencb;
}
{
if (!strcmp(name, "uri"))
{
- char uri[1024]; /* New printer URI */
- http_uri_status_t uri_status; /* URI status */
+ char uri[1024]; /* New printer URI */
+ char resolved[1024]; /* Resolved mDNS URI */
+
+ if (strstr(value, "._tcp"))
+ {
+ /*
+ * Resolve URI...
+ */
+
+ if (!_httpResolveURI(value, resolved, sizeof(resolved), _HTTP_RESOLVE_DEFAULT, NULL, NULL))
+ return (0);
+
+ value = resolved;
+ }
- if ((uri_status = httpSeparateURI(HTTP_URI_CODING_ALL, value, v->scheme, sizeof(v->scheme), v->username, sizeof(v->username), v->host, sizeof(v->host), &(v->port), v->resource, sizeof(v->resource))) < HTTP_URI_STATUS_OK)
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, value, v->scheme, sizeof(v->scheme), v->username, sizeof(v->username), v->host, sizeof(v->host), &(v->port), v->resource, sizeof(v->resource)) < HTTP_URI_STATUS_OK)
return (0);
if (v->username[0])