MCPcopy Create free account
hub / github.com/OpenPrinting/cups / register_printer

Function register_printer

tools/ippeveprinter.c:7184–7492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7182 */
7183
7184static int /* O - 1 on success, 0 on error */
7185register_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))

Callers 2

create_printerFunction · 0.85
run_printerFunction · 0.85

Calls 15

ippFindAttributeFunction · 0.85
httpAssembleURIFunction · 0.85
ippGetCountFunction · 0.85
ippGetStringFunction · 0.85
_cupsRWLockWriteFunction · 0.85
_cupsRWUnlockFunction · 0.85
TXTRecordCreateFunction · 0.85
TXTRecordSetValueFunction · 0.85
ippGetBooleanFunction · 0.85
DNSServiceRefDeallocateFunction · 0.85
DNSServiceRegisterFunction · 0.85
_cupsLangPrintfFunction · 0.85

Tested by

no test coverage detected