]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Create shims to pass to array structures as to not pass incompatible function pointers
authorRose <83477269+AtariDreams@users.noreply.github.com>
Sun, 23 Apr 2023 20:02:16 +0000 (16:02 -0400)
committerRose <83477269+AtariDreams@users.noreply.github.com>
Wed, 21 Jun 2023 14:05:57 +0000 (10:05 -0400)
Although it may seem to work on modern systems, casting functions that do not have the same number of arguments as the expected type can cause ABI problems and will be removed from the latest version of C.

By sheer luck, most modern ABIs and compilers will treat the CPU register that contains the third argumentas a scratch register that may contain information from the function that called itand push it to the stack just in case. However, not all ABIs are guaranteed to do this, and because this program is not supposed to rely on these implementation details, it is best to ensure by the C standard that undefined behavior, or platform-dependent behavior, does not occur by the creation of private shim functions meant to be passed.

The reason I did this instead of changing the function definition is to maintain backwards compatibility; some of the functions being passed are public API and therefore I cannot change them.

This is the best I could do, but if there is anything else I could do, please let me know.

48 files changed:
backend/dnssd.c
backend/ipp.c
backend/snmp.c
backend/usb-libusb.c
cgi-bin/admin.c
cgi-bin/help-index.c
cups/array.c
cups/dest-options.c
cups/dest.c
cups/ipp-support.c
cups/language.c
cups/libcups2.def
cups/ppd-cache.c
cups/ppd-conflicts.c
cups/ppd-emit.c
cups/ppd-localize.c
cups/ppd.c
cups/pwg-media.c
cups/string-private.h
cups/string.c
cups/testarray.c
notifier/rss.c
ppdc/ppdc.cxx
ppdc/ppdmerge.cxx
scheduler/auth.c
scheduler/auth.h
scheduler/banners.c
scheduler/client.c
scheduler/colorman.c
scheduler/cups-driverd.cxx
scheduler/cupsd.h
scheduler/cupsfilter.c
scheduler/filter.c
scheduler/job.c
scheduler/main.c
scheduler/mime.c
scheduler/network.c
scheduler/policy.c
scheduler/printers.c
scheduler/process.c
scheduler/quotas.c
scheduler/select.c
scheduler/subscriptions.c
scheduler/type.c
scheduler/util.h
tools/ippeveprinter.c
tools/ippfind.c
tools/ipptool.c

index 14a6772fb7b4ac103264c7f8ef0d4e6308121ef7..8f48a9e272ca534681420ce2b76cdf50e607444f 100644 (file)
@@ -101,7 +101,7 @@ static void         client_callback(AvahiClient *client,
                                        void *context);
 #endif /* HAVE_AVAHI */
 
-static int             compare_devices(cups_device_t *a, cups_device_t *b);
+static int             compare_devices(cups_device_t *a, cups_device_t *b, void *data);
 static void            exec_backend(char **argv) _CUPS_NORETURN;
 static cups_device_t   *get_device(cups_array_t *devices, const char *serviceName, const char *regtype, const char *replyDomain) _CUPS_NONNULL(1,2,3,4);
 #ifdef HAVE_MDNSRESPONDER
@@ -721,8 +721,10 @@ client_callback(
 
 static int                             /* O - Result of comparison */
 compare_devices(cups_device_t *a,      /* I - First device */
-                cups_device_t *b)      /* I - Second device */
+                cups_device_t *b,      /* I - Second device */
+                void       *data)      /* I - Unused */
 {
+  (void)data;
   return (strcmp(a->name, b->name));
 }
 
index be1f2c048143fa697075f7abd62178585671f978..b89fdd75e8f82f190f930baaab609ae23faef3f3 100644 (file)
@@ -3534,7 +3534,7 @@ update_reasons(ipp_attribute_t *attr,     /* I - printer-state-reasons or NULL */
   {
     int        i;                              /* Looping var */
 
-    new_reasons = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+    new_reasons = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
     op          = '\0';
 
     for (i = 0; i < attr->num_values; i ++)
index 17a29f8eebf4115785e923f193ed08c993874574..6a21ca63f98e8c083a845bde032d50de2d3604f8 100644 (file)
@@ -121,7 +121,7 @@ static void         add_cache(http_addr_t *addr, const char *addrname,
                                  const char *make_and_model);
 static device_uri_t    *add_device_uri(char *value);
 static void            alarm_handler(int sig);
-static int             compare_cache(snmp_cache_t *a, snmp_cache_t *b);
+static int             compare_cache(snmp_cache_t *a, snmp_cache_t *b, void *data);
 static void            debug_printf(const char *format, ...);
 static void            fix_make_model(char *make_model,
                                       const char *old_make_model,
@@ -441,10 +441,12 @@ alarm_handler(int sig)                    /* I - Signal number */
  * 'compare_cache()' - Compare two cache entries.
  */
 
-static int                             /* O - Result of comparison */
-compare_cache(snmp_cache_t *a,         /* I - First cache entry */
-              snmp_cache_t *b)         /* I - Second cache entry */
+static int                     /* O - Result of comparison */
+compare_cache(snmp_cache_t *a, /* I - First cache entry */
+              snmp_cache_t *b, /* I - Second cache entry */
+              void *data)      /* I - Unused */
 {
+  (void)data;
   return (_cups_strcasecmp(a->addrname, b->addrname));
 }
 
index 281102fee87d240e8314267d8858d6206094ebb8..1c591a0ac3958979c832b02b15aa7278f6bf7f89 100644 (file)
@@ -128,7 +128,7 @@ libusb_device               **all_list;     /* List of connected USB devices */
  */
 
 static int             close_device(usb_printer_t *printer);
-static int             compare_quirks(usb_quirk_t *a, usb_quirk_t *b);
+static int             compare_quirks(usb_quirk_t *a, usb_quirk_t *b, void *data);
 static usb_printer_t   *find_device(usb_cb_t cb, const void *data);
 static unsigned                find_quirks(int vendor_id, int product_id);
 static int             get_device_id(usb_printer_t *printer, char *buffer,
@@ -771,12 +771,15 @@ close_device(usb_printer_t *printer)      /* I - Printer */
  * 'compare_quirks()' - Compare two quirks entries.
  */
 
-static int                             /* O - Result of comparison */
-compare_quirks(usb_quirk_t *a,         /* I - First quirk entry */
-               usb_quirk_t *b)         /* I - Second quirk entry */
+static int                     /* O - Result of comparison */
+compare_quirks(usb_quirk_t *a, /* I - First quirk entry */
+               usb_quirk_t *b, /* I - Second quirk entry */
+               void *data)     /* I - Unused */
 {
   int result;                          /* Result of comparison */
 
+  (void)data;
+
   if ((result = b->vendor_id - a->vendor_id) == 0)
     result = b->product_id - a->product_id;
 
index 863e885568704675ca0ad17d9831dcefd02962df..096eb34f9944a60530fef99b9a012f43a0fa55cb 100644 (file)
@@ -1985,7 +1985,7 @@ do_list_printers(http_t *http)            /* I - HTTP connection */
     * Allocate an array and copy the device strings...
     */
 
-    printer_devices = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+    printer_devices = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
 
     for (attr = ippFindAttribute(response, "device-uri", IPP_TAG_URI);
          attr;
index 4a10235f33748f6249a5767dc2e19e6407127da6..05bdc6638e271e625191b60ced7a4a41f84bd902 100644 (file)
@@ -136,9 +136,9 @@ static int          help_load_file(help_index_t *hi,
                                       const char *relative,
                                       time_t     mtime);
 static help_node_t     *help_new_node(const char *filename, const char *anchor, const char *section, const char *text, time_t mtime, off_t offset, size_t length) _CUPS_NONNULL(1,3,4);
-static int             help_sort_by_name(help_node_t *p1, help_node_t *p2);
-static int             help_sort_by_score(help_node_t *p1, help_node_t *p2);
-static int             help_sort_words(help_word_t *w1, help_word_t *w2);
+static int             help_sort_by_name(help_node_t *p1, help_node_t *p2, void *data);
+static int             help_sort_by_score(help_node_t *p1, help_node_t *p2, void *data);
+static int             help_sort_words(help_word_t *w1, help_word_t *w2, void *data);
 
 
 /*
@@ -1205,9 +1205,10 @@ help_new_node(const char   *filename,    /* I - Filename */
  * 'help_sort_nodes_by_name()' - Sort nodes by section, filename, and anchor.
  */
 
-static int                             /* O - Difference */
-help_sort_by_name(help_node_t *n1,     /* I - First node */
-                  help_node_t *n2)     /* I - Second node */
+static int                         /* O - Difference */
+help_sort_by_name(help_node_t *n1, /* I - First node */
+                  help_node_t *n2, /* I - Second node */
+                  void *data)      /* Unused */
 {
   int          diff;                   /* Difference */
 
@@ -1230,13 +1231,16 @@ help_sort_by_name(help_node_t *n1,      /* I - First node */
  * 'help_sort_nodes_by_score()' - Sort nodes by score and text.
  */
 
-static int                             /* O - Difference */
-help_sort_by_score(help_node_t *n1,    /* I - First node */
-                   help_node_t *n2)    /* I - Second node */
+static int                          /* O - Difference */
+help_sort_by_score(help_node_t *n1, /* I - First node */
+                   help_node_t *n2, /* I - Second node */
+                   void *data)      /* I - Unused */
 {
   int          diff;                   /* Difference */
 
 
+  (void)data;
+
   if (n1->score != n2->score)
     return (n2->score - n1->score);
 
@@ -1256,9 +1260,11 @@ help_sort_by_score(help_node_t *n1,      /* I - First node */
  * 'help_sort_words()' - Sort words alphabetically.
  */
 
-static int                             /* O - Difference */
-help_sort_words(help_word_t *w1,       /* I - Second word */
-                help_word_t *w2)       /* I - Second word */
+static int                       /* O - Difference */
+help_sort_words(help_word_t *w1, /* I - Second word */
+                help_word_t *w2, /* I - Second word */
+                void *data)      /* Unused */
 {
+  (void)data;
   return (_cups_strcasecmp(w1->text, w2->text));
 }
index 41289a5c22ae26235c857c90ae512f9041ed31bb..f54e66485a977a893dac9fd3901f5c121d6d8958 100644 (file)
@@ -787,9 +787,9 @@ _cupsArrayNewStrings(const char *s, /* I - Delimited strings or NULL */
   cups_array_t *a;                     /* Array */
 
 
-  if ((a = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0,
-                         (cups_acopy_func_t)_cupsStrAlloc,
-                        (cups_afree_func_t)_cupsStrFree)) != NULL)
+  if ((a = cupsArrayNew3((cups_array_func_t)_cupsArrayStrcmp, NULL, NULL, 0,
+                         (cups_acopy_func_t)_cupsStrPrivAlloc,
+                         (cups_afree_func_t)_cupsStrPrivFree)) != NULL)
     _cupsArrayAddStrings(a, s, delim);
 
   return (a);
@@ -1317,3 +1317,43 @@ cups_array_find(cups_array_t *a, /* I - Array */
 
   return (current);
 }
+
+
+/*
+ * '_cupsArrayStrcmp()' - Meant to be passed as a pointer to CUPS arrays instead
+ * of strcmp. Will also work if called directly.
+ */
+
+int _cupsArrayStrcmp(const char *s1, /* I - first string to compare */
+                     const char *s2, /* I - second string to compare */
+                     void *data)     /* Unused */
+{
+  (void)data;
+  return (strcmp(s1, s2));
+}
+
+
+/*
+ * '_cupsArrayStrdup()' - Meant to be passed as a pointer to CUPS arrays instead
+ * of strdup. Will also work if called directly.
+ */
+
+char *_cupsArrayStrdup(const char *element, /* I - element to duplicate */
+                       void *data)          /* Unused */
+{
+  (void)data;
+  return (strdup(element));
+}
+
+
+/*
+ * '_cupsArrayFree()' - Meant to be passed as a pointer to CUPS arrays instead
+ * of free. Will also work if called directly.
+ */
+
+void _cupsArrayFree(void *element, /* I - element to free */
+                    void *data)    /* Unused */
+{
+  (void)data;
+  free(element);
+}
index d0d683d7a60b6ecd06a37a69d691f46b072c2388..4555c10829a7ac4fbf02ec724b837731b7a55573 100644 (file)
 static void            cups_add_dconstres(cups_array_t *a, ipp_t *collection);
 static int             cups_collection_contains(ipp_t *test, ipp_t *match);
 static size_t          cups_collection_string(ipp_attribute_t *attr, char *buffer, size_t bufsize) _CUPS_NONNULL((1,2));
-static int             cups_compare_dconstres(_cups_dconstres_t *a,
-                                              _cups_dconstres_t *b);
-static int             cups_compare_media_db(_cups_media_db_t *a,
-                                             _cups_media_db_t *b);
-static _cups_media_db_t        *cups_copy_media_db(_cups_media_db_t *mdb);
+static int cups_compare_dconstres(_cups_dconstres_t *a, _cups_dconstres_t *b,
+                                  void *data);
+static int cups_compare_media_db(_cups_media_db_t *a, _cups_media_db_t *b,
+                                 void *data);
+static _cups_media_db_t *cups_copy_media_db(_cups_media_db_t *mdb, void *data);
 static void            cups_create_cached(http_t *http, cups_dinfo_t *dinfo,
                                           unsigned flags);
 static void            cups_create_constraints(cups_dinfo_t *dinfo);
 static void            cups_create_defaults(cups_dinfo_t *dinfo);
 static void            cups_create_media_db(cups_dinfo_t *dinfo,
                                             unsigned flags);
-static void            cups_free_media_db(_cups_media_db_t *mdb);
+static void            cups_free_media_db(_cups_media_db_t *mdb, void *data);
 static int             cups_get_media_db(http_t *http, cups_dinfo_t *dinfo,
                                          pwg_media_t *pwg, unsigned flags,
                                          cups_size_t *size);
@@ -1730,11 +1730,12 @@ cups_collection_string(
  * 'cups_compare_dconstres()' - Compare to resolver entries.
  */
 
-static int                             /* O - Result of comparison */
-cups_compare_dconstres(
-    _cups_dconstres_t *a,              /* I - First resolver */
-    _cups_dconstres_t *b)              /* I - Second resolver */
+static int                                   /* O - Result of comparison */
+cups_compare_dconstres(_cups_dconstres_t *a, /* I - First resolver */
+                       _cups_dconstres_t *b, /* I - Second resolver */
+                       void *data)           /* Unused */
 {
+  (void)data;
   return (strcmp(a->name, b->name));
 }
 
@@ -1743,13 +1744,14 @@ cups_compare_dconstres(
  * 'cups_compare_media_db()' - Compare two media entries.
  */
 
-static int                             /* O - Result of comparison */
-cups_compare_media_db(
-    _cups_media_db_t *a,               /* I - First media entries */
-    _cups_media_db_t *b)               /* I - Second media entries */
+static int                                 /* O - Result of comparison */
+cups_compare_media_db(_cups_media_db_t *a, /* I - First media entries */
+                      _cups_media_db_t *b, /* I - Second media entries */
+                      void *data)          /* Unused */
 {
   int  result;                         /* Result of comparison */
 
+  (void)data;
 
   if ((result = a->width - b->width) == 0)
     result = a->length - b->length;
@@ -1762,12 +1764,13 @@ cups_compare_media_db(
  * 'cups_copy_media_db()' - Copy a media entry.
  */
 
-static _cups_media_db_t *              /* O - New media entry */
-cups_copy_media_db(
-    _cups_media_db_t *mdb)             /* I - Media entry to copy */
+static _cups_media_db_t *                 /* O - New media entry */
+cups_copy_media_db(_cups_media_db_t *mdb, /* I - Media entry to copy */
+                   void *data)            /* Unused */
 {
   _cups_media_db_t *temp;              /* New media entry */
 
+  (void)data;
 
   if ((temp = calloc(1, sizeof(_cups_media_db_t))) == NULL)
     return (NULL);
@@ -1888,12 +1891,9 @@ cups_create_constraints(
   ipp_attribute_t      *attr;          /* Attribute */
   _ipp_value_t         *val;           /* Current value */
 
-
-  dinfo->constraints = cupsArrayNew3(NULL, NULL, NULL, 0, NULL,
-                                     (cups_afree_func_t)free);
-  dinfo->resolvers   = cupsArrayNew3((cups_array_func_t)cups_compare_dconstres,
-                                    NULL, NULL, 0, NULL,
-                                     (cups_afree_func_t)free);
+  dinfo->constraints = cupsArrayNew3(NULL, NULL, NULL, 0, NULL, _cupsArrayFree);
+  dinfo->resolvers = cupsArrayNew3((cups_array_func_t)cups_compare_dconstres,
+                                   NULL, NULL, 0, NULL, _cupsArrayFree);
 
   if ((attr = ippFindAttribute(dinfo->attrs, "job-constraints-supported",
                               IPP_TAG_BEGIN_COLLECTION)) != NULL)
@@ -2253,9 +2253,10 @@ cups_create_media_db(
  */
 
 static void
-cups_free_media_db(
-    _cups_media_db_t *mdb)             /* I - Media entry to free */
+cups_free_media_db(_cups_media_db_t *mdb, /* I - Media entry to free */
+                   void *data)            /* I - Unused */
 {
+  (void)data;
   if (mdb->color)
     _cupsStrFree(mdb->color);
   if (mdb->key)
@@ -2332,11 +2333,11 @@ cups_get_media_db(http_t       *http,   /* I - Connection to destination */
 
       if (best->left != 0 || best->right != 0 || best->top != 0 || best->bottom != 0)
       {
-       for (mdb = (_cups_media_db_t *)cupsArrayNext(db);
-            mdb && !cups_compare_media_db(mdb, &key);
-            mdb = (_cups_media_db_t *)cupsArrayNext(db))
-       {
-         if (mdb->left <= best->left && mdb->right <= best->right &&
+        for (mdb = (_cups_media_db_t *)cupsArrayNext(db);
+             mdb && !cups_compare_media_db(mdb, &key, NULL);
+             mdb = (_cups_media_db_t *)cupsArrayNext(db))
+        {
+          if (mdb->left <= best->left && mdb->right <= best->right &&
              mdb->top <= best->top && mdb->bottom <= best->bottom)
          {
            best = mdb;
@@ -2344,7 +2345,7 @@ cups_get_media_db(http_t       *http,     /* I - Connection to destination */
                mdb->top == 0)
              break;
          }
-       }
+        }
       }
 
      /*
@@ -2363,10 +2364,10 @@ cups_get_media_db(http_t       *http,   /* I - Connection to destination */
       */
 
       for (mdb = (_cups_media_db_t *)cupsArrayNext(db);
-          mdb && !cups_compare_media_db(mdb, &key);
-          mdb = (_cups_media_db_t *)cupsArrayNext(db))
+           mdb && !cups_compare_media_db(mdb, &key, NULL);
+           mdb = (_cups_media_db_t *)cupsArrayNext(db))
       {
-       if (mdb->left >= best->left && mdb->right >= best->right &&
+        if (mdb->left >= best->left && mdb->right >= best->right &&
            mdb->top >= best->top && mdb->bottom >= best->bottom &&
            (mdb->bottom != best->bottom || mdb->left != best->left || mdb->right != best->right || mdb->top != best->top))
          best = mdb;
@@ -2379,10 +2380,10 @@ cups_get_media_db(http_t       *http,   /* I - Connection to destination */
       */
 
       for (mdb = (_cups_media_db_t *)cupsArrayNext(db);
-          mdb && !cups_compare_media_db(mdb, &key);
-          mdb = (_cups_media_db_t *)cupsArrayNext(db))
+           mdb && !cups_compare_media_db(mdb, &key, NULL);
+           mdb = (_cups_media_db_t *)cupsArrayNext(db))
       {
-       if (((mdb->left > 0 && mdb->left <= best->left) || best->left == 0) &&
+        if (((mdb->left > 0 && mdb->left <= best->left) || best->left == 0) &&
            ((mdb->right > 0 && mdb->right <= best->right) || best->right == 0) &&
            ((mdb->top > 0 && mdb->top <= best->top) || best->top == 0) &&
            ((mdb->bottom > 0 && mdb->bottom <= best->bottom) || best->bottom == 0) &&
index da775a390155d83d12cc05f2a355bf77a620be0c..416bd2ddc2fb205e859e69b4f11b6514d87b8a3b 100644 (file)
@@ -185,7 +185,7 @@ static void         cups_dnssd_client_cb(AvahiClient *client,
                                             void *context);
 #  endif /* HAVE_MDNSRESPONDER */
 static int             cups_dnssd_compare_devices(_cups_dnssd_device_t *a,
-                                                  _cups_dnssd_device_t *b);
+                                                  _cups_dnssd_device_t *b, void *data);
 static void            cups_dnssd_free_device(_cups_dnssd_device_t *device,
                                               _cups_dnssd_data_t *data);
 static _cups_dnssd_device_t *
@@ -2706,11 +2706,12 @@ cups_dnssd_client_cb(
  * 'cups_dnssd_compare_device()' - Compare two devices.
  */
 
-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 */
+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 */
+                           void *data)              /* Unused */
 {
+  (void)data;
   return (strcmp(a->dest.name, b->dest.name));
 }
 
index bb0c6c8bd9089e5610db024673cbe28ba56fa915..e0574c219e5be7f70c4ca42de9be4b304040a34e 100644 (file)
@@ -1947,7 +1947,7 @@ ippCreateRequestedArray(ipp_t *request)   /* I - IPP request */
 
     if (op == IPP_OP_GET_JOBS)
     {
-      ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+      ra = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
       cupsArrayAdd(ra, "job-id");
       cupsArrayAdd(ra, "job-uri");
 
@@ -1969,7 +1969,7 @@ ippCreateRequestedArray(ipp_t *request)   /* I - IPP request */
   * Create an array using "strcmp" as the comparison function...
   */
 
-  ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+  ra = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
 
   for (i = 0; i < count; i ++)
   {
index 96e828332fa465cadb9b4811ebc631a555c14a5e..6f5d6fcfa0d294dcb8de0f358ff6403db04be91f 100644 (file)
@@ -145,8 +145,9 @@ 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);
+static int             cups_message_compare(_cups_message_t *m1, _cups_message_t *m2,
+                                void *data);
+static void            cups_message_free(_cups_message_t *m, void *data);
 static void            cups_message_load(cups_lang_t *lang);
 static void            cups_message_puts(cups_file_t *fp, const char *s);
 static int             cups_read_strings(cups_file_t *fp, int flags, cups_array_t *a);
@@ -1646,11 +1647,12 @@ cups_cache_lookup(
  * 'cups_message_compare()' - Compare two messages.
  */
 
-static int                             /* O - Result of comparison */
-cups_message_compare(
-    _cups_message_t *m1,               /* I - First message */
-    _cups_message_t *m2)               /* I - Second message */
+static int                                /* O - Result of comparison */
+cups_message_compare(_cups_message_t *m1, /* I - First message */
+                     _cups_message_t *m2, /* I - Second message */
+                     void *data)          /* Unused */
 {
+  (void)data;
   return (strcmp(m1->msg, m2->msg));
 }
 
@@ -1659,9 +1661,10 @@ cups_message_compare(
  * 'cups_message_free()' - Free a message.
  */
 
-static void
-cups_message_free(_cups_message_t *m)  /* I - Message */
+static void cups_message_free(_cups_message_t *m, /* I - Message */
+                              void *data)         /* Unused */
 {
+  (void)data;
   if (m->msg)
     free(m->msg);
 
index 268522259d21e178a68e606dee66a15982dbb333..d5ec4f18257c9c7d173dfe735a5d8e1ddd87c0b7 100644 (file)
@@ -52,6 +52,9 @@ _cupsRasterReadHeader
 _cupsRasterReadPixels
 _cupsRasterWriteHeader
 _cupsRasterWritePixels
+_cupsArrayStrcmp
+_cupsArrayStrdup
+_cupsArrayFree
 _cupsSetDefaults
 _cupsSetError
 _cupsSetHTTPError
index 40881cd39513d8585d4ab93e950adfe20f4e3c95..88decc7067c938226a984928103f245a59d57f14 100644 (file)
@@ -34,10 +34,10 @@ static int  cups_get_url(http_t **http, const char *url, char *name, size_t names
 static const char *ppd_inputslot_for_keyword(_ppd_cache_t *pc, const char *keyword);
 static void    pwg_add_finishing(cups_array_t *finishings, ipp_finishings_t template, const char *name, const char *value);
 static void    pwg_add_message(cups_array_t *a, const char *msg, const char *str);
-static int     pwg_compare_finishings(_pwg_finishings_t *a, _pwg_finishings_t *b);
-static int     pwg_compare_sizes(cups_size_t *a, cups_size_t *b);
-static cups_size_t *pwg_copy_size(cups_size_t *size);
-static void    pwg_free_finishings(_pwg_finishings_t *f);
+static int     pwg_compare_finishings(_pwg_finishings_t *a, _pwg_finishings_t *b, void *data);
+static int     pwg_compare_sizes(cups_size_t *a, cups_size_t *b, void *data);
+static cups_size_t *pwg_copy_size(cups_size_t *size, void *data);
+static void    pwg_free_finishings(_pwg_finishings_t *f, void *data);
 static void    pwg_ppdize_name(const char *ipp, char *name, size_t namesize);
 static void    pwg_ppdize_resolution(ipp_attribute_t *attr, int element, int *xres, int *yres, char *name, size_t namesize);
 static void    pwg_unppdize_name(const char *ppd, char *name, size_t namesize,
@@ -598,14 +598,14 @@ _ppdCacheCreateWithFile(
     else if (!_cups_strcasecmp(line, "Filter"))
     {
       if (!pc->filters)
-        pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+        pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
 
       cupsArrayAdd(pc->filters, value);
     }
     else if (!_cups_strcasecmp(line, "PreFilter"))
     {
       if (!pc->prefilters)
-        pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+        pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
 
       cupsArrayAdd(pc->prefilters, value);
     }
@@ -957,7 +957,7 @@ _ppdCacheCreateWithFile(
     else if (!_cups_strcasecmp(line, "FinishingTemplate"))
     {
       if (!pc->templates)
-        pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+        pc->templates = cupsArrayNew3((cups_array_func_t)_cupsArrayStrcmp, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
 
       cupsArrayAdd(pc->templates, value);
     }
@@ -981,7 +981,7 @@ _ppdCacheCreateWithFile(
     else if (!_cups_strcasecmp(line, "SupportFile"))
     {
       if (!pc->support_files)
-        pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+        pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
 
       cupsArrayAdd(pc->support_files, value);
     }
@@ -1756,7 +1756,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
   * Copy filters and pre-filters...
   */
 
-  pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+  pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
 
   cupsArrayAdd(pc->filters,
                "application/vnd.cups-raw application/octet-stream 0 -");
@@ -1813,7 +1813,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
 
   if ((ppd_attr = ppdFindAttr(ppd, "cupsPreFilter", NULL)) != NULL)
   {
-    pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+    pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
 
     do
     {
@@ -1970,7 +1970,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
 
   if ((ppd_option = ppdFindOption(ppd, "cupsFinishingTemplate")) != NULL)
   {
-    pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+    pc->templates = cupsArrayNew3((cups_array_func_t)_cupsArrayStrcmp, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
 
     for (choice = ppd_option->choices, i = ppd_option->num_choices; i > 0; choice ++, i --)
     {
@@ -2020,7 +2020,7 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)   /* I - PPD file */
   * Support files...
   */
 
-  pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+  pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
 
   for (ppd_attr = ppdFindAttr(ppd, "cupsICCProfile", NULL);
        ppd_attr;
@@ -2349,6 +2349,7 @@ ppd_inputslot_for_keyword(
   return (NULL);
 }
 
+
 /*
  * '_ppdCacheGetInputSlot()' - Get the PPD InputSlot associated with the job
  *                        attributes or a keyword string.
@@ -3539,7 +3540,7 @@ _ppdCreateFromIPP2(
   else
     strlcpy(ppdname, "Unknown", sizeof(ppdname));
 
-  sizes = cupsArrayNew3((cups_array_func_t)pwg_compare_sizes, NULL, NULL, 0, (cups_acopy_func_t)pwg_copy_size, (cups_afree_func_t)free);
+  sizes = cupsArrayNew3((cups_array_func_t)pwg_compare_sizes, NULL, NULL, 0, (cups_acopy_func_t)pwg_copy_size, _cupsArrayFree);
 
   if ((attr = ippFindAttribute(supported, "media-col-database", IPP_TAG_BEGIN_COLLECTION)) != NULL)
   {
@@ -4494,8 +4495,8 @@ _ppdCreateFromIPP2(
     };
 
     count       = ippGetCount(attr);
-    names       = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
-    fin_options = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+    names       = cupsArrayNew3((cups_array_func_t)_cupsArrayStrcmp, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
+    fin_options = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
 
    /*
     * Staple/Bind/Stitch
@@ -4851,7 +4852,7 @@ _ppdCreateFromIPP2(
     cupsFilePuts(fp, "*cupsFinishingTemplate none: \"\"\n");
     cupsFilePrintf(fp, "*%s.cupsFinishingTemplate none/%s: \"\"\n", lang->language, _cupsLangString(lang, _("None")));
 
-    templates = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+    templates = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
     count     = ippGetCount(attr);
 
     for (i = 0; i < count; i ++)
@@ -5371,11 +5372,13 @@ pwg_add_message(cups_array_t *a,        /* I - Message catalog */
  * 'pwg_compare_finishings()' - Compare two finishings values.
  */
 
-static int                             /* O - Result of comparison */
+static int /* O - Result of comparison */
 pwg_compare_finishings(
-    _pwg_finishings_t *a,              /* I - First finishings value */
-    _pwg_finishings_t *b)              /* I - Second finishings value */
+    _pwg_finishings_t *a, /* I - First finishings value */
+    _pwg_finishings_t *b, /* I - Second finishings value */
+    void *data)           /* Unused */
 {
+  (void)data;
   return ((int)b->value - (int)a->value);
 }
 
@@ -5384,10 +5387,12 @@ pwg_compare_finishings(
  * 'pwg_compare_sizes()' - Compare two media sizes...
  */
 
-static int                             /* O - Result of comparison */
-pwg_compare_sizes(cups_size_t *a,      /* I - First media size */
-                  cups_size_t *b)      /* I - Second media size */
+static int                        /* O - Result of comparison */
+pwg_compare_sizes(cups_size_t *a, /* I - First media size */
+                  cups_size_t *b, /* I - Second media size */
+                  void *data)     /* Unused */
 {
+  (void)data;
   return (strcmp(a->media, b->media));
 }
 
@@ -5396,12 +5401,13 @@ pwg_compare_sizes(cups_size_t *a,       /* I - First media size */
  * 'pwg_copy_size()' - Copy a media size.
  */
 
-static cups_size_t *                   /* O - New media size */
-pwg_copy_size(cups_size_t *size)       /* I - Media size to copy */
+static cups_size_t *             /* O - New media size */
+pwg_copy_size(cups_size_t *size, /* I - Media size to copy */
+              void *data)        /* Unused*/
 {
-  cups_size_t  *newsize = (cups_size_t *)calloc(1, sizeof(cups_size_t));
-                                       /* New media size */
-
+  cups_size_t *newsize = (cups_size_t *)calloc(1, sizeof(cups_size_t));
+  /* New media size */
+  (void)data;
   if (newsize)
     memcpy(newsize, size, sizeof(cups_size_t));
 
@@ -5414,9 +5420,10 @@ pwg_copy_size(cups_size_t *size) /* I - Media size to copy */
  */
 
 static void
-pwg_free_finishings(
-    _pwg_finishings_t *f)              /* I - Finishings value */
+pwg_free_finishings(_pwg_finishings_t *f, /* I - Finishings value */
+                    void *data)           /* Unused */
 {
+  (void)data;
   cupsFreeOptions(f->num_options, f->options);
   free(f);
 }
index ffbacadca1f06ebac89d7cce825c041c9a8943bf..07020ce651b0a1bcf46b19c8146cdc8a10af9d42 100644 (file)
@@ -218,7 +218,7 @@ cupsResolveConflicts(
   cupsArraySave(ppd->sorted_attrs);
 
   resolvers = NULL;
-  pass      = cupsArrayNew((cups_array_func_t)_cups_strcasecmp, NULL);
+  pass      = cupsArrayNew((cups_array_func_t)_cupsArrayStrcasecmp, NULL);
   tries     = 0;
 
   while (tries < 100 &&
@@ -228,7 +228,7 @@ cupsResolveConflicts(
     tries ++;
 
     if (!resolvers)
-      resolvers = cupsArrayNew((cups_array_func_t)_cups_strcasecmp, NULL);
+      resolvers = cupsArrayNew((cups_array_func_t)_cupsArrayStrcasecmp, NULL);
 
     for (consts = (_ppd_cups_uiconsts_t *)cupsArrayFirst(active), changed = 0;
          consts;
index 74908d451cf8ace4e1b791f74e7aaadf6e87269f..88de0ae8b0827926dcc17af8dae11b3a2c123143 100644 (file)
@@ -28,7 +28,7 @@
  * Local functions...
  */
 
-static int     ppd_compare_cparams(ppd_cparam_t *a, ppd_cparam_t *b);
+static int     ppd_compare_cparams(ppd_cparam_t *a, ppd_cparam_t *b, void *data);
 static void    ppd_handle_media(ppd_file_t *ppd);
 
 
@@ -1105,10 +1105,12 @@ ppdEmitString(ppd_file_t    *ppd,       /* I - PPD file record */
  * 'ppd_compare_cparams()' - Compare the order of two custom parameters.
  */
 
-static int                             /* O - Result of comparison */
-ppd_compare_cparams(ppd_cparam_t *a,   /* I - First parameter */
-                    ppd_cparam_t *b)   /* I - Second parameter */
+static int                           /* O - Result of comparison */
+ppd_compare_cparams(ppd_cparam_t *a, /* I - First parameter */
+                    ppd_cparam_t *b, /* I - Second parameter */
+                    void *data)      /* Unused */
 {
+  (void)data;
   return (a->order - b->order);
 }
 
index ea8491532a8ce58244a5f63c3260458212d785c3..45dcdfc0cb1c26797dbf9ff509a0c213ae038564 100644 (file)
@@ -511,7 +511,8 @@ _ppdGetLanguages(ppd_file_t *ppd)   /* I - PPD file */
   * Yes, load the list...
   */
 
-  if ((languages = cupsArrayNew((cups_array_func_t)strcmp, NULL)) == NULL)
+  if ((languages = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL)) ==
+      NULL)
     return (NULL);
 
   if ((value = strdup(attr->value)) == NULL)
index 4ce9fcc5cddcd5080a96825054e1fe701c27175d..92d91aa8e2e693eed71bf8bbe840ecde32db017d 100644 (file)
@@ -64,22 +64,20 @@ static ppd_attr_t   *ppd_add_attr(ppd_file_t *ppd, const char *name,
                                      const char *value);
 static ppd_choice_t    *ppd_add_choice(ppd_option_t *option, const char *name);
 static ppd_size_t      *ppd_add_size(ppd_file_t *ppd, const char *name);
-static int             ppd_compare_attrs(ppd_attr_t *a, ppd_attr_t *b);
-static int             ppd_compare_choices(ppd_choice_t *a, ppd_choice_t *b);
-static int             ppd_compare_coptions(ppd_coption_t *a,
-                                            ppd_coption_t *b);
-static int             ppd_compare_options(ppd_option_t *a, ppd_option_t *b);
+static int ppd_compare_attrs(ppd_attr_t *a, ppd_attr_t *b, void *data);
+static int ppd_compare_choices(ppd_choice_t *a, ppd_choice_t *b, void *data);
+static int ppd_compare_coptions(ppd_coption_t *a, ppd_coption_t *b, void *data);
+static int ppd_compare_options(ppd_option_t *a, ppd_option_t *b, void *data);
 static int             ppd_decode(char *string);
 static void            ppd_free_filters(ppd_file_t *ppd);
 static void            ppd_free_group(ppd_group_t *group);
 static void            ppd_free_option(ppd_option_t *option);
 static ppd_coption_t   *ppd_get_coption(ppd_file_t *ppd, const char *name);
-static ppd_cparam_t    *ppd_get_cparam(ppd_coption_t *opt,
-                                       const char *param,
-                                       const char *text);
-static ppd_group_t     *ppd_get_group(ppd_file_t *ppd, const char *name,
-                                      const char *text, _ppd_globals_t *pg,
-                                      cups_encoding_t encoding);
+static ppd_cparam_t *ppd_get_cparam(ppd_coption_t *opt, const char *param,
+                                    const char *text);
+static ppd_group_t *ppd_get_group(ppd_file_t *ppd, const char *name,
+                                  const char *text, _ppd_globals_t *pg,
+                                  cups_encoding_t encoding);
 static ppd_option_t    *ppd_get_option(ppd_group_t *group, const char *name);
 static _ppd_globals_t  *ppd_globals_alloc(void);
 #if defined(HAVE_PTHREAD_H) || defined(_WIN32)
@@ -88,13 +86,13 @@ static void         ppd_globals_free(_ppd_globals_t *g);
 #ifdef HAVE_PTHREAD_H
 static void            ppd_globals_init(void);
 #endif /* HAVE_PTHREAD_H */
-static int             ppd_hash_option(ppd_option_t *option);
+static int             ppd_hash_option(ppd_option_t *option, void *data);
 static int             ppd_read(cups_file_t *fp, _ppd_line_t *line,
-                                char *keyword, char *option, char *text,
-                                char **string, int ignoreblank,
-                                _ppd_globals_t *pg);
+                                                                                               char *keyword, char *option, char *text,
+                                                                                               char **string, int ignoreblank,
+                                                                                               _ppd_globals_t *pg);
 static int             ppd_update_filters(ppd_file_t *ppd,
-                                          _ppd_globals_t *pg);
+                                                                        _ppd_globals_t *pg);
 
 
 /*
@@ -2484,10 +2482,12 @@ ppd_add_size(ppd_file_t *ppd,           /* I - PPD file */
  * 'ppd_compare_attrs()' - Compare two attributes.
  */
 
-static int                             /* O - Result of comparison */
-ppd_compare_attrs(ppd_attr_t *a,       /* I - First attribute */
-                  ppd_attr_t *b)       /* I - Second attribute */
+static int                       /* O - Result of comparison */
+ppd_compare_attrs(ppd_attr_t *a, /* I - First attribute */
+                  ppd_attr_t *b, /* I - Second attribute */
+                  void *data)    /* Unused */
 {
+  (void)data;
   return (_cups_strcasecmp(a->name, b->name));
 }
 
@@ -2496,10 +2496,12 @@ ppd_compare_attrs(ppd_attr_t *a,        /* I - First attribute */
  * 'ppd_compare_choices()' - Compare two choices...
  */
 
-static int                             /* O - Result of comparison */
-ppd_compare_choices(ppd_choice_t *a,   /* I - First choice */
-                    ppd_choice_t *b)   /* I - Second choice */
+static int                           /* O - Result of comparison */
+ppd_compare_choices(ppd_choice_t *a, /* I - First choice */
+                    ppd_choice_t *b, /* I - Second choice */
+                    void *data)      /* Unused */
 {
+  (void)data;
   return (strcmp(a->option->keyword, b->option->keyword));
 }
 
@@ -2508,10 +2510,12 @@ ppd_compare_choices(ppd_choice_t *a,    /* I - First choice */
  * 'ppd_compare_coptions()' - Compare two custom options.
  */
 
-static int                             /* O - Result of comparison */
-ppd_compare_coptions(ppd_coption_t *a, /* I - First option */
-                     ppd_coption_t *b) /* I - Second option */
+static int                             /* O - Result of comparison */
+ppd_compare_coptions(ppd_coption_t *a, /* I - First option */
+                     ppd_coption_t *b, /* I - Second option */
+                     void *data)       /* Unused */
 {
+  (void)data;
   return (_cups_strcasecmp(a->keyword, b->keyword));
 }
 
@@ -2520,10 +2524,12 @@ ppd_compare_coptions(ppd_coption_t *a,  /* I - First option */
  * 'ppd_compare_options()' - Compare two options.
  */
 
-static int                             /* O - Result of comparison */
-ppd_compare_options(ppd_option_t *a,   /* I - First option */
-                    ppd_option_t *b)   /* I - Second option */
+static int                           /* O - Result of comparison */
+ppd_compare_options(ppd_option_t *a, /* I - First option */
+                    ppd_option_t *b, /* I - Second option */
+                    void *data)      /* Unused */
 {
+  (void)data;
   return (_cups_strcasecmp(a->keyword, b->keyword));
 }
 
@@ -2897,12 +2903,13 @@ ppd_globals_init(void)
  * 'ppd_hash_option()' - Generate a hash of the option name...
  */
 
-static int                             /* O - Hash index */
-ppd_hash_option(ppd_option_t *option /* I - Option */
-{
+static int                            /* O - Hash index */
+ppd_hash_option(ppd_option_t *option, /* I - Option */
+                void *data) {
   int          hash = 0;               /* Hash index */
   const char   *k;                     /* Pointer into keyword */
 
+  (void)data;
 
   for (hash = option->keyword[0], k = option->keyword + 1; *k;)
     hash = (int)(33U * (unsigned)hash) + *k++;
index 3653739703ab02bab3b3895cca8f304f5e27046c..a56c058e38a5a4a7f98e3e8918a9b8b07a1977ce 100644 (file)
@@ -30,9 +30,9 @@
  * Local functions...
  */
 
-static int     pwg_compare_legacy(pwg_media_t *a, pwg_media_t *b);
-static int     pwg_compare_pwg(pwg_media_t *a, pwg_media_t *b);
-static int     pwg_compare_ppd(pwg_media_t *a, pwg_media_t *b);
+static int     pwg_compare_legacy(pwg_media_t *a, pwg_media_t *b, void *data);
+static int     pwg_compare_pwg(pwg_media_t *a, pwg_media_t *b, void *data);
+static int     pwg_compare_ppd(pwg_media_t *a, pwg_media_t *b, void *data);
 static char    *pwg_format_inches(char *buf, size_t bufsize, int val);
 static char    *pwg_format_millimeters(char *buf, size_t bufsize, int val);
 static int     pwg_scan_measurement(const char *buf, char **bufptr, int numer, int denom);
@@ -1058,10 +1058,12 @@ _pwgMediaTable(size_t *num_media)       /* O - Number of entries */
  * 'pwg_compare_legacy()' - Compare two sizes using the legacy names.
  */
 
-static int                             /* O - Result of comparison */
-pwg_compare_legacy(pwg_media_t *a,     /* I - First size */
-                   pwg_media_t *b)     /* I - Second size */
+static int                         /* O - Result of comparison */
+pwg_compare_legacy(pwg_media_t *a, /* I - First size */
+                   pwg_media_t *b, /* I - Second size */
+                   void *data)     /* Unused */
 {
+  (void)data;
   return (strcmp(a->legacy, b->legacy));
 }
 
@@ -1070,10 +1072,12 @@ pwg_compare_legacy(pwg_media_t *a,      /* I - First size */
  * 'pwg_compare_ppd()' - Compare two sizes using the PPD names.
  */
 
-static int                             /* O - Result of comparison */
-pwg_compare_ppd(pwg_media_t *a,        /* I - First size */
-                pwg_media_t *b)        /* I - Second size */
+static int                      /* O - Result of comparison */
+pwg_compare_ppd(pwg_media_t *a, /* I - First size */
+                pwg_media_t *b, /* I - Second size */
+                void *data)     /* Unused */
 {
+  (void)data;
   return (strcmp(a->ppd, b->ppd));
 }
 
@@ -1082,10 +1086,12 @@ pwg_compare_ppd(pwg_media_t *a, /* I - First size */
  * 'pwg_compare_pwg()' - Compare two sizes using the PWG names.
  */
 
-static int                             /* O - Result of comparison */
-pwg_compare_pwg(pwg_media_t *a,        /* I - First size */
-                pwg_media_t *b)        /* I - Second size */
+static int                      /* O - Result of comparison */
+pwg_compare_pwg(pwg_media_t *a, /* I - First size */
+                pwg_media_t *b, /* I - Second size */
+                void *data)     /* Unused */
 {
+  (void)data;
   return (strcmp(a->pwg, b->pwg));
 }
 
index 335e579c86ce4e209e0fc0002ed0aa55d89a92b8..df5873c8ca214821f46350c4cf7d0d01872c60bf 100644 (file)
@@ -180,6 +180,8 @@ extern void _cupsStrFree(const char *s) _CUPS_PRIVATE;
 extern char    *_cupsStrRetain(const char *s) _CUPS_PRIVATE;
 extern size_t  _cupsStrStatistics(size_t *alloc_bytes, size_t *total_bytes) _CUPS_PRIVATE;
 
+extern char *_cupsStrPrivAlloc(const char *s, void *data) _CUPS_PRIVATE;
+extern void _cupsStrPrivFree(const char *s, void *data) _CUPS_PRIVATE;
 
 /*
  * Floating point number functions...
@@ -197,6 +199,13 @@ extern double      _cupsStrScand(const char *buf, char **bufptr,
 
 extern char    *_cupsStrDate(char *buf, size_t bufsize, time_t timeval) _CUPS_PRIVATE;
 
+extern int _cupsArrayStrcmp(const char *s1, const char *s2, void *data) _CUPS_PRIVATE;
+
+extern int _cupsArrayStrcasecmp(const char *s, const char *t, void *data) _CUPS_PRIVATE;
+
+extern char *_cupsArrayStrdup(const char *element, void *data) _CUPS_PRIVATE;
+
+extern void _cupsArrayFree(void *element, void *data) _CUPS_PRIVATE;
 
 /*
  * C++ magic...
index b4fc12050c8be0b04c744698784255759ca8acaf..770616cf521bc3a0dd35d9904244b40a866e8fe5 100644 (file)
@@ -34,8 +34,7 @@ static cups_array_t   *stringpool = NULL;
  * Local functions...
  */
 
-static int     compare_sp_items(_cups_sp_item_t *a, _cups_sp_item_t *b);
-
+static int compare_sp_items(_cups_sp_item_t *a, _cups_sp_item_t *b, void *data);
 
 /*
  * '_cupsStrAlloc()' - Allocate/reference a string.
@@ -136,6 +135,32 @@ _cupsStrAlloc(const char *s)               /* I - String */
 }
 
 
+/*
+ * '_cupsStrPrivAlloc()' - Allocate/reference a string.
+ */
+
+char *                           /* O - String pointer */
+_cupsStrPrivAlloc(const char *s, /* I - String */
+                  void *data)    /* Unused */
+{
+  (void)data;
+  return _cupsStrAlloc(s);
+}
+
+
+/*
+ * '_cupsStrPrivFree()' - Free a string.
+ */
+
+void                            /* O - String pointer */
+_cupsStrPrivFree(const char *s, /* I - String */
+                 void *data)    /* Unused */
+{
+  (void)data;
+  _cupsStrFree(s);
+}
+
+
 /*
  * '_cupsStrDate()' - Return a localized date for a given time value.
  *
@@ -621,11 +646,15 @@ int                               /* O - Result of comparison (-1, 0, or 1) */
 _cups_strcasecmp(const char *s,        /* I - First string */
                  const char *t)        /* I - Second string */
 {
+  char u, v;
   while (*s != '\0' && *t != '\0')
   {
-    if (_cups_tolower(*s) < _cups_tolower(*t))
+    u = _cups_tolower(*s);
+    v = _cups_tolower(*t);
+
+    if (u < v)
       return (-1);
-    else if (_cups_tolower(*s) > _cups_tolower(*t))
+    else if (u > v)
       return (1);
 
     s ++;
@@ -640,6 +669,7 @@ _cups_strcasecmp(const char *s,     /* I - First string */
     return (-1);
 }
 
+
 /*
  * '_cups_strncasecmp()' - Do a case-insensitive comparison on up to N chars.
  */
@@ -649,11 +679,14 @@ _cups_strncasecmp(const char *s,  /* I - First string */
                   const char *t,       /* I - Second string */
                  size_t     n)         /* I - Maximum number of characters to compare */
 {
+  char u, v;
   while (*s != '\0' && *t != '\0' && n > 0)
   {
-    if (_cups_tolower(*s) < _cups_tolower(*t))
+    u = _cups_tolower(*s);
+    v = _cups_tolower(*t);
+    if (u < v)
       return (-1);
-    else if (_cups_tolower(*s) > _cups_tolower(*t))
+    else if (u > v)
       return (1);
 
     s ++;
@@ -761,9 +794,24 @@ _cups_strlcpy(char       *dst,             /* O - Destination string */
  * 'compare_sp_items()' - Compare two string pool items...
  */
 
-static int                             /* O - Result of comparison */
-compare_sp_items(_cups_sp_item_t *a,   /* I - First item */
-                 _cups_sp_item_t *b)   /* I - Second item */
+static int                           /* O - Result of comparison */
+compare_sp_items(_cups_sp_item_t *a, /* I - First item */
+                 _cups_sp_item_t *b, /* I - Second item */
+                 void *data)         /* Unused */
 {
+  (void)data;
   return (strcmp(a->str, b->str));
 }
+
+
+/*
+ * '_cupsArrayStrcasecmp()' - Compare two strings...
+ */
+
+int _cupsArrayStrcasecmp(const char *s, /* I - First string */
+                         const char *t, /* I - Second string */
+                         void *data)    /* Unused */
+{
+  (void)data;
+  return _cups_strcasecmp(s, t);
+}
index 185fcbec57c0a621a0176aee5eb7ccc367840f21..a224fce85e01087b3a598427dfe5b9ef9e229eec 100644 (file)
@@ -59,7 +59,7 @@ main(void)
   fputs("cupsArrayNew: ", stdout);
 
   data  = (void *)"testarray";
-  array = cupsArrayNew((cups_array_func_t)strcmp, data);
+  array = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, data);
 
   if (array)
     puts("PASS");
index 5c652fdb90ecdddcccec678e5430390b96018e4f..153dc7b67f73f9df0f6ef8dd622ee22b0db2708a 100644 (file)
@@ -45,7 +45,7 @@ static char           *rss_password;  /* Password for remote RSS */
  * Local functions...
  */
 
-static int             compare_rss(_cups_rss_t *a, _cups_rss_t *b);
+static int             compare_rss(_cups_rss_t *a, _cups_rss_t *b, void *data);
 static void            delete_message(_cups_rss_t *msg);
 static void            load_rss(cups_array_t *rss, const char *filename);
 static _cups_rss_t     *new_message(int sequence_number, char *subject,
@@ -397,10 +397,12 @@ main(int  argc,                           /* I - Number of command-line arguments */
  * 'compare_rss()' - Compare two messages.
  */
 
-static int                             /* O - Result of comparison */
-compare_rss(_cups_rss_t *a,            /* I - First message */
-            _cups_rss_t *b)            /* I - Second message */
+static int                  /* O - Result of comparison */
+compare_rss(_cups_rss_t *a, /* I - First message */
+            _cups_rss_t *b, /* I - Second message */
+            void *data)     /* Unused */
 {
+  (void)data;
   return (a->sequence_number - b->sequence_number);
 }
 
index 385f456413ed4c7b5354610db3a5b05545a10d62..213b0a23d8586020589ee6be0111c9627673694a 100644 (file)
@@ -69,7 +69,7 @@ main(int  argc,                               // I - Number of command-line arguments
   src             = new ppdcSource();
   use_model_name  = 0;
   verbose         = 0;
-  filenames       = cupsArrayNew((cups_array_func_t)_cups_strcasecmp, NULL);
+  filenames       = cupsArrayNew((cups_array_func_t)_cupsArrayStrcasecmp, NULL);
 
   for (i = 1; i < argc; i ++)
     if (argv[i][0] == '-')
index cd83964fae12ba5be68d15fff4ea34e09833a5d1..3edd99f4ead45af7b95079081254c56362b724c2 100644 (file)
@@ -174,7 +174,7 @@ main(int  argc,                             // I - Number of command-line arguments
 
   // Loop through the PPD files we loaded to generate a new language list...
   if (!languages)
-    languages = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+    languages = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
 
   for (ppd = (ppd_file_t *)cupsArrayFirst(ppds);
        ppd;
index 7f6c3f6d2ff2b0a9f11200dd914230e65287d02c..5de91b34dd73568959e69ba3e0ca220d3f15779d 100644 (file)
@@ -70,7 +70,8 @@ static int            check_admin_access(cupsd_client_t *con);
 static int             check_authref(cupsd_client_t *con, const char *right);
 #endif /* HAVE_AUTHORIZATION_H */
 static int             compare_locations(cupsd_location_t *a,
-                                         cupsd_location_t *b);
+                                                                                                                               cupsd_location_t *b,
+                                                                                                                               void *data);
 static cupsd_authmask_t        *copy_authmask(cupsd_authmask_t *am, void *data);
 static void            free_authmask(cupsd_authmask_t *am, void *data);
 #if HAVE_LIBPAM
@@ -162,8 +163,8 @@ cupsdAddName(cupsd_location_t *loc, /* I - Location to add to */
 
   if (!loc->names)
     loc->names = cupsArrayNew3(NULL, NULL, NULL, 0,
-                               (cups_acopy_func_t)_cupsStrAlloc,
-                               (cups_afree_func_t)_cupsStrFree);
+                               (cups_acopy_func_t)_cupsStrPrivAlloc,
+                               (cups_afree_func_t)_cupsStrPrivFree);
 
   if (!cupsArrayAdd(loc->names, name))
   {
@@ -1310,7 +1311,7 @@ cupsdCopyLocation(
                       "Unable to allocate memory for %d names: %s",
                      cupsArrayCount(loc->names), strerror(errno));
 
-      cupsdFreeLocation(temp);
+      cupsdFreeLocation(temp, NULL);
       return (NULL);
     }
   }
@@ -1326,7 +1327,7 @@ cupsdCopyLocation(
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "Unable to allocate memory for %d allow rules: %s",
                       cupsArrayCount(loc->allow), strerror(errno));
-      cupsdFreeLocation(temp);
+      cupsdFreeLocation(temp, NULL);
       return (NULL);
     }
   }
@@ -1342,7 +1343,7 @@ cupsdCopyLocation(
       cupsdLogMessage(CUPSD_LOG_ERROR,
                       "Unable to allocate memory for %d deny rules: %s",
                       cupsArrayCount(loc->deny), strerror(errno));
-      cupsdFreeLocation(temp);
+      cupsdFreeLocation(temp, NULL);
       return (NULL);
     }
   }
@@ -1509,9 +1510,10 @@ cupsdFindLocation(const char *location)  /* I - Connection */
  * 'cupsdFreeLocation()' - Free all memory used by a location.
  */
 
-void
-cupsdFreeLocation(cupsd_location_t *loc)/* I - Location to free */
+void cupsdFreeLocation(cupsd_location_t *loc, /* I - Location to free */
+                       void *data)            /* Unused */
 {
+  (void)data;
   cupsArrayDelete(loc->names);
   cupsArrayDelete(loc->allow);
   cupsArrayDelete(loc->deny);
@@ -2199,10 +2201,12 @@ check_authref(cupsd_client_t *con,      /* I - Connection */
  * 'compare_locations()' - Compare two locations.
  */
 
-static int                             /* O - Result of comparison */
-compare_locations(cupsd_location_t *a, /* I - First location */
-                  cupsd_location_t *b) /* I - Second location */
+static int                             /* O - Result of comparison */
+compare_locations(cupsd_location_t *a, /* I - First location */
+                  cupsd_location_t *b, /* I - Second location */
+                  void *data)          /* Unused */
 {
+  (void)data;
   return (strcmp(b->location, a->location));
 }
 
index 14885b0283de900949a14f47d439c922c0459b47..01c55aa2c4b3205487d37b28e2b5a892d7884821 100644 (file)
@@ -133,6 +133,6 @@ extern cupsd_location_t     *cupsdCopyLocation(cupsd_location_t *loc);
 extern void            cupsdDeleteAllLocations(void);
 extern cupsd_location_t        *cupsdFindBest(const char *path, http_state_t state);
 extern cupsd_location_t        *cupsdFindLocation(const char *location);
-extern void            cupsdFreeLocation(cupsd_location_t *loc);
+extern void            cupsdFreeLocation(cupsd_location_t *loc, void *data);
 extern http_status_t   cupsdIsAuthorized(cupsd_client_t *con, const char *owner);
 extern cupsd_location_t        *cupsdNewLocation(const char *location);
index e9399230209ab1475c729d7b7f5fe5167acf14f2..ed4078bc0bbcdc2eeba8b4562dcdc3beaa2b619e 100644 (file)
@@ -21,7 +21,8 @@
 
 static void    add_banner(const char *name, const char *filename);
 static int     compare_banners(const cupsd_banner_t *b0,
-                               const cupsd_banner_t *b1);
+                                                                                                               const cupsd_banner_t *b1,
+                                                                                                               void *data);
 static void    free_banners(void);
 
 
@@ -173,11 +174,12 @@ add_banner(const char *name,              /* I - Name of banner */
  * 'compare_banners()' - Compare two banners.
  */
 
-static int                             /* O - -1 if name0 < name1, etc. */
-compare_banners(
-    const cupsd_banner_t *b0,          /* I - First banner */
-    const cupsd_banner_t *b1)          /* I - Second banner */
+static int                                /* O - -1 if name0 < name1, etc. */
+compare_banners(const cupsd_banner_t *b0, /* I - First banner */
+                const cupsd_banner_t *b1, /* I - Second banner */
+                void *data)               /* Unused */
 {
+  (void)data;
   return (_cups_strcasecmp(b0->name, b1->name));
 }
 
index 91e441188c9ed5d60fa7b82e876e938468b456b9..90731441dc881760083472f2a825b583b0518b63 100644 (file)
 static int             check_if_modified(cupsd_client_t *con,
                                          struct stat *filestats);
 static int             compare_clients(cupsd_client_t *a, cupsd_client_t *b,
-                                       void *data);
+                              void *data);
 #ifdef HAVE_TLS
 static int             cupsd_start_tls(cupsd_client_t *con, http_encryption_t e);
 #endif /* HAVE_TLS */
 static char            *get_file(cupsd_client_t *con, struct stat *filestats,
-                                 char *filename, size_t len);
+                        char *filename, size_t len);
 static http_status_t   install_cupsd_conf(cupsd_client_t *con);
 static int             is_cgi(cupsd_client_t *con, const char *filename,
-                              struct stat *filestats, mime_type_t *type);
+                    struct stat *filestats, mime_type_t *type);
 static int             is_path_absolute(const char *path);
 static int             pipe_command(cupsd_client_t *con, int infile, int *outfile,
-                                    char *command, char *options, int root);
+                           char *command, char *options, int root);
 static int             valid_host(cupsd_client_t *con);
 static int             write_file(cupsd_client_t *con, http_status_t code,
-                                  char *filename, char *type,
-                                  struct stat *filestats);
+                         char *filename, char *type,
+                         struct stat *filestats);
 static void            write_pipe(cupsd_client_t *con);
 
 
@@ -2641,10 +2641,10 @@ check_if_modified(
  * 'compare_clients()' - Compare two client connections.
  */
 
-static int                             /* O - Result of comparison */
-compare_clients(cupsd_client_t *a,     /* I - First client */
-                cupsd_client_t *b,     /* I - Second client */
-                void           *data)  /* I - User data (not used) */
+static int                         /* O - Result of comparison */
+compare_clients(cupsd_client_t *a, /* I - First client */
+                cupsd_client_t *b, /* I - Second client */
+                void *data)        /* I - User data (not used) */
 {
   (void)data;
 
index 809ed7c65ddfc1a3f85977f359d4dd681c89aa09..c025dbcfd4a07822b154fede7f2c6ac7e5311d0b 100644 (file)
@@ -1398,8 +1398,8 @@ colord_register_printer(
   * See if we have any embedded profiles...
   */
 
-  profiles = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup,
-                          (cups_afree_func_t)free);
+  profiles = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup,
+                          _cupsArrayFree);
   for (attr = ppdFindAttr(ppd, "cupsICCProfile", NULL);
        attr;
        attr = ppdFindNextAttr(ppd, "cupsICCProfile", NULL))
index ef45e92671f9039ef60a59dec3f46f659ee2c22a..28eea0da935b68a9d0904e837231c5c5b15e8078 100644 (file)
@@ -155,13 +155,16 @@ static int                cat_drv(const char *name, int request_id);
 static void            cat_ppd(const char *name, int request_id) _CUPS_NORETURN;
 static int             cat_static(const char *name, int request_id);
 static int             cat_tar(const char *name, int request_id);
-static int             compare_inodes(struct stat *a, struct stat *b);
-static int             compare_matches(const ppd_info_t *p0,
-                                       const ppd_info_t *p1);
-static int             compare_names(const ppd_info_t *p0,
-                                     const ppd_info_t *p1);
-static int             compare_ppds(const ppd_info_t *p0,
-                                    const ppd_info_t *p1);
+static int             compare_inodes(struct stat *a, struct stat *b, void *data);
+static int             compare_matches(const ppd_info_t *p0,
+                              const ppd_info_t *p1,
+                              void *data);
+static int             compare_names(const ppd_info_t *p0,
+                            const ppd_info_t *p1,
+                            void *data);
+static int             compare_ppds(const ppd_info_t *p0,
+                           const ppd_info_t *p1,
+                           void *data);
 static void            dump_ppds_dat(const char *filename) _CUPS_NORETURN;
 static void            free_array(cups_array_t *a);
 static cups_file_t     *get_file(const char *name, int request_id,
@@ -701,10 +704,13 @@ cat_tar(const char *name,         /* I - PPD name */
  * 'compare_inodes()' - Compare two inodes.
  */
 
-static int                             /* O - Result of comparison */
-compare_inodes(struct stat *a,         /* I - First inode */
-               struct stat *b)         /* I - Second inode */
+static int                     /* O - Result of comparison */
+compare_inodes(struct stat *a, /* I - First inode */
+               struct stat *b, /* I - Second inode */
+               void *data)     /* Unused */
 {
+  (void)data;
+
   if (a->st_dev != b->st_dev)
     return (a->st_dev - b->st_dev);
   else
@@ -716,10 +722,12 @@ compare_inodes(struct stat *a,            /* I - First inode */
  * 'compare_matches()' - Compare PPD match scores for sorting.
  */
 
-static int
-compare_matches(const ppd_info_t *p0,  /* I - First PPD */
-                const ppd_info_t *p1)  /* I - Second PPD */
+static int compare_matches(const ppd_info_t *p0, /* I - First PPD */
+                           const ppd_info_t *p1, /* I - Second PPD */
+                           void *data)           /* Unused */
 {
+  (void)data;
+
   if (p1->matches != p0->matches)
     return (p1->matches - p0->matches);
   else
@@ -732,12 +740,14 @@ compare_matches(const ppd_info_t *p0,     /* I - First PPD */
  * 'compare_names()' - Compare PPD filenames for sorting.
  */
 
-static int                             /* O - Result of comparison */
-compare_names(const ppd_info_t *p0,    /* I - First PPD file */
-              const ppd_info_t *p1)    /* I - Second PPD file */
+static int                          /* O - Result of comparison */
+compare_names(const ppd_info_t *p0, /* I - First PPD file */
+              const ppd_info_t *p1, /* I - Second PPD file */
+              void *data)           /* Unused */
 {
   int  diff;                           /* Difference between strings */
 
+  (void)data;
 
   if ((diff = strcmp(p0->record.filename, p1->record.filename)) != 0)
     return (diff);
@@ -750,9 +760,10 @@ compare_names(const ppd_info_t *p0,        /* I - First PPD file */
  * 'compare_ppds()' - Compare PPD file make and model names for sorting.
  */
 
-static int                             /* O - Result of comparison */
-compare_ppds(const ppd_info_t *p0,     /* I - First PPD file */
-             const ppd_info_t *p1)     /* I - Second PPD file */
+static int                         /* O - Result of comparison */
+compare_ppds(const ppd_info_t *p0, /* I - First PPD file */
+             const ppd_info_t *p1, /* I - Second PPD file */
+             void *data)           /* Unused */
 {
   int  diff;                           /* Difference between strings */
 
@@ -761,6 +772,8 @@ compare_ppds(const ppd_info_t *p0,  /* I - First PPD file */
   * First compare manufacturers...
   */
 
+  (void)data;
+
   if ((diff = _cups_strcasecmp(p0->record.make, p1->record.make)) != 0)
     return (diff);
   else if ((diff = cupsdCompareNames(p0->record.make_and_model,
@@ -770,7 +783,7 @@ compare_ppds(const ppd_info_t *p0,  /* I - First PPD file */
                           p1->record.languages[0])) != 0)
     return (diff);
   else
-    return (compare_names(p0, p1));
+    return (compare_names(p0, p1, NULL));
 }
 
 
index bc1350e7e7640376469a6744a0b6fd875cea1dcf..58a3512839f84220b83e06dd8df84da0f9d2d60a 100644 (file)
@@ -220,3 +220,7 @@ extern void         cupsdStopSelect(void);
 /* server.c */
 extern void            cupsdStartServer(void);
 extern void            cupsdStopServer(void);
+
+extern int             _cupsArrayStrcmp(const char *s1, const char *s2, void *data);
+extern char            *_cupsArrayStrdup(const char *element, void *data);
+extern void            _cupsArrayFree(void *element, void *data);
index dc9ba898a1ca70080340c942564ff9fa4c7225cf..2e28c96429723e2e623550c3616075c0510edbb5 100644 (file)
@@ -60,7 +60,7 @@ static mime_type_t    *add_printer_filters(const char *command,
                                             mime_type_t **prefilter_type);
 static void            check_cb(void *context, _cups_fc_result_t result,
                                 const char *message);
-static int             compare_pids(mime_filter_t *a, mime_filter_t *b);
+static int             compare_pids(mime_filter_t *a, mime_filter_t *b, void *data);
 static char            *escape_options(int num_options, cups_option_t *options);
 static int             exec_filter(const char *filter, char **argv,
                                    char **envp, int infd, int outfd);
@@ -769,14 +769,17 @@ check_cb(void              *context,      /* I - Context (command name) */
  * 'compare_pids()' - Compare two filter PIDs...
  */
 
-static int                             /* O - Result of comparison */
-compare_pids(mime_filter_t *a,         /* I - First filter */
-             mime_filter_t *b)         /* I - Second filter */
+static int                     /* O - Result of comparison */
+compare_pids(mime_filter_t *a, /* I - First filter */
+             mime_filter_t *b, /* I - Second filter */
+             void *data)       /* Unused */
 {
- /*
-  * Because we're particularly lazy, we store the process ID in the "cost"
-  * variable...
-  */
+  /*
+   * Because we're particularly lazy, we store the process ID in the "cost"
+   * variable...
+   */
+
+  (void)data;
 
   return (a->cost - b->cost);
 }
index 5596d623ccd0f2c9ebb1ad56fc4d37d39ae39959..aa96f131326a8fa10858c7b4306796d5f79df5b9 100644 (file)
@@ -38,8 +38,8 @@ typedef struct _mime_typelist_s               /**** List of source types ****/
  * Local functions...
  */
 
-static int             mime_compare_filters(mime_filter_t *, mime_filter_t *);
-static int             mime_compare_srcs(mime_filter_t *, mime_filter_t *);
+static int             mime_compare_filters(mime_filter_t *, mime_filter_t *, void *);
+static int             mime_compare_srcs(mime_filter_t *, mime_filter_t *, void *);
 static cups_array_t    *mime_find_filters(mime_t *mime, mime_type_t *src,
                                      size_t srcsize, mime_type_t *dst,
                                      int *cost, _mime_typelist_t *visited);
@@ -258,12 +258,14 @@ mimeFilterLookup(mime_t      *mime,       /* I - MIME database */
  * 'mime_compare_filters()' - Compare two filters.
  */
 
-static int                             /* O - Comparison result */
-mime_compare_filters(mime_filter_t *f0,        /* I - First filter */
-                     mime_filter_t *f1)        /* I - Second filter */
+static int                              /* O - Comparison result */
+mime_compare_filters(mime_filter_t *f0, /* I - First filter */
+                     mime_filter_t *f1, /* I - Second filter */
+                     void *data)        /* Unused */
 {
   int  i;                              /* Result of comparison */
 
+  (void)data;
 
   if ((i = strcmp(f0->src->super, f1->src->super)) == 0)
     if ((i = strcmp(f0->src->type, f1->src->type)) == 0)
@@ -278,13 +280,13 @@ mime_compare_filters(mime_filter_t *f0,   /* I - First filter */
  * 'mime_compare_srcs()' - Compare two filter source types.
  */
 
-static int                             /* O - Comparison result */
-mime_compare_srcs(mime_filter_t *f0,   /* I - First filter */
-                  mime_filter_t *f1)   /* I - Second filter */
-{
+static int                           /* O - Comparison result */
+mime_compare_srcs(mime_filter_t *f0, /* I - First filter */
+                  mime_filter_t *f1, /* I - Second filter */
+                  void *data) {
   int  i;                              /* Result of comparison */
 
-
+  (void)data;
   if ((i = strcmp(f0->src->super, f1->src->super)) == 0)
     i = strcmp(f0->src->type, f1->src->type);
 
index 5ac782e7599d44aa7aed19174fd06a849a76c9f9..71cb2b34a07ad7a312f761b954b2cdb87cf487b5 100644 (file)
@@ -2898,10 +2898,10 @@ cupsdUpdateJobs(void)
  * 'compare_active_jobs()' - Compare the job IDs and priorities of two jobs.
  */
 
-static int                             /* O - Difference */
-compare_active_jobs(void *first,       /* I - First job */
-                    void *second,      /* I - Second job */
-                   void *data)         /* I - App data (not used) */
+static int                        /* O - Difference */
+compare_active_jobs(void *first,  /* I - First job */
+                    void *second, /* I - Second job */
+                    void *data)   /* I - App data (not used) */
 {
   int  diff;                           /* Difference */
 
@@ -2920,10 +2920,10 @@ compare_active_jobs(void *first,        /* I - First job */
  * 'compare_completed_jobs()' - Compare the job IDs and completion times of two jobs.
  */
 
-static int                             /* O - Difference */
-compare_completed_jobs(void *first,    /* I - First job */
-                       void *second,   /* I - Second job */
-                      void *data)      /* I - App data (not used) */
+static int                           /* O - Difference */
+compare_completed_jobs(void *first,  /* I - First job */
+                       void *second, /* I - Second job */
+                       void *data)   /* I - App data (not used) */
 {
   int  diff;                           /* Difference */
 
@@ -2942,10 +2942,10 @@ compare_completed_jobs(void *first,     /* I - First job */
  * 'compare_jobs()' - Compare the job IDs of two jobs.
  */
 
-static int                             /* O - Difference */
-compare_jobs(void *first,              /* I - First job */
-             void *second,             /* I - Second job */
-            void *data)                /* I - App data (not used) */
+static int                 /* O - Difference */
+compare_jobs(void *first,  /* I - First job */
+             void *second, /* I - Second job */
+             void *data)   /* I - App data (not used) */
 {
   (void)data;
 
index d971d4ffe819e8242f658e3e0a37e042cc9d8475..3fae37c431fd3b458e490d378682cbe54d3574c8 100644 (file)
@@ -1216,10 +1216,10 @@ cupsdAddString(cups_array_t **a,        /* IO - String array */
                const char   *s)                /* I  - String to copy and add */
 {
   if (!*a)
-    *a = cupsArrayNew3((cups_array_func_t)strcmp, NULL,
+    *a = cupsArrayNew3((cups_array_func_t)_cupsArrayStrcmp, NULL,
                       (cups_ahash_func_t)NULL, 0,
-                      (cups_acopy_func_t)strdup,
-                      (cups_afree_func_t)free);
+                      (cups_acopy_func_t)_cupsArrayStrdup,
+                      _cupsArrayFree);
 
   return (cupsArrayAdd(*a, (char *)s));
 }
index d60d4efb955a3ea4382c40eb0e53cdc3f00cdc08..9fe90bd6a449ac2f154e97d53adabdb6443f706e 100644 (file)
@@ -41,7 +41,7 @@ typedef struct _mime_fcache_s         /**** Filter cache structure ****/
 
 static const char *mime_add_fcache(cups_array_t *filtercache, const char *name,
                                   const char *filterpath);
-static int     mime_compare_fcache(_mime_fcache_t *a, _mime_fcache_t *b);
+static int     mime_compare_fcache(_mime_fcache_t *a, _mime_fcache_t *b, void *data);
 static void    mime_delete_fcache(cups_array_t *filtercache);
 static void    mime_delete_rules(mime_magic_t *rules);
 static void    mime_load_convs(mime_t *mime, const char *filename,
@@ -576,10 +576,12 @@ mime_add_fcache(
  * 'mime_compare_fcache()' - Compare two filter cache entries.
  */
 
-static int                             /* O - Result of comparison */
-mime_compare_fcache(_mime_fcache_t *a, /* I - First entry */
-               _mime_fcache_t *b)      /* I - Second entry */
+static int                             /* O - Result of comparison */
+mime_compare_fcache(_mime_fcache_t *a, /* I - First entry */
+                    _mime_fcache_t *b, /* I - Second entry */
+                    void *data)        /* Unused */
 {
+  (void)data;
   return (strcmp(a->name, b->name));
 }
 
index 5ba00a1fb636832e2244ba67e84c47f11fd0c845..7e389c55a454784e71fc515052e65fbf945d1aa0 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 static void    cupsdNetIFFree(void);
-static int     compare_netif(cupsd_netif_t *a, cupsd_netif_t *b);
+static int     compare_netif(cupsd_netif_t *a, cupsd_netif_t *b, void *data);
 
 
 /*
@@ -285,9 +285,11 @@ cupsdNetIFUpdate(void)
  * 'compare_netif()' - Compare two network interfaces.
  */
 
-static int                             /* O - Result of comparison */
-compare_netif(cupsd_netif_t *a,                /* I - First network interface */
-              cupsd_netif_t *b)                /* I - Second network interface */
+static int                      /* O - Result of comparison */
+compare_netif(cupsd_netif_t *a, /* I - First network interface */
+              cupsd_netif_t *b, /* I - Second network interface */
+              void *data)       /* Unused */
 {
+  (void)data;
   return (strcmp(a->name, b->name));
 }
index 20c91c8350ba987df15c625873527e6a4c72c40c..dde53500dae8981427618779331e1c8ecaf85e2a 100644 (file)
  * Local functions...
  */
 
-static int     compare_ops(cupsd_location_t *a, cupsd_location_t *b);
-static int     compare_policies(cupsd_policy_t *a, cupsd_policy_t *b);
-static void    free_policy(cupsd_policy_t *p);
-static int     hash_op(cupsd_location_t *op);
+static int     compare_ops(cupsd_location_t *a, cupsd_location_t *b, void *data);
+static int     compare_policies(cupsd_policy_t *a, cupsd_policy_t *b, void *data);
+static void    free_policy(cupsd_policy_t *p, void *data);
+static int     hash_op(cupsd_location_t *op, void *data);
 
 
 /*
@@ -448,10 +448,12 @@ cupsdGetPrivateAttrs(
  * 'compare_ops()' - Compare two operations.
  */
 
-static int                             /* O - Result of comparison */
-compare_ops(cupsd_location_t *a,       /* I - First operation */
-            cupsd_location_t *b)       /* I - Second operation */
+static int                       /* O - Result of comparison */
+compare_ops(cupsd_location_t *a, /* I - First operation */
+            cupsd_location_t *b, /* I - Second operation */
+            void *data)          /* Unused */
 {
+  (void)data;
   return (a->op - b->op);
 }
 
@@ -460,10 +462,12 @@ compare_ops(cupsd_location_t *a,  /* I - First operation */
  * 'compare_policies()' - Compare two policies.
  */
 
-static int                             /* O - Result of comparison */
-compare_policies(cupsd_policy_t *a,    /* I - First policy */
-                 cupsd_policy_t *b)    /* I - Second policy */
+static int                          /* O - Result of comparison */
+compare_policies(cupsd_policy_t *a, /* I - First policy */
+                 cupsd_policy_t *b, /* I - Second policy */
+                 void *data)        /* Unused */
 {
+  (void)data;
   return (_cups_strcasecmp(a->name, b->name));
 }
 
@@ -472,9 +476,10 @@ compare_policies(cupsd_policy_t *a,        /* I - First policy */
  * 'free_policy()' - Free the memory used by a policy.
  */
 
-static void
-free_policy(cupsd_policy_t *p)         /* I - Policy to free */
+static void free_policy(cupsd_policy_t *p, /* I - Policy to free */
+                        void *data)        /* Unused */
 {
+  (void)data;
   cupsArrayDelete(p->job_access);
   cupsArrayDelete(p->job_attrs);
   cupsArrayDelete(p->sub_access);
@@ -489,8 +494,10 @@ free_policy(cupsd_policy_t *p)             /* I - Policy to free */
  * 'hash_op()' - Generate a lookup hash for the operation.
  */
 
-static int                             /* O - Hash value */
-hash_op(cupsd_location_t *op)          /* I - Operation */
+static int                    /* O - Hash value */
+hash_op(cupsd_location_t *op, /* I - Operation */
+        void *data)           /* Unused */
 {
+  (void)data;
   return (((op->op >> 6) & 0x40) | (op->op & 0x3f));
 }
index 5f9852e64f661e3242ea7f30a1ba84bc4261cc3f..ec8b3871570a1137ce13519031e4c46d06ca179a 100644 (file)
@@ -517,7 +517,7 @@ cupsdCreateCommonData(void)
   snprintf(filename, sizeof(filename), "%s/notifier", ServerBin);
   if ((dir = cupsDirOpen(filename)) != NULL)
   {
-    notifiers = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+    notifiers = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
 
     while ((dent = cupsDirRead(dir)) != NULL)
     {
@@ -3285,7 +3285,7 @@ add_printer_defaults(cupsd_printer_t *p)/* I - Printer */
 
   if (!CommonDefaults)
   {
-    CommonDefaults = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+    CommonDefaults = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
 
     cupsArrayAdd(CommonDefaults, _cupsStrAlloc("copies-default"));
     cupsArrayAdd(CommonDefaults, _cupsStrAlloc("document-format-default"));
@@ -3685,15 +3685,15 @@ add_printer_formats(cupsd_printer_t *p) /* I - Printer */
  * 'compare_printers()' - Compare two printers.
  */
 
-static int                             /* O - Result of comparison */
-compare_printers(void *first,          /* I - First printer */
-                 void *second,         /* I - Second printer */
-                void *data)            /* I - App data (not used) */
+static int                     /* O - Result of comparison */
+compare_printers(void *first,  /* I - First printer */
+                 void *second, /* I - Second printer */
+                 void *data)   /* I - App data (not used) */
 {
   (void)data;
 
   return (_cups_strcasecmp(((cupsd_printer_t *)first)->name,
-                     ((cupsd_printer_t *)second)->name));
+                           ((cupsd_printer_t *)second)->name));
 }
 
 
index 840c0b88df45f6f0163f02c6f235a982eeb09835..221f1bf042d0b1282bc7ab6480d0cf4684142402 100644 (file)
@@ -59,7 +59,7 @@ static cups_array_t   *process_array = NULL;
  * Local functions...
  */
 
-static int     compare_procs(cupsd_proc_t *a, cupsd_proc_t *b);
+static int compare_procs(cupsd_proc_t *a, cupsd_proc_t *b, void *data);
 #ifdef HAVE_SANDBOX_H
 static char    *cupsd_requote(char *dst, const char *src, size_t dstsize);
 #endif /* HAVE_SANDBOX_H */
@@ -851,10 +851,12 @@ cupsdStartProcess(
  * 'compare_procs()' - Compare two processes.
  */
 
-static int                             /* O - Result of comparison */
-compare_procs(cupsd_proc_t *a,         /* I - First process */
-              cupsd_proc_t *b)         /* I - Second process */
+static int                     /* O - Result of comparison */
+compare_procs(cupsd_proc_t *a, /* I - First process */
+              cupsd_proc_t *b, /* I - Second process */
+              void *data)      /* Unused */
 {
+  (void)data;
   return (a->pid - b->pid);
 }
 
index d649dcb833f8e09452caa8901d2968d5d974fa35..e06e83794d72dd46fa7c2b07ebd3cd46cb8874ec 100644 (file)
@@ -19,9 +19,9 @@
  */
 
 static cupsd_quota_t   *add_quota(cupsd_printer_t *p, const char *username);
-static int             compare_quotas(const cupsd_quota_t *q1,
-                                      const cupsd_quota_t *q2);
-
+static int     compare_quotas(const cupsd_quota_t *q1,
+                           const cupsd_quota_t *q2,
+                           void *data);
 
 /*
  * 'cupsdFindQuota()' - Find a quota record.
@@ -217,9 +217,11 @@ add_quota(cupsd_printer_t *p,              /* I - Printer */
  * 'compare_quotas()' - Compare two quota records...
  */
 
-static int                             /* O - Result of comparison */
-compare_quotas(const cupsd_quota_t *q1,        /* I - First quota record */
-               const cupsd_quota_t *q2)        /* I - Second quota record */
+static int                              /* O - Result of comparison */
+compare_quotas(const cupsd_quota_t *q1, /* I - First quota record */
+               const cupsd_quota_t *q2, /* I - Second quota record */
+               void *data)              /* Unused */
 {
+  (void)data;
   return (_cups_strcasecmp(q1->username, q2->username));
 }
index 173155538ba325f4856742a902a185c4a99ceaef..3079f3d52b444b352837150dd66f99ff1538dcd4 100644 (file)
@@ -217,7 +217,7 @@ static fd_set               cupsd_global_input,
  * Local functions...
  */
 
-static int             compare_fds(_cupsd_fd_t *a, _cupsd_fd_t *b);
+static int     compare_fds(_cupsd_fd_t *a, _cupsd_fd_t *b, void *data);
 static _cupsd_fd_t     *find_fd(int fd);
 #define                        release_fd(f) { \
                          (f)->use --; \
@@ -887,10 +887,12 @@ cupsdStopSelect(void)
  * 'compare_fds()' - Compare file descriptors.
  */
 
-static int                             /* O - Result of comparison */
-compare_fds(_cupsd_fd_t *a,            /* I - First file descriptor */
-            _cupsd_fd_t *b)            /* I - Second file descriptor */
+static int                  /* O - Result of comparison */
+compare_fds(_cupsd_fd_t *a, /* I - First file descriptor */
+            _cupsd_fd_t *b, /* I - Second file descriptor */
+            void *data)     /* Unused */
 {
+  (void)data;
   return (a->fd - b->fd);
 }
 
index 9b31ec250e88cdce4cf846a578709151adb7af50..5212db7a4e6492605213cfa177917a23038f1fb4 100644 (file)
@@ -30,7 +30,7 @@
 static int     cupsd_compare_subscriptions(cupsd_subscription_t *first,
                                            cupsd_subscription_t *second,
                                            void *unused);
-static void    cupsd_delete_event(cupsd_event_t *event);
+static void cupsd_delete_event(cupsd_event_t *event, void *data);
 #ifdef HAVE_DBUS
 static void    cupsd_send_dbus(cupsd_eventmask_t event, cupsd_printer_t *dest,
                                cupsd_job_t *job);
@@ -1194,11 +1194,11 @@ cupsdStopAllNotifiers(void)
  * 'cupsd_compare_subscriptions()' - Compare two subscriptions.
  */
 
-static int                             /* O - Result of comparison */
+static int /* O - Result of comparison */
 cupsd_compare_subscriptions(
-    cupsd_subscription_t *first,       /* I - First subscription object */
-    cupsd_subscription_t *second,      /* I - Second subscription object */
-    void                *unused)       /* I - Unused user data pointer */
+    cupsd_subscription_t *first,  /* I - First subscription object */
+    cupsd_subscription_t *second, /* I - Second subscription object */
+    void *unused)                 /* I - Unused user data pointer */
 {
   (void)unused;
 
@@ -1213,18 +1213,18 @@ cupsd_compare_subscriptions(
  * flushing code will not work properly.
  */
 
-static void
-cupsd_delete_event(cupsd_event_t *event)/* I - Event to delete */
+static void cupsd_delete_event(cupsd_event_t *event, /* I - Event to delete */
+                               void *data)           /* Unused */
 {
- /*
-  * Free memory...
-  */
 /*
+   * Free memory...
+   */
 
+  (void)data;
   ippDelete(event->attrs);
   free(event);
 }
 
-
 #ifdef HAVE_DBUS
 /*
  * 'cupsd_send_dbus()' - Send a DBUS notification...
index cd252c450d1619bf5d63922e158c45f98530a469..49c469cc95f1488e955ff4aae062859d3c6ee3ef 100644 (file)
@@ -43,7 +43,7 @@ typedef struct _mime_filebuf_s                /**** File buffer for MIME typing ****/
  * Local functions...
  */
 
-static int     mime_compare_types(mime_type_t *t0, mime_type_t *t1);
+static int     mime_compare_types(mime_type_t *t0, mime_type_t *t1, void *data);
 static int     mime_check_rules(const char *filename, _mime_filebuf_t *fb,
                                 mime_magic_t *rules);
 static int     mime_patmatch(const char *s, const char *pat);
@@ -728,12 +728,14 @@ mimeType(mime_t     *mime,                /* I - MIME database */
  * 'mime_compare_types()' - Compare two MIME super/type names.
  */
 
-static int                             /* O - Result of comparison */
-mime_compare_types(mime_type_t *t0,    /* I - First type */
-                   mime_type_t *t1)    /* I - Second type */
+static int                          /* O - Result of comparison */
+mime_compare_types(mime_type_t *t0, /* I - First type */
+                   mime_type_t *t1, /* I - Second type */
+                   void *data)      /* Unused */
 {
   int  i;                              /* Result of comparison */
 
+  (void)data;
 
   if ((i = _cups_strcasecmp(t0->super, t1->super)) == 0)
     i = _cups_strcasecmp(t0->type, t1->type);
index 6fa8dfd244e1ba3b69c8e801080f1b9d3a5a945b..0a697fa8c70bd32642ca758314eceaeaadbb624d 100644 (file)
@@ -28,13 +28,6 @@ extern "C" {
 #  endif /* __cplusplus */
 
 
-/*
- * Types...
- */
-
-typedef int (*cupsd_compare_func_t)(const void *, const void *);
-
-
 /*
  * Prototypes...
  */
index 041a468ef7b3cf88620bd6109aee169b0666ca8e..7cc730567c743415c75afc866ee48cae90e74206 100644 (file)
@@ -274,7 +274,7 @@ typedef struct ippeve_client_s              /**** Client data ****/
 
 static http_status_t   authenticate_request(ippeve_client_t *client);
 static void            clean_jobs(ippeve_printer_t *printer);
-static int             compare_jobs(ippeve_job_t *a, ippeve_job_t *b);
+static int compare_jobs(ippeve_job_t *a, ippeve_job_t *b, void *data);
 static void            copy_attributes(ipp_t *to, ipp_t *from, cups_array_t *ra, ipp_tag_t group_tag, int quickcopy);
 static void            copy_job_attributes(ippeve_client_t *client, ippeve_job_t *job, cups_array_t *ra);
 static ippeve_client_t *create_client(ippeve_printer_t *printer, int sock);
@@ -880,10 +880,12 @@ clean_jobs(ippeve_printer_t *printer)     /* I - Printer */
  * 'compare_jobs()' - Compare two jobs.
  */
 
-static int                             /* O - Result of comparison */
-compare_jobs(ippeve_job_t *a,          /* I - First job */
-             ippeve_job_t *b)          /* I - Second job */
+static int                    /* O - Result of comparison */
+compare_jobs(ippeve_job_t *a, /* I - First job */
+             ippeve_job_t *b, /* I - Second job */
+             void *data)      /* Unused */
 {
+  (void)data;
   return (b->id - a->id);
 }
 
@@ -2486,7 +2488,7 @@ finish_document_data(
 
   respond_ipp(client, IPP_STATUS_OK, NULL);
 
-  ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+  ra = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
   cupsArrayAdd(ra, "job-id");
   cupsArrayAdd(ra, "job-state");
   cupsArrayAdd(ra, "job-state-message");
@@ -2506,7 +2508,7 @@ finish_document_data(
   job->state     = IPP_JSTATE_ABORTED;
   job->completed = time(NULL);
 
-  ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+  ra = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
   cupsArrayAdd(ra, "job-id");
   cupsArrayAdd(ra, "job-state");
   cupsArrayAdd(ra, "job-state-reasons");
@@ -2770,7 +2772,7 @@ finish_document_uri(
 
   respond_ipp(client, IPP_STATUS_OK, NULL);
 
-  ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+  ra = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
   cupsArrayAdd(ra, "job-id");
   cupsArrayAdd(ra, "job-state");
   cupsArrayAdd(ra, "job-state-reasons");
@@ -2789,7 +2791,7 @@ finish_document_uri(
   job->state     = IPP_JSTATE_ABORTED;
   job->completed = time(NULL);
 
-  ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+  ra = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
   cupsArrayAdd(ra, "job-id");
   cupsArrayAdd(ra, "job-state");
   cupsArrayAdd(ra, "job-state-reasons");
@@ -3381,7 +3383,7 @@ ipp_create_job(ippeve_client_t *client)   /* I - Client */
 
   respond_ipp(client, IPP_STATUS_OK, NULL);
 
-  ra = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+  ra = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
   cupsArrayAdd(ra, "job-id");
   cupsArrayAdd(ra, "job-state");
   cupsArrayAdd(ra, "job-state-message");
index 2e4272653df91bcedaebdd743a53c35931240b3a..58eb62145d9471962e4be89e30dd8d496c0462de 100644 (file)
@@ -163,7 +163,7 @@ static void         client_callback(AvahiClient *client,
                                        void *context);
 #endif /* HAVE_MDNSRESPONDER */
 
-static int             compare_services(ippfind_srv_t *a, ippfind_srv_t *b);
+static int             compare_services(ippfind_srv_t *a, ippfind_srv_t *b, void *data);
 static const char      *dnssd_error_string(int error);
 static int             eval_expr(ippfind_srv_t *service,
                                  ippfind_expr_t *expressions);
@@ -1629,10 +1629,12 @@ client_callback(
  * 'compare_services()' - Compare two devices.
  */
 
-static int                             /* O - Result of comparison */
-compare_services(ippfind_srv_t *a,     /* I - First device */
-                 ippfind_srv_t *b)     /* I - Second device */
+static int                         /* O - Result of comparison */
+compare_services(ippfind_srv_t *a, /* I - First device */
+                 ippfind_srv_t *b, /* I - Second device */
+                 void *data)       /* Unused */
 {
+  (void)data;
   return (strcmp(a->name, b->name));
 }
 
index 98f6657fab26e713042036b21391495370aac1ed..0ca9870a9fa7cf67fa5923338c32ef1d17a00738 100644 (file)
@@ -1578,7 +1578,7 @@ do_test(_ipp_file_t    *f,                /* I - IPP data file */
          add_stringf(data->errors, "detailed-status-message (text(MAX)) has bad length %d (RFC 8011 section 4.1.6.3).", (int)strlen(detailed_status_message));
       }
 
-      a = cupsArrayNew((cups_array_func_t)strcmp, NULL);
+      a = cupsArrayNew((cups_array_func_t)_cupsArrayStrcmp, NULL);
 
       for (attrptr = ippFirstAttribute(response), group = ippGetGroupTag(attrptr);
           attrptr;
@@ -2654,7 +2654,7 @@ init_data(ipptool_test_t *data)   /* I - Data */
   data->family       = AF_UNSPEC;
   data->def_transfer = IPPTOOL_TRANSFER_AUTO;
   data->def_version  = 11;
-  data->errors       = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+  data->errors       = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
   data->pass         = 1;
   data->prev_pass    = 1;
   data->request_id   = (CUPS_RAND() % 1000) * 137;
@@ -5704,7 +5704,7 @@ with_distinct_values(
   }
 
   // Collect values and determine they are all unique...
-  values = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+  values = cupsArrayNew3((cups_array_func_t)_cupsArrayStrcmp, NULL, NULL, 0, (cups_acopy_func_t)_cupsArrayStrdup, _cupsArrayFree);
 
   for (i = 0; i < count; i ++)
   {