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.
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
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));
}
{
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 ++)
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,
* '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));
}
*/
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,
* '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;
* 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;
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);
/*
* '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 */
* '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);
* '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));
}
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);
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);
+}
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);
* '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));
}
* '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;
* '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);
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)
*/
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)
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;
mdb->top == 0)
break;
}
- }
+ }
}
/*
*/
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;
*/
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) &&
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 *
* '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));
}
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");
* 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 ++)
{
# 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);
* '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));
}
* '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);
_cupsRasterReadPixels
_cupsRasterWriteHeader
_cupsRasterWritePixels
+_cupsArrayStrcmp
+_cupsArrayStrdup
+_cupsArrayFree
_cupsSetDefaults
_cupsSetError
_cupsSetHTTPError
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,
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);
}
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);
}
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);
}
* 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 -");
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
{
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 --)
{
* 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;
return (NULL);
}
+
/*
* '_ppdCacheGetInputSlot()' - Get the PPD InputSlot associated with the job
* attributes or a keyword string.
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)
{
};
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
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 ++)
* '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);
}
* '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));
}
* '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));
*/
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);
}
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 &&
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;
* 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);
* '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);
}
* 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)
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)
#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);
/*
* '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));
}
* '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));
}
* '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));
}
* '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));
}
* '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++;
* 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);
* '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));
}
* '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));
}
* '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));
}
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...
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...
* 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.
}
+/*
+ * '_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.
*
_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 ++;
return (-1);
}
+
/*
* '_cups_strncasecmp()' - Do a case-insensitive comparison on up to N chars.
*/
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 ++;
* '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);
+}
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");
* 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,
* '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);
}
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] == '-')
// 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;
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
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))
{
"Unable to allocate memory for %d names: %s",
cupsArrayCount(loc->names), strerror(errno));
- cupsdFreeLocation(temp);
+ cupsdFreeLocation(temp, NULL);
return (NULL);
}
}
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);
}
}
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);
}
}
* '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);
* '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));
}
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);
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);
* '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));
}
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);
* '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;
* 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))
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,
* '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
* '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
* '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);
* '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 */
* 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,
p1->record.languages[0])) != 0)
return (diff);
else
- return (compare_names(p0, p1));
+ return (compare_names(p0, p1, NULL));
}
/* 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);
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);
* '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);
}
* 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);
* '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)
* '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);
* '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 */
* '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 */
* '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;
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));
}
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,
* '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));
}
*/
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);
/*
* '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));
}
* 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);
/*
* '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);
}
* '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));
}
* '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);
* '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));
}
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)
{
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"));
* '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));
}
* 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 */
* '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);
}
*/
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.
* '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));
}
* 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 --; \
* '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);
}
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);
* '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;
* 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...
* 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);
* '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);
# endif /* __cplusplus */
-/*
- * Types...
- */
-
-typedef int (*cupsd_compare_func_t)(const void *, const void *);
-
-
/*
* Prototypes...
*/
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);
* '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);
}
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");
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");
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");
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");
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");
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);
* '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));
}
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;
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;
}
// 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 ++)
{