* Include necessary headers...
*/
-#include "ppd.h"
+#include "cups.h"
#include "string.h"
#include "debug.h"
return (0);
- if (!strncasecmp(choice, "Custom.", 7) /* TODO || strchr(choice, '=') */ )
+ if (!strncasecmp(choice, "Custom.", 7))
{
/*
* Handle a custom option...
ppd_cparam_t *cparam; /* Custom parameter */
char units[33]; /* Custom points units */
-
- /*
- * TODO: Detect and support custom option values using the
- * collection format "{Name1=foo Name2=bar}". For now, just
- * support Custom.value for single-valued custom options.
- */
-
if ((coption = ppdFindCustomOption(ppd, option)) != NULL)
{
if ((cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params)) == NULL)
}
}
}
+ else if (choice[0] == '{')
+ {
+ /*
+ * Handle multi-value custom options...
+ */
+
+ ppd_coption_t *coption; /* Custom option */
+ ppd_cparam_t *cparam; /* Custom parameter */
+ char units[33]; /* Custom points units */
+ int num_vals; /* Number of values */
+ cups_option_t *vals, /* Values */
+ *val; /* Value */
+
+
+ if ((c = ppdFindChoice(o, "Custom")) == NULL)
+ return (0);
+
+ if ((coption = ppdFindCustomOption(ppd, option)) != NULL)
+ {
+ num_vals = cupsParseOptions(choice + 1, 0, &vals);
+
+ for (i = 0, val = vals; i < num_vals; i ++, val ++)
+ {
+ if ((cparam = ppdFindCustomParam(coption, val->name)) == NULL)
+ continue;
+
+ switch (cparam->type)
+ {
+ case PPD_CUSTOM_CURVE :
+ case PPD_CUSTOM_INVCURVE :
+ case PPD_CUSTOM_REAL :
+ cparam->current.custom_real = atof(val->value);
+ break;
+
+ case PPD_CUSTOM_POINTS :
+ if (sscanf(val->value, "%f%s", &(cparam->current.custom_points),
+ units) < 2)
+ strcpy(units, "pt");
+
+ if (!strcasecmp(units, "cm"))
+ cparam->current.custom_points *= 72.0 / 2.54;
+ else if (!strcasecmp(units, "mm"))
+ cparam->current.custom_points *= 72.0 / 25.4;
+ else if (!strcasecmp(units, "m"))
+ cparam->current.custom_points *= 72.0 / 0.0254;
+ else if (!strcasecmp(units, "in"))
+ cparam->current.custom_points *= 72.0;
+ else if (!strcasecmp(units, "ft"))
+ cparam->current.custom_points *= 12 * 72.0;
+ break;
+
+ case PPD_CUSTOM_INT :
+ cparam->current.custom_int = atoi(val->value);
+ break;
+
+ case PPD_CUSTOM_PASSCODE :
+ case PPD_CUSTOM_PASSWORD :
+ case PPD_CUSTOM_STRING :
+ if (cparam->current.custom_string)
+ free(cparam->current.custom_string);
+
+ cparam->current.custom_string = strdup(val->value);
+ break;
+ }
+ }
+
+ cupsFreeOptions(num_vals, vals);
+ }
+ }
else
{
for (i = o->num_choices, c = o->choices; i > 0; i --, c ++)
case PPD_CUSTOM_PASSWORD :
case PPD_CUSTOM_STRING :
ppd_free(cparam->current.custom_string);
- ppd_free(cparam->minimum.custom_string);
- ppd_free(cparam->maximum.custom_string);
break;
default :
ppd->fonts[ppd->num_fonts] = strdup(name);
ppd->num_fonts ++;
}
-#if 0
- else if (!strcmp(keyword, "ParamCustomPageSize"))
- {
- if (!strcmp(name, "Width"))
- sscanf(string, "%*s%*s%f%f", ppd->custom_min + 0,
- ppd->custom_max + 0);
- else if (!strcmp(name, "Height"))
- sscanf(string, "%*s%*s%f%f", ppd->custom_min + 1,
- ppd->custom_max + 1);
- }
-#endif /* 0 */
else if (!strncmp(keyword, "ParamCustom", 11))
{
ppd_coption_t *coption; /* Custom option */
else if (!strcmp(ctype, "passcode"))
{
cparam->type = PPD_CUSTOM_PASSCODE;
- cparam->minimum.custom_passcode = strdup(cminimum);
- cparam->maximum.custom_passcode = strdup(cmaximum);
+ cparam->minimum.custom_passcode = atoi(cminimum);
+ cparam->maximum.custom_passcode = atoi(cmaximum);
}
else if (!strcmp(ctype, "password"))
{
cparam->type = PPD_CUSTOM_PASSWORD;
- cparam->minimum.custom_password = strdup(cminimum);
- cparam->maximum.custom_password = strdup(cmaximum);
+ cparam->minimum.custom_password = atoi(cminimum);
+ cparam->maximum.custom_password = atoi(cmaximum);
}
else if (!strcmp(ctype, "points"))
{
else if (!strcmp(ctype, "string"))
{
cparam->type = PPD_CUSTOM_STRING;
- cparam->minimum.custom_string = strdup(cminimum);
- cparam->maximum.custom_string = strdup(cmaximum);
+ cparam->minimum.custom_string = atoi(cminimum);
+ cparam->maximum.custom_string = atoi(cmaximum);
}
else
{
PPD_CUSTOM_STRING /* String of characters */
} ppd_cptype_t;
+typedef union ppd_cplimit_u /**** Custom Parameter Limit @since CUPS 1.2@ ****/
+{
+ float custom_curve; /* Gamma value */
+ int custom_int; /* Integer value */
+ float custom_invcurve; /* Gamma value */
+ int custom_passcode; /* Passcode length */
+ int custom_password; /* Password length */
+ float custom_points; /* Measurement value */
+ float custom_real; /* Real value */
+ int custom_string; /* String length */
+} ppd_cplimit_t;
+
typedef union ppd_cpvalue_u /**** Custom Parameter Value @since CUPS 1.2@ ****/
{
float custom_curve; /* Gamma value */
char text[PPD_MAX_TEXT]; /* Human-readable text */
int order; /* Order (0 to N) */
ppd_cptype_t type; /* Parameter type */
- ppd_cpvalue_t minimum, /* Minimum value */
- maximum, /* Maximum value */
- current; /* Current value */
+ ppd_cplimit_t minimum, /* Minimum value */
+ maximum; /* Maximum value */
+ ppd_cpvalue_t current; /* Current value */
} ppd_cparam_t;
typedef struct ppd_coption_s /**** Custom Option @since CUPS 1.2@ ****/
#
# Documentation makefile for the Common UNIX Printing System (CUPS).
#
-# Copyright 1993-2006 by Easy Software Products.
+# Copyright 1997-2006 by Easy Software Products.
#
# These coded instructions, statements, and computer programs are the
# property of Easy Software Products and are protected by Federal
help/man-backend.html \
help/man-cancel.html \
help/man-classes.conf.html \
+ help/man-client.conf.html \
help/man-cupsaddsmb.html \
help/man-cups-config.html \
help/man-cupsd.html \
option value is "2.0" then CUPS will output the string
"2.0 <</cupsReal1 2 1 roll>>setpagedevice".</p>
-<blockquote><b>Note:</b> Currently only CustomPageSize supports
-more than 1 parameter. This restriction is due to value encoding
-issues, since the "Custom.value" format does not allow for
-specification of named parameters. We anticipate supporting the
-collection value format "{Name1=foo Name2=bar}" for the final
-CUPS 1.2 release. In addition, the collection value format will
-allow string values to contain spaces.</blockquote>
-
<p>The "type" is one of the following keywords:</p>
<ul>