+
+ free(temp);
+
+ /*
+ * Update the printer-supply and printer-supply-description, as needed...
+ */
+
+ if (!strcmp(name, "marker-names"))
+ {
+ ipp_attribute_t *supply_desc = ippFindAttribute(p->attrs, "printer-supply-description", IPP_TAG_TEXT);
+ /* printer-supply-description attribute */
+
+ if (supply_desc != NULL)
+ ippDeleteAttribute(p->attrs, supply_desc);
+
+ supply_desc = ippCopyAttribute(p->attrs, attr, 0);
+ ippSetName(p->attrs, &supply_desc, "printer-supply-description");
+ ippSetValueTag(p->attrs, &supply_desc, IPP_TAG_TEXT);
+ }
+ else if (!strcmp(name, "marker-colors") || !strcmp(name, "marker-levels") || !strcmp(name, "marker-types"))
+ {
+ char buffer[256], /* printer-supply values */
+ pstype[64], /* printer-supply type value */
+ *psptr; /* Pointer into type */
+ const char *color, /* marker-colors value */
+ *type; /* marker-types value */
+ int level; /* marker-levels value */
+ ipp_attribute_t *colors = ippFindAttribute(p->attrs, "marker-colors", IPP_TAG_NAME);
+ /* marker-colors attribute */
+ ipp_attribute_t *levels = ippFindAttribute(p->attrs, "marker-levels", IPP_TAG_INTEGER);
+ /* marker-levels attribute */
+ ipp_attribute_t *types = ippFindAttribute(p->attrs, "marker-types", IPP_TAG_KEYWORD);
+ /* marker-types attribute */
+ ipp_attribute_t *supply = ippFindAttribute(p->attrs, "printer-supply", IPP_TAG_STRING);
+ /* printer-supply attribute */
+
+ if (supply != NULL)
+ {
+ ippDeleteAttribute(p->attrs, supply);
+ supply = NULL;
+ }
+
+ if (!colors || !levels || !types)
+ return;
+
+ count = ippGetCount(colors);
+ if (count != ippGetCount(levels) || count != ippGetCount(types))
+ return;
+
+ for (i = 0; i < count; i ++)
+ {
+ color = ippGetString(colors, i, NULL);
+ level = ippGetInteger(levels, i);
+ type = ippGetString(types, i, NULL);
+
+ for (psptr = pstype; *type && psptr < (pstype + sizeof(pstype) - 1); type ++)
+ if (*type == '-')
+ {
+ type ++;
+ *psptr++ = (char)toupper(*type & 255);
+ }
+ else
+ *psptr++ = *type;
+ *psptr = '\0';
+
+ snprintf(buffer, sizeof(buffer), "index=%d;class=%s;type=%s;unit=percent;maxcapacity=100;level=%d;colorantname=%s;", i + 1, strncmp(pstype, "waste", 5) ? "supplyThatIsConsumed" : "receptacleThatIsFilled", pstype, level, color);
+
+ if (!i)
+ supply = ippAddOctetString(p->attrs, IPP_TAG_PRINTER, "printer-supply", buffer, (int)strlen(buffer));
+ else
+ ippSetOctetString(p->attrs, &supply, i, buffer, (int)strlen(buffer));
+ }
+ }