/*
* PPD cache implementation for CUPS.
*
- * Copyright © 2010-2018 by Apple Inc.
+ * Copyright © 2010-2019 by Apple Inc.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more
* information.
ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, keyword);
else if (pc->sides_option && (choice = ppdFindMarkedChoice(ppd, pc->sides_option)) != NULL)
{
- if (!_cups_strcasecmp(choice->choice, pc->sides_1sided))
+ if (pc->sides_1sided && !_cups_strcasecmp(choice->choice, pc->sides_1sided))
ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, "one-sided");
- else if (!_cups_strcasecmp(choice->choice, pc->sides_2sided_long))
+ else if (pc->sides_2sided_long && !_cups_strcasecmp(choice->choice, pc->sides_2sided_long))
ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, "two-sided-long-edge");
- if (!_cups_strcasecmp(choice->choice, pc->sides_2sided_short))
+ else if (pc->sides_2sided_short && !_cups_strcasecmp(choice->choice, pc->sides_2sided_short))
ippAddString(request, IPP_TAG_JOB, IPP_TAG_KEYWORD, "sides", NULL, "two-sided-short-edge");
}
else if (!_cups_strcasecmp(line, "Filter"))
{
if (!pc->filters)
- pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0,
- (cups_acopy_func_t)_cupsStrAlloc,
- (cups_afree_func_t)_cupsStrFree);
+ pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
cupsArrayAdd(pc->filters, value);
}
else if (!_cups_strcasecmp(line, "PreFilter"))
{
if (!pc->prefilters)
- pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0,
- (cups_acopy_func_t)_cupsStrAlloc,
- (cups_afree_func_t)_cupsStrFree);
+ pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
cupsArrayAdd(pc->prefilters, value);
}
else if (!_cups_strcasecmp(line, "Product"))
{
- pc->product = _cupsStrAlloc(value);
+ pc->product = strdup(value);
}
else if (!_cups_strcasecmp(line, "SingleFile"))
{
}
map = pc->bins + pc->num_bins;
- map->pwg = _cupsStrAlloc(pwg_keyword);
- map->ppd = _cupsStrAlloc(ppd_keyword);
+ map->pwg = strdup(pwg_keyword);
+ map->ppd = strdup(ppd_keyword);
pc->num_bins ++;
}
goto create_error;
}
- size->map.pwg = _cupsStrAlloc(pwg_keyword);
- size->map.ppd = _cupsStrAlloc(ppd_keyword);
+ size->map.pwg = strdup(pwg_keyword);
+ size->map.ppd = strdup(ppd_keyword);
pc->num_sizes ++;
}
pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
pc->custom_max_width, pc->custom_max_length, NULL);
- pc->custom_max_keyword = _cupsStrAlloc(pwg_keyword);
+ pc->custom_max_keyword = strdup(pwg_keyword);
pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "min",
pc->custom_min_width, pc->custom_min_length, NULL);
- pc->custom_min_keyword = _cupsStrAlloc(pwg_keyword);
+ pc->custom_min_keyword = strdup(pwg_keyword);
}
else if (!_cups_strcasecmp(line, "SourceOption"))
{
- pc->source_option = _cupsStrAlloc(value);
+ pc->source_option = strdup(value);
}
else if (!_cups_strcasecmp(line, "NumSources"))
{
}
map = pc->sources + pc->num_sources;
- map->pwg = _cupsStrAlloc(pwg_keyword);
- map->ppd = _cupsStrAlloc(ppd_keyword);
+ map->pwg = strdup(pwg_keyword);
+ map->ppd = strdup(ppd_keyword);
pc->num_sources ++;
}
}
map = pc->types + pc->num_types;
- map->pwg = _cupsStrAlloc(pwg_keyword);
- map->ppd = _cupsStrAlloc(ppd_keyword);
+ map->pwg = strdup(pwg_keyword);
+ map->ppd = strdup(ppd_keyword);
pc->num_types ++;
}
pc->presets[print_color_mode] + print_quality);
}
else if (!_cups_strcasecmp(line, "SidesOption"))
- pc->sides_option = _cupsStrAlloc(value);
+ pc->sides_option = strdup(value);
else if (!_cups_strcasecmp(line, "Sides1Sided"))
- pc->sides_1sided = _cupsStrAlloc(value);
+ pc->sides_1sided = strdup(value);
else if (!_cups_strcasecmp(line, "Sides2SidedLong"))
- pc->sides_2sided_long = _cupsStrAlloc(value);
+ pc->sides_2sided_long = strdup(value);
else if (!_cups_strcasecmp(line, "Sides2SidedShort"))
- pc->sides_2sided_short = _cupsStrAlloc(value);
+ pc->sides_2sided_short = strdup(value);
else if (!_cups_strcasecmp(line, "Finishings"))
{
if (!pc->finishings)
else if (!_cups_strcasecmp(line, "FinishingTemplate"))
{
if (!pc->templates)
- pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)_cupsStrAlloc, (cups_afree_func_t)_cupsStrFree);
+ pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
cupsArrayAdd(pc->templates, value);
}
else if (!_cups_strcasecmp(line, "MaxCopies"))
pc->max_copies = atoi(value);
else if (!_cups_strcasecmp(line, "ChargeInfoURI"))
- pc->charge_info_uri = _cupsStrAlloc(value);
+ pc->charge_info_uri = strdup(value);
else if (!_cups_strcasecmp(line, "JobAccountId"))
pc->account_id = !_cups_strcasecmp(value, "true");
else if (!_cups_strcasecmp(line, "JobAccountingUserId"))
pc->accounting_user_id = !_cups_strcasecmp(value, "true");
else if (!_cups_strcasecmp(line, "JobPassword"))
- pc->password = _cupsStrAlloc(value);
+ pc->password = strdup(value);
else if (!_cups_strcasecmp(line, "Mandatory"))
{
if (pc->mandatory)
else if (!_cups_strcasecmp(line, "SupportFile"))
{
if (!pc->support_files)
- pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0,
- (cups_acopy_func_t)_cupsStrAlloc,
- (cups_afree_func_t)_cupsStrFree);
+ pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
cupsArrayAdd(pc->support_files, value);
}
*/
new_size = old_size;
- _cupsStrFree(old_size->map.ppd);
- _cupsStrFree(old_size->map.pwg);
+ free(old_size->map.ppd);
+ free(old_size->map.pwg);
}
}
* Save this size...
*/
- new_size->map.ppd = _cupsStrAlloc(ppd_size->name);
- new_size->map.pwg = _cupsStrAlloc(pwg_name);
+ new_size->map.ppd = strdup(ppd_size->name);
+ new_size->map.pwg = strdup(pwg_name);
new_size->width = new_width;
new_size->length = new_length;
new_size->left = new_left;
pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "max",
PWG_FROM_POINTS(ppd->custom_max[0]),
PWG_FROM_POINTS(ppd->custom_max[1]), NULL);
- pc->custom_max_keyword = _cupsStrAlloc(pwg_keyword);
+ pc->custom_max_keyword = strdup(pwg_keyword);
pc->custom_max_width = PWG_FROM_POINTS(ppd->custom_max[0]);
pc->custom_max_length = PWG_FROM_POINTS(ppd->custom_max[1]);
pwgFormatSizeName(pwg_keyword, sizeof(pwg_keyword), "custom", "min",
PWG_FROM_POINTS(ppd->custom_min[0]),
PWG_FROM_POINTS(ppd->custom_min[1]), NULL);
- pc->custom_min_keyword = _cupsStrAlloc(pwg_keyword);
+ pc->custom_min_keyword = strdup(pwg_keyword);
pc->custom_min_width = PWG_FROM_POINTS(ppd->custom_min[0]);
pc->custom_min_length = PWG_FROM_POINTS(ppd->custom_min[1]);
if (input_slot)
{
- pc->source_option = _cupsStrAlloc(input_slot->keyword);
+ pc->source_option = strdup(input_slot->keyword);
if ((pc->sources = calloc((size_t)input_slot->num_choices, sizeof(pwg_map_t))) == NULL)
{
"_");
}
- map->pwg = _cupsStrAlloc(pwg_name);
- map->ppd = _cupsStrAlloc(choice->choice);
+ map->pwg = strdup(pwg_name);
+ map->ppd = strdup(choice->choice);
/*
* Add localized text for PWG keyword to message catalog...
"_");
}
- map->pwg = _cupsStrAlloc(pwg_name);
- map->ppd = _cupsStrAlloc(choice->choice);
+ map->pwg = strdup(pwg_name);
+ map->ppd = strdup(choice->choice);
/*
* Add localized text for PWG keyword to message catalog...
{
pwg_unppdize_name(choice->choice, pwg_keyword, sizeof(pwg_keyword), "_");
- map->pwg = _cupsStrAlloc(pwg_keyword);
- map->ppd = _cupsStrAlloc(choice->choice);
+ map->pwg = strdup(pwg_keyword);
+ map->ppd = strdup(choice->choice);
/*
* Add localized text for PWG keyword to message catalog...
if (duplex)
{
- pc->sides_option = _cupsStrAlloc(duplex->keyword);
+ pc->sides_option = strdup(duplex->keyword);
for (i = duplex->num_choices, choice = duplex->choices;
i > 0;
{
if ((!_cups_strcasecmp(choice->choice, "None") ||
!_cups_strcasecmp(choice->choice, "False")) && !pc->sides_1sided)
- pc->sides_1sided = _cupsStrAlloc(choice->choice);
+ pc->sides_1sided = strdup(choice->choice);
else if ((!_cups_strcasecmp(choice->choice, "DuplexNoTumble") ||
!_cups_strcasecmp(choice->choice, "LongEdge") ||
!_cups_strcasecmp(choice->choice, "Top")) && !pc->sides_2sided_long)
- pc->sides_2sided_long = _cupsStrAlloc(choice->choice);
+ pc->sides_2sided_long = strdup(choice->choice);
else if ((!_cups_strcasecmp(choice->choice, "DuplexTumble") ||
!_cups_strcasecmp(choice->choice, "ShortEdge") ||
!_cups_strcasecmp(choice->choice, "Bottom")) &&
!pc->sides_2sided_short)
- pc->sides_2sided_short = _cupsStrAlloc(choice->choice);
+ pc->sides_2sided_short = strdup(choice->choice);
}
}
* Copy filters and pre-filters...
*/
- pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0,
- (cups_acopy_func_t)_cupsStrAlloc,
- (cups_afree_func_t)_cupsStrFree);
+ pc->filters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
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)_cupsStrAlloc,
- (cups_afree_func_t)_cupsStrFree);
+ pc->prefilters = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
do
{
*/
if (ppd->product)
- pc->product = _cupsStrAlloc(ppd->product);
+ pc->product = strdup(ppd->product);
/*
* Copy finishings mapping data...
if ((ppd_option = ppdFindOption(ppd, "cupsFinishingTemplate")) != NULL)
{
- pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)_cupsStrAlloc, (cups_afree_func_t)_cupsStrFree);
+ pc->templates = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
for (choice = ppd_option->choices, i = ppd_option->num_choices; i > 0; choice ++, i --)
{
*/
if ((ppd_attr = ppdFindAttr(ppd, "cupsChargeInfoURI", NULL)) != NULL)
- pc->charge_info_uri = _cupsStrAlloc(ppd_attr->value);
+ pc->charge_info_uri = strdup(ppd_attr->value);
if ((ppd_attr = ppdFindAttr(ppd, "cupsJobAccountId", NULL)) != NULL)
pc->account_id = !_cups_strcasecmp(ppd_attr->value, "true");
pc->accounting_user_id = !_cups_strcasecmp(ppd_attr->value, "true");
if ((ppd_attr = ppdFindAttr(ppd, "cupsJobPassword", NULL)) != NULL)
- pc->password = _cupsStrAlloc(ppd_attr->value);
+ pc->password = strdup(ppd_attr->value);
if ((ppd_attr = ppdFindAttr(ppd, "cupsMandatory", NULL)) != NULL)
pc->mandatory = _cupsArrayNewStrings(ppd_attr->value, ' ');
* Support files...
*/
- pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0,
- (cups_acopy_func_t)_cupsStrAlloc,
- (cups_afree_func_t)_cupsStrFree);
+ pc->support_files = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
for (ppd_attr = ppdFindAttr(ppd, "cupsICCProfile", NULL);
ppd_attr;
{
for (i = pc->num_bins, map = pc->bins; i > 0; i --, map ++)
{
- _cupsStrFree(map->pwg);
- _cupsStrFree(map->ppd);
+ free(map->pwg);
+ free(map->ppd);
}
free(pc->bins);
{
for (i = pc->num_sizes, size = pc->sizes; i > 0; i --, size ++)
{
- _cupsStrFree(size->map.pwg);
- _cupsStrFree(size->map.ppd);
+ free(size->map.pwg);
+ free(size->map.ppd);
}
free(pc->sizes);
}
- if (pc->source_option)
- _cupsStrFree(pc->source_option);
+ free(pc->source_option);
if (pc->sources)
{
for (i = pc->num_sources, map = pc->sources; i > 0; i --, map ++)
{
- _cupsStrFree(map->pwg);
- _cupsStrFree(map->ppd);
+ free(map->pwg);
+ free(map->ppd);
}
free(pc->sources);
{
for (i = pc->num_types, map = pc->types; i > 0; i --, map ++)
{
- _cupsStrFree(map->pwg);
- _cupsStrFree(map->ppd);
+ free(map->pwg);
+ free(map->ppd);
}
free(pc->types);
}
- if (pc->custom_max_keyword)
- _cupsStrFree(pc->custom_max_keyword);
-
- if (pc->custom_min_keyword)
- _cupsStrFree(pc->custom_min_keyword);
+ free(pc->custom_max_keyword);
+ free(pc->custom_min_keyword);
- _cupsStrFree(pc->product);
+ free(pc->product);
cupsArrayDelete(pc->filters);
cupsArrayDelete(pc->prefilters);
cupsArrayDelete(pc->finishings);
- _cupsStrFree(pc->charge_info_uri);
- _cupsStrFree(pc->password);
+ free(pc->charge_info_uri);
+ free(pc->password);
cupsArrayDelete(pc->mandatory);
{
DEBUG_printf(("_ppdCacheGetFinishingValues: Adding %d (%s)", f->value, ippEnumString("finishings", f->value)));
- values[num_values ++] = f->value;
+ values[num_values ++] = (int)f->value;
if (num_values >= max_values)
break;
if (pc->charge_info_uri)
cupsFilePutConf(fp, "ChargeInfoURI", pc->charge_info_uri);
- cupsFilePrintf(fp, "AccountId %s\n", pc->account_id ? "true" : "false");
- cupsFilePrintf(fp, "AccountingUserId %s\n",
+ cupsFilePrintf(fp, "JobAccountId %s\n", pc->account_id ? "true" : "false");
+ cupsFilePrintf(fp, "JobAccountingUserId %s\n",
pc->accounting_user_id ? "true" : "false");
if (pc->password)
- cupsFilePutConf(fp, "Password", pc->password);
+ cupsFilePutConf(fp, "JobPassword", pc->password);
for (value = (char *)cupsArrayFirst(pc->mandatory);
value;
httpClose(http);
}
+ /*
+ * Accounting...
+ */
+
+ if (ippGetBoolean(ippFindAttribute(response, "job-account-id-supported", IPP_TAG_BOOLEAN), 0))
+ cupsFilePuts(fp, "*cupsJobAccountId: True\n");
+
+ if (ippGetBoolean(ippFindAttribute(response, "job-accounting-user-id-supported", IPP_TAG_BOOLEAN), 0))
+ cupsFilePuts(fp, "*cupsJobAccountingUserId: True\n");
+
/*
* Password/PIN printing...
*/
pattern[maxlen] = '\0';
- cupsFilePrintf(fp, "*cupsPassword: \"%s\"\n", pattern);
+ cupsFilePrintf(fp, "*cupsJobPassword: \"%s\"\n", pattern);
}
/*
else
cupsFilePuts(fp, "*cupsFilter2: \"application/vnd.cups-pdf application/pdf 10 -\"\n");
}
+ else
+ cupsFilePuts(fp, "*cupsManualCopies: true\n");
if (is_apple)
cupsFilePuts(fp, "*cupsFilter2: \"image/urf image/urf 100 -\"\n");
if (is_pwg)