]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/dest.c
Merge changes from CUPS 1.5svn-r9567
[thirdparty/cups.git] / cups / dest.c
index 551dc73418fd6a5571579ba7ec54a2ead5923cad..1406c3420b6671000268385ec7290e67f534512c 100644 (file)
@@ -3,7 +3,7 @@
  *
  *   User-defined destination (and option) support for CUPS.
  *
- *   Copyright 2007-2010 by Apple Inc.
+ *   Copyright 2007-2011 by Apple Inc.
  *   Copyright 1997-2007 by Easy Software Products.
  *
  *   These coded instructions, statements, and computer programs are the
  *
  * Contents:
  *
- *   cupsAddDest()         - Add a destination to the list of destinations.
- *   cupsFreeDests()       - Free the memory used by the list of destinations.
- *   cupsGetDest()         - Get the named destination from the list.
- *   cupsGetDests()        - Get the list of destinations from the default
- *                           server.
- *   cupsGetDests2()       - Get the list of destinations from the specified
- *                           server.
- *   cupsGetNamedDest()    - Get options for the named destination.
- *   cupsRemoveDest()      - Remove a destination from the destination list.
- *   cupsSetDefaultDest()  - Set the default destination.
- *   cupsSetDests()        - Save the list of destinations for the default
- *                           server.
- *   cupsSetDests2()       - Save the list of destinations for the specified
- *                           server.
- *   appleCopyLocations()  - Copy the location history array.
- *   appleCopyNetwork()    - Get the network ID for the current location.
- *   appleGetPaperSize()   - Get the default paper size.
- *   appleGetPrinter()     - Get a printer from the history array.
- *   appleSetDefault()     - Set the default printer for this location.
- *   appleUseLastPrinter() - Get the default printer preference value.
- *   cups_add_dest()       - Add a destination to the array.
- *   cups_compare_dests()  - Compare two destinations.
- *   cups_find_dest()      - Find a destination using a binary search.
- *   cups_get_default()    - Get the default destination from an lpoptions file.
- *   cups_get_dests()      - Get destinations from a file.
- *   cups_get_sdests()     - Get destinations from a server.
- *   cups_make_string()    - Make a comma-separated string of values from an IPP
- *                           attribute.
+ *   cupsAddDest()                  - Add a destination to the list of
+ *                                    destinations.
+ *   _cupsAppleCopyDefaultPaperID() - Get the default paper ID.
+ *   _cupsAppleGetUseLastPrinter()  - Get whether to use the last used printer.
+ *   _cupsAppleSetDefaultPaperID()  - Set the default paper id.
+ *   _cupsAppleSetUseLastPrinter()  - Set whether to use the last used printer.
+ *   cupsFreeDests()                - Free the memory used by the list of
+ *                                    destinations.
+ *   cupsGetDest()                  - Get the named destination from the list.
+ *   _cupsGetDests()                - Get destinations from a server.
+ *   cupsGetDests()                 - Get the list of destinations from the
+ *                                    default server.
+ *   cupsGetDests2()                - Get the list of destinations from the
+ *                                    specified server.
+ *   cupsGetNamedDest()             - Get options for the named destination.
+ *   cupsRemoveDest()               - Remove a destination from the destination
+ *                                    list.
+ *   cupsSetDefaultDest()           - Set the default destination.
+ *   cupsSetDests()                 - Save the list of destinations for the
+ *                                    default server.
+ *   cupsSetDests2()                - Save the list of destinations for the
+ *                                    specified server.
+ *   _cupsUserDefault()             - Get the user default printer from
+ *                                    environment variables and location
+ *                                    information.
+ *   appleCopyLocations()           - Copy the location history array.
+ *   appleCopyNetwork()             - Get the network ID for the current
+ *                                    location.
+ *   appleGetPaperSize()            - Get the default paper size.
+ *   appleGetPrinter()              - Get a printer from the history array.
+ *   appleSetDefault()              - Set the default printer for this location.
+ *   cups_add_dest()                - Add a destination to the array.
+ *   cups_compare_dests()           - Compare two destinations.
+ *   cups_find_dest()               - Find a destination using a binary search.
+ *   cups_get_default()             - Get the default destination from an
+ *                                    lpoptions file.
+ *   cups_get_dests()               - Get destinations from a file.
+ *   cups_make_string()             - Make a comma-separated string of values
+ *                                    from an IPP attribute.
  */
 
 /*
 #endif /* HAVE_NOTIFY_H */
 
 #ifdef __APPLE__
-#  include <sys/cdefs.h>
-#  include <CoreFoundation/CoreFoundation.h>
 #  include <SystemConfiguration/SystemConfiguration.h>
 #  define kDefaultPaperIDKey CFSTR("DefaultPaperID")
 #  define kLocationHistoryArrayKey CFSTR("kLocationHistoryArrayKeyTMP")
 #  define kLocationNetworkKey CFSTR("kLocationNetworkKey")
 #  define kLocationPrinterIDKey CFSTR("kLocationPrinterIDKey")
 #  define kPMPrintingPreferences CFSTR("com.apple.print.PrintingPrefs")
+#  define kCUPSPrintingPreferences CFSTR("org.cups.PrintingPrefs")
 #  define kUseLastPrinterAsCurrentPrinterKey CFSTR("UseLastPrinterAsCurrentPrinter")
 #endif /* __APPLE__ */
 
@@ -81,7 +91,6 @@ static char   *appleGetPaperSize(char *name, int namesize);
 static CFStringRef appleGetPrinter(CFArrayRef locations, CFStringRef network,
                                   CFIndex *locindex);
 static void    appleSetDefault(const char *name);
-static int     appleUseLastPrinter(void);
 #endif /* __APPLE__ */
 static cups_dest_t *cups_add_dest(const char *name, const char *instance,
                                  int *num_dests, cups_dest_t **dests);
@@ -94,8 +103,6 @@ static char  *cups_get_default(const char *filename, char *namebuf,
 static int     cups_get_dests(const char *filename, const char *match_name,
                               const char *match_inst, int user_default_set,
                               int num_dests, cups_dest_t **dests);
-static int     cups_get_sdests(http_t *http, ipp_op_t op, const char *name,
-                               int num_dests, cups_dest_t **dests);
 static char    *cups_make_string(ipp_attribute_t *attr, char *buffer,
                                  size_t bufsize);
 
@@ -172,6 +179,83 @@ cupsAddDest(const char  *name,             /* I  - Destination name */
 }
 
 
+#ifdef __APPLE__
+/*
+ * '_cupsAppleCopyDefaultPaperID()' - Get the default paper ID.
+ */
+
+CFStringRef                            /* O - Default paper ID */
+_cupsAppleCopyDefaultPaperID(void)
+{
+  CFStringRef  paper;                  /* Default paper ID */
+
+
+  paper = CFPreferencesCopyAppValue(kDefaultPaperIDKey,
+                                    kCUPSPrintingPreferences);
+
+  if (!paper)
+    paper = CFPreferencesCopyAppValue(kDefaultPaperIDKey,
+                                      kPMPrintingPreferences);
+
+  return (paper);
+}
+
+
+/*
+ * '_cupsAppleGetUseLastPrinter()' - Get whether to use the last used printer.
+ */
+
+int                                    /* O - 1 to use last printer, 0 otherwise */
+_cupsAppleGetUseLastPrinter(void)
+{
+  Boolean      uselast,                /* Use last printer preference value */
+               uselast_set;            /* Valid is set? */
+
+
+  if (getenv("CUPS_DISABLE_APPLE_DEFAULT"))
+    return (0);
+
+  uselast = CFPreferencesGetAppBooleanValue(kUseLastPrinterAsCurrentPrinterKey,
+                                            kCUPSPrintingPreferences,
+                                           &uselast_set);
+  if (!uselast_set)
+    uselast = CFPreferencesGetAppBooleanValue(kUseLastPrinterAsCurrentPrinterKey,
+                                             kPMPrintingPreferences,
+                                             &uselast_set);
+  if (!uselast_set)
+    return (1);
+  else
+    return (uselast);
+}
+
+
+/*
+ * '_cupsAppleSetDefaultPaperID()' - Set the default paper id.
+ */
+
+void
+_cupsAppleSetDefaultPaperID(
+    CFStringRef name)                  /* I - New paper ID */
+{
+  CFPreferencesSetAppValue(kDefaultPaperIDKey, name, kCUPSPrintingPreferences);
+}
+
+
+/*
+ * '_cupsAppleSetUseLastPrinter()' - Set whether to use the last used printer.
+ */
+void                           
+_cupsAppleSetUseLastPrinter(
+    int uselast)                       /* O - 1 to use last printer, 0 otherwise */
+{
+  CFPreferencesSetAppValue(kUseLastPrinterAsCurrentPrinterKey, 
+                          uselast ? kCFBooleanTrue : kCFBooleanFalse,
+                          kCUPSPrintingPreferences);
+}
+#endif /* __APPLE__ */
+
+
 /*
  * 'cupsFreeDests()' - Free the memory used by the list of destinations.
  */
@@ -250,6 +334,271 @@ cupsGetDest(const char  *name,            /* I - Destination name or @code NULL@ for the d
 }
 
 
+/*
+ * '_cupsGetDests()' - Get destinations from a server.
+ *
+ * "op" is CUPS_GET_PRINTERS to get a full list, CUPS_GET_DEFAULT to get the
+ * system-wide default printer, or IPP_GET_PRINTER_ATTRIBUTES for a known
+ * printer.
+ *
+ * "name" is the name of an existing printer and is only used when "op" is
+ * IPP_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 Mac OS X 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 CUPS_HTTP_DEFAULT */
+             ipp_op_t    op,           /* I - IPP operation */
+             const char  *name,        /* I - Name of destination */
+             cups_dest_t **dests)      /* IO - Destinations */
+{
+  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 */
+               {
+                 "auth-info-required",
+                 "device-uri",
+                 "job-sheets-default",
+                 "marker-change-time",
+                 "marker-colors",
+                 "marker-high-levels",
+                 "marker-levels",
+                 "marker-low-levels",
+                 "marker-message",
+                 "marker-names",
+                 "marker-types",
+#ifdef __APPLE__
+                 "media-supported",
+#endif /* __APPLE__ */
+                 "printer-commands",
+                 "printer-defaults",
+                 "printer-info",
+                 "printer-is-accepting-jobs",
+                 "printer-is-shared",
+                 "printer-location",
+                 "printer-make-and-model",
+                 "printer-name",
+                 "printer-state",
+                 "printer-state-change-time",
+                 "printer-state-reasons",
+                 "printer-type",
+                 "printer-uri-supported"
+               };
+
+
+#ifdef __APPLE__
+ /*
+  * Get the default paper size...
+  */
+
+  appleGetPaperSize(media_default, sizeof(media_default));
+#endif /* __APPLE__ */
+
+ /*
+  * Build a CUPS_GET_PRINTERS or IPP_GET_PRINTER_ATTRIBUTES request, which
+  * require the following attributes:
+  *
+  *    attributes-charset
+  *    attributes-natural-language
+  *    requesting-user-name
+  *    printer-uri [for IPP_GET_PRINTER_ATTRIBUTES]
+  */
+
+  request = ippNewRequest(op);
+
+  ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+                "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
+               NULL, pattrs);
+
+  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+               "requesting-user-name", NULL, cupsUser());
+
+  if (name && op != CUPS_GET_DEFAULT)
+  {
+    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+                     "localhost", ippPort(), "/printers/%s", name);
+    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
+                 uri);
+  }
+
+ /*
+  * Do the request and get back a response...
+  */
+
+  if ((response = cupsDoRequest(http, request, "/")) != NULL)
+  {
+    for (attr = response->attrs; attr != NULL; attr = attr->next)
+    {
+     /*
+      * Skip leading attributes until we hit a printer...
+      */
+
+      while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
+        attr = attr->next;
+
+      if (attr == NULL)
+        break;
+
+     /*
+      * Pull the needed attributes from this printer...
+      */
+
+      printer_name = NULL;
+      num_options  = 0;
+      options      = NULL;
+
+      for (; attr && attr->group_tag == IPP_TAG_PRINTER; attr = attr->next)
+      {
+       if (attr->value_tag != IPP_TAG_INTEGER &&
+           attr->value_tag != IPP_TAG_ENUM &&
+           attr->value_tag != IPP_TAG_BOOLEAN &&
+           attr->value_tag != IPP_TAG_TEXT &&
+           attr->value_tag != IPP_TAG_TEXTLANG &&
+           attr->value_tag != IPP_TAG_NAME &&
+           attr->value_tag != IPP_TAG_NAMELANG &&
+           attr->value_tag != IPP_TAG_KEYWORD &&
+           attr->value_tag != IPP_TAG_RANGE &&
+           attr->value_tag != IPP_TAG_URI)
+          continue;
+
+        if (!strcmp(attr->name, "auth-info-required") ||
+           !strcmp(attr->name, "device-uri") ||
+           !strcmp(attr->name, "marker-change-time") ||
+           !strcmp(attr->name, "marker-colors") ||
+           !strcmp(attr->name, "marker-high-levels") ||
+           !strcmp(attr->name, "marker-levels") ||
+           !strcmp(attr->name, "marker-low-levels") ||
+           !strcmp(attr->name, "marker-message") ||
+           !strcmp(attr->name, "marker-names") ||
+           !strcmp(attr->name, "marker-types") ||
+           !strcmp(attr->name, "printer-commands") ||
+           !strcmp(attr->name, "printer-info") ||
+           !strcmp(attr->name, "printer-is-shared") ||
+           !strcmp(attr->name, "printer-make-and-model") ||
+           !strcmp(attr->name, "printer-state") ||
+           !strcmp(attr->name, "printer-state-change-time") ||
+           !strcmp(attr->name, "printer-type") ||
+            !strcmp(attr->name, "printer-is-accepting-jobs") ||
+            !strcmp(attr->name, "printer-location") ||
+            !strcmp(attr->name, "printer-state-reasons") ||
+           !strcmp(attr->name, "printer-uri-supported"))
+        {
+        /*
+         * Add a printer description attribute...
+         */
+
+          num_options = cupsAddOption(attr->name,
+                                     cups_make_string(attr, value,
+                                                      sizeof(value)),
+                                     num_options, &options);
+       }
+#ifdef __APPLE__
+       else if (!strcmp(attr->name, "media-supported"))
+       {
+        /*
+         * See if we can set a default media size...
+         */
+
+          int  i;                      /* Looping var */
+
+         for (i = 0; i < attr->num_values; i ++)
+           if (!strcasecmp(media_default, attr->values[i].string.text))
+           {
+             num_options = cupsAddOption("media", media_default, num_options,
+                                         &options);
+              break;
+           }
+       }
+#endif /* __APPLE__ */
+        else if (!strcmp(attr->name, "printer-name") &&
+                attr->value_tag == IPP_TAG_NAME)
+         printer_name = attr->values[0].string.text;
+        else if (strncmp(attr->name, "notify-", 7) &&
+                (attr->value_tag == IPP_TAG_BOOLEAN ||
+                 attr->value_tag == IPP_TAG_ENUM ||
+                 attr->value_tag == IPP_TAG_INTEGER ||
+                 attr->value_tag == IPP_TAG_KEYWORD ||
+                 attr->value_tag == IPP_TAG_NAME ||
+                 attr->value_tag == IPP_TAG_RANGE) &&
+                (ptr = strstr(attr->name, "-default")) != NULL)
+       {
+        /*
+         * Add a default option...
+         */
+
+          strlcpy(optname, attr->name, sizeof(optname));
+         optname[ptr - attr->name] = '\0';
+
+         if (strcasecmp(optname, "media") ||
+             !cupsGetOption("media", num_options, options))
+           num_options = cupsAddOption(optname,
+                                       cups_make_string(attr, value,
+                                                        sizeof(value)),
+                                       num_options, &options);
+       }
+      }
+
+     /*
+      * See if we have everything needed...
+      */
+
+      if (!printer_name)
+      {
+        cupsFreeOptions(num_options, options);
+
+        if (attr == NULL)
+         break;
+       else
+          continue;
+      }
+
+      if ((dest = cups_add_dest(printer_name, NULL, &num_dests, dests)) != NULL)
+      {
+        dest->num_options = num_options;
+       dest->options     = options;
+      }
+      else
+        cupsFreeOptions(num_options, options);
+
+      if (attr == NULL)
+       break;
+    }
+
+    ippDelete(response);
+  }
+
+ /*
+  * Return the count...
+  */
+
+  return (num_dests);
+}
+
+
 /*
  * 'cupsGetDests()' - Get the list of destinations from the default server.
  *
@@ -315,20 +664,14 @@ cupsGetDests2(http_t      *http,  /* I - Connection to server or @code CUPS_HTTP_
   {
     _cupsSetError(IPP_INTERNAL_ERROR, _("Bad NULL dests pointer"), 1);
     return (0);
-  }
-
- /*
-  * Initialize destination array...
-  */
-
-  num_dests = 0;
-  *dests    = (cups_dest_t *)0;
+  }
 
  /*
   * Grab the printers and classes...
   */
 
-  num_dests = cups_get_sdests(http, CUPS_GET_PRINTERS, NULL, num_dests, dests);
+  *dests    = (cups_dest_t *)0;
+  num_dests = _cupsGetDests(http, CUPS_GET_PRINTERS, NULL, dests);
 
   if (cupsLastError() >= IPP_REDIRECTION_OTHER_SITE)
   {
@@ -550,7 +893,7 @@ cupsGetNamedDest(http_t     *http,  /* I - Connection to server or @code CUPS_HTT
   * Get the printer's attributes...
   */
 
-  if (!cups_get_sdests(http, op, name, 0, &dest))
+  if (!_cupsGetDests(http, op, name, &dest))
   {
     if (op == CUPS_GET_DEFAULT || (name && !set_as_default))
       return (NULL);
@@ -560,7 +903,7 @@ cupsGetNamedDest(http_t     *http,  /* I - Connection to server or @code CUPS_HTT
     * configuration file does not exist.  Find out the real default.
     */
 
-    if (!cups_get_sdests(http, CUPS_GET_DEFAULT, NULL, 0, &dest))
+    if (!_cupsGetDests(http, CUPS_GET_DEFAULT, NULL, &dest))
       return (NULL);
   }
 
@@ -737,7 +1080,7 @@ cupsSetDests2(http_t      *http,   /* I - Connection to server or @code CUPS_HTTP_
   * Get the server destinations...
   */
 
-  num_temps = cups_get_sdests(http, CUPS_GET_PRINTERS, NULL, 0, &temps);
+  num_temps = _cupsGetDests(http, CUPS_GET_PRINTERS, NULL, &temps);
 
   if (cupsLastError() >= IPP_REDIRECTION_OTHER_SITE)
   {
@@ -960,7 +1303,7 @@ _cupsUserDefault(char   *name,             /* I - Name buffer */
   * system preferences...
   */
 
-  if (!appleUseLastPrinter())
+  if (!_cupsAppleGetUseLastPrinter())
   {
     DEBUG_puts("1_cupsUserDefault: Not using last printer as default...");
     name[0] = '\0';
@@ -1098,7 +1441,7 @@ appleCopyNetwork(void)
  * 'appleGetPaperSize()' - Get the default paper size.
  */
 
-static char *                          /* O - Default paper size */
+char *                                 /* O - Default paper size */
 appleGetPaperSize(char *name,          /* I - Paper size name buffer */
                   int  namesize)       /* I - Size of buffer */
 {
@@ -1106,8 +1449,7 @@ appleGetPaperSize(char *name,             /* I - Paper size name buffer */
   _pwg_media_t *pwgmedia;              /* PWG media size */
 
 
-  defaultPaperID = CFPreferencesCopyAppValue(kDefaultPaperIDKey,
-                                             kPMPrintingPreferences);
+  defaultPaperID = _cupsAppleCopyDefaultPaperID();
   if (!defaultPaperID ||
       CFGetTypeID(defaultPaperID) != CFStringGetTypeID() ||
       !CFStringGetCString(defaultPaperID, name, namesize,
@@ -1272,30 +1614,6 @@ appleSetDefault(const char *name)        /* I - Default printer/class name */
 }
 
 
-/*
- * 'appleUseLastPrinter()' - Get the default printer preference value.
- */
-
-static int                             /* O - 1 to use last printer, 0 otherwise */
-appleUseLastPrinter(void)
-{
-  CFPropertyListRef    uselast;        /* Use last printer preference value */
-
-
-  if (getenv("CUPS_DISABLE_APPLE_DEFAULT"))
-    return (0);
-
-  if ((uselast = CFPreferencesCopyAppValue(kUseLastPrinterAsCurrentPrinterKey,
-                                           kPMPrintingPreferences)) != NULL)
-  {
-    CFRelease(uselast);
-
-    if (uselast == kCFBooleanFalse)
-      return (0);
-  }
-
-  return (1);
-}
 #endif /* __APPLE__ */
 
 
@@ -1713,252 +2031,6 @@ cups_get_dests(
 }
 
 
-/*
- * 'cups_get_sdests()' - Get destinations from a server.
- */
-
-static int                             /* O - Number of destinations */
-cups_get_sdests(http_t      *http,     /* I - Connection to server or CUPS_HTTP_DEFAULT */
-                ipp_op_t    op,                /* I - IPP operation */
-               const char  *name,      /* I - Name of destination */
-                int         num_dests, /* I - Number of destinations */
-                cups_dest_t **dests)   /* IO - 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 */
-               {
-                 "auth-info-required",
-                 "device-uri",
-                 "job-sheets-default",
-                 "marker-change-time",
-                 "marker-colors",
-                 "marker-high-levels",
-                 "marker-levels",
-                 "marker-low-levels",
-                 "marker-message",
-                 "marker-names",
-                 "marker-types",
-#ifdef __APPLE__
-                 "media-supported",
-#endif /* __APPLE__ */
-                 "printer-commands",
-                 "printer-defaults",
-                 "printer-info",
-                 "printer-is-accepting-jobs",
-                 "printer-is-shared",
-                 "printer-location",
-                 "printer-make-and-model",
-                 "printer-name",
-                 "printer-state",
-                 "printer-state-change-time",
-                 "printer-state-reasons",
-                 "printer-type",
-                 "printer-uri-supported"
-               };
-
-
-#ifdef __APPLE__
- /*
-  * Get the default paper size...
-  */
-
-  appleGetPaperSize(media_default, sizeof(media_default));
-#endif /* __APPLE__ */
-
- /*
-  * Build a CUPS_GET_PRINTERS or IPP_GET_PRINTER_ATTRIBUTES request, which
-  * require the following attributes:
-  *
-  *    attributes-charset
-  *    attributes-natural-language
-  *    requesting-user-name
-  *    printer-uri [for IPP_GET_PRINTER_ATTRIBUTES]
-  */
-
-  request = ippNewRequest(op);
-
-  ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
-                "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
-               NULL, pattrs);
-
-  ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
-               "requesting-user-name", NULL, cupsUser());
-
-  if (name && op != CUPS_GET_DEFAULT)
-  {
-    httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
-                     "localhost", ippPort(), "/printers/%s", name);
-    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
-                 uri);
-  }
-
- /*
-  * Do the request and get back a response...
-  */
-
-  if ((response = cupsDoRequest(http, request, "/")) != NULL)
-  {
-    for (attr = response->attrs; attr != NULL; attr = attr->next)
-    {
-     /*
-      * Skip leading attributes until we hit a printer...
-      */
-
-      while (attr != NULL && attr->group_tag != IPP_TAG_PRINTER)
-        attr = attr->next;
-
-      if (attr == NULL)
-        break;
-
-     /*
-      * Pull the needed attributes from this printer...
-      */
-
-      printer_name = NULL;
-      num_options  = 0;
-      options      = NULL;
-
-      for (; attr && attr->group_tag == IPP_TAG_PRINTER; attr = attr->next)
-      {
-       if (attr->value_tag != IPP_TAG_INTEGER &&
-           attr->value_tag != IPP_TAG_ENUM &&
-           attr->value_tag != IPP_TAG_BOOLEAN &&
-           attr->value_tag != IPP_TAG_TEXT &&
-           attr->value_tag != IPP_TAG_TEXTLANG &&
-           attr->value_tag != IPP_TAG_NAME &&
-           attr->value_tag != IPP_TAG_NAMELANG &&
-           attr->value_tag != IPP_TAG_KEYWORD &&
-           attr->value_tag != IPP_TAG_RANGE &&
-           attr->value_tag != IPP_TAG_URI)
-          continue;
-
-        if (!strcmp(attr->name, "auth-info-required") ||
-           !strcmp(attr->name, "device-uri") ||
-           !strcmp(attr->name, "marker-change-time") ||
-           !strcmp(attr->name, "marker-colors") ||
-           !strcmp(attr->name, "marker-high-levels") ||
-           !strcmp(attr->name, "marker-levels") ||
-           !strcmp(attr->name, "marker-low-levels") ||
-           !strcmp(attr->name, "marker-message") ||
-           !strcmp(attr->name, "marker-names") ||
-           !strcmp(attr->name, "marker-types") ||
-           !strcmp(attr->name, "printer-commands") ||
-           !strcmp(attr->name, "printer-info") ||
-           !strcmp(attr->name, "printer-is-shared") ||
-           !strcmp(attr->name, "printer-make-and-model") ||
-           !strcmp(attr->name, "printer-state") ||
-           !strcmp(attr->name, "printer-state-change-time") ||
-           !strcmp(attr->name, "printer-type") ||
-            !strcmp(attr->name, "printer-is-accepting-jobs") ||
-            !strcmp(attr->name, "printer-location") ||
-            !strcmp(attr->name, "printer-state-reasons") ||
-           !strcmp(attr->name, "printer-uri-supported"))
-        {
-        /*
-         * Add a printer description attribute...
-         */
-
-          num_options = cupsAddOption(attr->name,
-                                     cups_make_string(attr, value,
-                                                      sizeof(value)),
-                                     num_options, &options);
-       }
-#ifdef __APPLE__
-       else if (!strcmp(attr->name, "media-supported"))
-       {
-        /*
-         * See if we can set a default media size...
-         */
-
-          int  i;                      /* Looping var */
-
-         for (i = 0; i < attr->num_values; i ++)
-           if (!strcasecmp(media_default, attr->values[i].string.text))
-           {
-             num_options = cupsAddOption("media", media_default, num_options,
-                                         &options);
-              break;
-           }
-       }
-#endif /* __APPLE__ */
-        else if (!strcmp(attr->name, "printer-name") &&
-                attr->value_tag == IPP_TAG_NAME)
-         printer_name = attr->values[0].string.text;
-        else if (strncmp(attr->name, "notify-", 7) &&
-                (attr->value_tag == IPP_TAG_BOOLEAN ||
-                 attr->value_tag == IPP_TAG_ENUM ||
-                 attr->value_tag == IPP_TAG_INTEGER ||
-                 attr->value_tag == IPP_TAG_KEYWORD ||
-                 attr->value_tag == IPP_TAG_NAME ||
-                 attr->value_tag == IPP_TAG_RANGE) &&
-                (ptr = strstr(attr->name, "-default")) != NULL)
-       {
-        /*
-         * Add a default option...
-         */
-
-          strlcpy(optname, attr->name, sizeof(optname));
-         optname[ptr - attr->name] = '\0';
-
-         if (strcasecmp(optname, "media") ||
-             !cupsGetOption("media", num_options, options))
-           num_options = cupsAddOption(optname,
-                                       cups_make_string(attr, value,
-                                                        sizeof(value)),
-                                       num_options, &options);
-       }
-      }
-
-     /*
-      * See if we have everything needed...
-      */
-
-      if (!printer_name)
-      {
-        cupsFreeOptions(num_options, options);
-
-        if (attr == NULL)
-         break;
-       else
-          continue;
-      }
-
-      if ((dest = cups_add_dest(printer_name, NULL, &num_dests, dests)) != NULL)
-      {
-        dest->num_options = num_options;
-       dest->options     = options;
-      }
-      else
-        cupsFreeOptions(num_options, options);
-
-      if (attr == NULL)
-       break;
-    }
-
-    ippDelete(response);
-  }
-
- /*
-  * Return the count...
-  */
-
-  return (num_dests);
-}
-
-
 /*
  * 'cups_make_string()' - Make a comma-separated string of values from an IPP
  *                        attribute.