]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/printers.c
Merge changes from CUPS 1.4svn-r7582.
[thirdparty/cups.git] / scheduler / printers.c
index 640f02ac287f01b4f9d156690c7fd01dabd7f2a2..ce03647b4885d980ac7dcdfbcf23474962b6e52d 100644 (file)
@@ -1816,6 +1816,13 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
                {                       /* No authentication */
                  "none"
                };
+  static const char * const standard_commands[] =
+               {                       /* Standard CUPS commands */
+                 "AutoConfigure",
+                 "Clean",
+                 "PrintSelfTestPage",
+                 "ReportLevels"
+               };
 
 
   DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name,
@@ -2308,6 +2315,88 @@ cupsdSetPrinterAttrs(cupsd_printer_t *p)/* I - Printer to setup */
           p->type |= CUPS_PRINTER_COMMANDS;
         }
 
+        if (p->type & CUPS_PRINTER_COMMANDS)
+       {
+         char  *commands,              /* Copy of commands */
+               *start,                 /* Start of name */
+               *end;                   /* End of name */
+          int  count;                  /* Number of commands */
+
+
+          if ((ppdattr = ppdFindAttr(ppd, "cupsCommands", NULL)) != NULL &&
+             ppdattr->value && ppdattr->value[0])
+         {
+           for (count = 0, start = ppdattr->value; *start; count ++)
+           {
+             while (isspace(*start & 255))
+               start ++;
+
+             if (!*start)
+               break;
+
+             while (*start && !isspace(*start & 255))
+               start ++;
+           }
+         }
+         else
+           count = 0;
+
+          if (count > 0)
+         {
+          /*
+           * Make a copy of the commands string and count how many ...
+           */
+
+           attr = ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+                                "printer-commands", count, NULL, NULL);
+
+           commands = strdup(ppdattr->value);
+
+           for (count = 0, start = commands; *start; count ++)
+           {
+             while (isspace(*start & 255))
+               start ++;
+
+             if (!*start)
+               break;
+
+              end = start;
+             while (*end && !isspace(*end & 255))
+               end ++;
+
+              if (*end)
+               *end++ = '\0';
+
+              attr->values[count].string.text = _cupsStrAlloc(start);
+
+              start = end;
+           }
+
+           free(commands);
+          }
+         else
+         {
+          /*
+           * Add the standard list of commands...
+           */
+
+           ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+                         "printer-commands",
+                         (int)(sizeof(standard_commands) /
+                               sizeof(standard_commands[0])), NULL,
+                         standard_commands);
+         }
+       }
+       else
+       {
+        /*
+         * No commands supported...
+         */
+
+         ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+                      "printer-commands", NULL, "none");
+        }
+
        /*
        * Show current and available port monitors for this printer...
        */