2 * "$Id: cupstestppd.c 7807 2008-07-28 21:54:24Z mike $"
4 * PPD test program for CUPS.
6 * Copyright 2007-2012 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 cups_file_t
*fp
; /* PPD file */
151 int files
; /* Number of files */
152 int verbose
; /* Want verbose output? */
153 int warn
; /* Which errors to just warn about */
154 int ignore
; /* Which errors to ignore */
155 int status
; /* Exit status */
156 int errors
; /* Number of conformance errors */
157 int ppdversion
; /* PPD spec version in PPD file */
158 ppd_status_t error
; /* Status of ppdOpen*() */
159 int line
; /* Line number for error */
160 char *root
; /* Root directory */
161 int xdpi
, /* X resolution */
162 ydpi
; /* Y resolution */
163 ppd_file_t
*ppd
; /* PPD file record */
164 ppd_attr_t
*attr
; /* PPD attribute */
165 ppd_size_t
*size
; /* Size record */
166 ppd_group_t
*group
; /* UI group */
167 ppd_option_t
*option
; /* Standard UI option */
168 ppd_group_t
*group2
; /* UI group */
169 ppd_option_t
*option2
; /* Standard UI option */
170 ppd_choice_t
*choice
; /* Standard UI option choice */
171 struct lconv
*loc
; /* Locale data */
172 static char *uis
[] = { "BOOLEAN", "PICKONE", "PICKMANY" };
173 static char *sections
[] = { "ANY", "DOCUMENT", "EXIT",
174 "JCL", "PAGE", "PROLOG" };
177 _cupsSetLocale(argv
);
181 * Display PPD files for each file listed on the command-line...
184 ppdSetConformance(PPD_CONFORM_STRICT
);
194 for (i
= 1; i
< argc
; i
++)
195 if (argv
[i
][0] == '-' && argv
[i
][1])
197 for (opt
= argv
[i
] + 1; *opt
; opt
++)
200 case 'I' : /* Ignore errors */
206 if (!strcmp(argv
[i
], "none"))
208 else if (!strcmp(argv
[i
], "filename"))
209 ignore
|= WARN_FILENAME
;
210 else if (!strcmp(argv
[i
], "filters"))
211 ignore
|= WARN_FILTERS
;
212 else if (!strcmp(argv
[i
], "profiles"))
213 ignore
|= WARN_PROFILES
;
214 else if (!strcmp(argv
[i
], "all"))
215 ignore
= WARN_FILTERS
| WARN_PROFILES
;
220 case 'R' : /* Alternate root directory */
229 case 'W' : /* Turn errors into warnings */
235 if (!strcmp(argv
[i
], "none"))
237 else if (!strcmp(argv
[i
], "constraints"))
238 warn
|= WARN_CONSTRAINTS
;
239 else if (!strcmp(argv
[i
], "defaults"))
240 warn
|= WARN_DEFAULTS
;
241 else if (!strcmp(argv
[i
], "duplex"))
243 else if (!strcmp(argv
[i
], "filters"))
244 warn
|= WARN_FILTERS
;
245 else if (!strcmp(argv
[i
], "profiles"))
246 warn
|= WARN_PROFILES
;
247 else if (!strcmp(argv
[i
], "sizes"))
249 else if (!strcmp(argv
[i
], "translations"))
250 warn
|= WARN_TRANSLATIONS
;
251 else if (!strcmp(argv
[i
], "all"))
257 case 'q' : /* Quiet mode */
260 _cupsLangPuts(stderr
,
261 _("cupstestppd: The -q option is incompatible "
262 "with the -v option."));
269 case 'r' : /* Relaxed mode */
270 ppdSetConformance(PPD_CONFORM_RELAXED
);
273 case 'v' : /* Verbose mode */
276 _cupsLangPuts(stderr
,
277 _("cupstestppd: The -v option is incompatible "
278 "with the -q option."));
293 * Open the PPD file...
296 if (files
&& verbose
>= 0)
301 if (argv
[i
][0] == '-')
307 ppd
= _ppdOpen(cupsFileStdin(), _PPD_LOCALIZATION_ALL
);
310 printf("%s:", (ppd
&& ppd
->pcfilename
) ? ppd
->pcfilename
: "(stdin)");
315 * Read from a file...
319 printf("%s:", argv
[i
]);
321 if ((fp
= cupsFileOpen(argv
[i
], "r")) != NULL
)
323 ppd
= _ppdOpen(fp
, _PPD_LOCALIZATION_ALL
);
328 status
= ERROR_FILE_OPEN
;
332 _cupsLangPuts(stdout
, _(" FAIL"));
333 _cupsLangPrintf(stdout
,
334 _(" **FAIL** Unable to open PPD file - %s"),
343 error
= ppdLastError(&line
);
345 if (error
<= PPD_ALLOC_ERROR
)
347 status
= ERROR_FILE_OPEN
;
351 _cupsLangPuts(stdout
, _(" FAIL"));
352 _cupsLangPrintf(stdout
,
353 _(" **FAIL** Unable to open PPD file - %s"),
359 status
= ERROR_PPD_FORMAT
;
363 _cupsLangPuts(stdout
, _(" FAIL"));
364 _cupsLangPrintf(stdout
,
365 _(" **FAIL** Unable to open PPD file - "
367 ppdErrorString(error
), line
);
371 case PPD_MISSING_PPDADOBE4
:
372 _cupsLangPuts(stdout
,
373 _(" REF: Page 42, section "
376 case PPD_MISSING_VALUE
:
377 _cupsLangPuts(stdout
,
378 _(" REF: Page 20, section "
381 case PPD_BAD_OPEN_GROUP
:
382 case PPD_NESTED_OPEN_GROUP
:
383 _cupsLangPuts(stdout
,
384 _(" REF: Pages 45-46, section "
387 case PPD_BAD_OPEN_UI
:
388 case PPD_NESTED_OPEN_UI
:
389 _cupsLangPuts(stdout
,
390 _(" REF: Pages 42-45, section "
393 case PPD_BAD_ORDER_DEPENDENCY
:
394 _cupsLangPuts(stdout
,
395 _(" REF: Pages 48-49, section "
398 case PPD_BAD_UI_CONSTRAINTS
:
399 _cupsLangPuts(stdout
,
400 _(" REF: Pages 52-54, section "
403 case PPD_MISSING_ASTERISK
:
404 _cupsLangPuts(stdout
,
405 _(" REF: Page 15, section "
408 case PPD_LINE_TOO_LONG
:
409 _cupsLangPuts(stdout
,
410 _(" REF: Page 15, section "
413 case PPD_ILLEGAL_CHARACTER
:
414 _cupsLangPuts(stdout
,
415 _(" REF: Page 15, section "
418 case PPD_ILLEGAL_MAIN_KEYWORD
:
419 _cupsLangPuts(stdout
,
420 _(" REF: Pages 16-17, section "
423 case PPD_ILLEGAL_OPTION_KEYWORD
:
424 _cupsLangPuts(stdout
,
425 _(" REF: Page 19, section "
428 case PPD_ILLEGAL_TRANSLATION
:
429 _cupsLangPuts(stdout
,
430 _(" REF: Page 27, section "
437 check_basics(argv
[i
]);
445 * Show the header and then perform basic conformance tests (limited
446 * only by what the CUPS PPD functions actually load...)
453 _cupsLangPuts(stdout
,
454 _("\n DETAILED CONFORMANCE TEST RESULTS"));
456 if ((attr
= ppdFindAttr(ppd
, "FormatVersion", NULL
)) != NULL
&&
458 ppdversion
= (int)(10 * _cupsStrScand(attr
->value
, NULL
, loc
) + 0.5);
460 if ((attr
= ppdFindAttr(ppd
, "cupsFilter2", NULL
)) != NULL
)
464 if (strstr(attr
->value
, "application/vnd.cups-raster"))
466 if (!test_raster(ppd
, verbose
))
471 while ((attr
= ppdFindNextAttr(ppd
, "cupsFilter2", NULL
)) != NULL
);
475 for (j
= 0; j
< ppd
->num_filters
; j
++)
476 if (strstr(ppd
->filters
[j
], "application/vnd.cups-raster"))
478 if (!test_raster(ppd
, verbose
))
485 * Look for default keywords with no matching option...
488 if (!(warn
& WARN_DEFAULTS
))
489 errors
= check_defaults(ppd
, errors
, verbose
, 0);
491 if ((attr
= ppdFindAttr(ppd
, "DefaultImageableArea", NULL
)) == NULL
)
495 if (!errors
&& !verbose
)
496 _cupsLangPuts(stdout
, _(" FAIL"));
498 _cupsLangPuts(stdout
,
499 _(" **FAIL** REQUIRED DefaultImageableArea\n"
500 " REF: Page 102, section 5.15."));
505 else if (ppdPageSize(ppd
, attr
->value
) == NULL
&&
506 strcmp(attr
->value
, "Unknown"))
510 if (!errors
&& !verbose
)
511 _cupsLangPuts(stdout
, _(" FAIL"));
513 _cupsLangPrintf(stdout
,
514 _(" **FAIL** BAD DefaultImageableArea %s\n"
515 " REF: Page 102, section 5.15."),
524 _cupsLangPuts(stdout
, _(" PASS DefaultImageableArea"));
527 if ((attr
= ppdFindAttr(ppd
, "DefaultPaperDimension", NULL
)) == NULL
)
531 if (!errors
&& !verbose
)
532 _cupsLangPuts(stdout
, _(" FAIL"));
534 _cupsLangPuts(stdout
,
535 _(" **FAIL** REQUIRED DefaultPaperDimension\n"
536 " REF: Page 103, section 5.15."));
541 else if (ppdPageSize(ppd
, attr
->value
) == NULL
&&
542 strcmp(attr
->value
, "Unknown"))
546 if (!errors
&& !verbose
)
547 _cupsLangPuts(stdout
, _(" FAIL"));
549 _cupsLangPrintf(stdout
,
550 _(" **FAIL** BAD DefaultPaperDimension %s\n"
551 " REF: Page 103, section 5.15."),
557 else if (verbose
> 0)
558 _cupsLangPuts(stdout
, _(" PASS DefaultPaperDimension"));
560 for (j
= 0, group
= ppd
->groups
; j
< ppd
->num_groups
; j
++, group
++)
561 for (k
= 0, option
= group
->options
;
562 k
< group
->num_options
;
566 * Verify that we have a default choice...
569 if (option
->defchoice
[0])
571 if (ppdFindChoice(option
, option
->defchoice
) == NULL
&&
572 strcmp(option
->defchoice
, "Unknown"))
576 if (!errors
&& !verbose
)
577 _cupsLangPuts(stdout
, _(" FAIL"));
579 _cupsLangPrintf(stdout
,
580 _(" **FAIL** BAD Default%s %s\n"
581 " REF: Page 40, section 4.5."),
582 option
->keyword
, option
->defchoice
);
587 else if (verbose
> 0)
588 _cupsLangPrintf(stdout
,
589 _(" PASS Default%s"),
596 if (!errors
&& !verbose
)
597 _cupsLangPuts(stdout
, _(" FAIL"));
599 _cupsLangPrintf(stdout
,
600 _(" **FAIL** REQUIRED Default%s\n"
601 " REF: Page 40, section 4.5."),
609 if ((attr
= ppdFindAttr(ppd
, "FileVersion", NULL
)) != NULL
)
611 for (ptr
= attr
->value
; *ptr
; ptr
++)
612 if (!isdigit(*ptr
& 255) && *ptr
!= '.')
619 if (!errors
&& !verbose
)
620 _cupsLangPuts(stdout
, _(" FAIL"));
622 _cupsLangPrintf(stdout
,
623 _(" **FAIL** Bad FileVersion \"%s\"\n"
624 " REF: Page 56, section 5.3."),
630 else if (verbose
> 0)
631 _cupsLangPuts(stdout
, _(" PASS FileVersion"));
637 if (!errors
&& !verbose
)
638 _cupsLangPuts(stdout
, _(" FAIL"));
640 _cupsLangPuts(stdout
,
641 _(" **FAIL** REQUIRED FileVersion\n"
642 " REF: Page 56, section 5.3."));
648 if ((attr
= ppdFindAttr(ppd
, "FormatVersion", NULL
)) != NULL
)
651 if (*ptr
== '4' && ptr
[1] == '.')
654 for (ptr
+= 2; *ptr
; ptr
++)
655 if (!isdigit(*ptr
& 255))
663 if (!errors
&& !verbose
)
664 _cupsLangPuts(stdout
, _(" FAIL"));
666 _cupsLangPrintf(stdout
,
667 _(" **FAIL** Bad FormatVersion \"%s\"\n"
668 " REF: Page 56, section 5.3."),
674 else if (verbose
> 0)
675 _cupsLangPuts(stdout
, _(" PASS FormatVersion"));
681 if (!errors
&& !verbose
)
682 _cupsLangPuts(stdout
, _(" FAIL"));
684 _cupsLangPuts(stdout
,
685 _(" **FAIL** REQUIRED FormatVersion\n"
686 " REF: Page 56, section 5.3."));
692 if (ppd
->lang_encoding
!= NULL
)
695 _cupsLangPuts(stdout
, _(" PASS LanguageEncoding"));
697 else if (ppdversion
> 40)
701 if (!errors
&& !verbose
)
702 _cupsLangPuts(stdout
, _(" FAIL"));
704 _cupsLangPuts(stdout
,
705 _(" **FAIL** REQUIRED LanguageEncoding\n"
706 " REF: Pages 56-57, section 5.3."));
712 if (ppd
->lang_version
!= NULL
)
715 _cupsLangPuts(stdout
, _(" PASS LanguageVersion"));
721 if (!errors
&& !verbose
)
722 _cupsLangPuts(stdout
, _(" FAIL"));
724 _cupsLangPuts(stdout
,
725 _(" **FAIL** REQUIRED LanguageVersion\n"
726 " REF: Pages 57-58, section 5.3."));
732 if (ppd
->manufacturer
!= NULL
)
734 if (!_cups_strncasecmp(ppd
->manufacturer
, "Hewlett-Packard", 15) ||
735 !_cups_strncasecmp(ppd
->manufacturer
, "Hewlett Packard", 15))
739 if (!errors
&& !verbose
)
740 _cupsLangPuts(stdout
, _(" FAIL"));
742 _cupsLangPuts(stdout
,
743 _(" **FAIL** BAD Manufacturer (should be "
745 " REF: Page 211, table D.1."));
750 else if (!_cups_strncasecmp(ppd
->manufacturer
, "OkiData", 7) ||
751 !_cups_strncasecmp(ppd
->manufacturer
, "Oki Data", 8))
755 if (!errors
&& !verbose
)
756 _cupsLangPuts(stdout
, _(" FAIL"));
758 _cupsLangPuts(stdout
,
759 _(" **FAIL** BAD Manufacturer (should be "
761 " REF: Page 211, table D.1."));
766 else if (verbose
> 0)
767 _cupsLangPuts(stdout
, _(" PASS Manufacturer"));
769 else if (ppdversion
>= 43)
773 if (!errors
&& !verbose
)
774 _cupsLangPuts(stdout
, _(" FAIL"));
776 _cupsLangPuts(stdout
,
777 _(" **FAIL** REQUIRED Manufacturer\n"
778 " REF: Pages 58-59, section 5.3."));
784 if (ppd
->modelname
!= NULL
)
786 for (ptr
= ppd
->modelname
; *ptr
; ptr
++)
787 if (!isalnum(*ptr
& 255) && !strchr(" ./-+", *ptr
))
794 if (!errors
&& !verbose
)
795 _cupsLangPuts(stdout
, _(" FAIL"));
797 _cupsLangPrintf(stdout
,
798 _(" **FAIL** BAD ModelName - \"%c\" not "
799 "allowed in string.\n"
800 " REF: Pages 59-60, section 5.3."),
806 else if (verbose
> 0)
807 _cupsLangPuts(stdout
, _(" PASS ModelName"));
813 if (!errors
&& !verbose
)
814 _cupsLangPuts(stdout
, _(" FAIL"));
816 _cupsLangPuts(stdout
,
817 _(" **FAIL** REQUIRED ModelName\n"
818 " REF: Pages 59-60, section 5.3."));
824 if (ppd
->nickname
!= NULL
)
827 _cupsLangPuts(stdout
, _(" PASS NickName"));
833 if (!errors
&& !verbose
)
834 _cupsLangPuts(stdout
, _(" FAIL"));
836 _cupsLangPuts(stdout
,
837 _(" **FAIL** REQUIRED NickName\n"
838 " REF: Page 60, section 5.3."));
844 if (ppdFindOption(ppd
, "PageSize") != NULL
)
847 _cupsLangPuts(stdout
, _(" PASS PageSize"));
853 if (!errors
&& !verbose
)
854 _cupsLangPuts(stdout
, _(" FAIL"));
856 _cupsLangPuts(stdout
,
857 _(" **FAIL** REQUIRED PageSize\n"
858 " REF: Pages 99-100, section 5.14."));
864 if (ppdFindOption(ppd
, "PageRegion") != NULL
)
867 _cupsLangPuts(stdout
, _(" PASS PageRegion"));
873 if (!errors
&& !verbose
)
874 _cupsLangPuts(stdout
, _(" FAIL"));
876 _cupsLangPuts(stdout
,
877 _(" **FAIL** REQUIRED PageRegion\n"
878 " REF: Page 100, section 5.14."));
884 if (ppd
->pcfilename
!= NULL
)
887 _cupsLangPuts(stdout
, _(" PASS PCFileName"));
889 else if (!(ignore
& WARN_FILENAME
))
893 if (!errors
&& !verbose
)
894 _cupsLangPuts(stdout
, _(" FAIL"));
896 _cupsLangPuts(stdout
,
897 _(" **FAIL** REQUIRED PCFileName\n"
898 " REF: Pages 61-62, section 5.3."));
904 if (ppd
->product
!= NULL
)
906 if (ppd
->product
[0] != '(' ||
907 ppd
->product
[strlen(ppd
->product
) - 1] != ')')
911 if (!errors
&& !verbose
)
912 _cupsLangPuts(stdout
, _(" FAIL"));
914 _cupsLangPuts(stdout
,
915 _(" **FAIL** BAD Product - not \"(string)\".\n"
916 " REF: Page 62, section 5.3."));
921 else if (verbose
> 0)
922 _cupsLangPuts(stdout
, _(" PASS Product"));
928 if (!errors
&& !verbose
)
929 _cupsLangPuts(stdout
, _(" FAIL"));
931 _cupsLangPuts(stdout
,
932 _(" **FAIL** REQUIRED Product\n"
933 " REF: Page 62, section 5.3."));
939 if ((attr
= ppdFindAttr(ppd
, "PSVersion", NULL
)) != NULL
&&
942 char junkstr
[255]; /* Temp string */
943 int junkint
; /* Temp integer */
946 if (sscanf(attr
->value
, "(%[^)])%d", junkstr
, &junkint
) != 2)
950 if (!errors
&& !verbose
)
951 _cupsLangPuts(stdout
, _(" FAIL"));
953 _cupsLangPuts(stdout
,
954 _(" **FAIL** BAD PSVersion - not \"(string) "
956 " REF: Pages 62-64, section 5.3."));
961 else if (verbose
> 0)
962 _cupsLangPuts(stdout
, _(" PASS PSVersion"));
968 if (!errors
&& !verbose
)
969 _cupsLangPuts(stdout
, _(" FAIL"));
971 _cupsLangPuts(stdout
,
972 _(" **FAIL** REQUIRED PSVersion\n"
973 " REF: Pages 62-64, section 5.3."));
979 if (ppd
->shortnickname
!= NULL
)
981 if (strlen(ppd
->shortnickname
) > 31)
985 if (!errors
&& !verbose
)
986 _cupsLangPuts(stdout
, _(" FAIL"));
988 _cupsLangPuts(stdout
,
989 _(" **FAIL** BAD ShortNickName - longer "
991 " REF: Pages 64-65, section 5.3."));
996 else if (verbose
> 0)
997 _cupsLangPuts(stdout
, _(" PASS ShortNickName"));
999 else if (ppdversion
>= 43)
1003 if (!errors
&& !verbose
)
1004 _cupsLangPuts(stdout
, _(" FAIL"));
1006 _cupsLangPuts(stdout
,
1007 _(" **FAIL** REQUIRED ShortNickName\n"
1008 " REF: Page 64-65, section 5.3."));
1014 if (ppd
->patches
!= NULL
&& strchr(ppd
->patches
, '\"') &&
1015 strstr(ppd
->patches
, "*End"))
1019 if (!errors
&& !verbose
)
1020 _cupsLangPuts(stdout
, _(" FAIL"));
1022 _cupsLangPuts(stdout
,
1023 _(" **FAIL** BAD JobPatchFile attribute in file\n"
1024 " REF: Page 24, section 3.4."));
1031 * Check for page sizes without the corresponding ImageableArea or
1032 * PaperDimension values...
1035 if (ppd
->num_sizes
== 0)
1039 if (!errors
&& !verbose
)
1040 _cupsLangPuts(stdout
, _(" FAIL"));
1042 _cupsLangPuts(stdout
,
1043 _(" **FAIL** REQUIRED PageSize\n"
1044 " REF: Page 41, section 5.\n"
1045 " REF: Page 99, section 5.14."));
1052 for (j
= 0, size
= ppd
->sizes
; j
< ppd
->num_sizes
; j
++, size
++)
1055 * Don't check custom size...
1058 if (!strcmp(size
->name
, "Custom"))
1062 * Check for ImageableArea...
1065 if (size
->left
== 0.0 && size
->bottom
== 0.0 &&
1066 size
->right
== 0.0 && size
->top
== 0.0)
1070 if (!errors
&& !verbose
)
1071 _cupsLangPuts(stdout
, _(" FAIL"));
1073 _cupsLangPrintf(stdout
,
1074 _(" **FAIL** REQUIRED ImageableArea for "
1076 " REF: Page 41, section 5.\n"
1077 " REF: Page 102, section 5.15."),
1085 * Check for PaperDimension...
1088 if (size
->width
<= 0.0 && size
->length
<= 0.0)
1092 if (!errors
&& !verbose
)
1093 _cupsLangPuts(stdout
, _(" FAIL"));
1095 _cupsLangPrintf(stdout
,
1096 _(" **FAIL** REQUIRED PaperDimension "
1098 " REF: Page 41, section 5.\n"
1099 " REF: Page 103, section 5.15."),
1109 * Check for valid Resolution, JCLResolution, or SetResolution values...
1112 if ((option
= ppdFindOption(ppd
, "Resolution")) == NULL
)
1113 if ((option
= ppdFindOption(ppd
, "JCLResolution")) == NULL
)
1114 option
= ppdFindOption(ppd
, "SetResolution");
1118 for (j
= option
->num_choices
, choice
= option
->choices
;
1123 * Verify that all resolution options are of the form NNNdpi
1127 xdpi
= strtol(choice
->choice
, (char **)&ptr
, 10);
1128 if (ptr
> choice
->choice
&& xdpi
> 0)
1131 ydpi
= strtol(ptr
+ 1, (char **)&ptr
, 10);
1138 if (xdpi
<= 0 || xdpi
> 99999 || ydpi
<= 0 || ydpi
> 99999 ||
1143 if (!errors
&& !verbose
)
1144 _cupsLangPuts(stdout
, _(" FAIL"));
1146 _cupsLangPrintf(stdout
,
1147 _(" **FAIL** Bad %s choice %s\n"
1148 " REF: Page 84, section 5.9"),
1149 option
->keyword
, choice
->choice
);
1157 if ((attr
= ppdFindAttr(ppd
, "1284DeviceID", NULL
)) &&
1158 strcmp(attr
->name
, "1284DeviceID"))
1162 if (!errors
&& !verbose
)
1163 _cupsLangPuts(stdout
, _(" FAIL"));
1165 _cupsLangPrintf(stdout
,
1166 _(" **FAIL** %s must be 1284DeviceID\n"
1167 " REF: Page 72, section 5.5"),
1174 errors
= check_case(ppd
, errors
, verbose
);
1176 if (!(warn
& WARN_CONSTRAINTS
))
1177 errors
= check_constraints(ppd
, errors
, verbose
, 0);
1179 if (!(warn
& WARN_FILTERS
) && !(ignore
& WARN_FILTERS
))
1180 errors
= check_filters(ppd
, root
, errors
, verbose
, 0);
1182 if (!(warn
& WARN_PROFILES
) && !(ignore
& WARN_PROFILES
))
1183 errors
= check_profiles(ppd
, root
, errors
, verbose
, 0);
1185 if (!(warn
& WARN_SIZES
))
1186 errors
= check_sizes(ppd
, errors
, verbose
, 0);
1188 if (!(warn
& WARN_TRANSLATIONS
))
1189 errors
= check_translations(ppd
, errors
, verbose
, 0);
1191 if (!(warn
& WARN_DUPLEX
))
1192 errors
= check_duplex(ppd
, errors
, verbose
, 0);
1194 if ((attr
= ppdFindAttr(ppd
, "cupsLanguages", NULL
)) != NULL
&&
1198 * This file contains localizations, check for conformance of the
1199 * base translation...
1202 if ((attr
= ppdFindAttr(ppd
, "LanguageEncoding", NULL
)) != NULL
)
1204 if (!attr
->value
|| strcmp(attr
->value
, "ISOLatin1"))
1206 if (!errors
&& !verbose
)
1207 _cupsLangPuts(stdout
, _(" FAIL"));
1210 _cupsLangPrintf(stdout
,
1211 _(" **FAIL** Bad LanguageEncoding %s - "
1212 "must be ISOLatin1."),
1213 attr
->value
? attr
->value
: "(null)");
1218 if (!ppd
->lang_version
|| strcmp(ppd
->lang_version
, "English"))
1220 if (!errors
&& !verbose
)
1221 _cupsLangPuts(stdout
, _(" FAIL"));
1224 _cupsLangPrintf(stdout
,
1225 _(" **FAIL** Bad LanguageVersion %s - "
1226 "must be English."),
1227 ppd
->lang_version
? ppd
->lang_version
: "(null)");
1233 * Loop through all options and choices...
1236 for (option
= ppdFirstOption(ppd
);
1238 option
= ppdNextOption(ppd
))
1241 * Check for special characters outside A0 to BF, F7, or F8
1242 * that are used for languages other than English.
1245 for (ptr
= option
->text
; *ptr
; ptr
++)
1246 if ((*ptr
& 0x80) && (*ptr
& 0xe0) != 0xa0 &&
1247 (*ptr
& 0xff) != 0xf7 && (*ptr
& 0xff) != 0xf8)
1252 if (!errors
&& !verbose
)
1253 _cupsLangPuts(stdout
, _(" FAIL"));
1256 _cupsLangPrintf(stdout
,
1257 _(" **FAIL** Default translation "
1258 "string for option %s contains 8-bit "
1265 for (j
= 0; j
< option
->num_choices
; j
++)
1268 * Check for special characters outside A0 to BF, F7, or F8
1269 * that are used for languages other than English.
1272 for (ptr
= option
->choices
[j
].text
; *ptr
; ptr
++)
1273 if ((*ptr
& 0x80) && (*ptr
& 0xe0) != 0xa0 &&
1274 (*ptr
& 0xff) != 0xf7 && (*ptr
& 0xff) != 0xf8)
1279 if (!errors
&& !verbose
)
1280 _cupsLangPuts(stdout
, _(" FAIL"));
1283 _cupsLangPrintf(stdout
,
1284 _(" **FAIL** Default translation "
1285 "string for option %s choice %s contains "
1286 "8-bit characters."),
1288 option
->choices
[j
].choice
);
1298 * Final pass/fail notification...
1302 status
= ERROR_CONFORMANCE
;
1304 _cupsLangPuts(stdout
, _(" PASS"));
1308 check_basics(argv
[i
]);
1310 if (warn
& WARN_DEFAULTS
)
1311 errors
= check_defaults(ppd
, errors
, verbose
, 1);
1313 if (warn
& WARN_CONSTRAINTS
)
1314 errors
= check_constraints(ppd
, errors
, verbose
, 1);
1316 if ((warn
& WARN_FILTERS
) && !(ignore
& WARN_FILTERS
))
1317 errors
= check_filters(ppd
, root
, errors
, verbose
, 1);
1319 if ((warn
& WARN_PROFILES
) && !(ignore
& WARN_PROFILES
))
1320 errors
= check_profiles(ppd
, root
, errors
, verbose
, 1);
1322 if (warn
& WARN_SIZES
)
1323 errors
= check_sizes(ppd
, errors
, verbose
, 1);
1325 errors
= check_sizes(ppd
, errors
, verbose
, 2);
1327 if (warn
& WARN_TRANSLATIONS
)
1328 errors
= check_translations(ppd
, errors
, verbose
, 1);
1330 if (warn
& WARN_DUPLEX
)
1331 errors
= check_duplex(ppd
, errors
, verbose
, 1);
1334 * Look for legacy duplex keywords...
1337 if ((option
= ppdFindOption(ppd
, "JCLDuplex")) == NULL
)
1338 if ((option
= ppdFindOption(ppd
, "EFDuplex")) == NULL
)
1339 option
= ppdFindOption(ppd
, "KD03Duplex");
1342 _cupsLangPrintf(stdout
,
1343 _(" WARN Duplex option keyword %s may not "
1344 "work as expected and should be named Duplex.\n"
1345 " REF: Page 122, section 5.17"),
1349 * Look for default keywords with no corresponding option...
1352 for (j
= 0; j
< ppd
->num_attrs
; j
++)
1354 attr
= ppd
->attrs
[j
];
1356 if (!strcmp(attr
->name
, "DefaultColorSpace") ||
1357 !strcmp(attr
->name
, "DefaultColorSep") ||
1358 !strcmp(attr
->name
, "DefaultFont") ||
1359 !strcmp(attr
->name
, "DefaultHalftoneType") ||
1360 !strcmp(attr
->name
, "DefaultImageableArea") ||
1361 !strcmp(attr
->name
, "DefaultLeadingEdge") ||
1362 !strcmp(attr
->name
, "DefaultOutputOrder") ||
1363 !strcmp(attr
->name
, "DefaultPaperDimension") ||
1364 !strcmp(attr
->name
, "DefaultResolution") ||
1365 !strcmp(attr
->name
, "DefaultScreenProc") ||
1366 !strcmp(attr
->name
, "DefaultTransfer"))
1369 if (!strncmp(attr
->name
, "Default", 7) &&
1370 !ppdFindOption(ppd
, attr
->name
+ 7))
1371 _cupsLangPrintf(stdout
,
1372 _(" WARN %s has no corresponding "
1377 if (ppdversion
< 43)
1379 _cupsLangPrintf(stdout
,
1380 _(" WARN Obsolete PPD version %.1f.\n"
1381 " REF: Page 42, section 5.2."),
1385 if (!ppd
->lang_encoding
&& ppdversion
< 41)
1387 _cupsLangPuts(stdout
,
1388 _(" WARN LanguageEncoding required by PPD "
1390 " REF: Pages 56-57, section 5.3."));
1393 if (!ppd
->manufacturer
&& ppdversion
< 43)
1395 _cupsLangPuts(stdout
,
1396 _(" WARN Manufacturer required by PPD "
1398 " REF: Pages 58-59, section 5.3."));
1402 * Treat a PCFileName attribute longer than 12 characters as
1403 * a warning and not a hard error...
1406 if (!(ignore
& WARN_FILENAME
) && ppd
->pcfilename
)
1408 if (strlen(ppd
->pcfilename
) > 12)
1410 _cupsLangPuts(stdout
,
1411 _(" WARN PCFileName longer than 8.3 in "
1412 "violation of PPD spec.\n"
1413 " REF: Pages 61-62, section "
1417 if (!_cups_strcasecmp(ppd
->pcfilename
, "unused.ppd"))
1418 _cupsLangPuts(stdout
,
1419 _(" WARN PCFileName should contain a "
1420 "unique filename.\n"
1421 " REF: Pages 61-62, section "
1425 if (!ppd
->shortnickname
&& ppdversion
< 43)
1427 _cupsLangPuts(stdout
,
1428 _(" WARN ShortNickName required by PPD "
1430 " REF: Pages 64-65, section 5.3."));
1434 * Check the Protocols line and flag PJL + BCP since TBCP is
1435 * usually used with PJL...
1440 if (strstr(ppd
->protocols
, "PJL") &&
1441 strstr(ppd
->protocols
, "BCP") &&
1442 !strstr(ppd
->protocols
, "TBCP"))
1444 _cupsLangPuts(stdout
,
1445 _(" WARN Protocols contains both PJL "
1446 "and BCP; expected TBCP.\n"
1447 " REF: Pages 78-79, section 5.7."));
1450 if (strstr(ppd
->protocols
, "PJL") &&
1451 (!ppd
->jcl_begin
|| !ppd
->jcl_end
|| !ppd
->jcl_ps
))
1453 _cupsLangPuts(stdout
,
1454 _(" WARN Protocols contains PJL but JCL "
1455 "attributes are not set.\n"
1456 " REF: Pages 78-79, section 5.7."));
1461 * Check for options with a common prefix, e.g. Duplex and Duplexer,
1462 * which are errors according to the spec but won't cause problems
1463 * with CUPS specifically...
1466 for (j
= 0, group
= ppd
->groups
; j
< ppd
->num_groups
; j
++, group
++)
1467 for (k
= 0, option
= group
->options
;
1468 k
< group
->num_options
;
1471 len
= (int)strlen(option
->keyword
);
1473 for (m
= 0, group2
= ppd
->groups
;
1474 m
< ppd
->num_groups
;
1476 for (n
= 0, option2
= group2
->options
;
1477 n
< group2
->num_options
;
1479 if (option
!= option2
&&
1480 len
< (int)strlen(option2
->keyword
) &&
1481 !strncmp(option
->keyword
, option2
->keyword
, len
))
1483 _cupsLangPrintf(stdout
,
1484 _(" WARN %s shares a common "
1486 " REF: Page 15, section "
1488 option
->keyword
, option2
->keyword
);
1496 _cupsLangPrintf(stdout
, _(" %d ERRORS FOUND"), errors
);
1498 _cupsLangPuts(stdout
, _(" NO ERRORS FOUND"));
1502 * Then list the options, if "-v" was provided...
1507 _cupsLangPrintf(stdout
,
1509 " language_level = %d\n"
1510 " color_device = %s\n"
1511 " variable_sizes = %s\n"
1513 ppd
->language_level
,
1514 ppd
->color_device
? "TRUE" : "FALSE",
1515 ppd
->variable_sizes
? "TRUE" : "FALSE",
1518 switch (ppd
->colorspace
)
1521 _cupsLangPuts(stdout
, " colorspace = PPD_CS_CMYK");
1524 _cupsLangPuts(stdout
, " colorspace = PPD_CS_CMY");
1527 _cupsLangPuts(stdout
, " colorspace = PPD_CS_GRAY");
1530 _cupsLangPuts(stdout
, " colorspace = PPD_CS_RGB");
1533 _cupsLangPuts(stdout
, " colorspace = <unknown>");
1537 _cupsLangPrintf(stdout
, " num_emulations = %d",
1538 ppd
->num_emulations
);
1539 for (j
= 0; j
< ppd
->num_emulations
; j
++)
1540 _cupsLangPrintf(stdout
, " emulations[%d] = %s",
1541 j
, ppd
->emulations
[j
].name
);
1543 _cupsLangPrintf(stdout
, " lang_encoding = %s",
1544 ppd
->lang_encoding
);
1545 _cupsLangPrintf(stdout
, " lang_version = %s",
1547 _cupsLangPrintf(stdout
, " modelname = %s", ppd
->modelname
);
1548 _cupsLangPrintf(stdout
, " ttrasterizer = %s",
1549 ppd
->ttrasterizer
== NULL
? "None" : ppd
->ttrasterizer
);
1550 _cupsLangPrintf(stdout
, " manufacturer = %s",
1552 _cupsLangPrintf(stdout
, " product = %s", ppd
->product
);
1553 _cupsLangPrintf(stdout
, " nickname = %s", ppd
->nickname
);
1554 _cupsLangPrintf(stdout
, " shortnickname = %s",
1555 ppd
->shortnickname
);
1556 _cupsLangPrintf(stdout
, " patches = %d bytes",
1557 ppd
->patches
== NULL
? 0 : (int)strlen(ppd
->patches
));
1559 _cupsLangPrintf(stdout
, " num_groups = %d", ppd
->num_groups
);
1560 for (j
= 0, group
= ppd
->groups
; j
< ppd
->num_groups
; j
++, group
++)
1562 _cupsLangPrintf(stdout
, " group[%d] = %s",
1565 for (k
= 0, option
= group
->options
; k
< group
->num_options
; k
++, option
++)
1567 _cupsLangPrintf(stdout
,
1568 " options[%d] = %s (%s) %s %s %.0f "
1570 k
, option
->keyword
, option
->text
, uis
[option
->ui
],
1571 sections
[option
->section
], option
->order
,
1572 option
->num_choices
);
1574 if (!strcmp(option
->keyword
, "PageSize") ||
1575 !strcmp(option
->keyword
, "PageRegion"))
1577 for (m
= option
->num_choices
, choice
= option
->choices
;
1581 size
= ppdPageSize(ppd
, choice
->choice
);
1584 _cupsLangPrintf(stdout
,
1585 " %s (%s) = ERROR%s",
1586 choice
->choice
, choice
->text
,
1587 !strcmp(option
->defchoice
, choice
->choice
)
1590 _cupsLangPrintf(stdout
,
1591 " %s (%s) = %.2fx%.2fin "
1592 "(%.1f,%.1f,%.1f,%.1f)%s",
1593 choice
->choice
, choice
->text
,
1594 size
->width
/ 72.0, size
->length
/ 72.0,
1595 size
->left
/ 72.0, size
->bottom
/ 72.0,
1596 size
->right
/ 72.0, size
->top
/ 72.0,
1597 !strcmp(option
->defchoice
, choice
->choice
)
1603 for (m
= option
->num_choices
, choice
= option
->choices
;
1607 _cupsLangPrintf(stdout
, " %s (%s)%s",
1608 choice
->choice
, choice
->text
,
1609 !strcmp(option
->defchoice
, choice
->choice
)
1616 _cupsLangPrintf(stdout
, " num_consts = %d",
1618 for (j
= 0; j
< ppd
->num_consts
; j
++)
1619 _cupsLangPrintf(stdout
,
1620 " consts[%d] = *%s %s *%s %s",
1621 j
, ppd
->consts
[j
].option1
, ppd
->consts
[j
].choice1
,
1622 ppd
->consts
[j
].option2
, ppd
->consts
[j
].choice2
);
1624 _cupsLangPrintf(stdout
, " num_profiles = %d",
1626 for (j
= 0; j
< ppd
->num_profiles
; j
++)
1627 _cupsLangPrintf(stdout
,
1628 " profiles[%d] = %s/%s %.3f %.3f "
1629 "[ %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f ]",
1630 j
, ppd
->profiles
[j
].resolution
,
1631 ppd
->profiles
[j
].media_type
,
1632 ppd
->profiles
[j
].gamma
, ppd
->profiles
[j
].density
,
1633 ppd
->profiles
[j
].matrix
[0][0],
1634 ppd
->profiles
[j
].matrix
[0][1],
1635 ppd
->profiles
[j
].matrix
[0][2],
1636 ppd
->profiles
[j
].matrix
[1][0],
1637 ppd
->profiles
[j
].matrix
[1][1],
1638 ppd
->profiles
[j
].matrix
[1][2],
1639 ppd
->profiles
[j
].matrix
[2][0],
1640 ppd
->profiles
[j
].matrix
[2][1],
1641 ppd
->profiles
[j
].matrix
[2][2]);
1643 _cupsLangPrintf(stdout
, " num_fonts = %d", ppd
->num_fonts
);
1644 for (j
= 0; j
< ppd
->num_fonts
; j
++)
1645 _cupsLangPrintf(stdout
, " fonts[%d] = %s",
1648 _cupsLangPrintf(stdout
, " num_attrs = %d", ppd
->num_attrs
);
1649 for (j
= 0; j
< ppd
->num_attrs
; j
++)
1650 _cupsLangPrintf(stdout
,
1651 " attrs[%d] = %s %s%s%s: \"%s\"", j
,
1652 ppd
->attrs
[j
]->name
, ppd
->attrs
[j
]->spec
,
1653 ppd
->attrs
[j
]->text
[0] ? "/" : "",
1654 ppd
->attrs
[j
]->text
,
1655 ppd
->attrs
[j
]->value
?
1656 ppd
->attrs
[j
]->value
: "(null)");
1670 * 'check_basics()' - Check for CR LF, mixed line endings, and blank lines.
1674 check_basics(const char *filename
) /* I - PPD file to check */
1676 cups_file_t
*fp
; /* File pointer */
1677 int ch
; /* Current character */
1678 int col
, /* Current column */
1679 whitespace
; /* Only seen whitespace? */
1680 int eol
; /* Line endings */
1681 int linenum
; /* Line number */
1682 int mixed
; /* Mixed line endings? */
1685 if ((fp
= cupsFileOpen(filename
, "r")) == NULL
)
1694 while ((ch
= cupsFileGetChar(fp
)) != EOF
)
1696 if (ch
== '\r' || ch
== '\n')
1700 if (eol
== EOL_NONE
)
1702 else if (eol
!= EOL_LF
)
1705 else if (ch
== '\r')
1707 if (cupsFilePeekChar(fp
) == '\n')
1709 cupsFileGetChar(fp
);
1711 if (eol
== EOL_NONE
)
1713 else if (eol
!= EOL_CRLF
)
1716 else if (eol
== EOL_NONE
)
1718 else if (eol
!= EOL_CR
)
1722 if (col
> 0 && whitespace
)
1723 _cupsLangPrintf(stdout
,
1724 _(" WARN Line %d only contains whitespace."),
1733 if (ch
!= ' ' && ch
!= '\t')
1741 _cupsLangPuts(stdout
,
1742 _(" WARN File contains a mix of CR, LF, and "
1743 "CR LF line endings."));
1745 if (eol
== EOL_CRLF
)
1746 _cupsLangPuts(stdout
,
1747 _(" WARN Non-Windows PPD files should use lines "
1748 "ending with only LF, not CR LF."));
1755 * 'check_constraints()' - Check UIConstraints in the PPD file.
1758 static int /* O - Errors found */
1759 check_constraints(ppd_file_t
*ppd
, /* I - PPD file */
1760 int errors
, /* I - Errors found */
1761 int verbose
, /* I - Verbosity level */
1762 int warn
) /* I - Warnings only? */
1764 int i
; /* Looping var */
1765 const char *prefix
; /* WARN/FAIL prefix */
1766 ppd_const_t
*c
; /* Current UIConstraints data */
1767 ppd_attr_t
*constattr
; /* Current cupsUIConstraints attribute */
1768 const char *vptr
; /* Pointer into constraint value */
1769 char option
[PPD_MAX_NAME
],
1770 /* Option name/MainKeyword */
1771 choice
[PPD_MAX_NAME
],
1772 /* Choice/OptionKeyword */
1773 *ptr
; /* Pointer into option or choice */
1774 int num_options
; /* Number of options */
1775 cups_option_t
*options
; /* Options */
1776 ppd_option_t
*o
; /* PPD option */
1779 prefix
= warn
? " WARN " : "**FAIL**";
1783 * See what kind of constraint data we have in the PPD...
1786 if ((constattr
= ppdFindAttr(ppd
, "cupsUIConstraints", NULL
)) != NULL
)
1789 * Check new-style cupsUIConstraints data...
1793 constattr
= ppdFindNextAttr(ppd
, "cupsUIConstraints", NULL
))
1795 if (!constattr
->value
)
1797 if (!warn
&& !errors
&& !verbose
)
1798 _cupsLangPuts(stdout
, _(" FAIL"));
1800 _cupsLangPrintf(stdout
,
1801 _(" %s Empty cupsUIConstraints %s"),
1802 prefix
, constattr
->spec
);
1810 for (i
= 0, vptr
= strchr(constattr
->value
, '*');
1812 i
++, vptr
= strchr(vptr
+ 1, '*'));
1816 if (!warn
&& !errors
&& !verbose
)
1817 _cupsLangPuts(stdout
, _(" FAIL"));
1819 _cupsLangPrintf(stdout
,
1820 _(" %s Bad cupsUIConstraints %s: \"%s\""),
1821 prefix
, constattr
->spec
, constattr
->value
);
1829 cupsArraySave(ppd
->sorted_attrs
);
1831 if (constattr
->spec
[0] &&
1832 !ppdFindAttr(ppd
, "cupsUIResolver", constattr
->spec
))
1834 if (!warn
&& !errors
&& !verbose
)
1835 _cupsLangPuts(stdout
, _(" FAIL"));
1837 _cupsLangPrintf(stdout
,
1838 _(" %s Missing cupsUIResolver %s"),
1839 prefix
, constattr
->spec
);
1845 cupsArrayRestore(ppd
->sorted_attrs
);
1850 for (vptr
= strchr(constattr
->value
, '*');
1852 vptr
= strchr(vptr
, '*'))
1855 * Extract "*Option Choice" or just "*Option"...
1858 for (vptr
++, ptr
= option
; *vptr
&& !isspace(*vptr
& 255); vptr
++)
1859 if (ptr
< (option
+ sizeof(option
) - 1))
1864 while (isspace(*vptr
& 255))
1871 for (ptr
= choice
; *vptr
&& !isspace(*vptr
& 255); vptr
++)
1872 if (ptr
< (choice
+ sizeof(choice
) - 1))
1878 if (!_cups_strncasecmp(option
, "Custom", 6) && !_cups_strcasecmp(choice
, "True"))
1880 _cups_strcpy(option
, option
+ 6);
1881 strcpy(choice
, "Custom");
1884 if ((o
= ppdFindOption(ppd
, option
)) == NULL
)
1886 if (!warn
&& !errors
&& !verbose
)
1887 _cupsLangPuts(stdout
, _(" FAIL"));
1889 _cupsLangPrintf(stdout
,
1890 _(" %s Missing option %s in "
1891 "cupsUIConstraints %s: \"%s\""),
1892 prefix
, option
, constattr
->spec
, constattr
->value
);
1900 if (choice
[0] && !ppdFindChoice(o
, choice
))
1902 if (!warn
&& !errors
&& !verbose
)
1903 _cupsLangPuts(stdout
, _(" FAIL"));
1905 _cupsLangPrintf(stdout
,
1906 _(" %s Missing choice *%s %s in "
1907 "cupsUIConstraints %s: \"%s\""),
1908 prefix
, option
, choice
, constattr
->spec
,
1918 num_options
= cupsAddOption(option
, choice
, num_options
, &options
);
1921 for (i
= 0; i
< o
->num_choices
; i
++)
1922 if (_cups_strcasecmp(o
->choices
[i
].choice
, "None") &&
1923 _cups_strcasecmp(o
->choices
[i
].choice
, "Off") &&
1924 _cups_strcasecmp(o
->choices
[i
].choice
, "False"))
1926 num_options
= cupsAddOption(option
, o
->choices
[i
].choice
,
1927 num_options
, &options
);
1934 * Resolvers must list at least two options...
1937 if (num_options
< 2)
1939 if (!warn
&& !errors
&& !verbose
)
1940 _cupsLangPuts(stdout
, _(" FAIL"));
1942 _cupsLangPrintf(stdout
,
1943 _(" %s cupsUIResolver %s does not list at least "
1944 "two different options."),
1945 prefix
, constattr
->spec
);
1952 * Test the resolver...
1955 if (!cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
))
1957 if (!warn
&& !errors
&& !verbose
)
1958 _cupsLangPuts(stdout
, _(" FAIL"));
1960 _cupsLangPrintf(stdout
,
1961 _(" %s cupsUIResolver %s causes a loop."),
1962 prefix
, constattr
->spec
);
1968 cupsFreeOptions(num_options
, options
);
1974 * Check old-style [Non]UIConstraints data...
1977 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
1979 if (!_cups_strncasecmp(c
->option1
, "Custom", 6) &&
1980 !_cups_strcasecmp(c
->choice1
, "True"))
1982 strcpy(option
, c
->option1
+ 6);
1983 strcpy(choice
, "Custom");
1987 strcpy(option
, c
->option1
);
1988 strcpy(choice
, c
->choice1
);
1991 if ((o
= ppdFindOption(ppd
, option
)) == NULL
)
1993 if (!warn
&& !errors
&& !verbose
)
1994 _cupsLangPuts(stdout
, _(" FAIL"));
1996 _cupsLangPrintf(stdout
,
1997 _(" %s Missing option %s in "
1998 "UIConstraints \"*%s %s *%s %s\"."),
2000 c
->option1
, c
->choice1
, c
->option2
, c
->choice2
);
2005 else if (choice
[0] && !ppdFindChoice(o
, choice
))
2007 if (!warn
&& !errors
&& !verbose
)
2008 _cupsLangPuts(stdout
, _(" FAIL"));
2010 _cupsLangPrintf(stdout
,
2011 _(" %s Missing choice *%s %s in "
2012 "UIConstraints \"*%s %s *%s %s\"."),
2013 prefix
, c
->option1
, c
->choice1
,
2014 c
->option1
, c
->choice1
, c
->option2
, c
->choice2
);
2020 if (!_cups_strncasecmp(c
->option2
, "Custom", 6) &&
2021 !_cups_strcasecmp(c
->choice2
, "True"))
2023 strcpy(option
, c
->option2
+ 6);
2024 strcpy(choice
, "Custom");
2028 strcpy(option
, c
->option2
);
2029 strcpy(choice
, c
->choice2
);
2032 if ((o
= ppdFindOption(ppd
, option
)) == NULL
)
2034 if (!warn
&& !errors
&& !verbose
)
2035 _cupsLangPuts(stdout
, _(" FAIL"));
2037 _cupsLangPrintf(stdout
,
2038 _(" %s Missing option %s in "
2039 "UIConstraints \"*%s %s *%s %s\"."),
2041 c
->option1
, c
->choice1
, c
->option2
, c
->choice2
);
2046 else if (choice
[0] && !ppdFindChoice(o
, choice
))
2048 if (!warn
&& !errors
&& !verbose
)
2049 _cupsLangPuts(stdout
, _(" FAIL"));
2051 _cupsLangPrintf(stdout
,
2052 _(" %s Missing choice *%s %s in "
2053 "UIConstraints \"*%s %s *%s %s\"."),
2054 prefix
, c
->option2
, c
->choice2
,
2055 c
->option1
, c
->choice1
, c
->option2
, c
->choice2
);
2068 * 'check_case()' - Check that there are no duplicate groups, options,
2069 * or choices that differ only by case.
2072 static int /* O - Errors found */
2073 check_case(ppd_file_t
*ppd
, /* I - PPD file */
2074 int errors
, /* I - Errors found */
2075 int verbose
) /* I - Verbosity level */
2077 int i
, j
; /* Looping vars */
2078 ppd_group_t
*groupa
, /* First group */
2079 *groupb
; /* Second group */
2080 ppd_option_t
*optiona
, /* First option */
2081 *optionb
; /* Second option */
2082 ppd_choice_t
*choicea
, /* First choice */
2083 *choiceb
; /* Second choice */
2087 * Check that the groups do not have any duplicate names...
2090 for (i
= ppd
->num_groups
, groupa
= ppd
->groups
; i
> 1; i
--, groupa
++)
2091 for (j
= i
- 1, groupb
= groupa
+ 1; j
> 0; j
--, groupb
++)
2092 if (!_cups_strcasecmp(groupa
->name
, groupb
->name
))
2094 if (!errors
&& !verbose
)
2095 _cupsLangPuts(stdout
, _(" FAIL"));
2098 _cupsLangPrintf(stdout
,
2099 _(" **FAIL** Group names %s and %s differ only "
2101 groupa
->name
, groupb
->name
);
2107 * Check that the options do not have any duplicate names...
2110 for (optiona
= ppdFirstOption(ppd
); optiona
; optiona
= ppdNextOption(ppd
))
2112 cupsArraySave(ppd
->options
);
2113 for (optionb
= ppdNextOption(ppd
); optionb
; optionb
= ppdNextOption(ppd
))
2114 if (!_cups_strcasecmp(optiona
->keyword
, optionb
->keyword
))
2116 if (!errors
&& !verbose
)
2117 _cupsLangPuts(stdout
, _(" FAIL"));
2120 _cupsLangPrintf(stdout
,
2121 _(" **FAIL** Option names %s and %s differ only "
2123 optiona
->keyword
, optionb
->keyword
);
2127 cupsArrayRestore(ppd
->options
);
2130 * Then the choices...
2133 for (i
= optiona
->num_choices
, choicea
= optiona
->choices
;
2136 for (j
= i
- 1, choiceb
= choicea
+ 1; j
> 0; j
--, choiceb
++)
2137 if (!strcmp(choicea
->choice
, choiceb
->choice
))
2139 if (!errors
&& !verbose
)
2140 _cupsLangPuts(stdout
, _(" FAIL"));
2143 _cupsLangPrintf(stdout
,
2144 _(" **FAIL** Multiple occurrences of %s "
2146 optiona
->keyword
, choicea
->choice
);
2154 else if (!_cups_strcasecmp(choicea
->choice
, choiceb
->choice
))
2156 if (!errors
&& !verbose
)
2157 _cupsLangPuts(stdout
, _(" FAIL"));
2160 _cupsLangPrintf(stdout
,
2161 _(" **FAIL** %s choice names %s and %s "
2162 "differ only by case."),
2163 optiona
->keyword
, choicea
->choice
, choiceb
->choice
);
2170 * Return the number of errors found...
2178 * 'check_defaults()' - Check default option keywords in the PPD file.
2181 static int /* O - Errors found */
2182 check_defaults(ppd_file_t
*ppd
, /* I - PPD file */
2183 int errors
, /* I - Errors found */
2184 int verbose
, /* I - Verbosity level */
2185 int warn
) /* I - Warnings only? */
2187 int j
, k
; /* Looping vars */
2188 ppd_attr_t
*attr
; /* PPD attribute */
2189 ppd_option_t
*option
; /* Standard UI option */
2190 const char *prefix
; /* WARN/FAIL prefix */
2193 prefix
= warn
? " WARN " : "**FAIL**";
2195 ppdMarkDefaults(ppd
);
2196 if (ppdConflicts(ppd
))
2198 if (!warn
&& !errors
&& !verbose
)
2199 _cupsLangPuts(stdout
, _(" FAIL"));
2202 _cupsLangPrintf(stdout
,
2203 _(" %s Default choices conflicting."), prefix
);
2205 show_conflicts(ppd
, prefix
);
2211 for (j
= 0; j
< ppd
->num_attrs
; j
++)
2213 attr
= ppd
->attrs
[j
];
2215 if (!strcmp(attr
->name
, "DefaultColorSpace") ||
2216 !strcmp(attr
->name
, "DefaultFont") ||
2217 !strcmp(attr
->name
, "DefaultHalftoneType") ||
2218 !strcmp(attr
->name
, "DefaultImageableArea") ||
2219 !strcmp(attr
->name
, "DefaultLeadingEdge") ||
2220 !strcmp(attr
->name
, "DefaultOutputOrder") ||
2221 !strcmp(attr
->name
, "DefaultPaperDimension") ||
2222 !strcmp(attr
->name
, "DefaultResolution") ||
2223 !strcmp(attr
->name
, "DefaultTransfer"))
2226 if (!strncmp(attr
->name
, "Default", 7))
2228 if ((option
= ppdFindOption(ppd
, attr
->name
+ 7)) != NULL
&&
2229 strcmp(attr
->value
, "Unknown"))
2232 * Check that the default option value matches a choice...
2235 for (k
= 0; k
< option
->num_choices
; k
++)
2236 if (!strcmp(option
->choices
[k
].choice
, attr
->value
))
2239 if (k
>= option
->num_choices
)
2241 if (!warn
&& !errors
&& !verbose
)
2242 _cupsLangPuts(stdout
, _(" FAIL"));
2245 _cupsLangPrintf(stdout
,
2246 _(" %s %s %s does not exist."),
2247 prefix
, attr
->name
, attr
->value
);
2261 * 'check_duplex()' - Check duplex keywords in the PPD file.
2264 static int /* O - Errors found */
2265 check_duplex(ppd_file_t
*ppd
, /* I - PPD file */
2266 int errors
, /* I - Error found */
2267 int verbose
, /* I - Verbosity level */
2268 int warn
) /* I - Warnings only? */
2270 int i
; /* Looping var */
2271 ppd_option_t
*option
; /* PPD option */
2272 ppd_choice_t
*choice
; /* Current choice */
2273 const char *prefix
; /* Message prefix */
2276 prefix
= warn
? " WARN " : "**FAIL**";
2279 * Check for a duplex option, and for standard values...
2282 if ((option
= ppdFindOption(ppd
, "Duplex")) != NULL
)
2284 if (!ppdFindChoice(option
, "None"))
2288 if (!warn
&& !errors
&& !verbose
)
2289 _cupsLangPuts(stdout
, _(" FAIL"));
2291 _cupsLangPrintf(stdout
,
2292 _(" %s REQUIRED %s does not define "
2294 " REF: Page 122, section 5.17"),
2295 prefix
, option
->keyword
);
2302 for (i
= option
->num_choices
, choice
= option
->choices
;
2305 if (strcmp(choice
->choice
, "None") &&
2306 strcmp(choice
->choice
, "DuplexNoTumble") &&
2307 strcmp(choice
->choice
, "DuplexTumble") &&
2308 strcmp(choice
->choice
, "SimplexTumble"))
2312 if (!warn
&& !errors
&& !verbose
)
2313 _cupsLangPuts(stdout
, _(" FAIL"));
2315 _cupsLangPrintf(stdout
,
2316 _(" %s Bad %s choice %s.\n"
2317 " REF: Page 122, section 5.17"),
2318 prefix
, option
->keyword
, choice
->choice
);
2331 * 'check_filters()' - Check filters in the PPD file.
2334 static int /* O - Errors found */
2335 check_filters(ppd_file_t
*ppd
, /* I - PPD file */
2336 const char *root
, /* I - Root directory */
2337 int errors
, /* I - Errors found */
2338 int verbose
, /* I - Verbosity level */
2339 int warn
) /* I - Warnings only? */
2341 ppd_attr_t
*attr
; /* PPD attribute */
2342 const char *ptr
; /* Pointer into string */
2343 char super
[16], /* Super-type for filter */
2344 type
[256], /* Type for filter */
2345 dstsuper
[16], /* Destination super-type for filter */
2346 dsttype
[256], /* Destination type for filter */
2347 program
[1024], /* Program/filter name */
2348 pathprog
[1024]; /* Complete path to program/filter */
2349 int cost
; /* Cost of filter */
2350 const char *prefix
; /* WARN/FAIL prefix */
2351 struct stat fileinfo
; /* File information */
2354 prefix
= warn
? " WARN " : "**FAIL**";
2360 for (attr
= ppdFindAttr(ppd
, "cupsFilter", NULL
);
2362 attr
= ppdFindNextAttr(ppd
, "cupsFilter", NULL
))
2364 if (strcmp(attr
->name
, "cupsFilter"))
2366 if (!warn
&& !errors
&& !verbose
)
2367 _cupsLangPuts(stdout
, _(" FAIL"));
2370 _cupsLangPrintf(stdout
,
2371 _(" %s Bad spelling of %s - should be %s."),
2372 prefix
, attr
->name
, "cupsFilter");
2379 sscanf(attr
->value
, "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super
, type
,
2380 &cost
, program
) != 4)
2382 if (!warn
&& !errors
&& !verbose
)
2383 _cupsLangPuts(stdout
, _(" FAIL"));
2386 _cupsLangPrintf(stdout
,
2387 _(" %s Bad cupsFilter value \"%s\"."),
2388 prefix
, attr
->value
);
2393 else if (strcmp(program
, "-"))
2395 if (program
[0] == '/')
2396 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
, program
);
2399 if ((ptr
= getenv("CUPS_SERVERBIN")) == NULL
)
2400 ptr
= CUPS_SERVERBIN
;
2402 if (*ptr
== '/' || !*root
)
2403 snprintf(pathprog
, sizeof(pathprog
), "%s%s/filter/%s", root
, ptr
,
2406 snprintf(pathprog
, sizeof(pathprog
), "%s/%s/filter/%s", root
, ptr
,
2410 if (stat(pathprog
, &fileinfo
))
2412 if (!warn
&& !errors
&& !verbose
)
2413 _cupsLangPuts(stdout
, _(" FAIL"));
2416 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2417 prefix
, "cupsFilter", pathprog
);
2422 else if (fileinfo
.st_uid
!= 0 ||
2423 (fileinfo
.st_mode
& MODE_WRITE
) ||
2424 (fileinfo
.st_mode
& MODE_MASK
) != MODE_PROGRAM
)
2426 if (!warn
&& !errors
&& !verbose
)
2427 _cupsLangPuts(stdout
, _(" FAIL"));
2430 _cupsLangPrintf(stdout
,
2431 _(" %s Bad permissions on %s file \"%s\"."),
2432 prefix
, "cupsFilter", pathprog
);
2438 errors
= valid_path("cupsFilter", pathprog
, errors
, verbose
, warn
);
2446 for (attr
= ppdFindAttr(ppd
, "cupsFilter2", NULL
);
2448 attr
= ppdFindNextAttr(ppd
, "cupsFilter2", NULL
))
2450 if (strcmp(attr
->name
, "cupsFilter2"))
2452 if (!warn
&& !errors
&& !verbose
)
2453 _cupsLangPuts(stdout
, _(" FAIL"));
2456 _cupsLangPrintf(stdout
,
2457 _(" %s Bad spelling of %s - should be %s."),
2458 prefix
, attr
->name
, "cupsFilter2");
2465 sscanf(attr
->value
, "%15[^/]/%255s%*[ \t]%15[^/]/%255s%d%*[ \t]%1023[^\n]",
2466 super
, type
, dstsuper
, dsttype
, &cost
, program
) != 6)
2468 if (!warn
&& !errors
&& !verbose
)
2469 _cupsLangPuts(stdout
, _(" FAIL"));
2472 _cupsLangPrintf(stdout
,
2473 _(" %s Bad cupsFilter2 value \"%s\"."),
2474 prefix
, attr
->value
);
2479 else if (strcmp(program
, "-"))
2481 if (strncmp(program
, "maxsize(", 8) &&
2482 (ptr
= strchr(program
+ 8, ')')) != NULL
)
2485 while (_cups_isspace(*ptr
))
2488 _cups_strcpy(program
, ptr
);
2491 if (program
[0] == '/')
2492 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
, program
);
2495 if ((ptr
= getenv("CUPS_SERVERBIN")) == NULL
)
2496 ptr
= CUPS_SERVERBIN
;
2498 if (*ptr
== '/' || !*root
)
2499 snprintf(pathprog
, sizeof(pathprog
), "%s%s/filter/%s", root
, ptr
,
2502 snprintf(pathprog
, sizeof(pathprog
), "%s/%s/filter/%s", root
, ptr
,
2506 if (stat(pathprog
, &fileinfo
))
2508 if (!warn
&& !errors
&& !verbose
)
2509 _cupsLangPuts(stdout
, _(" FAIL"));
2512 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2513 prefix
, "cupsFilter2", pathprog
);
2518 else if (fileinfo
.st_uid
!= 0 ||
2519 (fileinfo
.st_mode
& MODE_WRITE
) ||
2520 (fileinfo
.st_mode
& MODE_MASK
) != MODE_PROGRAM
)
2522 if (!warn
&& !errors
&& !verbose
)
2523 _cupsLangPuts(stdout
, _(" FAIL"));
2526 _cupsLangPrintf(stdout
,
2527 _(" %s Bad permissions on %s file \"%s\"."),
2528 prefix
, "cupsFilter2", pathprog
);
2534 errors
= valid_path("cupsFilter2", pathprog
, errors
, verbose
, warn
);
2542 for (attr
= ppdFindAttr(ppd
, "cupsPreFilter", NULL
);
2544 attr
= ppdFindNextAttr(ppd
, "cupsPreFilter", NULL
))
2546 if (strcmp(attr
->name
, "cupsPreFilter"))
2548 if (!warn
&& !errors
&& !verbose
)
2549 _cupsLangPuts(stdout
, _(" FAIL"));
2552 _cupsLangPrintf(stdout
,
2553 _(" %s Bad spelling of %s - should be %s."),
2554 prefix
, attr
->name
, "cupsPreFilter");
2561 sscanf(attr
->value
, "%15[^/]/%255s%d%*[ \t]%1023[^\n]", super
, type
,
2562 &cost
, program
) != 4)
2564 if (!warn
&& !errors
&& !verbose
)
2565 _cupsLangPuts(stdout
, _(" FAIL"));
2568 _cupsLangPrintf(stdout
,
2569 _(" %s Bad cupsPreFilter value \"%s\"."),
2570 prefix
, attr
->value
? attr
->value
: "");
2575 else if (strcmp(program
, "-"))
2577 if (program
[0] == '/')
2578 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
, program
);
2581 if ((ptr
= getenv("CUPS_SERVERBIN")) == NULL
)
2582 ptr
= CUPS_SERVERBIN
;
2584 if (*ptr
== '/' || !*root
)
2585 snprintf(pathprog
, sizeof(pathprog
), "%s%s/filter/%s", root
, ptr
,
2588 snprintf(pathprog
, sizeof(pathprog
), "%s/%s/filter/%s", root
, ptr
,
2592 if (stat(pathprog
, &fileinfo
))
2594 if (!warn
&& !errors
&& !verbose
)
2595 _cupsLangPuts(stdout
, _(" FAIL"));
2598 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2599 prefix
, "cupsPreFilter", pathprog
);
2604 else if (fileinfo
.st_uid
!= 0 ||
2605 (fileinfo
.st_mode
& MODE_WRITE
) ||
2606 (fileinfo
.st_mode
& MODE_MASK
) != MODE_PROGRAM
)
2608 if (!warn
&& !errors
&& !verbose
)
2609 _cupsLangPuts(stdout
, _(" FAIL"));
2612 _cupsLangPrintf(stdout
,
2613 _(" %s Bad permissions on %s file \"%s\"."),
2614 prefix
, "cupsPreFilter", pathprog
);
2620 errors
= valid_path("cupsPreFilter", pathprog
, errors
, verbose
, warn
);
2629 for (attr
= ppdFindAttr(ppd
, "APDialogExtension", NULL
);
2631 attr
= ppdFindNextAttr(ppd
, "APDialogExtension", NULL
))
2633 if (strcmp(attr
->name
, "APDialogExtension"))
2635 if (!warn
&& !errors
&& !verbose
)
2636 _cupsLangPuts(stdout
, _(" FAIL"));
2639 _cupsLangPrintf(stdout
,
2640 _(" %s Bad spelling of %s - should be %s."),
2641 prefix
, attr
->name
, "APDialogExtension");
2647 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
,
2648 attr
->value
? attr
->value
: "(null)");
2650 if (!attr
->value
|| stat(pathprog
, &fileinfo
))
2652 if (!warn
&& !errors
&& !verbose
)
2653 _cupsLangPuts(stdout
, _(" FAIL"));
2656 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2657 prefix
, "APDialogExtension", pathprog
);
2662 else if (fileinfo
.st_uid
!= 0 ||
2663 (fileinfo
.st_mode
& MODE_WRITE
) ||
2664 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DIRECTORY
)
2666 if (!warn
&& !errors
&& !verbose
)
2667 _cupsLangPuts(stdout
, _(" FAIL"));
2670 _cupsLangPrintf(stdout
,
2671 _(" %s Bad permissions on %s file \"%s\"."),
2672 prefix
, "APDialogExtension", pathprog
);
2678 errors
= valid_path("APDialogExtension", pathprog
, errors
, verbose
,
2686 if ((attr
= ppdFindAttr(ppd
, "APPrinterIconPath", NULL
)) != NULL
)
2688 if (strcmp(attr
->name
, "APPrinterIconPath"))
2690 if (!warn
&& !errors
&& !verbose
)
2691 _cupsLangPuts(stdout
, _(" FAIL"));
2694 _cupsLangPrintf(stdout
,
2695 _(" %s Bad spelling of %s - should be %s."),
2696 prefix
, attr
->name
, "APPrinterIconPath");
2702 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
,
2703 attr
->value
? attr
->value
: "(null)");
2705 if (!attr
->value
|| stat(pathprog
, &fileinfo
))
2707 if (!warn
&& !errors
&& !verbose
)
2708 _cupsLangPuts(stdout
, _(" FAIL"));
2711 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2712 prefix
, "APPrinterIconPath", pathprog
);
2717 else if (fileinfo
.st_uid
!= 0 ||
2718 (fileinfo
.st_mode
& MODE_WRITE
) ||
2719 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DATAFILE
)
2721 if (!warn
&& !errors
&& !verbose
)
2722 _cupsLangPuts(stdout
, _(" FAIL"));
2725 _cupsLangPrintf(stdout
,
2726 _(" %s Bad permissions on %s file \"%s\"."),
2727 prefix
, "APPrinterIconPath", pathprog
);
2733 errors
= valid_path("APPrinterIconPath", pathprog
, errors
, verbose
,
2738 * APPrinterLowInkTool
2741 if ((attr
= ppdFindAttr(ppd
, "APPrinterLowInkTool", NULL
)) != NULL
)
2743 if (strcmp(attr
->name
, "APPrinterLowInkTool"))
2745 if (!warn
&& !errors
&& !verbose
)
2746 _cupsLangPuts(stdout
, _(" FAIL"));
2749 _cupsLangPrintf(stdout
,
2750 _(" %s Bad spelling of %s - should be %s."),
2751 prefix
, attr
->name
, "APPrinterLowInkTool");
2757 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
,
2758 attr
->value
? attr
->value
: "(null)");
2760 if (!attr
->value
|| stat(pathprog
, &fileinfo
))
2762 if (!warn
&& !errors
&& !verbose
)
2763 _cupsLangPuts(stdout
, _(" FAIL"));
2766 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2767 prefix
, "APPrinterLowInkTool", pathprog
);
2772 else if (fileinfo
.st_uid
!= 0 ||
2773 (fileinfo
.st_mode
& MODE_WRITE
) ||
2774 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DIRECTORY
)
2776 if (!warn
&& !errors
&& !verbose
)
2777 _cupsLangPuts(stdout
, _(" FAIL"));
2780 _cupsLangPrintf(stdout
,
2781 _(" %s Bad permissions on %s file \"%s\"."),
2782 prefix
, "APPrinterLowInkTool", pathprog
);
2788 errors
= valid_path("APPrinterLowInkTool", pathprog
, errors
, verbose
,
2793 * APPrinterUtilityPath
2796 if ((attr
= ppdFindAttr(ppd
, "APPrinterUtilityPath", NULL
)) != NULL
)
2798 if (strcmp(attr
->name
, "APPrinterUtilityPath"))
2800 if (!warn
&& !errors
&& !verbose
)
2801 _cupsLangPuts(stdout
, _(" FAIL"));
2804 _cupsLangPrintf(stdout
,
2805 _(" %s Bad spelling of %s - should be %s."),
2806 prefix
, attr
->name
, "APPrinterUtilityPath");
2812 snprintf(pathprog
, sizeof(pathprog
), "%s%s", root
,
2813 attr
->value
? attr
->value
: "(null)");
2815 if (!attr
->value
|| stat(pathprog
, &fileinfo
))
2817 if (!warn
&& !errors
&& !verbose
)
2818 _cupsLangPuts(stdout
, _(" FAIL"));
2821 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2822 prefix
, "APPrinterUtilityPath", pathprog
);
2827 else if (fileinfo
.st_uid
!= 0 ||
2828 (fileinfo
.st_mode
& MODE_WRITE
) ||
2829 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DIRECTORY
)
2831 if (!warn
&& !errors
&& !verbose
)
2832 _cupsLangPuts(stdout
, _(" FAIL"));
2835 _cupsLangPrintf(stdout
,
2836 _(" %s Bad permissions on %s file \"%s\"."),
2837 prefix
, "APPrinterUtilityPath", pathprog
);
2843 errors
= valid_path("APPrinterUtilityPath", pathprog
, errors
, verbose
,
2848 * APScanAppBundleID and APScanAppPath
2851 if ((attr
= ppdFindAttr(ppd
, "APScanAppPath", NULL
)) != NULL
)
2853 if (strcmp(attr
->name
, "APScanAppPath"))
2855 if (!warn
&& !errors
&& !verbose
)
2856 _cupsLangPuts(stdout
, _(" FAIL"));
2859 _cupsLangPrintf(stdout
,
2860 _(" %s Bad spelling of %s - should be %s."),
2861 prefix
, attr
->name
, "APScanAppPath");
2867 if (!attr
->value
|| stat(attr
->value
, &fileinfo
))
2869 if (!warn
&& !errors
&& !verbose
)
2870 _cupsLangPuts(stdout
, _(" FAIL"));
2873 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2874 prefix
, "APScanAppPath",
2875 attr
->value
? attr
->value
: "<NULL>");
2880 else if (fileinfo
.st_uid
!= 0 ||
2881 (fileinfo
.st_mode
& MODE_WRITE
) ||
2882 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DIRECTORY
)
2884 if (!warn
&& !errors
&& !verbose
)
2885 _cupsLangPuts(stdout
, _(" FAIL"));
2888 _cupsLangPrintf(stdout
,
2889 _(" %s Bad permissions on %s file \"%s\"."),
2890 prefix
, "APScanAppPath", attr
->value
);
2896 errors
= valid_path("APScanAppPath", attr
->value
, errors
, verbose
,
2899 if (ppdFindAttr(ppd
, "APScanAppBundleID", NULL
))
2901 if (!warn
&& !errors
&& !verbose
)
2902 _cupsLangPuts(stdout
, _(" FAIL"));
2905 _cupsLangPrintf(stdout
, _(" %s Cannot provide both "
2906 "APScanAppPath and APScanAppBundleID."),
2913 #endif /* __APPLE__ */
2920 * 'check_profiles()' - Check ICC color profiles in the PPD file.
2923 static int /* O - Errors found */
2924 check_profiles(ppd_file_t
*ppd
, /* I - PPD file */
2925 const char *root
, /* I - Root directory */
2926 int errors
, /* I - Errors found */
2927 int verbose
, /* I - Verbosity level */
2928 int warn
) /* I - Warnings only? */
2930 int i
; /* Looping var */
2931 ppd_attr_t
*attr
; /* PPD attribute */
2932 const char *ptr
; /* Pointer into string */
2933 const char *prefix
; /* WARN/FAIL prefix */
2934 char filename
[1024]; /* Profile filename */
2935 struct stat fileinfo
; /* File information */
2936 int num_profiles
= 0; /* Number of profiles */
2937 unsigned hash
, /* Current hash value */
2938 hashes
[1000]; /* Hash values of profile names */
2939 const char *specs
[1000]; /* Specifiers for profiles */
2942 prefix
= warn
? " WARN " : "**FAIL**";
2944 for (attr
= ppdFindAttr(ppd
, "cupsICCProfile", NULL
);
2946 attr
= ppdFindNextAttr(ppd
, "cupsICCProfile", NULL
))
2949 * Check for valid selector...
2952 for (i
= 0, ptr
= strchr(attr
->spec
, '.'); ptr
; ptr
= strchr(ptr
+ 1, '.'))
2955 if (!attr
->value
|| i
< 2)
2957 if (!warn
&& !errors
&& !verbose
)
2958 _cupsLangPuts(stdout
, _(" FAIL"));
2961 _cupsLangPrintf(stdout
,
2962 _(" %s Bad cupsICCProfile %s."),
2963 prefix
, attr
->spec
);
2972 * Check for valid profile filename...
2975 if (attr
->value
[0] == '/')
2976 snprintf(filename
, sizeof(filename
), "%s%s", root
, attr
->value
);
2979 if ((ptr
= getenv("CUPS_DATADIR")) == NULL
)
2982 if (*ptr
== '/' || !*root
)
2983 snprintf(filename
, sizeof(filename
), "%s%s/profiles/%s", root
, ptr
,
2986 snprintf(filename
, sizeof(filename
), "%s/%s/profiles/%s", root
, ptr
,
2990 if (stat(filename
, &fileinfo
))
2992 if (!warn
&& !errors
&& !verbose
)
2993 _cupsLangPuts(stdout
, _(" FAIL"));
2996 _cupsLangPrintf(stdout
, _(" %s Missing %s file \"%s\"."),
2997 prefix
, "cupsICCProfile", filename
);
3002 else if (fileinfo
.st_uid
!= 0 ||
3003 (fileinfo
.st_mode
& MODE_WRITE
) ||
3004 (fileinfo
.st_mode
& MODE_MASK
) != MODE_DATAFILE
)
3006 if (!warn
&& !errors
&& !verbose
)
3007 _cupsLangPuts(stdout
, _(" FAIL"));
3010 _cupsLangPrintf(stdout
,
3011 _(" %s Bad permissions on %s file \"%s\"."),
3012 prefix
, "cupsICCProfile", filename
);
3018 errors
= valid_path("cupsICCProfile", filename
, errors
, verbose
, warn
);
3021 * Check for hash collisions...
3024 hash
= _ppdHashName(attr
->spec
);
3026 if (num_profiles
> 0)
3028 for (i
= 0; i
< num_profiles
; i
++)
3029 if (hashes
[i
] == hash
)
3032 if (i
< num_profiles
)
3034 if (!warn
&& !errors
&& !verbose
)
3035 _cupsLangPuts(stdout
, _(" FAIL"));
3038 _cupsLangPrintf(stdout
,
3039 _(" %s cupsICCProfile %s hash value "
3040 "collides with %s."), prefix
, attr
->spec
,
3049 * Remember up to 1000 profiles...
3052 if (num_profiles
< 1000)
3054 hashes
[num_profiles
] = hash
;
3055 specs
[num_profiles
] = attr
->spec
;
3065 * 'check_sizes()' - Check media sizes in the PPD file.
3068 static int /* O - Errors found */
3069 check_sizes(ppd_file_t
*ppd
, /* I - PPD file */
3070 int errors
, /* I - Errors found */
3071 int verbose
, /* I - Verbosity level */
3072 int warn
) /* I - Warnings only? */
3074 int i
; /* Looping var */
3075 ppd_size_t
*size
; /* Current size */
3076 int width
, /* Custom width */
3077 length
; /* Custom length */
3078 const char *prefix
; /* WARN/FAIL prefix */
3079 ppd_option_t
*page_size
, /* PageSize option */
3080 *page_region
; /* PageRegion option */
3081 _pwg_media_t
*pwg_media
; /* PWG media */
3082 char buf
[1024]; /* PapeSize name that is supposed to be */
3083 const char *ptr
; /* Pointer into string */
3084 int width_2540ths
, /* PageSize width in 2540ths */
3085 length_2540ths
; /* PageSize length in 2540ths */
3086 int is_ok
; /* Flag for PageSize name verification */
3087 double width_tmp
, /* Width after rounded up */
3088 length_tmp
, /* Length after rounded up */
3089 width_inch
, /* Width in inches */
3090 length_inch
, /* Length in inches */
3091 width_mm
, /* Width in millimeters */
3092 length_mm
; /* Length in millimeters */
3095 prefix
= warn
? " WARN " : "**FAIL**";
3097 if ((page_size
= ppdFindOption(ppd
, "PageSize")) == NULL
&& warn
!= 2)
3099 if (!warn
&& !errors
&& !verbose
)
3100 _cupsLangPuts(stdout
, _(" FAIL"));
3103 _cupsLangPrintf(stdout
,
3104 _(" %s Missing REQUIRED PageSize option.\n"
3105 " REF: Page 99, section 5.14."),
3112 if ((page_region
= ppdFindOption(ppd
, "PageRegion")) == NULL
&& warn
!= 2)
3114 if (!warn
&& !errors
&& !verbose
)
3115 _cupsLangPuts(stdout
, _(" FAIL"));
3118 _cupsLangPrintf(stdout
,
3119 _(" %s Missing REQUIRED PageRegion option.\n"
3120 " REF: Page 100, section 5.14."),
3127 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
3130 * Check that the size name is standard...
3133 if (!strcmp(size
->name
, "Custom"))
3136 * Skip custom page size...
3142 if (warn
!= 2 && size
->name
[0] == 'w' &&
3143 sscanf(size
->name
, "w%dh%d", &width
, &length
) == 2)
3146 * Validate device-specific size wNNNhNNN should have proper width and
3150 if (fabs(width
- size
->width
) >= 1.0 ||
3151 fabs(length
- size
->length
) >= 1.0)
3153 if (!warn
&& !errors
&& !verbose
)
3154 _cupsLangPuts(stdout
, _(" FAIL"));
3157 _cupsLangPrintf(stdout
,
3158 _(" %s Size \"%s\" has unexpected dimensions "
3160 prefix
, size
->name
, size
->width
, size
->length
);
3168 * Verify that the size is defined for both PageSize and PageRegion...
3171 if (warn
!= 2 && !ppdFindChoice(page_size
, size
->name
))
3173 if (!warn
&& !errors
&& !verbose
)
3174 _cupsLangPuts(stdout
, _(" FAIL"));
3177 _cupsLangPrintf(stdout
,
3178 _(" %s Size \"%s\" defined for %s but not for "
3180 prefix
, size
->name
, "PageRegion", "PageSize");
3185 else if (warn
!= 2 && !ppdFindChoice(page_region
, size
->name
))
3187 if (!warn
&& !errors
&& !verbose
)
3188 _cupsLangPuts(stdout
, _(" FAIL"));
3191 _cupsLangPrintf(stdout
,
3192 _(" %s Size \"%s\" defined for %s but not for "
3194 prefix
, size
->name
, "PageSize", "PageRegion");
3201 * Verify that the size name is Adobe standard name if it's a standard size
3202 * and the dimentional name if it's not a standard size. Suffix should be
3203 * .Fullbleed, etc., or numeric, e.g., Letter, Letter.Fullbleed,
3204 * Letter.Transverse, Letter1, Letter2, 4x8, 55x91mm, 55x91mm.Fullbleed, etc.
3210 width_2540ths
= (size
->length
> size
->width
) ?
3211 _PWG_FROMPTS(size
->width
) :
3212 _PWG_FROMPTS(size
->length
);
3213 length_2540ths
= (size
->length
> size
->width
) ?
3214 _PWG_FROMPTS(size
->length
) :
3215 _PWG_FROMPTS(size
->width
);
3216 pwg_media
= _pwgMediaForSize(width_2540ths
, length_2540ths
);
3218 if (pwg_media
&& pwg_media
->ppd
)
3220 size_t ppdlen
= strlen(pwg_media
->ppd
);
3221 /* Length of standard PPD name */
3223 strlcpy(buf
, pwg_media
->ppd
, sizeof(buf
));
3225 if (size
->left
== 0 && size
->bottom
== 0 &&
3226 size
->right
== size
->width
&& size
->top
== size
->length
)
3228 snprintf(buf
, sizeof(buf
), "%s.Fullbleed", pwg_media
->ppd
);
3229 if (_cups_strcasecmp(size
->name
, buf
))
3232 * Allow an additional qualifier such as ".WithTab"...
3235 size_t buflen
= strlen(buf
);/* Length of full bleed name */
3237 if (_cups_strncasecmp(size
->name
, buf
, buflen
) ||
3238 size
->name
[buflen
] != '.')
3242 else if (strcmp(size
->name
, buf
) && size
->width
> size
->length
)
3244 if (!strcmp(pwg_media
->ppd
, "DoublePostcardRotated"))
3245 strlcpy(buf
, "DoublePostcard", sizeof(buf
));
3247 snprintf(buf
, sizeof(buf
), "%sRotated", pwg_media
->ppd
);
3249 if (strcmp(size
->name
, buf
))
3251 snprintf(buf
, sizeof(buf
), "%s.Transverse", pwg_media
->ppd
);
3252 if (strcmp(size
->name
, buf
))
3256 else if (!strncmp(size
->name
, pwg_media
->ppd
, ppdlen
))
3259 * Check for a proper qualifier (number, "Small", or .something)...
3262 ptr
= size
->name
+ ppdlen
;
3264 if (isdigit(*ptr
& 255))
3266 for (ptr
++; *ptr
; ptr
++)
3268 if (!isdigit(*ptr
& 255))
3275 else if (*ptr
!= '.' && *ptr
&& strcmp(ptr
, "Small"))
3281 * Check for EnvSizeName as well...
3284 if (strncmp(pwg_media
->ppd
, "Env", 3))
3285 snprintf(buf
, sizeof(buf
), "Env%s", pwg_media
->ppd
);
3287 if (strcmp(size
->name
, buf
))
3292 _cupsLangPrintf(stdout
,
3293 _(" %s Size \"%s\" should be the Adobe "
3294 "standard name \"%s\"."),
3295 prefix
, size
->name
, buf
);
3299 width_tmp
= (fabs(size
->width
- ceil(size
->width
)) < 0.1) ?
3300 ceil(size
->width
) : size
->width
;
3301 length_tmp
= (fabs(size
->length
- ceil(size
->length
)) < 0.1) ?
3302 ceil(size
->length
) : size
->length
;
3304 if (fmod(width_tmp
, 18.0) == 0.0 || fmod(length_tmp
, 18.0) == 0.0)
3306 width_inch
= width_tmp
/ 72.0;
3307 length_inch
= length_tmp
/ 72.0;
3309 snprintf(buf
, sizeof(buf
), "%gx%g", width_inch
, length_inch
);
3313 width_mm
= size
->width
/ 72.0 * 25.4;
3314 length_mm
= size
->length
/ 72.0 * 25.4;
3316 snprintf(buf
, sizeof(buf
), "%.0fx%.0fmm", width_mm
, length_mm
);
3319 if (size
->left
== 0 && size
->bottom
== 0 &&
3320 size
->right
== size
->width
&& size
->top
== size
->length
)
3321 strlcat(buf
, ".Fullbleed", sizeof(buf
));
3322 else if (size
->width
> size
->length
)
3323 strlcat(buf
, ".Transverse", sizeof(buf
));
3325 if (_cups_strcasecmp(size
->name
, buf
))
3327 size_t buflen
= strlen(buf
); /* Length of proposed name */
3329 if (_cups_strncasecmp(size
->name
, buf
, buflen
) ||
3330 strcmp(size
->name
+ buflen
, "in"))
3331 _cupsLangPrintf(stdout
,
3332 _(" %s Size \"%s\" should be \"%s\"."),
3333 prefix
, size
->name
, buf
);
3344 * 'check_translations()' - Check translations in the PPD file.
3347 static int /* O - Errors found */
3348 check_translations(ppd_file_t
*ppd
, /* I - PPD file */
3349 int errors
, /* I - Errors found */
3350 int verbose
, /* I - Verbosity level */
3351 int warn
) /* I - Warnings only? */
3353 int j
; /* Looping var */
3354 ppd_attr_t
*attr
; /* PPD attribute */
3355 cups_array_t
*languages
; /* Array of languages */
3356 int langlen
; /* Length of language */
3357 char *language
, /* Current language */
3358 keyword
[PPD_MAX_NAME
], /* Localization keyword (full) */
3359 llkeyword
[PPD_MAX_NAME
],/* Localization keyword (base) */
3360 ckeyword
[PPD_MAX_NAME
], /* Custom option keyword (full) */
3361 cllkeyword
[PPD_MAX_NAME
];
3362 /* Custom option keyword (base) */
3363 ppd_option_t
*option
; /* Standard UI option */
3364 ppd_coption_t
*coption
; /* Custom option */
3365 ppd_cparam_t
*cparam
; /* Custom parameter */
3366 char ll
[3]; /* Base language */
3367 const char *prefix
; /* WARN/FAIL prefix */
3368 const char *text
; /* Pointer into UI text */
3371 prefix
= warn
? " WARN " : "**FAIL**";
3373 if ((languages
= _ppdGetLanguages(ppd
)) != NULL
)
3376 * This file contains localizations, check them...
3379 for (language
= (char *)cupsArrayFirst(languages
);
3381 language
= (char *)cupsArrayNext(languages
))
3383 langlen
= (int)strlen(language
);
3384 if (langlen
!= 2 && langlen
!= 5)
3386 if (!warn
&& !errors
&& !verbose
)
3387 _cupsLangPuts(stdout
, _(" FAIL"));
3390 _cupsLangPrintf(stdout
,
3391 _(" %s Bad language \"%s\"."),
3400 if (!strcmp(language
, "en"))
3403 strlcpy(ll
, language
, sizeof(ll
));
3406 * Loop through all options and choices...
3409 for (option
= ppdFirstOption(ppd
);
3411 option
= ppdNextOption(ppd
))
3413 if (!strcmp(option
->keyword
, "PageRegion"))
3416 snprintf(keyword
, sizeof(keyword
), "%s.Translation", language
);
3417 snprintf(llkeyword
, sizeof(llkeyword
), "%s.Translation", ll
);
3419 if ((attr
= ppdFindAttr(ppd
, keyword
, option
->keyword
)) == NULL
&&
3420 (attr
= ppdFindAttr(ppd
, llkeyword
, option
->keyword
)) == NULL
)
3422 if (!warn
&& !errors
&& !verbose
)
3423 _cupsLangPuts(stdout
, _(" FAIL"));
3426 _cupsLangPrintf(stdout
,
3427 _(" %s Missing \"%s\" translation "
3428 "string for option %s."),
3429 prefix
, language
, option
->keyword
);
3434 else if (!valid_utf8(attr
->text
))
3436 if (!warn
&& !errors
&& !verbose
)
3437 _cupsLangPuts(stdout
, _(" FAIL"));
3440 _cupsLangPrintf(stdout
,
3441 _(" %s Bad UTF-8 \"%s\" translation "
3442 "string for option %s."),
3443 prefix
, language
, option
->keyword
);
3449 snprintf(keyword
, sizeof(keyword
), "%s.%s", language
,
3451 snprintf(llkeyword
, sizeof(llkeyword
), "%s.%s", ll
,
3454 for (j
= 0; j
< option
->num_choices
; j
++)
3457 * First see if this choice is a number; if so, don't require
3461 for (text
= option
->choices
[j
].text
; *text
; text
++)
3462 if (!strchr("0123456789-+.", *text
))
3469 * Check custom choices differently...
3472 if (!_cups_strcasecmp(option
->choices
[j
].choice
, "Custom") &&
3473 (coption
= ppdFindCustomOption(ppd
,
3474 option
->keyword
)) != NULL
)
3476 snprintf(ckeyword
, sizeof(ckeyword
), "%s.Custom%s",
3477 language
, option
->keyword
);
3479 if ((attr
= ppdFindAttr(ppd
, ckeyword
, "True")) != NULL
&&
3480 !valid_utf8(attr
->text
))
3482 if (!warn
&& !errors
&& !verbose
)
3483 _cupsLangPuts(stdout
, _(" FAIL"));
3486 _cupsLangPrintf(stdout
,
3487 _(" %s Bad UTF-8 \"%s\" "
3488 "translation string for option %s, "
3491 ckeyword
+ 1 + strlen(language
),
3498 if (_cups_strcasecmp(option
->keyword
, "PageSize"))
3500 for (cparam
= (ppd_cparam_t
*)cupsArrayFirst(coption
->params
);
3502 cparam
= (ppd_cparam_t
*)cupsArrayNext(coption
->params
))
3504 snprintf(ckeyword
, sizeof(ckeyword
), "%s.ParamCustom%s",
3505 language
, option
->keyword
);
3506 snprintf(cllkeyword
, sizeof(cllkeyword
), "%s.ParamCustom%s",
3507 ll
, option
->keyword
);
3509 if ((attr
= ppdFindAttr(ppd
, ckeyword
,
3510 cparam
->name
)) == NULL
&&
3511 (attr
= ppdFindAttr(ppd
, cllkeyword
,
3512 cparam
->name
)) == NULL
)
3514 if (!warn
&& !errors
&& !verbose
)
3515 _cupsLangPuts(stdout
, _(" FAIL"));
3518 _cupsLangPrintf(stdout
,
3519 _(" %s Missing \"%s\" "
3520 "translation string for option %s, "
3523 ckeyword
+ 1 + strlen(language
),
3529 else if (!valid_utf8(attr
->text
))
3531 if (!warn
&& !errors
&& !verbose
)
3532 _cupsLangPuts(stdout
, _(" FAIL"));
3535 _cupsLangPrintf(stdout
,
3536 _(" %s Bad UTF-8 \"%s\" "
3537 "translation string for option %s, "
3540 ckeyword
+ 1 + strlen(language
),
3549 else if ((attr
= ppdFindAttr(ppd
, keyword
,
3550 option
->choices
[j
].choice
)) == NULL
&&
3551 (attr
= ppdFindAttr(ppd
, llkeyword
,
3552 option
->choices
[j
].choice
)) == NULL
)
3554 if (!warn
&& !errors
&& !verbose
)
3555 _cupsLangPuts(stdout
, _(" FAIL"));
3558 _cupsLangPrintf(stdout
,
3559 _(" %s Missing \"%s\" "
3560 "translation string for option %s, "
3562 prefix
, language
, option
->keyword
,
3563 option
->choices
[j
].choice
);
3568 else if (!valid_utf8(attr
->text
))
3570 if (!warn
&& !errors
&& !verbose
)
3571 _cupsLangPuts(stdout
, _(" FAIL"));
3574 _cupsLangPrintf(stdout
,
3575 _(" %s Bad UTF-8 \"%s\" "
3576 "translation string for option %s, "
3578 prefix
, language
, option
->keyword
,
3579 option
->choices
[j
].choice
);
3589 * Verify that we have the base language for each localized one...
3592 for (language
= (char *)cupsArrayFirst(languages
);
3594 language
= (char *)cupsArrayNext(languages
))
3598 * Lookup the base language...
3601 cupsArraySave(languages
);
3603 strlcpy(ll
, language
, sizeof(ll
));
3605 if (!cupsArrayFind(languages
, ll
) &&
3606 strcmp(ll
, "zh") && strcmp(ll
, "en"))
3608 if (!warn
&& !errors
&& !verbose
)
3609 _cupsLangPuts(stdout
, _(" FAIL"));
3612 _cupsLangPrintf(stdout
,
3613 _(" %s No base translation \"%s\" "
3614 "is included in file."), prefix
, ll
);
3620 cupsArrayRestore(languages
);
3624 * Free memory used for the languages...
3627 _ppdFreeLanguages(languages
);
3635 * 'show_conflicts()' - Show option conflicts in a PPD file.
3639 show_conflicts(ppd_file_t
*ppd
, /* I - PPD to check */
3640 const char *prefix
) /* I - Prefix string */
3642 int i
, j
; /* Looping variables */
3643 ppd_const_t
*c
; /* Current constraint */
3644 ppd_option_t
*o1
, *o2
; /* Options */
3645 ppd_choice_t
*c1
, *c2
; /* Choices */
3649 * Loop through all of the UI constraints and report any options
3653 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
3656 * Grab pointers to the first option...
3659 o1
= ppdFindOption(ppd
, c
->option1
);
3663 else if (c
->choice1
[0] != '\0')
3666 * This constraint maps to a specific choice.
3669 c1
= ppdFindChoice(o1
, c
->choice1
);
3674 * This constraint applies to any choice for this option.
3677 for (j
= o1
->num_choices
, c1
= o1
->choices
; j
> 0; j
--, c1
++)
3682 !_cups_strcasecmp(c1
->choice
, "None") ||
3683 !_cups_strcasecmp(c1
->choice
, "Off") ||
3684 !_cups_strcasecmp(c1
->choice
, "False"))
3689 * Grab pointers to the second option...
3692 o2
= ppdFindOption(ppd
, c
->option2
);
3696 else if (c
->choice2
[0] != '\0')
3699 * This constraint maps to a specific choice.
3702 c2
= ppdFindChoice(o2
, c
->choice2
);
3707 * This constraint applies to any choice for this option.
3710 for (j
= o2
->num_choices
, c2
= o2
->choices
; j
> 0; j
--, c2
++)
3715 !_cups_strcasecmp(c2
->choice
, "None") ||
3716 !_cups_strcasecmp(c2
->choice
, "Off") ||
3717 !_cups_strcasecmp(c2
->choice
, "False"))
3722 * If both options are marked then there is a conflict...
3725 if (c1
!= NULL
&& c1
->marked
&& c2
!= NULL
&& c2
->marked
)
3726 _cupsLangPrintf(stdout
,
3727 _(" %s \"%s %s\" conflicts with \"%s %s\"\n"
3728 " (constraint=\"%s %s %s %s\")."),
3729 prefix
, o1
->keyword
, c1
->choice
, o2
->keyword
, c2
->choice
,
3730 c
->option1
, c
->choice1
, c
->option2
, c
->choice2
);
3736 * 'test_raster()' - Test PostScript commands for raster printers.
3739 static int /* O - 1 on success, 0 on failure */
3740 test_raster(ppd_file_t
*ppd
, /* I - PPD file */
3741 int verbose
) /* I - Verbosity */
3743 cups_page_header2_t header
; /* Page header */
3746 ppdMarkDefaults(ppd
);
3747 if (cupsRasterInterpretPPD(&header
, ppd
, 0, NULL
, 0))
3750 _cupsLangPuts(stdout
, _(" FAIL"));
3753 _cupsLangPrintf(stdout
,
3754 _(" **FAIL** Default option code cannot be "
3755 "interpreted: %s"), cupsRasterErrorString());
3761 * Try a test of custom page size code, if available...
3764 if (!ppdPageSize(ppd
, "Custom.612x792"))
3767 ppdMarkOption(ppd
, "PageSize", "Custom.612x792");
3769 if (cupsRasterInterpretPPD(&header
, ppd
, 0, NULL
, 0))
3772 _cupsLangPuts(stdout
, _(" FAIL"));
3775 _cupsLangPrintf(stdout
,
3776 _(" **FAIL** Default option code cannot be "
3777 "interpreted: %s"), cupsRasterErrorString());
3787 * 'usage()' - Show program usage.
3793 _cupsLangPuts(stdout
, _("Usage: cupstestppd [options] filename1.ppd[.gz] "
3794 "[... filenameN.ppd[.gz]]"));
3795 _cupsLangPuts(stdout
, _(" program | cupstestppd [options] -"));
3796 _cupsLangPuts(stdout
, "");
3797 _cupsLangPuts(stdout
, _("Options:"));
3798 _cupsLangPuts(stdout
, "");
3799 _cupsLangPuts(stdout
, _(" -I {filename,filters,none,profiles}"));
3800 _cupsLangPuts(stdout
, _(" Ignore specific warnings."));
3801 _cupsLangPuts(stdout
, _(" -R root-directory Set alternate root."));
3802 _cupsLangPuts(stdout
, _(" -W {all,none,constraints,defaults,duplex,"
3803 "filters,profiles,sizes,translations}"));
3804 _cupsLangPuts(stdout
, _(" Issue warnings instead of "
3806 _cupsLangPuts(stdout
, _(" -q Run silently."));
3807 _cupsLangPuts(stdout
, _(" -r Use 'relaxed' open mode."));
3808 _cupsLangPuts(stdout
, _(" -v Be slightly verbose."));
3809 _cupsLangPuts(stdout
, _(" -vv Be very verbose."));
3816 * 'valid_path()' - Check whether a path has the correct capitalization.
3819 static int /* O - Errors found */
3820 valid_path(const char *keyword
, /* I - Keyword using path */
3821 const char *path
, /* I - Path to check */
3822 int errors
, /* I - Errors found */
3823 int verbose
, /* I - Verbosity level */
3824 int warn
) /* I - Warnings only? */
3826 cups_dir_t
*dir
; /* Current directory */
3827 cups_dentry_t
*dentry
; /* Current directory entry */
3828 char temp
[1024], /* Temporary path */
3829 *ptr
; /* Pointer into temporary path */
3830 const char *prefix
; /* WARN/FAIL prefix */
3833 prefix
= warn
? " WARN " : "**FAIL**";
3836 * Loop over the components of the path, checking that the entry exists with
3837 * the same capitalization...
3840 strlcpy(temp
, path
, sizeof(temp
));
3842 while ((ptr
= strrchr(temp
, '/')) != NULL
)
3845 * Chop off the trailing component so temp == dirname and ptr == basename.
3851 * Try opening the directory containing the base name...
3855 dir
= cupsDirOpen(temp
);
3857 dir
= cupsDirOpen("/");
3863 while ((dentry
= cupsDirRead(dir
)) != NULL
)
3865 if (!strcmp(dentry
->filename
, ptr
))
3873 * Display an error if the filename doesn't exist with the same
3879 if (!warn
&& !errors
&& !verbose
)
3880 _cupsLangPuts(stdout
, _(" FAIL"));
3883 _cupsLangPrintf(stdout
,
3884 _(" %s %s file \"%s\" has the wrong "
3885 "capitalization."), prefix
, keyword
, path
);
3899 * 'valid_utf8()' - Check whether a string contains valid UTF-8 text.
3902 static int /* O - 1 if valid, 0 if not */
3903 valid_utf8(const char *s
) /* I - String to check */
3910 * Check for valid UTF-8 sequence...
3913 if ((*s
& 0xc0) == 0x80)
3914 return (0); /* Illegal suffix byte */
3915 else if ((*s
& 0xe0) == 0xc0)
3918 * 2-byte sequence...
3923 if ((*s
& 0xc0) != 0x80)
3924 return (0); /* Missing suffix byte */
3926 else if ((*s
& 0xf0) == 0xe0)
3929 * 3-byte sequence...
3934 if ((*s
& 0xc0) != 0x80)
3935 return (0); /* Missing suffix byte */
3939 if ((*s
& 0xc0) != 0x80)
3940 return (0); /* Missing suffix byte */
3942 else if ((*s
& 0xf8) == 0xf0)
3945 * 4-byte sequence...
3950 if ((*s
& 0xc0) != 0x80)
3951 return (0); /* Missing suffix byte */
3955 if ((*s
& 0xc0) != 0x80)
3956 return (0); /* Missing suffix byte */
3960 if ((*s
& 0xc0) != 0x80)
3961 return (0); /* Missing suffix byte */
3964 return (0); /* Bad sequence */
3975 * End of "$Id: cupstestppd.c 7807 2008-07-28 21:54:24Z mike $".