]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/ipp-vars.c
Merge pull request #5913 from apple/bug-fix-rollup-1
[thirdparty/cups.git] / cups / ipp-vars.c
index d9f4cf0cbdcec54254719eba35507566e4582953..69efbd9aa0751ef28e61cc38a797a8255f90c100 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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"
 
 
 /*
@@ -133,7 +134,9 @@ const char *                                /* O - Value or @code NULL@ if not set */
 _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);
@@ -157,11 +160,16 @@ _ippVarsGet(_ipp_vars_t *v,               /* I - IPP variables */
  */
 
 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;
 }
 
 
@@ -212,10 +220,22 @@ _ippVarsSet(_ipp_vars_t *v,               /* I - IPP variables */
 {
   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])