/*
- * "$Id: ppd.c 7552 2008-05-12 17:42:15Z mike $"
+ * "$Id: ppd.c 7906 2008-09-03 20:19:43Z mike $"
*
* PPD file routines for the Common UNIX Printing System (CUPS).
*
* ppd_add_size() - Add a page size.
* ppd_compare_attrs() - Compare two attributes.
* ppd_compare_choices() - Compare two choices...
- * ppd_compare_consts() - Compare two constraints.
* ppd_compare_coptions() - Compare two custom options.
* ppd_compare_cparams() - Compare two custom parameters.
* ppd_compare_options() - Compare two options.
* Include necessary headers.
*/
+#include "ppd-private.h"
#include "globals.h"
#include "debug.h"
#include <stdlib.h>
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_consts(ppd_const_t *a, ppd_const_t *b);
static int ppd_compare_coptions(ppd_coption_t *a,
ppd_coption_t *b);
static int ppd_compare_cparams(ppd_cparam_t *a, ppd_cparam_t *b);
_cupsStrFree(ppd->lang_encoding);
_cupsStrFree(ppd->nickname);
- _cupsStrFree(ppd->patches);
+ if (ppd->patches)
+ free(ppd->patches);
_cupsStrFree(ppd->jcl_begin);
_cupsStrFree(ppd->jcl_end);
_cupsStrFree(ppd->jcl_ps);
cupsArrayDelete(ppd->coptions);
+ /*
+ * Free constraints...
+ */
+
+ if (ppd->cups_uiconstraints)
+ {
+ _ppd_cups_uiconsts_t *consts; /* Current constraints */
+
+
+ for (consts = (_ppd_cups_uiconsts_t *)cupsArrayFirst(ppd->cups_uiconstraints);
+ consts;
+ consts = (_ppd_cups_uiconsts_t *)cupsArrayNext(ppd->cups_uiconstraints))
+ {
+ free(consts->constraints);
+ free(consts);
+ }
+
+ cupsArrayDelete(ppd->cups_uiconstraints);
+ }
+
/*
* Free the whole record...
*/
/*
* 'ppdErrorString()' - Returns the text assocated with a status.
*
- * @since CUPS 1.1.19@
+ * @since CUPS 1.1.19/Mac OS X 10.3@
*/
const char * /* O - Status string */
else if (!strcasecmp(name, "ISOLatin5"))
return (CUPS_ISO8859_5);
else if (!strcasecmp(name, "JIS83-RKSJ"))
- return (CUPS_WINDOWS_932);
+ return (CUPS_JIS_X0213);
else if (!strcasecmp(name, "MacStandard"))
return (CUPS_MAC_ROMAN);
else if (!strcasecmp(name, "WindowsANSI"))
/*
* 'ppdLastError()' - Return the status from the last ppdOpen*().
*
- * @since CUPS 1.1.19@
+ * @since CUPS 1.1.19/Mac OS X 10.3@
*/
ppd_status_t /* O - Status code */
/*
* 'ppdOpen2()' - Read a PPD file into memory.
*
- * @since CUPS 1.2@
+ * @since CUPS 1.2/Mac OS X 10.5@
*/
ppd_file_t * /* O - PPD file record or @code NULL@ if the PPD file could not be opened. */
cg->ppd_status = PPD_MISSING_PPDADOBE4;
_cupsStrFree(string);
+ ppd_free(line.buffer);
return (NULL);
}
{
cg->ppd_status = PPD_ALLOC_ERROR;
+ _cupsStrFree(string);
+ ppd_free(line.buffer);
+
return (NULL);
}
"string=%d chars...", mask, keyword, name, text,
string ? (int)strlen(string) : 0));
- if (strncmp(keyword, "Default", 7) && !string)
+ if (strncmp(keyword, "Default", 7) && !string &&
+ cg->ppd_conform != PPD_CONFORM_RELAXED)
{
/*
* Need a string value!
* Add the "custom" option...
*/
- if ((choice = ppd_add_choice(custom_option, "Custom")) == NULL)
- {
- DEBUG_puts("Unable to add Custom choice!");
+ if ((choice = ppdFindChoice(custom_option, "Custom")) == NULL)
+ if ((choice = ppd_add_choice(custom_option, "Custom")) == NULL)
+ {
+ DEBUG_puts("Unable to add Custom choice!");
- cg->ppd_status = PPD_ALLOC_ERROR;
+ cg->ppd_status = PPD_ALLOC_ERROR;
- goto error;
- }
+ goto error;
+ }
strlcpy(choice->text, text[0] ? text : _("Custom"),
sizeof(choice->text));
choice->code = _cupsStrAlloc(string);
+
+ if (custom_option->section == PPD_ORDER_JCL)
+ ppd_decode(choice->code);
}
/*
if (custom_option)
{
- if ((choice = ppd_add_choice(custom_option, "Custom")) == NULL)
- {
- DEBUG_puts("Unable to add Custom choice!");
+ if ((choice = ppdFindChoice(custom_option, "Custom")) == NULL)
+ if ((choice = ppd_add_choice(custom_option, "Custom")) == NULL)
+ {
+ DEBUG_puts("Unable to add Custom choice!");
- cg->ppd_status = PPD_ALLOC_ERROR;
+ cg->ppd_status = PPD_ALLOC_ERROR;
- goto error;
- }
+ goto error;
+ }
strlcpy(choice->text, text[0] ? text : _("Custom"),
sizeof(choice->text));
else if (!strcmp(keyword, "JobPatchFile"))
{
if (ppd->patches == NULL)
- ppd->patches = _cupsStrAlloc(string);
+ ppd->patches = strdup(string);
else
{
temp = realloc(ppd->patches, strlen(ppd->patches) +
if ((custom_attr = ppdFindAttr(ppd, custom_name, "True")) != NULL)
{
- if ((choice = ppd_add_choice(option, "Custom")) == NULL)
- {
- DEBUG_puts("Unable to add Custom choice!");
+ if ((choice = ppdFindChoice(option, "Custom")) == NULL)
+ if ((choice = ppd_add_choice(option, "Custom")) == NULL)
+ {
+ DEBUG_puts("Unable to add Custom choice!");
- cg->ppd_status = PPD_ALLOC_ERROR;
+ cg->ppd_status = PPD_ALLOC_ERROR;
- goto error;
- }
+ goto error;
+ }
strlcpy(choice->text,
custom_attr->text[0] ? custom_attr->text : _("Custom"),
sizeof(choice->text));
- choice->code = _cupsStrAlloc(custom_attr->value);
+ choice->code = _cupsStrRetain(custom_attr->value);
}
}
else if (!strcmp(keyword, "JCLOpenUI"))
strlcpy(choice->text,
custom_attr->text[0] ? custom_attr->text : _("Custom"),
sizeof(choice->text));
- choice->code = _cupsStrAlloc(custom_attr->value);
+ choice->code = _cupsStrRetain(custom_attr->value);
}
}
else if (!strcmp(keyword, "CloseUI") || !strcmp(keyword, "JCLCloseUI"))
break;
}
- /*
- * For CustomPageSize and InputSlot/ManualFeed, create a duplicate
- * constraint for PageRegion...
- */
-
- if (!strcasecmp(constraint->option1, "CustomPageSize") &&
- (!strcasecmp(constraint->option2, "InputSlot") ||
- !strcasecmp(constraint->option2, "ManualFeed")))
- {
- ppd->num_consts ++;
-
- strcpy(constraint[1].option1, "PageRegion");
- strcpy(constraint[1].choice1, "Custom");
- strcpy(constraint[1].option2, constraint->option2);
- strcpy(constraint[1].choice2, constraint->choice2);
- }
- else if (!strcasecmp(constraint->option2, "CustomPageSize") &&
- (!strcasecmp(constraint->option1, "InputSlot") ||
- !strcasecmp(constraint->option1, "ManualFeed")))
- {
- ppd->num_consts ++;
-
- strcpy(constraint[1].option1, constraint->option1);
- strcpy(constraint[1].choice1, constraint->choice1);
- strcpy(constraint[1].option2, "PageRegion");
- strcpy(constraint[1].choice2, "Custom");
- }
-
- /*
- * Handle CustomFoo option constraints...
- */
-
- if (!strncasecmp(constraint->option1, "Custom", 6) &&
- !strcasecmp(constraint->choice1, "True"))
- {
- _cups_strcpy(constraint->option1, constraint->option1 + 6);
- strcpy(constraint->choice1, "Custom");
- }
-
- if (!strncasecmp(constraint->option2, "Custom", 6) &&
- !strcasecmp(constraint->choice2, "True"))
- {
- _cups_strcpy(constraint->option2, constraint->option2 + 6);
- strcpy(constraint->choice2, "Custom");
- }
-
/*
* Don't add this one as an attribute...
*/
_cupsStrFree(string);
}
- if (line.buffer)
- free(line.buffer);
+ ppd_free(line.buffer);
/*
* Reset language preferences...
}
}
- /*
- * Sort the constraints...
- */
-
- if (ppd->num_consts > 1)
- qsort(ppd->consts, ppd->num_consts, sizeof(ppd_const_t),
- (int (*)(const void *, const void *))ppd_compare_consts);
-
/*
* Create an array to track the marked choices...
*/
error:
- if (line.buffer)
- free(line.buffer);
-
_cupsStrFree(string);
+ ppd_free(line.buffer);
ppdClose(ppd);
/*
* 'ppdSetConformance()' - Set the conformance level for PPD files.
*
- * @since CUPS 1.1.20@
+ * @since CUPS 1.1.20/Mac OS X 10.4@
*/
void
ppd_compare_attrs(ppd_attr_t *a, /* I - First attribute */
ppd_attr_t *b) /* I - Second attribute */
{
- int ret; /* Result of comparison */
-
-
- if ((ret = strcasecmp(a->name, b->name)) != 0)
- return (ret);
- else
- return (strcasecmp(a->spec, b->spec));
+ return (strcasecmp(a->name, b->name));
}
}
-/*
- * 'ppd_compare_consts()' - Compare two constraints.
- */
-
-static int /* O - Result of comparison */
-ppd_compare_consts(ppd_const_t *a, /* I - First constraint */
- ppd_const_t *b) /* I - Second constraint */
-{
- int ret; /* Result of comparison */
-
-
- if ((ret = strcmp(a->option1, b->option1)) != 0)
- return (ret);
- else if ((ret = strcmp(a->choice1, b->choice1)) != 0)
- return (ret);
- else if ((ret = strcmp(a->option2, b->option2)) != 0)
- return (ret);
- else
- return (strcmp(a->choice2, b->choice2));
-}
-
-
/*
* 'ppd_compare_coptions()' - Compare two custom options.
*/
/*
- * End of "$Id: ppd.c 7552 2008-05-12 17:42:15Z mike $".
+ * End of "$Id: ppd.c 7906 2008-09-03 20:19:43Z mike $".
*/