| 7182 | */ |
| 7183 | |
| 7184 | static int /* O - 1 on success, 0 on error */ |
| 7185 | register_printer( |
| 7186 | ippeve_printer_t *printer) /* I - Printer */ |
| 7187 | { |
| 7188 | #ifdef HAVE_DNSSD |
| 7189 | ippeve_txt_t ipp_txt; /* DNS-SD IPP TXT record */ |
| 7190 | int i, /* Looping var */ |
| 7191 | count; /* Number of values */ |
| 7192 | ipp_attribute_t *color_supported, |
| 7193 | *document_format_supported, |
| 7194 | *printer_location, |
| 7195 | *printer_make_and_model, |
| 7196 | *printer_uuid, |
| 7197 | *sides_supported, |
| 7198 | *urf_supported; /* Printer attributes */ |
| 7199 | const char *value; /* Value string */ |
| 7200 | char adminurl[247], /* adminurl value */ |
| 7201 | formats[252], /* List of supported formats */ |
| 7202 | urf[252], /* List of supported URF values */ |
| 7203 | *ptr; /* Pointer into string */ |
| 7204 | |
| 7205 | |
| 7206 | if (printer->dnssd_subtypes && !strcmp(printer->dnssd_subtypes, "off")) |
| 7207 | return (1); |
| 7208 | |
| 7209 | color_supported = ippFindAttribute(printer->attrs, "color-supported", IPP_TAG_BOOLEAN); |
| 7210 | document_format_supported = ippFindAttribute(printer->attrs, "document-format-supported", IPP_TAG_MIMETYPE); |
| 7211 | printer_location = ippFindAttribute(printer->attrs, "printer-location", IPP_TAG_TEXT); |
| 7212 | printer_make_and_model = ippFindAttribute(printer->attrs, "printer-make-and-model", IPP_TAG_TEXT); |
| 7213 | printer_uuid = ippFindAttribute(printer->attrs, "printer-uuid", IPP_TAG_URI); |
| 7214 | sides_supported = ippFindAttribute(printer->attrs, "sides-supported", IPP_TAG_KEYWORD); |
| 7215 | urf_supported = ippFindAttribute(printer->attrs, "urf-supported", IPP_TAG_KEYWORD); |
| 7216 | |
| 7217 | httpAssembleURI(HTTP_URI_CODING_ALL, adminurl, sizeof(adminurl), WEB_SCHEME, NULL, printer->hostname, printer->port, "/"); |
| 7218 | |
| 7219 | for (i = 0, count = ippGetCount(document_format_supported), ptr = formats; i < count; i ++) |
| 7220 | { |
| 7221 | value = ippGetString(document_format_supported, i, NULL); |
| 7222 | |
| 7223 | if (!strcasecmp(value, "application/octet-stream")) |
| 7224 | continue; |
| 7225 | |
| 7226 | if (ptr > formats && ptr < (formats + sizeof(formats) - 1)) |
| 7227 | *ptr++ = ','; |
| 7228 | |
| 7229 | strlcpy(ptr, value, sizeof(formats) - (size_t)(ptr - formats)); |
| 7230 | ptr += strlen(ptr); |
| 7231 | |
| 7232 | if (ptr >= (formats + sizeof(formats) - 1)) |
| 7233 | break; |
| 7234 | } |
| 7235 | |
| 7236 | urf[0] = '\0'; |
| 7237 | for (i = 0, count = ippGetCount(urf_supported), ptr = urf; i < count; i ++) |
| 7238 | { |
| 7239 | value = ippGetString(urf_supported, i, NULL); |
| 7240 | |
| 7241 | if (ptr > urf && ptr < (urf + sizeof(urf) - 1)) |
no test coverage detected