]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Migrate to DNS-SD API.
authorMichael R Sweet <msweet@msweet.org>
Sun, 10 Sep 2023 14:04:43 +0000 (10:04 -0400)
committerMichael R Sweet <msweet@msweet.org>
Sun, 10 Sep 2023 21:58:50 +0000 (17:58 -0400)
cups/dest.c
cups/language-private.h
cups/language.c
cups/testlang.c
ppdc/ppdc-catalog.cxx
scheduler/job.c

index 72f0b8e2c69deb485074fc8e36046a382f6065d9..dc91de822ef8dbe0c98e5ff0ba509cd8976aa936 100644 (file)
@@ -1,76 +1,54 @@
-/*
- * User-defined destination (and option) support for CUPS.
- *
- * Copyright © 2021-2023 by OpenPrinting.
- * Copyright © 2007-2019 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products.
- *
- * Licensed under Apache License v2.0.  See the file "LICENSE" for more
- * information.
- */
-
-/*
- * Include necessary headers...
- */
+//
+// User-defined destination (and option) support for CUPS.
+//
+// Copyright © 2021-2023 by OpenPrinting.
+// Copyright © 2007-2019 by Apple Inc.
+// Copyright © 1997-2007 by Easy Software Products.
+//
+// Licensed under Apache License v2.0.  See the file "LICENSE" for more
+// information.
+//
 
 #include "cups-private.h"
-#include "debug-internal.h"
 #include <sys/stat.h>
 
 #ifdef HAVE_NOTIFY_H
 #  include <notify.h>
-#endif /* HAVE_NOTIFY_H */
+#endif // HAVE_NOTIFY_H
 
 #ifndef _WIN32
 #  include <poll.h>
-#endif /* !_WIN32 */
+#endif // !_WIN32
 
-#ifdef HAVE_MDNSRESPONDER
-#  include <dns_sd.h>
-#endif /* HAVE_MDNSRESPONDER */
+#include "dnssd.h"
 
-#ifdef HAVE_AVAHI
-#  include <avahi-client/client.h>
-#  include <avahi-client/lookup.h>
-#  include <avahi-common/simple-watch.h>
-#  include <avahi-common/domain.h>
-#  include <avahi-common/error.h>
-#  include <avahi-common/malloc.h>
-#define kDNSServiceMaxDomainName AVAHI_DOMAIN_NAME_MAX
-#endif /* HAVE_AVAHI */
 
-
-/*
- * Constants...
- */
+//
+// Constants...
+//
 
 #ifdef __APPLE__
 #  if HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME
 #    include <SystemConfiguration/SystemConfiguration.h>
 #    define _CUPS_LOCATION_DEFAULTS 1
-#  endif /* HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME */
+#  endif // HAVE_SCDYNAMICSTORECOPYCOMPUTERNAME
 #  define kCUPSPrintingPrefs   CFSTR("org.cups.PrintingPrefs")
 #  define kDefaultPaperIDKey   CFSTR("DefaultPaperID")
 #  define kLastUsedPrintersKey CFSTR("LastUsedPrinters")
 #  define kLocationNetworkKey  CFSTR("Network")
 #  define kLocationPrinterIDKey        CFSTR("PrinterID")
 #  define kUseLastPrinter      CFSTR("UseLastPrinter")
-#endif /* __APPLE__ */
+#endif // __APPLE__
 
-#ifdef HAVE_DNSSD
-#  define _CUPS_DNSSD_GET_DESTS 250     /* Milliseconds for cupsGetDests */
-#  define _CUPS_DNSSD_MAXTIME  50      /* Milliseconds for maximum quantum of time */
-#else
-#  define _CUPS_DNSSD_GET_DESTS 0       /* Milliseconds for cupsGetDests */
-#endif /* HAVE_DNSSD */
+#define _CUPS_DNSSD_GET_DESTS  250     // Milliseconds for cupsGetDests
+#define _CUPS_DNSSD_MAXTIME    50      // Milliseconds for maximum quantum of time
 
 
-/*
- * Types...
- */
+//
+// Types...
+//
 
-#ifdef HAVE_DNSSD
-typedef enum _cups_dnssd_state_e       /* Enumerated device state */
+typedef enum _cups_dnssd_state_e       // Enumerated device state
 {
   _CUPS_DNSSD_NEW,
   _CUPS_DNSSD_QUERY,
@@ -80,150 +58,81 @@ typedef enum _cups_dnssd_state_e   /* Enumerated device state */
   _CUPS_DNSSD_ERROR
 } _cups_dnssd_state_t;
 
-typedef struct _cups_dnssd_data_s      /* Enumeration data */
+typedef struct _cups_dnssd_data_s      // Enumeration data
 {
-#  ifdef HAVE_MDNSRESPONDER
-  DNSServiceRef                main_ref;       /* Main service reference */
-#  else /* HAVE_AVAHI */
-  AvahiSimplePoll      *simple_poll;   /* Polling interface */
-  AvahiClient          *client;        /* Client information */
-  int                  got_data;       /* Did we get data? */
-  int                  browsers;       /* How many browsers are running? */
-#  endif /* HAVE_MDNSRESPONDER */
-  cups_dest_cb_t       cb;             /* Callback */
-  void                 *user_data;     /* User data pointer */
-  cups_ptype_t         type,           /* Printer type filter */
-                       mask;           /* Printer type mask */
-  cups_array_t         *devices;       /* Devices found so far */
-  int                  num_dests;      /* Number of lpoptions destinations */
-  cups_dest_t          *dests;         /* lpoptions destinations */
-  char                 def_name[1024], /* Default printer name, if any */
-                       *def_instance;  /* Default printer instance, if any */
+  cups_rwlock_t                rwlock;         // Reader/writer lock
+  cups_dnssd_t         *dnssd;         // DNS-SD context
+  cups_dest_cb_t       cb;             // Callback
+  void                 *user_data;     // User data pointer
+  cups_ptype_t         type,           // Printer type filter
+                       mask;           // Printer type mask
+  cups_array_t         *devices;       // Devices found so far
+  size_t               num_dests;      // Number of lpoptions destinations
+  cups_dest_t          *dests;         // lpoptions destinations
+  char                 def_name[1024], // Default printer name, if any
+                       *def_instance;  // Default printer instance, if any
 } _cups_dnssd_data_t;
 
-typedef struct _cups_dnssd_device_s    /* Enumerated device */
+typedef struct _cups_dnssd_device_s    // Enumerated device
 {
-  _cups_dnssd_state_t  state;          /* State of device listing */
-#  ifdef HAVE_MDNSRESPONDER
-  DNSServiceRef                ref;            /* Service reference for query */
-#  else /* HAVE_AVAHI */
-  AvahiRecordBrowser   *ref;           /* Browser for query */
-#  endif /* HAVE_MDNSRESPONDER */
-  char                 *fullName,      /* Full name */
-                       *regtype,       /* Registration type */
-                       *domain;        /* Domain name */
-  cups_ptype_t         type;           /* Device registration type */
-  cups_dest_t          dest;           /* Destination record */
+  _cups_dnssd_state_t  state;          // State of device listing
+  cups_dnssd_query_t   *query;         // DNS-SD query request
+  char                 *fullname,      // Full name
+                       *regtype,       // Registration type
+                       *domain;        // Domain name
+  cups_ptype_t         type;           // Device registration type
+  cups_dest_t          dest;           // Destination record
 } _cups_dnssd_device_t;
 
-typedef struct _cups_dnssd_resolve_s   /* Data for resolving URI */
+typedef struct _cups_dnssd_resdata_s   // Data for resolving URI
 {
-  int                  *cancel;        /* Pointer to "cancel" variable */
-  struct timeval       end_time;       /* Ending time */
-} _cups_dnssd_resolve_t;
-#endif /* HAVE_DNSSD */
+  int                  *cancel;        // Pointer to "cancel" variable
+  struct timeval       end_time;       // Ending time
+} _cups_dnssd_resdata_t;
 
 typedef struct _cups_getdata_s
 {
-  int          num_dests;              /* Number of destinations */
-  cups_dest_t  *dests;                 /* Destinations */
-  char         def_name[1024],         /* Default printer name, if any */
-               *def_instance;          /* Default printer instance, if any */
+  int          num_dests;              // Number of destinations
+  cups_dest_t  *dests;                 // Destinations
+  char         def_name[1024],         // Default printer name, if any
+               *def_instance;          // Default printer instance, if any
 } _cups_getdata_t;
 
 typedef struct _cups_namedata_s
 {
-  const char  *name;                    /* Named destination */
-  cups_dest_t *dest;                    /* Destination */
+  const char  *name;                    // Named destination
+  cups_dest_t *dest;                    // Destination
 } _cups_namedata_t;
 
 
-/*
- * Local functions...
- */
+//
+// Local functions...
+//
 
 #if _CUPS_LOCATION_DEFAULTS
 static CFArrayRef      appleCopyLocations(void);
 static CFStringRef     appleCopyNetwork(void);
-#endif /* _CUPS_LOCATION_DEFAULTS */
+#endif // _CUPS_LOCATION_DEFAULTS
 #ifdef __APPLE__
 static char            *appleGetPaperSize(char *name, size_t namesize);
-#endif /* __APPLE__ */
+#endif // __APPLE__
 #if _CUPS_LOCATION_DEFAULTS
-static CFStringRef     appleGetPrinter(CFArrayRef locations,
-                                       CFStringRef network, CFIndex *locindex);
-#endif /* _CUPS_LOCATION_DEFAULTS */
-static cups_dest_t     *cups_add_dest(const char *name, const char *instance,
-                                      int *num_dests, cups_dest_t **dests);
+static CFStringRef     appleGetPrinter(CFArrayRef locations, CFStringRef network, CFIndex *locindex);
+#endif // _CUPS_LOCATION_DEFAULTS
+static cups_dest_t     *cups_add_dest(const char *name, const char *instance, int *num_dests, cups_dest_t **dests);
 #ifdef __BLOCKS__
-static int             cups_block_cb(cups_dest_block_t block, unsigned flags,
-                                     cups_dest_t *dest);
-#endif /* __BLOCKS__ */
+static int             cups_block_cb(cups_dest_block_t block, unsigned flags, cups_dest_t *dest);
+#endif // __BLOCKS__
 static int             cups_compare_dests(cups_dest_t *a, cups_dest_t *b);
-#ifdef HAVE_DNSSD
-#  ifdef HAVE_MDNSRESPONDER
-static void            cups_dnssd_browse_cb(DNSServiceRef sdRef,
-                                            DNSServiceFlags flags,
-                                            uint32_t interfaceIndex,
-                                            DNSServiceErrorType errorCode,
-                                            const char *serviceName,
-                                            const char *regtype,
-                                            const char *replyDomain,
-                                            void *context);
-#  else /* HAVE_AVAHI */
-static void            cups_dnssd_browse_cb(AvahiServiceBrowser *browser,
-                                            AvahiIfIndex interface,
-                                            AvahiProtocol protocol,
-                                            AvahiBrowserEvent event,
-                                            const char *serviceName,
-                                            const char *regtype,
-                                            const char *replyDomain,
-                                            AvahiLookupResultFlags flags,
-                                            void *context);
-static void            cups_dnssd_client_cb(AvahiClient *client,
-                                            AvahiClientState state,
-                                            void *context);
-#  endif /* HAVE_MDNSRESPONDER */
-static int             cups_dnssd_compare_devices(_cups_dnssd_device_t *a,
-                                                  _cups_dnssd_device_t *b);
-static void            cups_dnssd_free_device(_cups_dnssd_device_t *device,
-                                              _cups_dnssd_data_t *data);
-static _cups_dnssd_device_t *
-                       cups_dnssd_get_device(_cups_dnssd_data_t *data,
-                                             const char *serviceName,
-                                             const char *regtype,
-                                             const char *replyDomain);
-#  ifdef HAVE_MDNSRESPONDER
-static void            cups_dnssd_query_cb(DNSServiceRef sdRef,
-                                           DNSServiceFlags flags,
-                                           uint32_t interfaceIndex,
-                                           DNSServiceErrorType errorCode,
-                                           const char *fullName,
-                                           uint16_t rrtype, uint16_t rrclass,
-                                           uint16_t rdlen, const void *rdata,
-                                           uint32_t ttl, void *context);
-#  else /* HAVE_AVAHI */
-static int             cups_dnssd_poll_cb(struct pollfd *pollfds,
-                                          unsigned int num_pollfds,
-                                          int timeout, void *context);
-static void            cups_dnssd_query_cb(AvahiRecordBrowser *browser,
-                                           AvahiIfIndex interface,
-                                           AvahiProtocol protocol,
-                                           AvahiBrowserEvent event,
-                                           const char *name, uint16_t rrclass,
-                                           uint16_t rrtype, const void *rdata,
-                                           size_t rdlen,
-                                           AvahiLookupResultFlags flags,
-                                           void *context);
-#  endif /* HAVE_MDNSRESPONDER */
-static const char      *cups_dnssd_resolve(cups_dest_t *dest, const char *uri,
-                                           int msec, int *cancel,
-                                           cups_dest_cb_t cb, void *user_data);
-static bool            cups_dnssd_resolve_cb(void *context);
-static void            cups_dnssd_unquote(char *dst, const char *src,
-                                          size_t dstsize);
+static void            cups_dest_browse_cb(cups_dnssd_browse_t *browse, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *name, const char *regtype, const char *domain);
+static int             cups_dnssd_compare_devices(_cups_dnssd_device_t *a, _cups_dnssd_device_t *b);
+static void            cups_dnssd_free_device(_cups_dnssd_device_t *device, _cups_dnssd_data_t *data);
+static _cups_dnssd_device_t *cups_dnssd_get_device(_cups_dnssd_data_t *data, const char *serviceName, const char *regtype, const char *replyDomain);
+static void            cups_dest_query_cb(cups_dnssd_query_t *query, void *cb_data, cups_dnssd_flags_t flags, uint32_t if_index, const char *fullname, uint16_t rrtype, const void *qdata, uint16_t qlen);
+static const char      *cups_dest_resolve(cups_dest_t *dest, const char *uri, int msec, int *cancel, cups_dest_cb_t cb, void *user_data);
+static bool            cups_dest_resolve_cb(void *context);
+static void            cups_dnssd_unquote(char *dst, const char *src, size_t dstsize);
 static int             cups_elapsed(struct timeval *t);
-#endif /* HAVE_DNSSD */
 static int              cups_enum_dests(http_t *http, unsigned flags, int msec, int *cancel, cups_ptype_t type, cups_ptype_t mask, cups_dest_cb_t cb, void *user_data);
 static int             cups_find_dest(const char *name, const char *instance,
                                       int num_dests, cups_dest_t *dests, int prev,
@@ -236,34 +145,35 @@ static char               *cups_make_string(ipp_attribute_t *attr, char *buffer,
                                          size_t bufsize);
 static int              cups_name_cb(_cups_namedata_t *data, unsigned flags, cups_dest_t *dest);
 static void            cups_queue_name(char *name, const char *serviceName, size_t namesize);
-
-
-/*
- * 'cupsAddDest()' - Add a destination to the list of destinations.
- *
- * This function cannot be used to add a new class or printer queue,
- * it only adds a new container of saved options for the named
- * destination or instance.
- *
- * If the named destination already exists, the destination list is
- * returned unchanged.  Adding a new instance of a destination creates
- * a copy of that destination's options.
- *
- * Use the @link cupsSaveDests@ function to save the updated list of
- * destinations to the user's lpoptions file.
- */
-
-int                                    /* O  - New number of destinations */
-cupsAddDest(const char  *name,         /* I  - Destination name */
-            const char *instance,      /* I  - Instance name or @code NULL@ for none/primary */
-            int         num_dests,     /* I  - Number of destinations */
-            cups_dest_t **dests)       /* IO - Destinations */
+static void            dnssd_error_cb(void *cb_data, const char *message);
+
+
+//
+// 'cupsAddDest()' - Add a destination to the list of destinations.
+//
+// This function cannot be used to add a new class or printer queue,
+// it only adds a new container of saved options for the named
+// destination or instance.
+//
+// If the named destination already exists, the destination list is
+// returned unchanged.  Adding a new instance of a destination creates
+// a copy of that destination's options.
+//
+// Use the @link cupsSaveDests@ function to save the updated list of
+// destinations to the user's lpoptions file.
+//
+
+int                                    // O  - New number of destinations
+cupsAddDest(const char  *name,         // I  - Destination name
+            const char *instance,      // I  - Instance name or @code NULL@ for none/primary
+            int         num_dests,     // I  - Number of destinations
+            cups_dest_t **dests)       // IO - Destinations
 {
-  int          i;                      /* Looping var */
-  cups_dest_t  *dest;                  /* Destination pointer */
-  cups_dest_t  *parent = NULL;         /* Parent destination */
-  cups_option_t        *doption,               /* Current destination option */
-               *poption;               /* Current parent option */
+  int          i;                      // Looping var
+  cups_dest_t  *dest;                  // Destination pointer
+  cups_dest_t  *parent = NULL;         // Parent destination
+  cups_option_t        *doption,               // Current destination option
+               *poption;               // Current parent option
 
 
   if (!name || !dests)
@@ -316,11 +226,11 @@ cupsAddDest(const char  *name,            /* I  - Destination name */
 
 
 #ifdef __APPLE__
-/*
- * '_cupsAppleCopyDefaultPaperID()' - Get the default paper ID.
- */
+//
+// '_cupsAppleCopyDefaultPaperID()' - Get the default paper ID.
+//
 
-CFStringRef                            /* O - Default paper ID */
+CFStringRef                            // O - Default paper ID
 _cupsAppleCopyDefaultPaperID(void)
 {
   return (CFPreferencesCopyAppValue(kDefaultPaperIDKey,
@@ -328,23 +238,23 @@ _cupsAppleCopyDefaultPaperID(void)
 }
 
 
-/*
- * '_cupsAppleCopyDefaultPrinter()' - Get the default printer at this location.
- */
+//
+// '_cupsAppleCopyDefaultPrinter()' - Get the default printer at this location.
+//
 
-CFStringRef                            /* O - Default printer name */
+CFStringRef                            // O - Default printer name
 _cupsAppleCopyDefaultPrinter(void)
 {
 #  if _CUPS_LOCATION_DEFAULTS
-  CFStringRef  network;                /* Network location */
-  CFArrayRef   locations;              /* Location array */
-  CFStringRef  locprinter;             /* Current printer */
+  CFStringRef  network;                // Network location
+  CFArrayRef   locations;              // Location array
+  CFStringRef  locprinter;             // Current printer
 
 
- /*
-  * Use location-based defaults only if "use last printer" is selected in the
-  * system preferences...
-  */
+  //
+  // Use location-based defaults only if "use last printer" is selected in the
+  // system preferences...
+  //
 
   if (!_cupsAppleGetUseLastPrinter())
   {
@@ -353,9 +263,9 @@ _cupsAppleCopyDefaultPrinter(void)
     return (NULL);
   }
 
- /*
-  * Get the current location...
-  */
+  //
+  // Get the current location...
+  //
 
   if ((network = appleCopyNetwork()) == NULL)
   {
@@ -364,9 +274,9 @@ _cupsAppleCopyDefaultPrinter(void)
     return (NULL);
   }
 
- /*
-  * Lookup the network in the preferences...
-  */
+  //
+  // Lookup the network in the preferences...
+  //
 
   if ((locations = appleCopyLocations()) == NULL)
   {
@@ -394,19 +304,19 @@ _cupsAppleCopyDefaultPrinter(void)
 
 #  else
   return (NULL);
-#  endif /* _CUPS_LOCATION_DEFAULTS */
+#  endif // _CUPS_LOCATION_DEFAULTS
 }
 
 
-/*
- * '_cupsAppleGetUseLastPrinter()' - Get whether to use the last used printer.
- */
+//
+// '_cupsAppleGetUseLastPrinter()' - Get whether to use the last used printer.
+//
 
-int                                    /* O - 1 to use last printer, 0 otherwise */
+int                                    // O - 1 to use last printer, 0 otherwise
 _cupsAppleGetUseLastPrinter(void)
 {
-  Boolean      uselast,                /* Use last printer preference value */
-               uselast_set;            /* Valid is set? */
+  Boolean      uselast,                // Use last printer preference value
+               uselast_set;            // Valid is set?
 
 
   if (getenv("CUPS_DISABLE_APPLE_DEFAULT"))
@@ -422,43 +332,43 @@ _cupsAppleGetUseLastPrinter(void)
 }
 
 
-/*
- * '_cupsAppleSetDefaultPaperID()' - Set the default paper id.
- */
+//
+// '_cupsAppleSetDefaultPaperID()' - Set the default paper id.
+//
 
 void
 _cupsAppleSetDefaultPaperID(
-    CFStringRef name)                  /* I - New paper ID */
+    CFStringRef name)                  // I - New paper ID
 {
   CFPreferencesSetAppValue(kDefaultPaperIDKey, name, kCUPSPrintingPrefs);
   CFPreferencesAppSynchronize(kCUPSPrintingPrefs);
 
 #  ifdef HAVE_NOTIFY_POST
   notify_post("com.apple.printerPrefsChange");
-#  endif /* HAVE_NOTIFY_POST */
+#  endif // HAVE_NOTIFY_POST
 }
 
 
-/*
- * '_cupsAppleSetDefaultPrinter()' - Set the default printer for this location.
- */
+//
+// '_cupsAppleSetDefaultPrinter()' - Set the default printer for this location.
+//
 
 void
 _cupsAppleSetDefaultPrinter(
-    CFStringRef name)                  /* I - Default printer/class name */
+    CFStringRef name)                  // I - Default printer/class name
 {
 #  if _CUPS_LOCATION_DEFAULTS
-  CFStringRef          network;        /* Current network */
-  CFArrayRef           locations;      /* Old locations array */
-  CFIndex              locindex;       /* Index in locations array */
-  CFStringRef          locprinter;     /* Current printer */
-  CFMutableArrayRef    newlocations;   /* New locations array */
-  CFMutableDictionaryRef newlocation;  /* New location */
+  CFStringRef          network;        // Current network
+  CFArrayRef           locations;      // Old locations array
+  CFIndex              locindex;       // Index in locations array
+  CFStringRef          locprinter;     // Current printer
+  CFMutableArrayRef    newlocations;   // New locations array
+  CFMutableDictionaryRef newlocation;  // New location
 
 
- /*
-  * Get the current location...
-  */
+  //
+  // Get the current location...
+  //
 
   if ((network = appleCopyNetwork()) == NULL)
   {
@@ -466,9 +376,9 @@ _cupsAppleSetDefaultPrinter(
     return;
   }
 
- /*
-  * Lookup the network in the preferences...
-  */
+  //
+  // Lookup the network in the preferences...
+  //
 
   if ((locations = appleCopyLocations()) != NULL)
     locprinter = appleGetPrinter(locations, network, &locindex);
@@ -527,7 +437,7 @@ _cupsAppleSetDefaultPrinter(
 
 #  ifdef HAVE_NOTIFY_POST
       notify_post("com.apple.printerPrefsChange");
-#  endif /* HAVE_NOTIFY_POST */
+#  endif // HAVE_NOTIFY_POST
     }
 
     if (newlocations)
@@ -544,17 +454,17 @@ _cupsAppleSetDefaultPrinter(
 
 #  else
   (void)name;
-#  endif /* _CUPS_LOCATION_DEFAULTS */
+#  endif // _CUPS_LOCATION_DEFAULTS
 }
 
 
-/*
- * '_cupsAppleSetUseLastPrinter()' - Set whether to use the last used printer.
- */
+//
+// '_cupsAppleSetUseLastPrinter()' - Set whether to use the last used printer.
+//
 
 void
 _cupsAppleSetUseLastPrinter(
-    int uselast)                       /* O - 1 to use last printer, 0 otherwise */
+    int uselast)                       // O - 1 to use last printer, 0 otherwise
 {
   CFPreferencesSetAppValue(kUseLastPrinter,
                           uselast ? kCFBooleanTrue : kCFBooleanFalse,
@@ -563,57 +473,57 @@ _cupsAppleSetUseLastPrinter(
 
 #  ifdef HAVE_NOTIFY_POST
   notify_post("com.apple.printerPrefsChange");
-#  endif /* HAVE_NOTIFY_POST */
+#  endif // HAVE_NOTIFY_POST
 }
-#endif /* __APPLE__ */
-
-
-/*
- * 'cupsConnectDest()' - Open a connection to the destination.
- *
- * Connect to the destination, returning a new @code http_t@ connection object
- * and optionally the resource path to use for the destination.  These calls
- * will block until a connection is made, the timeout expires, the integer
- * pointed to by "cancel" is non-zero, or the callback function (or block)
- * returns 0.  The caller is responsible for calling @link httpClose@ on the
- * returned connection.
- *
- * Starting with CUPS 2.2.4, the caller can pass @code CUPS_DEST_FLAGS_DEVICE@
- * for the "flags" argument to connect directly to the device associated with
- * the destination.  Otherwise, the connection is made to the CUPS scheduler
- * associated with the destination.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-http_t *                               /* O - Connection to destination or @code NULL@ */
+#endif // __APPLE__
+
+
+//
+// 'cupsConnectDest()' - Open a connection to the destination.
+//
+// Connect to the destination, returning a new @code http_t@ connection object
+// and optionally the resource path to use for the destination.  These calls
+// will block until a connection is made, the timeout expires, the integer
+// pointed to by "cancel" is non-zero, or the callback function (or block)
+// returns 0.  The caller is responsible for calling @link httpClose@ on the
+// returned connection.
+//
+// Starting with CUPS 2.2.4, the caller can pass @code CUPS_DEST_FLAGS_DEVICE@
+// for the "flags" argument to connect directly to the device associated with
+// the destination.  Otherwise, the connection is made to the CUPS scheduler
+// associated with the destination.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+http_t *                               // O - Connection to destination or @code NULL@
 cupsConnectDest(
-    cups_dest_t    *dest,              /* I - Destination */
-    unsigned       flags,              /* I - Connection flags */
-    int            msec,               /* I - Timeout in milliseconds */
-    int            *cancel,            /* I - Pointer to "cancel" variable */
-    char           *resource,          /* I - Resource buffer */
-    size_t         resourcesize,       /* I - Size of resource buffer */
-    cups_dest_cb_t cb,                 /* I - Callback function */
-    void           *user_data)         /* I - User data pointer */
+    cups_dest_t    *dest,              // I - Destination
+    unsigned       flags,              // I - Connection flags
+    int            msec,               // I - Timeout in milliseconds
+    int            *cancel,            // I - Pointer to "cancel" variable
+    char           *resource,          // I - Resource buffer
+    size_t         resourcesize,       // I - Size of resource buffer
+    cups_dest_cb_t cb,                 // I - Callback function
+    void           *user_data)         // I - User data pointer
 {
-  const char   *uri;                   /* Printer URI */
-  char         scheme[32],             /* URI scheme */
-               userpass[256],          /* Username and password (unused) */
-               hostname[256],          /* Hostname */
-               tempresource[1024];     /* Temporary resource buffer */
-  int          port;                   /* Port number */
-  char         portstr[16];            /* Port number string */
-  http_encryption_t encryption;                /* Encryption to use */
-  http_addrlist_t *addrlist;           /* Address list for server */
-  http_t       *http;                  /* Connection to server */
+  const char   *uri;                   // Printer URI
+  char         scheme[32],             // URI scheme
+               userpass[256],          // Username and password (unused)
+               hostname[256],          // Hostname
+               tempresource[1024];     // Temporary resource buffer
+  int          port;                   // Port number
+  char         portstr[16];            // Port number string
+  http_encryption_t encryption;                // Encryption to use
+  http_addrlist_t *addrlist;           // Address list for server
+  http_t       *http;                  // Connection to server
 
 
   DEBUG_printf("cupsConnectDest(dest=%p, flags=0x%x, msec=%d, cancel=%p(%d), resource=\"%s\", resourcesize=" CUPS_LLFMT ", cb=%p, user_data=%p)", (void *)dest, flags, msec, (void *)cancel, cancel ? *cancel : -1, resource, CUPS_LLCAST resourcesize, (void *)cb, user_data);
 
- /*
-  * Range check input...
-  */
+  //
+  // Range check input...
+  //
 
   if (!dest)
   {
@@ -630,28 +540,24 @@ cupsConnectDest(
     resourcesize = sizeof(tempresource);
   }
 
- /*
-  * Grab the printer URI...
-  */
+  //
+  // Grab the printer URI...
+  //
 
   if (flags & CUPS_DEST_FLAGS_DEVICE)
   {
     if ((uri = cupsGetOption("device-uri", dest->num_options, dest->options)) != NULL)
     {
-#ifdef HAVE_DNSSD
       if (strstr(uri, "._tcp"))
-        uri = cups_dnssd_resolve(dest, uri, msec, cancel, cb, user_data);
-#endif /* HAVE_DNSSD */
+        uri = cups_dest_resolve(dest, uri, msec, cancel, cb, user_data);
     }
   }
   else if ((uri = cupsGetOption("printer-uri-supported", dest->num_options, dest->options)) == NULL)
   {
     if ((uri = cupsGetOption("device-uri", dest->num_options, dest->options)) != NULL)
     {
-#ifdef HAVE_DNSSD
       if (strstr(uri, "._tcp"))
-        uri = cups_dnssd_resolve(dest, uri, msec, cancel, cb, user_data);
-#endif /* HAVE_DNSSD */
+        uri = cups_dest_resolve(dest, uri, msec, cancel, cb, user_data);
     }
 
     if (uri)
@@ -688,9 +594,9 @@ cupsConnectDest(
     return (NULL);
   }
 
- /*
-  * Lookup the address for the server...
-  */
+  //
+  // Lookup the address for the server...
+  //
 
   if (cb)
     (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_RESOLVING, dest);
@@ -715,9 +621,9 @@ cupsConnectDest(
     return (NULL);
   }
 
- /*
-  * Create the HTTP object pointing to the server referenced by the URI...
-  */
+  //
+  // Create the HTTP object pointing to the server referenced by the URI...
+  //
 
   if (!strcmp(scheme, "ipps") || port == 443)
     encryption = HTTP_ENCRYPTION_ALWAYS;
@@ -727,9 +633,9 @@ cupsConnectDest(
   http = httpConnect2(hostname, port, addrlist, AF_UNSPEC, encryption, 1, 0, NULL);
   httpAddrFreeList(addrlist);
 
- /*
-  * Connect if requested...
-  */
+  //
+  // Connect if requested...
+  //
 
   if (flags & CUPS_DEST_FLAGS_UNCONNECTED)
   {
@@ -757,70 +663,70 @@ cupsConnectDest(
 
 
 #ifdef __BLOCKS__
-/*
- * 'cupsConnectDestBlock()' - Open a connection to the destination.
- *
- * Connect to the destination, returning a new @code http_t@ connection object
- * and optionally the resource path to use for the destination.  These calls
- * will block until a connection is made, the timeout expires, the integer
- * pointed to by "cancel" is non-zero, or the block returns 0.  The caller is
- * responsible for calling @link httpClose@ on the returned connection.
- *
- * Starting with CUPS 2.2.4, the caller can pass  @code CUPS_DEST_FLAGS_DEVICE@
- * for the "flags" argument to connect directly to the device associated with
- * the destination.  Otherwise, the connection is made to the CUPS scheduler
- * associated with the destination.
- *
- * @since CUPS 1.6/macOS 10.8@ @exclude all@
- */
-
-http_t *                               /* O - Connection to destination or @code NULL@ */
+//
+// 'cupsConnectDestBlock()' - Open a connection to the destination.
+//
+// Connect to the destination, returning a new @code http_t@ connection object
+// and optionally the resource path to use for the destination.  These calls
+// will block until a connection is made, the timeout expires, the integer
+// pointed to by "cancel" is non-zero, or the block returns 0.  The caller is
+// responsible for calling @link httpClose@ on the returned connection.
+//
+// Starting with CUPS 2.2.4, the caller can pass  @code CUPS_DEST_FLAGS_DEVICE@
+// for the "flags" argument to connect directly to the device associated with
+// the destination.  Otherwise, the connection is made to the CUPS scheduler
+// associated with the destination.
+//
+// @since CUPS 1.6/macOS 10.8@ @exclude all@
+//
+
+http_t *                               // O - Connection to destination or @code NULL@
 cupsConnectDestBlock(
-    cups_dest_t       *dest,           /* I - Destination */
-    unsigned          flags,           /* I - Connection flags */
-    int               msec,            /* I - Timeout in milliseconds */
-    int               *cancel,         /* I - Pointer to "cancel" variable */
-    char              *resource,       /* I - Resource buffer */
-    size_t            resourcesize,    /* I - Size of resource buffer */
-    cups_dest_block_t block)           /* I - Callback block */
+    cups_dest_t       *dest,           // I - Destination
+    unsigned          flags,           // I - Connection flags
+    int               msec,            // I - Timeout in milliseconds
+    int               *cancel,         // I - Pointer to "cancel" variable
+    char              *resource,       // I - Resource buffer
+    size_t            resourcesize,    // I - Size of resource buffer
+    cups_dest_block_t block)           // I - Callback block
 {
   return (cupsConnectDest(dest, flags, msec, cancel, resource, resourcesize,
                           (cups_dest_cb_t)cups_block_cb, (void *)block));
 }
-#endif /* __BLOCKS__ */
-
-
-/*
- * 'cupsCopyDest()' - Copy a destination.
- *
- * Make a copy of the destination to an array of destinations (or just a single
- * copy) - for use with the cupsEnumDests* functions. The caller is responsible
- * for calling cupsFreeDests() on the returned object(s).
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int                                     /* O  - New number of destinations */
-cupsCopyDest(cups_dest_t *dest,         /* I  - Destination to copy */
-             int         num_dests,     /* I  - Number of destinations */
-             cups_dest_t **dests)       /* IO - Destination array */
+#endif // __BLOCKS__
+
+
+//
+// 'cupsCopyDest()' - Copy a destination.
+//
+// Make a copy of the destination to an array of destinations (or just a single
+// copy) - for use with the cupsEnumDests* functions. The caller is responsible
+// for calling cupsFreeDests() on the returned object(s).
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int                                     // O  - New number of destinations
+cupsCopyDest(cups_dest_t *dest,         // I  - Destination to copy
+             int         num_dests,     // I  - Number of destinations
+             cups_dest_t **dests)       // IO - Destination array
 {
-  int          i;                      /* Looping var */
-  cups_dest_t  *new_dest;              /* New destination pointer */
-  cups_option_t        *new_option,            /* Current destination option */
-               *option;                /* Current parent option */
+  int          i;                      // Looping var
+  cups_dest_t  *new_dest;              // New destination pointer
+  cups_option_t        *new_option,            // Current destination option
+               *option;                // Current parent option
 
 
- /*
-  * Range check input...
-  */
+  //
+  // Range check input...
+  //
 
   if (!dest || num_dests < 0 || !dests)
     return (num_dests);
 
- /*
-  * See if the destination already exists...
-  */
+  //
+  // See if the destination already exists...
+  //
 
   if ((new_dest = cupsGetDest(dest->name, dest->instance, num_dests,
                               *dests)) != NULL)
@@ -867,24 +773,24 @@ cupsCopyDest(cups_dest_t *dest,         /* I  - Destination to copy */
 }
 
 
-/*
- * '_cupsCreateDest()' - Create a local (temporary) queue.
- */
+//
+// '_cupsCreateDest()' - Create a local (temporary) queue.
+//
 
-char *                                 /* O - Printer URI or @code NULL@ on error */
-_cupsCreateDest(const char *name,      /* I - Printer name */
-                const char *info,      /* I - Printer description of @code NULL@ */
-               const char *device_id,  /* I - 1284 Device ID or @code NULL@ */
-               const char *device_uri, /* I - Device URI */
-               char       *uri,        /* I - Printer URI buffer */
-               size_t     urisize)     /* I - Size of URI buffer */
+char *                                 // O - Printer URI or @code NULL@ on error
+_cupsCreateDest(const char *name,      // I - Printer name
+                const char *info,      // I - Printer description of @code NULL@
+               const char *device_id,  // I - 1284 Device ID or @code NULL@
+               const char *device_uri, // I - Device URI
+               char       *uri,        // I - Printer URI buffer
+               size_t     urisize)     // I - Size of URI buffer
 {
-  http_t       *http;                  /* Connection to server */
-  ipp_t                *request,               /* CUPS-Create-Local-Printer request */
-               *response;              /* CUPS-Create-Local-Printer response */
-  ipp_attribute_t *attr;               /* printer-uri-supported attribute */
+  http_t       *http;                  // Connection to server
+  ipp_t                *request,               // CUPS-Create-Local-Printer request
+               *response;              // CUPS-Create-Local-Printer response
+  ipp_attribute_t *attr;               // printer-uri-supported attribute
   ipp_pstate_t state = IPP_PSTATE_STOPPED;
-                                       /* printer-state value */
+                                       // printer-state value
 
 
   if (!name || !device_uri || !uri || urisize < 32)
@@ -944,90 +850,90 @@ _cupsCreateDest(const char *name, /* I - Printer name */
 }
 
 
-/*
- * 'cupsEnumDests()' - Enumerate available destinations with a callback function.
- *
- * Destinations are enumerated from one or more sources.  The callback function
- * receives the @code user_data@ pointer and the destination pointer which can
- * be used as input to the @link cupsCopyDest@ function.  The function must
- * return 1 to continue enumeration or 0 to stop.
- *
- * The @code type@ and @code mask@ arguments allow the caller to filter the
- * destinations that are enumerated.  Passing 0 for both will enumerate all
- * printers.  The constant @code CUPS_PRINTER_DISCOVERED@ is used to filter on
- * destinations that are available but have not yet been added locally.
- *
- * Enumeration happens on the current thread and does not return until all
- * destinations have been enumerated or the callback function returns 0.
- *
- * Note: The callback function will likely receive multiple updates for the same
- * destinations - it is up to the caller to suppress any duplicate destinations.
- *
- * @since CUPS 1.6/macOS 10.8@
- */
-
-int                                    /* O - 1 on success, 0 on failure */
+//
+// 'cupsEnumDests()' - Enumerate available destinations with a callback function.
+//
+// Destinations are enumerated from one or more sources.  The callback function
+// receives the @code user_data@ pointer and the destination pointer which can
+// be used as input to the @link cupsCopyDest@ function.  The function must
+// return 1 to continue enumeration or 0 to stop.
+//
+// The @code type@ and @code mask@ arguments allow the caller to filter the
+// destinations that are enumerated.  Passing 0 for both will enumerate all
+// printers.  The constant @code CUPS_PRINTER_DISCOVERED@ is used to filter on
+// destinations that are available but have not yet been added locally.
+//
+// Enumeration happens on the current thread and does not return until all
+// destinations have been enumerated or the callback function returns 0.
+//
+// Note: The callback function will likely receive multiple updates for the same
+// destinations - it is up to the caller to suppress any duplicate destinations.
+//
+// @since CUPS 1.6/macOS 10.8@
+//
+
+int                                    // O - 1 on success, 0 on failure
 cupsEnumDests(
-  unsigned       flags,                        /* I - Enumeration flags */
-  int            msec,                 /* I - Timeout in milliseconds, -1 for indefinite */
-  int            *cancel,              /* I - Pointer to "cancel" variable */
-  cups_ptype_t   type,                 /* I - Printer type bits */
-  cups_ptype_t   mask,                 /* I - Mask for printer type bits */
-  cups_dest_cb_t cb,                   /* I - Callback function */
-  void           *user_data)           /* I - User data */
+  unsigned       flags,                        // I - Enumeration flags
+  int            msec,                 // I - Timeout in milliseconds, -1 for indefinite
+  int            *cancel,              // I - Pointer to "cancel" variable
+  cups_ptype_t   type,                 // I - Printer type bits
+  cups_ptype_t   mask,                 // I - Mask for printer type bits
+  cups_dest_cb_t cb,                   // I - Callback function
+  void           *user_data)           // I - User data
 {
   return (cups_enum_dests(CUPS_HTTP_DEFAULT, flags, msec, cancel, type, mask, cb, user_data));
 }
 
 
 #  ifdef __BLOCKS__
-/*
- * 'cupsEnumDestsBlock()' - Enumerate available destinations with a block.
- *
- * Destinations are enumerated from one or more sources.  The block receives the
- * @code user_data@ pointer and the destination pointer which can be used as
- * input to the @link cupsCopyDest@ function.  The block must return 1 to
- * continue enumeration or 0 to stop.
- *
- * The @code type@ and @code mask@ arguments allow the caller to filter the
- * destinations that are enumerated.  Passing 0 for both will enumerate all
- * printers.  The constant @code CUPS_PRINTER_DISCOVERED@ is used to filter on
- * destinations that are available but have not yet been added locally.
- *
- * Enumeration happens on the current thread and does not return until all
- * destinations have been enumerated or the block returns 0.
- *
- * Note: The block will likely receive multiple updates for the same
- * destinations - it is up to the caller to suppress any duplicate destinations.
- *
- * @since CUPS 1.6/macOS 10.8@ @exclude all@
- */
-
-int                                    /* O - 1 on success, 0 on failure */
+//
+// 'cupsEnumDestsBlock()' - Enumerate available destinations with a block.
+//
+// Destinations are enumerated from one or more sources.  The block receives the
+// @code user_data@ pointer and the destination pointer which can be used as
+// input to the @link cupsCopyDest@ function.  The block must return 1 to
+// continue enumeration or 0 to stop.
+//
+// The @code type@ and @code mask@ arguments allow the caller to filter the
+// destinations that are enumerated.  Passing 0 for both will enumerate all
+// printers.  The constant @code CUPS_PRINTER_DISCOVERED@ is used to filter on
+// destinations that are available but have not yet been added locally.
+//
+// Enumeration happens on the current thread and does not return until all
+// destinations have been enumerated or the block returns 0.
+//
+// Note: The block will likely receive multiple updates for the same
+// destinations - it is up to the caller to suppress any duplicate destinations.
+//
+// @since CUPS 1.6/macOS 10.8@ @exclude all@
+//
+
+int                                    // O - 1 on success, 0 on failure
 cupsEnumDestsBlock(
-    unsigned          flags,           /* I - Enumeration flags */
-    int               timeout,         /* I - Timeout in milliseconds, 0 for indefinite */
-    int               *cancel,         /* I - Pointer to "cancel" variable */
-    cups_ptype_t      type,            /* I - Printer type bits */
-    cups_ptype_t      mask,            /* I - Mask for printer type bits */
-    cups_dest_block_t block)           /* I - Block */
+    unsigned          flags,           // I - Enumeration flags
+    int               timeout,         // I - Timeout in milliseconds, 0 for indefinite
+    int               *cancel,         // I - Pointer to "cancel" variable
+    cups_ptype_t      type,            // I - Printer type bits
+    cups_ptype_t      mask,            // I - Mask for printer type bits
+    cups_dest_block_t block)           // I - Block
 {
   return (cupsEnumDests(flags, timeout, cancel, type, mask,
                         (cups_dest_cb_t)cups_block_cb, (void *)block));
 }
-#  endif /* __BLOCKS__ */
+#  endif // __BLOCKS__
 
 
-/*
- * 'cupsFreeDests()' - Free the memory used by the list of destinations.
- */
+//
+// 'cupsFreeDests()' - Free the memory used by the list of destinations.
+//
 
 void
-cupsFreeDests(int         num_dests,   /* I - Number of destinations */
-              cups_dest_t *dests)      /* I - Destinations */
+cupsFreeDests(int         num_dests,   // I - Number of destinations
+              cups_dest_t *dests)      // I - Destinations
 {
-  int          i;                      /* Looping var */
-  cups_dest_t  *dest;                  /* Current destination */
+  int          i;                      // Looping var
+  cups_dest_t  *dest;                  // Current destination
 
 
   if (num_dests == 0 || dests == NULL)
@@ -1045,21 +951,21 @@ cupsFreeDests(int         num_dests,     /* I - Number of destinations */
 }
 
 
-/*
- * 'cupsGetDest()' - Get the named destination from the list.
- *
- * Use the @link cupsEnumDests@ or @link cupsGetDests2@ functions to get a
- * list of supported destinations for the current user.
- */
+//
+// 'cupsGetDest()' - Get the named destination from the list.
+//
+// Use the @link cupsEnumDests@ or @link cupsGetDests2@ functions to get a
+// list of supported destinations for the current user.
+//
 
-cups_dest_t *                          /* O - Destination pointer or @code NULL@ */
-cupsGetDest(const char  *name,         /* I - Destination name or @code NULL@ for the default destination */
-            const char *instance,      /* I - Instance name or @code NULL@ */
-            int         num_dests,     /* I - Number of destinations */
-            cups_dest_t *dests)                /* I - Destinations */
+cups_dest_t *                          // O - Destination pointer or @code NULL@
+cupsGetDest(const char  *name,         // I - Destination name or @code NULL@ for the default destination
+            const char *instance,      // I - Instance name or @code NULL@
+            int         num_dests,     // I - Number of destinations
+            cups_dest_t *dests)                // I - Destinations
 {
-  int  diff,                           /* Result of comparison */
-       match;                          /* Matching index */
+  int  diff,                           // Result of comparison
+       match;                          // Matching index
 
 
   if (num_dests <= 0 || !dests)
@@ -1096,31 +1002,31 @@ cupsGetDest(const char  *name,          /* I - Destination name or @code NULL@ for the d
 }
 
 
-/*
- * '_cupsGetDestResource()' - Get the resource path and URI for a destination.
- */
+//
+// '_cupsGetDestResource()' - Get the resource path and URI for a destination.
+//
 
-const char *                           /* O - URI */
+const char *                           // O - URI
 _cupsGetDestResource(
-    cups_dest_t *dest,                 /* I - Destination */
-    unsigned    flags,                 /* I - Destination flags */
-    char        *resource,             /* I - Resource buffer */
-    size_t      resourcesize)          /* I - Size of resource buffer */
+    cups_dest_t *dest,                 // I - Destination
+    unsigned    flags,                 // I - Destination flags
+    char        *resource,             // I - Resource buffer
+    size_t      resourcesize)          // I - Size of resource buffer
 {
-  const char   *uri,                   /* URI */
-               *device_uri,            /* Device URI */
-               *printer_uri;           /* Printer URI */
-  char         scheme[32],             /* URI scheme */
-               userpass[256],          /* Username and password (unused) */
-               hostname[256];          /* Hostname */
-  int          port;                   /* Port number */
+  const char   *uri,                   // URI
+               *device_uri,            // Device URI
+               *printer_uri;           // Printer URI
+  char         scheme[32],             // URI scheme
+               userpass[256],          // Username and password (unused)
+               hostname[256];          // Hostname
+  int          port;                   // Port number
 
 
   DEBUG_printf("_cupsGetDestResource(dest=%p(%s), flags=%u, resource=%p, resourcesize=%d)", (void *)dest, dest->name, flags, (void *)resource, (int)resourcesize);
 
- /*
-  * Range check input...
-  */
+  //
+  // Range check input...
+  //
 
   if (!dest || !resource || resourcesize < 1)
   {
@@ -1131,19 +1037,18 @@ _cupsGetDestResource(
     return (NULL);
   }
 
- /*
-  * Grab the printer and device URIs...
-  */
+  //
+  // Grab the printer and device URIs...
+  //
 
   device_uri  = cupsGetOption("device-uri", dest->num_options, dest->options);
   printer_uri = cupsGetOption("printer-uri-supported", dest->num_options, dest->options);
 
   DEBUG_printf("1_cupsGetDestResource: device-uri=\"%s\", printer-uri-supported=\"%s\".", device_uri, printer_uri);
 
-#ifdef HAVE_DNSSD
   if (((flags & CUPS_DEST_FLAGS_DEVICE) || !printer_uri) && device_uri && strstr(device_uri, "._tcp"))
   {
-    if ((device_uri = cups_dnssd_resolve(dest, device_uri, 5000, NULL, NULL, NULL)) != NULL)
+    if ((device_uri = cups_dest_resolve(dest, device_uri, 5000, NULL, NULL, NULL)) != NULL)
     {
       DEBUG_printf("1_cupsGetDestResource: Resolved device-uri=\"%s\".", device_uri);
     }
@@ -1159,7 +1064,6 @@ _cupsGetDestResource(
       return (NULL);
     }
   }
-#endif /* HAVE_DNSSD */
 
   if (flags & CUPS_DEST_FLAGS_DEVICE)
   {
@@ -1207,35 +1111,35 @@ _cupsGetDestResource(
 }
 
 
-/*
- * 'cupsGetDestWithURI()' - Get a destination associated with a URI.
- *
- * "name" is the desired name for the printer. If @code NULL@, a name will be
- * created using the URI.
- *
- * "uri" is the "ipp" or "ipps" URI for the printer.
- *
- * @since CUPS 2.0/macOS 10.10@
- */
-
-cups_dest_t *                          /* O - Destination or @code NULL@ */
-cupsGetDestWithURI(const char *name,   /* I - Desired printer name or @code NULL@ */
-                   const char *uri)    /* I - URI for the printer */
+//
+// 'cupsGetDestWithURI()' - Get a destination associated with a URI.
+//
+// "name" is the desired name for the printer. If @code NULL@, a name will be
+// created using the URI.
+//
+// "uri" is the "ipp" or "ipps" URI for the printer.
+//
+// @since CUPS 2.0/macOS 10.10@
+//
+
+cups_dest_t *                          // O - Destination or @code NULL@
+cupsGetDestWithURI(const char *name,   // I - Desired printer name or @code NULL@
+                   const char *uri)    // I - URI for the printer
 {
-  cups_dest_t  *dest;                  /* New destination */
-  char         temp[1024],             /* Temporary string */
-               scheme[256],            /* Scheme from URI */
-               userpass[256],          /* Username:password from URI */
-               hostname[256],          /* Hostname from URI */
-               resource[1024],         /* Resource path from URI */
-               *ptr;                   /* Pointer into string */
-  const char   *info;                  /* printer-info string */
-  int          port;                   /* Port number from URI */
+  cups_dest_t  *dest;                  // New destination
+  char         temp[1024],             // Temporary string
+               scheme[256],            // Scheme from URI
+               userpass[256],          // Username:password from URI
+               hostname[256],          // Hostname from URI
+               resource[1024],         // Resource path from URI
+               *ptr;                   // Pointer into string
+  const char   *info;                  // printer-info string
+  int          port;                   // Port number from URI
 
 
- /*
-  * Range check input...
-  */
+  //
+  // Range check input...
+  //
 
   if (!uri)
   {
@@ -1299,9 +1203,9 @@ cupsGetDestWithURI(const char *name,      /* I - Desired printer name or @code NULL@
     }
   }
 
- /*
-  * Create the destination...
-  */
+  //
+  // Create the destination...
+  //
 
   if ((dest = calloc(1, sizeof(cups_dest_t))) == NULL)
   {
@@ -1317,54 +1221,54 @@ cupsGetDestWithURI(const char *name,    /* I - Desired printer name or @code NULL@
 }
 
 
-/*
- * '_cupsGetDests()' - Get destinations from a server.
- *
- * "op" is IPP_OP_CUPS_GET_PRINTERS to get a full list, IPP_OP_CUPS_GET_DEFAULT
- * to get the system-wide default printer, or IPP_OP_GET_PRINTER_ATTRIBUTES for
- * a known printer.
- *
- * "name" is the name of an existing printer and is only used when "op" is
- * IPP_OP_GET_PRINTER_ATTRIBUTES.
- *
- * "dest" is initialized to point to the array of destinations.
- *
- * 0 is returned if there are no printers, no default printer, or the named
- * printer does not exist, respectively.
- *
- * Free the memory used by the destination array using the @link cupsFreeDests@
- * function.
- *
- * Note: On macOS this function also gets the default paper from the system
- * preferences (~/L/P/org.cups.PrintingPrefs.plist) and includes it in the
- * options array for each destination that supports it.
- */
-
-int                                    /* O  - Number of destinations */
+//
+// '_cupsGetDests()' - Get destinations from a server.
+//
+// "op" is IPP_OP_CUPS_GET_PRINTERS to get a full list, IPP_OP_CUPS_GET_DEFAULT
+// to get the system-wide default printer, or IPP_OP_GET_PRINTER_ATTRIBUTES for
+// a known printer.
+//
+// "name" is the name of an existing printer and is only used when "op" is
+// IPP_OP_GET_PRINTER_ATTRIBUTES.
+//
+// "dest" is initialized to point to the array of destinations.
+//
+// 0 is returned if there are no printers, no default printer, or the named
+// printer does not exist, respectively.
+//
+// Free the memory used by the destination array using the @link cupsFreeDests@
+// function.
+//
+// Note: On macOS this function also gets the default paper from the system
+// preferences (~/L/P/org.cups.PrintingPrefs.plist) and includes it in the
+// options array for each destination that supports it.
+//
+
+int                                    // O  - Number of destinations
 _cupsGetDests(http_t       *http,      /* I  - Connection to server or
                                         *      @code CUPS_HTTP_DEFAULT@ */
-             ipp_op_t     op,          /* I  - IPP operation */
-             const char   *name,       /* I  - Name of destination */
-             cups_dest_t  **dests,     /* IO - Destinations */
-             cups_ptype_t type,        /* I  - Printer type bits */
-             cups_ptype_t mask)        /* I  - Printer type mask */
+             ipp_op_t     op,          // I  - IPP operation
+             const char   *name,       // I  - Name of destination
+             cups_dest_t  **dests,     // IO - Destinations
+             cups_ptype_t type,        // I  - Printer type bits
+             cups_ptype_t mask)        // I  - Printer type mask
 {
-  int          num_dests = 0;          /* Number of destinations */
-  cups_dest_t  *dest;                  /* Current destination */
-  ipp_t                *request,               /* IPP Request */
-               *response;              /* IPP Response */
-  ipp_attribute_t *attr;               /* Current attribute */
-  const char   *printer_name;          /* printer-name attribute */
-  char         uri[1024];              /* printer-uri value */
-  int          num_options;            /* Number of options */
-  cups_option_t        *options;               /* Options */
+  int          num_dests = 0;          // Number of destinations
+  cups_dest_t  *dest;                  // Current destination
+  ipp_t                *request,               // IPP Request
+               *response;              // IPP Response
+  ipp_attribute_t *attr;               // Current attribute
+  const char   *printer_name;          // printer-name attribute
+  char         uri[1024];              // printer-uri value
+  int          num_options;            // Number of options
+  cups_option_t        *options;               // Options
 #ifdef __APPLE__
-  char         media_default[41];      /* Default paper size */
-#endif /* __APPLE__ */
-  char         optname[1024],          /* Option name */
-               value[2048],            /* Option value */
-               *ptr;                   /* Pointer into name/value */
-  static const char * const pattrs[] = /* Attributes we're interested in */
+  char         media_default[41];      // Default paper size
+#endif // __APPLE__
+  char         optname[1024],          // Option name
+               value[2048],            // Option value
+               *ptr;                   // Pointer into name/value
+  static const char * const pattrs[] = // Attributes we're interested in
                {
                  "auth-info-required",
                  "device-uri",
@@ -1379,7 +1283,7 @@ _cupsGetDests(http_t       *http, /* I  - Connection to server or
                  "marker-types",
 #ifdef __APPLE__
                  "media-supported",
-#endif /* __APPLE__ */
+#endif // __APPLE__
                  "printer-commands",
                  "printer-defaults",
                  "printer-info",
@@ -1401,23 +1305,23 @@ _cupsGetDests(http_t       *http,       /* I  - Connection to server or
   DEBUG_printf("_cupsGetDests(http=%p, op=%x(%s), name=\"%s\", dests=%p, type=%x, mask=%x)", (void *)http, op, ippOpString(op), name, (void *)dests, type, mask);
 
 #ifdef __APPLE__
- /*
-  * Get the default paper size...
-  */
+  //
+  // Get the default paper size...
+  //
 
   appleGetPaperSize(media_default, sizeof(media_default));
   DEBUG_printf("1_cupsGetDests: Default media is '%s'.", media_default);
-#endif /* __APPLE__ */
-
- /*
-  * Build a IPP_OP_CUPS_GET_PRINTERS or IPP_OP_GET_PRINTER_ATTRIBUTES request, which
-  * require the following attributes:
-  *
-  *    attributes-charset
-  *    attributes-natural-language
-  *    requesting-user-name
-  *    printer-uri [for IPP_OP_GET_PRINTER_ATTRIBUTES]
-  */
+#endif // __APPLE__
+
+  //
+  // Build a IPP_OP_CUPS_GET_PRINTERS or IPP_OP_GET_PRINTER_ATTRIBUTES request, which
+  // require the following attributes:
+  //
+  //    attributes-charset
+  //    attributes-natural-language
+  //    requesting-user-name
+  //    printer-uri [for IPP_OP_GET_PRINTER_ATTRIBUTES]
+  //
 
   request = ippNewRequest(op);
 
@@ -1441,9 +1345,9 @@ _cupsGetDests(http_t       *http, /* I  - Connection to server or
     ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_ENUM, "printer-type-mask", (int)mask);
   }
 
- /*
-  * Do the request and get back a response...
-  */
+  //
+  // Do the request and get back a response...
+  //
 
   if ((response = cupsDoRequest(http, request, "/")) != NULL)
   {
@@ -1521,7 +1425,7 @@ _cupsGetDests(http_t       *http, /* I  - Connection to server or
          * See if we can set a default media size...
          */
 
-          int  i;                      /* Looping var */
+          int  i;                      // Looping var
 
          for (i = 0; i < attr->num_values; i ++)
            if (!_cups_strcasecmp(media_default, attr->values[i].string.text))
@@ -1531,7 +1435,7 @@ _cupsGetDests(http_t       *http, /* I  - Connection to server or
               break;
            }
        }
-#endif /* __APPLE__ */
+#endif // __APPLE__
         else if (!strcmp(attr->name, "printer-name") &&
                 attr->value_tag == IPP_TAG_NAME)
          printer_name = attr->values[0].string.text;
@@ -1586,79 +1490,79 @@ _cupsGetDests(http_t       *http,       /* I  - Connection to server or
     ippDelete(response);
   }
 
- /*
-  * Return the count...
-  */
+  //
+  // Return the count...
+  //
 
   return (num_dests);
 }
 
 
-/*
- * 'cupsGetDests()' - Get the list of destinations from the default server.
- *
- * Starting with CUPS 1.2, the returned list of destinations include the
- * "printer-info", "printer-is-accepting-jobs", "printer-is-shared",
- * "printer-make-and-model", "printer-state", "printer-state-change-time",
- * "printer-state-reasons", "printer-type", and "printer-uri-supported"
- * attributes as options.
- *
- * CUPS 1.4 adds the "marker-change-time", "marker-colors",
- * "marker-high-levels", "marker-levels", "marker-low-levels", "marker-message",
- * "marker-names", "marker-types", and "printer-commands" attributes as options.
- *
- * CUPS 2.2 adds accessible IPP printers to the list of destinations that can
- * be used.  The "printer-uri-supported" option will be present for those IPP
- * printers that have been recently used.
- *
- * Use the @link cupsFreeDests@ function to free the destination list and
- * the @link cupsGetDest@ function to find a particular destination.
- *
- * @exclude all@
- */
-
-int                                    /* O - Number of destinations */
-cupsGetDests(cups_dest_t **dests)      /* O - Destinations */
+//
+// 'cupsGetDests()' - Get the list of destinations from the default server.
+//
+// Starting with CUPS 1.2, the returned list of destinations include the
+// "printer-info", "printer-is-accepting-jobs", "printer-is-shared",
+// "printer-make-and-model", "printer-state", "printer-state-change-time",
+// "printer-state-reasons", "printer-type", and "printer-uri-supported"
+// attributes as options.
+//
+// CUPS 1.4 adds the "marker-change-time", "marker-colors",
+// "marker-high-levels", "marker-levels", "marker-low-levels", "marker-message",
+// "marker-names", "marker-types", and "printer-commands" attributes as options.
+//
+// CUPS 2.2 adds accessible IPP printers to the list of destinations that can
+// be used.  The "printer-uri-supported" option will be present for those IPP
+// printers that have been recently used.
+//
+// Use the @link cupsFreeDests@ function to free the destination list and
+// the @link cupsGetDest@ function to find a particular destination.
+//
+// @exclude all@
+//
+
+int                                    // O - Number of destinations
+cupsGetDests(cups_dest_t **dests)      // O - Destinations
 {
   return (cupsGetDests2(CUPS_HTTP_DEFAULT, dests));
 }
 
 
-/*
- * 'cupsGetDests2()' - Get the list of destinations from the specified server.
- *
- * Starting with CUPS 1.2, the returned list of destinations include the
- * "printer-info", "printer-is-accepting-jobs", "printer-is-shared",
- * "printer-make-and-model", "printer-state", "printer-state-change-time",
- * "printer-state-reasons", "printer-type", and "printer-uri-supported"
- * attributes as options.
- *
- * CUPS 1.4 adds the "marker-change-time", "marker-colors",
- * "marker-high-levels", "marker-levels", "marker-low-levels", "marker-message",
- * "marker-names", "marker-types", and "printer-commands" attributes as options.
- *
- * CUPS 2.2 adds accessible IPP printers to the list of destinations that can
- * be used.  The "printer-uri-supported" option will be present for those IPP
- * printers that have been recently used.
- *
- * Use the @link cupsFreeDests@ function to free the destination list and
- * the @link cupsGetDest@ function to find a particular destination.
- *
- * @since CUPS 1.1.21/macOS 10.4@
- */
-
-int                                    /* O - Number of destinations */
-cupsGetDests2(http_t      *http,       /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
-              cups_dest_t **dests)     /* O - Destinations */
+//
+// 'cupsGetDests2()' - Get the list of destinations from the specified server.
+//
+// Starting with CUPS 1.2, the returned list of destinations include the
+// "printer-info", "printer-is-accepting-jobs", "printer-is-shared",
+// "printer-make-and-model", "printer-state", "printer-state-change-time",
+// "printer-state-reasons", "printer-type", and "printer-uri-supported"
+// attributes as options.
+//
+// CUPS 1.4 adds the "marker-change-time", "marker-colors",
+// "marker-high-levels", "marker-levels", "marker-low-levels", "marker-message",
+// "marker-names", "marker-types", and "printer-commands" attributes as options.
+//
+// CUPS 2.2 adds accessible IPP printers to the list of destinations that can
+// be used.  The "printer-uri-supported" option will be present for those IPP
+// printers that have been recently used.
+//
+// Use the @link cupsFreeDests@ function to free the destination list and
+// the @link cupsGetDest@ function to find a particular destination.
+//
+// @since CUPS 1.1.21/macOS 10.4@
+//
+
+int                                    // O - Number of destinations
+cupsGetDests2(http_t      *http,       // I - Connection to server or @code CUPS_HTTP_DEFAULT@
+              cups_dest_t **dests)     // O - Destinations
 {
-  _cups_getdata_t data;                 /* Enumeration data */
+  _cups_getdata_t data;                 // Enumeration data
 
 
   DEBUG_printf("cupsGetDests2(http=%p, dests=%p)", (void *)http, (void *)dests);
 
-/*
-  * Range check the input...
-  */
+//
+  // Range check the input...
+  //
 
   if (!dests)
   {
@@ -1667,9 +1571,9 @@ cupsGetDests2(http_t      *http,  /* I - Connection to server or @code CUPS_HTTP_
     return (0);
   }
 
- /*
-  * Connect to the server as needed...
-  */
+  //
+  // Connect to the server as needed...
+  //
 
   if (!http)
   {
@@ -1681,9 +1585,9 @@ cupsGetDests2(http_t      *http,  /* I - Connection to server or @code CUPS_HTTP_
     }
   }
 
- /*
-  * Grab the printers and classes...
-  */
+  //
+  // Grab the printers and classes...
+  //
 
   data.num_dests = 0;
   data.dests     = NULL;
@@ -1707,9 +1611,9 @@ cupsGetDests2(http_t      *http,  /* I - Connection to server or @code CUPS_HTTP_
     cups_enum_dests(http, 0, _CUPS_DNSSD_GET_DESTS, NULL, 0, 0, (cups_dest_cb_t)cups_get_cb, &data);
   }
 
- /*
-  * Return the number of destinations...
-  */
+  //
+  // Return the number of destinations...
+  //
 
   *dests = data.dests;
 
@@ -1722,47 +1626,47 @@ cupsGetDests2(http_t      *http,        /* I - Connection to server or @code CUPS_HTTP_
 }
 
 
-/*
- * 'cupsGetNamedDest()' - Get options for the named destination.
- *
- * This function is optimized for retrieving a single destination and should
- * be used instead of @link cupsGetDests2@ and @link cupsGetDest@ when you
- * either know the name of the destination or want to print to the default
- * destination.  If @code NULL@ is returned, the destination does not exist or
- * there is no default destination.
- *
- * If "http" is @code CUPS_HTTP_DEFAULT@, the connection to the default print
- * server will be used.
- *
- * If "name" is @code NULL@, the default printer for the current user will be
- * returned.
- *
- * The returned destination must be freed using @link cupsFreeDests@ with a
- * "num_dests" value of 1.
- *
- * @since CUPS 1.4/macOS 10.6@
- */
-
-cups_dest_t *                          /* O - Destination or @code NULL@ */
-cupsGetNamedDest(http_t     *http,     /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
-                 const char *name,     /* I - Destination name or @code NULL@ for the default destination */
-                 const char *instance) /* I - Instance name or @code NULL@ */
+//
+// 'cupsGetNamedDest()' - Get options for the named destination.
+//
+// This function is optimized for retrieving a single destination and should
+// be used instead of @link cupsGetDests2@ and @link cupsGetDest@ when you
+// either know the name of the destination or want to print to the default
+// destination.  If @code NULL@ is returned, the destination does not exist or
+// there is no default destination.
+//
+// If "http" is @code CUPS_HTTP_DEFAULT@, the connection to the default print
+// server will be used.
+//
+// If "name" is @code NULL@, the default printer for the current user will be
+// returned.
+//
+// The returned destination must be freed using @link cupsFreeDests@ with a
+// "num_dests" value of 1.
+//
+// @since CUPS 1.4/macOS 10.6@
+//
+
+cups_dest_t *                          // O - Destination or @code NULL@
+cupsGetNamedDest(http_t     *http,     // I - Connection to server or @code CUPS_HTTP_DEFAULT@
+                 const char *name,     // I - Destination name or @code NULL@ for the default destination
+                 const char *instance) // I - Instance name or @code NULL@
 {
-  const char    *dest_name;             /* Working destination name */
-  cups_dest_t  *dest;                  /* Destination */
-  char         filename[1024],         /* Path to lpoptions */
-               defname[256];           /* Default printer name */
-  int          set_as_default = 0;     /* Set returned destination as default */
+  const char    *dest_name;             // Working destination name
+  cups_dest_t  *dest;                  // Destination
+  char         filename[1024],         // Path to lpoptions
+               defname[256];           // Default printer name
+  int          set_as_default = 0;     // Set returned destination as default
   ipp_op_t     op = IPP_OP_GET_PRINTER_ATTRIBUTES;
-                                       /* IPP operation to get server ops */
-  _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
+                                       // IPP operation to get server ops
+  _cups_globals_t *cg = _cupsGlobals();        // Pointer to library globals
 
 
   DEBUG_printf("cupsGetNamedDest(http=%p, name=\"%s\", instance=\"%s\")", (void *)http, name, instance);
 
- /*
-  * If "name" is NULL, find the default destination...
-  */
+  //
+  // If "name" is NULL, find the default destination...
+  //
 
   dest_name = name;
 
@@ -1773,7 +1677,7 @@ cupsGetNamedDest(http_t     *http,        /* I - Connection to server or @code CUPS_HTT
 
     if (dest_name)
     {
-      char     *ptr;                   /* Temporary pointer... */
+      char     *ptr;                   // Temporary pointer...
 
       if ((ptr = strchr(defname, '/')) != NULL)
       {
@@ -1829,13 +1733,13 @@ cupsGetNamedDest(http_t     *http,      /* I - Connection to server or @code CUPS_HTT
       DEBUG_printf("1cupsGetNamedDest: Using name=\"%s\"...", name);
   }
 
- /*
-  * Get the printer's attributes...
-  */
+  //
+  // Get the printer's attributes...
+  //
 
   if (!_cupsGetDests(http, op, dest_name, &dest, 0, 0))
   {
-    _cups_namedata_t  data;           /* Callback data */
+    _cups_namedata_t  data;           // Callback data
 
     data.name = dest_name;
     data.dest = NULL;
@@ -1855,7 +1759,7 @@ cupsGetNamedDest(http_t     *http,        /* I - Connection to server or @code CUPS_HTT
            _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("The printer or class does not exist."), 1);
            break;
 
-       case 1 : /* Set from env vars */
+       case 1 : // Set from env vars
            if (getenv("LPDEST"))
              _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("LPDEST environment variable names default destination that does not exist."), 1);
            else if (getenv("PRINTER"))
@@ -1864,15 +1768,15 @@ cupsGetNamedDest(http_t     *http,      /* I - Connection to server or @code CUPS_HTT
              _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("No default destination."), 1);
            break;
 
-       case 2 : /* Set from ~/.cups/lpoptions */
+       case 2 : // Set from ~/.cups/lpoptions
            _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("~/.cups/lpoptions file names default destination that does not exist."), 1);
            break;
 
-       case 3 : /* Set from /etc/cups/lpoptions */
+       case 3 : // Set from /etc/cups/lpoptions
            _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("/etc/cups/lpoptions file names default destination that does not exist."), 1);
            break;
 
-       case 4 : /* Set from server */
+       case 4 : // Set from server
            _cupsSetError(IPP_STATUS_ERROR_NOT_FOUND, _("No default destination."), 1);
            break;
       }
@@ -1891,9 +1795,9 @@ cupsGetNamedDest(http_t     *http,        /* I - Connection to server or @code CUPS_HTT
   if (set_as_default)
     dest->is_default = 1;
 
- /*
-  * Then add local options...
-  */
+  //
+  // Then add local options...
+  //
 
   snprintf(filename, sizeof(filename), "%s/lpoptions", cg->cups_serverroot);
   cups_get_dests(filename, dest_name, instance, 0, 1, 1, &dest);
@@ -1909,53 +1813,53 @@ cupsGetNamedDest(http_t     *http,      /* I - Connection to server or @code CUPS_HTT
     cups_get_dests(filename, dest_name, instance, 0, 1, 1, &dest);
   }
 
- /*
-  * Return the result...
-  */
+  //
+  // Return the result...
+  //
 
   return (dest);
 }
 
 
-/*
- * 'cupsRemoveDest()' - Remove a destination from the destination list.
- *
- * Removing a destination/instance does not delete the class or printer
- * queue, merely the lpoptions for that destination/instance.  Use the
- * @link cupsSetDests@ or @link cupsSetDests2@ functions to save the new
- * options for the user.
- *
- * @since CUPS 1.3/macOS 10.5@
- */
-
-int                                    /* O  - New number of destinations */
-cupsRemoveDest(const char  *name,      /* I  - Destination name */
-               const char  *instance,  /* I  - Instance name or @code NULL@ */
-              int         num_dests,   /* I  - Number of destinations */
-              cups_dest_t **dests)     /* IO - Destinations */
+//
+// 'cupsRemoveDest()' - Remove a destination from the destination list.
+//
+// Removing a destination/instance does not delete the class or printer
+// queue, merely the lpoptions for that destination/instance.  Use the
+// @link cupsSetDests@ or @link cupsSetDests2@ functions to save the new
+// options for the user.
+//
+// @since CUPS 1.3/macOS 10.5@
+//
+
+int                                    // O  - New number of destinations
+cupsRemoveDest(const char  *name,      // I  - Destination name
+               const char  *instance,  // I  - Instance name or @code NULL@
+              int         num_dests,   // I  - Number of destinations
+              cups_dest_t **dests)     // IO - Destinations
 {
-  int          i;                      /* Index into destinations */
-  cups_dest_t  *dest;                  /* Pointer to destination */
+  int          i;                      // Index into destinations
+  cups_dest_t  *dest;                  // Pointer to destination
 
 
- /*
-  * Find the destination...
-  */
+  //
+  // Find the destination...
+  //
 
   if ((dest = cupsGetDest(name, instance, num_dests, *dests)) == NULL)
     return (num_dests);
 
- /*
-  * Free memory...
-  */
+  //
+  // Free memory...
+  //
 
   _cupsStrFree(dest->name);
   _cupsStrFree(dest->instance);
   cupsFreeOptions(dest->num_options, dest->options);
 
- /*
-  * Remove the destination from the array...
-  */
+  //
+  // Remove the destination from the array...
+  //
 
   num_dests --;
 
@@ -1968,34 +1872,34 @@ cupsRemoveDest(const char  *name,       /* I  - Destination name */
 }
 
 
-/*
- * 'cupsSetDefaultDest()' - Set the default destination.
- *
- * @since CUPS 1.3/macOS 10.5@
- */
+//
+// 'cupsSetDefaultDest()' - Set the default destination.
+//
+// @since CUPS 1.3/macOS 10.5@
+//
 
 void
 cupsSetDefaultDest(
-    const char  *name,                 /* I - Destination name */
-    const char  *instance,             /* I - Instance name or @code NULL@ */
-    int         num_dests,             /* I - Number of destinations */
-    cups_dest_t *dests)                        /* I - Destinations */
+    const char  *name,                 // I - Destination name
+    const char  *instance,             // I - Instance name or @code NULL@
+    int         num_dests,             // I - Number of destinations
+    cups_dest_t *dests)                        // I - Destinations
 {
-  int          i;                      /* Looping var */
-  cups_dest_t  *dest;                  /* Current destination */
+  int          i;                      // Looping var
+  cups_dest_t  *dest;                  // Current destination
 
 
- /*
-  * Range check input...
-  */
+  //
+  // Range check input...
+  //
 
   if (!name || num_dests <= 0 || !dests)
     return;
 
- /*
-  * Loop through the array and set the "is_default" flag for the matching
-  * destination...
-  */
+  //
+  // Loop through the array and set the "is_default" flag for the matching
+  // destination...
+  //
 
   for (i = num_dests, dest = dests; i > 0; i --, dest ++)
     dest->is_default = !_cups_strcasecmp(name, dest->name) &&
@@ -2005,61 +1909,61 @@ cupsSetDefaultDest(
 }
 
 
-/*
- * 'cupsSetDests()' - Save the list of destinations for the default server.
- *
- * This function saves the destinations to /etc/cups/lpoptions when run
- * as root and ~/.cups/lpoptions when run as a normal user.
- *
- * @exclude all@
- */
+//
+// 'cupsSetDests()' - Save the list of destinations for the default server.
+//
+// This function saves the destinations to /etc/cups/lpoptions when run
+// as root and ~/.cups/lpoptions when run as a normal user.
+//
+// @exclude all@
+//
 
 void
-cupsSetDests(int         num_dests,    /* I - Number of destinations */
-             cups_dest_t *dests)       /* I - Destinations */
+cupsSetDests(int         num_dests,    // I - Number of destinations
+             cups_dest_t *dests)       // I - Destinations
 {
   cupsSetDests2(CUPS_HTTP_DEFAULT, num_dests, dests);
 }
 
 
-/*
- * 'cupsSetDests2()' - Save the list of destinations for the specified server.
- *
- * This function saves the destinations to /etc/cups/lpoptions when run
- * as root and ~/.cups/lpoptions when run as a normal user.
- *
- * @since CUPS 1.1.21/macOS 10.4@
- */
+//
+// 'cupsSetDests2()' - Save the list of destinations for the specified server.
+//
+// This function saves the destinations to /etc/cups/lpoptions when run
+// as root and ~/.cups/lpoptions when run as a normal user.
+//
+// @since CUPS 1.1.21/macOS 10.4@
+//
 
-int                                    /* O - 0 on success, -1 on error */
-cupsSetDests2(http_t      *http,       /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */
-              int         num_dests,   /* I - Number of destinations */
-              cups_dest_t *dests)      /* I - Destinations */
+int                                    // O - 0 on success, -1 on error
+cupsSetDests2(http_t      *http,       // I - Connection to server or @code CUPS_HTTP_DEFAULT@
+              int         num_dests,   // I - Number of destinations
+              cups_dest_t *dests)      // I - Destinations
 {
-  int          i, j;                   /* Looping vars */
-  int          wrote;                  /* Wrote definition? */
-  cups_dest_t  *dest;                  /* Current destination */
-  cups_option_t        *option;                /* Current option */
-  _ipp_option_t        *match;                 /* Matching attribute for option */
-  FILE         *fp;                    /* File pointer */
-  char         filename[1024];         /* lpoptions file */
-  int          num_temps;              /* Number of temporary destinations */
-  cups_dest_t  *temps = NULL,          /* Temporary destinations */
-               *temp;                  /* Current temporary dest */
-  const char   *val;                   /* Value of temporary option */
-  _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
-
-
- /*
-  * Range check the input...
-  */
+  int          i, j;                   // Looping vars
+  int          wrote;                  // Wrote definition?
+  cups_dest_t  *dest;                  // Current destination
+  cups_option_t        *option;                // Current option
+  _ipp_option_t        *match;                 // Matching attribute for option
+  FILE         *fp;                    // File pointer
+  char         filename[1024];         // lpoptions file
+  int          num_temps;              // Number of temporary destinations
+  cups_dest_t  *temps = NULL,          // Temporary destinations
+               *temp;                  // Current temporary dest
+  const char   *val;                   // Value of temporary option
+  _cups_globals_t *cg = _cupsGlobals();        // Pointer to library globals
+
+
+  //
+  // Range check the input...
+  //
 
   if (!num_dests || !dests)
     return (-1);
 
- /*
-  * Get the server destinations...
-  */
+  //
+  // Get the server destinations...
+  //
 
   num_temps = _cupsGetDests(http, IPP_OP_CUPS_GET_PRINTERS, NULL, &temps, 0, 0);
 
@@ -2069,16 +1973,16 @@ cupsSetDests2(http_t      *http,        /* I - Connection to server or @code CUPS_HTTP_
     return (-1);
   }
 
- /*
-  * Figure out which file to write to...
-  */
+  //
+  // Figure out which file to write to...
+  //
 
   snprintf(filename, sizeof(filename), "%s/lpoptions", cg->cups_serverroot);
 
   if (cg->home
 #ifndef _WIN32
       && getuid() != 0
-#endif /* !_WIN32 */
+#endif // !_WIN32
       )
   {
    /*
@@ -2100,9 +2004,9 @@ cupsSetDests2(http_t      *http,  /* I - Connection to server or @code CUPS_HTTP_
 #endif // _WIN32
   }
 
- /*
-  * Try to open the file...
-  */
+  //
+  // Try to open the file...
+  //
 
   if ((fp = fopen(filename, "w")) == NULL)
   {
@@ -2111,21 +2015,21 @@ cupsSetDests2(http_t      *http,        /* I - Connection to server or @code CUPS_HTTP_
   }
 
 #ifndef _WIN32
- /*
-  * Set the permissions to 0644 when saving to the /etc/cups/lpoptions
-  * file...
-  */
+  //
+  // Set the permissions to 0644 when saving to the /etc/cups/lpoptions
+  // file...
+  //
 
   if (!getuid())
     fchmod(fileno(fp), 0644);
-#endif /* !_WIN32 */
+#endif // !_WIN32
 
- /*
-  * Write each printer; each line looks like:
-  *
-  *    Dest name[/instance] options
-  *    Default name[/instance] options
-  */
+  //
+  // Write each printer; each line looks like:
+  //
+  //    Dest name[/instance] options
+  //    Default name[/instance] options
+  //
 
   for (i = num_dests, dest = dests; i > 0; i --, dest ++)
     if (dest->instance != NULL || dest->num_options != 0 || dest->is_default)
@@ -2208,24 +2112,24 @@ cupsSetDests2(http_t      *http,        /* I - Connection to server or @code CUPS_HTTP_
         fputs("\n", fp);
     }
 
- /*
-  * Free the temporary destinations and close the file...
-  */
+  //
+  // Free the temporary destinations and close the file...
+  //
 
   cupsFreeDests(num_temps, temps);
 
   fclose(fp);
 
 #ifdef __APPLE__
- /*
-  * Set the default printer for this location - this allows command-line
-  * and GUI applications to share the same default destination...
-  */
+  //
+  // Set the default printer for this location - this allows command-line
+  // and GUI applications to share the same default destination...
+  //
 
   if ((dest = cupsGetDest(NULL, NULL, num_dests, dests)) != NULL)
   {
     CFStringRef name = CFStringCreateWithCString(kCFAllocatorDefault, dest->name, kCFStringEncodingUTF8);
-                                       /* Default printer name */
+                                       // Default printer name
 
     if (name)
     {
@@ -2233,34 +2137,34 @@ cupsSetDests2(http_t      *http,        /* I - Connection to server or @code CUPS_HTTP_
       CFRelease(name);
     }
   }
-#endif /* __APPLE__ */
+#endif // __APPLE__
 
 #ifdef HAVE_NOTIFY_POST
- /*
-  * Send a notification so that macOS applications can know about the
-  * change, too.
-  */
+  //
+  // Send a notification so that macOS applications can know about the
+  // change, too.
+  //
 
   notify_post("com.apple.printerListChange");
-#endif /* HAVE_NOTIFY_POST */
+#endif // HAVE_NOTIFY_POST
 
   return (0);
 }
 
 
-/*
- * '_cupsGetUserDefault()' - Get the user default printer from environment
- *                        variables and location information.
- */
+//
+// '_cupsGetUserDefault()' - Get the user default printer from environment
+//                        variables and location information.
+//
 
-char *                                 /* O - Default printer or NULL */
-_cupsGetUserDefault(char   *name,              /* I - Name buffer */
-                 size_t namesize)      /* I - Size of name buffer */
+char *                                 // O - Default printer or NULL
+_cupsGetUserDefault(char   *name,              // I - Name buffer
+                 size_t namesize)      // I - Size of name buffer
 {
-  const char   *env;                   /* LPDEST or PRINTER env variable */
+  const char   *env;                   // LPDEST or PRINTER env variable
 #ifdef __APPLE__
-  CFStringRef  locprinter;             /* Last printer as this location */
-#endif /* __APPLE__ */
+  CFStringRef  locprinter;             // Last printer as this location
+#endif // __APPLE__
 
 
   if ((env = getenv("LPDEST")) == NULL)
@@ -2274,10 +2178,10 @@ _cupsGetUserDefault(char   *name,               /* I - Name buffer */
   }
 
 #ifdef __APPLE__
- /*
-  * Use location-based defaults if "use last printer" is selected in the
-  * system preferences...
-  */
+  //
+  // Use location-based defaults if "use last printer" is selected in the
+  // system preferences...
+  //
 
   if (!getenv("CUPS_NO_APPLE_DEFAULT") && (locprinter = _cupsAppleCopyDefaultPrinter()) != NULL)
   {
@@ -2292,30 +2196,30 @@ _cupsGetUserDefault(char   *name,               /* I - Name buffer */
   return (*name ? name : NULL);
 
 #else
- /*
-  * No location-based defaults on this platform...
-  */
+  //
+  // No location-based defaults on this platform...
+  //
 
   name[0] = '\0';
   return (NULL);
-#endif /* __APPLE__ */
+#endif // __APPLE__
 }
 
 
 #if _CUPS_LOCATION_DEFAULTS
-/*
- * 'appleCopyLocations()' - Copy the location history array.
- */
+//
+// 'appleCopyLocations()' - Copy the location history array.
+//
 
-static CFArrayRef                      /* O - Location array or NULL */
+static CFArrayRef                      // O - Location array or NULL
 appleCopyLocations(void)
 {
-  CFArrayRef   locations;              /* Location array */
+  CFArrayRef   locations;              // Location array
 
 
- /*
-  * Look up the location array in the preferences...
-  */
+  //
+  // Look up the location array in the preferences...
+  //
 
   if ((locations = CFPreferencesCopyAppValue(kLastUsedPrintersKey,
                                              kCUPSPrintingPrefs)) == NULL)
@@ -2331,17 +2235,17 @@ appleCopyLocations(void)
 }
 
 
-/*
- * 'appleCopyNetwork()' - Get the network ID for the current location.
- */
+//
+// 'appleCopyNetwork()' - Get the network ID for the current location.
+//
 
-static CFStringRef                     /* O - Network ID */
+static CFStringRef                     // O - Network ID
 appleCopyNetwork(void)
 {
-  SCDynamicStoreRef    dynamicStore;   /* System configuration data */
-  CFStringRef          key;            /* Current network configuration key */
-  CFDictionaryRef      ip_dict;        /* Network configuration data */
-  CFStringRef          network = NULL; /* Current network ID */
+  SCDynamicStoreRef    dynamicStore;   // System configuration data
+  CFStringRef          key;            // Current network configuration key
+  CFDictionaryRef      ip_dict;        // Network configuration data
+  CFStringRef          network = NULL; // Current network ID
 
 
   if ((dynamicStore = SCDynamicStoreCreate(NULL, CFSTR("libcups"), NULL,
@@ -2395,20 +2299,20 @@ appleCopyNetwork(void)
 
   return (network);
 }
-#endif /* _CUPS_LOCATION_DEFAULTS */
+#endif // _CUPS_LOCATION_DEFAULTS
 
 
 #ifdef __APPLE__
-/*
- * 'appleGetPaperSize()' - Get the default paper size.
- */
+//
+// 'appleGetPaperSize()' - Get the default paper size.
+//
 
-static char *                          /* O - Default paper size */
-appleGetPaperSize(char   *name,                /* I - Paper size name buffer */
-                  size_t namesize)     /* I - Size of buffer */
+static char *                          // O - Default paper size
+appleGetPaperSize(char   *name,                // I - Paper size name buffer
+                  size_t namesize)     // I - Size of buffer
 {
-  CFStringRef  defaultPaperID;         /* Default paper ID */
-  pwg_media_t  *pwgmedia;              /* PWG media size */
+  CFStringRef  defaultPaperID;         // Default paper ID
+  pwg_media_t  *pwgmedia;              // PWG media size
 
 
   defaultPaperID = _cupsAppleCopyDefaultPaperID();
@@ -2424,24 +2328,24 @@ appleGetPaperSize(char   *name,         /* I - Paper size name buffer */
 
   return (name);
 }
-#endif /* __APPLE__ */
+#endif // __APPLE__
 
 
 #if _CUPS_LOCATION_DEFAULTS
-/*
- * 'appleGetPrinter()' - Get a printer from the history array.
- */
-
-static CFStringRef                     /* O - Printer name or NULL */
-appleGetPrinter(CFArrayRef  locations, /* I - Location array */
-                CFStringRef network,   /* I - Network name */
-               CFIndex     *locindex)  /* O - Index in array */
+//
+// 'appleGetPrinter()' - Get a printer from the history array.
+//
+
+static CFStringRef                     // O - Printer name or NULL
+appleGetPrinter(CFArrayRef  locations, // I - Location array
+                CFStringRef network,   // I - Network name
+               CFIndex     *locindex)  // O - Index in array
 {
-  CFIndex              i,              /* Looping var */
-                       count;          /* Number of locations */
-  CFDictionaryRef      location;       /* Current location */
-  CFStringRef          locnetwork,     /* Current network */
-                       locprinter;     /* Current printer */
+  CFIndex              i,              // Looping var
+                       count;          // Number of locations
+  CFDictionaryRef      location;       // Current location
+  CFStringRef          locnetwork,     // Current network
+                       locprinter;     // Current printer
 
 
   for (i = 0, count = CFArrayGetCount(locations); i < count; i ++)
@@ -2465,29 +2369,29 @@ appleGetPrinter(CFArrayRef  locations,  /* I - Location array */
 
   return (NULL);
 }
-#endif /* _CUPS_LOCATION_DEFAULTS */
+#endif // _CUPS_LOCATION_DEFAULTS
 
 
-/*
- * 'cups_add_dest()' - Add a destination to the array.
- *
- * Unlike cupsAddDest(), this function does not check for duplicates.
- */
+//
+// 'cups_add_dest()' - Add a destination to the array.
+//
+// Unlike cupsAddDest(), this function does not check for duplicates.
+//
 
-static cups_dest_t *                   /* O  - New destination */
-cups_add_dest(const char  *name,       /* I  - Name of destination */
-              const char  *instance,   /* I  - Instance or NULL */
-              int         *num_dests,  /* IO - Number of destinations */
-             cups_dest_t **dests)      /* IO - Destinations */
+static cups_dest_t *                   // O  - New destination
+cups_add_dest(const char  *name,       // I  - Name of destination
+              const char  *instance,   // I  - Instance or NULL
+              int         *num_dests,  // IO - Number of destinations
+             cups_dest_t **dests)      // IO - Destinations
 {
-  int          insert,                 /* Insertion point */
-               diff;                   /* Result of comparison */
-  cups_dest_t  *dest;                  /* Destination pointer */
+  int          insert,                 // Insertion point
+               diff;                   // Result of comparison
+  cups_dest_t  *dest;                  // Destination pointer
 
 
- /*
-  * Add new destination...
-  */
+  //
+  // Add new destination...
+  //
 
   if (*num_dests == 0)
     dest = malloc(sizeof(cups_dest_t));
@@ -2499,9 +2403,9 @@ cups_add_dest(const char  *name,  /* I  - Name of destination */
 
   *dests = dest;
 
- /*
-  * Find where to insert the destination...
-  */
+  //
+  // Find where to insert the destination...
+  //
 
   if (*num_dests == 0)
     insert = 0;
@@ -2514,18 +2418,18 @@ cups_add_dest(const char  *name,        /* I  - Name of destination */
       insert ++;
   }
 
- /*
-  * Move the array elements as needed...
-  */
+  //
+  // Move the array elements as needed...
+  //
 
   if (insert < *num_dests)
     memmove(*dests + insert + 1, *dests + insert, (size_t)(*num_dests - insert) * sizeof(cups_dest_t));
 
   (*num_dests) ++;
 
- /*
-  * Initialize the destination...
-  */
+  //
+  // Initialize the destination...
+  //
 
   dest              = *dests + insert;
   dest->name        = _cupsStrAlloc(name);
@@ -2539,30 +2443,30 @@ cups_add_dest(const char  *name,        /* I  - Name of destination */
 
 
 #  ifdef __BLOCKS__
-/*
- * 'cups_block_cb()' - Enumeration callback for block API.
- */
+//
+// 'cups_block_cb()' - Enumeration callback for block API.
+//
 
-static int                             /* O - 1 to continue, 0 to stop */
+static int                             // O - 1 to continue, 0 to stop
 cups_block_cb(
-    cups_dest_block_t block,           /* I - Block */
-    unsigned          flags,           /* I - Destination flags */
-    cups_dest_t       *dest)           /* I - Destination */
+    cups_dest_block_t block,           // I - Block
+    unsigned          flags,           // I - Destination flags
+    cups_dest_t       *dest)           // I - Destination
 {
   return ((block)(flags, dest));
 }
-#  endif /* __BLOCKS__ */
+#  endif // __BLOCKS__
 
 
-/*
- * 'cups_compare_dests()' - Compare two destinations.
- */
+//
+// 'cups_compare_dests()' - Compare two destinations.
+//
 
-static int                             /* O - Result of comparison */
-cups_compare_dests(cups_dest_t *a,     /* I - First destination */
-                   cups_dest_t *b)     /* I - Second destination */
+static int                             // O - Result of comparison
+cups_compare_dests(cups_dest_t *a,     // I - First destination
+                   cups_dest_t *b)     // I - Second destination
 {
-  int  diff;                           /* Difference */
+  int  diff;                           // Difference
 
 
   if ((diff = _cups_strcasecmp(a->name, b->name)) != 0)
@@ -2574,167 +2478,59 @@ cups_compare_dests(cups_dest_t *a,     /* I - First destination */
 }
 
 
-#ifdef HAVE_DNSSD
-#  ifdef HAVE_MDNSRESPONDER
-/*
- * 'cups_dnssd_browse_cb()' - Browse for printers.
- */
+//
+// 'cups_dest_browse_cb()' - Browse for printers.
+//
 
 static void
-cups_dnssd_browse_cb(
-    DNSServiceRef       sdRef,         /* I - Service reference */
-    DNSServiceFlags     flags,         /* I - Option flags */
-    uint32_t            interfaceIndex,        /* I - Interface number */
-    DNSServiceErrorType errorCode,     /* I - Error, if any */
-    const char          *serviceName,  /* I - Name of service/device */
-    const char          *regtype,      /* I - Type of service */
-    const char          *replyDomain,  /* I - Service domain */
-    void                *context)      /* I - Enumeration data */
+cups_dest_browse_cb(
+    cups_dnssd_browse_t *browse,       // I - DNS-SD browser
+    void                *context,      // I - Enumeration data
+    cups_dnssd_flags_t  flags,         // I - Flags
+    uint32_t            if_index,      // I - Interface
+    const char          *serviceName,  // I - Name of service/device
+    const char          *regtype,      // I - Type of service
+    const char          *replyDomain)  // I - Service domain
 {
   _cups_dnssd_data_t   *data = (_cups_dnssd_data_t *)context;
-                                       /* Enumeration data */
-
+                                       // Enumeration data
 
-  DEBUG_printf("5cups_dnssd_browse_cb(sdRef=%p, flags=%x, interfaceIndex=%d, errorCode=%d, serviceName=\"%s\", regtype=\"%s\", replyDomain=\"%s\", context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, serviceName, regtype, replyDomain, context);
 
- /*
-  * Don't do anything on error...
-  */
+  DEBUG_printf("5cups_dest_browse_cb(browse=%p, context=%p, flags=%x, if_index=%d, serviceName=\"%s\", regtype=\"%s\", replyDomain=\"%s\")", (void *)browse, context, flags, if_index, serviceName, regtype, replyDomain);
 
-  if (errorCode != kDNSServiceErr_NoError)
+  // Don't do anything on error, only add services...
+  if ((flags & CUPS_DNSSD_FLAGS_ERROR) || !(flags & CUPS_DNSSD_FLAGS_ADD))
     return;
 
- /*
-  * Get the device...
-  */
-
+  // Get the device...
   cups_dnssd_get_device(data, serviceName, regtype, replyDomain);
 }
+//
+// 'cups_dnssd_compare_device()' - Compare two devices.
+//
 
-
-#  else /* HAVE_AVAHI */
-/*
- * 'cups_dnssd_browse_cb()' - Browse for printers.
- */
-
-static void
-cups_dnssd_browse_cb(
-    AvahiServiceBrowser    *browser,   /* I - Browser */
-    AvahiIfIndex           interface,  /* I - Interface index (unused) */
-    AvahiProtocol          protocol,   /* I - Network protocol (unused) */
-    AvahiBrowserEvent      event,      /* I - What happened */
-    const char             *name,      /* I - Service name */
-    const char             *type,      /* I - Registration type */
-    const char             *domain,    /* I - Domain */
-    AvahiLookupResultFlags flags,      /* I - Flags */
-    void                   *context)   /* I - Devices array */
-{
-#ifdef DEBUG
-  AvahiClient          *client = avahi_service_browser_get_client(browser);
-                                       /* Client information */
-#endif /* DEBUG */
-  _cups_dnssd_data_t   *data = (_cups_dnssd_data_t *)context;
-                                       /* Enumeration data */
-
-
-  (void)interface;
-  (void)protocol;
-  (void)context;
-
-  DEBUG_printf("cups_dnssd_browse_cb(..., name=\"%s\", type=\"%s\", domain=\"%s\", ...);", name, type, domain);
-
-  switch (event)
-  {
-    case AVAHI_BROWSER_FAILURE:
-       DEBUG_printf("cups_dnssd_browse_cb: %s", avahi_strerror(avahi_client_errno(client)));
-       avahi_simple_poll_quit(data->simple_poll);
-       break;
-
-    case AVAHI_BROWSER_NEW:
-       /*
-       * This object is new on the network.
-       */
-
-       cups_dnssd_get_device(data, name, type, domain);
-       break;
-
-    case AVAHI_BROWSER_REMOVE :
-    case AVAHI_BROWSER_CACHE_EXHAUSTED :
-        break;
-
-    case AVAHI_BROWSER_ALL_FOR_NOW :
-        DEBUG_puts("cups_dnssd_browse_cb: ALL_FOR_NOW");
-        data->browsers --;
-        break;
-  }
-}
-
-
-/*
- * 'cups_dnssd_client_cb()' - Avahi client callback function.
- */
-
-static void
-cups_dnssd_client_cb(
-    AvahiClient      *client,          /* I - Client information (unused) */
-    AvahiClientState state,            /* I - Current state */
-    void             *context)         /* I - User data (unused) */
-{
-  _cups_dnssd_data_t   *data = (_cups_dnssd_data_t *)context;
-                                       /* Enumeration data */
-
-
-  (void)client;
-
-  DEBUG_printf("cups_dnssd_client_cb(client=%p, state=%d, context=%p)", client, state, context);
-
- /*
-  * If the connection drops, quit.
-  */
-
-  if (state == AVAHI_CLIENT_FAILURE)
-  {
-    DEBUG_puts("cups_dnssd_client_cb: Avahi connection failed.");
-    avahi_simple_poll_quit(data->simple_poll);
-  }
-}
-#  endif /* HAVE_MDNSRESPONDER */
-
-
-/*
- * 'cups_dnssd_compare_device()' - Compare two devices.
- */
-
-static int                             /* O - Result of comparison */
+static int                             // O - Result of comparison
 cups_dnssd_compare_devices(
-    _cups_dnssd_device_t *a,           /* I - First device */
-    _cups_dnssd_device_t *b)           /* I - Second device */
+    _cups_dnssd_device_t *a,           // I - First device
+    _cups_dnssd_device_t *b)           // I - Second device
 {
   return (strcmp(a->dest.name, b->dest.name));
 }
 
 
-/*
- * 'cups_dnssd_free_device()' - Free the memory used by a device.
- */
+//
+// 'cups_dnssd_free_device()' - Free the memory used by a device.
+//
 
 static void
 cups_dnssd_free_device(
-    _cups_dnssd_device_t *device,      /* I - Device */
-    _cups_dnssd_data_t   *data)                /* I - Enumeration data */
+    _cups_dnssd_device_t *device,      // I - Device
+    _cups_dnssd_data_t   *data)                // I - Enumeration data
 {
   DEBUG_printf("5cups_dnssd_free_device(device=%p(%s), data=%p)", (void *)device, device->dest.name, (void *)data);
 
-#  ifdef HAVE_MDNSRESPONDER
-  if (device->ref)
-    DNSServiceRefDeallocate(device->ref);
-#  else /* HAVE_AVAHI */
-  if (device->ref)
-    avahi_record_browser_free(device->ref);
-#  endif /* HAVE_MDNSRESPONDER */
-
   _cupsStrFree(device->domain);
-  _cupsStrFree(device->fullName);
+  _cupsStrFree(device->fullname);
   _cupsStrFree(device->regtype);
   _cupsStrFree(device->dest.name);
 
@@ -2744,70 +2540,61 @@ cups_dnssd_free_device(
 }
 
 
-/*
- * 'cups_dnssd_get_device()' - Lookup a device and create it as needed.
- */
+//
+// 'cups_dnssd_get_device()' - Lookup a device and create it as needed.
+//
 
-static _cups_dnssd_device_t *          /* O - Device */
+static _cups_dnssd_device_t *          // O - Device
 cups_dnssd_get_device(
-    _cups_dnssd_data_t *data,          /* I - Enumeration data */
-    const char         *serviceName,   /* I - Service name */
-    const char         *regtype,       /* I - Registration type */
-    const char         *replyDomain)   /* I - Domain name */
+    _cups_dnssd_data_t *data,          // I - Enumeration data
+    const char         *serviceName,   // I - Service name
+    const char         *regtype,       // I - Registration type
+    const char         *replyDomain)   // I - Domain name
 {
-  _cups_dnssd_device_t key,            /* Search key */
-                       *device;        /* Device */
-  char                 fullName[kDNSServiceMaxDomainName],
-                                       /* Full name for query */
-                       name[128];      /* Queue name */
+  _cups_dnssd_device_t key,            // Search key
+                       *device;        // Device
+  char                 fullname[1024], // Full name for query
+                       name[128];      // Queue name
 
 
   DEBUG_printf("5cups_dnssd_get_device(data=%p, serviceName=\"%s\", regtype=\"%s\", replyDomain=\"%s\")", (void *)data, serviceName, regtype, replyDomain);
 
- /*
-  * See if this is an existing device...
-  */
-
+  // See if this is an existing device...
   cups_queue_name(name, serviceName, sizeof(name));
 
   key.dest.name = name;
 
-  if ((device = cupsArrayFind(data->devices, &key)) != NULL)
-  {
-   /*
-    * Yes, see if we need to do anything with this...
-    */
+  cupsRWLockRead(&data->rwlock);
 
-    int        update = 0;                     /* Non-zero if we need to update */
+  device = cupsArrayFind(data->devices, &key);
 
-    if (!_cups_strcasecmp(replyDomain, "local.") &&
-       _cups_strcasecmp(device->domain, replyDomain))
-    {
-     /*
-      * Update the "global" listing to use the .local domain name instead.
-      */
+  cupsRWUnlock(&data->rwlock);
 
+  if (device)
+  {
+    // Yes, see if we need to do anything with this...
+    bool       update = false;         // Non-zero if we need to update
+
+    if (!_cups_strcasecmp(replyDomain, "local.") && _cups_strcasecmp(device->domain, replyDomain))
+    {
+      // Update the "global" listing to use the .local domain name instead.
       _cupsStrFree(device->domain);
       device->domain = _cupsStrAlloc(replyDomain);
 
       DEBUG_printf("6cups_dnssd_get_device: Updating '%s' to use local domain.", device->dest.name);
 
-      update = 1;
+      update = true;
     }
 
-    if (!_cups_strcasecmp(regtype, "_ipps._tcp") &&
-       _cups_strcasecmp(device->regtype, regtype))
+    if (!_cups_strcasecmp(regtype, "_ipps._tcp") && _cups_strcasecmp(device->regtype, regtype))
     {
-     /*
-      * Prefer IPPS over IPP.
-      */
-
+      // Prefer IPPS over IPP.
       _cupsStrFree(device->regtype);
       device->regtype = _cupsStrAlloc(regtype);
 
       DEBUG_printf("6cups_dnssd_get_device: Updating '%s' to use IPPS.", device->dest.name);
 
-      update = 1;
+      update = true;
     }
 
     if (!update)
@@ -2818,13 +2605,10 @@ cups_dnssd_get_device(
   }
   else
   {
-   /*
-    * No, add the device...
-    */
-
+    // No, add the device...
     DEBUG_printf("6cups_dnssd_get_device: Adding '%s' for %s with domain '%s'.", serviceName, !strcmp(regtype, "_ipps._tcp") ? "IPPS" : "IPP", replyDomain);
 
-    if ((device = calloc(1, sizeof(_cups_dnssd_device_t))) == NULL)
+    if ((device = calloc(sizeof(_cups_dnssd_device_t), 1)) == NULL)
       return (NULL);
 
     device->dest.name = _cupsStrAlloc(name);
@@ -2833,32 +2617,18 @@ cups_dnssd_get_device(
 
     device->dest.num_options = cupsAddOption("printer-info", serviceName, 0, &device->dest.options);
 
+    cupsRWLockWrite(&data->rwlock);
     cupsArrayAdd(data->devices, device);
+    cupsRWUnlock(&data->rwlock);
   }
 
- /*
-  * Set the "full name" of this service, which is used for queries...
-  */
-
-#  ifdef HAVE_MDNSRESPONDER
-  DNSServiceConstructFullName(fullName, serviceName, regtype, replyDomain);
-#  else /* HAVE_AVAHI */
-  avahi_service_name_join(fullName, kDNSServiceMaxDomainName, serviceName, regtype, replyDomain);
-#  endif /* HAVE_MDNSRESPONDER */
-
-  _cupsStrFree(device->fullName);
-  device->fullName = _cupsStrAlloc(fullName);
+  // Set the "full name" of this service, which is used for queries...
+  cupsDNSSDAssembleFullName(fullname, sizeof(fullname), serviceName, regtype, replyDomain);
+  _cupsStrFree(device->fullname);
+  device->fullname = _cupsStrAlloc(fullname);
 
-  if (device->ref)
-  {
-#  ifdef HAVE_MDNSRESPONDER
-    DNSServiceRefDeallocate(device->ref);
-#  else /* HAVE_AVAHI */
-    avahi_record_browser_free(device->ref);
-#  endif /* HAVE_MDNSRESPONDER */
-
-    device->ref = 0;
-  }
+  cupsDNSSDQueryDelete(device->query);
+  device->query = NULL;
 
   if (device->state == _CUPS_DNSSD_ACTIVE)
   {
@@ -2872,127 +2642,40 @@ cups_dnssd_get_device(
 }
 
 
-#  ifdef HAVE_AVAHI
-/*
- * 'cups_dnssd_poll_cb()' - Wait for input on the specified file descriptors.
- *
- * Note: This function is needed because avahi_simple_poll_iterate is broken
- *       and always uses a timeout of 0 (!) milliseconds.
- *       (https://github.com/lathiat/avahi/issues/127)
- *
- * @private@
- */
-
-static int                             /* O - Number of file descriptors matching */
-cups_dnssd_poll_cb(
-    struct pollfd *pollfds,            /* I - File descriptors */
-    unsigned int  num_pollfds,         /* I - Number of file descriptors */
-    int           timeout,             /* I - Timeout in milliseconds (unused) */
-    void          *context)            /* I - User data (unused) */
-{
-  _cups_dnssd_data_t   *data = (_cups_dnssd_data_t *)context;
-                                       /* Enumeration data */
-  int                  val;            /* Return value */
-
-
-  DEBUG_printf("cups_dnssd_poll_cb(pollfds=%p, num_pollfds=%d, timeout=%d, context=%p)", pollfds, num_pollfds, timeout, context);
-
-  (void)timeout;
-
-  val = poll(pollfds, num_pollfds, _CUPS_DNSSD_MAXTIME);
-
-  DEBUG_printf("cups_dnssd_poll_cb: poll() returned %d", val);
-
-  if (val < 0)
-  {
-    DEBUG_printf("cups_dnssd_poll_cb: %s", strerror(errno));
-  }
-  else if (val > 0)
-  {
-    data->got_data = 1;
-  }
-
-  return (val);
-}
-#  endif /* HAVE_AVAHI */
-
-
-/*
- * 'cups_dnssd_query_cb()' - Process query data.
- */
+//
+// 'cups_dest_query_cb()' - Process query data.
+//
 
 static void
-cups_dnssd_query_cb(
-#  ifdef HAVE_MDNSRESPONDER
-    DNSServiceRef       sdRef,         /* I - Service reference */
-    DNSServiceFlags     flags,         /* I - Data flags */
-    uint32_t            interfaceIndex,        /* I - Interface */
-    DNSServiceErrorType errorCode,     /* I - Error, if any */
-    const char          *fullName,     /* I - Full service name */
-    uint16_t            rrtype,                /* I - Record type */
-    uint16_t            rrclass,       /* I - Record class */
-    uint16_t            rdlen,         /* I - Length of record data */
-    const void          *rdata,                /* I - Record data */
-    uint32_t            ttl,           /* I - Time-to-live */
-#  else /* HAVE_AVAHI */
-    AvahiRecordBrowser     *browser,   /* I - Record browser */
-    AvahiIfIndex           interfaceIndex,
-                                       /* I - Interface index (unused) */
-    AvahiProtocol          protocol,   /* I - Network protocol (unused) */
-    AvahiBrowserEvent      event,      /* I - What happened? */
-    const char             *fullName,  /* I - Service name */
-    uint16_t               rrclass,    /* I - Record class */
-    uint16_t               rrtype,     /* I - Record type */
-    const void             *rdata,     /* I - TXT record */
-    size_t                 rdlen,      /* I - Length of TXT record */
-    AvahiLookupResultFlags flags,      /* I - Flags */
-#  endif /* HAVE_MDNSRESPONDER */
-    void                *context)      /* I - Enumeration data */
+cups_dest_query_cb(
+    cups_dnssd_query_t  *query,                // I - Query request
+    void                *context,      // I - Enumeration data
+    cups_dnssd_flags_t flags,          // I - DNS-SD flags
+    uint32_t            if_index,      // I - Interface
+    const char          *fullname,     // I - Full service name
+    uint16_t            rrtype,                // I - Record type
+    const void          *rdata,                // I - Record data
+    uint16_t            rdlen)         // I - Length of record data
 {
-#  if defined(DEBUG) && defined(HAVE_AVAHI)
-  AvahiClient          *client = avahi_record_browser_get_client(browser);
-                                       /* Client information */
-#  endif /* DEBUG && HAVE_AVAHI */
   _cups_dnssd_data_t   *data = (_cups_dnssd_data_t *)context;
-                                       /* Enumeration data */
-  char                 serviceName[256],/* Service name */
-                       name[128],      /* Queue name */
-                       *ptr;           /* Pointer into string */
-  _cups_dnssd_device_t dkey,           /* Search key */
-                       *device;        /* Device */
-
-
-#  ifdef HAVE_MDNSRESPONDER
-  DEBUG_printf("5cups_dnssd_query_cb(sdRef=%p, flags=%x, interfaceIndex=%d, errorCode=%d, fullName=\"%s\", rrtype=%u, rrclass=%u, rdlen=%u, rdata=%p, ttl=%u, context=%p)", (void *)sdRef, flags, interfaceIndex, errorCode, fullName, rrtype, rrclass, rdlen, rdata, ttl, context);
+                                       // Enumeration data
+  char                 serviceName[256],// Service name
+                       name[128],      // Queue name
+                       *ptr;           // Pointer into string
+  _cups_dnssd_device_t dkey,           // Search key
+                       *device;        // Device
 
- /*
-  * Only process "add" data...
-  */
 
-  if (errorCode != kDNSServiceErr_NoError || !(flags & kDNSServiceFlagsAdd))
-    return;
-
-#  else /* HAVE_AVAHI */
-  DEBUG_printf("cups_dnssd_query_cb(browser=%p, interfaceIndex=%d, protocol=%d, event=%d, fullName=\"%s\", rrclass=%u, rrtype=%u, rdata=%p, rdlen=%u, flags=%x, context=%p)", browser, interfaceIndex, protocol, event, fullName, rrclass, rrtype, rdata, (unsigned)rdlen, flags, context);
-
- /*
-  * Only process "add" data...
-  */
-
-  if (event != AVAHI_BROWSER_NEW)
-  {
-    if (event == AVAHI_BROWSER_FAILURE)
-      DEBUG_printf("cups_dnssd_query_cb: %s", avahi_strerror(avahi_client_errno(client)));
+  (void)query;
+  (void)if_index;
+  (void)rrtype;
 
+  // Only process "add" data...
+  if (!(flags & CUPS_DNSSD_FLAGS_ADD) || (flags & CUPS_DNSSD_FLAGS_ERROR))
     return;
-  }
-#  endif /* HAVE_MDNSRESPONDER */
-
- /*
-  * Lookup the service in the devices array.
-  */
 
-  cups_dnssd_unquote(serviceName, fullName, sizeof(serviceName));
+  // Lookup the service in the devices array.
+  cups_dnssd_unquote(serviceName, fullname, sizeof(serviceName));
 
   if ((ptr = strstr(serviceName, "._")) != NULL)
     *ptr = '\0';
@@ -3003,41 +2686,33 @@ cups_dnssd_query_cb(
 
   if ((device = cupsArrayFind(data->devices, &dkey)) != NULL && device->state == _CUPS_DNSSD_NEW)
   {
-   /*
-    * Found it, pull out the make and model from the TXT record and save it...
-    */
-
-    const uint8_t      *txt,           /* Pointer into data */
-                       *txtnext,       /* Next key/value pair */
-                       *txtend;        /* End of entire TXT record */
-    uint8_t            txtlen;         /* Length of current key/value pair */
-    char               key[256],       /* Key string */
-                       value[256],     /* Value string */
+    // Found it, pull out the make and model from the TXT record and save it...
+    const uint8_t      *txt,           // Pointer into data
+                       *txtnext,       // Next key/value pair
+                       *txtend;        // End of entire TXT record
+    uint8_t            txtlen;         // Length of current key/value pair
+    char               key[256],       // Key string
+                       value[256],     // Value string
                        make_and_model[512],
-                                       /* Manufacturer and model */
-                       model[256],     /* Model */
-                       uriname[1024],  /* Name for URI */
-                       uri[1024];      /* Printer URI */
+                                       // Manufacturer and model
+                       model[256],     // Model
+                       uriname[1024],  // Name for URI
+                       uri[1024];      // Printer URI
     cups_ptype_t       type = CUPS_PRINTER_DISCOVERED | CUPS_PRINTER_BW;
-                                       /* Printer type */
-    int                        saw_printer_type = 0;
-                                       /* Did we see a printer-type key? */
+                                       // Printer type
+    bool               saw_printer_type = false;
+                                       // Did we see a printer-type key?
 
     device->state     = _CUPS_DNSSD_PENDING;
     make_and_model[0] = '\0';
 
     cupsCopyString(model, "Unknown", sizeof(model));
 
-    for (txt = rdata, txtend = txt + rdlen;
-        txt < txtend;
-        txt = txtnext)
+    for (txt = rdata, txtend = txt + rdlen; txt < txtend; txt = txtnext)
     {
-     /*
-      * Read a key/value pair starting with an 8-bit length.  Since the
-      * length is 8 bits and the size of the key/value buffers is 256, we
-      * don't need to check for overflow...
-      */
-
+      // Read a key/value pair starting with an 8-bit length.  Since the
+      // length is 8 bits and the size of the key/value buffers is 256, we
+      // don't need to check for overflow...
       txtlen = *txt++;
 
       if (!txtlen || (txt + txtlen) > txtend)
@@ -3057,36 +2732,36 @@ cups_dnssd_query_cb(
          memcpy(value, txt, (size_t)(txtnext - txt));
        value[txtnext - txt] = '\0';
 
-       DEBUG_printf("6cups_dnssd_query_cb: %s=%s", key, value);
+       DEBUG_printf("6cups_dest_query_cb: %s=%s", key, value);
       }
       else
       {
-       DEBUG_printf("6cups_dnssd_query_cb: '%s' with no value.", key);
+       DEBUG_printf("6cups_dest_query_cb: '%s' with no value.", key);
        continue;
       }
 
-      if (!_cups_strcasecmp(key, "usb_MFG") ||
-          !_cups_strcasecmp(key, "usb_MANU") ||
-         !_cups_strcasecmp(key, "usb_MANUFACTURER"))
+      if (!_cups_strcasecmp(key, "usb_MFG") || !_cups_strcasecmp(key, "usb_MANU") || !_cups_strcasecmp(key, "usb_MANUFACTURER"))
+      {
        cupsCopyString(make_and_model, value, sizeof(make_and_model));
-      else if (!_cups_strcasecmp(key, "usb_MDL") ||
-               !_cups_strcasecmp(key, "usb_MODEL"))
+      }
+      else if (!_cups_strcasecmp(key, "usb_MDL") || !_cups_strcasecmp(key, "usb_MODEL"))
+      {
        cupsCopyString(model, value, sizeof(model));
+      }
       else if (!_cups_strcasecmp(key, "product") && !strstr(value, "Ghostscript"))
       {
        if (value[0] == '(')
        {
-        /*
-         * Strip parenthesis...
-         */
-
+         // Strip parenthesis...
          if ((ptr = value + strlen(value) - 1) > value && *ptr == ')')
            *ptr = '\0';
 
          cupsCopyString(model, value + 1, sizeof(model));
        }
        else
+       {
          cupsCopyString(model, value, sizeof(model));
+       }
       }
       else if (!_cups_strcasecmp(key, "ty"))
       {
@@ -3096,30 +2771,26 @@ cups_dnssd_query_cb(
          *ptr = '\0';
       }
       else if (!_cups_strcasecmp(key, "note"))
-        device->dest.num_options = cupsAddOption("printer-location", value,
-                                                device->dest.num_options,
-                                                &device->dest.options);
+      {
+        device->dest.num_options = cupsAddOption("printer-location", value, device->dest.num_options, &device->dest.options);
+      }
       else if (!_cups_strcasecmp(key, "pdl"))
       {
-       /*
-        * Look for PDF-capable printers; only PDF-capable printers are shown.
-        */
-
-        const char     *start, *next;  /* Pointer into value */
-        int            have_pdf = 0,   /* Have PDF? */
-                       have_raster = 0;/* Have raster format support? */
+        // Look for PDF-capable printers; only PDF-capable printers are shown.
+        const char *start, *next;      // Pointer into value
+        bool   have_pdf = false,       // Have PDF?
+               have_raster = false;    // Have raster format support?
 
         for (start = value; start && *start; start = next)
         {
           if (!_cups_strncasecmp(start, "application/pdf", 15) && (!start[15] || start[15] == ','))
           {
-            have_pdf = 1;
+            have_pdf = true;
             break;
           }
-          else if ((!_cups_strncasecmp(start, "image/pwg-raster", 16) && (!start[16] || start[16] == ',')) ||
-                  (!_cups_strncasecmp(start, "image/urf", 9) && (!start[9] || start[9] == ',')))
+          else if ((!_cups_strncasecmp(start, "image/pwg-raster", 16) && (!start[16] || start[16] == ',')) || (!_cups_strncasecmp(start, "image/urf", 9) && (!start[9] || start[9] == ',')))
           {
-            have_raster = 1;
+            have_raster = true;
             break;
           }
 
@@ -3132,39 +2803,44 @@ cups_dnssd_query_cb(
       }
       else if (!_cups_strcasecmp(key, "printer-type"))
       {
-       /*
-        * Value is either NNNN or 0xXXXX
-        */
-
-       saw_printer_type = 1;
+        // Value is either NNNN or 0xXXXX
+       saw_printer_type = true;
         type             = (cups_ptype_t)strtol(value, NULL, 0) | CUPS_PRINTER_DISCOVERED;
       }
       else if (!saw_printer_type)
       {
-       if (!_cups_strcasecmp(key, "air") &&
-                !_cups_strcasecmp(value, "t"))
+       if (!_cups_strcasecmp(key, "air") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_AUTHENTICATED;
-       else if (!_cups_strcasecmp(key, "bind") &&
-                !_cups_strcasecmp(value, "t"))
+       }
+       else if (!_cups_strcasecmp(key, "bind") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_BIND;
-       else if (!_cups_strcasecmp(key, "collate") &&
-                !_cups_strcasecmp(value, "t"))
+       }
+       else if (!_cups_strcasecmp(key, "collate") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_COLLATE;
-       else if (!_cups_strcasecmp(key, "color") &&
-                !_cups_strcasecmp(value, "t"))
+       }
+       else if (!_cups_strcasecmp(key, "color") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_COLOR;
-       else if (!_cups_strcasecmp(key, "copies") &&
-                !_cups_strcasecmp(value, "t"))
+       }
+       else if (!_cups_strcasecmp(key, "copies") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_COPIES;
-       else if (!_cups_strcasecmp(key, "duplex") &&
-                !_cups_strcasecmp(value, "t"))
+       }
+       else if (!_cups_strcasecmp(key, "duplex") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_DUPLEX;
-       else if (!_cups_strcasecmp(key, "fax") &&
-                !_cups_strcasecmp(value, "t"))
+       }
+       else if (!_cups_strcasecmp(key, "fax") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_MFP;
-       else if (!_cups_strcasecmp(key, "papercustom") &&
-                !_cups_strcasecmp(value, "t"))
+       }
+       else if (!_cups_strcasecmp(key, "papercustom") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_VARIABLE;
+       }
        else if (!_cups_strcasecmp(key, "papermax"))
        {
          if (!_cups_strcasecmp(value, "legal-a4"))
@@ -3174,25 +2850,26 @@ cups_dnssd_query_cb(
          else if (!_cups_strcasecmp(value, ">isoc-a2"))
            type |= CUPS_PRINTER_LARGE;
        }
-       else if (!_cups_strcasecmp(key, "punch") &&
-                !_cups_strcasecmp(value, "t"))
+       else if (!_cups_strcasecmp(key, "punch") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_PUNCH;
-       else if (!_cups_strcasecmp(key, "scan") &&
-                !_cups_strcasecmp(value, "t"))
+       }
+       else if (!_cups_strcasecmp(key, "scan") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_MFP;
-       else if (!_cups_strcasecmp(key, "sort") &&
-                !_cups_strcasecmp(value, "t"))
+       }
+       else if (!_cups_strcasecmp(key, "sort") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_SORT;
-       else if (!_cups_strcasecmp(key, "staple") &&
-                !_cups_strcasecmp(value, "t"))
+       }
+       else if (!_cups_strcasecmp(key, "staple") && !_cups_strcasecmp(value, "t"))
+       {
          type |= CUPS_PRINTER_STAPLE;
+       }
       }
     }
 
-   /*
-    * Save the printer-xxx values...
-    */
-
+    // Save the printer-xxx values...
     if (make_and_model[0])
     {
       cupsConcatString(make_and_model, " ", sizeof(make_and_model));
@@ -3201,51 +2878,47 @@ cups_dnssd_query_cb(
       device->dest.num_options = cupsAddOption("printer-make-and-model", make_and_model, device->dest.num_options, &device->dest.options);
     }
     else
+    {
       device->dest.num_options = cupsAddOption("printer-make-and-model", model, device->dest.num_options, &device->dest.options);
+    }
 
     device->type = type;
     snprintf(value, sizeof(value), "%u", type);
     device->dest.num_options = cupsAddOption("printer-type", value, device->dest.num_options, &device->dest.options);
 
-   /*
-    * Save the URI...
-    */
-
-    cups_dnssd_unquote(uriname, device->fullName, sizeof(uriname));
-    httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri),
-                    !strcmp(device->regtype, "_ipps._tcp") ? "ipps" : "ipp",
-                    NULL, uriname, 0, saw_printer_type ? "/cups" : "/");
+    // Save the URI...
+    cups_dnssd_unquote(uriname, device->fullname, sizeof(uriname));
+    httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), !strcmp(device->regtype, "_ipps._tcp") ? "ipps" : "ipp", NULL, uriname, 0, saw_printer_type ? "/cups" : "/");
 
     DEBUG_printf("6cups_dnssd_query: device-uri=\"%s\"", uri);
 
     device->dest.num_options = cupsAddOption("device-uri", uri, device->dest.num_options, &device->dest.options);
   }
   else
-    DEBUG_printf("6cups_dnssd_query: Ignoring TXT record for '%s'.", fullName);
+  {
+    DEBUG_printf("6cups_dnssd_query: Ignoring TXT record for '%s'.", fullname);
+  }
 }
 
 
-/*
- * 'cups_dnssd_resolve()' - Resolve a Bonjour printer URI.
- */
+//
+// 'cups_dest_resolve()' - Resolve a Bonjour printer URI.
+//
 
-static const char *                    /* O - Resolved URI or NULL */
-cups_dnssd_resolve(
-    cups_dest_t    *dest,              /* I - Destination */
-    const char     *uri,               /* I - Current printer URI */
-    int            msec,               /* I - Time in milliseconds */
-    int            *cancel,            /* I - Pointer to "cancel" variable */
-    cups_dest_cb_t cb,                 /* I - Callback */
-    void           *user_data)         /* I - User data for callback */
+static const char *                    // O - Resolved URI or NULL
+cups_dest_resolve(
+    cups_dest_t    *dest,              // I - Destination
+    const char     *uri,               // I - Current printer URI
+    int            msec,               // I - Time in milliseconds
+    int            *cancel,            // I - Pointer to "cancel" variable
+    cups_dest_cb_t cb,                 // I - Callback
+    void           *user_data)         // I - User data for callback
 {
-  char                 tempuri[1024];  /* Temporary URI buffer */
-  _cups_dnssd_resolve_t        resolve;        /* Resolve data */
+  char                 tempuri[1024];  // Temporary URI buffer
+  _cups_dnssd_resdata_t        resolve;        // Resolve data
 
 
- /*
-  * Resolve the URI...
-  */
-
+  // Resolve the URI...
   resolve.cancel = cancel;
   gettimeofday(&resolve.end_time, NULL);
   if (msec > 0)
@@ -3260,12 +2933,14 @@ cups_dnssd_resolve(
     }
   }
   else
+  {
     resolve.end_time.tv_sec += 75;
+  }
 
   if (cb)
     (*cb)(user_data, CUPS_DEST_FLAGS_UNCONNECTED | CUPS_DEST_FLAGS_RESOLVING, dest);
 
-  if ((uri = httpResolveURI(uri, tempuri, sizeof(tempuri), HTTP_RESOLVE_DEFAULT, cups_dnssd_resolve_cb, &resolve)) == NULL)
+  if ((uri = httpResolveURI(uri, tempuri, sizeof(tempuri), HTTP_RESOLVE_DEFAULT, cups_dest_resolve_cb, &resolve)) == NULL)
   {
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to resolve printer-uri."), 1);
 
@@ -3275,62 +2950,51 @@ cups_dnssd_resolve(
     return (NULL);
   }
 
- /*
-  * Save the resolved URI...
-  */
-
+  // Save the resolved URI...
   dest->num_options = cupsAddOption("device-uri", uri, dest->num_options, &dest->options);
 
   return (cupsGetOption("device-uri", dest->num_options, dest->options));
 }
 
 
-/*
- * 'cups_dnssd_resolve_cb()' - See if we should continue resolving.
- */
+//
+// 'cups_dest_resolve_cb()' - See if we should continue resolving.
+//
 
-static bool                            /* O - `true` to continue, `false` to stop */
-cups_dnssd_resolve_cb(void *context)   /* I - Resolve data */
+static bool                            // O - `true` to continue, `false` to stop
+cups_dest_resolve_cb(void *context)    // I - Resolve data
 {
-  _cups_dnssd_resolve_t        *resolve = (_cups_dnssd_resolve_t *)context;
-                                       /* Resolve data */
-  struct timeval       curtime;        /* Current time */
+  _cups_dnssd_resdata_t        *resolve = (_cups_dnssd_resdata_t *)context;
+                                       // Resolve data
+  struct timeval       curtime;        // Current time
 
 
- /*
-  * If the cancel variable is set, return immediately.
-  */
-
+  // If the cancel variable is set, return immediately.
   if (resolve->cancel && *(resolve->cancel))
   {
-    DEBUG_puts("4cups_dnssd_resolve_cb: Canceled.");
+    DEBUG_puts("4cups_dest_resolve_cb: Canceled.");
     return (false);
   }
 
- /*
-  * Otherwise check the end time...
-  */
-
+  // Otherwise check the end time...
   gettimeofday(&curtime, NULL);
 
-  DEBUG_printf("4cups_dnssd_resolve_cb: curtime=%d.%06d, end_time=%d.%06d", (int)curtime.tv_sec, (int)curtime.tv_usec, (int)resolve->end_time.tv_sec, (int)resolve->end_time.tv_usec);
+  DEBUG_printf("4cups_dest_resolve_cb: curtime=%d.%06d, end_time=%d.%06d", (int)curtime.tv_sec, (int)curtime.tv_usec, (int)resolve->end_time.tv_sec, (int)resolve->end_time.tv_usec);
 
-  return (curtime.tv_sec < resolve->end_time.tv_sec ||
-          (curtime.tv_sec == resolve->end_time.tv_sec &&
-           curtime.tv_usec < resolve->end_time.tv_usec));
+  return (curtime.tv_sec < resolve->end_time.tv_sec || (curtime.tv_sec == resolve->end_time.tv_sec && curtime.tv_usec < resolve->end_time.tv_usec));
 }
 
 
-/*
- * 'cups_dnssd_unquote()' - Unquote a name string.
- */
+//
+// 'cups_dnssd_unquote()' - Unquote a name string.
+//
 
 static void
-cups_dnssd_unquote(char       *dst,    /* I - Destination buffer */
-                   const char *src,    /* I - Source string */
-                  size_t     dstsize)  /* I - Size of destination buffer */
+cups_dnssd_unquote(char       *dst,    // I - Destination buffer
+                   const char *src,    // I - Source string
+                  size_t     dstsize)  // I - Size of destination buffer
 {
-  char *dstend = dst + dstsize - 1;    /* End of destination buffer */
+  char *dstend = dst + dstsize - 1;    // End of destination buffer
 
 
   while (*src && dst < dstend)
@@ -3338,32 +3002,35 @@ cups_dnssd_unquote(char       *dst,     /* I - Destination buffer */
     if (*src == '\\')
     {
       src ++;
-      if (isdigit(src[0] & 255) && isdigit(src[1] & 255) &&
-          isdigit(src[2] & 255))
+      if (isdigit(src[0] & 255) && isdigit(src[1] & 255) && isdigit(src[2] & 255))
       {
         *dst++ = ((((src[0] - '0') * 10) + src[1] - '0') * 10) + src[2] - '0';
        src += 3;
       }
       else
+      {
         *dst++ = *src++;
+      }
     }
     else
+    {
       *dst++ = *src ++;
+    }
   }
 
   *dst = '\0';
 }
 
 
-/*
- * 'cups_elapsed()' - Return the elapsed time in milliseconds.
- */
+//
+// 'cups_elapsed()' - Return the elapsed time in milliseconds.
+//
 
-static int                             /* O  - Elapsed time in milliseconds */
-cups_elapsed(struct timeval *t)                /* IO - Previous time */
+static int                             // O  - Elapsed time in milliseconds
+cups_elapsed(struct timeval *t)                // IO - Previous time
 {
-  int                  msecs;          /* Milliseconds */
-  struct timeval       nt;             /* New time */
+  int                  msecs;          // Milliseconds
+  struct timeval       nt;             // New time
 
 
   gettimeofday(&nt, NULL);
@@ -3374,61 +3041,44 @@ cups_elapsed(struct timeval *t)         /* IO - Previous time */
 
   return (msecs);
 }
-#endif /* HAVE_DNSSD */
 
 
-/*
- * 'cups_enum_dests()' - Enumerate destinations from a specific server.
- */
+//
+// 'cups_enum_dests()' - Enumerate destinations from a specific server.
+//
 
-static int                              /* O - 1 on success, 0 on failure */
+static int                              // O - 1 on success, 0 on failure
 cups_enum_dests(
-  http_t         *http,                 /* I - Connection to scheduler */
-  unsigned       flags,                 /* I - Enumeration flags */
-  int            msec,                  /* I - Timeout in milliseconds, -1 for indefinite */
-  int            *cancel,               /* I - Pointer to "cancel" variable */
-  cups_ptype_t   type,                  /* I - Printer type bits */
-  cups_ptype_t   mask,                  /* I - Mask for printer type bits */
-  cups_dest_cb_t cb,                    /* I - Callback function */
-  void           *user_data)            /* I - User data */
+  http_t         *http,                 // I - Connection to scheduler
+  unsigned       flags,                 // I - Enumeration flags
+  int            msec,                  // I - Timeout in milliseconds, -1 for indefinite
+  int            *cancel,               // I - Pointer to "cancel" variable
+  cups_ptype_t   type,                  // I - Printer type bits
+  cups_ptype_t   mask,                  // I - Mask for printer type bits
+  cups_dest_cb_t cb,                    // I - Callback function
+  void           *user_data)            // I - User data
 {
-  int           i, j, k,               /* Looping vars */
-                num_dests;              /* Number of destinations */
-  cups_dest_t   *dests = NULL,          /* Destinations */
-                *dest;                 /* Current destination */
-  cups_option_t        *option;                /* Current option */
-  const char   *user_default;          /* Default printer from environment */
-#ifdef HAVE_DNSSD
-  int           count,                  /* Number of queries started */
-                completed,              /* Number of completed queries */
-                remaining;              /* Remainder of timeout */
-  struct timeval curtime;               /* Current time */
-  _cups_dnssd_data_t data;             /* Data for callback */
-  _cups_dnssd_device_t *device;         /* Current device */
-#  ifdef HAVE_MDNSRESPONDER
-  int           nfds,                   /* Number of files responded */
-                main_fd;                /* File descriptor for lookups */
-  DNSServiceRef ipp_ref = NULL;                /* IPP browser */
-  DNSServiceRef ipps_ref = NULL;       /* IPPS browser */
-  struct pollfd pfd;                    /* Polling data */
-#  else /* HAVE_AVAHI */
-  int           error;                  /* Error value */
-  AvahiServiceBrowser *ipp_ref = NULL;  /* IPP browser */
-  AvahiServiceBrowser *ipps_ref = NULL; /* IPPS browser */
-#  endif /* HAVE_MDNSRESPONDER */
-#else
-  _cups_getdata_t data;                        /* Data for callback */
-#endif /* HAVE_DNSSD */
-  char         filename[1024];         /* Local lpoptions file */
-  _cups_globals_t *cg = _cupsGlobals();        /* Pointer to library globals */
+  int           i, j, k,               // Looping vars
+                num_dests,              // Number of destinations
+               num_devices;            // Number of devices
+  cups_dest_t   *dests = NULL,          // Destinations
+                *dest;                 // Current destination
+  cups_option_t        *option;                // Current option
+  const char   *user_default;          // Default printer from environment
+  int           count,                  // Number of queries started
+                completed,              // Number of completed queries
+                remaining;              // Remainder of timeout
+  struct timeval curtime;               // Current time
+  _cups_dnssd_data_t data;             // Data for callback
+  _cups_dnssd_device_t *device;         // Current device
+  cups_dnssd_t *dnssd = NULL;          // DNS-SD context
+  char         filename[1024];         // Local lpoptions file
+  _cups_globals_t *cg = _cupsGlobals();        // Pointer to library globals
 
 
   DEBUG_printf("cups_enum_dests(flags=%x, msec=%d, cancel=%p, type=%x, mask=%x, cb=%p, user_data=%p)", flags, msec, (void *)cancel, type, mask, (void *)cb, (void *)user_data);
 
- /*
-  * Range check input...
-  */
-
+  // Range check input...
   (void)flags;
 
   if (!cb)
@@ -3437,10 +3087,7 @@ cups_enum_dests(
     return (0);
   }
 
- /*
-  * Load the /etc/cups/lpoptions and ~/.cups/lpoptions files...
-  */
-
+  // Load the /etc/cups/lpoptions and ~/.cups/lpoptions files...
   memset(&data, 0, sizeof(data));
 
   user_default = _cupsGetUserDefault(data.def_name, sizeof(data.def_name));
@@ -3450,6 +3097,7 @@ cups_enum_dests(
 
   if (cg->home)
   {
+  // TODO: Use cg->userconfig
 #if _WIN32
     snprintf(filename, sizeof(filename), "%s/AppData/Local/cups/lpoptions", cg->home);
 #else
@@ -3461,10 +3109,7 @@ cups_enum_dests(
 
   if (!user_default && (dest = cupsGetDest(NULL, NULL, data.num_dests, data.dests)) != NULL)
   {
-   /*
-    * Use an lpoptions default printer...
-    */
-
+    // Use an lpoptions default printer...
     if (dest->instance)
       snprintf(data.def_name, sizeof(data.def_name), "%s/%s", dest->name, dest->instance);
     else
@@ -3472,7 +3117,7 @@ cups_enum_dests(
   }
   else
   {
-    const char *default_printer;       /* Server default printer */
+    const char *default_printer;       // Server default printer
 
     if ((default_printer = cupsGetDefault2(http)) != NULL)
       cupsCopyString(data.def_name, default_printer, sizeof(data.def_name));
@@ -3480,42 +3125,28 @@ cups_enum_dests(
 
   if (data.def_name[0])
   {
-   /*
-    * Separate printer and instance name...
-    */
-
+    // Separate printer and instance name...
     if ((data.def_instance = strchr(data.def_name, '/')) != NULL)
       *data.def_instance++ = '\0';
   }
 
   DEBUG_printf("1cups_enum_dests: def_name=\"%s\", def_instance=\"%s\"", data.def_name, data.def_instance);
 
- /*
-  * Get ready to enumerate...
-  */
-
-#ifdef HAVE_DNSSD
+  // Get ready to enumerate...
   data.type      = type;
   data.mask      = mask;
   data.cb        = cb;
   data.user_data = user_data;
   data.devices   = cupsArrayNew3((cups_array_func_t)cups_dnssd_compare_devices, NULL, NULL, 0, NULL, (cups_afree_func_t)cups_dnssd_free_device);
-#endif /* HAVE_DNSSD */
 
   if (!(mask & CUPS_PRINTER_DISCOVERED) || !(type & CUPS_PRINTER_DISCOVERED))
   {
-   /*
-    * Get the list of local printers and pass them to the callback function...
-    */
-
+    // Get the list of local printers and pass them to the callback function...
     num_dests = _cupsGetDests(http, IPP_OP_CUPS_GET_PRINTERS, NULL, &dests, type, mask);
 
     if (data.def_name[0])
     {
-     /*
-      * Lookup the named default printer and instance and make it the default...
-      */
-
+      // Lookup the named default printer and instance and make it the default...
       if ((dest = cupsGetDest(data.def_name, data.def_instance, num_dests, dests)) != NULL)
       {
        DEBUG_printf("1cups_enum_dests: Setting is_default on \"%s/%s\".", dest->name, dest->instance);
@@ -3523,21 +3154,14 @@ cups_enum_dests(
       }
     }
 
-    for (i = num_dests, dest = dests;
-         i > 0 && (!cancel || !*cancel);
-         i --, dest ++)
+    for (i = num_dests, dest = dests; i > 0 && (!cancel || !*cancel); i --, dest ++)
     {
-      cups_dest_t      *user_dest;     /* Destination from lpoptions */
-#ifdef HAVE_DNSSD
-      const char       *device_uri;    /* Device URI */
-#endif /* HAVE_DNSSD */
+      cups_dest_t      *user_dest;     // Destination from lpoptions
+      const char       *device_uri;    // Device URI
 
       if ((user_dest = cupsGetDest(dest->name, NULL, data.num_dests, data.dests)) != NULL)
       {
-       /*
-        * Apply user defaults to this destination for all instances...
-        */
-
+        // Apply user defaults to this destination for all instances...
         for (j = user_dest - data.dests; j < data.num_dests; j ++, user_dest ++)
         {
           if (_cups_strcasecmp(user_dest->name, dest->name))
@@ -3560,22 +3184,20 @@ cups_enum_dests(
           break;
       }
       else if (!(*cb)(user_data, i > 1 ? CUPS_DEST_FLAGS_MORE : CUPS_DEST_FLAGS_NONE, dest))
+      {
         break;
+      }
 
-#ifdef HAVE_DNSSD
       if (!dest->instance && (device_uri = cupsGetOption("device-uri", dest->num_options, dest->options)) != NULL && !strncmp(device_uri, "dnssd://", 8))
       {
-       /*
-        * Add existing queue using service name, etc. so we don't list it again...
-        */
-
-        char    scheme[32],             /* URI scheme */
-                userpass[32],           /* Username:password */
-                serviceName[256],       /* Service name (host field) */
-                resource[256],          /* Resource (options) */
-                *regtype,               /* Registration type */
-                *replyDomain;           /* Registration domain */
-        int     port;                   /* Port number (not used) */
+        // Add existing queue using service name, etc. so we don't list it again...
+        char    scheme[32],             // URI scheme
+                userpass[32],           // Username:password
+                serviceName[256],       // Service name (host field)
+                resource[256],          // Resource (options)
+                *regtype,               // Registration type
+                *replyDomain;           // Registration domain
+        int     port;                   // Port number (not used)
 
         if (httpSeparateURI(HTTP_URI_CODING_ALL, device_uri, scheme, sizeof(scheme), userpass, sizeof(userpass), serviceName, sizeof(serviceName), &port, resource, sizeof(resource)) >= HTTP_URI_STATUS_OK)
         {
@@ -3594,7 +3216,6 @@ cups_enum_dests(
           }
         }
       }
-#endif /* HAVE_DNSSD */
     }
 
     cupsFreeDests(num_dests, dests);
@@ -3603,113 +3224,44 @@ cups_enum_dests(
       goto enum_finished;
   }
 
- /*
-  * Return early if the caller doesn't want to do discovery...
-  */
-
+  // Return early if the caller doesn't want to do discovery...
   if ((mask & CUPS_PRINTER_DISCOVERED) && !(type & CUPS_PRINTER_DISCOVERED))
     goto enum_finished;
 
-#ifdef HAVE_DNSSD
- /*
-  * Get Bonjour-shared printers...
-  */
-
+  // Get DNS-SD printers...
   gettimeofday(&curtime, NULL);
 
-#  ifdef HAVE_MDNSRESPONDER
-  if (DNSServiceCreateConnection(&data.main_ref) != kDNSServiceErr_NoError)
+  if ((dnssd = cupsDNSSDNew(dnssd_error_cb, NULL)) == NULL)
   {
     DEBUG_puts("1cups_enum_dests: Unable to create service browser, returning 0.");
 
     cupsFreeDests(data.num_dests, data.dests);
     cupsArrayDelete(data.devices);
 
-    return (0);
+    return (false);
   }
 
-  main_fd = DNSServiceRefSockFD(data.main_ref);
-
-  ipp_ref = data.main_ref;
-  if (DNSServiceBrowse(&ipp_ref, kDNSServiceFlagsShareConnection, 0, "_ipp._tcp", NULL, (DNSServiceBrowseReply)cups_dnssd_browse_cb, &data) != kDNSServiceErr_NoError)
+  if (!cupsDNSSDBrowseNew(dnssd, CUPS_DNSSD_IF_INDEX_ANY, "_ipp._tcp", /*domain*/NULL, cups_dest_browse_cb, &data))
   {
     DEBUG_puts("1cups_enum_dests: Unable to create IPP browser, returning 0.");
-    DNSServiceRefDeallocate(data.main_ref);
+    cupsDNSSDDelete(dnssd);
 
     cupsFreeDests(data.num_dests, data.dests);
     cupsArrayDelete(data.devices);
 
-    return (0);
+    return (false);
   }
 
-  ipps_ref = data.main_ref;
-  if (DNSServiceBrowse(&ipps_ref, kDNSServiceFlagsShareConnection, 0, "_ipps._tcp", NULL, (DNSServiceBrowseReply)cups_dnssd_browse_cb, &data) != kDNSServiceErr_NoError)
+  if (!cupsDNSSDBrowseNew(dnssd, CUPS_DNSSD_IF_INDEX_ANY, "_ipps._tcp", /*domain*/NULL, cups_dest_browse_cb, &data))
   {
     DEBUG_puts("1cups_enum_dests: Unable to create IPPS browser, returning 0.");
-    DNSServiceRefDeallocate(data.main_ref);
-
-    cupsFreeDests(data.num_dests, data.dests);
-    cupsArrayDelete(data.devices);
-
-    return (0);
-  }
-
-#  else /* HAVE_AVAHI */
-  if ((data.simple_poll = avahi_simple_poll_new()) == NULL)
-  {
-    DEBUG_puts("1cups_enum_dests: Unable to create Avahi poll, returning 0.");
+    cupsDNSSDDelete(dnssd);
 
     cupsFreeDests(data.num_dests, data.dests);
     cupsArrayDelete(data.devices);
 
-    return (0);
-  }
-
-  avahi_simple_poll_set_func(data.simple_poll, cups_dnssd_poll_cb, &data);
-
-  data.client = avahi_client_new(avahi_simple_poll_get(data.simple_poll),
-         0, cups_dnssd_client_cb, &data,
-         &error);
-  if (!data.client)
-  {
-    DEBUG_puts("1cups_enum_dests: Unable to create Avahi client, returning 0.");
-    avahi_simple_poll_free(data.simple_poll);
-
-    cupsFreeDests(data.num_dests, data.dests);
-    cupsArrayDelete(data.devices);
-
-    return (0);
-  }
-
-  data.browsers = 1;
-  if ((ipp_ref = avahi_service_browser_new(data.client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_ipp._tcp", NULL, 0, cups_dnssd_browse_cb, &data)) == NULL)
-  {
-    DEBUG_puts("1cups_enum_dests: Unable to create Avahi IPP browser, returning 0.");
-
-    avahi_client_free(data.client);
-    avahi_simple_poll_free(data.simple_poll);
-
-    cupsFreeDests(data.num_dests, data.dests);
-    cupsArrayDelete(data.devices);
-
-    return (0);
-  }
-
-  data.browsers ++;
-  if ((ipps_ref = avahi_service_browser_new(data.client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, "_ipps._tcp", NULL, 0, cups_dnssd_browse_cb, &data)) == NULL)
-  {
-    DEBUG_puts("1cups_enum_dests: Unable to create Avahi IPPS browser, returning 0.");
-
-    avahi_service_browser_free(ipp_ref);
-    avahi_client_free(data.client);
-    avahi_simple_poll_free(data.simple_poll);
-
-    cupsFreeDests(data.num_dests, data.dests);
-    cupsArrayDelete(data.devices);
-
-    return (0);
+    return (false);
   }
-#  endif /* HAVE_MDNSRESPONDER */
 
   if (msec < 0)
     remaining = INT_MAX;
@@ -3718,106 +3270,56 @@ cups_enum_dests(
 
   while (remaining > 0 && (!cancel || !*cancel))
   {
-   /*
-    * Check for input...
-    */
-
+    // Check for input...
     DEBUG_printf("1cups_enum_dests: remaining=%d", remaining);
 
     cups_elapsed(&curtime);
 
-#  ifdef HAVE_MDNSRESPONDER
-    pfd.fd     = main_fd;
-    pfd.events = POLLIN;
-
-    nfds = poll(&pfd, 1, remaining > _CUPS_DNSSD_MAXTIME ? _CUPS_DNSSD_MAXTIME : remaining);
-
-    if (nfds > 0)
-      DNSServiceProcessResult(data.main_ref);
-    else if (nfds < 0 && errno != EINTR && errno != EAGAIN)
-      break;
+    remaining -= cups_elapsed(&curtime);
 
-#  else /* HAVE_AVAHI */
-    data.got_data = 0;
+    cupsRWLockRead(&data.rwlock);
 
-    if ((error = avahi_simple_poll_iterate(data.simple_poll, _CUPS_DNSSD_MAXTIME)) > 0)
+    for (i = 0, num_devices = cupsArrayCount(data.devices), count = 0, completed = 0; i < num_devices; i ++)
     {
-     /*
-      * We've been told to exit the loop.  Perhaps the connection to
-      * Avahi failed.
-      */
-
-      break;
-    }
-
-    DEBUG_printf("1cups_enum_dests: got_data=%d", data.got_data);
-#  endif /* HAVE_MDNSRESPONDER */
-
-    remaining -= cups_elapsed(&curtime);
+      device = cupsArrayIndex(data.devices, i);
 
-    for (device = (_cups_dnssd_device_t *)cupsArrayFirst(data.devices),
-             count = 0, completed = 0;
-         device;
-         device = (_cups_dnssd_device_t *)cupsArrayNext(data.devices))
-    {
-      if (device->ref)
+      if (device->query)
         count ++;
 
       if (device->state == _CUPS_DNSSD_ACTIVE)
         completed ++;
 
-      if (!device->ref && device->state == _CUPS_DNSSD_NEW)
+      if (!device->query && device->state == _CUPS_DNSSD_NEW)
       {
-        DEBUG_printf("1cups_enum_dests: Querying '%s'.", device->fullName);
-
-#  ifdef HAVE_MDNSRESPONDER
-        device->ref = data.main_ref;
+        DEBUG_printf("1cups_enum_dests: Querying '%s'.", device->fullname);
 
-        if (DNSServiceQueryRecord(&(device->ref), kDNSServiceFlagsShareConnection, 0, device->fullName, kDNSServiceType_TXT, kDNSServiceClass_IN, (DNSServiceQueryRecordReply)cups_dnssd_query_cb, &data) == kDNSServiceErr_NoError)
+       if ((device->query = cupsDNSSDQueryNew(dnssd, CUPS_DNSSD_IF_INDEX_ANY, device->fullname, CUPS_DNSSD_RRTYPE_TXT, cups_dest_query_cb, &data)) != NULL)
         {
           count ++;
         }
         else
         {
-          device->ref   = 0;
           device->state = _CUPS_DNSSD_ERROR;
 
           DEBUG_puts("1cups_enum_dests: Query failed.");
         }
-
-#  else /* HAVE_AVAHI */
-        if ((device->ref = avahi_record_browser_new(data.client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, device->fullName, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_TXT, 0, cups_dnssd_query_cb, &data)) != NULL)
-        {
-          DEBUG_printf("1cups_enum_dests: Query ref=%p", device->ref);
-          count ++;
-        }
-        else
-        {
-          device->state = _CUPS_DNSSD_ERROR;
-
-          DEBUG_printf("1cups_enum_dests: Query failed: %s", avahi_strerror(avahi_client_errno(data.client)));
-        }
-#  endif /* HAVE_MDNSRESPONDER */
       }
-      else if (device->ref && device->state == _CUPS_DNSSD_PENDING)
+      else if (device->query && device->state == _CUPS_DNSSD_PENDING)
       {
         completed ++;
 
-        DEBUG_printf("1cups_enum_dests: Query for \"%s\" is complete.", device->fullName);
+        DEBUG_printf("1cups_enum_dests: Query for \"%s\" is complete.", device->fullname);
 
         if ((device->type & mask) == type)
         {
-          cups_dest_t  *user_dest;     /* Destination from lpoptions */
+          cups_dest_t  *user_dest;     // Destination from lpoptions
 
           dest = &device->dest;
 
          if ((user_dest = cupsGetDest(dest->name, dest->instance, data.num_dests, data.dests)) != NULL)
          {
-          /*
-           * Apply user defaults to this destination for all instances...
-           */
-
-           for (j = user_dest - data.dests; j < data.num_dests; j ++, user_dest ++)
+           // Apply user defaults to this destination for all instances...
+           for (j = (size_t)(user_dest - data.dests); j < data.num_dests; j ++, user_dest ++)
            {
              if (_cups_strcasecmp(user_dest->name, dest->name))
              {
@@ -3826,10 +3328,7 @@ cups_enum_dests(
              }
 
              for (k = dest->num_options, option = dest->options; k > 0; k --, option ++)
-             {
-               if (!cupsGetOption(option->name, user_dest->num_options, user_dest->options))
-                 user_dest->num_options = cupsAddOption(option->name, option->value, user_dest->num_options, &user_dest->options);
-             }
+               user_dest->num_options = cupsAddOption(option->name, option->value, user_dest->num_options, &user_dest->options);
 
              if (!(*cb)(user_data, CUPS_DEST_FLAGS_NONE, user_dest))
                break;
@@ -3862,77 +3361,47 @@ cups_enum_dests(
       }
     }
 
-#  ifdef HAVE_AVAHI
-    DEBUG_printf("1cups_enum_dests: remaining=%d, browsers=%d, completed=%d, count=%d, devices count=%d", remaining, data.browsers, completed, count, cupsArrayCount(data.devices));
+    DEBUG_printf("1cups_enum_dests: remaining=%d, completed=%u, count=%u, devices count=%u", remaining, (unsigned)completed, (unsigned)count, (unsigned)cupsArrayCount(data.devices));
 
-    if (data.browsers == 0 && completed == cupsArrayCount(data.devices))
-      break;
-#  else
-    DEBUG_printf("1cups_enum_dests: remaining=%d, completed=%d, count=%d, devices count=%d", remaining, completed, count, cupsArrayCount(data.devices));
+    cupsRWUnlock(&data.rwlock);
 
-    if (completed == cupsArrayCount(data.devices))
+    if (completed && completed == cupsArrayCount(data.devices))
       break;
-#  endif /* HAVE_AVAHI */
-  }
-#endif /* HAVE_DNSSD */
 
- /*
-  * Return...
-  */
+    usleep(100000);
+  }
 
+  // Return...
   enum_finished:
 
-  cupsFreeDests(data.num_dests, data.dests);
+  cupsDNSSDDelete(dnssd);
 
-#ifdef HAVE_DNSSD
+  cupsFreeDests(data.num_dests, data.dests);
   cupsArrayDelete(data.devices);
 
-#  ifdef HAVE_MDNSRESPONDER
-  if (ipp_ref)
-    DNSServiceRefDeallocate(ipp_ref);
-
-  if (ipps_ref)
-    DNSServiceRefDeallocate(ipps_ref);
-
-  if (data.main_ref)
-    DNSServiceRefDeallocate(data.main_ref);
-
-#  else /* HAVE_AVAHI */
-  if (ipp_ref)
-    avahi_service_browser_free(ipp_ref);
-  if (ipps_ref)
-    avahi_service_browser_free(ipps_ref);
-
-  if (data.client)
-    avahi_client_free(data.client);
-  if (data.simple_poll)
-    avahi_simple_poll_free(data.simple_poll);
-#  endif /* HAVE_MDNSRESPONDER */
-#endif /* HAVE_DNSSD */
-
   DEBUG_puts("1cups_enum_dests: Returning 1.");
 
   return (1);
 }
 
 
-/*
- * 'cups_find_dest()' - Find a destination using a binary search.
- */
+//
+// 'cups_find_dest()' - Find a destination using a binary search.
+//
 
-static int                             /* O - Index of match */
-cups_find_dest(const char  *name,      /* I - Destination name */
-               const char  *instance,  /* I - Instance or NULL */
-               int         num_dests,  /* I - Number of destinations */
-              cups_dest_t *dests,      /* I - Destinations */
-              int         prev,        /* I - Previous index */
-              int         *rdiff)      /* O - Difference of match */
+static int                             // O - Index of match
+cups_find_dest(const char  *name,      // I - Destination name
+               const char  *instance,  // I - Instance or NULL
+               int         num_dests,  // I - Number of destinations
+              cups_dest_t *dests,      // I - Destinations
+              int         prev,        // I - Previous index
+              int         *rdiff)      // O - Difference of match
 {
-  int          left,                   /* Low mark for binary search */
-               right,                  /* High mark for binary search */
-               current,                /* Current index */
-               diff;                   /* Result of comparison */
-  cups_dest_t  key;                    /* Search key */
+  int          left,                   // Low mark for binary search
+               right,                  // High mark for binary search
+               current,                // Current index
+               diff;                   // Result of comparison
+  cups_dest_t  key;                    // Search key
 
 
   key.name     = (char *)name;
@@ -4009,9 +3478,9 @@ cups_find_dest(const char  *name, /* I - Destination name */
     }
   }
 
- /*
-  * Return the closest destination and the difference...
-  */
+  //
+  // Return the closest destination and the difference...
+  //
 
   *rdiff = diff;
 
@@ -4019,14 +3488,14 @@ cups_find_dest(const char  *name,       /* I - Destination name */
 }
 
 
-/*
- * 'cups_get_cb()' - Collect enumerated destinations.
- */
+//
+// 'cups_get_cb()' - Collect enumerated destinations.
+//
 
-static int                              /* O - 1 to continue, 0 to stop */
-cups_get_cb(_cups_getdata_t *data,      /* I - Data from cupsGetDests */
-            unsigned        flags,      /* I - Enumeration flags */
-            cups_dest_t     *dest)      /* I - Destination */
+static int                              // O - 1 to continue, 0 to stop
+cups_get_cb(_cups_getdata_t *data,      // I - Data from cupsGetDests
+            unsigned        flags,      // I - Enumeration flags
+            cups_dest_t     *dest)      // I - Destination
 {
   if (flags & CUPS_DEST_FLAGS_REMOVED)
   {
@@ -4049,21 +3518,21 @@ cups_get_cb(_cups_getdata_t *data,      /* I - Data from cupsGetDests */
 }
 
 
-/*
- * 'cups_get_default()' - Get the default destination from an lpoptions file.
- */
+//
+// 'cups_get_default()' - Get the default destination from an lpoptions file.
+//
 
-static char *                          /* O - Default destination or NULL */
-cups_get_default(const char *filename, /* I - File to read */
-                 char       *namebuf,  /* I - Name buffer */
-                size_t     namesize,   /* I - Size of name buffer */
-                const char **instance) /* I - Instance */
+static char *                          // O - Default destination or NULL
+cups_get_default(const char *filename, // I - File to read
+                 char       *namebuf,  // I - Name buffer
+                size_t     namesize,   // I - Size of name buffer
+                const char **instance) // I - Instance
 {
-  cups_file_t  *fp;                    /* lpoptions file */
-  char         line[8192],             /* Line from file */
-               *value,                 /* Value for line */
-               *nameptr;               /* Pointer into name */
-  int          linenum;                /* Current line */
+  cups_file_t  *fp;                    // lpoptions file
+  char         line[8192],             // Line from file
+               *value,                 // Value for line
+               *nameptr;               // Pointer into name
+  int          linenum;                // Current line
 
 
   *namebuf = '\0';
@@ -4098,45 +3567,45 @@ cups_get_default(const char *filename,  /* I - File to read */
 }
 
 
-/*
- * 'cups_get_dests()' - Get destinations from a file.
- */
+//
+// 'cups_get_dests()' - Get destinations from a file.
+//
 
-static int                             /* O - Number of destinations */
+static int                             // O - Number of destinations
 cups_get_dests(
-    const char  *filename,             /* I - File to read from */
-    const char  *match_name,           /* I - Destination name we want */
-    const char  *match_inst,           /* I - Instance name we want */
-    int         load_all,              /* I - Load all saved destinations? */
-    int         user_default_set,      /* I - User default printer set? */
-    int         num_dests,             /* I - Number of destinations */
-    cups_dest_t **dests)               /* IO - Destinations */
+    const char  *filename,             // I - File to read from
+    const char  *match_name,           // I - Destination name we want
+    const char  *match_inst,           // I - Instance name we want
+    int         load_all,              // I - Load all saved destinations?
+    int         user_default_set,      // I - User default printer set?
+    int         num_dests,             // I - Number of destinations
+    cups_dest_t **dests)               // IO - Destinations
 {
-  int          i;                      /* Looping var */
-  cups_dest_t  *dest;                  /* Current destination */
-  cups_file_t  *fp;                    /* File pointer */
-  char         line[8192],             /* Line from file */
-               *lineptr,               /* Pointer into line */
-               *name,                  /* Name of destination/option */
-               *instance;              /* Instance of destination */
-  int          linenum;                /* Current line number */
+  int          i;                      // Looping var
+  cups_dest_t  *dest;                  // Current destination
+  cups_file_t  *fp;                    // File pointer
+  char         line[8192],             // Line from file
+               *lineptr,               // Pointer into line
+               *name,                  // Name of destination/option
+               *instance;              // Instance of destination
+  int          linenum;                // Current line number
 
 
   DEBUG_printf("7cups_get_dests(filename=\"%s\", match_name=\"%s\", match_inst=\"%s\", load_all=%d, user_default_set=%d, num_dests=%d, dests=%p)", filename, match_name, match_inst, load_all, user_default_set, num_dests, (void *)dests);
 
- /*
-  * Try to open the file...
-  */
+  //
+  // Try to open the file...
+  //
 
   if ((fp = cupsFileOpen(filename, "r")) == NULL)
     return (num_dests);
 
- /*
-  * Read each printer; each line looks like:
-  *
-  *    Dest name[/instance] options
-  *    Default name[/instance] options
-  */
+  //
+  // Read each printer; each line looks like:
+  //
+  //    Dest name[/instance] options
+  //    Default name[/instance] options
+  //
 
   linenum = 0;
 
@@ -4253,9 +3722,9 @@ cups_get_dests(
     }
   }
 
- /*
-  * Close the file and return...
-  */
+  //
+  // Close the file and return...
+  //
 
   cupsFileClose(fp);
 
@@ -4263,26 +3732,26 @@ cups_get_dests(
 }
 
 
-/*
- * 'cups_make_string()' - Make a comma-separated string of values from an IPP
- *                        attribute.
- */
+//
+// 'cups_make_string()' - Make a comma-separated string of values from an IPP
+//                        attribute.
+//
 
-static char *                          /* O - New string */
+static char *                          // O - New string
 cups_make_string(
-    ipp_attribute_t *attr,             /* I - Attribute to convert */
-    char            *buffer,           /* I - Buffer */
-    size_t          bufsize)           /* I - Size of buffer */
+    ipp_attribute_t *attr,             // I - Attribute to convert
+    char            *buffer,           // I - Buffer
+    size_t          bufsize)           // I - Size of buffer
 {
-  int          i;                      /* Looping var */
-  char         *ptr,                   /* Pointer into buffer */
-               *end,                   /* Pointer to end of buffer */
-               *valptr;                /* Pointer into string attribute */
+  int          i;                      // Looping var
+  char         *ptr,                   // Pointer into buffer
+               *end,                   // Pointer to end of buffer
+               *valptr;                // Pointer into string attribute
 
 
- /*
-  * Return quickly if we have a single string value...
-  */
+  //
+  // Return quickly if we have a single string value...
+  //
 
   if (attr->num_values == 1 &&
       attr->value_tag != IPP_TAG_INTEGER &&
@@ -4291,10 +3760,10 @@ cups_make_string(
       attr->value_tag != IPP_TAG_RANGE)
     return (attr->values[0].string.text);
 
- /*
-  * Copy the values to the string, separating with commas and escaping strings
-  * as needed...
-  */
+  //
+  // Copy the values to the string, separating with commas and escaping strings
+  // as needed...
+  //
 
   end = buffer + bufsize - 1;
 
@@ -4352,14 +3821,14 @@ cups_make_string(
 }
 
 
-/*
- * 'cups_name_cb()' - Find an enumerated destination.
- */
+//
+// 'cups_name_cb()' - Find an enumerated destination.
+//
 
-static int                              /* O - 1 to continue, 0 to stop */
-cups_name_cb(_cups_namedata_t *data,    /* I - Data from cupsGetNamedDest */
-             unsigned         flags,    /* I - Enumeration flags */
-             cups_dest_t      *dest)    /* I - Destination */
+static int                              // O - 1 to continue, 0 to stop
+cups_name_cb(_cups_namedata_t *data,    // I - Data from cupsGetNamedDest
+             unsigned         flags,    // I - Enumeration flags
+             cups_dest_t      *dest)    // I - Destination
 {
   DEBUG_printf("2cups_name_cb(data=%p(%s), flags=%x, dest=%p(%s)", (void *)data, data->name, flags, (void *)dest, dest->name);
 
@@ -4377,18 +3846,18 @@ cups_name_cb(_cups_namedata_t *data,    /* I - Data from cupsGetNamedDest */
 }
 
 
-/*
- * 'cups_queue_name()' - Create a local queue name based on the service name.
- */
+//
+// 'cups_queue_name()' - Create a local queue name based on the service name.
+//
 
 static void
 cups_queue_name(
-    char       *name,                  /* I - Name buffer */
-    const char *serviceName,           /* I - Service name */
-    size_t     namesize)               /* I - Size of name buffer */
+    char       *name,                  // I - Name buffer
+    const char *serviceName,           // I - Service name
+    size_t     namesize)               // I - Size of name buffer
 {
-  const char   *ptr;                   /* Pointer into serviceName */
-  char         *nameptr;               /* Pointer into name */
+  const char   *ptr;                   // Pointer into serviceName
+  char         *nameptr;               // Pointer into name
 
 
   for (nameptr = name, ptr = serviceName; *ptr && nameptr < (name + namesize - 1); ptr ++)
@@ -4403,13 +3872,26 @@ cups_queue_name(
       *nameptr++ = '_';
   }
 
- /*
-  * Remove an underscore if it is the last character and isn't the only
-  * character in the name...
-  */
+  //
+  // Remove an underscore if it is the last character and isn't the only
+  // character in the name...
+  //
 
   if (nameptr > (name + 1) && nameptr[-1] == '_')
     nameptr --;
 
   *nameptr = '\0';
 }
+
+
+//
+// 'dnssd_error_cb()' - Report an error.
+//
+
+static void
+dnssd_error_cb(void       *cb_data,    // I - Callback data (unused)
+               const char *message)    // I - Message
+{
+  (void)cb_data;
+  _cupsSetError(IPP_STATUS_ERROR_INTERNAL, message, 0);
+}
index 7c304dfca7369fa7dd57d7063fb34ace43e2d580..4e29a87b35ed7470627d2e34d5cc8277e429c1f2 100644 (file)
@@ -18,9 +18,6 @@
 #  include "config.h"
 #  include <stdio.h>
 #  include <cups/transcode.h>
-#  ifdef __APPLE__
-#    include <CoreFoundation/CoreFoundation.h>
-#  endif /* __APPLE__ */
 
 #  ifdef __cplusplus
 extern "C" {
@@ -59,10 +56,6 @@ typedef struct _cups_message_s               /**** Message catalog entry ****/
  * Prototypes...
  */
 
-#  ifdef __APPLE__
-extern const char      *_cupsAppleLanguage(const char *locale, char *language, size_t langsize) _CUPS_PRIVATE;
-extern const char      *_cupsAppleLocale(CFStringRef languageName, char *locale, size_t localesize) _CUPS_PRIVATE;
-#  endif /* __APPLE__ */
 extern void            _cupsCharmapFlush(void) _CUPS_INTERNAL;
 extern const char      *_cupsEncodingName(cups_encoding_t encoding) _CUPS_PRIVATE;
 extern void            _cupsLangPrintError(const char *prefix, const char *message) _CUPS_PRIVATE;
index f4a3b771c3b8f2413bc73d88553cb97ecf99d597..1f375c6aa2a043593092756db013ef9adf6bc2a0 100644 (file)
@@ -105,45 +105,12 @@ static const char * const lang_encodings[] =
                          "shift_jisx0213"
                        };
 
-#ifdef __APPLE__
-typedef struct
-{
-  const char * const language;         /* Language ID */
-  const char * const locale;           /* Locale ID */
-} _apple_language_locale_t;
-
-static const _apple_language_locale_t apple_language_locale[] =
-{                                      /* Language to locale ID LUT */
-  { "en",         "en_US" },
-  { "nb",         "no" },
-  { "nb_NO",      "no" },
-  { "zh-Hans",    "zh_CN" },
-  { "zh_HANS",    "zh_CN" },
-  { "zh-Hant",    "zh_TW" },
-  { "zh_HANT",    "zh_TW" },
-  { "zh-Hant_CN", "zh_TW" }
-};
-#endif /* __APPLE__ */
-
 
 /*
  * Local functions...
  */
 
 
-#ifdef __APPLE__
-static const char      *appleLangDefault(void);
-#  ifdef CUPS_BUNDLEDIR
-#    ifndef CF_RETURNS_RETAINED
-#      if __has_feature(attribute_cf_returns_retained)
-#        define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
-#      else
-#        define CF_RETURNS_RETAINED
-#      endif /* __has_feature(attribute_cf_returns_retained) */
-#    endif /* !CF_RETURNED_RETAINED */
-static cups_array_t    *appleMessageLoad(const char *locale) CF_RETURNS_RETAINED;
-#  endif /* CUPS_BUNDLEDIR */
-#endif /* __APPLE__ */
 static cups_lang_t     *cups_cache_lookup(const char *name, cups_encoding_t encoding);
 static int             cups_message_compare(_cups_message_t *m1, _cups_message_t *m2);
 static void            cups_message_free(_cups_message_t *m);
@@ -153,183 +120,6 @@ static int                cups_read_strings(cups_file_t *fp, int flags, cups_array_t *a);
 static void            cups_unquote(char *d, const char *s);
 
 
-#ifdef __APPLE__
-/*
- * '_cupsAppleLanguage()' - Get the Apple language identifier associated with a
- *                          locale ID.
- */
-
-const char *                           /* O - Language ID */
-_cupsAppleLanguage(const char *locale, /* I - Locale ID */
-                   char       *language,/* I - Language ID buffer */
-                   size_t     langsize)        /* I - Size of language ID buffer */
-{
-  int          i;                      /* Looping var */
-  CFStringRef  localeid,               /* CF locale identifier */
-               langid;                 /* CF language identifier */
-
-
- /*
-  * Copy the locale name and convert, as needed, to the Apple-specific
-  * locale identifier...
-  */
-
-  switch (strlen(locale))
-  {
-    default :
-        /*
-        * Invalid locale...
-        */
-
-        cupsCopyString(language, "en", langsize);
-        break;
-
-    case 2 :
-        cupsCopyString(language, locale, langsize);
-        break;
-
-    case 5 :
-        cupsCopyString(language, locale, langsize);
-
-       if (language[2] == '-')
-       {
-        /*
-         * Convert ll-cc to ll_CC...
-         */
-
-         language[2] = '_';
-         language[3] = (char)toupper(language[3] & 255);
-         language[4] = (char)toupper(language[4] & 255);
-       }
-       break;
-  }
-
-  for (i = 0;
-       i < (int)(sizeof(apple_language_locale) /
-                sizeof(apple_language_locale[0]));
-       i ++)
-    if (!strcmp(locale, apple_language_locale[i].locale))
-    {
-      cupsCopyString(language, apple_language_locale[i].language, sizeof(language));
-      break;
-    }
-
- /*
-  * Attempt to map the locale ID to a language ID...
-  */
-
-  if ((localeid = CFStringCreateWithCString(kCFAllocatorDefault, language,
-                                            kCFStringEncodingASCII)) != NULL)
-  {
-    if ((langid = CFLocaleCreateCanonicalLanguageIdentifierFromString(
-                      kCFAllocatorDefault, localeid)) != NULL)
-    {
-      CFStringGetCString(langid, language, (CFIndex)langsize, kCFStringEncodingASCII);
-      CFRelease(langid);
-    }
-
-    CFRelease(localeid);
-  }
-
- /*
-  * Return what we got...
-  */
-
-  return (language);
-}
-
-
-/*
- * '_cupsAppleLocale()' - Get the locale associated with an Apple language ID.
- */
-
-const char *                                   /* O - Locale */
-_cupsAppleLocale(CFStringRef languageName,     /* I - Apple language ID */
-                 char        *locale,          /* I - Buffer for locale */
-                size_t      localesize)        /* I - Size of buffer */
-{
-  int          i;                      /* Looping var */
-  CFStringRef  localeName;             /* Locale as a CF string */
-#ifdef DEBUG
-  char          temp[1024];             /* Temporary string */
-
-
-  if (!CFStringGetCString(languageName, temp, (CFIndex)sizeof(temp), kCFStringEncodingASCII))
-    temp[0] = '\0';
-
-  DEBUG_printf("_cupsAppleLocale(languageName=%p(%s), locale=%p, localsize=%d)", (void *)languageName, temp, (void *)locale, (int)localesize);
-#endif /* DEBUG */
-
-  localeName = CFLocaleCreateCanonicalLocaleIdentifierFromString(kCFAllocatorDefault, languageName);
-
-  if (localeName)
-  {
-   /*
-    * Copy the locale name and tweak as needed...
-    */
-
-    if (!CFStringGetCString(localeName, locale, (CFIndex)localesize, kCFStringEncodingASCII))
-      *locale = '\0';
-
-    DEBUG_printf("_cupsAppleLocale: locale=\"%s\"", locale);
-
-    CFRelease(localeName);
-
-   /*
-    * Map new language identifiers to locales...
-    */
-
-    for (i = 0;
-        i < (int)(sizeof(apple_language_locale) /
-                  sizeof(apple_language_locale[0]));
-        i ++)
-    {
-      size_t len = strlen(apple_language_locale[i].language);
-
-      if (!strcmp(locale, apple_language_locale[i].language) ||
-          (!strncmp(locale, apple_language_locale[i].language, len) && (locale[len] == '_' || locale[len] == '-')))
-      {
-        DEBUG_printf("_cupsAppleLocale: Updating locale to \"%s\".", apple_language_locale[i].locale);
-       cupsCopyString(locale, apple_language_locale[i].locale, localesize);
-       break;
-      }
-    }
-  }
-  else
-  {
-   /*
-    * Just try the Apple language name...
-    */
-
-    if (!CFStringGetCString(languageName, locale, (CFIndex)localesize, kCFStringEncodingASCII))
-      *locale = '\0';
-  }
-
-  if (!*locale)
-  {
-    DEBUG_puts("_cupsAppleLocale: Returning NULL.");
-    return (NULL);
-  }
-
- /*
-  * Convert language subtag into region subtag...
-  */
-
-  if (locale[2] == '-')
-    locale[2] = '_';
-  else if (locale[3] == '-')
-    locale[3] = '_';
-
-  if (!strchr(locale, '.'))
-    cupsConcatString(locale, ".UTF-8", localesize);
-
-  DEBUG_printf("_cupsAppleLocale: Returning \"%s\".", locale);
-
-  return (locale);
-}
-#endif /* __APPLE__ */
-
-
 /*
  * '_cupsEncodingName()' - Return the character encoding name string
  *                         for the given encoding enumeration.
@@ -444,9 +234,7 @@ cups_lang_t *                               /* O - Language data */
 cupsLangGet(const char *language)      /* I - Language or locale */
 {
   int                  i;              /* Looping var */
-#ifndef __APPLE__
   char                 locale[255];    /* Copy of locale name */
-#endif /* !__APPLE__ */
   char                 langname[16],   /* Requested language name */
                        country[16],    /* Country code */
                        charset[16],    /* Character set */
@@ -500,27 +288,6 @@ cupsLangGet(const char *language)  /* I - Language or locale */
 
   DEBUG_printf("2cupsLangGet(language=\"%s\")", language);
 
-#ifdef __APPLE__
- /*
-  * Set the character set to UTF-8...
-  */
-
-  cupsCopyString(charset, "UTF8", sizeof(charset));
-
- /*
-  * Apple's setlocale doesn't give us the user's localization
-  * preference so we have to look it up this way...
-  */
-
-  if (!language)
-  {
-    if (!getenv("SOFTWARE") || (language = getenv("LANG")) == NULL)
-      language = appleLangDefault();
-
-    DEBUG_printf("4cupsLangGet: language=\"%s\"", language);
-  }
-
-#else
  /*
   * Set the charset to "unknown"...
   */
@@ -540,11 +307,11 @@ cupsLangGet(const char *language) /* I - Language or locale */
     * "POSIX", use the environment to get the default...
     */
 
-#  ifdef LC_MESSAGES
+#ifdef LC_MESSAGES
     ptr = setlocale(LC_MESSAGES, NULL);
-#  else
+#else
     ptr = setlocale(LC_ALL, NULL);
-#  endif /* LC_MESSAGES */
+#endif /* LC_MESSAGES */
 
     DEBUG_printf("4cupsLangGet: current locale is \"%s\"", ptr);
 
@@ -597,7 +364,6 @@ cupsLangGet(const char *language)   /* I - Language or locale */
       DEBUG_printf("4cupsLangGet: new language value is \"%s\"", language);
     }
   }
-#endif /* __APPLE__ */
 
  /*
   * If "language" is NULL at this point, then chances are we are using
@@ -882,15 +648,6 @@ _cupsLangString(cups_lang_t *lang, /* I - Language */
 void
 _cupsMessageFree(cups_array_t *a)      /* I - Message array */
 {
-#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
- /*
-  * Release the cups.strings dictionary as needed...
-  */
-
-  if (cupsArrayUserData(a))
-    CFRelease((CFDictionaryRef)cupsArrayUserData(a));
-#endif /* __APPLE__ && CUPS_BUNDLEDIR */
-
  /*
   * Free the array...
   */
@@ -1159,46 +916,6 @@ _cupsMessageLookup(cups_array_t *a,       /* I - Message array */
   key.msg = (char *)m;
   match   = (_cups_message_t *)cupsArrayFind(a, &key);
 
-#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
-  if (!match && cupsArrayUserData(a))
-  {
-   /*
-    * Try looking the string up in the cups.strings dictionary...
-    */
-
-    CFDictionaryRef    dict;           /* cups.strings dictionary */
-    CFStringRef                cfm,            /* Message as a CF string */
-                       cfstr;          /* Localized text as a CF string */
-
-    dict       = (CFDictionaryRef)cupsArrayUserData(a);
-    cfm        = CFStringCreateWithCString(kCFAllocatorDefault, m, kCFStringEncodingUTF8);
-    match      = calloc(1, sizeof(_cups_message_t));
-    match->msg = strdup(m);
-    cfstr      = cfm ? CFDictionaryGetValue(dict, cfm) : NULL;
-
-    if (cfstr)
-    {
-      char     buffer[1024];           /* Message buffer */
-
-      CFStringGetCString(cfstr, buffer, sizeof(buffer), kCFStringEncodingUTF8);
-      match->str = strdup(buffer);
-
-      DEBUG_printf("1_cupsMessageLookup: Found \"%s\" as \"%s\"...", m, buffer);
-    }
-    else
-    {
-      match->str = strdup(m);
-
-      DEBUG_printf("1_cupsMessageLookup: Did not find \"%s\"...", m);
-    }
-
-    cupsArrayAdd(a, match);
-
-    if (cfm)
-      CFRelease(cfm);
-  }
-#endif /* __APPLE__ && CUPS_BUNDLEDIR */
-
   if (match && match->str)
     return (match->str);
   else
@@ -1271,324 +988,6 @@ _cupsMessageSave(const char   *filename,/* I - Output filename */
 }
 
 
-#ifdef __APPLE__
-/*
- * 'appleLangDefault()' - Get the default locale string.
- */
-
-static const char *                    /* O - Locale string */
-appleLangDefault(void)
-{
-  CFBundleRef          bundle;         /* Main bundle (if any) */
-  CFArrayRef           bundleList;     /* List of localizations in bundle */
-  CFPropertyListRef    localizationList = NULL;
-                                       /* List of localization data */
-  CFStringRef          languageName;   /* Current name */
-  char                 *lang;          /* LANG environment variable */
-  _cups_globals_t      *cg = _cupsGlobals();
-                                       /* Pointer to library globals */
-
-
-  DEBUG_puts("2appleLangDefault()");
-
- /*
-  * Only do the lookup and translation the first time.
-  */
-
-  if (!cg->language[0])
-  {
-    if (getenv("SOFTWARE") != NULL && (lang = getenv("LANG")) != NULL)
-    {
-      DEBUG_printf("3appleLangDefault: Using LANG=%s", lang);
-      cupsCopyString(cg->language, lang, sizeof(cg->language));
-      return (cg->language);
-    }
-    else if ((bundle = CFBundleGetMainBundle()) != NULL &&
-             (bundleList = CFBundleCopyBundleLocalizations(bundle)) != NULL)
-    {
-      CFURLRef resources = CFBundleCopyResourcesDirectoryURL(bundle);
-
-      DEBUG_puts("3appleLangDefault: Getting localizationList from bundle.");
-
-      if (resources)
-      {
-        CFStringRef    cfpath = CFURLCopyPath(resources);
-       char            path[1024];
-
-        if (cfpath)
-       {
-        /*
-         * See if we have an Info.plist file in the bundle...
-         */
-
-         CFStringGetCString(cfpath, path, sizeof(path), kCFStringEncodingUTF8);
-         DEBUG_printf("3appleLangDefault: Got a resource URL (\"%s\")", path);
-         cupsConcatString(path, "Contents/Info.plist", sizeof(path));
-
-          if (!access(path, R_OK))
-           localizationList = CFBundleCopyPreferredLocalizationsFromArray(bundleList);
-         else
-           DEBUG_puts("3appleLangDefault: No Info.plist, ignoring resource URL...");
-
-         CFRelease(cfpath);
-       }
-
-       CFRelease(resources);
-      }
-      else
-        DEBUG_puts("3appleLangDefault: No resource URL.");
-
-      CFRelease(bundleList);
-    }
-
-    if (!localizationList)
-    {
-      DEBUG_puts("3appleLangDefault: Getting localizationList from preferences.");
-
-      localizationList =
-         CFPreferencesCopyAppValue(CFSTR("AppleLanguages"),
-                                   kCFPreferencesCurrentApplication);
-    }
-
-    if (localizationList)
-    {
-#ifdef DEBUG
-      if (CFGetTypeID(localizationList) == CFArrayGetTypeID())
-        DEBUG_printf("3appleLangDefault: Got localizationList, %d entries.", (int)CFArrayGetCount(localizationList));
-      else
-        DEBUG_puts("3appleLangDefault: Got localizationList but not an array.");
-#endif /* DEBUG */
-
-      if (CFGetTypeID(localizationList) == CFArrayGetTypeID() &&
-         CFArrayGetCount(localizationList) > 0)
-      {
-       languageName = CFArrayGetValueAtIndex(localizationList, 0);
-
-       if (languageName &&
-           CFGetTypeID(languageName) == CFStringGetTypeID())
-       {
-         if (_cupsAppleLocale(languageName, cg->language, sizeof(cg->language)))
-           DEBUG_printf("3appleLangDefault: cg->language=\"%s\"", cg->language);
-         else
-           DEBUG_puts("3appleLangDefault: Unable to get locale.");
-       }
-      }
-
-      CFRelease(localizationList);
-    }
-
-   /*
-    * If we didn't find the language, default to en_US...
-    */
-
-    if (!cg->language[0])
-    {
-      DEBUG_puts("3appleLangDefault: Defaulting to en_US.");
-      cupsCopyString(cg->language, "en_US.UTF-8", sizeof(cg->language));
-    }
-  }
-  else
-    DEBUG_printf("3appleLangDefault: Using previous locale \"%s\".", cg->language);
-
- /*
-  * Return the cached locale...
-  */
-
-  return (cg->language);
-}
-
-
-#  ifdef CUPS_BUNDLEDIR
-/*
- * 'appleMessageLoad()' - Load a message catalog from a localizable bundle.
- */
-
-static cups_array_t *                  /* O - Message catalog */
-appleMessageLoad(const char *locale)   /* I - Locale ID */
-{
-  char                 filename[1024], /* Path to cups.strings file */
-                       applelang[256], /* Apple language ID */
-                       baselang[4];    /* Base language */
-  CFURLRef             url;            /* URL to cups.strings file */
-  CFReadStreamRef      stream = NULL;  /* File stream */
-  CFPropertyListRef    plist = NULL;   /* Localization file */
-#ifdef DEBUG
-  const char            *cups_strings = getenv("CUPS_STRINGS");
-                                        /* Test strings file */
-  CFErrorRef           error = NULL;   /* Error when opening file */
-#endif /* DEBUG */
-
-
-  DEBUG_printf("appleMessageLoad(locale=\"%s\")", locale);
-
- /*
-  * Load the cups.strings file...
-  */
-
-#ifdef DEBUG
-  if (cups_strings)
-  {
-    DEBUG_puts("1appleMessageLoad: Using debug CUPS_STRINGS file.");
-    cupsCopyString(filename, cups_strings, sizeof(filename));
-  }
-  else
-#endif /* DEBUG */
-
-  snprintf(filename, sizeof(filename),
-           CUPS_BUNDLEDIR "/Resources/%s.lproj/cups.strings",
-          _cupsAppleLanguage(locale, applelang, sizeof(applelang)));
-
-  if (access(filename, 0))
-  {
-   /*
-    * <rdar://problem/22086642>
-    *
-    * Try with original locale string...
-    */
-
-    DEBUG_printf("1appleMessageLoad: \"%s\": %s", filename, strerror(errno));
-    snprintf(filename, sizeof(filename), CUPS_BUNDLEDIR "/Resources/%s.lproj/cups.strings", locale);
-  }
-
-  if (access(filename, 0))
-  {
-   /*
-    * <rdar://problem/25292403>
-    *
-    * Try with just the language code...
-    */
-
-    DEBUG_printf("1appleMessageLoad: \"%s\": %s", filename, strerror(errno));
-
-    cupsCopyString(baselang, locale, sizeof(baselang));
-    if (baselang[3] == '-' || baselang[3] == '_')
-      baselang[3] = '\0';
-
-    snprintf(filename, sizeof(filename), CUPS_BUNDLEDIR "/Resources/%s.lproj/cups.strings", baselang);
-  }
-
-  if (access(filename, 0))
-  {
-   /*
-    * Try alternate lproj directory names...
-    */
-
-    DEBUG_printf("1appleMessageLoad: \"%s\": %s", filename, strerror(errno));
-
-    if (!strncmp(locale, "en", 2))
-      locale = "English";
-    else if (!strncmp(locale, "nb", 2))
-      locale = "no";
-    else if (!strncmp(locale, "nl", 2))
-      locale = "Dutch";
-    else if (!strncmp(locale, "fr", 2))
-      locale = "French";
-    else if (!strncmp(locale, "de", 2))
-      locale = "German";
-    else if (!strncmp(locale, "it", 2))
-      locale = "Italian";
-    else if (!strncmp(locale, "ja", 2))
-      locale = "Japanese";
-    else if (!strncmp(locale, "es", 2))
-      locale = "Spanish";
-    else if (!strcmp(locale, "zh_HK") || !strncasecmp(locale, "zh-Hant", 7) || !strncasecmp(locale, "zh_Hant", 7))
-    {
-     /*
-      * <rdar://problem/22130168>
-      * <rdar://problem/27245567>
-      *
-      * Try zh_TW first, then zh...  Sigh...
-      */
-
-      if (!access(CUPS_BUNDLEDIR "/Resources/zh_TW.lproj/cups.strings", 0))
-        locale = "zh_TW";
-      else
-        locale = "zh";
-    }
-    else if (strstr(locale, "_") != NULL || strstr(locale, "-") != NULL)
-    {
-     /*
-      * Drop country code, just try language...
-      */
-
-      cupsCopyString(baselang, locale, sizeof(baselang));
-      if (baselang[2] == '-' || baselang[2] == '_')
-        baselang[2] = '\0';
-
-      locale = baselang;
-    }
-
-    snprintf(filename, sizeof(filename),
-            CUPS_BUNDLEDIR "/Resources/%s.lproj/cups.strings", locale);
-  }
-
-  DEBUG_printf("1appleMessageLoad: filename=\"%s\"", filename);
-
-  url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault,
-                                                (UInt8 *)filename,
-                                               (CFIndex)strlen(filename), false);
-  if (url)
-  {
-    stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, url);
-    if (stream)
-    {
-     /*
-      * Read the property list containing the localization data.
-      *
-      * NOTE: This code currently generates a clang "potential leak"
-      * warning, but the object is released in _cupsMessageFree().
-      */
-
-      CFReadStreamOpen(stream);
-
-#ifdef DEBUG
-      plist = CFPropertyListCreateWithStream(kCFAllocatorDefault, stream, 0,
-                                             kCFPropertyListImmutable, NULL,
-                                             &error);
-      if (error)
-      {
-        CFStringRef    msg = CFErrorCopyDescription(error);
-                                       /* Error message */
-
-        CFStringGetCString(msg, filename, sizeof(filename),
-                           kCFStringEncodingUTF8);
-        DEBUG_printf("1appleMessageLoad: %s", filename);
-
-       CFRelease(msg);
-        CFRelease(error);
-      }
-
-#else
-      plist = CFPropertyListCreateWithStream(kCFAllocatorDefault, stream, 0,
-                                             kCFPropertyListImmutable, NULL,
-                                             NULL);
-#endif /* DEBUG */
-
-      if (plist && CFGetTypeID(plist) != CFDictionaryGetTypeID())
-      {
-         CFRelease(plist);
-         plist = NULL;
-      }
-
-      CFRelease(stream);
-    }
-
-    CFRelease(url);
-  }
-
-  DEBUG_printf("1appleMessageLoad: url=%p, stream=%p, plist=%p", url, stream, plist);
-
- /*
-  * Create and return an empty array to act as a cache for messages, passing the
-  * plist as the user data.
-  */
-
-  return (_cupsMessageNew((void *)plist));
-}
-#  endif /* CUPS_BUNDLEDIR */
-#endif /* __APPLE__ */
-
-
 /*
  * 'cups_cache_lookup()' - Lookup a language in the cache...
  */
@@ -1665,10 +1064,6 @@ cups_message_free(_cups_message_t *m)    /* I - Message */
 static void
 cups_message_load(cups_lang_t *lang)   /* I - Language */
 {
-#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
-  lang->strings = appleMessageLoad(lang->language);
-
-#else
   char                 filename[1024]; /* Filename for language locale file */
   _cups_globals_t      *cg = _cupsGlobals();
                                        /* Pointer to library globals */
@@ -1703,7 +1098,6 @@ cups_message_load(cups_lang_t *lang)      /* I - Language */
   */
 
   lang->strings = _cupsMessageLoad(filename, _CUPS_MESSAGE_UNQUOTE);
-#endif /* __APPLE__ && CUPS_BUNDLEDIR */
 }
 
 
index e0cd6b4f420ffefe7ea01973c756af50d2e006e1..ee231eaea7ad28fa72c32506eddd2534c42bec08 100644 (file)
@@ -19,9 +19,6 @@
 
 #include "cups-private.h"
 #include "ppd-private.h"
-#ifdef __APPLE__
-#  include <CoreFoundation/CoreFoundation.h>
-#endif /* __APPLE__ */
 #include <cups/dir.h>
 
 
@@ -30,9 +27,6 @@
  */
 
 static int     show_ppd(const char *filename);
-#ifdef __APPLE__
-static int     test_apple(void);
-#endif // __APPLE__
 static int     test_language(const char *locale);
 static int     test_string(cups_lang_t *language, const char *msgid);
 static void    usage(void);
@@ -147,10 +141,6 @@ main(int  argc,                            /* I - Number of command-line arguments */
       cupsDirClose(dir);
     }
 
-#ifdef __APPLE__
-    errors += test_apple();
-#endif // __APPLE__
-
     if (!errors)
       puts("ALL TESTS PASSED");
   }
@@ -210,101 +200,6 @@ show_ppd(const char *filename)            /* I - Filename */
 }
 
 
-#ifdef __APPLE__
-/*
- * 'test_apple()' - Test macOS locale handing...
- */
-
-static int                             /* O - Number of errors */
-test_apple(void)
-{
-  int          errors = 0;             /* Number of errors */
-  CFIndex      i,                      /* Looping var */
-               num_locales;            /* Number of locales */
-  CFArrayRef   locales;                /* Locales */
-  CFStringRef  locale_id,              /* Current locale ID */
-               language_id;            /* Current language ID */
-  cups_lang_t  *language = NULL;       /* Message catalog */
-  char         locale_str[256],        /* Locale ID C string */
-               language_str[256],      /* Language ID C string */
-               buffer[1024],           /* String buffer */
-               *bufptr;                /* Pointer to ".UTF-8" in POSIX locale */
-  size_t       buflen;                 /* Length of POSIX locale */
-
-
- /*
-  * Test all possible language IDs for compatibility with _cupsAppleLocale...
-  */
-
-  locales     = CFLocaleCopyAvailableLocaleIdentifiers();
-  num_locales = CFArrayGetCount(locales);
-
-  printf("CFLocaleCopyAvailableLocaleIdentifiers: %d locales\n", (int)num_locales);
-
-  for (i = 0; i < num_locales; i ++)
-  {
-    locale_id   = CFArrayGetValueAtIndex(locales, i);
-    language_id = CFLocaleCreateCanonicalLanguageIdentifierFromString(kCFAllocatorDefault, locale_id);
-
-    printf("CFStringGetCString(locale_id %d): ", (int)i);
-    if (!locale_id || !CFStringGetCString(locale_id, locale_str, (CFIndex)sizeof(locale_str), kCFStringEncodingASCII))
-    {
-      puts("FAIL");
-      errors ++;
-      continue;
-    }
-    else
-      printf("PASS (\"%s\")\n", locale_str);
-
-    printf("CFStringGetCString(language_id %d): ", (int)i);
-    if (!language_id || !CFStringGetCString(language_id, language_str, (CFIndex)sizeof(language_str), kCFStringEncodingASCII))
-    {
-      printf("%d %s: FAIL (unable to get language ID string)\n", (int)i + 1, locale_str);
-      errors ++;
-      continue;
-    }
-    else
-      printf("PASS (\"%s\")\n", language_str);
-
-    printf("_cupsAppleLocale(\"%s\"): ", language_str);
-    if (!_cupsAppleLocale(language_id, buffer, sizeof(buffer)))
-    {
-      puts("FAIL");
-      errors ++;
-      continue;
-    }
-    else
-      printf("PASS (\"%s\")\n", buffer);
-
-    if ((bufptr = strstr(buffer, ".UTF-8")) != NULL)
-      buflen = (size_t)(bufptr - buffer);
-    else
-      buflen = strlen(buffer);
-
-    printf("cupsLangGet(\"%s\"): ", buffer);
-    if ((language = cupsLangGet(buffer)) == NULL)
-    {
-      puts("FAIL");
-      errors ++;
-      continue;
-    }
-    else if (strncasecmp(language->language, buffer, buflen))
-    {
-      printf("FAIL (got \"%s\")\n", language->language);
-      errors ++;
-      continue;
-    }
-    else
-      puts("PASS");
-  }
-
-  CFRelease(locales);
-
-  return (errors);
-}
-#endif // __APPLE__
-
-
 /*
  * 'test_language()' - Test a specific language...
  */
index 660d64d8a66cb72901fa6ef1232124c10ba39e39..f2110438984f0f63d71d60ade44052562b329da3 100644 (file)
@@ -31,9 +31,6 @@ typedef enum
 // Local functions...
 //
 
-#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
-static void    apple_add_message(CFStringRef key, CFStringRef val, ppdcCatalog *c);
-#endif /* __APPLE__ && CUPS_BUNDLEDIR */
 static int     get_utf8(char *&ptr);
 static int     get_utf16(cups_file_t *fp, ppdc_cs_t &cs);
 static int     put_utf8(int ch, char *&ptr, char *end);
@@ -58,70 +55,7 @@ ppdcCatalog::ppdcCatalog(const char *l,      // I - Locale
   {
     // Try loading the base messages for this locale...
     char       pofile[1024];           // Message catalog file
-
-
-#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
-    char               applelang[256]; // Apple language ID
-    CFURLRef           url;            // URL to cups.strings file
-    CFReadStreamRef    stream = NULL;  // File stream
-    CFPropertyListRef  plist = NULL;   // Localization file
-
-    snprintf(pofile, sizeof(pofile), CUPS_BUNDLEDIR "/Resources/%s.lproj/cups.strings", _cupsAppleLanguage(l, applelang, sizeof(applelang)));
-    if (access(pofile, 0))
-    {
-      // Try alternate lproj directory names...
-      const char *tl = l;              // Temporary locale string
-
-      if (!strncmp(l, "en", 2))
-       tl = "English";
-      else if (!strncmp(l, "nb", 2))
-        tl = "no";
-      else if (!strncmp(l, "nl", 2))
-       tl = "Dutch";
-      else if (!strncmp(l, "fr", 2))
-       tl = "French";
-      else if (!strncmp(l, "de", 2))
-       tl = "German";
-      else if (!strncmp(l, "it", 2))
-       tl = "Italian";
-      else if (!strncmp(l, "ja", 2))
-       tl = "Japanese";
-      else if (!strncmp(l, "es", 2))
-       tl = "Spanish";
-
-      snprintf(pofile, sizeof(pofile), CUPS_BUNDLEDIR "/Resources/%s.lproj/cups.strings", tl);
-    }
-
-    url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (UInt8 *)pofile, (CFIndex)strlen(pofile), false);
-    if (url)
-    {
-      stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, url);
-
-      if (stream)
-      {
-       /*
-       * Read the property list containing the localization data.
-       */
-
-       CFReadStreamOpen(stream);
-
-       plist = CFPropertyListCreateWithStream(kCFAllocatorDefault, stream, 0, kCFPropertyListImmutable, NULL, NULL);
-
-  if (plist)
-  {
-    if (CFGetTypeID(plist) == CFDictionaryGetTypeID())
-      CFDictionaryApplyFunction((CFDictionaryRef)plist, (CFDictionaryApplierFunction)apple_add_message, this);
-    CFRelease(plist);
-  }
-
-  CFRelease(stream);
-      }
-
-      CFRelease(url);
-    }
-
-#else
-    _cups_globals_t    *cg = _cupsGlobals();
+    _cups_globals_t *cg = _cupsGlobals();
                                        // Global information
 
     snprintf(pofile, sizeof(pofile), "%s/%s/cups_%s.po", cg->localedir, l, l);
@@ -138,7 +72,6 @@ ppdcCatalog::ppdcCatalog(const char *l,      // I - Locale
 
       load_messages(pofile);
     }
-#endif /* __APPLE__ && CUPS_BUNDLEDIR */
   }
 
   if (f && *f)
@@ -655,27 +588,6 @@ ppdcCatalog::save_messages(
 }
 
 
-#if defined(__APPLE__) && defined(CUPS_BUNDLEDIR)
-//
-// 'apple_add_message()' - Add a message from a localization dictionary.
-//
-
-static void
-apple_add_message(CFStringRef key,     // I - Localization key
-                  CFStringRef val,     // I - Localized value
-                  ppdcCatalog *c)      // I - Message catalog
-{
-  char id[1024],                       // Message id
-       str[1024];                      // Localized message
-
-
-  if (CFStringGetCString(key, id, sizeof(id), kCFStringEncodingUTF8) &&
-      CFStringGetCString(val, str, sizeof(str), kCFStringEncodingUTF8))
-    c->add_message(id, str);
-}
-#endif /* __APPLE__ && CUPS_BUNDLEDIR */
-
-
 //
 // 'get_utf8()' - Get a UTF-8 character.
 //
index 0584f29a576a9f8419b02719b12a430dcba0b01c..928f26e6b38b222f6f4a010321cbb266e5542efc 100644 (file)
@@ -529,10 +529,6 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
                        final_content_type[1024] = "",
                                        /* FINAL_CONTENT_TYPE env variable */
                        lang[255],      /* LANG env variable */
-#ifdef __APPLE__
-                       apple_language[255],
-                                       /* APPLE_LANGUAGE env variable */
-#endif /* __APPLE__ */
                        auth_info_required[255],
                                        /* AUTH_INFO_REQUIRED env variable */
                        ppd[1024],      /* PPD env variable */
@@ -938,12 +934,6 @@ cupsdContinueJob(cupsd_job_t *job) /* I - Job */
   attr = ippFindAttribute(job->attrs, "attributes-natural-language",
                           IPP_TAG_LANGUAGE);
 
-#ifdef __APPLE__
-  cupsCopyString(apple_language, "APPLE_LANGUAGE=", sizeof(apple_language));
-  _cupsAppleLanguage(attr->values[0].string.text,
-                    apple_language + 15, sizeof(apple_language) - 15);
-#endif /* __APPLE__ */
-
   switch (strlen(attr->values[0].string.text))
   {
     default :
@@ -1053,9 +1043,6 @@ cupsdContinueJob(cupsd_job_t *job)        /* I - Job */
 
   envp[envc ++] = charset;
   envp[envc ++] = lang;
-#ifdef __APPLE__
-  envp[envc ++] = apple_language;
-#endif /* __APPLE__ */
   envp[envc ++] = ppd;
   envp[envc ++] = content_type;
   envp[envc ++] = device_uri;