]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Advertise auth-info-required via CUPS browsing and DNS-SD.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 19 Mar 2007 06:16:32 +0000 (06:16 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Mon, 19 Mar 2007 06:16:32 +0000 (06:16 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@6354 7a7537e8-13f0-0310-91df-b6672ffda945

scheduler/dirsvc.c
scheduler/printers.c

index 6146daef813391720626611dc0beeb367ff7d8ac..c1920dbe07b9b99531f45e8a54d62939589b36fb 100644 (file)
@@ -2448,10 +2448,11 @@ dnssdBuildTxtRecord(
     int             *txt_len,          /* O - TXT record length */
     cupsd_printer_t *p)                        /* I - Printer information */
 {
-  int          i;                      /* Looping var */
+  int          i, j;                   /* Looping vars */
   char         type_str[32],           /* Type to string buffer */
                state_str[32],          /* State to string buffer */
                rp_str[1024],           /* Queue name string buffer */
+               air_str[1024],          /* auth-info-required string buffer */
                *keyvalue[32][2];       /* Table of key/value pairs */
 
 
@@ -2556,6 +2557,27 @@ dnssdBuildTxtRecord(
   keyvalue[i  ][0] = "pdl";
   keyvalue[i++][1] = p->pdl ? p->pdl : "application/postscript";
 
+  if (p->num_auth_info_required)
+  {
+    char       *air = air_str;         /* Pointer into string */
+
+
+    for (j = 0; j < p->num_auth_info_required; j ++)
+    {
+      if (air >= (air_str + sizeof(air_str) - 2))
+        break;
+
+      if (j)
+        *air++ = ',';
+
+      strlcpy(air, p->auth_info_required[j], sizeof(air_str) - (air - air_str));
+      air += strlen(air);
+    }
+
+    keyvalue[i  ][0] = "air";
+    keyvalue[i++][1] = air;
+  }
+
  /*
   * Then pack them into a proper txt record...
   */
@@ -3082,7 +3104,7 @@ process_implicit_classes(void)
 
 /*
  * 'send_cups_browse()' - Send new browsing information using the CUPS
- *                           protocol.
+ *                        protocol.
  */
 
 static void
index fb2e0d3636c604db212180fe76ed2c23cdeb26ea..09c22b4b5a094d6550affd7242a097ab300401e0 100644 (file)
@@ -2288,6 +2288,14 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
     if (BrowseLocalOptions)
       length += 12 + strlen(BrowseLocalOptions);
 
+    if (p->num_auth_info_required > 0)
+    {
+      length += 18;                    /* auth-info-required */
+
+      for (i = 0; i < p->num_auth_info_required; i ++)
+        length += strlen(p->auth_info_required[i]) + 1;
+    }
+
    /*
     * Allocate the new string...
     */
@@ -2334,7 +2342,20 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
        }
       }
 
-      *attrptr = '\0';
+      if (p->num_auth_info_required > 0)
+      {
+        strcpy(attrptr, "auth-info-required");
+       attrptr += 18;
+
+       for (i = 0; i < p->num_auth_info_required; i ++)
+       {
+         *attrptr++ = i ? ',' : '=';
+         strcpy(attrptr, p->auth_info_required[i]);
+         attrptr += strlen(attrptr);
+       }
+      }
+      else
+       *attrptr = '\0';
     }
   }