4 * DNS-SD discovery backend for CUPS.
6 * Copyright 2008-2011 by Apple Inc.
8 * These coded instructions, statements, and computer programs are the
9 * property of Apple Inc. and are protected by Federal copyright
10 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
11 * "LICENSE" which should have been included with this file. If this
12 * file is missing or damaged, see the license at "http://www.cups.org/".
14 * This file is subject to the Apple OS-Developed Software exception.
18 * main() - Browse for printers.
19 * browse_callback() - Browse devices.
20 * browse_local_callback() - Browse local devices.
21 * compare_devices() - Compare two devices.
22 * exec_backend() - Execute the backend that corresponds to the
23 * resolved service name.
24 * get_device() - Create or update a device.
25 * query_callback() - Process query data.
26 * sigterm_handler() - Handle termination signals...
27 * unquote() - Unquote a name string.
31 * Include necessary headers.
34 #include "backend-private.h"
35 #include <cups/array.h>
45 CUPS_DEVICE_PRINTER
= 0, /* lpd://... */
46 CUPS_DEVICE_IPP
, /* ipp://... */
47 CUPS_DEVICE_FAX_IPP
, /* ipp://... */
48 CUPS_DEVICE_PDL_DATASTREAM
, /* socket://... */
49 CUPS_DEVICE_RIOUSBPRINT
/* riousbprint://... */
55 DNSServiceRef ref
; /* Service reference for resolve */
56 char *name
, /* Service name */
57 *domain
, /* Domain name */
58 *fullName
, /* Full name */
59 *make_and_model
, /* Make and model from TXT record */
60 *device_id
; /* 1284 device ID from TXT record */
61 cups_devtype_t type
; /* Device registration type */
62 int priority
, /* Priority associated with type */
63 cups_shared
, /* CUPS shared printer? */
64 sent
; /* Did we list the device? */
72 static int job_canceled
= 0;
73 /* Set to 1 on SIGTERM */
80 static void browse_callback(DNSServiceRef sdRef
,
81 DNSServiceFlags flags
,
82 uint32_t interfaceIndex
,
83 DNSServiceErrorType errorCode
,
84 const char *serviceName
,
86 const char *replyDomain
, void *context
);
87 static void browse_local_callback(DNSServiceRef sdRef
,
88 DNSServiceFlags flags
,
89 uint32_t interfaceIndex
,
90 DNSServiceErrorType errorCode
,
91 const char *serviceName
,
93 const char *replyDomain
,
95 static int compare_devices(cups_device_t
*a
, cups_device_t
*b
);
96 static void exec_backend(char **argv
);
97 static cups_device_t
*get_device(cups_array_t
*devices
,
98 const char *serviceName
,
100 const char *replyDomain
);
101 static void query_callback(DNSServiceRef sdRef
,
102 DNSServiceFlags flags
,
103 uint32_t interfaceIndex
,
104 DNSServiceErrorType errorCode
,
105 const char *fullName
, uint16_t rrtype
,
106 uint16_t rrclass
, uint16_t rdlen
,
107 const void *rdata
, uint32_t ttl
,
109 static void sigterm_handler(int sig
);
110 static void unquote(char *dst
, const char *src
, size_t dstsize
);
114 * 'main()' - Browse for printers.
117 int /* O - Exit status */
118 main(int argc
, /* I - Number of command-line args */
119 char *argv
[]) /* I - Command-line arguments */
121 const char *name
; /* Backend name */
122 DNSServiceRef main_ref
, /* Main service reference */
123 fax_ipp_ref
, /* IPP fax service reference */
124 ipp_ref
, /* IPP service reference */
125 ipp_tls_ref
, /* IPP w/TLS service reference */
126 local_fax_ipp_ref
, /* Local IPP fax service reference */
127 local_ipp_ref
, /* Local IPP service reference */
128 local_ipp_tls_ref
, /* Local IPP w/TLS service reference */
129 local_printer_ref
, /* Local LPD service reference */
130 pdl_datastream_ref
, /* AppSocket service reference */
131 printer_ref
, /* LPD service reference */
132 riousbprint_ref
; /* Remote IO service reference */
133 int fd
; /* Main file descriptor */
134 fd_set input
; /* Input set for select() */
135 struct timeval timeout
; /* Timeout for select() */
136 cups_array_t
*devices
; /* Device array */
137 cups_device_t
*device
; /* Current device */
138 char uriName
[1024]; /* Unquoted fullName for URI */
139 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
140 struct sigaction action
; /* Actions for POSIX signals */
141 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
145 * Don't buffer stderr, and catch SIGTERM...
148 setbuf(stderr
, NULL
);
150 #ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
151 sigset(SIGTERM
, sigterm_handler
);
152 #elif defined(HAVE_SIGACTION)
153 memset(&action
, 0, sizeof(action
));
155 sigemptyset(&action
.sa_mask
);
156 action
.sa_handler
= sigterm_handler
;
157 sigaction(SIGTERM
, &action
, NULL
);
159 signal(SIGTERM
, sigterm_handler
);
160 #endif /* HAVE_SIGSET */
163 * Check command-line...
170 _cupsLangPrintf(stderr
,
171 _("Usage: %s job-id user title copies options [file]"),
177 * Only do discovery when run as "dnssd"...
180 if ((name
= strrchr(argv
[0], '/')) != NULL
)
185 if (strcmp(name
, "dnssd"))
189 * Create an array to track devices...
192 devices
= cupsArrayNew((cups_array_func_t
)compare_devices
, NULL
);
195 * Browse for different kinds of printers...
198 if (DNSServiceCreateConnection(&main_ref
) != kDNSServiceErr_NoError
)
200 perror("ERROR: Unable to create service connection");
204 fd
= DNSServiceRefSockFD(main_ref
);
206 fax_ipp_ref
= main_ref
;
207 DNSServiceBrowse(&fax_ipp_ref
, kDNSServiceFlagsShareConnection
, 0,
208 "_fax-ipp._tcp", NULL
, browse_callback
, devices
);
211 DNSServiceBrowse(&ipp_ref
, kDNSServiceFlagsShareConnection
, 0,
212 "_ipp._tcp", NULL
, browse_callback
, devices
);
214 ipp_tls_ref
= main_ref
;
215 DNSServiceBrowse(&ipp_tls_ref
, kDNSServiceFlagsShareConnection
, 0,
216 "_ipp-tls._tcp", NULL
, browse_callback
, devices
);
218 local_fax_ipp_ref
= main_ref
;
219 DNSServiceBrowse(&local_fax_ipp_ref
, kDNSServiceFlagsShareConnection
,
220 kDNSServiceInterfaceIndexLocalOnly
,
221 "_fax-ipp._tcp", NULL
, browse_local_callback
, devices
);
223 local_ipp_ref
= main_ref
;
224 DNSServiceBrowse(&local_ipp_ref
, kDNSServiceFlagsShareConnection
,
225 kDNSServiceInterfaceIndexLocalOnly
,
226 "_ipp._tcp", NULL
, browse_local_callback
, devices
);
228 local_ipp_tls_ref
= main_ref
;
229 DNSServiceBrowse(&local_ipp_tls_ref
, kDNSServiceFlagsShareConnection
,
230 kDNSServiceInterfaceIndexLocalOnly
,
231 "_ipp-tls._tcp", NULL
, browse_local_callback
, devices
);
233 local_printer_ref
= main_ref
;
234 DNSServiceBrowse(&local_printer_ref
, kDNSServiceFlagsShareConnection
,
235 kDNSServiceInterfaceIndexLocalOnly
,
236 "_printer._tcp", NULL
, browse_local_callback
, devices
);
238 pdl_datastream_ref
= main_ref
;
239 DNSServiceBrowse(&pdl_datastream_ref
, kDNSServiceFlagsShareConnection
, 0,
240 "_pdl-datastream._tcp", NULL
, browse_callback
, devices
);
242 printer_ref
= main_ref
;
243 DNSServiceBrowse(&printer_ref
, kDNSServiceFlagsShareConnection
, 0,
244 "_printer._tcp", NULL
, browse_callback
, devices
);
246 riousbprint_ref
= main_ref
;
247 DNSServiceBrowse(&riousbprint_ref
, kDNSServiceFlagsShareConnection
, 0,
248 "_riousbprint._tcp", NULL
, browse_callback
, devices
);
251 * Loop until we are killed...
254 while (!job_canceled
)
262 if (select(fd
+ 1, &input
, NULL
, NULL
, &timeout
) < 0)
265 if (FD_ISSET(fd
, &input
))
268 * Process results of our browsing...
271 DNSServiceProcessResult(main_ref
);
276 * Announce any devices we've found...
279 DNSServiceErrorType status
; /* DNS query status */
280 cups_device_t
*best
; /* Best matching device */
281 char device_uri
[1024]; /* Device URI */
282 int count
; /* Number of queries */
285 for (device
= (cups_device_t
*)cupsArrayFirst(devices
),
286 best
= NULL
, count
= 0;
288 device
= (cups_device_t
*)cupsArrayNext(devices
))
289 if (!device
->ref
&& !device
->sent
)
292 * Found the device, now get the TXT record(s) for it...
297 device
->ref
= main_ref
;
299 fprintf(stderr
, "DEBUG: Querying \"%s\"...\n", device
->fullName
);
301 status
= DNSServiceQueryRecord(&(device
->ref
),
302 kDNSServiceFlagsShareConnection
,
305 kDNSServiceClass_IN
, query_callback
,
307 if (status
!= kDNSServiceErr_NoError
)
309 fputs("ERROR: Unable to query for TXT records!\n", stderr
);
310 fprintf(stderr
, "DEBUG: DNSServiceQueryRecord returned %d\n",
317 else if (!device
->sent
)
320 * Got the TXT records, now report the device...
323 DNSServiceRefDeallocate(device
->ref
);
328 else if (strcasecmp(best
->name
, device
->name
) ||
329 strcasecmp(best
->domain
, device
->domain
))
331 unquote(uriName
, best
->fullName
, sizeof(uriName
));
333 httpAssembleURI(HTTP_URI_CODING_ALL
, device_uri
, sizeof(device_uri
),
334 "dnssd", NULL
, uriName
, 0,
335 best
->cups_shared
? "/cups" : "/");
337 cupsBackendReport("network", device_uri
, best
->make_and_model
,
338 best
->name
, best
->device_id
, NULL
);
342 else if (best
->priority
> device
->priority
||
343 (best
->priority
== device
->priority
&&
344 best
->type
< device
->type
))
355 unquote(uriName
, best
->fullName
, sizeof(uriName
));
357 httpAssembleURI(HTTP_URI_CODING_ALL
, device_uri
, sizeof(device_uri
),
358 "dnssd", NULL
, uriName
, 0,
359 best
->cups_shared
? "/cups" : "/");
361 cupsBackendReport("network", device_uri
, best
->make_and_model
,
362 best
->name
, best
->device_id
, NULL
);
368 return (CUPS_BACKEND_OK
);
373 * 'browse_callback()' - Browse devices.
378 DNSServiceRef sdRef
, /* I - Service reference */
379 DNSServiceFlags flags
, /* I - Option flags */
380 uint32_t interfaceIndex
, /* I - Interface number */
381 DNSServiceErrorType errorCode
, /* I - Error, if any */
382 const char *serviceName
, /* I - Name of service/device */
383 const char *regtype
, /* I - Type of service */
384 const char *replyDomain
, /* I - Service domain */
385 void *context
) /* I - Devices array */
387 fprintf(stderr
, "DEBUG2: browse_callback(sdRef=%p, flags=%x, "
388 "interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", "
389 "regtype=\"%s\", replyDomain=\"%s\", context=%p)\n",
390 sdRef
, flags
, interfaceIndex
, errorCode
,
391 serviceName
? serviceName
: "(null)",
392 regtype
? regtype
: "(null)",
393 replyDomain
? replyDomain
: "(null)",
397 * Only process "add" data...
400 if (errorCode
!= kDNSServiceErr_NoError
|| !(flags
& kDNSServiceFlagsAdd
))
407 get_device((cups_array_t
*)context
, serviceName
, regtype
, replyDomain
);
412 * 'browse_local_callback()' - Browse local devices.
416 browse_local_callback(
417 DNSServiceRef sdRef
, /* I - Service reference */
418 DNSServiceFlags flags
, /* I - Option flags */
419 uint32_t interfaceIndex
, /* I - Interface number */
420 DNSServiceErrorType errorCode
, /* I - Error, if any */
421 const char *serviceName
, /* I - Name of service/device */
422 const char *regtype
, /* I - Type of service */
423 const char *replyDomain
, /* I - Service domain */
424 void *context
) /* I - Devices array */
426 cups_device_t
*device
; /* Device */
429 fprintf(stderr
, "DEBUG2: browse_local_callback(sdRef=%p, flags=%x, "
430 "interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", "
431 "regtype=\"%s\", replyDomain=\"%s\", context=%p)\n",
432 sdRef
, flags
, interfaceIndex
, errorCode
,
433 serviceName
? serviceName
: "(null)",
434 regtype
? regtype
: "(null)",
435 replyDomain
? replyDomain
: "(null)",
439 * Only process "add" data...
442 if (errorCode
!= kDNSServiceErr_NoError
|| !(flags
& kDNSServiceFlagsAdd
))
449 device
= get_device((cups_array_t
*)context
, serviceName
, regtype
,
453 * Hide locally-registered devices...
456 fprintf(stderr
, "DEBUG: Hiding local printer \"%s\"...\n",
463 * 'compare_devices()' - Compare two devices.
466 static int /* O - Result of comparison */
467 compare_devices(cups_device_t
*a
, /* I - First device */
468 cups_device_t
*b
) /* I - Second device */
470 return (strcmp(a
->name
, b
->name
));
475 * 'exec_backend()' - Execute the backend that corresponds to the
476 * resolved service name.
480 exec_backend(char **argv
) /* I - Command-line arguments */
482 const char *resolved_uri
, /* Resolved device URI */
483 *cups_serverbin
; /* Location of programs */
484 char scheme
[1024], /* Scheme from URI */
485 *ptr
, /* Pointer into scheme */
486 filename
[1024]; /* Backend filename */
490 * Resolve the device URI...
495 while ((resolved_uri
= cupsBackendDeviceURI(argv
)) == NULL
)
497 _cupsLangPrintFilter(stderr
, "INFO", _("Unable to locate printer."));
500 if (getenv("CLASS") != NULL
)
501 exit(CUPS_BACKEND_FAILED
);
505 * Extract the scheme from the URI...
508 strlcpy(scheme
, resolved_uri
, sizeof(scheme
));
509 if ((ptr
= strchr(scheme
, ':')) != NULL
)
513 * Get the filename of the backend...
516 if ((cups_serverbin
= getenv("CUPS_SERVERBIN")) == NULL
)
517 cups_serverbin
= CUPS_SERVERBIN
;
519 snprintf(filename
, sizeof(filename
), "%s/backend/%s", cups_serverbin
, scheme
);
522 * Overwrite the device URI and run the new backend...
525 setenv("DEVICE_URI", resolved_uri
, 1);
527 argv
[0] = (char *)resolved_uri
;
529 fprintf(stderr
, "DEBUG: Executing backend \"%s\"...\n", filename
);
531 execv(filename
, argv
);
533 fprintf(stderr
, "ERROR: Unable to execute backend \"%s\": %s\n", filename
,
535 exit(CUPS_BACKEND_STOP
);
540 * 'get_device()' - Create or update a device.
543 static cups_device_t
* /* O - Device */
544 get_device(cups_array_t
*devices
, /* I - Device array */
545 const char *serviceName
, /* I - Name of service/device */
546 const char *regtype
, /* I - Type of service */
547 const char *replyDomain
) /* I - Service domain */
549 cups_device_t key
, /* Search key */
550 *device
; /* Device */
551 char fullName
[kDNSServiceMaxDomainName
];
552 /* Full name for query */
556 * See if this is a new device...
559 key
.name
= (char *)serviceName
;
561 if (!strcmp(regtype
, "_ipp._tcp.") ||
562 !strcmp(regtype
, "_ipp-tls._tcp."))
563 key
.type
= CUPS_DEVICE_IPP
;
564 else if (!strcmp(regtype
, "_fax-ipp._tcp."))
565 key
.type
= CUPS_DEVICE_FAX_IPP
;
566 else if (!strcmp(regtype
, "_printer._tcp."))
567 key
.type
= CUPS_DEVICE_PRINTER
;
568 else if (!strcmp(regtype
, "_pdl-datastream._tcp."))
569 key
.type
= CUPS_DEVICE_PDL_DATASTREAM
;
571 key
.type
= CUPS_DEVICE_RIOUSBPRINT
;
573 for (device
= cupsArrayFind(devices
, &key
);
575 device
= cupsArrayNext(devices
))
576 if (strcasecmp(device
->name
, key
.name
))
578 else if (device
->type
== key
.type
)
580 if (!strcasecmp(device
->domain
, "local.") &&
581 strcasecmp(device
->domain
, replyDomain
))
584 * Update the .local listing to use the "global" domain name instead.
585 * The backend will try local lookups first, then the global domain name.
588 free(device
->domain
);
589 device
->domain
= strdup(replyDomain
);
591 DNSServiceConstructFullName(fullName
, device
->name
, regtype
,
593 free(device
->fullName
);
594 device
->fullName
= strdup(fullName
);
601 * Yes, add the device...
604 fprintf(stderr
, "DEBUG: Found \"%s.%s%s\"...\n", serviceName
, regtype
,
607 device
= calloc(sizeof(cups_device_t
), 1);
608 device
->name
= strdup(serviceName
);
609 device
->domain
= strdup(replyDomain
);
610 device
->type
= key
.type
;
611 device
->priority
= 50;
613 cupsArrayAdd(devices
, device
);
616 * Set the "full name" of this service, which is used for queries...
619 DNSServiceConstructFullName(fullName
, serviceName
, regtype
, replyDomain
);
620 device
->fullName
= strdup(fullName
);
627 * 'query_callback()' - Process query data.
632 DNSServiceRef sdRef
, /* I - Service reference */
633 DNSServiceFlags flags
, /* I - Data flags */
634 uint32_t interfaceIndex
, /* I - Interface */
635 DNSServiceErrorType errorCode
, /* I - Error, if any */
636 const char *fullName
, /* I - Full service name */
637 uint16_t rrtype
, /* I - Record type */
638 uint16_t rrclass
, /* I - Record class */
639 uint16_t rdlen
, /* I - Length of record data */
640 const void *rdata
, /* I - Record data */
641 uint32_t ttl
, /* I - Time-to-live */
642 void *context
) /* I - Devices array */
644 cups_array_t
*devices
; /* Device array */
645 char name
[1024], /* Service name */
646 *ptr
; /* Pointer into string */
647 cups_device_t dkey
, /* Search key */
648 *device
; /* Device */
651 fprintf(stderr
, "DEBUG2: query_callback(sdRef=%p, flags=%x, "
652 "interfaceIndex=%d, errorCode=%d, fullName=\"%s\", "
653 "rrtype=%u, rrclass=%u, rdlen=%u, rdata=%p, ttl=%u, "
655 sdRef
, flags
, interfaceIndex
, errorCode
,
656 fullName
? fullName
: "(null)", rrtype
, rrclass
, rdlen
, rdata
, ttl
,
660 * Only process "add" data...
663 if (errorCode
!= kDNSServiceErr_NoError
|| !(flags
& kDNSServiceFlagsAdd
))
667 * Lookup the service in the devices array.
670 devices
= (cups_array_t
*)context
;
673 unquote(name
, fullName
, sizeof(name
));
675 if ((dkey
.domain
= strstr(name
, "._tcp.")) != NULL
)
678 dkey
.domain
= (char *)"local.";
680 if ((ptr
= strstr(name
, "._")) != NULL
)
683 if (strstr(fullName
, "_ipp._tcp.") ||
684 strstr(fullName
, "_ipp-tls._tcp."))
685 dkey
.type
= CUPS_DEVICE_IPP
;
686 else if (strstr(fullName
, "_fax-ipp._tcp."))
687 dkey
.type
= CUPS_DEVICE_FAX_IPP
;
688 else if (strstr(fullName
, "_printer._tcp."))
689 dkey
.type
= CUPS_DEVICE_PRINTER
;
690 else if (strstr(fullName
, "_pdl-datastream._tcp."))
691 dkey
.type
= CUPS_DEVICE_PDL_DATASTREAM
;
693 dkey
.type
= CUPS_DEVICE_RIOUSBPRINT
;
695 for (device
= cupsArrayFind(devices
, &dkey
);
697 device
= cupsArrayNext(devices
))
699 if (strcasecmp(device
->name
, dkey
.name
) ||
700 strcasecmp(device
->domain
, dkey
.domain
))
705 else if (device
->type
== dkey
.type
)
708 * Found it, pull out the priority and make and model from the TXT
709 * record and save it...
712 const uint8_t *data
, /* Pointer into data */
713 *datanext
, /* Next key/value pair */
714 *dataend
; /* End of entire TXT record */
715 uint8_t datalen
; /* Length of current key/value pair */
716 char key
[256], /* Key string */
717 value
[256], /* Value string */
719 /* Manufacturer and model */
720 model
[256], /* Model */
721 device_id
[2048];/* 1284 device ID */
725 make_and_model
[0] = '\0';
727 strcpy(model
, "Unknown");
729 for (data
= rdata
, dataend
= data
+ rdlen
;
734 * Read a key/value pair starting with an 8-bit length. Since the
735 * length is 8 bits and the size of the key/value buffers is 256, we
736 * don't need to check for overflow...
741 if (!datalen
|| (data
+ datalen
) >= dataend
)
744 datanext
= data
+ datalen
;
746 for (ptr
= key
; data
< datanext
&& *data
!= '='; data
++)
750 if (data
< datanext
&& *data
== '=')
755 memcpy(value
, data
, datanext
- data
);
756 value
[datanext
- data
] = '\0';
761 if (!strncasecmp(key
, "usb_", 4))
764 * Add USB device ID information...
767 ptr
= device_id
+ strlen(device_id
);
768 snprintf(ptr
, sizeof(device_id
) - (ptr
- device_id
), "%s:%s;",
772 if (!strcasecmp(key
, "usb_MFG") || !strcasecmp(key
, "usb_MANU") ||
773 !strcasecmp(key
, "usb_MANUFACTURER"))
774 strcpy(make_and_model
, value
);
775 else if (!strcasecmp(key
, "usb_MDL") || !strcasecmp(key
, "usb_MODEL"))
776 strcpy(model
, value
);
777 else if (!strcasecmp(key
, "product") && !strstr(value
, "Ghostscript"))
782 * Strip parenthesis...
785 if ((ptr
= value
+ strlen(value
) - 1) > value
&& *ptr
== ')')
788 strcpy(model
, value
+ 1);
791 strcpy(model
, value
);
793 else if (!strcasecmp(key
, "ty"))
795 strcpy(model
, value
);
797 if ((ptr
= strchr(model
, ',')) != NULL
)
800 else if (!strcasecmp(key
, "priority"))
801 device
->priority
= atoi(value
);
802 else if ((device
->type
== CUPS_DEVICE_IPP
||
803 device
->type
== CUPS_DEVICE_PRINTER
) &&
804 !strcasecmp(key
, "printer-type"))
807 * This is a CUPS printer!
810 device
->cups_shared
= 1;
812 if (device
->type
== CUPS_DEVICE_PRINTER
)
817 if (device
->device_id
)
818 free(device
->device_id
);
820 if (!device_id
[0] && strcmp(model
, "Unknown"))
822 if (make_and_model
[0])
823 snprintf(device_id
, sizeof(device_id
), "MFG:%s;MDL:%s;",
824 make_and_model
, model
);
825 else if (!strncasecmp(model
, "designjet ", 10))
826 snprintf(device_id
, sizeof(device_id
), "MFG:HP;MDL:%s", model
+ 10);
827 else if (!strncasecmp(model
, "stylus ", 7))
828 snprintf(device_id
, sizeof(device_id
), "MFG:EPSON;MDL:%s", model
+ 7);
829 else if ((ptr
= strchr(model
, ' ')) != NULL
)
832 * Assume the first word is the make...
835 memcpy(make_and_model
, model
, ptr
- model
);
836 make_and_model
[ptr
- model
] = '\0';
838 snprintf(device_id
, sizeof(device_id
), "MFG:%s;MDL:%s",
839 make_and_model
, ptr
+ 1);
844 device
->device_id
= strdup(device_id
);
846 device
->device_id
= NULL
;
848 if (device
->make_and_model
)
849 free(device
->make_and_model
);
851 if (make_and_model
[0])
853 strlcat(make_and_model
, " ", sizeof(make_and_model
));
854 strlcat(make_and_model
, model
, sizeof(make_and_model
));
856 device
->make_and_model
= strdup(make_and_model
);
859 device
->make_and_model
= strdup(model
);
865 fprintf(stderr
, "DEBUG: Ignoring TXT record for \"%s\"...\n", fullName
);
870 * 'sigterm_handler()' - Handle termination signals...
874 sigterm_handler(int sig
) /* I - Signal number (unused) */
879 exit(CUPS_BACKEND_OK
);
886 * 'unquote()' - Unquote a name string.
890 unquote(char *dst
, /* I - Destination buffer */
891 const char *src
, /* I - Source string */
892 size_t dstsize
) /* I - Size of destination buffer */
894 char *dstend
= dst
+ dstsize
- 1; /* End of destination buffer */
897 while (*src
&& dst
< dstend
)
902 if (isdigit(src
[0] & 255) && isdigit(src
[1] & 255) &&
903 isdigit(src
[2] & 255))
905 *dst
++ = ((((src
[0] - '0') * 10) + src
[1] - '0') * 10) + src
[2] - '0';