]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - backend/dnssd.c
Fix typo.
[thirdparty/cups.git] / backend / dnssd.c
index 9afdecfe8c21f9e1a01a15b80d7fc68ebc294fd8..c0d3579b293e9daaa7eeff252193af73fd0c160a 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * "$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
@@ -96,7 +94,7 @@ static void           browse_callback(DNSServiceRef sdRef,
                                        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,
@@ -105,7 +103,7 @@ static void         browse_local_callback(DNSServiceRef sdRef,
                                              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,
@@ -123,12 +121,12 @@ static void               client_callback(AvahiClient *client,
 #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,
@@ -138,7 +136,7 @@ static void         query_callback(DNSServiceRef sdRef,
                                       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,
@@ -155,7 +153,7 @@ static void         query_callback(AvahiRecordBrowser *browser,
 #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));
 
 
 /*
@@ -921,13 +919,6 @@ get_device(cups_array_t *devices,  /* I - Device array */
   * 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);
@@ -943,8 +934,7 @@ get_device(cups_array_t *devices,   /* I - Device array */
 #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);
@@ -959,7 +949,7 @@ get_device(cups_array_t *devices,   /* I - Device array */
  *
  * 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 */
@@ -1050,9 +1040,7 @@ query_callback(
                   "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...
@@ -1065,9 +1053,7 @@ query_callback(
   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...
@@ -1202,9 +1188,9 @@ query_callback(
       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)
     {
      /*
@@ -1214,7 +1200,7 @@ query_callback(
       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);
     }
   }
@@ -1271,6 +1257,13 @@ query_callback(
     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
@@ -1327,8 +1320,3 @@ unquote(char       *dst,          /* I - Destination buffer */
 
   *dst = '\0';
 }
-
-
-/*
- * End of "$Id$".
- */