4 * Option marking routines for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2009 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 * cupsGetConflicts() - Get a list of conflicting options in a marked
23 * cupsResolveConflicts() - Resolve conflicts in a marked PPD.
24 * ppdConflicts() - Check to see if there are any conflicts among
25 * the marked option choices.
26 * ppdInstallableConflict() - Test whether an option choice conflicts with an
28 * ppd_is_installable() - Determine whether an option is in the
29 * InstallableOptions group.
30 * ppd_load_constraints() - Load constraints from a PPD file.
31 * ppd_test_constraints() - See if any constraints are active.
35 * Include necessary headers...
38 #include "ppd-private.h"
49 _PPD_NORMAL_CONSTRAINTS
,
50 _PPD_INSTALLABLE_CONSTRAINTS
,
59 static int ppd_is_installable(ppd_group_t
*installable
,
61 static void ppd_load_constraints(ppd_file_t
*ppd
);
62 static cups_array_t
*ppd_test_constraints(ppd_file_t
*ppd
,
66 cups_option_t
*options
,
71 * 'cupsGetConflicts()' - Get a list of conflicting options in a marked PPD.
73 * This function gets a list of options that would conflict if "option" and
74 * "choice" were marked in the PPD. You would typically call this function
75 * after marking the currently selected options in the PPD in order to
76 * determine whether a new option selection would cause a conflict.
78 * The number of conflicting options are returned with "options" pointing to
79 * the conflicting options. The returned option array must be freed using
80 * @link cupsFreeOptions@.
85 int /* O - Number of conflicting options */
87 ppd_file_t
*ppd
, /* I - PPD file */
88 const char *option
, /* I - Option to test */
89 const char *choice
, /* I - Choice to test */
90 cups_option_t
**options
) /* O - Conflicting options */
92 int i
, /* Looping var */
93 num_options
; /* Number of conflicting options */
94 cups_array_t
*active
; /* Active conflicts */
95 _ppd_cups_uiconsts_t
*c
; /* Current constraints */
96 _ppd_cups_uiconst_t
*cptr
; /* Current constraint */
100 * Range check input...
106 if (!ppd
|| !option
|| !choice
|| !options
)
110 * Test for conflicts...
113 active
= ppd_test_constraints(ppd
, option
, choice
, 0, NULL
,
114 _PPD_ALL_CONSTRAINTS
);
117 * Loop through all of the UI constraints and add any options that conflict...
120 for (num_options
= 0, c
= (_ppd_cups_uiconsts_t
*)cupsArrayFirst(active
);
122 c
= (_ppd_cups_uiconsts_t
*)cupsArrayNext(active
))
124 for (i
= c
->num_constraints
, cptr
= c
->constraints
;
127 if (strcasecmp(cptr
->option
->keyword
, option
))
128 num_options
= cupsAddOption(cptr
->option
->keyword
, cptr
->choice
->choice
,
129 num_options
, options
);
132 cupsArrayDelete(active
);
134 return (num_options
);
139 * 'cupsResolveConflicts()' - Resolve conflicts in a marked PPD.
141 * This function attempts to resolve any conflicts in a marked PPD, returning
142 * a list of option changes that are required to resolve them. On input,
143 * "num_options" and "options" contain any pending option changes that have
144 * not yet been marked, while "option" and "choice" contain the most recent
145 * selection which may or may not be in "num_options" or "options".
147 * On successful return, "num_options" and "options" are updated to contain
148 * "option" and "choice" along with any changes required to resolve conflicts
149 * specified in the PPD file and 1 is returned.
151 * If option conflicts cannot be resolved, "num_options" and "options" are not
152 * changed and 0 is returned.
154 * When resolving conflicts, @code cupsResolveConflicts@ does not consider
155 * changes to the current page size (@code media@, @code PageSize@, and
156 * @code PageRegion@) or to the most recent option specified in "option".
157 * Thus, if the only way to resolve a conflict is to change the page size
158 * or the option the user most recently changed, @code cupsResolveConflicts@
159 * will return 0 to indicate it was unable to resolve the conflicts.
161 * The @code cupsResolveConflicts@ function uses one of two sources of option
162 * constraint information. The preferred constraint information is defined by
163 * @code cupsUIConstraints@ and @code cupsUIResolver@ attributes - in this
164 * case, the PPD file provides constraint resolution actions.
166 * The backup constraint information is defined by the
167 * @code UIConstraints@ and @code NonUIConstraints@ attributes. These
168 * constraints are resolved algorithmically by first selecting the default
169 * choice for the conflicting option, then iterating over all possible choices
170 * until a non-conflicting option choice is found.
175 int /* O - 1 on success, 0 on failure */
176 cupsResolveConflicts(
177 ppd_file_t
*ppd
, /* I - PPD file */
178 const char *option
, /* I - Newly selected option or @code NULL@ for none */
179 const char *choice
, /* I - Newly selected choice or @code NULL@ for none */
180 int *num_options
, /* IO - Number of additional selected options */
181 cups_option_t
**options
) /* IO - Additional selected options */
183 int i
, /* Looping var */
184 num_newopts
, /* Number of new options */
185 num_resopts
; /* Number of resolver options */
186 cups_option_t
*newopts
, /* New options */
187 *resopts
; /* Resolver options */
188 cups_array_t
*active
, /* Active constraints */
189 *pass
, /* Resolvers for this pass */
190 *resolvers
; /* Resolvers we have used */
191 _ppd_cups_uiconsts_t
*consts
; /* Current constraints */
192 _ppd_cups_uiconst_t
*constptr
; /* Current constraint */
193 ppd_attr_t
*resolver
; /* Current resolver */
194 const char *value
; /* Selected option value */
195 int changed
; /* Did we change anything? */
196 ppd_choice_t
*marked
; /* Marked choice */
200 * Range check input...
203 if (!ppd
|| !num_options
|| !options
|| (option
== NULL
) != (choice
== NULL
))
207 * Build a shadow option array...
213 for (i
= 0; i
< *num_options
; i
++)
214 num_newopts
= cupsAddOption((*options
)[i
].name
, (*options
)[i
].value
,
215 num_newopts
, &newopts
);
216 if (option
&& strcasecmp(option
, "Collate"))
217 num_newopts
= cupsAddOption(option
, choice
, num_newopts
, &newopts
);
220 * Loop until we have no conflicts...
223 cupsArraySave(ppd
->sorted_attrs
);
226 pass
= cupsArrayNew((cups_array_func_t
)strcasecmp
, NULL
);
228 while ((active
= ppd_test_constraints(ppd
, NULL
, NULL
, num_newopts
, newopts
,
229 _PPD_ALL_CONSTRAINTS
)) != NULL
)
232 resolvers
= cupsArrayNew((cups_array_func_t
)strcasecmp
, NULL
);
234 for (consts
= (_ppd_cups_uiconsts_t
*)cupsArrayFirst(active
), changed
= 0;
236 consts
= (_ppd_cups_uiconsts_t
*)cupsArrayNext(active
))
238 if (consts
->resolver
[0])
241 * Look up the resolver...
244 if (cupsArrayFind(pass
, consts
->resolver
))
245 continue; /* Already applied this resolver... */
247 if (cupsArrayFind(resolvers
, consts
->resolver
))
253 DEBUG_printf(("ppdResolveConflicts: Resolver loop with %s!\n",
258 if ((resolver
= ppdFindAttr(ppd
, "cupsUIResolver",
259 consts
->resolver
)) == NULL
)
261 DEBUG_printf(("ppdResolveConflicts: Resolver %s not found!\n",
266 if (!resolver
->value
)
268 DEBUG_printf(("ppdResolveConflicts: Resolver %s has no value!\n",
274 * Add the options from the resolver...
277 cupsArrayAdd(pass
, consts
->resolver
);
278 cupsArrayAdd(resolvers
, consts
->resolver
);
280 if (option
&& choice
)
283 num_resopts
= _ppdParseOptions(resolver
->value
, 0, &resopts
);
285 if ((value
= cupsGetOption(option
, num_newopts
, newopts
)) != NULL
&&
286 !strcasecmp(value
, choice
))
288 DEBUG_printf(("cupsResolveConflicts: Resolver %s changes %s!\n",
289 consts
->resolver
, option
));
290 cupsFreeOptions(num_resopts
, resopts
);
294 cupsFreeOptions(num_resopts
, resopts
);
297 num_newopts
= _ppdParseOptions(resolver
->value
, num_newopts
, &newopts
);
303 * Try resolving by choosing the default values for non-installable
304 * options, then by iterating through the possible choices...
307 int j
; /* Looping var */
308 ppd_choice_t
*cptr
; /* Current choice */
309 cups_array_t
*test
; /* Test array for conflicts */
312 for (i
= consts
->num_constraints
, constptr
= consts
->constraints
;
317 * Can't resolve by changing an installable option...
320 if (constptr
->installable
)
324 * Is this the option we are changing?
327 if (option
&& !strcasecmp(constptr
->option
->keyword
, option
))
331 * Get the current option choice...
334 if ((value
= cupsGetOption(constptr
->option
->keyword
, num_newopts
,
337 marked
= ppdFindMarkedChoice(ppd
, constptr
->option
->keyword
);
338 value
= marked
? marked
->choice
: "";
342 * Try the default choice...
347 if (strcasecmp(value
, constptr
->option
->defchoice
) &&
348 (test
= ppd_test_constraints(ppd
, constptr
->option
->keyword
,
349 constptr
->option
->defchoice
,
350 num_newopts
, newopts
,
351 _PPD_ALL_CONSTRAINTS
)) == NULL
)
357 num_newopts
= cupsAddOption(constptr
->option
->keyword
,
358 constptr
->option
->defchoice
,
359 num_newopts
, &newopts
);
365 * Try each choice instead...
368 for (j
= constptr
->option
->num_choices
,
369 cptr
= constptr
->option
->choices
;
373 cupsArrayDelete(test
);
376 if (strcasecmp(value
, cptr
->choice
) &&
377 strcasecmp(constptr
->option
->defchoice
, cptr
->choice
) &&
378 (test
= ppd_test_constraints(ppd
, constptr
->option
->keyword
,
379 cptr
->choice
, num_newopts
,
381 _PPD_ALL_CONSTRAINTS
)) == NULL
)
384 * This choice works...
387 num_newopts
= cupsAddOption(constptr
->option
->keyword
,
388 cptr
->choice
, num_newopts
,
395 cupsArrayDelete(test
);
402 DEBUG_puts("ppdResolveConflicts: Unable to automatically resolve "
408 cupsArrayClear(pass
);
409 cupsArrayDelete(active
);
413 * Free the caller's option array...
416 cupsFreeOptions(*num_options
, *options
);
419 * If Collate is the option we are testing, add it here. Otherwise, remove
420 * any Collate option from the resolve list since the filters automatically
421 * handle manual collation...
424 if (option
&& !strcasecmp(option
, "Collate"))
425 num_newopts
= cupsAddOption(option
, choice
, num_newopts
, &newopts
);
427 num_newopts
= cupsRemoveOption("Collate", num_newopts
, &newopts
);
430 * Return the new list of options to the caller...
433 *num_options
= num_newopts
;
436 cupsArrayDelete(pass
);
437 cupsArrayDelete(resolvers
);
439 cupsArrayRestore(ppd
->sorted_attrs
);
444 * If we get here, we failed to resolve...
449 cupsFreeOptions(num_newopts
, newopts
);
451 cupsArrayDelete(pass
);
452 cupsArrayDelete(resolvers
);
454 cupsArrayRestore(ppd
->sorted_attrs
);
461 * 'ppdConflicts()' - Check to see if there are any conflicts among the
462 * marked option choices.
464 * The returned value is the same as returned by @link ppdMarkOption@.
467 int /* O - Number of conflicts found */
468 ppdConflicts(ppd_file_t
*ppd
) /* I - PPD to check */
470 int i
, /* Looping variable */
471 conflicts
; /* Number of conflicts */
472 cups_array_t
*active
; /* Active conflicts */
473 _ppd_cups_uiconsts_t
*c
; /* Current constraints */
474 _ppd_cups_uiconst_t
*cptr
; /* Current constraint */
475 ppd_option_t
*o
; /* Current option */
482 * Clear all conflicts...
485 for (o
= ppdFirstOption(ppd
); o
; o
= ppdNextOption(ppd
))
489 * Test for conflicts...
492 active
= ppd_test_constraints(ppd
, NULL
, NULL
, 0, NULL
,
493 _PPD_ALL_CONSTRAINTS
);
494 conflicts
= cupsArrayCount(active
);
497 * Loop through all of the UI constraints and flag any options
501 for (c
= (_ppd_cups_uiconsts_t
*)cupsArrayFirst(active
);
503 c
= (_ppd_cups_uiconsts_t
*)cupsArrayNext(active
))
505 for (i
= c
->num_constraints
, cptr
= c
->constraints
;
508 cptr
->option
->conflicted
= 1;
511 cupsArrayDelete(active
);
514 * Return the number of conflicts found...
522 * 'ppdInstallableConflict()' - Test whether an option choice conflicts with
523 * an installable option.
525 * This function tests whether a particular option choice is available based
526 * on constraints against options in the "InstallableOptions" group.
531 int /* O - 1 if conflicting, 0 if not conflicting */
532 ppdInstallableConflict(
533 ppd_file_t
*ppd
, /* I - PPD file */
534 const char *option
, /* I - Option */
535 const char *choice
) /* I - Choice */
537 cups_array_t
*active
; /* Active conflicts */
541 * Range check input...
544 if (!ppd
|| !option
|| !choice
)
548 * Test constraints using the new option...
551 active
= ppd_test_constraints(ppd
, option
, choice
, 0, NULL
,
552 _PPD_INSTALLABLE_CONSTRAINTS
);
554 cupsArrayDelete(active
);
556 return (active
!= NULL
);
561 * 'ppd_is_installable()' - Determine whether an option is in the
562 * InstallableOptions group.
565 static int /* O - 1 if installable, 0 if normal */
567 ppd_group_t
*installable
, /* I - InstallableOptions group */
568 const char *name
) /* I - Option name */
572 int i
; /* Looping var */
573 ppd_option_t
*option
; /* Current option */
576 for (i
= installable
->num_options
, option
= installable
->options
;
579 if (!strcasecmp(option
->keyword
, name
))
588 * 'ppd_load_constraints()' - Load constraints from a PPD file.
592 ppd_load_constraints(ppd_file_t
*ppd
) /* I - PPD file */
594 int i
; /* Looping var */
595 ppd_const_t
*oldconst
; /* Current UIConstraints data */
596 ppd_attr_t
*constattr
; /* Current cupsUIConstraints attribute */
597 _ppd_cups_uiconsts_t
*consts
; /* Current cupsUIConstraints data */
598 _ppd_cups_uiconst_t
*constptr
; /* Current constraint */
599 ppd_group_t
*installable
; /* Installable options group */
600 const char *vptr
; /* Pointer into constraint value */
601 char option
[PPD_MAX_NAME
], /* Option name/MainKeyword */
602 choice
[PPD_MAX_NAME
], /* Choice/OptionKeyword */
603 *ptr
; /* Pointer into option or choice */
607 * Create an array to hold the constraint data...
610 ppd
->cups_uiconstraints
= cupsArrayNew(NULL
, NULL
);
613 * Find the installable options group if it exists...
616 for (i
= ppd
->num_groups
, installable
= ppd
->groups
;
618 i
--, installable
++)
619 if (!strcasecmp(installable
->name
, "InstallableOptions"))
626 * Load old-style [Non]UIConstraints data...
629 for (i
= ppd
->num_consts
, oldconst
= ppd
->consts
; i
> 0; i
--, oldconst
++)
632 * Weed out nearby duplicates, since the PPD spec requires that you
633 * define both "*Foo foo *Bar bar" and "*Bar bar *Foo foo"...
637 !strcasecmp(oldconst
[0].option1
, oldconst
[1].option2
) &&
638 !strcasecmp(oldconst
[0].choice1
, oldconst
[1].choice2
) &&
639 !strcasecmp(oldconst
[0].option2
, oldconst
[1].option1
) &&
640 !strcasecmp(oldconst
[0].choice2
, oldconst
[1].choice1
))
647 if ((consts
= calloc(1, sizeof(_ppd_cups_uiconsts_t
))) == NULL
)
649 DEBUG_puts("ppd_load_constraints: Unable to allocate memory for "
654 if ((constptr
= calloc(2, sizeof(_ppd_cups_uiconst_t
))) == NULL
)
657 DEBUG_puts("ppd_load_constraints: Unable to allocate memory for "
663 * Fill in the information...
666 consts
->num_constraints
= 2;
667 consts
->constraints
= constptr
;
669 if (!strncasecmp(oldconst
->option1
, "Custom", 6) &&
670 !strcasecmp(oldconst
->choice1
, "True"))
672 constptr
[0].option
= ppdFindOption(ppd
, oldconst
->option1
+ 6);
673 constptr
[0].choice
= ppdFindChoice(constptr
[0].option
, "Custom");
674 constptr
[0].installable
= 0;
678 constptr
[0].option
= ppdFindOption(ppd
, oldconst
->option1
);
679 constptr
[0].choice
= ppdFindChoice(constptr
[0].option
,
681 constptr
[0].installable
= ppd_is_installable(installable
,
685 if (!constptr
[0].option
|| (!constptr
[0].choice
&& oldconst
->choice1
[0]))
687 DEBUG_printf(("ppd_load_constraints: Unknown option *%s %s!\n",
688 oldconst
->option1
, oldconst
->choice1
));
689 free(consts
->constraints
);
694 if (!strncasecmp(oldconst
->option2
, "Custom", 6) &&
695 !strcasecmp(oldconst
->choice2
, "True"))
697 constptr
[1].option
= ppdFindOption(ppd
, oldconst
->option2
+ 6);
698 constptr
[1].choice
= ppdFindChoice(constptr
[1].option
, "Custom");
699 constptr
[1].installable
= 0;
703 constptr
[1].option
= ppdFindOption(ppd
, oldconst
->option2
);
704 constptr
[1].choice
= ppdFindChoice(constptr
[1].option
,
706 constptr
[1].installable
= ppd_is_installable(installable
,
710 if (!constptr
[1].option
|| (!constptr
[1].choice
&& oldconst
->choice2
[0]))
712 DEBUG_printf(("ppd_load_constraints: Unknown option *%s %s!\n",
713 oldconst
->option2
, oldconst
->choice2
));
714 free(consts
->constraints
);
719 consts
->installable
= constptr
[0].installable
|| constptr
[1].installable
;
722 * Add it to the constraints array...
725 cupsArrayAdd(ppd
->cups_uiconstraints
, consts
);
729 * Then load new-style constraints...
732 for (constattr
= ppdFindAttr(ppd
, "cupsUIConstraints", NULL
);
734 constattr
= ppdFindNextAttr(ppd
, "cupsUIConstraints", NULL
))
736 if (!constattr
->value
)
738 DEBUG_puts("ppd_load_constraints: Bad cupsUIConstraints value!");
742 for (i
= 0, vptr
= strchr(constattr
->value
, '*');
744 i
++, vptr
= strchr(vptr
+ 1, '*'));
748 DEBUG_puts("ppd_load_constraints: Bad cupsUIConstraints value!");
752 if ((consts
= calloc(1, sizeof(_ppd_cups_uiconsts_t
))) == NULL
)
754 DEBUG_puts("ppd_load_constraints: Unable to allocate memory for "
755 "cupsUIConstraints!");
759 if ((constptr
= calloc(i
, sizeof(_ppd_cups_uiconst_t
))) == NULL
)
762 DEBUG_puts("ppd_load_constraints: Unable to allocate memory for "
763 "cupsUIConstraints!");
767 consts
->num_constraints
= i
;
768 consts
->constraints
= constptr
;
770 strlcpy(consts
->resolver
, constattr
->spec
, sizeof(consts
->resolver
));
772 for (i
= 0, vptr
= strchr(constattr
->value
, '*');
774 i
++, vptr
= strchr(vptr
, '*'), constptr
++)
777 * Extract "*Option Choice" or just "*Option"...
780 for (vptr
++, ptr
= option
; *vptr
&& !isspace(*vptr
& 255); vptr
++)
781 if (ptr
< (option
+ sizeof(option
) - 1))
786 while (isspace(*vptr
& 255))
793 for (ptr
= choice
; *vptr
&& !isspace(*vptr
& 255); vptr
++)
794 if (ptr
< (choice
+ sizeof(choice
) - 1))
800 if (!strncasecmp(option
, "Custom", 6) && !strcasecmp(choice
, "True"))
802 _cups_strcpy(option
, option
+ 6);
803 strcpy(choice
, "Custom");
806 constptr
->option
= ppdFindOption(ppd
, option
);
807 constptr
->choice
= ppdFindChoice(constptr
->option
, choice
);
808 constptr
->installable
= ppd_is_installable(installable
, option
);
809 consts
->installable
|= constptr
->installable
;
811 if (!constptr
->option
|| (!constptr
->choice
&& choice
[0]))
813 DEBUG_printf(("ppd_load_constraints: Unknown option *%s %s!\n",
820 cupsArrayAdd(ppd
->cups_uiconstraints
, consts
);
823 free(consts
->constraints
);
831 * 'ppd_test_constraints()' - See if any constraints are active.
834 static cups_array_t
* /* O - Array of active constraints */
835 ppd_test_constraints(
836 ppd_file_t
*ppd
, /* I - PPD file */
837 const char *option
, /* I - Current option */
838 const char *choice
, /* I - Current choice */
839 int num_options
, /* I - Number of additional options */
840 cups_option_t
*options
, /* I - Additional options */
841 int which
) /* I - Which constraints to test */
843 int i
; /* Looping var */
844 _ppd_cups_uiconsts_t
*consts
; /* Current constraints */
845 _ppd_cups_uiconst_t
*constptr
; /* Current constraint */
846 ppd_choice_t key
, /* Search key */
847 *marked
; /* Marked choice */
848 cups_array_t
*active
= NULL
; /* Active constraints */
849 const char *value
; /* Current value */
850 int option_conflict
;/* Conflict with current option? */
853 DEBUG_printf(("ppd_test_constraints(ppd=%p, num_options=%d, options=%p, "
854 "which=%d)\n", ppd
, num_options
, options
, which
));
856 if (!ppd
->cups_uiconstraints
)
857 ppd_load_constraints(ppd
);
859 DEBUG_printf(("ppd_test_constraints: %d constraints!\n",
860 cupsArrayCount(ppd
->cups_uiconstraints
)));
862 cupsArraySave(ppd
->marked
);
864 for (consts
= (_ppd_cups_uiconsts_t
*)cupsArrayFirst(ppd
->cups_uiconstraints
);
866 consts
= (_ppd_cups_uiconsts_t
*)cupsArrayNext(ppd
->cups_uiconstraints
))
868 DEBUG_printf(("ppd_test_constraints: installable=%d, resolver=\"%s\", "
869 "num_constraints=%d option1=\"%s\", choice1=\"%s\", "
870 "option2=\"%s\", choice2=\"%s\", ...\n",
871 consts
->installable
, consts
->resolver
, consts
->num_constraints
,
872 consts
->constraints
[0].option
->keyword
,
873 consts
->constraints
[0].choice
?
874 consts
->constraints
[0].choice
->choice
: "",
875 consts
->constraints
[1].option
->keyword
,
876 consts
->constraints
[1].choice
?
877 consts
->constraints
[1].choice
->choice
: ""));
879 if (which
!= _PPD_ALL_CONSTRAINTS
&& which
!= consts
->installable
)
882 DEBUG_puts("ppd_test_constraints: Testing...");
884 for (i
= consts
->num_constraints
, constptr
= consts
->constraints
,
889 DEBUG_printf(("ppd_test_constraints: %s=%s?\n", constptr
->option
->keyword
,
890 constptr
->choice
? constptr
->choice
->choice
: ""));
892 if (constptr
->choice
&&
893 (!strcasecmp(constptr
->option
->keyword
, "PageSize") ||
894 !strcasecmp(constptr
->option
->keyword
, "PageRegion")))
897 * PageSize and PageRegion are used depending on the selected input slot
898 * and manual feed mode. Validate against the selected page size instead
899 * of an individual option...
902 if (option
&& choice
&&
903 (!strcasecmp(option
, "PageSize") ||
904 !strcasecmp(option
, "PageRegion")))
908 if (!strcasecmp(value
, constptr
->choice
->choice
))
911 else if ((value
= cupsGetOption("PageSize", num_options
,
913 if ((value
= cupsGetOption("PageRegion", num_options
,
915 if ((value
= cupsGetOption("media", num_options
, options
)) == NULL
)
917 ppd_size_t
*size
= ppdPageSize(ppd
, NULL
);
923 if (!value
|| strcasecmp(value
, constptr
->choice
->choice
))
925 DEBUG_puts("ppd_test_constraints: NO");
929 else if (constptr
->choice
)
931 if (option
&& choice
&& !strcasecmp(option
, constptr
->option
->keyword
))
933 if (strcasecmp(choice
, constptr
->choice
->choice
))
938 else if ((value
= cupsGetOption(constptr
->option
->keyword
, num_options
,
941 if (strcasecmp(value
, constptr
->choice
->choice
))
943 DEBUG_puts("ppd_test_constraints: NO");
947 else if (!constptr
->choice
->marked
)
949 DEBUG_puts("ppd_test_constraints: NO");
953 else if (option
&& choice
&&
954 !strcasecmp(option
, constptr
->option
->keyword
))
956 if (!strcasecmp(choice
, "None") || !strcasecmp(choice
, "Off") ||
957 !strcasecmp(choice
, "False"))
962 else if ((value
= cupsGetOption(constptr
->option
->keyword
, num_options
,
965 if (!strcasecmp(value
, "None") || !strcasecmp(value
, "Off") ||
966 !strcasecmp(value
, "False"))
968 DEBUG_puts("ppd_test_constraints: NO");
974 key
.option
= constptr
->option
;
976 if ((marked
= (ppd_choice_t
*)cupsArrayFind(ppd
->marked
, &key
))
978 (!strcasecmp(marked
->choice
, "None") ||
979 !strcasecmp(marked
->choice
, "Off") ||
980 !strcasecmp(marked
->choice
, "False")))
982 DEBUG_puts("ppd_test_constraints: NO");
988 if (i
<= 0 && (!option
|| option_conflict
))
991 active
= cupsArrayNew(NULL
, NULL
);
993 cupsArrayAdd(active
, consts
);
994 DEBUG_puts("ppd_test_constraints: Added...");
998 cupsArrayRestore(ppd
->marked
);
1000 DEBUG_printf(("ppd_test_constraints: Found %d active constraints!\n",
1001 cupsArrayCount(active
)));