/*
- * "$Id: ppd-cache.c 11833 2014-04-24 15:04:15Z msweet $"
+ * "$Id: ppd-cache.c 11832 2014-04-24 15:04:00Z msweet $"
*
- * PPD cache implementation for CUPS.
+ * PPD cache implementation for CUPS.
*
- * Copyright 2010-2013 by Apple Inc.
+ * Copyright 2010-2014 by Apple Inc.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * _ppdCacheCreateWithFile() - Create PPD cache and mapping data from a
- * written file.
- * _ppdCacheCreateWithPPD() - Create PWG mapping data from a PPD file.
- * _ppdCacheDestroy() - Free all memory used for PWG mapping data.
- * _ppdCacheGetBin() - Get the PWG output-bin keyword associated with
- * a PPD OutputBin.
- * _ppdCacheGetInputSlot() - Get the PPD InputSlot associated with the job
- * attributes or a keyword string.
- * _ppdCacheGetMediaType() - Get the PPD MediaType associated with the job
- * attributes or a keyword string.
- * _ppdCacheGetOutputBin() - Get the PPD OutputBin associated with the
- * keyword string.
- * _ppdCacheGetPageSize() - Get the PPD PageSize associated with the job
- * attributes or a keyword string.
- * _ppdCacheGetSize() - Get the PWG size associated with a PPD
- * PageSize.
- * _ppdCacheGetSource() - Get the PWG media-source associated with a PPD
- * InputSlot.
- * _ppdCacheGetType() - Get the PWG media-type associated with a PPD
- * MediaType.
- * _ppdCacheWriteFile() - Write PWG mapping data to a file.
- * _pwgInputSlotForSource() - Get the InputSlot name for the given PWG
- * media-source.
- * _pwgMediaTypeForType() - Get the MediaType name for the given PWG
- * media-type.
- * _pwgPageSizeForMedia() - Get the PageSize name for the given media.
- * pwg_ppdize_name() - Convert an IPP keyword to a PPD keyword.
- * pwg_unppdize_name() - Convert a PPD keyword to a lowercase IPP
- * keyword.
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
goto create_error;
}
- if ((pc->bins = calloc(num_bins, sizeof(pwg_map_t))) == NULL)
+ if ((pc->bins = calloc((size_t)num_bins, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d bins.",
num_sizes));
if (num_sizes > 0)
{
- if ((pc->sizes = calloc(num_sizes, sizeof(pwg_size_t))) == NULL)
+ if ((pc->sizes = calloc((size_t)num_sizes, sizeof(pwg_size_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d sizes.",
num_sizes));
goto create_error;
}
- if ((pc->sources = calloc(num_sources, sizeof(pwg_map_t))) == NULL)
+ if ((pc->sources = calloc((size_t)num_sources, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d sources.",
num_sources));
goto create_error;
}
- if ((pc->types = calloc(num_types, sizeof(pwg_map_t))) == NULL)
+ if ((pc->types = calloc((size_t)num_types, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithFile: Unable to allocate %d types.",
num_types));
if ((finishings = calloc(1, sizeof(_pwg_finishings_t))) == NULL)
goto create_error;
- finishings->value = strtol(value, &valueptr, 10);
+ finishings->value = (ipp_finishings_t)strtol(value, &valueptr, 10);
finishings->num_options = cupsParseOptions(valueptr, 0,
&(finishings->options));
if (ppd->num_sizes > 0)
{
- if ((pc->sizes = calloc(ppd->num_sizes, sizeof(pwg_size_t))) == NULL)
+ if ((pc->sizes = calloc((size_t)ppd->num_sizes, sizeof(pwg_size_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_size_t's.", ppd->num_sizes));
* dimensions that are <= 0...
*/
- if ((pwg_media = pwgMediaForSize(PWG_FROM_POINTS(ppd_size->width),
- PWG_FROM_POINTS(ppd_size->length))) == NULL)
+ if ((pwg_media = _pwgMediaNearSize(PWG_FROM_POINTS(ppd_size->width),
+ PWG_FROM_POINTS(ppd_size->length),
+ 0)) == NULL)
continue;
new_width = pwg_media->width;
{
pc->source_option = _cupsStrAlloc(input_slot->keyword);
- if ((pc->sources = calloc(input_slot->num_choices,
- sizeof(pwg_map_t))) == NULL)
+ if ((pc->sources = calloc((size_t)input_slot->num_choices, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_map_t's for InputSlot.", input_slot->num_choices));
if ((media_type = ppdFindOption(ppd, "MediaType")) != NULL)
{
- if ((pc->types = calloc(media_type->num_choices,
- sizeof(pwg_map_t))) == NULL)
+ if ((pc->types = calloc((size_t)media_type->num_choices, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_map_t's for MediaType.", media_type->num_choices));
if ((output_bin = ppdFindOption(ppd, "OutputBin")) != NULL)
{
- if ((pc->bins = calloc(output_bin->num_choices,
- sizeof(pwg_map_t))) == NULL)
+ if ((pc->bins = calloc((size_t)output_bin->num_choices, sizeof(pwg_map_t))) == NULL)
{
DEBUG_printf(("_ppdCacheCreateWithPPD: Unable to allocate %d "
"pwg_map_t's for OutputBin.", output_bin->num_choices));
num_options = pc->num_presets[_PWG_PRINT_COLOR_MODE_COLOR]
[pwg_print_quality];
- options = calloc(sizeof(cups_option_t), num_options);
+ options = calloc(sizeof(cups_option_t), (size_t)num_options);
if (options)
{
if ((finishings = calloc(1, sizeof(_pwg_finishings_t))) == NULL)
goto create_error;
- finishings->value = atoi(ppd_attr->spec);
+ finishings->value = (ipp_finishings_t)atoi(ppd_attr->spec);
finishings->num_options = _ppdParseOptions(ppd_attr->value, 0,
&(finishings->options),
_PPD_PARSE_OPTIONS);
for (i = 0; i < num_values; i ++)
{
- key.value = ippGetInteger(attr, i);
+ key.value = (ipp_finishings_t)ippGetInteger(attr, i);
if ((f = cupsArrayFind(pc->finishings, &key)) != NULL)
{
* Range check input...
*/
+ DEBUG_printf(("_ppdCacheGetFinishingValues(pc=%p, num_options=%d, options=%p, max_values=%d, values=%p)", pc, num_options, options, max_values, values));
+
if (!pc || !pc->finishings || num_options < 1 || max_values < 1 || !values)
+ {
+ DEBUG_puts("_ppdCacheGetFinishingValues: Bad arguments, returning 0.");
return (0);
+ }
/*
* Go through the finishings options and see what is set...
f;
f = (_pwg_finishings_t *)cupsArrayNext(pc->finishings))
{
+ DEBUG_printf(("_ppdCacheGetFinishingValues: Checking %d (%s)", f->value, ippEnumString("finishings", f->value)));
+
for (i = f->num_options, option = f->options; i > 0; i --, option ++)
+ {
+ DEBUG_printf(("_ppdCacheGetFinishingValues: %s=%s?", option->name, option->value));
+
if ((val = cupsGetOption(option->name, num_options, options)) == NULL ||
_cups_strcasecmp(option->value, val))
+ {
+ DEBUG_puts("_ppdCacheGetFinishingValues: NO");
break;
+ }
+ }
if (i == 0)
{
+ DEBUG_printf(("_ppdCacheGetFinishingValues: Adding %d.", f->value));
+
values[num_values ++] = f->value;
if (num_values >= max_values)
}
}
+ DEBUG_printf(("_ppdCacheGetFinishingValues: Returning %d.", num_values));
+
return (num_values);
}
* Copy the size name from class_sizename_dimensions...
*/
- memcpy(name, sizeptr + 1, dimptr - sizeptr - 1);
+ memcpy(name, sizeptr + 1, (size_t)(dimptr - sizeptr - 1));
name[dimptr - sizeptr - 1] = '\0';
}
*end; /* End of name buffer */
- *name = toupper(*ipp++);
+ *name = (char)toupper(*ipp++);
for (ptr = name + 1, end = name + namesize - 1; *ipp && ptr < end;)
{
if (*ipp == '-' && _cups_isalpha(ipp[1]))
{
ipp ++;
- *ptr++ = toupper(*ipp++ & 255);
+ *ptr++ = (char)toupper(*ipp++ & 255);
}
else
*ptr++ = *ipp++;
for (ptr = name, end = name + namesize - 1; *ppd && ptr < end; ppd ++)
{
if (_cups_isalnum(*ppd) || *ppd == '-')
- *ptr++ = tolower(*ppd & 255);
+ *ptr++ = (char)tolower(*ppd & 255);
else if (strchr(dashchars, *ppd))
*ptr++ = '-';
else
/*
- * End of "$Id: ppd-cache.c 11833 2014-04-24 15:04:15Z msweet $".
+ * End of "$Id: ppd-cache.c 11832 2014-04-24 15:04:00Z msweet $".
*/