2 * "$Id: mark.c 9895 2011-08-12 00:16:55Z mike $"
4 * Option marking routines for CUPS.
6 * Copyright 2007-2011 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * PostScript is a trademark of Adobe Systems, Inc.
17 * This file is subject to the Apple OS-Developed Software exception.
21 * cupsMarkOptions() - Mark command-line options in a PPD file.
22 * ppdFindChoice() - Return a pointer to an option choice.
23 * ppdFindMarkedChoice() - Return the marked choice for the specified option.
24 * ppdFindOption() - Return a pointer to the specified option.
25 * ppdIsMarked() - Check to see if an option is marked.
26 * ppdMarkDefaults() - Mark all default options in the PPD file.
27 * ppdMarkOption() - Mark an option in a PPD file and return the number
29 * ppdFirstOption() - Return the first option in the PPD file.
30 * ppdNextOption() - Return the next option in the PPD file.
31 * _ppdParseOptions() - Parse options from a PPD file.
32 * ppd_debug_marked() - Output the marked array to stdout...
33 * ppd_defaults() - Set the defaults for this group and all sub-groups.
34 * ppd_mark_choices() - Mark one or more option choices from a string.
35 * ppd_mark_option() - Quickly mark an option without checking for
40 * Include necessary headers...
43 #include "cups-private.h"
51 static void ppd_debug_marked(ppd_file_t *ppd, const char *title);
53 # define ppd_debug_marked(ppd,title)
55 static void ppd_defaults(ppd_file_t *ppd, ppd_group_t *g);
56 static void ppd_mark_choices(ppd_file_t *ppd, const char *s);
57 static void ppd_mark_option(ppd_file_t *ppd, const char *option,
62 * 'cupsMarkOptions()' - Mark command-line options in a PPD file.
64 * This function maps the IPP "finishings", "media", "mirror",
65 * "multiple-document-handling", "output-bin", "print-color-mode",
66 * "print-quality", "printer-resolution", and "sides" attributes to their
67 * corresponding PPD options and choices.
70 int /* O - 1 if conflicts exist, 0 otherwise */
72 ppd_file_t *ppd, /* I - PPD file */
73 int num_options, /* I - Number of options */
74 cups_option_t *options) /* I - Options */
76 int i, j; /* Looping vars */
77 char *ptr, /* Pointer into string */
78 s[255]; /* Temporary string */
79 const char *val, /* Pointer into value */
80 *media, /* media option */
81 *output_bin, /* output-bin option */
82 *page_size, /* PageSize option */
83 *ppd_keyword, /* PPD keyword */
84 *print_color_mode, /* print-color-mode option */
85 *print_quality, /* print-quality option */
86 *sides; /* sides option */
87 cups_option_t *optptr; /* Current option */
88 ppd_attr_t *attr; /* PPD attribute */
89 _ppd_cache_t *cache; /* PPD cache and mapping data */
96 if (!ppd || num_options <= 0 || !options)
99 ppd_debug_marked(ppd, "Before...");
102 * Do special handling for finishings, media, output-bin, output-mode,
103 * print-color-mode, print-quality, and PageSize...
106 media = cupsGetOption("media", num_options, options);
107 output_bin = cupsGetOption("output-bin", num_options, options);
108 page_size = cupsGetOption("PageSize", num_options, options);
109 print_quality = cupsGetOption("print-quality", num_options, options);
110 sides = cupsGetOption("sides", num_options, options);
112 if ((print_color_mode = cupsGetOption("print-color-mode", num_options,
114 print_color_mode = cupsGetOption("output-mode", num_options, options);
116 if ((media || output_bin || print_color_mode || print_quality || sides) &&
120 * Load PPD cache and mapping data as needed...
123 ppd->cache = _ppdCacheCreateWithPPD(ppd);
131 * Loop through the option string, separating it at commas and marking each
132 * individual option as long as the corresponding PPD option (PageSize,
133 * InputSlot, etc.) is not also set.
135 * For PageSize, we also check for an empty option value since some versions
136 * of MacOS X use it to specify auto-selection of the media based solely on
140 for (val = media; *val;)
143 * Extract the sub-option from the string...
146 for (ptr = s; *val && *val != ',' && (ptr - s) < (sizeof(s) - 1);)
157 if (!page_size || !page_size[0])
159 if (!_cups_strncasecmp(s, "Custom.", 7) || ppdPageSize(ppd, s))
160 ppd_mark_option(ppd, "PageSize", s);
161 else if ((ppd_keyword = _ppdCacheGetPageSize(cache, NULL, s, NULL)) != NULL)
162 ppd_mark_option(ppd, "PageSize", ppd_keyword);
165 if (cache && cache->source_option &&
166 !cupsGetOption(cache->source_option, num_options, options) &&
167 (ppd_keyword = _ppdCacheGetInputSlot(cache, NULL, s)) != NULL)
168 ppd_mark_option(ppd, cache->source_option, ppd_keyword);
170 if (!cupsGetOption("MediaType", num_options, options) &&
171 (ppd_keyword = _ppdCacheGetMediaType(cache, NULL, s)) != NULL)
172 ppd_mark_option(ppd, "MediaType", ppd_keyword);
178 if (!cupsGetOption("com.apple.print.DocumentTicket.PMSpoolFormat",
179 num_options, options) &&
180 !cupsGetOption("APPrinterPreset", num_options, options) &&
181 (print_color_mode || print_quality))
184 * Map output-mode and print-quality to a preset...
187 _pwg_print_color_mode_t pwg_pcm;/* print-color-mode index */
188 _pwg_print_quality_t pwg_pq; /* print-quality index */
189 cups_option_t *preset;/* Current preset option */
191 if (print_color_mode && !strcmp(print_color_mode, "monochrome"))
192 pwg_pcm = _PWG_PRINT_COLOR_MODE_MONOCHROME;
194 pwg_pcm = _PWG_PRINT_COLOR_MODE_COLOR;
198 pwg_pq = atoi(print_quality) - IPP_QUALITY_DRAFT;
199 if (pwg_pq < _PWG_PRINT_QUALITY_DRAFT)
200 pwg_pq = _PWG_PRINT_QUALITY_DRAFT;
201 else if (pwg_pq > _PWG_PRINT_QUALITY_HIGH)
202 pwg_pq = _PWG_PRINT_QUALITY_HIGH;
205 pwg_pq = _PWG_PRINT_QUALITY_NORMAL;
207 if (cache->num_presets[pwg_pcm][pwg_pq] == 0)
210 * Try to find a preset that works so that we maximize the chances of us
211 * getting a good print using IPP attributes.
214 if (cache->num_presets[pwg_pcm][_PWG_PRINT_QUALITY_NORMAL] > 0)
215 pwg_pq = _PWG_PRINT_QUALITY_NORMAL;
216 else if (cache->num_presets[_PWG_PRINT_COLOR_MODE_COLOR][pwg_pq] > 0)
217 pwg_pcm = _PWG_PRINT_COLOR_MODE_COLOR;
220 pwg_pq = _PWG_PRINT_QUALITY_NORMAL;
221 pwg_pcm = _PWG_PRINT_COLOR_MODE_COLOR;
225 if (cache->num_presets[pwg_pcm][pwg_pq] > 0)
228 * Copy the preset options as long as the corresponding names are not
229 * already defined in the IPP request...
232 for (i = cache->num_presets[pwg_pcm][pwg_pq],
233 preset = cache->presets[pwg_pcm][pwg_pq];
237 if (!cupsGetOption(preset->name, num_options, options))
238 ppd_mark_option(ppd, preset->name, preset->value);
243 if (output_bin && !cupsGetOption("OutputBin", num_options, options) &&
244 (ppd_keyword = _ppdCacheGetOutputBin(cache, output_bin)) != NULL)
247 * Map output-bin to OutputBin...
250 ppd_mark_option(ppd, "OutputBin", ppd_keyword);
253 if (sides && cache->sides_option &&
254 !cupsGetOption(cache->sides_option, num_options, options))
257 * Map sides to duplex option...
260 if (!strcmp(sides, "one-sided") && cache->sides_1sided)
261 ppd_mark_option(ppd, cache->sides_option, cache->sides_1sided);
262 else if (!strcmp(sides, "two-sided-long-edge") &&
263 cache->sides_2sided_long)
264 ppd_mark_option(ppd, cache->sides_option, cache->sides_2sided_long);
265 else if (!strcmp(sides, "two-sided-short-edge") &&
266 cache->sides_2sided_short)
267 ppd_mark_option(ppd, cache->sides_option, cache->sides_2sided_short);
272 * Mark other options...
275 for (i = num_options, optptr = options; i > 0; i --, optptr ++)
276 if (!_cups_strcasecmp(optptr->name, "media") ||
277 !_cups_strcasecmp(optptr->name, "output-bin") ||
278 !_cups_strcasecmp(optptr->name, "output-mode") ||
279 !_cups_strcasecmp(optptr->name, "print-quality") ||
280 !_cups_strcasecmp(optptr->name, "sides"))
282 else if (!_cups_strcasecmp(optptr->name, "resolution") ||
283 !_cups_strcasecmp(optptr->name, "printer-resolution"))
285 ppd_mark_option(ppd, "Resolution", optptr->value);
286 ppd_mark_option(ppd, "SetResolution", optptr->value);
287 /* Calcomp, Linotype, QMS, Summagraphics, Tektronix, Varityper */
288 ppd_mark_option(ppd, "JCLResolution", optptr->value);
290 ppd_mark_option(ppd, "CNRes_PGP", optptr->value);
293 else if (!_cups_strcasecmp(optptr->name, "multiple-document-handling"))
295 if (!cupsGetOption("Collate", num_options, options) &&
296 ppdFindOption(ppd, "Collate"))
298 if (_cups_strcasecmp(optptr->value, "separate-documents-uncollated-copies"))
299 ppd_mark_option(ppd, "Collate", "True");
301 ppd_mark_option(ppd, "Collate", "False");
304 else if (!_cups_strcasecmp(optptr->name, "finishings"))
307 * Lookup cupsIPPFinishings attributes for each value...
310 for (ptr = optptr->value; *ptr;)
313 * Get the next finishings number...
316 if (!isdigit(*ptr & 255))
319 if ((j = strtol(ptr, &ptr, 10)) < 3)
323 * Skip separator as needed...
330 * Look it up in the PPD file...
335 if ((attr = ppdFindAttr(ppd, "cupsIPPFinishings", s)) == NULL)
339 * Apply "*Option Choice" settings from the attribute value...
342 ppd_mark_choices(ppd, attr->value);
345 else if (!_cups_strcasecmp(optptr->name, "APPrinterPreset"))
348 * Lookup APPrinterPreset value...
351 if ((attr = ppdFindAttr(ppd, "APPrinterPreset", optptr->value)) != NULL)
354 * Apply "*Option Choice" settings from the attribute value...
357 ppd_mark_choices(ppd, attr->value);
360 else if (!_cups_strcasecmp(optptr->name, "mirror"))
361 ppd_mark_option(ppd, "MirrorPrint", optptr->value);
363 ppd_mark_option(ppd, optptr->name, optptr->value);
365 ppd_debug_marked(ppd, "After...");
367 return (ppdConflicts(ppd) > 0);
372 * 'ppdFindChoice()' - Return a pointer to an option choice.
375 ppd_choice_t * /* O - Choice pointer or @code NULL@ */
376 ppdFindChoice(ppd_option_t *o, /* I - Pointer to option */
377 const char *choice) /* I - Name of choice */
379 int i; /* Looping var */
380 ppd_choice_t *c; /* Current choice */
386 if (choice[0] == '{' || !_cups_strncasecmp(choice, "Custom.", 7))
389 for (i = o->num_choices, c = o->choices; i > 0; i --, c ++)
390 if (!_cups_strcasecmp(c->choice, choice))
398 * 'ppdFindMarkedChoice()' - Return the marked choice for the specified option.
401 ppd_choice_t * /* O - Pointer to choice or @code NULL@ */
402 ppdFindMarkedChoice(ppd_file_t *ppd, /* I - PPD file */
403 const char *option) /* I - Keyword/option name */
405 ppd_choice_t key, /* Search key for choice */
406 *marked; /* Marked choice */
409 DEBUG_printf(("2ppdFindMarkedChoice(ppd=%p, option=\"%s\")", ppd, option));
411 if ((key.option = ppdFindOption(ppd, option)) == NULL)
413 DEBUG_puts("3ppdFindMarkedChoice: Option not found, returning NULL");
417 marked = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key);
419 DEBUG_printf(("3ppdFindMarkedChoice: Returning %p(%s)...", marked,
420 marked ? marked->choice : "NULL"));
427 * 'ppdFindOption()' - Return a pointer to the specified option.
430 ppd_option_t * /* O - Pointer to option or @code NULL@ */
431 ppdFindOption(ppd_file_t *ppd, /* I - PPD file data */
432 const char *option) /* I - Option/Keyword name */
435 * Range check input...
444 * Search in the array...
447 ppd_option_t key; /* Option search key */
450 strlcpy(key.keyword, option, sizeof(key.keyword));
452 return ((ppd_option_t *)cupsArrayFind(ppd->options, &key));
457 * Search in each group...
460 int i, j; /* Looping vars */
461 ppd_group_t *group; /* Current group */
462 ppd_option_t *optptr; /* Current option */
465 for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++)
466 for (j = group->num_options, optptr = group->options;
469 if (!_cups_strcasecmp(optptr->keyword, option))
478 * 'ppdIsMarked()' - Check to see if an option is marked.
481 int /* O - Non-zero if option is marked */
482 ppdIsMarked(ppd_file_t *ppd, /* I - PPD file data */
483 const char *option, /* I - Option/Keyword name */
484 const char *choice) /* I - Choice name */
486 ppd_choice_t key, /* Search key */
487 *c; /* Choice pointer */
493 if ((key.option = ppdFindOption(ppd, option)) == NULL)
496 if ((c = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key)) == NULL)
499 return (!strcmp(c->choice, choice));
504 * 'ppdMarkDefaults()' - Mark all default options in the PPD file.
508 ppdMarkDefaults(ppd_file_t *ppd) /* I - PPD file record */
510 int i; /* Looping variables */
511 ppd_group_t *g; /* Current group */
512 ppd_choice_t *c; /* Current choice */
519 * Clean out the marked array...
522 for (c = (ppd_choice_t *)cupsArrayFirst(ppd->marked);
524 c = (ppd_choice_t *)cupsArrayNext(ppd->marked))
526 cupsArrayRemove(ppd->marked, c);
531 * Then repopulate it with the defaults...
534 for (i = ppd->num_groups, g = ppd->groups; i > 0; i --, g ++)
535 ppd_defaults(ppd, g);
540 * 'ppdMarkOption()' - Mark an option in a PPD file and return the number of
544 int /* O - Number of conflicts */
545 ppdMarkOption(ppd_file_t *ppd, /* I - PPD file record */
546 const char *option, /* I - Keyword */
547 const char *choice) /* I - Option name */
549 DEBUG_printf(("ppdMarkOption(ppd=%p, option=\"%s\", choice=\"%s\")",
550 ppd, option, choice));
553 * Range check input...
556 if (!ppd || !option || !choice)
563 ppd_mark_option(ppd, option, choice);
566 * Return the number of conflicts...
569 return (ppdConflicts(ppd));
574 * 'ppdFirstOption()' - Return the first option in the PPD file.
576 * Options are returned from all groups in ascending alphanumeric order.
578 * @since CUPS 1.2/Mac OS X 10.5@
581 ppd_option_t * /* O - First option or @code NULL@ */
582 ppdFirstOption(ppd_file_t *ppd) /* I - PPD file */
587 return ((ppd_option_t *)cupsArrayFirst(ppd->options));
592 * 'ppdNextOption()' - Return the next option in the PPD file.
594 * Options are returned from all groups in ascending alphanumeric order.
596 * @since CUPS 1.2/Mac OS X 10.5@
599 ppd_option_t * /* O - Next option or @code NULL@ */
600 ppdNextOption(ppd_file_t *ppd) /* I - PPD file */
605 return ((ppd_option_t *)cupsArrayNext(ppd->options));
610 * '_ppdParseOptions()' - Parse options from a PPD file.
612 * This function looks for strings of the form:
614 * *option choice ... *optionN choiceN
615 * property value ... propertyN valueN
617 * It stops when it finds a string that doesn't match this format.
620 int /* O - Number of options */
622 const char *s, /* I - String to parse */
623 int num_options, /* I - Number of options */
624 cups_option_t **options, /* IO - Options */
625 _ppd_parse_t which) /* I - What to parse */
627 char option[PPD_MAX_NAME * 2 + 1], /* Current option/property */
628 choice[PPD_MAX_NAME], /* Current choice/value */
629 *ptr; /* Pointer into option or choice */
633 return (num_options);
636 * Read all of the "*Option Choice" and "property value" pairs from the
637 * string, add them to an options array as we go...
643 * Skip leading whitespace...
646 while (_cups_isspace(*s))
650 * Get the option/property name...
654 while (*s && !_cups_isspace(*s) && ptr < (option + sizeof(option) - 1))
657 if (ptr == s || !_cups_isspace(*s))
666 while (_cups_isspace(*s))
673 while (*s && !_cups_isspace(*s) && ptr < (choice + sizeof(choice) - 1))
676 if (*s && !_cups_isspace(*s))
682 * Add it to the options array...
685 if (option[0] == '*' && which != _PPD_PARSE_PROPERTIES)
686 num_options = cupsAddOption(option + 1, choice, num_options, options);
687 else if (option[0] != '*' && which != _PPD_PARSE_OPTIONS)
688 num_options = cupsAddOption(option, choice, num_options, options);
691 return (num_options);
697 * 'ppd_debug_marked()' - Output the marked array to stdout...
701 ppd_debug_marked(ppd_file_t *ppd, /* I - PPD file data */
702 const char *title) /* I - Title for list */
704 ppd_choice_t *c; /* Current choice */
707 DEBUG_printf(("2cupsMarkOptions: %s", title));
709 for (c = (ppd_choice_t *)cupsArrayFirst(ppd->marked);
711 c = (ppd_choice_t *)cupsArrayNext(ppd->marked))
712 DEBUG_printf(("2cupsMarkOptions: %s=%s", c->option->keyword, c->choice));
718 * 'ppd_defaults()' - Set the defaults for this group and all sub-groups.
722 ppd_defaults(ppd_file_t *ppd, /* I - PPD file */
723 ppd_group_t *g) /* I - Group to default */
725 int i; /* Looping var */
726 ppd_option_t *o; /* Current option */
727 ppd_group_t *sg; /* Current sub-group */
730 for (i = g->num_options, o = g->options; i > 0; i --, o ++)
731 if (_cups_strcasecmp(o->keyword, "PageRegion") != 0)
732 ppdMarkOption(ppd, o->keyword, o->defchoice);
734 for (i = g->num_subgroups, sg = g->subgroups; i > 0; i --, sg ++)
735 ppd_defaults(ppd, sg);
740 * 'ppd_mark_choices()' - Mark one or more option choices from a string.
744 ppd_mark_choices(ppd_file_t *ppd, /* I - PPD file */
745 const char *s) /* I - "*Option Choice ..." string */
747 int i, /* Looping var */
748 num_options; /* Number of options */
749 cups_option_t *options, /* Options */
750 *option; /* Current option */
757 num_options = _ppdParseOptions(s, 0, &options, 0);
759 for (i = num_options, option = options; i > 0; i --, option ++)
760 ppd_mark_option(ppd, option->name, option->value);
762 cupsFreeOptions(num_options, options);
767 * 'ppd_mark_option()' - Quick mark an option without checking for conflicts.
771 ppd_mark_option(ppd_file_t *ppd, /* I - PPD file */
772 const char *option, /* I - Option name */
773 const char *choice) /* I - Choice name */
775 int i, j; /* Looping vars */
776 ppd_option_t *o; /* Option pointer */
777 ppd_choice_t *c, /* Choice pointer */
778 *oldc, /* Old choice pointer */
779 key; /* Search key for choice */
780 struct lconv *loc; /* Locale data */
783 DEBUG_printf(("7ppd_mark_option(ppd=%p, option=\"%s\", choice=\"%s\")",
784 ppd, option, choice));
787 * AP_D_InputSlot is the "default input slot" on MacOS X, and setting
788 * it clears the regular InputSlot choices...
791 if (!_cups_strcasecmp(option, "AP_D_InputSlot"))
793 cupsArraySave(ppd->options);
795 if ((o = ppdFindOption(ppd, "InputSlot")) != NULL)
798 if ((oldc = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key)) != NULL)
801 cupsArrayRemove(ppd->marked, oldc);
805 cupsArrayRestore(ppd->options);
809 * Check for custom options...
812 cupsArraySave(ppd->options);
814 o = ppdFindOption(ppd, option);
816 cupsArrayRestore(ppd->options);
823 if (!_cups_strncasecmp(choice, "Custom.", 7))
826 * Handle a custom option...
829 if ((c = ppdFindChoice(o, "Custom")) == NULL)
832 if (!_cups_strcasecmp(option, "PageSize"))
835 * Handle custom page sizes...
838 ppdPageSize(ppd, choice);
843 * Handle other custom options...
846 ppd_coption_t *coption; /* Custom option */
847 ppd_cparam_t *cparam; /* Custom parameter */
848 char *units; /* Custom points units */
851 if ((coption = ppdFindCustomOption(ppd, option)) != NULL)
853 if ((cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params)) == NULL)
856 switch (cparam->type)
858 case PPD_CUSTOM_CURVE :
859 case PPD_CUSTOM_INVCURVE :
860 case PPD_CUSTOM_REAL :
861 cparam->current.custom_real = (float)_cupsStrScand(choice + 7,
865 case PPD_CUSTOM_POINTS :
866 cparam->current.custom_points = (float)_cupsStrScand(choice + 7,
872 if (!_cups_strcasecmp(units, "cm"))
873 cparam->current.custom_points *= 72.0f / 2.54f;
874 else if (!_cups_strcasecmp(units, "mm"))
875 cparam->current.custom_points *= 72.0f / 25.4f;
876 else if (!_cups_strcasecmp(units, "m"))
877 cparam->current.custom_points *= 72.0f / 0.0254f;
878 else if (!_cups_strcasecmp(units, "in"))
879 cparam->current.custom_points *= 72.0f;
880 else if (!_cups_strcasecmp(units, "ft"))
881 cparam->current.custom_points *= 12.0f * 72.0f;
885 case PPD_CUSTOM_INT :
886 cparam->current.custom_int = atoi(choice + 7);
889 case PPD_CUSTOM_PASSCODE :
890 case PPD_CUSTOM_PASSWORD :
891 case PPD_CUSTOM_STRING :
892 if (cparam->current.custom_string)
893 _cupsStrFree(cparam->current.custom_string);
895 cparam->current.custom_string = _cupsStrAlloc(choice + 7);
902 * Make sure that we keep the option marked below...
907 else if (choice[0] == '{')
910 * Handle multi-value custom options...
913 ppd_coption_t *coption; /* Custom option */
914 ppd_cparam_t *cparam; /* Custom parameter */
915 char *units; /* Custom points units */
916 int num_vals; /* Number of values */
917 cups_option_t *vals, /* Values */
921 if ((c = ppdFindChoice(o, "Custom")) == NULL)
924 if ((coption = ppdFindCustomOption(ppd, option)) != NULL)
926 num_vals = cupsParseOptions(choice, 0, &vals);
928 for (i = 0, val = vals; i < num_vals; i ++, val ++)
930 if ((cparam = ppdFindCustomParam(coption, val->name)) == NULL)
933 switch (cparam->type)
935 case PPD_CUSTOM_CURVE :
936 case PPD_CUSTOM_INVCURVE :
937 case PPD_CUSTOM_REAL :
938 cparam->current.custom_real = (float)_cupsStrScand(val->value,
942 case PPD_CUSTOM_POINTS :
943 cparam->current.custom_points = (float)_cupsStrScand(val->value,
949 if (!_cups_strcasecmp(units, "cm"))
950 cparam->current.custom_points *= 72.0f / 2.54f;
951 else if (!_cups_strcasecmp(units, "mm"))
952 cparam->current.custom_points *= 72.0f / 25.4f;
953 else if (!_cups_strcasecmp(units, "m"))
954 cparam->current.custom_points *= 72.0f / 0.0254f;
955 else if (!_cups_strcasecmp(units, "in"))
956 cparam->current.custom_points *= 72.0f;
957 else if (!_cups_strcasecmp(units, "ft"))
958 cparam->current.custom_points *= 12.0f * 72.0f;
962 case PPD_CUSTOM_INT :
963 cparam->current.custom_int = atoi(val->value);
966 case PPD_CUSTOM_PASSCODE :
967 case PPD_CUSTOM_PASSWORD :
968 case PPD_CUSTOM_STRING :
969 if (cparam->current.custom_string)
970 _cupsStrFree(cparam->current.custom_string);
972 cparam->current.custom_string = _cupsStrRetain(val->value);
977 cupsFreeOptions(num_vals, vals);
982 for (i = o->num_choices, c = o->choices; i > 0; i --, c ++)
983 if (!_cups_strcasecmp(c->choice, choice))
991 * Option found; mark it and then handle unmarking any other options.
994 if (o->ui != PPD_UI_PICKMANY)
997 * Unmark all other choices...
1000 if ((oldc = (ppd_choice_t *)cupsArrayFind(ppd->marked, c)) != NULL)
1003 cupsArrayRemove(ppd->marked, oldc);
1006 if (!_cups_strcasecmp(option, "PageSize") || !_cups_strcasecmp(option, "PageRegion"))
1009 * Mark current page size...
1012 for (j = 0; j < ppd->num_sizes; j ++)
1013 ppd->sizes[j].marked = !_cups_strcasecmp(ppd->sizes[j].name,
1017 * Unmark the current PageSize or PageRegion setting, as
1021 cupsArraySave(ppd->options);
1023 if (!_cups_strcasecmp(option, "PageSize"))
1025 if ((o = ppdFindOption(ppd, "PageRegion")) != NULL)
1028 if ((oldc = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key)) != NULL)
1031 cupsArrayRemove(ppd->marked, oldc);
1037 if ((o = ppdFindOption(ppd, "PageSize")) != NULL)
1040 if ((oldc = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key)) != NULL)
1043 cupsArrayRemove(ppd->marked, oldc);
1048 cupsArrayRestore(ppd->options);
1050 else if (!_cups_strcasecmp(option, "InputSlot"))
1053 * Unmark ManualFeed option...
1056 cupsArraySave(ppd->options);
1058 if ((o = ppdFindOption(ppd, "ManualFeed")) != NULL)
1061 if ((oldc = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key)) != NULL)
1064 cupsArrayRemove(ppd->marked, oldc);
1068 cupsArrayRestore(ppd->options);
1070 else if (!_cups_strcasecmp(option, "ManualFeed") &&
1071 !_cups_strcasecmp(choice, "True"))
1074 * Unmark InputSlot option...
1077 cupsArraySave(ppd->options);
1079 if ((o = ppdFindOption(ppd, "InputSlot")) != NULL)
1082 if ((oldc = (ppd_choice_t *)cupsArrayFind(ppd->marked, &key)) != NULL)
1085 cupsArrayRemove(ppd->marked, oldc);
1089 cupsArrayRestore(ppd->options);
1095 cupsArrayAdd(ppd->marked, c);
1100 * End of "$Id: mark.c 9895 2011-08-12 00:16:55Z mike $".