Blame SOURCES/0001-Use-cupsGetNamedDest-for-legacy-printing-APIs-Issue-.patch

90c877
From 7271db11d27fe436f0c743bed3be8a5c6f93f2c2 Mon Sep 17 00:00:00 2001
90c877
From: Michael R Sweet <michael.r.sweet@gmail.com>
90c877
Date: Mon, 9 Apr 2018 09:50:19 -0400
90c877
Subject: [PATCH] Use cupsGetNamedDest for legacy printing APIs (Issue #5288)
90c877
90c877
---
90c877
 cups/util.c                          | 59 +++++-----------------------
90c877
 xcode/CUPS.xcodeproj/project.pbxproj |  6 ++-
90c877
 2 files changed, 15 insertions(+), 50 deletions(-)
90c877
90c877
diff --git a/cups/util.c b/cups/util.c
90c877
index ebc54d3cf..b15963e9e 100644
90c877
--- a/cups/util.c
90c877
+++ b/cups/util.c
90c877
@@ -21,19 +22,6 @@
90c877
 #endif /* WIN32 || __EMX__ */
90c877
 
90c877
 
90c877
-/*
90c877
- * Enumeration data and callback...
90c877
- */
90c877
-
90c877
-typedef struct _cups_createdata_s
90c877
-{
90c877
-  const char  *name;                    /* Destination name */
90c877
-  cups_dest_t *dest;                    /* Matching destination */
90c877
-} _cups_createdata_t;
90c877
-
90c877
-static int  cups_create_cb(_cups_createdata_t *data, unsigned flags, cups_dest_t *dest);
90c877
-
90c877
-
90c877
 /*
90c877
  * 'cupsCancelJob()' - Cancel a print job on the default server.
90c877
  *
90c877
@@ -168,7 +156,7 @@ cupsCreateJob(
90c877
 {
90c877
   int		job_id = 0;		/* job-id value */
90c877
   ipp_status_t  status;                 /* Create-Job status */
90c877
-  _cups_createdata_t data;              /* Enumeration data */
90c877
+  cups_dest_t	*dest;			/* Destination */
90c877
   cups_dinfo_t  *info;                  /* Destination information */
90c877
 
90c877
 
90c877
@@ -188,12 +176,7 @@ cupsCreateJob(
90c877
   * Lookup the destination...
90c877
   */
90c877
 
90c877
-  data.name = name;
90c877
-  data.dest = NULL;
90c877
-
90c877
-  cupsEnumDests(0, 1000, NULL, 0, 0, (cups_dest_cb_t)cups_create_cb, &data);
90c877
-
90c877
-  if (!data.dest)
90c877
+  if ((dest = cupsGetNamedDest(http, name, NULL)) == NULL)
90c877
   {
90c877
     DEBUG_puts("1cupsCreateJob: Destination not found.");
90c877
     _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(ENOENT), 0);
90c877
@@ -205,18 +188,18 @@ cupsCreateJob(
90c877
   */
90c877
 
90c877
   DEBUG_puts("1cupsCreateJob: Querying destination info.");
90c877
-  if ((info = cupsCopyDestInfo(http, data.dest)) == NULL)
90c877
+  if ((info = cupsCopyDestInfo(http, dest)) == NULL)
90c877
   {
90c877
     DEBUG_puts("1cupsCreateJob: Query failed.");
90c877
-    cupsFreeDests(1, data.dest);
90c877
+    cupsFreeDests(1, dest);
90c877
     return (0);
90c877
   }
90c877
 
90c877
-  status = cupsCreateDestJob(http, data.dest, info, &job_id, title, num_options, options);
90c877
+  status = cupsCreateDestJob(http, dest, info, &job_id, title, num_options, options);
90c877
   DEBUG_printf(("1cupsCreateJob: cupsCreateDestJob returned %04x (%s)", status, ippErrorString(status)));
90c877
 
90c877
   cupsFreeDestInfo(info);
90c877
-  cupsFreeDests(1, data.dest);
90c877
+  cupsFreeDests(1, dest);
90c877
 
90c877
  /*
90c877
   * Return the job...
90c877
@@ -968,25 +951,3 @@ cupsStartDocument(
90c877
   return (status);
90c877
 }
90c877
 
90c877
-
90c877
-/*
90c877
- * 'cups_create_cb()' - Find the destination for printing.
90c877
- */
90c877
-
90c877
-static int                              /* O - 0 on match */
90c877
-cups_create_cb(
90c877
-    _cups_createdata_t *data,           /* I - Data from cupsCreateJob call */
90c877
-    unsigned           flags,           /* I - Enumeration flags */
90c877
-    cups_dest_t        *dest)           /* I - Destination */
90c877
-{
90c877
-  DEBUG_printf(("2cups_create_cb(data=%p(%s), flags=%08x, dest=%p(%s))", (void *)data, data->name, flags, (void *)dest, dest->name));
90c877
-
90c877
-  (void)flags;
90c877
-
90c877
-  if (dest->instance || strcasecmp(data->name, dest->name))
90c877
-    return (1);
90c877
-
90c877
-  cupsCopyDest(dest, 0, &data->dest);
90c877
-
90c877
-  return (0);
90c877
-}
90c877
-- 
90c877
2.35.1
90c877