/*
- * "$Id$"
- *
* DNS-SD discovery backend for CUPS.
*
- * Copyright 2008-2015 by Apple Inc.
+ * Copyright 2008-2018 by Apple Inc.
*
* These coded instructions, statements, and computer programs are the
* property of Apple Inc. and are protected by Federal copyright
const char *serviceName,
const char *regtype,
const char *replyDomain, void *context)
- __attribute__((nonnull(1,5,6,7,8)));
+ _CUPS_NONNULL((1,5,6,7,8));
static void browse_local_callback(DNSServiceRef sdRef,
DNSServiceFlags flags,
uint32_t interfaceIndex,
const char *regtype,
const char *replyDomain,
void *context)
- __attribute__((nonnull(1,5,6,7,8)));
+ _CUPS_NONNULL((1,5,6,7,8));
#endif /* HAVE_DNSSD */
#ifdef HAVE_AVAHI
static void browse_callback(AvahiServiceBrowser *browser,
#endif /* HAVE_AVAHI */
static int compare_devices(cups_device_t *a, cups_device_t *b);
-static void exec_backend(char **argv) __attribute__((noreturn));
+static void exec_backend(char **argv) _CUPS_NORETURN;
static cups_device_t *get_device(cups_array_t *devices,
const char *serviceName,
const char *regtype,
const char *replyDomain)
- __attribute__((nonnull(1,2,3,4)));
+ _CUPS_NONNULL((1,2,3,4));
#ifdef HAVE_DNSSD
static void query_callback(DNSServiceRef sdRef,
DNSServiceFlags flags,
uint16_t rrclass, uint16_t rdlen,
const void *rdata, uint32_t ttl,
void *context)
- __attribute__((nonnull(1,5,9,11)));
+ _CUPS_NONNULL((1,5,9,11));
#elif defined(HAVE_AVAHI)
static int poll_callback(struct pollfd *pollfds,
unsigned int num_pollfds, int timeout,
#endif /* HAVE_DNSSD */
static void sigterm_handler(int sig);
static void unquote(char *dst, const char *src, size_t dstsize)
- __attribute__((nonnull(1,2)));
+ _CUPS_NONNULL((1,2));
/*
* Yes, add the device...
*/
-#ifdef HAVE_DNSSD
- DNSServiceConstructFullName(fullName, serviceName, regtype, replyDomain);
-#else /* HAVE_AVAHI */
- avahi_service_name_join(fullName, kDNSServiceMaxDomainName,
- serviceName, regtype, replyDomain);
-#endif /* HAVE_DNSSD */
-
device = calloc(sizeof(cups_device_t), 1);
device->name = strdup(serviceName);
device->domain = strdup(replyDomain);
#ifdef HAVE_DNSSD
DNSServiceConstructFullName(fullName, serviceName, regtype, replyDomain);
#else /* HAVE_AVAHI */
- avahi_service_name_join(fullName, kDNSServiceMaxDomainName,
- serviceName, regtype, replyDomain);
+ avahi_service_name_join(fullName, kDNSServiceMaxDomainName, serviceName, regtype, replyDomain);
#endif /* HAVE_DNSSD */
device->fullName = strdup(fullName);
*
* Note: This function is needed because avahi_simple_poll_iterate is broken
* and always uses a timeout of 0 (!) milliseconds.
- * (Avahi Ticket #364)
+ * (https://github.com/lathiat/avahi/issues/127)
*/
static int /* O - Number of file descriptors matching */
"interfaceIndex=%d, errorCode=%d, fullName=\"%s\", "
"rrtype=%u, rrclass=%u, rdlen=%u, rdata=%p, ttl=%u, "
"context=%p)\n",
- sdRef, flags, interfaceIndex, errorCode,
- fullName ? fullName : "(null)", rrtype, rrclass, rdlen, rdata, ttl,
- context);
+ sdRef, flags, interfaceIndex, errorCode, fullName, rrtype, rrclass, rdlen, rdata, ttl, context);
/*
* Only process "add" data...
fprintf(stderr, "DEBUG2: query_callback(browser=%p, interfaceIndex=%d, "
"protocol=%d, event=%d, fullName=\"%s\", rrclass=%u, "
"rrtype=%u, rdata=%p, rdlen=%u, flags=%x, context=%p)\n",
- browser, interfaceIndex, protocol, event,
- fullName ? fullName : "(null)", rrclass, rrtype, rdata,
- (unsigned)rdlen, flags, context);
+ browser, interfaceIndex, protocol, event, fullName, rrclass, rrtype, rdata, (unsigned)rdlen, flags, context);
/*
* Only process "add" data...
snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;",
make_and_model, model);
else if (!_cups_strncasecmp(model, "designjet ", 10))
- snprintf(device_id, sizeof(device_id), "MFG:HP;MDL:%s", model + 10);
+ snprintf(device_id, sizeof(device_id), "MFG:HP;MDL:%s;", model + 10);
else if (!_cups_strncasecmp(model, "stylus ", 7))
- snprintf(device_id, sizeof(device_id), "MFG:EPSON;MDL:%s", model + 7);
+ snprintf(device_id, sizeof(device_id), "MFG:EPSON;MDL:%s;", model + 7);
else if ((ptr = strchr(model, ' ')) != NULL)
{
/*
memcpy(make_and_model, model, (size_t)(ptr - model));
make_and_model[ptr - model] = '\0';
- snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s",
+ snprintf(device_id, sizeof(device_id), "MFG:%s;MDL:%s;",
make_and_model, ptr + 1);
}
}
strlcat(make_and_model, " ", sizeof(make_and_model));
strlcat(make_and_model, model, sizeof(make_and_model));
+ if (!_cups_strncasecmp(make_and_model, "EPSON EPSON ", 12))
+ _cups_strcpy(make_and_model, make_and_model + 6);
+ else if (!_cups_strncasecmp(make_and_model, "HP HP ", 6))
+ _cups_strcpy(make_and_model, make_and_model + 3);
+ else if (!_cups_strncasecmp(make_and_model, "Lexmark International Lexmark ", 30))
+ _cups_strcpy(make_and_model, make_and_model + 22);
+
device->make_and_model = strdup(make_and_model);
}
else
*dst = '\0';
}
-
-
-/*
- * End of "$Id$".
- */