2 * "$Id: cupstestppd.c 7807 2008-07-28 21:54:24Z mike $"
4 * PPD test program 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 * main() - Main entry for test program.
22 * check_basics() - Check for CR LF, mixed line endings, and blank
24 * check_constraints() - Check UIConstraints in the PPD file.
25 * check_case() - Check that there are no duplicate groups, options,
26 * or choices that differ only by case.
27 * check_defaults() - Check default option keywords in the PPD file.
28 * check_duplex() - Check duplex keywords in the PPD file.
29 * check_filters() - Check filters in the PPD file.
30 * check_profiles() - Check ICC color profiles in the PPD file.
31 * check_sizes() - Check media sizes in the PPD file.
32 * check_translations() - Check translations in the PPD file.
33 * show_conflicts() - Show option conflicts in a PPD file.
34 * test_raster() - Test PostScript commands for raster printers.
35 * usage() - Show program usage.
36 * valid_path() - Check whether a path has the correct capitalization.
37 * valid_utf8() - Check whether a string contains valid UTF-8 text.
41 * Include necessary headers...
44 #include <cups/cups-private.h>
46 #include <cups/ppd-private.h>
47 #include <cups/raster.h>
55 * Error warning overrides...
65 WARN_TRANSLATIONS
= 16,
101 * File permissions...
104 #define MODE_WRITE 0022 /* Group/other write */
105 #define MODE_MASK 0555 /* Owner/group/other read+exec/search */
106 #define MODE_DATAFILE 0444 /* Owner/group/other read */
107 #define MODE_DIRECTORY 0555 /* Owner/group/other read+search */
108 #define MODE_PROGRAM 0555 /* Owner/group/other read+exec */
115 static void check_basics(const char *filename
);
116 static int check_constraints(ppd_file_t
*ppd
, int errors
, int verbose
,
118 static int check_case(ppd_file_t
*ppd
, int errors
, int verbose
);
119 static int check_defaults(ppd_file_t
*ppd
, int errors
, int verbose
,
121 static int check_duplex(ppd_file_t
*ppd
, int errors
, int verbose
,
123 static int check_filters(ppd_file_t
*ppd
, const char *root
, int errors
,
124 int verbose
, int warn
);
125 static int check_profiles(ppd_file_t
*ppd
, const char *root
, int errors
,
126 int verbose
, int warn
);
127 static int check_sizes(ppd_file_t
*ppd
, int errors
, int verbose
, int warn
);
128 static int check_translations(ppd_file_t
*ppd
, int errors
, int verbose
,
130 static void show_conflicts(ppd_file_t
*ppd
, const char *prefix
);
131 static int test_raster(ppd_file_t
*ppd
, int verbose
);
132 static void usage(void) __attribute__((noreturn
));
133 static int valid_path(const char *keyword
, const char *path
, int errors
,
134 int verbose
, int warn
);
135 static int valid_utf8(const char *s
);
139 * 'main()' - Main entry for test program.
142 int /* O - Exit status */
143 main(int argc
, /* I - Number of command-line args */
144 char *argv
[]) /* I - Command-line arguments */
146 int i
, j
, k
, m
, n
; /* Looping vars */
147 int len
; /* Length of option name */
148 char *opt
; /* Option character */
149 const char *ptr
; /* Pointer into string */
150 int files
; /* Number of files */
151 int verbose
; /* Want verbose output? */
152 int warn
; /* Which errors to just warn about */
153 int ignore
; /* Which errors to ignore */
154 int status
; /* Exit status */
155 int errors
; /* Number of conformance errors */
156 int ppdversion
; /* PPD spec version in PPD file */
157 ppd_status_t error
; /* Status of ppdOpen*() */
158 int line
; /* Line number for error */
159 char *root
; /* Root directory */
160 int xdpi
, /* X resolution */
161 ydpi
; /* Y resolution */
162 ppd_file_t
*ppd
; /* PPD file record */
163 ppd_attr_t
*attr
; /* PPD attribute */
164 ppd_size_t
*size
; /* Size record */
165 ppd_group_t
*group
; /* UI group */
166 ppd_option_t
*option
; /* Standard UI option */
167 ppd_group_t
*group2
; /* UI group */
168 ppd_option_t
*option2
; /* Standard UI option */
169 ppd_choice_t
*choice
; /* Standard UI option choice */
170 struct lconv
*loc
; /* Locale data */
171 static char *uis
[] = { "BOOLEAN", "PICKONE", "PICKMANY" };
172 static char *sections
[] = { "ANY", "DOCUMENT", "EXIT",
173 "JCL", "PAGE", "PROLOG" };
176 _cupsSetLocale(argv
);
180 * Display PPD files for each file listed on the command-line...
183 ppdSetConformance(PPD_CONFORM_STRICT
);
193 for (i
= 1; i
< argc
; i
++)
194 if (argv
[i
][0] == '-' && argv
[i
][1])
196 for (opt
= argv
[i
] + 1; *opt
; opt
++)
199 case 'I' : /* Ignore errors */
205 if (!strcmp(argv
[i
], "none"))
207 else if (!strcmp(argv
[i
], "filename"))
208 ignore
|= WARN_FILENAME
;
209 else if (!strcmp(argv
[i
], "filters"))
210 ignore
|= WARN_FILTERS
;
211 else if (!strcmp(argv
[i
], "profiles"))
212 ignore
|= WARN_PROFILES
;
213 else if (!strcmp(argv
[i
], "all"))
214 ignore
= WARN_FILTERS
| WARN_PROFILES
;
219 case 'R' : /* Alternate root directory */
228 case 'W' : /* Turn errors into warnings */
234 if (!strcmp(argv
[i
], "none"))
236 else if (!strcmp(argv
[i
], "constraints"))
237 warn
|= WARN_CONSTRAINTS
;
238 else if (!strcmp(argv
[i
], "defaults"))
239 warn
|= WARN_DEFAULTS
;
240 else if (!strcmp(argv
[i
], "duplex"))
242 else if (!strcmp(argv
[i
], "filters"))
243 warn
|= WARN_FILTERS
;
244 else if (!strcmp(argv
[i
], "profiles"))
245 warn
|= WARN_PROFILES
;
246 else if (!strcmp(argv
[i
], "sizes"))
248 else if (!strcmp(argv
[i
], "translations"))
249 warn
|= WARN_TRANSLATIONS
;
250 else if (!strcmp(argv
[i
], "all"))
256 case 'q' : /* Quiet mode */
259 _cupsLangPuts(stderr
,
260 _("cupstestppd: The -q option is incompatible "
261 "with the -v option."));
268 case 'r' : /* Relaxed mode */
269 ppdSetConformance(PPD_CONFORM_RELAXED
);
272 case 'v' : /* Verbose mode */
275 _cupsLangPuts(stderr
,
276 _("cupstestppd: The -v option is incompatible "
277 "with the -q option."));
292 * Open the PPD file...
295 if (files
&& verbose
>= 0)
300 if (argv
[i
][0] == '-')
306 ppd
= ppdOpen(stdin
);
309 printf("%s:", (ppd
&& ppd
->pcfilename
) ? ppd
->pcfilename
: "(stdin)");
314 * Read from a file...
318 printf("%s:", argv
[i
]);
320 ppd
= ppdOpenFile(argv
[i
]);
325 error
= ppdLastError(&line
);
327 if (error
<= PPD_ALLOC_ERROR
)
329 status
= ERROR_FILE_OPEN
;
333 _cupsLangPuts(stdout
, _(" FAIL"));
334 _cupsLangPrintf(stdout
,
335 _(" **FAIL** Unable to open PPD file - %s"),
341 status
= ERROR_PPD_FORMAT
;
345 _cupsLangPuts(stdout
, _(" FAIL"));
346 _cupsLangPrintf(stdout
,
347 _(" **FAIL** Unable to open PPD file - "
349 ppdErrorString(error
), line
);
353 case PPD_MISSING_PPDADOBE4
:
354 _cupsLangPuts(stdout
,
355 _(" REF: Page 42, section "
358 case PPD_MISSING_VALUE
:
359 _cupsLangPuts(stdout
,
360 _(" REF: Page 20, section "
363 case PPD_BAD_OPEN_GROUP
:
364 case PPD_NESTED_OPEN_GROUP
:
365 _cupsLangPuts(stdout
,
366 _(" REF: Pages 45-46, section "
369 case PPD_BAD_OPEN_UI
:
370 case PPD_NESTED_OPEN_UI
:
371 _cupsLangPuts(stdout
,
372 _(" REF: Pages 42-45, section "
375 case PPD_BAD_ORDER_DEPENDENCY
:
376 _cupsLangPuts(stdout
,
377 _(" REF: Pages 48-49, section "
380 case PPD_BAD_UI_CONSTRAINTS
:
381 _cupsLangPuts(stdout
,
382 _(" REF: Pages 52-54, section "
385 case PPD_MISSING_ASTERISK
:
386 _cupsLangPuts(stdout
,
387 _(" REF: Page 15, section "
390 case PPD_LINE_TOO_LONG
:
391 _cupsLangPuts(stdout
,
392 _(" REF: Page 15, section "
395 case PPD_ILLEGAL_CHARACTER
:
396 _cupsLangPuts(stdout
,
397 _(" REF: Page 15, section "
400 case PPD_ILLEGAL_MAIN_KEYWORD
:
401 _cupsLangPuts(stdout
,
402 _(" REF: Pages 16-17, section "
405 case PPD_ILLEGAL_OPTION_KEYWORD
:
406 _cupsLangPuts(stdout
,
407 _(" REF: Page 19, section "
410 case PPD_ILLEGAL_TRANSLATION
:
411 _cupsLangPuts(stdout
,
412 _(" REF: Page 27, section "
419 check_basics(argv
[i
]);
427 * Show the header and then perform basic conformance tests (limited
428 * only by what the CUPS PPD functions actually load...)
435 _cupsLangPuts(stdout
,
436 _("\n DETAILED CONFORMANCE TEST RESULTS"));
438 if ((attr
= ppdFindAttr(ppd
, "FormatVersion", NULL
)) != NULL
&&
440 ppdversion
= (int)(10 * _cupsStrScand(attr
->value
, NULL
, loc
) + 0.5);
442 if ((attr
= ppdFindAttr(ppd
, "cupsFilter2", NULL
)) != NULL
)
446 if (strstr(attr
->value
, "application/vnd.cups-raster"))
448 if (!test_raster(ppd
, verbose
))
453 while ((attr
= ppdFindNextAttr(ppd
, "cupsFilter2", NULL
)) != NULL
);
457 for (j
= 0; j
< ppd
->num_filters
; j
++)
458 if (strstr(ppd
->filters
[j
], "application/vnd.cups-raster"))
460 if (!test_raster(ppd
, verbose
))
467 * Look for default keywords with no matching option...
470 if (!(warn
& WARN_DEFAULTS
))
471 errors
= check_defaults(ppd
, errors
, verbose
, 0);
473 if ((attr
= ppdFindAttr(ppd
, "DefaultImageableArea", NULL
)) == NULL
)
477 if (!errors
&& !verbose
)
478 _cupsLangPuts(stdout
, _(" FAIL"));
480 _cupsLangPuts(stdout
,
481 _(" **FAIL** REQUIRED DefaultImageableArea\n"
482 " REF: Page 102, section 5.15."));
487 else if (ppdPageSize(ppd
, attr
->value
) == NULL
&&
488 strcmp(attr
->value
, "Unknown"))
492 if (!errors
&& !verbose
)
493 _cupsLangPuts(stdout
, _(" FAIL"));
495 _cupsLangPrintf(stdout
,
496 _(" **FAIL** BAD DefaultImageableArea %s\n"
497 " REF: Page 102, section 5.15."),
506 _cupsLangPuts(stdout
, _(" PASS DefaultImageableArea"));
509 if ((attr
= ppdFindAttr(ppd
, "DefaultPaperDimension", NULL
)) == NULL
)
513 if (!errors
&& !verbose
)
514 _cupsLangPuts(stdout
, _(" FAIL"));
516 _cupsLangPuts(stdout
,
517 _(" **FAIL** REQUIRED DefaultPaperDimension\n"
518 " REF: Page 103, section 5.15."));
523 else if (ppdPageSize(ppd
, attr
->value
) == NULL
&&
524 strcmp(attr
->value
, "Unknown"))
528 if (!errors
&& !verbose
)
529 _cupsLangPuts(stdout
, _(" FAIL"));
531 _cupsLangPrintf(stdout
,
532 _(" **FAIL** BAD DefaultPaperDimension %s\n"
533 " REF: Page 103, section 5.15."),
539 else if (verbose
> 0)
540 _cupsLangPuts(stdout
, _(" PASS DefaultPaperDimension"));
542 for (j
= 0, group
= ppd
->groups
; j
< ppd
->num_groups
; j
++, group
++)
543 for (k
= 0, option
= group
->options
;
544 k
< group
->num_options
;
548 * Verify that we have a default choice...
551 if (option
->defchoice
[0])
553 if (ppdFindChoice(option
, option
->defchoice
) == NULL
&&
554 strcmp(option
->defchoice
, "Unknown"))
558 if (!errors
&& !verbose
)
559 _cupsLangPuts(stdout
, _(" FAIL"));
561 _cupsLangPrintf(stdout
,
562 _(" **FAIL** BAD Default%s %s\n"
563 " REF: Page 40, section 4.5."),
564 option
->keyword
, option
->defchoice
);
569 else if (verbose
> 0)
570 _cupsLangPrintf(stdout
,
571 _(" PASS Default%s"),
578 if (!errors
&& !verbose
)
579 _cupsLangPuts(stdout
, _(" FAIL"));
581 _cupsLangPrintf(stdout
,
582 _(" **FAIL** REQUIRED Default%s\n"
583 " REF: Page 40, section 4.5."),
591 if ((attr
= ppdFindAttr(ppd
, "FileVersion", NULL
)) != NULL
)
593 for (ptr
= attr
->value
; *ptr
; ptr
++)
594 if (!isdigit(*ptr
& 255) && *ptr
!= '.')
601 if (!errors
&& !verbose
)
602 _cupsLangPuts(stdout
, _(" FAIL"));
604 _cupsLangPrintf(stdout
,
605 _(" **FAIL** Bad FileVersion \"%s\"\n"
606 " REF: Page 56, section 5.3."),
612 else if (verbose
> 0)
613 _cupsLangPuts(stdout
, _(" PASS FileVersion"));
619 if (!errors
&& !verbose
)
620 _cupsLangPuts(stdout
, _(" FAIL"));
622 _cupsLangPuts(stdout
,
623 _(" **FAIL** REQUIRED FileVersion\n"
624 " REF: Page 56, section 5.3."));
630 if ((attr
= ppdFindAttr(ppd
, "FormatVersion", NULL
)) != NULL
)
633 if (*ptr
== '4' && ptr
[1] == '.')
636 for (ptr
+= 2; *ptr
; ptr
++)
637 if (!isdigit(*ptr
& 255))
645 if (!errors
&& !verbose
)
646 _cupsLangPuts(stdout
, _(" FAIL"));
648 _cupsLangPrintf(stdout
,
649 _(" **FAIL** Bad FormatVersion \"%s\"\n"
650 " REF: Page 56, section 5.3."),
656 else if (verbose
> 0)
657 _cupsLangPuts(stdout
, _(" PASS FormatVersion"));
663 if (!errors
&& !verbose
)
664 _cupsLangPuts(stdout
, _(" FAIL"));
666 _cupsLangPuts(stdout
,
667 _(" **FAIL** REQUIRED FormatVersion\n"
668 " REF: Page 56, section 5.3."));
674 if (ppd
->lang_encoding
!= NULL
)
677 _cupsLangPuts(stdout
, _(" PASS LanguageEncoding"));
679 else if (ppdversion
> 40)
683 if (!errors
&& !verbose
)
684 _cupsLangPuts(stdout
, _(" FAIL"));
686 _cupsLangPuts(stdout
,
687 _(" **FAIL** REQUIRED LanguageEncoding\n"
688 " REF: Pages 56-57, section 5.3."));
694 if (ppd
->lang_version
!= NULL
)
697 _cupsLangPuts(stdout
, _(" PASS LanguageVersion"));
703 if (!errors
&& !verbose
)
704 _cupsLangPuts(stdout
, _(" FAIL"));
706 _cupsLangPuts(stdout
,
707 _(" **FAIL** REQUIRED LanguageVersion\n"
708 " REF: Pages 57-58, section 5.3."));
714 if (ppd
->manufacturer
!= NULL
)
716 if (!_cups_strncasecmp(ppd
->manufacturer
, "Hewlett-Packard", 15) ||
717 !_cups_strncasecmp(ppd
->manufacturer
, "Hewlett Packard", 15))
721 if (!errors
&& !verbose
)
722 _cupsLangPuts(stdout
, _(" FAIL"));
724 _cupsLangPuts(stdout
,
725 _(" **FAIL** BAD Manufacturer (should be "
727 " REF: Page 211, table D.1."));
732 else if (!_cups_strncasecmp(ppd
->manufacturer
, "OkiData", 7) ||
733 !_cups_strncasecmp(ppd
->manufacturer
, "Oki Data", 8))
737 if (!errors
&& !verbose
)
738 _cupsLangPuts(stdout
, _(" FAIL"));
740 _cupsLangPuts(stdout
,
741 _(" **FAIL** BAD Manufacturer (should be "
743 " REF: Page 211, table D.1."));
748 else if (verbose
> 0)
749 _cupsLangPuts(stdout
, _(" PASS Manufacturer"));
751 else if (ppdversion
>= 43)
755 if (!errors
&& !verbose
)
756 _cupsLangPuts(stdout
, _(" FAIL"));
758 _cupsLangPuts(stdout
,
759 _(" **FAIL** REQUIRED Manufacturer\n"
760 " REF: Pages 58-59, section 5.3."));
766 if (ppd
->modelname
!= NULL
)
768 for (ptr
= ppd
->modelname
; *ptr
; ptr
++)
769 if (!isalnum(*ptr
& 255) && !strchr(" ./-+", *ptr
))
776 if (!errors
&& !verbose
)
777 _cupsLangPuts(stdout
, _(" FAIL"));
779 _cupsLangPrintf(stdout
,
780 _(" **FAIL** BAD ModelName - \"%c\" not "
781 "allowed in string.\n"
782 " REF: Pages 59-60, section 5.3."),
788 else if (verbose
> 0)
789 _cupsLangPuts(stdout
, _(" PASS ModelName"));
795 if (!errors
&& !verbose
)
796 _cupsLangPuts(stdout
, _(" FAIL"));
798 _cupsLangPuts(stdout
,
799 _(" **FAIL** REQUIRED ModelName\n"
800 " REF: Pages 59-60, section 5.3."));
806 if (ppd
->nickname
!= NULL
)
809 _cupsLangPuts(stdout
, _(" PASS NickName"));
815 if (!errors
&& !verbose
)
816 _cupsLangPuts(stdout
, _(" FAIL"));
818 _cupsLangPuts(stdout
,
819 _(" **FAIL** REQUIRED NickName\n"
820 " REF: Page 60, section 5.3."));
826 if (ppdFindOption(ppd
, "PageSize") != NULL
)
829 _cupsLangPuts(stdout
, _(" PASS PageSize"));
835 if (!errors
&& !verbose
)
836 _cupsLangPuts(stdout
, _(" FAIL"));
838 _cupsLangPuts(stdout
,
839 _(" **FAIL** REQUIRED PageSize\n"
840 " REF: Pages 99-100, section 5.14."));
846 if (ppdFindOption(ppd
, "PageRegion") != NULL
)
849 _cupsLangPuts(stdout
, _(" PASS PageRegion"));
855 if (!errors
&& !verbose
)
856 _cupsLangPuts(stdout
, _(" FAIL"));
858 _cupsLangPuts(stdout
,
859 _(" **FAIL** REQUIRED PageRegion\n"
860 " REF: Page 100, section 5.14."));
866 if (ppd
->pcfilename
!= NULL
)
869 _cupsLangPuts(stdout
, _(" PASS PCFileName"));
871 else if (!(ignore
& WARN_FILENAME
))
875 if (!errors
&& !verbose
)
876 _cupsLangPuts(stdout
, _(" FAIL"));
878 _cupsLangPuts(stdout
,
879 _(" **FAIL** REQUIRED PCFileName\n"
880 " REF: Pages 61-62, section 5.3."));
886 if (ppd
->product
!= NULL
)
888 if (ppd
->product
[0] != '(' ||
889 ppd
->product
[strlen(ppd
->product
) - 1] != ')')
893 if (!errors
&& !verbose
)
894 _cupsLangPuts(stdout
, _(" FAIL"));
896 _cupsLangPuts(stdout
,
897 _(" **FAIL** BAD Product - not \"(string)\".\n"
898 " REF: Page 62, section 5.3."));
903 else if (verbose
> 0)
904 _cupsLangPuts(stdout
, _(" PASS Product"));
910 if (!errors
&& !verbose
)
911 _cupsLangPuts(stdout
, _(" FAIL"));
913 _cupsLangPuts(stdout
,
914 _(" **FAIL** REQUIRED Product\n"
915 " REF: Page 62, section 5.3."));
921 if ((attr
= ppdFindAttr(ppd
, "PSVersion", NULL
)) != NULL
&&
924 char junkstr
[255]; /* Temp string */
925 int junkint
; /* Temp integer */
928 if (sscanf(attr
->value
, "(%[^)])%d", junkstr
, &junkint
) != 2)
932 if (!errors
&& !verbose
)
933 _cupsLangPuts(stdout
, _(" FAIL"));
935 _cupsLangPuts(stdout
,
936 _(" **FAIL** BAD PSVersion - not \"(string) "
938 " REF: Pages 62-64, section 5.3."));
943 else if (verbose
> 0)
944 _cupsLangPuts(stdout
, _(" PASS PSVersion"));
950 if (!errors
&& !verbose
)
951 _cupsLangPuts(stdout
, _(" FAIL"));
953 _cupsLangPuts(stdout
,
954 _(" **FAIL** REQUIRED PSVersion\n"
955 " REF: Pages 62-64, section 5.3."));
961 if (ppd
->shortnickname
!= NULL
)
963 if (strlen(ppd
->shortnickname
) > 31)
967 if (!errors
&& !verbose
)
968 _cupsLangPuts(stdout
, _(" FAIL"));
970 _cupsLangPuts(stdout
,
971 _(" **FAIL** BAD ShortNickName - longer "
973 " REF: Pages 64-65, section 5.3."));
978 else if (verbose
> 0)
979 _cupsLangPuts(stdout
, _(" PASS ShortNickName"));
981 else if (ppdversion
>= 43)
985 if (!errors
&& !verbose
)
986 _cupsLangPuts(stdout
, _(" FAIL"));
988 _cupsLangPuts(stdout
,
989 _(" **FAIL** REQUIRED ShortNickName\n"
990 " REF: Page 64-65, section 5.3."));
996 if (ppd
->patches
!= NULL
&& strchr(ppd
->patches
, '\"') &&
997 strstr(ppd
->patches
, "*End"))
1001 if (!errors
&& !verbose
)
1002 _cupsLangPuts(stdout
, _(" FAIL"));
1004 _cupsLangPuts(stdout
,
1005 _(" **FAIL** BAD JobPatchFile attribute in file\n"
1006 " REF: Page 24, section 3.4."));
1013 * Check for page sizes without the corresponding ImageableArea or
1014 * PaperDimension values...
1017 if (ppd
->num_sizes
== 0)
1021 if (!errors
&& !verbose
)
1022 _cupsLangPuts(stdout
, _(" FAIL"));
1024 _cupsLangPuts(stdout
,
1025 _(" **FAIL** REQUIRED PageSize\n"
1026 " REF: Page 41, section 5.\n"
1027 " REF: Page 99, section 5.14."));
1034 for (j
= 0, size
= ppd
->sizes
; j
< ppd
->num_sizes
; j
++, size
++)
1037 * Don't check custom size...
1040 if (!strcmp(size
->name
, "Custom"))
1044 * Check for ImageableArea...
1047 if (size
->left
== 0.0 && size
->bottom
== 0.0 &&
1048 size
->right
== 0.0 && size
->top
== 0.0)
1052 if (!errors
&& !verbose
)
1053 _cupsLangPuts(stdout
, _(" FAIL"));
1055 _cupsLangPrintf(stdout
,
1056 _(" **FAIL** REQUIRED ImageableArea for "
1058 " REF: Page 41, section 5.\n"
1059 " REF: Page 102, section 5.15."),
1067 * Check for PaperDimension...
1070 if (size
->width
== 0.0 && size
->length
== 0.0)
1074 if (!errors
&& !verbose
)
1075 _cupsLangPuts(stdout
, _(" FAIL"));
1077 _cupsLangPrintf(stdout
,
1078 _(" **FAIL** REQUIRED PaperDimension "
1080 " REF: Page 41, section 5.\n"
1081 " REF: Page 103, section 5.15."),
1091 * Check for valid Resolution, JCLResolution, or SetResolution values...
1094 if ((option
= ppdFindOption(ppd
, "Resolution")) == NULL
)
1095 if ((option
= ppdFindOption(ppd
, "JCLResolution")) == NULL
)
1096 option
= ppdFindOption(ppd
, "SetResolution");
1100 for (j
= option
->num_choices
, choice
= option
->choices
;
1105 * Verify that all resolution options are of the form NNNdpi
1109 xdpi
= strtol(choice
->choice
, (char **)&ptr
, 10);
1110 if (ptr
> choice
->choice
&& xdpi
> 0)
1113 ydpi
= strtol(ptr
+ 1, (char **)&ptr
, 10);
1120 if (xdpi
<= 0 || xdpi
> 99999 || ydpi
<= 0 || ydpi
> 99999 ||
1125 if (!errors
&& !verbose
)
1126 _cupsLangPuts(stdout
, _(" FAIL"));
1128 _cupsLangPrintf(stdout
,
1129 _(" **FAIL** Bad %s choice %s\n"
1130 " REF: Page 84, section 5.9"),
1131 option
->keyword
, choice
->choice
);
1139 if ((attr
= ppdFindAttr(ppd
, "1284DeviceID", NULL
)) &&
1140 strcmp(attr
->name
, "1284DeviceID"))
1144 if (!errors
&& !verbose
)
1145 _cupsLangPuts(stdout
, _(" FAIL"));
1147 _cupsLangPrintf(stdout
,
1148 _(" **FAIL** %s must be 1284DeviceID\n"
1149 " REF: Page 72, section 5.5"),
1156 errors
= check_case(ppd
, errors
, verbose
);
1158 if (!(warn
& WARN_CONSTRAINTS
))
1159 errors
= check_constraints(ppd
, errors
, verbose
, 0);
1161 if (!(warn
& WARN_FILTERS
) && !(ignore
& WARN_FILTERS
))
1162 errors
= check_filters(ppd
, root
, errors
, verbose
, 0);
1164 if (!(warn
& WARN_PROFILES
) && !(ignore
& WARN_PROFILES
))
1165 errors
= check_profiles(ppd
, root
, errors
, verbose
, 0);
1167 if (!(warn
& WARN_SIZES
))
1168 errors
= check_sizes(ppd
, errors
, verbose
, 0);
1170 if (!(warn
& WARN_TRANSLATIONS
))
1171 errors
= check_translations(ppd
, errors
, verbose
, 0);
1173 if (!(warn
& WARN_DUPLEX
))
1174 errors
= check_duplex(ppd
, errors
, verbose
, 0);
1176 if ((attr
= ppdFindAttr(ppd
, "cupsLanguages", NULL
)) != NULL
&&
1180 * This file contains localizations, check for conformance of the
1181 * base translation...
1184 if ((attr
= ppdFindAttr(ppd
, "LanguageEncoding", NULL
)) != NULL
)
1186 if (!attr
->value
|| strcmp(attr
->value
, "ISOLatin1"))
1188 if (!errors
&& !verbose
)
1189 _cupsLangPuts(stdout
, _(" FAIL"));
1192 _cupsLangPrintf(stdout
,
1193 _(" **FAIL** Bad LanguageEncoding %s - "
1194 "must be ISOLatin1."),
1195 attr
->value
? attr
->value
: "(null)");
1200 if (!ppd
->lang_version
|| strcmp(ppd
->lang_version
, "English"))
1202 if (!errors
&& !verbose
)
1203 _cupsLangPuts(stdout
, _(" FAIL"));
1206 _cupsLangPrintf(stdout
,
1207 _(" **FAIL** Bad LanguageVersion %s - "
1208 "must be English."),
1209 ppd
->lang_version
? ppd
->lang_version
: "(null)");
1215 * Loop through all options and choices...
1218 for (option
= ppdFirstOption(ppd
);
1220 option
= ppdNextOption(ppd
))
1223 * Check for special characters outside A0 to BF, F7, or F8
1224 * that are used for languages other than English.
1227 for (ptr
= option
->text
; *ptr
; ptr
++)
1228 if ((*ptr
& 0x80) && (*ptr
& 0xe0) != 0xa0 &&
1229 (*ptr
& 0xff) != 0xf7 && (*ptr
& 0xff) != 0xf8)
1234 if (!errors
&& !verbose
)
1235 _cupsLangPuts(stdout
, _(" FAIL"));
1238 _cupsLangPrintf(stdout
,
1239 _(" **FAIL** Default translation "
1240 "string for option %s contains 8-bit "
1247 for (j
= 0; j
< option
->num_choices
; j
++)
1250 * Check for special characters outside A0 to BF, F7, or F8
1251 * that are used for languages other than English.
1254 for (ptr
= option
->choices
[j
].text
; *ptr
; ptr
++)
1255 if ((*ptr
& 0x80) && (*ptr
& 0xe0) != 0xa0 &&
1256 (*ptr
& 0xff) != 0xf7 && (*ptr
& 0xff) != 0xf8)
1261 if (!errors
&& !verbose
)
1262 _cupsLangPuts(stdout
, _(" FAIL"));
1265 _cupsLangPrintf(stdout
,
1266 _(" **FAIL** Default translation "
1267 "string for option %s choice %s contains "
1268 "8-bit characters."),
1270 option
->choices
[j
].choice
);
1280 * Final pass/fail notification...
1284 status
= ERROR_CONFORMANCE
;
1286 _cupsLangPuts(stdout
, _(" PASS"));
1290 check_basics(argv
[i
]);
1292 if (warn
& WARN_DEFAULTS
)
1293 errors
= check_defaults(ppd
, errors
, verbose
, 1);
1295 if (warn
& WARN_CONSTRAINTS
)
1296 errors
= check_constraints(ppd
, errors
, verbose
, 1);
1298 if ((warn
& WARN_FILTERS
) && !(ignore
& WARN_FILTERS
))
1299 errors
= check_filters(ppd
, root
, errors
, verbose
, 1);
1301 if ((warn
& WARN_PROFILES
) && !(ignore
& WARN_PROFILES
))
1302 errors
= check_profiles(ppd
, root
, errors
, verbose
, 1);
1304 if (warn
& WARN_SIZES
)
1305 errors
= check_sizes(ppd
, errors
, verbose
, 1);
1307 errors
= check_sizes(ppd
, errors
, verbose
, 2);
1309 if (warn
& WARN_TRANSLATIONS
)
1310 errors
= check_translations(ppd
, errors
, verbose
, 1);
1312 if (warn
& WARN_DUPLEX
)
1313 errors
= check_duplex(ppd
, errors
, verbose
, 1);
1316 * Look for legacy duplex keywords...
1319 if ((option
= ppdFindOption(ppd
, "JCLDuplex")) == NULL
)
1320 if ((option
= ppdFindOption(ppd
, "EFDuplex")) == NULL
)
1321 option
= ppdFindOption(ppd
, "KD03Duplex");
1324 _cupsLangPrintf(stdout
,
1325 _(" WARN Duplex option keyword %s may not "
1326 "work as expected and should be named Duplex.\n"
1327 " REF: Page 122, section 5.17"),
1331 * Look for default keywords with no corresponding option...
1334 for (j
= 0; j
< ppd
->num_attrs
; j
++)
1336 attr
= ppd
->attrs
[j
];
1338 if (!strcmp(attr
->name
, "DefaultColorSpace") ||
1339 !strcmp(attr
->name
, "DefaultColorSep") ||
1340 !strcmp(attr
->name
, "DefaultFont") ||
1341 !strcmp(attr
->name
, "DefaultHalftoneType") ||
1342 !strcmp(attr
->name
, "DefaultImageableArea") ||
1343 !strcmp(attr
->name
, "DefaultLeadingEdge") ||
1344 !strcmp(attr
->name
, "DefaultOutputOrder") ||
1345 !strcmp(attr
->name
, "DefaultPaperDimension") ||
1346 !strcmp(attr
->name
, "DefaultResolution") ||
1347 !strcmp(attr
->name
, "DefaultScreenProc") ||
1348 !strcmp(attr
->name
, "DefaultTransfer"))
1351 if (!strncmp(attr
->name
, "Default", 7) &&
1352 !ppdFindOption(ppd
, attr
->name
+ 7))
1353 _cupsLangPrintf(stdout
,
1354 _(" WARN %s has no corresponding "
1359 if (ppdversion
< 43)
1361 _cupsLangPrintf(stdout
,
1362 _(" WARN Obsolete PPD version %.1f.\n"
1363 " REF: Page 42, section 5.2."),
1367 if (!ppd
->lang_encoding
&& ppdversion
< 41)
1369 _cupsLangPuts(stdout
,
1370 _(" WARN LanguageEncoding required by PPD "
1372 " REF: Pages 56-57, section 5.3."));
1375 if (!ppd
->manufacturer
&& ppdversion
< 43)
1377 _cupsLangPuts(stdout
,
1378 _(" WARN Manufacturer required by PPD "
1380 " REF: Pages 58-59, section 5.3."));
1384 * Treat a PCFileName attribute longer than 12 characters as
1385 * a warning and not a hard error...
1388 if (!(ignore
& WARN_FILENAME
) && ppd
->pcfilename
)
1390 if (strlen(ppd
->pcfilename
) > 12)
1392 _cupsLangPuts(stdout
,
1393 _(" WARN PCFileName longer than 8.3 in "
1394 "violation of PPD spec.\n"
1395 " REF: Pages 61-62, section "
1399 if (!_cups_strcasecmp(ppd
->pcfilename
, "unused.ppd"))
1400 _cupsLangPuts(stdout
,
1401 _(" WARN PCFileName should contain a "
1402 "unique filename.\n"
1403 " REF: Pages 61-62, section "
1407 if (!ppd
->shortnickname
&& ppdversion
< 43)
1409 _cupsLangPuts(stdout
,
1410 _(" WARN ShortNickName required by PPD "
1412 " REF: Pages 64-65, section 5.3."));
1416 * Check the Protocols line and flag PJL + BCP since TBCP is
1417 * usually used with PJL...
1422 if (strstr(ppd
->protocols
, "PJL") &&
1423 strstr(ppd
->protocols
, "BCP") &&
1424 !strstr(ppd
->protocols
, "TBCP"))
1426 _cupsLangPuts(stdout
,
1427 _(" WARN Protocols contains both PJL "
1428 "and BCP; expected TBCP.\n"
1429 " REF: Pages 78-79, section 5.7."));
1432 if (strstr(ppd
->protocols
, "PJL") &&
1433 (!ppd
->jcl_begin
|| !ppd
->jcl_end
|| !ppd
->jcl_ps
))
1435 _cupsLangPuts(stdout
,
1436 _(" WARN Protocols contains PJL but JCL "
1437 "attributes are not set.\n"
1438 " REF: Pages 78-79, section 5.7."));
1443 * Check for options with a common prefix, e.g. Duplex and Duplexer,
1444 * which are errors according to the spec but won't cause problems
1445 * with CUPS specifically...
1448 for (j
= 0, group
= ppd
->groups
; j
< ppd
->num_groups
; j
++, group
++)
1449 for (k
= 0, option
= group
->options
;
1450 k
< group
->num_options
;
1453 len
= (int)strlen(option
->keyword
);
1455 for (m
= 0, group2
= ppd
->groups
;
1456 m
< ppd
->num_groups
;
1458 for (n
= 0, option2
= group2
->options
;
1459 n
< group2
->num_options
;
1461 if (option
!= option2
&&
1462 len
< (int)strlen(option2
->keyword
) &&
1463 !strncmp(option
->keyword
, option2
->keyword
, len
))
1465 _cupsLangPrintf(stdout
,
1466 _(" WARN %s shares a common "
1468 " REF: Page 15, section "
1470 option
->keyword
, option2
->keyword
);
1478 _cupsLangPrintf(stdout
, _(" %d ERRORS FOUND"), errors
);
1480 _cupsLangPuts(stdout
, _(" NO ERRORS FOUND"));
1484 * Then list the options, if "-v" was provided...
1489 _cupsLangPrintf(stdout
,
1491 " language_level = %d\n"
1492 " color_device = %s\n"
1493 " variable_sizes = %s\n"
1495 ppd
->language_level
,
1496 ppd
->color_device
? "TRUE" : "FALSE",
1497 ppd
->variable_sizes
? "TRUE" : "FALSE",
1500 switch (ppd
->colorspace
)
1503 _cupsLangPuts(stdout
, " colorspace = PPD_CS_CMYK");
1506 _cupsLangPuts(stdout
, " colorspace = PPD_CS_CMY");
1509 _cupsLangPuts(stdout
, " colorspace = PPD_CS_GRAY");
1512 _cupsLangPuts(stdout
, " colorspace = PPD_CS_RGB");
1515 _cupsLangPuts(stdout
, " colorspace = <unknown>");
1519 _cupsLangPrintf(stdout
, " num_emulations = %d",
1520 ppd
->num_emulations
);
1521 for (j
= 0; j
< ppd
->num_emulations
; j
++)
1522 _cupsLangPrintf(stdout
, " emulations[%d] = %s",
1523 j
, ppd
->emulations
[j
].name
);
1525 _cupsLangPrintf(stdout
, " lang_encoding = %s",
1526 ppd
->lang_encoding
);
1527 _cupsLangPrintf(stdout
, " lang_version = %s",
1529 _cupsLangPrintf(stdout
, " modelname = %s", ppd
->modelname
);
1530 _cupsLangPrintf(stdout
, " ttrasterizer = %s",
1531 ppd
->ttrasterizer
== NULL
? "None" : ppd
->ttrasterizer
);
1532 _cupsLangPrintf(stdout
, " manufacturer = %s",
1534 _cupsLangPrintf(stdout
, " product = %s", ppd
->product
);
1535 _cupsLangPrintf(stdout
, " nickname = %s", ppd
->nickname
);
1536 _cupsLangPrintf(stdout
, " shortnickname = %s",
1537 ppd
->shortnickname
);
1538 _cupsLangPrintf(stdout
, " patches = %d bytes",
1539 ppd
->patches
== NULL
? 0 : (int)strlen(ppd
->patches
));
1541 _cupsLangPrintf(stdout
, " num_groups = %d", ppd
->num_groups
);
1542 for (j
= 0, group
= ppd
->groups
; j
< ppd
->num_groups
; j
++, group
++)
1544 _cupsLangPrintf(stdout
, " group[%d] = %s",
1547 for (k
= 0, option
= group
->options
; k
< group
->num_options
; k
++, option
++)
1549 _cupsLangPrintf(stdout
,
1550 " options[%d] = %s (%s) %s %s %.0f "
1552 k
, option
->keyword
, option
->text
, uis
[option
->ui
],
1553 sections
[option
->section
], option
->order
,
1554 option
->num_choices
);
1556 if (!strcmp(option
->keyword
, "PageSize") ||
1557 !strcmp(option
->keyword
, "PageRegion"))
1559 for (m
= option
->num_choices
, choice
= option
->choices
;
1563 size
= ppdPageSize(ppd
, choice
->choice
);
1566 _cupsLangPrintf(stdout
,
1567 " %s (%s) = ERROR%s",
1568 choice
->choice
, choice
->text
,
1569 !strcmp(option
->defchoice
, choice
->choice
)
1572 _cupsLangPrintf(stdout
,
1573 " %s (%s) = %.2fx%.2fin "
1574 "(%.1f,%.1f,%.1f,%.1f)%s",
1575 choice
->choice
, choice
->text
,
1576 size
->width
/ 72.0, size
->length
/ 72.0,
1577 size
->left
/ 72.0, size
->bottom
/ 72.0,
1578 size
->right
/ 72.0, size
->top
/ 72.0,
1579 !strcmp(option
->defchoice
, choice
->choice
)
1585 for (m
= option
->num_choices
, choice
= option
->choices
;
1589 _cupsLangPrintf(stdout
, " %s (%s)%s",
1590 choice
->choice
, choice
->text
,
1591 !strcmp(option
->defchoice
, choice
->choice
)
1598 _cupsLangPrintf(stdout
, " num_consts = %d",
1600 for (j
= 0; j
< ppd
->num_consts
; j
++)
1601 _cupsLangPrintf(stdout
,
1602 " consts[%d] = *%s %s *%s %s",
1603 j
, ppd
->consts
[j
].option1
, ppd
->consts
[j
].choice1
,
1604 ppd
->consts
[j
].option2
, ppd
->consts
[j
].choice2
);
1606 _cupsLangPrintf(stdout
, " num_profiles = %d",
1608 for (j
= 0; j
< ppd
->num_profiles
; j
++)
1609 _cupsLangPrintf(stdout
,
1610 " profiles[%d] = %s/%s %.3f %.3f "
1611 "[ %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f ]",
1612 j
, ppd
->profiles
[j
].resolution
,
1613 ppd
->profiles
[j
].media_type
,
1614 ppd
->profiles
[j
].gamma
, ppd
->profiles
[j
].density
,
1615 ppd
->profiles
[j
].matrix
[0][0],
1616 ppd
->profiles
[j
].matrix
[0][1],
1617 ppd
->profiles
[j
].matrix
[0][2],
1618 ppd
->profiles
[j
].matrix
[1][0],
1619 ppd
->profiles
[j
].matrix
[1][1],
1620 ppd
->profiles
[j
].matrix
[1][2],
1621 ppd
->profiles
[j
].matrix
[2][0],
1622 ppd
->profiles
[j
].matrix
[2][1],
1623 ppd
->profiles
[j
].matrix
[2][2]);
1625 _cupsLangPrintf(stdout
, " num_fonts = %d", ppd
->num_fonts
);
1626 for (j
= 0; j
< ppd
->num_fonts
; j
++)
1627 _cupsLangPrintf(stdout
, " fonts[%d] = %s",
1630 _cupsLangPrintf(stdout
, " num_attrs = %d", ppd
->num_attrs
);
1631 for (j
= 0; j
< ppd
->num_attrs
; j
++)
1632 _cupsLangPrintf(stdout
,
1633 " attrs[%d] = %s %s%s%s: \"%s\"", j
,
1634 ppd
->attrs
[j
]->name
, ppd
->attrs
[j
]->spec
,
1635 ppd
->attrs
[j
]->text
[0] ? "/" : "",
1636 ppd
->attrs
[j
]->text
,
1637 ppd
->attrs
[j
]->value
?
1638 ppd
->attrs
[j
]->value
: "(null)");
1652 * 'check_basics()' - Check for CR LF, mixed line endings, and blank lines.
1656 check_basics(const char *filename
) /* I - PPD file to check */
1658 cups_file_t
*fp
; /* File pointer */
1659 int ch
; /* Current character */
1660 int col
, /* Current column */
1661 whitespace
; /* Only seen whitespace? */
1662 int eol
; /* Line endings */
1663 int linenum
; /* Line number */
1664 int mixed
; /* Mixed line endings? */
1667 if ((fp
= cupsFileOpen(filename
, "r")) == NULL
)
1676 while ((ch
= cupsFileGetChar(fp
)) != EOF
)
1678 if (ch
== '\r' || ch
== '\n')
1682 if (eol
== EOL_NONE
)
1684 else if (eol
!= EOL_LF
)
1687 else if (ch
== '\r')
1689 if (cupsFilePeekChar(fp
) == '\n')
1691 cupsFileGetChar(fp
);
1693 if (eol
== EOL_NONE
)
1695 else if (eol
!= EOL_CRLF
)
1698 else if (eol
== EOL_NONE
)
1700 else if (eol
!= EOL_CR
)
1704 if (col
> 0 && whitespace
)
1705 _cupsLangPrintf(stdout
,
1706 _(" WARN Line %d only contains whitespace."),
1715 if (ch
!= ' ' && ch
!= '\t')
1723 _cupsLangPuts(stdout
,
1724 _(" WARN File contains a mix of CR, LF, and "
1725 "CR LF line endings."));
1727 if (eol
== EOL_CRLF
)
1728 _cupsLangPuts(stdout
,
1729 _(" WARN Non-Windows PPD files should use lines "
1730 "ending with only LF, not CR LF."));
1737 * 'check_constraints()' - Check UIConstraints in the PPD file.
1740 static int /* O - Errors found */
1741 check_constraints(ppd_file_t
*ppd
, /* I - PPD file */
1742 int errors
, /* I - Errors found */
1743 int verbose
, /* I - Verbosity level */
1744 int warn
) /* I - Warnings only? */
1746 int i
; /* Looping var */
1747 const char *prefix
; /* WARN/FAIL prefix */
1748 ppd_const_t
*c
; /* Current UIConstraints data */
1749 ppd_attr_t
*constattr
; /* Current cupsUIConstraints attribute */
1750 const char *vptr
; /* Pointer into constraint value */
1751 char option
[PPD_MAX_NAME
],
1752 /* Option name/MainKeyword */
1753 choice
[PPD_MAX_NAME
],
1754 /* Choice/OptionKeyword */
1755 *ptr
; /* Pointer into option or choice */
1756 int num_options
; /* Number of options */
1757 cups_option_t
*options
; /* Options */
1758 ppd_option_t
*o
; /* PPD option */
1761 prefix
= warn
? " WARN " : "**FAIL**";
1765 * See what kind of constraint data we have in the PPD...
1768 if ((constattr
= ppdFindAttr(ppd
, "cupsUIConstraints", NULL
)) != NULL
)
1771 * Check new-style cupsUIConstraints data...
1775 constattr
= ppdFindNextAttr(ppd
, "cupsUIConstraints", NULL
))
1777 if (!constattr
->value
)
1779 if (!warn
&& !errors
&& !verbose
)
1780 _cupsLangPuts(stdout
, _(" FAIL"));
1782 _cupsLangPrintf(stdout
,
1783 _(" %s Empty cupsUIConstraints %s"),
1784 prefix
, constattr
->spec
);
1792 for (i
= 0, vptr
= strchr(constattr
->value
, '*');
1794 i
++, vptr
= strchr(vptr
+ 1, '*'));
1798 if (!warn
&& !errors
&& !verbose
)
1799 _cupsLangPuts(stdout
, _(" FAIL"));
1801 _cupsLangPrintf(stdout
,
1802 _(" %s Bad cupsUIConstraints %s: \"%s\""),
1803 prefix
, constattr
->spec
, constattr
->value
);
1811 cupsArraySave(ppd
->sorted_attrs
);
1813 if (constattr
->spec
[0] &&
1814 !ppdFindAttr(ppd
, "cupsUIResolver", constattr
->spec
))
1816 if (!warn
&& !errors
&& !verbose
)
1817 _cupsLangPuts(stdout
, _(" FAIL"));
1819 _cupsLangPrintf(stdout
,
1820 _(" %s Missing cupsUIResolver %s"),
1821 prefix
, constattr
->spec
);
1827 cupsArrayRestore(ppd
->sorted_attrs
);
1832 for (vptr
= strchr(constattr
->value
, '*');
1834 vptr
= strchr(vptr
, '*'))
1837 * Extract "*Option Choice" or just "*Option"...
1840 for (vptr
++, ptr
= option
; *vptr
&& !isspace(*vptr
& 255); vptr
++)
1841 if (ptr
< (option
+ sizeof(option
) - 1))
1846 while (isspace(*vptr
& 255))
1853 for (ptr
= choice
; *vptr
&& !isspace(*vptr
& 255); vptr
++)
1854 if (ptr
< (choice
+ sizeof(choice
) - 1))
1860 if (!_cups_strncasecmp(option
, "Custom", 6) && !_cups_strcasecmp(choice
, "True"))
1862 _cups_strcpy(option
, option
+ 6);
1863 strcpy(choice
, "Custom");
1866 if ((o
= ppdFindOption(ppd
, option
)) == NULL
)
1868 if (!warn
&& !errors
&& !verbose
)
1869 _cupsLangPuts(stdout
, _(" FAIL"));
1871 _cupsLangPrintf(stdout
,
1872 _(" %s Missing option %s in "
1873 "cupsUIConstraints %s: \"%s\""),
1874 prefix
, option
, constattr
->spec
, constattr
->value
);
1882 if (choice
[0] && !ppdFindChoice(o
, choice
))
1884 if (!warn
&& !errors
&& !verbose
)
1885 _cupsLangPuts(stdout
, _(" FAIL"));
1887 _cupsLangPrintf(stdout
,
1888 _(" %s Missing choice *%s %s in "
1889 "cupsUIConstraints %s: \"%s\""),
1890 prefix
, option
, choice
, constattr
->spec
,
1900 num_options
= cupsAddOption(option
, choice
, num_options
, &options
);
1903 for (i
= 0; i
< o
->num_choices
; i
++)
1904 if (_cups_strcasecmp(o
->choices
[i
].choice
, "None") &&
1905 _cups_strcasecmp(o
->choices
[i
].choice
, "Off") &&
1906 _cups_strcasecmp(o
->choices
[i
].choice
, "False"))
1908 num_options
= cupsAddOption(option
, o
->choices
[i
].choice
,
1909 num_options
, &options
);
1916 * Resolvers must list at least two options...
1919 if (num_options
< 2)
1921 if (!warn
&& !errors
&& !verbose
)
1922 _cupsLangPuts(stdout
, _(" FAIL"));
1924 _cupsLangPrintf(stdout
,
1925 _(" %s cupsUIResolver %s does not list at least "
1926 "two different options."),
1927 prefix
, constattr
->spec
);
1934 * Test the resolver...
1937 if (!cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
))
1939 if (!warn
&& !errors
&& !verbose
)
1940 _cupsLangPuts(stdout
, _(" FAIL"));
1942 _cupsLangPrintf(stdout
,
1943 _(" %s cupsUIResolver %s causes a loop."),
1944 prefix
, constattr
->spec
);
1950 cupsFreeOptions(num_options
, options
);
1956 * Check old-style [Non]UIConstraints data...
1959 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
1961 if (!_cups_strncasecmp(c
->option1
, "Custom", 6) &&
1962 !_cups_strcasecmp(c
->choice1
, "True"))
1964 strcpy(option
, c
->option1
+ 6);
1965 strcpy(choice
, "Custom");
1969 strcpy(option
, c
->option1
);
1970 strcpy(choice
, c
->choice1
);
1973 if ((o
= ppdFindOption(ppd
, option
)) == NULL
)
1975 if (!warn
&& !errors
&& !verbose
)
1976 _cupsLangPuts(stdout
, _(" FAIL"));
1978 _cupsLangPrintf(stdout
,
1979 _(" %s Missing option %s in "
1980 "UIConstraints \"*%s %s *%s %s\"."),
1982 c
->option1
, c
->choice1
, c
->option2
, c
->choice2
);
1987 else if (choice
[0] && !ppdFindChoice(o
, choice
))
1989 if (!warn
&& !errors
&& !verbose
)
1990 _cupsLangPuts(stdout
, _(" FAIL"));
1992 _cupsLangPrintf(stdout
,
1993 _(" %s Missing choice *%s %s in "
1994 "UIConstraints \"*%s %s *%s %s\"."),
1995 prefix
, c
->option1
, c
->choice1
,
1996 c
->option1
, c
->choice1
, c
->option2
, c
->choice2
);
2002 if (!_cups_strncasecmp(c
->option2
, "Custom", 6) &&
2003 !_cups_strcasecmp(c
->choice2
, "True"))
2005 strcpy(option
, c
->option2
+ 6);
2006 strcpy(choice
, "Custom");
2010 strcpy(option
, c
->option2
);
2011 strcpy(choice
, c
->choice2
);
2014 if ((o
= ppdFindOption(ppd
, option
)) == NULL
)
2016 if (!warn
&& !errors
&& !verbose
)
2017 _cupsLangPuts(stdout
, _(" FAIL"));
2019 _cupsLangPrintf(stdout
,
2020 _(" %s Missing option %s in "
2021 "UIConstraints \"*%s %s *%s %s\"."),
2023 c
->option1
, c
->choice1
, c
->option2
, c
->choice2
);
2028 else if (choice
[0] && !ppdFindChoice(o
, choice
))
2030 if (!warn
&& !errors
&& !verbose
)
2031 _cupsLangPuts(stdout
, _(" FAIL"));
2033 _cupsLangPrintf(stdout
,
2034 _(" %s Missing choice *%s %s in "
2035 "UIConstraints \"*%s %s *%s %s\"."),
2036 prefix
, c
->option2
, c
->choice2
,
2037 c
->option1
, c
->choice1
, c
->option2
, c
->choice2
);
2050 * 'check_case()' - Check that there are no duplicate groups, options,
2051 * or choices that differ only by case.
2054 static int /* O - Errors found */
2055 check_case(ppd_file_t
*ppd
, /* I - PPD file */
2056 int errors
, /* I - Errors found */
2057 int verbose
) /* I - Verbosity level */
2059 int i
, j
; /* Looping vars */
2060 ppd_group_t
*groupa
, /* First group */
2061 *groupb
; /* Second group */
2062 ppd_option_t
*optiona
, /* First option */
2063 *optionb
; /* Second option */
2064 ppd_choice_t
*choicea
, /* First choice */
2065 *choiceb
; /* Second choice */
2069 * Check that the groups do not have any duplicate names...
2072 for (i
= ppd
->num_groups
, groupa
= ppd
->groups
; i
> 1; i
--, groupa
++)
2073 for (j
= i
- 1, groupb
= groupa
+ 1; j
> 0; j
--, groupb
++)
2074 if (!_cups_strcasecmp(groupa
->name
, groupb
->name
))
2076 if (!errors
&& !verbose
)
2077 _cupsLangPuts(stdout
, _(" FAIL"));
2080 _cupsLangPrintf(stdout
,
2081 _(" **FAIL** Group names %s and %s differ only "
2083 groupa
->name
, groupb
->name
);
2089 * Check that the options do not have any duplicate names...
2092 for (optiona
= ppdFirstOption(ppd
); optiona
; optiona
= ppdNextOption(ppd
))
2094 cupsArraySave(ppd
->options
);
2095 for (optionb
= ppdNextOption(ppd
); optionb
; optionb
= ppdNextOption(ppd
))
2096 if (!_cups_strcasecmp(optiona
->keyword
, optionb
->keyword
))
2098 if (!errors
&& !verbose
)
2099 _cupsLangPuts(stdout
, _(" FAIL"));
2102 _cupsLangPrintf(stdout
,
2103 _(" **FAIL** Option names %s and %s differ only "
2105 optiona
->keyword
, optionb
->keyword
);
2109 cupsArrayRestore(ppd
->options
);
2112 * Then the choices...
2115 for (i
= optiona
->num_choices
, choicea
= optiona
->choices
;
2118 for (j
= i
- 1, choiceb
= choicea
+ 1; j
> 0; j
--, choiceb
++)
2119 if (!strcmp(choicea
->choice
, choiceb
->choice
))
2121 if (!errors
&& !verbose
)
2122 _cupsLangPuts(stdout
, _(" FAIL"));
2125 _cupsLangPrintf(stdout
,
2126 _(" **FAIL** Multiple occurrences of %s "
2128 optiona
->keyword
, choicea
->choice
);
2136 else if (!_cups_strcasecmp(choicea
->choice
, choiceb
->choice
))
2138 if (!errors
&& !verbose
)
2139 _cupsLangPuts(stdout
, _(" FAIL"));
2142 _cupsLangPrintf(stdout
,
2143 _(" **FAIL** %s choice names %s and %s "
2144 "differ only by case."),
2145 optiona
->keyword
, choicea
->choice
, choiceb
->choice
);
2152 * Return the number of errors found...
2160 * 'check_defaults()' - Check default option keywords in the PPD file.
2163 static int /* O - Errors found */
2164 check_defaults(ppd_file_t
*ppd
, /* I - PPD file */
2165 int errors
, /* I - Errors found */
2166 int verbose
, /* I - Verbosity level */
2167 int warn
) /* I - Warnings only? */
2169 int j
, k
; /* Looping vars */
2170 ppd_attr_t
*attr
; /* PPD attribute */
2171 ppd_option_t
*option
; /* Standard UI option */
2172 const char *prefix
; /* WARN/FAIL prefix */
2175 prefix
= warn
? " WARN " : "**FAIL**";
2177 ppdMarkDefaults(ppd
);
2178 if (ppdConflicts(ppd
))
2180 if (!warn
&& !errors
&& !verbose
)
2181 _cupsLangPuts(stdout
, _(" FAIL"));
2184 _cupsLangPrintf(stdout
,
2185 _(" %s Default choices conflicting."), prefix
);
2187 show_conflicts(ppd
, prefix
);
2193 for (j
= 0; j
< ppd
->num_attrs
; j
++)
2195 attr
= ppd
->attrs
[j
];
2197 if (!strcmp(attr
->name
, "DefaultColorSpace") ||
2198 !strcmp(attr
->name
, "DefaultFont") ||
2199 !strcmp(attr
->name
, "DefaultHalftoneType") ||
2200 !strcmp(attr
->name
, "DefaultImageableArea") ||
2201 !strcmp(attr
->name
, "DefaultLeadingEdge") ||
2202 !strcmp(attr
->name
, "DefaultOutputOrder") ||
2203 !strcmp(attr
->name
, "DefaultPaperDimension") ||
2204 !strcmp(attr
->name
, "DefaultResolution") ||
2205 !strcmp(attr
->name
, "DefaultTransfer"))
2208 if (!strncmp(attr
->name
, "Default", 7))
2210 if ((option
= ppdFindOption(ppd
, attr
->name
+ 7)) != NULL
&&
2211 strcmp(attr
->value
, "Unknown"))
2214 * Check that the default option value matches a choice...
2217 for (k
= 0; k
< option
->num_choices
; k
++)
2218 if (!strcmp(option
->choices
[k
].choice
, attr
->value
))
2221 if (k
>= option
->num_choices
)
2223 if (!warn
&& !errors
&& !verbose
)
2224 _cupsLangPuts(stdout
, _(" FAIL"));
2227 _cupsLangPrintf(stdout
,
2228 _(" %s %s %s does not exist."),
2229 prefix
, attr
->name
, attr
->value
);
2243 * 'check_duplex()' - Check duplex keywords in the PPD file.
2246 static int /* O - Errors found */
2247 check_duplex(ppd_file_t
*ppd
, /* I - PPD file */
2248 int errors
, /* I - Error found */
2249 int verbose
, /* I - Verbosity level */
2250 int warn
) /* I - Warnings only? */
2252 int i
; /* Looping var */
2253 ppd_option_t
*option
; /* PPD option */
2254 ppd_choice_t
*choice
; /* Current choice */
2255 const char *prefix
; /* Message prefix */
2258 prefix
= warn
? " WARN " : "**FAIL**";
2261 * Check for a duplex option, and for standard values...
2264 if ((option
= ppdFindOption(ppd
, "Duplex")) != NULL
)
2266 if (!ppdFindChoice(option
, "None"))
2270 if (!warn
&& !errors
&& !verbose
)
2271 _cupsLangPuts(stdout
, _(" FAIL"));
2273 _cupsLangPrintf(stdout
,
2274 _(" %s REQUIRED %s does not define "
2276 " REF: Page 122, section 5.17"),
2277 prefix
, option
->keyword
);
2284 for (i
= option
->num_choices
, choice
= option
->choices
;
2287 if (strcmp(choice
->choice
, "None") &&
2288 strcmp(choice
->choice
, "DuplexNoTumble") &&
2289 strcmp(choice
->choice
, "DuplexTumble") &&
2290 strcmp(choice
->choice
, "SimplexTumble"))
2294 if (!warn
&& !errors
&& !verbose
)
2295 _cupsLangPuts(stdout
, _(" FAIL"));
2297 _cupsLangPrintf(stdout
,
2298 _(" %s Bad %s choice %s.\n"
2299 " REF: Page 122, section 5.17"),
2300 prefix
, option
->keyword
, choice
->choice
);
2313 * 'check_filters()' - Check filters in the PPD file.
2316 static int /* O - Errors found */
2317 check_filters(ppd_file_t
*ppd
, /* I - PPD file */
2318 const char *root
, /* I - Root directory */
2319 int errors
, /* I - Errors found */
2320 int verbose
, /* I - Verbosity level */
2321 int warn
) /* I - Warnings only? */
2323 ppd_attr_t
*attr
; /* PPD attribute */
2324 const char *ptr
; /* Pointer into string */
2325 char super
[16], /* Super-type for filter */
2326 type
[256], /* Type for filter */
2327 dstsuper
[16], /* Destination super-type for filter */
2328 dsttype
[256], /* Destination type for filter */
2329 program
[1024], /* Program/filter name */
2330 pathprog
[1024]; /* Complete path to program/filter */
2331 int cost
; /* Cost of filter */
2332 const char *prefix
; /* WARN/FAIL prefix */
2333 struct stat fileinfo
; /* File information */
2336 prefix
= warn
? " WARN " : "**FAIL**";
2342 for (attr
= ppdFindAttr(ppd
, "cupsFilter", NULL
);
2344 attr
= ppdFindNextAttr(ppd
, "cupsFilter", NULL
))
2346 if (strcmp(attr
->name
, "cupsFilter"))
2348 if (!warn
&& !errors
&& !verbose
)
2349 _cupsLangPuts(stdout
, _(" FAIL"));
2352 _cupsLangPrintf(stdout
,
2353 _(" %s Bad spelling of %s - should be %s."),
2354 prefix
, attr
->name
, "cupsFilter");
2361 sscanf(attr
->value
, "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super
, type
,
2362 &cost
, program
) != 4)
2364 if (!warn
&& !errors
&& !verbose
)
2365 _cupsLangPuts(stdout
, _(" FAIL"));
2368 _cupsLangPrintf(stdout
,
2369 _(" %s Bad cupsFilter value \"%s\"."),
2370 prefix
, attr
->value
);
2375 else if (strcmp(program
, "-"))
2377 if (program
[0] == '/')
2378 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
, program
);
2381 if ((ptr
= getenv("CUPS_SERVERBIN")) == NULL
)
2382 ptr
= CUPS_SERVERBIN
;
2384 if (*ptr
== '/' || !*root
)
2385 snprintf(pathprog
, sizeof(pathprog
), "%s%s/filter/%s", root
, ptr
,
2388 snprintf(pathprog
, sizeof(pathprog
), "%s/%s/filter/%s", root
, ptr
,
2392 if (stat(pathprog
, &fileinfo
))
2394 if (!warn
&& !errors
&& !verbose
)
2395 _cupsLangPuts(stdout
, _(" FAIL"));
2398 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2399 prefix
, "cupsFilter", pathprog
);
2404 else if (fileinfo
.st_uid
!= 0 ||
2405 (fileinfo
.st_mode
& MODE_WRITE
) ||
2406 (fileinfo
.st_mode
& MODE_MASK
) != MODE_PROGRAM
)
2408 if (!warn
&& !errors
&& !verbose
)
2409 _cupsLangPuts(stdout
, _(" FAIL"));
2412 _cupsLangPrintf(stdout
,
2413 _(" %s Bad permissions on %s file \"%s\"."),
2414 prefix
, "cupsFilter", pathprog
);
2420 errors
= valid_path("cupsFilter", pathprog
, errors
, verbose
, warn
);
2428 for (attr
= ppdFindAttr(ppd
, "cupsFilter2", NULL
);
2430 attr
= ppdFindNextAttr(ppd
, "cupsFilter2", NULL
))
2432 if (strcmp(attr
->name
, "cupsFilter2"))
2434 if (!warn
&& !errors
&& !verbose
)
2435 _cupsLangPuts(stdout
, _(" FAIL"));
2438 _cupsLangPrintf(stdout
,
2439 _(" %s Bad spelling of %s - should be %s."),
2440 prefix
, attr
->name
, "cupsFilter2");
2447 sscanf(attr
->value
, "%15[^/]/%255s%*[ \t]%15[^/]/%255s%d%*[ \t]%1023[^\n]",
2448 super
, type
, dstsuper
, dsttype
, &cost
, program
) != 6)
2450 if (!warn
&& !errors
&& !verbose
)
2451 _cupsLangPuts(stdout
, _(" FAIL"));
2454 _cupsLangPrintf(stdout
,
2455 _(" %s Bad cupsFilter2 value \"%s\"."),
2456 prefix
, attr
->value
);
2461 else if (strcmp(program
, "-"))
2463 if (strncmp(program
, "maxsize(", 8) &&
2464 (ptr
= strchr(program
+ 8, ')')) != NULL
)
2467 while (_cups_isspace(*ptr
))
2470 _cups_strcpy(program
, ptr
);
2473 if (program
[0] == '/')
2474 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
, program
);
2477 if ((ptr
= getenv("CUPS_SERVERBIN")) == NULL
)
2478 ptr
= CUPS_SERVERBIN
;
2480 if (*ptr
== '/' || !*root
)
2481 snprintf(pathprog
, sizeof(pathprog
), "%s%s/filter/%s", root
, ptr
,
2484 snprintf(pathprog
, sizeof(pathprog
), "%s/%s/filter/%s", root
, ptr
,
2488 if (stat(pathprog
, &fileinfo
))
2490 if (!warn
&& !errors
&& !verbose
)
2491 _cupsLangPuts(stdout
, _(" FAIL"));
2494 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2495 prefix
, "cupsFilter2", pathprog
);
2500 else if (fileinfo
.st_uid
!= 0 ||
2501 (fileinfo
.st_mode
& MODE_WRITE
) ||
2502 (fileinfo
.st_mode
& MODE_MASK
) != MODE_PROGRAM
)
2504 if (!warn
&& !errors
&& !verbose
)
2505 _cupsLangPuts(stdout
, _(" FAIL"));
2508 _cupsLangPrintf(stdout
,
2509 _(" %s Bad permissions on %s file \"%s\"."),
2510 prefix
, "cupsFilter2", pathprog
);
2516 errors
= valid_path("cupsFilter2", pathprog
, errors
, verbose
, warn
);
2524 for (attr
= ppdFindAttr(ppd
, "cupsPreFilter", NULL
);
2526 attr
= ppdFindNextAttr(ppd
, "cupsPreFilter", NULL
))
2528 if (strcmp(attr
->name
, "cupsPreFilter"))
2530 if (!warn
&& !errors
&& !verbose
)
2531 _cupsLangPuts(stdout
, _(" FAIL"));
2534 _cupsLangPrintf(stdout
,
2535 _(" %s Bad spelling of %s - should be %s."),
2536 prefix
, attr
->name
, "cupsPreFilter");
2543 sscanf(attr
->value
, "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super
, type
,
2544 &cost
, program
) != 4)
2546 if (!warn
&& !errors
&& !verbose
)
2547 _cupsLangPuts(stdout
, _(" FAIL"));
2550 _cupsLangPrintf(stdout
,
2551 _(" %s Bad cupsPreFilter value \"%s\"."),
2552 prefix
, attr
->value
? attr
->value
: "");
2557 else if (strcmp(program
, "-"))
2559 if (program
[0] == '/')
2560 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
, program
);
2563 if ((ptr
= getenv("CUPS_SERVERBIN")) == NULL
)
2564 ptr
= CUPS_SERVERBIN
;
2566 if (*ptr
== '/' || !*root
)
2567 snprintf(pathprog
, sizeof(pathprog
), "%s%s/filter/%s", root
, ptr
,
2570 snprintf(pathprog
, sizeof(pathprog
), "%s/%s/filter/%s", root
, ptr
,
2574 if (stat(pathprog
, &fileinfo
))
2576 if (!warn
&& !errors
&& !verbose
)
2577 _cupsLangPuts(stdout
, _(" FAIL"));
2580 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2581 prefix
, "cupsPreFilter", pathprog
);
2586 else if (fileinfo
.st_uid
!= 0 ||
2587 (fileinfo
.st_mode
& MODE_WRITE
) ||
2588 (fileinfo
.st_mode
& MODE_MASK
) != MODE_PROGRAM
)
2590 if (!warn
&& !errors
&& !verbose
)
2591 _cupsLangPuts(stdout
, _(" FAIL"));
2594 _cupsLangPrintf(stdout
,
2595 _(" %s Bad permissions on %s file \"%s\"."),
2596 prefix
, "cupsPreFilter", pathprog
);
2602 errors
= valid_path("cupsPreFilter", pathprog
, errors
, verbose
, warn
);
2611 for (attr
= ppdFindAttr(ppd
, "APDialogExtension", NULL
);
2613 attr
= ppdFindNextAttr(ppd
, "APDialogExtension", NULL
))
2615 if (strcmp(attr
->name
, "APDialogExtension"))
2617 if (!warn
&& !errors
&& !verbose
)
2618 _cupsLangPuts(stdout
, _(" FAIL"));
2621 _cupsLangPrintf(stdout
,
2622 _(" %s Bad spelling of %s - should be %s."),
2623 prefix
, attr
->name
, "APDialogExtension");
2629 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
,
2630 attr
->value
? attr
->value
: "(null)");
2632 if (!attr
->value
|| stat(pathprog
, &fileinfo
))
2634 if (!warn
&& !errors
&& !verbose
)
2635 _cupsLangPuts(stdout
, _(" FAIL"));
2638 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2639 prefix
, "APDialogExtension", pathprog
);
2644 else if (fileinfo
.st_uid
!= 0 ||
2645 (fileinfo
.st_mode
& MODE_WRITE
) ||
2646 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DIRECTORY
)
2648 if (!warn
&& !errors
&& !verbose
)
2649 _cupsLangPuts(stdout
, _(" FAIL"));
2652 _cupsLangPrintf(stdout
,
2653 _(" %s Bad permissions on %s file \"%s\"."),
2654 prefix
, "APDialogExtension", pathprog
);
2660 errors
= valid_path("APDialogExtension", pathprog
, errors
, verbose
,
2668 if ((attr
= ppdFindAttr(ppd
, "APPrinterIconPath", NULL
)) != NULL
)
2670 if (strcmp(attr
->name
, "APPrinterIconPath"))
2672 if (!warn
&& !errors
&& !verbose
)
2673 _cupsLangPuts(stdout
, _(" FAIL"));
2676 _cupsLangPrintf(stdout
,
2677 _(" %s Bad spelling of %s - should be %s."),
2678 prefix
, attr
->name
, "APPrinterIconPath");
2684 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
,
2685 attr
->value
? attr
->value
: "(null)");
2687 if (!attr
->value
|| stat(pathprog
, &fileinfo
))
2689 if (!warn
&& !errors
&& !verbose
)
2690 _cupsLangPuts(stdout
, _(" FAIL"));
2693 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2694 prefix
, "APPrinterIconPath", pathprog
);
2699 else if (fileinfo
.st_uid
!= 0 ||
2700 (fileinfo
.st_mode
& MODE_WRITE
) ||
2701 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DATAFILE
)
2703 if (!warn
&& !errors
&& !verbose
)
2704 _cupsLangPuts(stdout
, _(" FAIL"));
2707 _cupsLangPrintf(stdout
,
2708 _(" %s Bad permissions on %s file \"%s\"."),
2709 prefix
, "APPrinterIconPath", pathprog
);
2715 errors
= valid_path("APPrinterIconPath", pathprog
, errors
, verbose
,
2720 * APPrinterLowInkTool
2723 if ((attr
= ppdFindAttr(ppd
, "APPrinterLowInkTool", NULL
)) != NULL
)
2725 if (strcmp(attr
->name
, "APPrinterLowInkTool"))
2727 if (!warn
&& !errors
&& !verbose
)
2728 _cupsLangPuts(stdout
, _(" FAIL"));
2731 _cupsLangPrintf(stdout
,
2732 _(" %s Bad spelling of %s - should be %s."),
2733 prefix
, attr
->name
, "APPrinterLowInkTool");
2739 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
,
2740 attr
->value
? attr
->value
: "(null)");
2742 if (!attr
->value
|| stat(pathprog
, &fileinfo
))
2744 if (!warn
&& !errors
&& !verbose
)
2745 _cupsLangPuts(stdout
, _(" FAIL"));
2748 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2749 prefix
, "APPrinterLowInkTool", pathprog
);
2754 else if (fileinfo
.st_uid
!= 0 ||
2755 (fileinfo
.st_mode
& MODE_WRITE
) ||
2756 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DIRECTORY
)
2758 if (!warn
&& !errors
&& !verbose
)
2759 _cupsLangPuts(stdout
, _(" FAIL"));
2762 _cupsLangPrintf(stdout
,
2763 _(" %s Bad permissions on %s file \"%s\"."),
2764 prefix
, "APPrinterLowInkTool", pathprog
);
2770 errors
= valid_path("APPrinterLowInkTool", pathprog
, errors
, verbose
,
2775 * APPrinterUtilityPath
2778 if ((attr
= ppdFindAttr(ppd
, "APPrinterUtilityPath", NULL
)) != NULL
)
2780 if (strcmp(attr
->name
, "APPrinterUtilityPath"))
2782 if (!warn
&& !errors
&& !verbose
)
2783 _cupsLangPuts(stdout
, _(" FAIL"));
2786 _cupsLangPrintf(stdout
,
2787 _(" %s Bad spelling of %s - should be %s."),
2788 prefix
, attr
->name
, "APPrinterUtilityPath");
2794 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
,
2795 attr
->value
? attr
->value
: "(null)");
2797 if (!attr
->value
|| stat(pathprog
, &fileinfo
))
2799 if (!warn
&& !errors
&& !verbose
)
2800 _cupsLangPuts(stdout
, _(" FAIL"));
2803 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2804 prefix
, "APPrinterUtilityPath", pathprog
);
2809 else if (fileinfo
.st_uid
!= 0 ||
2810 (fileinfo
.st_mode
& MODE_WRITE
) ||
2811 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DIRECTORY
)
2813 if (!warn
&& !errors
&& !verbose
)
2814 _cupsLangPuts(stdout
, _(" FAIL"));
2817 _cupsLangPrintf(stdout
,
2818 _(" %s Bad permissions on %s file \"%s\"."),
2819 prefix
, "APPrinterUtilityPath", pathprog
);
2825 errors
= valid_path("APPrinterUtilityPath", pathprog
, errors
, verbose
,
2830 * APScanAppBundleID and APScanAppPath
2833 if ((attr
= ppdFindAttr(ppd
, "APScanAppPath", NULL
)) != NULL
)
2835 if (strcmp(attr
->name
, "APScanAppPath"))
2837 if (!warn
&& !errors
&& !verbose
)
2838 _cupsLangPuts(stdout
, _(" FAIL"));
2841 _cupsLangPrintf(stdout
,
2842 _(" %s Bad spelling of %s - should be %s."),
2843 prefix
, attr
->name
, "APScanAppPath");
2849 if (!attr
->value
|| stat(attr
->value
, &fileinfo
))
2851 if (!warn
&& !errors
&& !verbose
)
2852 _cupsLangPuts(stdout
, _(" FAIL"));
2855 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2856 prefix
, "APScanAppPath",
2857 attr
->value
? attr
->value
: "<NULL>");
2862 else if (fileinfo
.st_uid
!= 0 ||
2863 (fileinfo
.st_mode
& MODE_WRITE
) ||
2864 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DIRECTORY
)
2866 if (!warn
&& !errors
&& !verbose
)
2867 _cupsLangPuts(stdout
, _(" FAIL"));
2870 _cupsLangPrintf(stdout
,
2871 _(" %s Bad permissions on %s file \"%s\"."),
2872 prefix
, "APScanAppPath", attr
->value
);
2878 errors
= valid_path("APScanAppPath", attr
->value
, errors
, verbose
,
2881 if (ppdFindAttr(ppd
, "APScanAppBundleID", NULL
))
2883 if (!warn
&& !errors
&& !verbose
)
2884 _cupsLangPuts(stdout
, _(" FAIL"));
2887 _cupsLangPrintf(stdout
, _(" %s Cannot provide both "
2888 "APScanAppPath and APScanAppBundleID."),
2895 #endif /* __APPLE__ */
2902 * 'check_profiles()' - Check ICC color profiles in the PPD file.
2905 static int /* O - Errors found */
2906 check_profiles(ppd_file_t
*ppd
, /* I - PPD file */
2907 const char *root
, /* I - Root directory */
2908 int errors
, /* I - Errors found */
2909 int verbose
, /* I - Verbosity level */
2910 int warn
) /* I - Warnings only? */
2912 int i
; /* Looping var */
2913 ppd_attr_t
*attr
; /* PPD attribute */
2914 const char *ptr
; /* Pointer into string */
2915 const char *prefix
; /* WARN/FAIL prefix */
2916 char filename
[1024]; /* Profile filename */
2917 struct stat fileinfo
; /* File information */
2918 int num_profiles
= 0; /* Number of profiles */
2919 unsigned hash
, /* Current hash value */
2920 hashes
[1000]; /* Hash values of profile names */
2921 const char *specs
[1000]; /* Specifiers for profiles */
2924 prefix
= warn
? " WARN " : "**FAIL**";
2926 for (attr
= ppdFindAttr(ppd
, "cupsICCProfile", NULL
);
2928 attr
= ppdFindNextAttr(ppd
, "cupsICCProfile", NULL
))
2931 * Check for valid selector...
2934 for (i
= 0, ptr
= strchr(attr
->spec
, '.'); ptr
; ptr
= strchr(ptr
+ 1, '.'))
2937 if (!attr
->value
|| i
< 2)
2939 if (!warn
&& !errors
&& !verbose
)
2940 _cupsLangPuts(stdout
, _(" FAIL"));
2943 _cupsLangPrintf(stdout
,
2944 _(" %s Bad cupsICCProfile %s."),
2945 prefix
, attr
->spec
);
2954 * Check for valid profile filename...
2957 if (attr
->value
[0] == '/')
2958 snprintf(filename
, sizeof(filename
), "%s%s", root
, attr
->value
);
2961 if ((ptr
= getenv("CUPS_DATADIR")) == NULL
)
2964 if (*ptr
== '/' || !*root
)
2965 snprintf(filename
, sizeof(filename
), "%s%s/profiles/%s", root
, ptr
,
2968 snprintf(filename
, sizeof(filename
), "%s/%s/profiles/%s", root
, ptr
,
2972 if (stat(filename
, &fileinfo
))
2974 if (!warn
&& !errors
&& !verbose
)
2975 _cupsLangPuts(stdout
, _(" FAIL"));
2978 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2979 prefix
, "cupsICCProfile", filename
);
2984 else if (fileinfo
.st_uid
!= 0 ||
2985 (fileinfo
.st_mode
& MODE_WRITE
) ||
2986 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DATAFILE
)
2988 if (!warn
&& !errors
&& !verbose
)
2989 _cupsLangPuts(stdout
, _(" FAIL"));
2992 _cupsLangPrintf(stdout
,
2993 _(" %s Bad permissions on %s file \"%s\"."),
2994 prefix
, "cupsICCProfile", filename
);
3000 errors
= valid_path("cupsICCProfile", filename
, errors
, verbose
, warn
);
3003 * Check for hash collisions...
3006 hash
= _ppdHashName(attr
->spec
);
3008 if (num_profiles
> 0)
3010 for (i
= 0; i
< num_profiles
; i
++)
3011 if (hashes
[i
] == hash
)
3014 if (i
< num_profiles
)
3016 if (!warn
&& !errors
&& !verbose
)
3017 _cupsLangPuts(stdout
, _(" FAIL"));
3020 _cupsLangPrintf(stdout
,
3021 _(" %s cupsICCProfile %s hash value "
3022 "collides with %s."), prefix
, attr
->spec
,
3031 * Remember up to 1000 profiles...
3034 if (num_profiles
< 1000)
3036 hashes
[num_profiles
] = hash
;
3037 specs
[num_profiles
] = attr
->spec
;
3047 * 'check_sizes()' - Check media sizes in the PPD file.
3050 static int /* O - Errors found */
3051 check_sizes(ppd_file_t
*ppd
, /* I - PPD file */
3052 int errors
, /* I - Errors found */
3053 int verbose
, /* I - Verbosity level */
3054 int warn
) /* I - Warnings only? */
3056 int i
; /* Looping var */
3057 ppd_size_t
*size
; /* Current size */
3058 int width
, /* Custom width */
3059 length
; /* Custom length */
3060 const char *prefix
; /* WARN/FAIL prefix */
3061 ppd_option_t
*page_size
, /* PageSize option */
3062 *page_region
; /* PageRegion option */
3063 _pwg_media_t
*pwg_media
; /* PWG media */
3064 char buf
[1024]; /* PapeSize name that is supposed to be */
3065 const char *ptr
; /* Pointer into string */
3066 int width_2540ths
, /* PageSize width in 2540ths */
3067 length_2540ths
; /* PageSize length in 2540ths */
3068 int is_ok
; /* Flag for PageSize name verification */
3069 double width_tmp
, /* Width after rounded up */
3070 length_tmp
, /* Length after rounded up */
3071 width_inch
, /* Width in inches */
3072 length_inch
, /* Length in inches */
3073 width_mm
, /* Width in millimeters */
3074 length_mm
; /* Length in millimeters */
3077 prefix
= warn
? " WARN " : "**FAIL**";
3079 if ((page_size
= ppdFindOption(ppd
, "PageSize")) == NULL
&& warn
!= 2)
3081 if (!warn
&& !errors
&& !verbose
)
3082 _cupsLangPuts(stdout
, _(" FAIL"));
3085 _cupsLangPrintf(stdout
,
3086 _(" %s Missing REQUIRED PageSize option.\n"
3087 " REF: Page 99, section 5.14."),
3094 if ((page_region
= ppdFindOption(ppd
, "PageRegion")) == NULL
&& warn
!= 2)
3096 if (!warn
&& !errors
&& !verbose
)
3097 _cupsLangPuts(stdout
, _(" FAIL"));
3100 _cupsLangPrintf(stdout
,
3101 _(" %s Missing REQUIRED PageRegion option.\n"
3102 " REF: Page 100, section 5.14."),
3109 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
3112 * Check that the size name is standard...
3115 if (!strcmp(size
->name
, "Custom"))
3118 * Skip custom page size...
3123 else if (warn
!= 2 && size
->name
[0] == 'w' &&
3124 sscanf(size
->name
, "w%dh%d", &width
, &length
) == 2)
3127 * Validate device-specific size wNNNhNNN should have proper width and
3131 if (fabs(width
- size
->width
) >= 1.0 ||
3132 fabs(length
- size
->length
) >= 1.0)
3134 if (!warn
&& !errors
&& !verbose
)
3135 _cupsLangPuts(stdout
, _(" FAIL"));
3138 _cupsLangPrintf(stdout
,
3139 _(" %s Size \"%s\" has unexpected dimensions "
3141 prefix
, size
->name
, size
->width
, size
->length
);
3149 * Verify that the size is defined for both PageSize and PageRegion...
3152 if (warn
!= 2 && !ppdFindChoice(page_size
, size
->name
))
3154 if (!warn
&& !errors
&& !verbose
)
3155 _cupsLangPuts(stdout
, _(" FAIL"));
3158 _cupsLangPrintf(stdout
,
3159 _(" %s Size \"%s\" defined for %s but not for "
3161 prefix
, size
->name
, "PageRegion", "PageSize");
3166 else if (warn
!= 2 && !ppdFindChoice(page_region
, size
->name
))
3168 if (!warn
&& !errors
&& !verbose
)
3169 _cupsLangPuts(stdout
, _(" FAIL"));
3172 _cupsLangPrintf(stdout
,
3173 _(" %s Size \"%s\" defined for %s but not for "
3175 prefix
, size
->name
, "PageSize", "PageRegion");
3182 * Verify that the size name is Adobe standard name if it's a standard size
3183 * and the dementional name if it's not a standard size. Suffix should be
3184 * .Fullbleed, etc., or numeric, e.g., Letter, Letter.Fullbleed,
3185 * Letter.Transverse, Letter1, Letter2, 4x8, 55x91mm, 55x91mm.Fullbleed, etc.
3191 width_2540ths
= (size
->length
> size
->width
) ?
3192 _PWG_FROMPTS(size
->width
) :
3193 _PWG_FROMPTS(size
->length
);
3194 length_2540ths
= (size
->length
> size
->width
) ?
3195 _PWG_FROMPTS(size
->length
) :
3196 _PWG_FROMPTS(size
->width
);
3197 pwg_media
= _pwgMediaForSize(width_2540ths
, length_2540ths
);
3199 if (pwg_media
&& pwg_media
->ppd
)
3201 strlcpy(buf
, pwg_media
->ppd
, sizeof(buf
));
3203 if (size
->left
== 0 && size
->bottom
== 0 &&
3204 size
->right
== size
->width
&& size
->top
== size
->length
)
3206 snprintf(buf
, sizeof(buf
), "%s.Fullbleed", pwg_media
->ppd
);
3207 if (strcmp(size
->name
, buf
))
3210 else if (size
->width
> size
->length
)
3212 if ((ptr
= pwg_media
->ppd
+ strlen(pwg_media
->ppd
) - 7)
3213 >= pwg_media
->ppd
&& !strcmp(ptr
, "Rotated"))
3215 if (strcmp(size
->name
, buf
))
3220 snprintf(buf
, sizeof(buf
), "%sRotated", pwg_media
->ppd
);
3221 if (strcmp(size
->name
, buf
))
3223 snprintf(buf
, sizeof(buf
), "%s.Transverse", pwg_media
->ppd
);
3224 if (strcmp(size
->name
, buf
))
3231 if ((!strncmp(size
->name
, pwg_media
->ppd
, strlen(pwg_media
->ppd
))))
3233 for (ptr
= size
->name
+ strlen(pwg_media
->ppd
); *ptr
; ptr
++)
3235 if (!isdigit(*ptr
& 255))
3247 _cupsLangPrintf(stdout
,
3248 _(" %s Size \"%s\" should be the Adobe "
3249 "standard name \"%s\"."),
3250 prefix
, size
->name
, buf
);
3254 width_tmp
= (fabs(size
->width
- ceil(size
->width
)) < 0.1) ?
3255 ceil(size
->width
) : size
->width
;
3256 length_tmp
= (fabs(size
->length
- ceil(size
->length
)) < 0.1) ?
3257 ceil(size
->length
) : size
->length
;
3259 if (fmod(width_tmp
, 18.0) == 0.0 && fmod(length_tmp
, 18.0) == 0.0)
3261 width_inch
= width_tmp
/ 72.0;
3262 length_inch
= length_tmp
/ 72.0;
3264 snprintf(buf
, sizeof(buf
), "%gx%g", width_inch
, length_inch
);
3268 width_mm
= size
->width
/ 72.0 * 25.4;
3269 length_mm
= size
->length
/ 72.0 * 25.4;
3271 snprintf(buf
, sizeof(buf
), "%.0fx%.0fmm", width_mm
, length_mm
);
3274 if (size
->left
== 0 && size
->bottom
== 0 &&
3275 size
->right
== size
->width
&& size
->top
== size
->length
)
3276 strlcat(buf
, ".Fullbleed", sizeof(buf
));
3277 else if (size
->width
> size
->length
)
3278 strlcat(buf
, ".Transverse", sizeof(buf
));
3280 if (strcmp(size
->name
, buf
))
3281 _cupsLangPrintf(stdout
,
3282 _(" %s Size \"%s\" should be \"%s\"."),
3283 prefix
, size
->name
, buf
);
3293 * 'check_translations()' - Check translations in the PPD file.
3296 static int /* O - Errors found */
3297 check_translations(ppd_file_t
*ppd
, /* I - PPD file */
3298 int errors
, /* I - Errors found */
3299 int verbose
, /* I - Verbosity level */
3300 int warn
) /* I - Warnings only? */
3302 int j
; /* Looping var */
3303 ppd_attr_t
*attr
; /* PPD attribute */
3304 cups_array_t
*languages
; /* Array of languages */
3305 int langlen
; /* Length of language */
3306 char *language
, /* Current language */
3307 keyword
[PPD_MAX_NAME
], /* Localization keyword (full) */
3308 llkeyword
[PPD_MAX_NAME
],/* Localization keyword (base) */
3309 ckeyword
[PPD_MAX_NAME
], /* Custom option keyword (full) */
3310 cllkeyword
[PPD_MAX_NAME
];
3311 /* Custom option keyword (base) */
3312 ppd_option_t
*option
; /* Standard UI option */
3313 ppd_coption_t
*coption
; /* Custom option */
3314 ppd_cparam_t
*cparam
; /* Custom parameter */
3315 char ll
[3]; /* Base language */
3316 const char *prefix
; /* WARN/FAIL prefix */
3317 const char *text
; /* Pointer into UI text */
3320 prefix
= warn
? " WARN " : "**FAIL**";
3322 if ((languages
= _ppdGetLanguages(ppd
)) != NULL
)
3325 * This file contains localizations, check them...
3328 for (language
= (char *)cupsArrayFirst(languages
);
3330 language
= (char *)cupsArrayNext(languages
))
3332 langlen
= (int)strlen(language
);
3333 if (langlen
!= 2 && langlen
!= 5)
3335 if (!warn
&& !errors
&& !verbose
)
3336 _cupsLangPuts(stdout
, _(" FAIL"));
3339 _cupsLangPrintf(stdout
,
3340 _(" %s Bad language \"%s\"."),
3349 if (!strcmp(language
, "en"))
3352 strlcpy(ll
, language
, sizeof(ll
));
3355 * Loop through all options and choices...
3358 for (option
= ppdFirstOption(ppd
);
3360 option
= ppdNextOption(ppd
))
3362 if (!strcmp(option
->keyword
, "PageRegion"))
3365 snprintf(keyword
, sizeof(keyword
), "%s.Translation", language
);
3366 snprintf(llkeyword
, sizeof(llkeyword
), "%s.Translation", ll
);
3368 if ((attr
= ppdFindAttr(ppd
, keyword
, option
->keyword
)) == NULL
&&
3369 (attr
= ppdFindAttr(ppd
, llkeyword
, option
->keyword
)) == NULL
)
3371 if (!warn
&& !errors
&& !verbose
)
3372 _cupsLangPuts(stdout
, _(" FAIL"));
3375 _cupsLangPrintf(stdout
,
3376 _(" %s Missing \"%s\" translation "
3377 "string for option %s."),
3378 prefix
, language
, option
->keyword
);
3383 else if (!valid_utf8(attr
->text
))
3385 if (!warn
&& !errors
&& !verbose
)
3386 _cupsLangPuts(stdout
, _(" FAIL"));
3389 _cupsLangPrintf(stdout
,
3390 _(" %s Bad UTF-8 \"%s\" translation "
3391 "string for option %s."),
3392 prefix
, language
, option
->keyword
);
3398 snprintf(keyword
, sizeof(keyword
), "%s.%s", language
,
3400 snprintf(llkeyword
, sizeof(llkeyword
), "%s.%s", ll
,
3403 for (j
= 0; j
< option
->num_choices
; j
++)
3406 * First see if this choice is a number; if so, don't require
3410 for (text
= option
->choices
[j
].text
; *text
; text
++)
3411 if (!strchr("0123456789-+.", *text
))
3418 * Check custom choices differently...
3421 if (!_cups_strcasecmp(option
->choices
[j
].choice
, "Custom") &&
3422 (coption
= ppdFindCustomOption(ppd
,
3423 option
->keyword
)) != NULL
)
3425 snprintf(ckeyword
, sizeof(ckeyword
), "%s.Custom%s",
3426 language
, option
->keyword
);
3428 if ((attr
= ppdFindAttr(ppd
, ckeyword
, "True")) != NULL
&&
3429 !valid_utf8(attr
->text
))
3431 if (!warn
&& !errors
&& !verbose
)
3432 _cupsLangPuts(stdout
, _(" FAIL"));
3435 _cupsLangPrintf(stdout
,
3436 _(" %s Bad UTF-8 \"%s\" "
3437 "translation string for option %s, "
3440 ckeyword
+ 1 + strlen(language
),
3447 if (_cups_strcasecmp(option
->keyword
, "PageSize"))
3449 for (cparam
= (ppd_cparam_t
*)cupsArrayFirst(coption
->params
);
3451 cparam
= (ppd_cparam_t
*)cupsArrayNext(coption
->params
))
3453 snprintf(ckeyword
, sizeof(ckeyword
), "%s.ParamCustom%s",
3454 language
, option
->keyword
);
3455 snprintf(cllkeyword
, sizeof(cllkeyword
), "%s.ParamCustom%s",
3456 ll
, option
->keyword
);
3458 if ((attr
= ppdFindAttr(ppd
, ckeyword
,
3459 cparam
->name
)) == NULL
&&
3460 (attr
= ppdFindAttr(ppd
, cllkeyword
,
3461 cparam
->name
)) == NULL
)
3463 if (!warn
&& !errors
&& !verbose
)
3464 _cupsLangPuts(stdout
, _(" FAIL"));
3467 _cupsLangPrintf(stdout
,
3468 _(" %s Missing \"%s\" "
3469 "translation string for option %s, "
3472 ckeyword
+ 1 + strlen(language
),
3478 else if (!valid_utf8(attr
->text
))
3480 if (!warn
&& !errors
&& !verbose
)
3481 _cupsLangPuts(stdout
, _(" FAIL"));
3484 _cupsLangPrintf(stdout
,
3485 _(" %s Bad UTF-8 \"%s\" "
3486 "translation string for option %s, "
3489 ckeyword
+ 1 + strlen(language
),
3498 else if ((attr
= ppdFindAttr(ppd
, keyword
,
3499 option
->choices
[j
].choice
)) == NULL
&&
3500 (attr
= ppdFindAttr(ppd
, llkeyword
,
3501 option
->choices
[j
].choice
)) == NULL
)
3503 if (!warn
&& !errors
&& !verbose
)
3504 _cupsLangPuts(stdout
, _(" FAIL"));
3507 _cupsLangPrintf(stdout
,
3508 _(" %s Missing \"%s\" "
3509 "translation string for option %s, "
3511 prefix
, language
, option
->keyword
,
3512 option
->choices
[j
].choice
);
3517 else if (!valid_utf8(attr
->text
))
3519 if (!warn
&& !errors
&& !verbose
)
3520 _cupsLangPuts(stdout
, _(" FAIL"));
3523 _cupsLangPrintf(stdout
,
3524 _(" %s Bad UTF-8 \"%s\" "
3525 "translation string for option %s, "
3527 prefix
, language
, option
->keyword
,
3528 option
->choices
[j
].choice
);
3538 * Verify that we have the base language for each localized one...
3541 for (language
= (char *)cupsArrayFirst(languages
);
3543 language
= (char *)cupsArrayNext(languages
))
3547 * Lookup the base language...
3550 cupsArraySave(languages
);
3552 strlcpy(ll
, language
, sizeof(ll
));
3554 if (!cupsArrayFind(languages
, ll
) &&
3555 strcmp(ll
, "zh") && strcmp(ll
, "en"))
3557 if (!warn
&& !errors
&& !verbose
)
3558 _cupsLangPuts(stdout
, _(" FAIL"));
3561 _cupsLangPrintf(stdout
,
3562 _(" %s No base translation \"%s\" "
3563 "is included in file."), prefix
, ll
);
3569 cupsArrayRestore(languages
);
3573 * Free memory used for the languages...
3576 _ppdFreeLanguages(languages
);
3584 * 'show_conflicts()' - Show option conflicts in a PPD file.
3588 show_conflicts(ppd_file_t
*ppd
, /* I - PPD to check */
3589 const char *prefix
) /* I - Prefix string */
3591 int i
, j
; /* Looping variables */
3592 ppd_const_t
*c
; /* Current constraint */
3593 ppd_option_t
*o1
, *o2
; /* Options */
3594 ppd_choice_t
*c1
, *c2
; /* Choices */
3598 * Loop through all of the UI constraints and report any options
3602 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
3605 * Grab pointers to the first option...
3608 o1
= ppdFindOption(ppd
, c
->option1
);
3612 else if (c
->choice1
[0] != '\0')
3615 * This constraint maps to a specific choice.
3618 c1
= ppdFindChoice(o1
, c
->choice1
);
3623 * This constraint applies to any choice for this option.
3626 for (j
= o1
->num_choices
, c1
= o1
->choices
; j
> 0; j
--, c1
++)
3631 !_cups_strcasecmp(c1
->choice
, "None") ||
3632 !_cups_strcasecmp(c1
->choice
, "Off") ||
3633 !_cups_strcasecmp(c1
->choice
, "False"))
3638 * Grab pointers to the second option...
3641 o2
= ppdFindOption(ppd
, c
->option2
);
3645 else if (c
->choice2
[0] != '\0')
3648 * This constraint maps to a specific choice.
3651 c2
= ppdFindChoice(o2
, c
->choice2
);
3656 * This constraint applies to any choice for this option.
3659 for (j
= o2
->num_choices
, c2
= o2
->choices
; j
> 0; j
--, c2
++)
3664 !_cups_strcasecmp(c2
->choice
, "None") ||
3665 !_cups_strcasecmp(c2
->choice
, "Off") ||
3666 !_cups_strcasecmp(c2
->choice
, "False"))
3671 * If both options are marked then there is a conflict...
3674 if (c1
!= NULL
&& c1
->marked
&& c2
!= NULL
&& c2
->marked
)
3675 _cupsLangPrintf(stdout
,
3676 _(" %s \"%s %s\" conflicts with \"%s %s\"\n"
3677 " (constraint=\"%s %s %s %s\")."),
3678 prefix
, o1
->keyword
, c1
->choice
, o2
->keyword
, c2
->choice
,
3679 c
->option1
, c
->choice1
, c
->option2
, c
->choice2
);
3685 * 'test_raster()' - Test PostScript commands for raster printers.
3688 static int /* O - 1 on success, 0 on failure */
3689 test_raster(ppd_file_t
*ppd
, /* I - PPD file */
3690 int verbose
) /* I - Verbosity */
3692 cups_page_header2_t header
; /* Page header */
3695 ppdMarkDefaults(ppd
);
3696 if (cupsRasterInterpretPPD(&header
, ppd
, 0, NULL
, 0))
3699 _cupsLangPuts(stdout
, _(" FAIL"));
3702 _cupsLangPrintf(stdout
,
3703 _(" **FAIL** Default option code cannot be "
3704 "interpreted: %s"), cupsRasterErrorString());
3710 * Try a test of custom page size code, if available...
3713 if (!ppdPageSize(ppd
, "Custom.612x792"))
3716 ppdMarkOption(ppd
, "PageSize", "Custom.612x792");
3718 if (cupsRasterInterpretPPD(&header
, ppd
, 0, NULL
, 0))
3721 _cupsLangPuts(stdout
, _(" FAIL"));
3724 _cupsLangPrintf(stdout
,
3725 _(" **FAIL** Default option code cannot be "
3726 "interpreted: %s"), cupsRasterErrorString());
3736 * 'usage()' - Show program usage.
3742 _cupsLangPuts(stdout
, _("Usage: cupstestppd [options] filename1.ppd[.gz] "
3743 "[... filenameN.ppd[.gz]]"));
3744 _cupsLangPuts(stdout
, _(" program | cupstestppd [options] -"));
3745 _cupsLangPuts(stdout
, "");
3746 _cupsLangPuts(stdout
, _("Options:"));
3747 _cupsLangPuts(stdout
, "");
3748 _cupsLangPuts(stdout
, _(" -I {filename,filters,none,profiles}"));
3749 _cupsLangPuts(stdout
, _(" Ignore specific warnings."));
3750 _cupsLangPuts(stdout
, _(" -R root-directory Set alternate root."));
3751 _cupsLangPuts(stdout
, _(" -W {all,none,constraints,defaults,duplex,"
3752 "filters,profiles,sizes,translations}"));
3753 _cupsLangPuts(stdout
, _(" Issue warnings instead of "
3755 _cupsLangPuts(stdout
, _(" -q Run silently."));
3756 _cupsLangPuts(stdout
, _(" -r Use 'relaxed' open mode."));
3757 _cupsLangPuts(stdout
, _(" -v Be slightly verbose."));
3758 _cupsLangPuts(stdout
, _(" -vv Be very verbose."));
3765 * 'valid_path()' - Check whether a path has the correct capitalization.
3768 static int /* O - Errors found */
3769 valid_path(const char *keyword
, /* I - Keyword using path */
3770 const char *path
, /* I - Path to check */
3771 int errors
, /* I - Errors found */
3772 int verbose
, /* I - Verbosity level */
3773 int warn
) /* I - Warnings only? */
3775 cups_dir_t
*dir
; /* Current directory */
3776 cups_dentry_t
*dentry
; /* Current directory entry */
3777 char temp
[1024], /* Temporary path */
3778 *ptr
; /* Pointer into temporary path */
3779 const char *prefix
; /* WARN/FAIL prefix */
3782 prefix
= warn
? " WARN " : "**FAIL**";
3785 * Loop over the components of the path, checking that the entry exists with
3786 * the same capitalization...
3789 strlcpy(temp
, path
, sizeof(temp
));
3791 while ((ptr
= strrchr(temp
, '/')) != NULL
)
3794 * Chop off the trailing component so temp == dirname and ptr == basename.
3800 * Try opening the directory containing the base name...
3804 dir
= cupsDirOpen(temp
);
3806 dir
= cupsDirOpen("/");
3812 while ((dentry
= cupsDirRead(dir
)) != NULL
)
3814 if (!strcmp(dentry
->filename
, ptr
))
3822 * Display an error if the filename doesn't exist with the same
3828 if (!warn
&& !errors
&& !verbose
)
3829 _cupsLangPuts(stdout
, _(" FAIL"));
3832 _cupsLangPrintf(stdout
,
3833 _(" %s %s file \"%s\" has the wrong "
3834 "capitalization."), prefix
, keyword
, path
);
3848 * 'valid_utf8()' - Check whether a string contains valid UTF-8 text.
3851 static int /* O - 1 if valid, 0 if not */
3852 valid_utf8(const char *s
) /* I - String to check */
3859 * Check for valid UTF-8 sequence...
3862 if ((*s
& 0xc0) == 0x80)
3863 return (0); /* Illegal suffix byte */
3864 else if ((*s
& 0xe0) == 0xc0)
3867 * 2-byte sequence...
3872 if ((*s
& 0xc0) != 0x80)
3873 return (0); /* Missing suffix byte */
3875 else if ((*s
& 0xf0) == 0xe0)
3878 * 3-byte sequence...
3883 if ((*s
& 0xc0) != 0x80)
3884 return (0); /* Missing suffix byte */
3888 if ((*s
& 0xc0) != 0x80)
3889 return (0); /* Missing suffix byte */
3891 else if ((*s
& 0xf8) == 0xf0)
3894 * 4-byte sequence...
3899 if ((*s
& 0xc0) != 0x80)
3900 return (0); /* Missing suffix byte */
3904 if ((*s
& 0xc0) != 0x80)
3905 return (0); /* Missing suffix byte */
3909 if ((*s
& 0xc0) != 0x80)
3910 return (0); /* Missing suffix byte */
3913 return (0); /* Bad sequence */
3924 * End of "$Id: cupstestppd.c 7807 2008-07-28 21:54:24Z mike $".