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

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