4 * DNS-SD discovery backend for the Common UNIX Printing System (CUPS).
6 * Copyright 2008-2009 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
= SIG_IGN
;
157 sigaction(SIGTERM
, &action
, sigterm_handler
);
159 signal(SIGTERM
, sigterm_handler
);
160 #endif /* HAVE_SIGSET */
163 * Check command-line...
170 fprintf(stderr
, "Usage: %s job user title copies options [filename(s)]\n",
176 * Only do discovery when run as "dnssd"...
179 if ((name
= strrchr(argv
[0], '/')) != NULL
)
184 if (strcmp(name
, "dnssd"))
188 * Create an array to track devices...
191 devices
= cupsArrayNew((cups_array_func_t
)compare_devices
, NULL
);
194 * Browse for different kinds of printers...
197 if (DNSServiceCreateConnection(&main_ref
) != kDNSServiceErr_NoError
)
199 perror("ERROR: Unable to create service connection");
203 fd
= DNSServiceRefSockFD(main_ref
);
205 fax_ipp_ref
= main_ref
;
206 DNSServiceBrowse(&fax_ipp_ref
, kDNSServiceFlagsShareConnection
, 0,
207 "_fax-ipp._tcp", NULL
, browse_callback
, devices
);
210 DNSServiceBrowse(&ipp_ref
, kDNSServiceFlagsShareConnection
, 0,
211 "_ipp._tcp", NULL
, browse_callback
, devices
);
213 ipp_tls_ref
= main_ref
;
214 DNSServiceBrowse(&ipp_tls_ref
, kDNSServiceFlagsShareConnection
, 0,
215 "_ipp-tls._tcp", NULL
, browse_callback
, devices
);
217 local_fax_ipp_ref
= main_ref
;
218 DNSServiceBrowse(&local_fax_ipp_ref
, kDNSServiceFlagsShareConnection
,
219 kDNSServiceInterfaceIndexLocalOnly
,
220 "_fax-ipp._tcp", NULL
, browse_local_callback
, devices
);
222 local_ipp_ref
= main_ref
;
223 DNSServiceBrowse(&local_ipp_ref
, kDNSServiceFlagsShareConnection
,
224 kDNSServiceInterfaceIndexLocalOnly
,
225 "_ipp._tcp", NULL
, browse_local_callback
, devices
);
227 local_ipp_tls_ref
= main_ref
;
228 DNSServiceBrowse(&local_ipp_tls_ref
, kDNSServiceFlagsShareConnection
,
229 kDNSServiceInterfaceIndexLocalOnly
,
230 "_ipp-tls._tcp", NULL
, browse_local_callback
, devices
);
232 local_printer_ref
= main_ref
;
233 DNSServiceBrowse(&local_printer_ref
, kDNSServiceFlagsShareConnection
,
234 kDNSServiceInterfaceIndexLocalOnly
,
235 "_printer._tcp", NULL
, browse_local_callback
, devices
);
237 pdl_datastream_ref
= main_ref
;
238 DNSServiceBrowse(&pdl_datastream_ref
, kDNSServiceFlagsShareConnection
, 0,
239 "_pdl-datastream._tcp", NULL
, browse_callback
, devices
);
241 printer_ref
= main_ref
;
242 DNSServiceBrowse(&printer_ref
, kDNSServiceFlagsShareConnection
, 0,
243 "_printer._tcp", NULL
, browse_callback
, devices
);
245 riousbprint_ref
= main_ref
;
246 DNSServiceBrowse(&riousbprint_ref
, kDNSServiceFlagsShareConnection
, 0,
247 "_riousbprint._tcp", NULL
, browse_callback
, devices
);
250 * Loop until we are killed...
253 while (!job_canceled
)
261 if (select(fd
+ 1, &input
, NULL
, NULL
, &timeout
) < 0)
264 if (FD_ISSET(fd
, &input
))
267 * Process results of our browsing...
270 DNSServiceProcessResult(main_ref
);
275 * Announce any devices we've found...
278 DNSServiceErrorType status
; /* DNS query status */
279 cups_device_t
*best
; /* Best matching device */
280 char device_uri
[1024]; /* Device URI */
281 int count
; /* Number of queries */
284 for (device
= (cups_device_t
*)cupsArrayFirst(devices
),
285 best
= NULL
, count
= 0;
287 device
= (cups_device_t
*)cupsArrayNext(devices
))
288 if (!device
->ref
&& !device
->sent
)
291 * Found the device, now get the TXT record(s) for it...
296 device
->ref
= main_ref
;
298 fprintf(stderr
, "DEBUG: Querying \"%s\"...\n", device
->fullName
);
300 status
= DNSServiceQueryRecord(&(device
->ref
),
301 kDNSServiceFlagsShareConnection
,
304 kDNSServiceClass_IN
, query_callback
,
306 if (status
!= kDNSServiceErr_NoError
)
308 fputs("ERROR: Unable to query for TXT records!\n", stderr
);
309 fprintf(stderr
, "DEBUG: DNSServiceQueryRecord returned %d\n",
316 else if (!device
->sent
)
319 * Got the TXT records, now report the device...
322 DNSServiceRefDeallocate(device
->ref
);
327 else if (strcasecmp(best
->name
, device
->name
) ||
328 strcasecmp(best
->domain
, device
->domain
))
330 unquote(uriName
, best
->fullName
, sizeof(uriName
));
332 httpAssembleURI(HTTP_URI_CODING_ALL
, device_uri
, sizeof(device_uri
),
333 "dnssd", NULL
, uriName
, 0,
334 best
->cups_shared
? "/cups" : "/");
336 cupsBackendReport("network", device_uri
, best
->make_and_model
,
337 best
->name
, best
->device_id
, NULL
);
341 else if (best
->priority
> device
->priority
||
342 (best
->priority
== device
->priority
&&
343 best
->type
< device
->type
))
354 unquote(uriName
, best
->fullName
, sizeof(uriName
));
356 httpAssembleURI(HTTP_URI_CODING_ALL
, device_uri
, sizeof(device_uri
),
357 "dnssd", NULL
, uriName
, 0,
358 best
->cups_shared
? "/cups" : "/");
360 cupsBackendReport("network", device_uri
, best
->make_and_model
,
361 best
->name
, best
->device_id
, NULL
);
367 return (CUPS_BACKEND_OK
);
372 * 'browse_callback()' - Browse devices.
377 DNSServiceRef sdRef
, /* I - Service reference */
378 DNSServiceFlags flags
, /* I - Option flags */
379 uint32_t interfaceIndex
, /* I - Interface number */
380 DNSServiceErrorType errorCode
, /* I - Error, if any */
381 const char *serviceName
, /* I - Name of service/device */
382 const char *regtype
, /* I - Type of service */
383 const char *replyDomain
, /* I - Service domain */
384 void *context
) /* I - Devices array */
386 fprintf(stderr
, "DEBUG2: browse_callback(sdRef=%p, flags=%x, "
387 "interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", "
388 "regtype=\"%s\", replyDomain=\"%s\", context=%p)\n",
389 sdRef
, flags
, interfaceIndex
, errorCode
,
390 serviceName
? serviceName
: "(null)",
391 regtype
? regtype
: "(null)",
392 replyDomain
? replyDomain
: "(null)",
396 * Only process "add" data...
399 if (errorCode
!= kDNSServiceErr_NoError
|| !(flags
& kDNSServiceFlagsAdd
))
406 get_device((cups_array_t
*)context
, serviceName
, regtype
, replyDomain
);
411 * 'browse_local_callback()' - Browse local devices.
415 browse_local_callback(
416 DNSServiceRef sdRef
, /* I - Service reference */
417 DNSServiceFlags flags
, /* I - Option flags */
418 uint32_t interfaceIndex
, /* I - Interface number */
419 DNSServiceErrorType errorCode
, /* I - Error, if any */
420 const char *serviceName
, /* I - Name of service/device */
421 const char *regtype
, /* I - Type of service */
422 const char *replyDomain
, /* I - Service domain */
423 void *context
) /* I - Devices array */
425 cups_device_t
*device
; /* Device */
428 fprintf(stderr
, "DEBUG2: browse_local_callback(sdRef=%p, flags=%x, "
429 "interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", "
430 "regtype=\"%s\", replyDomain=\"%s\", context=%p)\n",
431 sdRef
, flags
, interfaceIndex
, errorCode
,
432 serviceName
? serviceName
: "(null)",
433 regtype
? regtype
: "(null)",
434 replyDomain
? replyDomain
: "(null)",
438 * Only process "add" data...
441 if (errorCode
!= kDNSServiceErr_NoError
|| !(flags
& kDNSServiceFlagsAdd
))
448 device
= get_device((cups_array_t
*)context
, serviceName
, regtype
,
452 * Hide locally-registered devices...
455 fprintf(stderr
, "DEBUG: Hiding local printer \"%s\"...\n",
462 * 'compare_devices()' - Compare two devices.
465 static int /* O - Result of comparison */
466 compare_devices(cups_device_t
*a
, /* I - First device */
467 cups_device_t
*b
) /* I - Second device */
469 return (strcmp(a
->name
, b
->name
));
474 * 'exec_backend()' - Execute the backend that corresponds to the
475 * resolved service name.
479 exec_backend(char **argv
) /* I - Command-line arguments */
481 const char *resolved_uri
, /* Resolved device URI */
482 *cups_serverbin
; /* Location of programs */
483 char scheme
[1024], /* Scheme from URI */
484 *ptr
, /* Pointer into scheme */
485 filename
[1024]; /* Backend filename */
489 * Resolve the device URI...
494 if ((resolved_uri
= cupsBackendDeviceURI(argv
)) == NULL
)
495 exit(CUPS_BACKEND_FAILED
);
498 * Extract the scheme from the URI...
501 strlcpy(scheme
, resolved_uri
, sizeof(scheme
));
502 if ((ptr
= strchr(scheme
, ':')) != NULL
)
506 * Get the filename of the backend...
509 if ((cups_serverbin
= getenv("CUPS_SERVERBIN")) == NULL
)
510 cups_serverbin
= CUPS_SERVERBIN
;
512 snprintf(filename
, sizeof(filename
), "%s/backend/%s", cups_serverbin
, scheme
);
515 * Overwrite the device URI and run the new backend...
518 setenv("DEVICE_URI", resolved_uri
, 1);
520 argv
[0] = (char *)resolved_uri
;
522 fprintf(stderr
, "DEBUG: Executing backend \"%s\"...\n", filename
);
524 execv(filename
, argv
);
526 fprintf(stderr
, "ERROR: Unable to execute backend \"%s\": %s\n", filename
,
528 exit(CUPS_BACKEND_STOP
);
533 * 'get_device()' - Create or update a device.
536 static cups_device_t
* /* O - Device */
537 get_device(cups_array_t
*devices
, /* I - Device array */
538 const char *serviceName
, /* I - Name of service/device */
539 const char *regtype
, /* I - Type of service */
540 const char *replyDomain
) /* I - Service domain */
542 cups_device_t key
, /* Search key */
543 *device
; /* Device */
544 char fullName
[kDNSServiceMaxDomainName
];
545 /* Full name for query */
549 * See if this is a new device...
552 key
.name
= (char *)serviceName
;
554 if (!strcmp(regtype
, "_ipp._tcp.") ||
555 !strcmp(regtype
, "_ipp-tls._tcp."))
556 key
.type
= CUPS_DEVICE_IPP
;
557 else if (!strcmp(regtype
, "_fax-ipp._tcp."))
558 key
.type
= CUPS_DEVICE_FAX_IPP
;
559 else if (!strcmp(regtype
, "_printer._tcp."))
560 key
.type
= CUPS_DEVICE_PRINTER
;
561 else if (!strcmp(regtype
, "_pdl-datastream._tcp."))
562 key
.type
= CUPS_DEVICE_PDL_DATASTREAM
;
564 key
.type
= CUPS_DEVICE_RIOUSBPRINT
;
566 for (device
= cupsArrayFind(devices
, &key
);
568 device
= cupsArrayNext(devices
))
569 if (strcasecmp(device
->name
, key
.name
))
571 else if (device
->type
== key
.type
)
573 if (!strcasecmp(device
->domain
, "local.") &&
574 strcasecmp(device
->domain
, replyDomain
))
577 * Update the .local listing to use the "global" domain name instead.
578 * The backend will try local lookups first, then the global domain name.
581 free(device
->domain
);
582 device
->domain
= strdup(replyDomain
);
584 DNSServiceConstructFullName(fullName
, device
->name
, regtype
,
586 free(device
->fullName
);
587 device
->fullName
= strdup(fullName
);
594 * Yes, add the device...
597 fprintf(stderr
, "DEBUG: Found \"%s.%s%s\"...\n", serviceName
, regtype
,
600 device
= calloc(sizeof(cups_device_t
), 1);
601 device
->name
= strdup(serviceName
);
602 device
->domain
= strdup(replyDomain
);
603 device
->type
= key
.type
;
604 device
->priority
= 50;
606 cupsArrayAdd(devices
, device
);
609 * Set the "full name" of this service, which is used for queries...
612 DNSServiceConstructFullName(fullName
, serviceName
, regtype
, replyDomain
);
613 device
->fullName
= strdup(fullName
);
620 * 'query_callback()' - Process query data.
625 DNSServiceRef sdRef
, /* I - Service reference */
626 DNSServiceFlags flags
, /* I - Data flags */
627 uint32_t interfaceIndex
, /* I - Interface */
628 DNSServiceErrorType errorCode
, /* I - Error, if any */
629 const char *fullName
, /* I - Full service name */
630 uint16_t rrtype
, /* I - Record type */
631 uint16_t rrclass
, /* I - Record class */
632 uint16_t rdlen
, /* I - Length of record data */
633 const void *rdata
, /* I - Record data */
634 uint32_t ttl
, /* I - Time-to-live */
635 void *context
) /* I - Devices array */
637 cups_array_t
*devices
; /* Device array */
638 char name
[1024], /* Service name */
639 *ptr
; /* Pointer into string */
640 cups_device_t dkey
, /* Search key */
641 *device
; /* Device */
644 fprintf(stderr
, "DEBUG2: query_callback(sdRef=%p, flags=%x, "
645 "interfaceIndex=%d, errorCode=%d, fullName=\"%s\", "
646 "rrtype=%u, rrclass=%u, rdlen=%u, rdata=%p, ttl=%u, "
648 sdRef
, flags
, interfaceIndex
, errorCode
,
649 fullName
? fullName
: "(null)", rrtype
, rrclass
, rdlen
, rdata
, ttl
,
653 * Only process "add" data...
656 if (errorCode
!= kDNSServiceErr_NoError
|| !(flags
& kDNSServiceFlagsAdd
))
660 * Lookup the service in the devices array.
663 devices
= (cups_array_t
*)context
;
666 unquote(name
, fullName
, sizeof(name
));
668 if ((dkey
.domain
= strstr(name
, "._tcp.")) != NULL
)
671 dkey
.domain
= (char *)"local.";
673 if ((ptr
= strstr(name
, "._")) != NULL
)
676 if (strstr(fullName
, "_ipp._tcp.") ||
677 strstr(fullName
, "_ipp-tls._tcp."))
678 dkey
.type
= CUPS_DEVICE_IPP
;
679 else if (strstr(fullName
, "_fax-ipp._tcp."))
680 dkey
.type
= CUPS_DEVICE_FAX_IPP
;
681 else if (strstr(fullName
, "_printer._tcp."))
682 dkey
.type
= CUPS_DEVICE_PRINTER
;
683 else if (strstr(fullName
, "_pdl-datastream._tcp."))
684 dkey
.type
= CUPS_DEVICE_PDL_DATASTREAM
;
686 dkey
.type
= CUPS_DEVICE_RIOUSBPRINT
;
688 for (device
= cupsArrayFind(devices
, &dkey
);
690 device
= cupsArrayNext(devices
))
692 if (strcasecmp(device
->name
, dkey
.name
) ||
693 strcasecmp(device
->domain
, dkey
.domain
))
698 else if (device
->type
== dkey
.type
)
701 * Found it, pull out the priority and make and model from the TXT
702 * record and save it...
705 const uint8_t *data
, /* Pointer into data */
706 *datanext
, /* Next key/value pair */
707 *dataend
; /* End of entire TXT record */
708 uint8_t datalen
; /* Length of current key/value pair */
709 char key
[256], /* Key string */
710 value
[256], /* Value string */
712 /* Manufacturer and model */
713 model
[256], /* Model */
714 device_id
[2048];/* 1284 device ID */
718 make_and_model
[0] = '\0';
720 strcpy(model
, "Unknown");
722 for (data
= rdata
, dataend
= data
+ rdlen
;
727 * Read a key/value pair starting with an 8-bit length. Since the
728 * length is 8 bits and the size of the key/value buffers is 256, we
729 * don't need to check for overflow...
734 if (!datalen
|| (data
+ datalen
) >= dataend
)
737 datanext
= data
+ datalen
;
739 for (ptr
= key
; data
< datanext
&& *data
!= '='; data
++)
743 if (data
< datanext
&& *data
== '=')
748 memcpy(value
, data
, datanext
- data
);
749 value
[datanext
- data
] = '\0';
754 if (!strncasecmp(key
, "usb_", 4))
757 * Add USB device ID information...
760 ptr
= device_id
+ strlen(device_id
);
761 snprintf(ptr
, sizeof(device_id
) - (ptr
- device_id
), "%s:%s;",
765 if (!strcasecmp(key
, "usb_MFG") || !strcasecmp(key
, "usb_MANU") ||
766 !strcasecmp(key
, "usb_MANUFACTURER"))
767 strcpy(make_and_model
, value
);
768 else if (!strcasecmp(key
, "usb_MDL") || !strcasecmp(key
, "usb_MODEL"))
769 strcpy(model
, value
);
770 else if (!strcasecmp(key
, "product") && !strstr(value
, "Ghostscript"))
775 * Strip parenthesis...
778 if ((ptr
= value
+ strlen(value
) - 1) > value
&& *ptr
== ')')
781 strcpy(model
, value
+ 1);
784 strcpy(model
, value
);
786 else if (!strcasecmp(key
, "ty"))
788 strcpy(model
, value
);
790 if ((ptr
= strchr(model
, ',')) != NULL
)
793 else if (!strcasecmp(key
, "priority"))
794 device
->priority
= atoi(value
);
795 else if ((device
->type
== CUPS_DEVICE_IPP
||
796 device
->type
== CUPS_DEVICE_PRINTER
) &&
797 !strcasecmp(key
, "printer-type"))
800 * This is a CUPS printer!
803 device
->cups_shared
= 1;
805 if (device
->type
== CUPS_DEVICE_PRINTER
)
810 if (device
->device_id
)
811 free(device
->device_id
);
813 if (!device_id
[0] && strcmp(model
, "Unknown"))
815 if (make_and_model
[0])
816 snprintf(device_id
, sizeof(device_id
), "MFG:%s;MDL:%s;",
817 make_and_model
, model
);
818 else if (!strncasecmp(model
, "designjet ", 10))
819 snprintf(device_id
, sizeof(device_id
), "MFG:HP;MDL:%s", model
+ 10);
820 else if (!strncasecmp(model
, "stylus ", 7))
821 snprintf(device_id
, sizeof(device_id
), "MFG:EPSON;MDL:%s", model
+ 7);
822 else if ((ptr
= strchr(model
, ' ')) != NULL
)
825 * Assume the first word is the make...
828 memcpy(make_and_model
, model
, ptr
- model
);
829 make_and_model
[ptr
- model
] = '\0';
831 snprintf(device_id
, sizeof(device_id
), "MFG:%s;MDL:%s",
832 make_and_model
, ptr
+ 1);
837 device
->device_id
= strdup(device_id
);
839 device
->device_id
= NULL
;
841 if (device
->make_and_model
)
842 free(device
->make_and_model
);
844 if (make_and_model
[0])
846 strlcat(make_and_model
, " ", sizeof(make_and_model
));
847 strlcat(make_and_model
, model
, sizeof(make_and_model
));
849 device
->make_and_model
= strdup(make_and_model
);
852 device
->make_and_model
= strdup(model
);
858 fprintf(stderr
, "DEBUG: Ignoring TXT record for \"%s\"...\n", fullName
);
863 * 'sigterm_handler()' - Handle termination signals...
867 sigterm_handler(int sig
) /* I - Signal number (unused) */
870 exit(CUPS_BACKEND_OK
);
877 * 'unquote()' - Unquote a name string.
881 unquote(char *dst
, /* I - Destination buffer */
882 const char *src
, /* I - Source string */
883 size_t dstsize
) /* I - Size of destination buffer */
885 char *dstend
= dst
+ dstsize
- 1; /* End of destination buffer */
888 while (*src
&& dst
< dstend
)
893 if (isdigit(src
[0] & 255) && isdigit(src
[1] & 255) &&
894 isdigit(src
[2] & 255))
896 *dst
++ = ((((src
[0] - '0') * 10) + src
[1] - '0') * 10) + src
[2] - '0';