diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2008-07-30 23:42:12 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2008-07-30 23:42:12 +0000 |
commit | 749b1e90a80fd8245f9cb84d2f78ab65034eeb81 (patch) | |
tree | 41c2eb9f8c465165197a146aadd4df3e37ca362f /systemv/cupstestppd.c | |
parent | 005dd1eb9e7844f4bf631111847c26c9a4b56df3 (diff) |
Merge changes from CUPS 1.4svn-r7817.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@901 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'systemv/cupstestppd.c')
-rw-r--r-- | systemv/cupstestppd.c | 303 |
1 files changed, 234 insertions, 69 deletions
diff --git a/systemv/cupstestppd.c b/systemv/cupstestppd.c index b8052b3b5..e398d3f4c 100644 --- a/systemv/cupstestppd.c +++ b/systemv/cupstestppd.c @@ -21,8 +21,11 @@ * main() - Main entry for test program. * check_basics() - Check for CR LF, mixed line endings, and blank * lines. + * check_case() - Check that there are no duplicate groups, options, + * or choices that differ only by case. * check_constraints() - Check UIConstraints in the PPD file. * check_defaults() - Check default option keywords in the PPD file. + * check_duplex() - Check duplex keywords in the PPD file. * check_filters() - Check filters in the PPD file. * check_profiles() - Check ICC color profiles in the PPD file. * check_translations() - Check translations in the PPD file. @@ -58,7 +61,8 @@ enum WARN_FILTERS = 4, WARN_PROFILES = 8, WARN_TRANSLATIONS = 16, - WARN_ALL = 31 + WARN_DUPLEX = 32, + WARN_ALL = 63 }; @@ -96,8 +100,11 @@ enum static void check_basics(const char *filename); static int check_constraints(ppd_file_t *ppd, int errors, int verbose, int warn); +static int check_case(ppd_file_t *ppd, int errors, int verbose); static int check_defaults(ppd_file_t *ppd, int errors, int verbose, int warn); +static int check_duplex(ppd_file_t *ppd, int errors, int verbose, + int warn); static int check_filters(ppd_file_t *ppd, const char *root, int errors, int verbose, int warn); static int check_profiles(ppd_file_t *ppd, const char *root, int errors, @@ -190,6 +197,8 @@ main(int argc, /* I - Number of command-line args */ warn |= WARN_CONSTRAINTS; else if (!strcmp(argv[i], "defaults")) warn |= WARN_DEFAULTS; + else if (!strcmp(argv[i], "duplex")) + warn |= WARN_DUPLEX; else if (!strcmp(argv[i], "filters")) warn |= WARN_FILTERS; else if (!strcmp(argv[i], "profiles")) @@ -1008,55 +1017,6 @@ main(int argc, /* I - Number of command-line args */ } } - /* - * Check for a duplex option, and for standard values... - */ - - if ((option = ppdFindOption(ppd, "Duplex")) == NULL) - if ((option = ppdFindOption(ppd, "JCLDuplex")) == NULL) - if ((option = ppdFindOption(ppd, "EFDuplex")) == NULL) - option = ppdFindOption(ppd, "KD03Duplex"); - - if (option != NULL) - { - if (ppdFindChoice(option, "None") == NULL) - { - if (verbose >= 0) - { - if (!errors && !verbose) - _cupsLangPuts(stdout, _(" FAIL\n")); - - _cupsLangPrintf(stdout, - _(" **FAIL** REQUIRED %s does not define " - "choice None!\n" - " REF: Page 122, section 5.17\n"), - option->keyword); - } - - errors ++; - } - - for (j = option->num_choices, choice = option->choices; j > 0; j --, choice ++) - if (strcmp(choice->choice, "None") && - strcmp(choice->choice, "DuplexNoTumble") && - strcmp(choice->choice, "DuplexTumble") && - strcmp(choice->choice, "SimplexTumble")) - { - if (verbose >= 0) - { - if (!errors && !verbose) - _cupsLangPuts(stdout, _(" FAIL\n")); - - _cupsLangPrintf(stdout, - _(" **FAIL** Bad %s choice %s!\n" - " REF: Page 122, section 5.17\n"), - option->keyword, choice->choice); - } - - errors ++; - } - } - if ((attr = ppdFindAttr(ppd, "1284DeviceID", NULL)) && strcmp(attr->name, "1284DeviceID")) { @@ -1074,6 +1034,8 @@ main(int argc, /* I - Number of command-line args */ errors ++; } + errors = check_case(ppd, errors, verbose); + if (!(warn & WARN_CONSTRAINTS)) errors = check_constraints(ppd, errors, verbose, 0); @@ -1086,6 +1048,9 @@ main(int argc, /* I - Number of command-line args */ if (!(warn & WARN_TRANSLATIONS)) errors = check_translations(ppd, errors, verbose, 0); + if (!(warn & WARN_DUPLEX)) + errors = check_duplex(ppd, errors, verbose, 0); + if ((attr = ppdFindAttr(ppd, "cupsLanguages", NULL)) != NULL && attr->value) { @@ -1217,6 +1182,24 @@ main(int argc, /* I - Number of command-line args */ if (warn & WARN_TRANSLATIONS) errors = check_translations(ppd, errors, verbose, 1); + if (warn & WARN_DUPLEX) + errors = check_duplex(ppd, errors, verbose, 1); + + /* + * Look for legacy duplex keywords... + */ + + if ((option = ppdFindOption(ppd, "JCLDuplex")) == NULL) + if ((option = ppdFindOption(ppd, "EFDuplex")) == NULL) + option = ppdFindOption(ppd, "KD03Duplex"); + + if (option) + _cupsLangPrintf(stdout, + _(" WARN Duplex option keyword %s may not " + "work as expected and should be named Duplex!\n" + " REF: Page 122, section 5.17\n"), + option->keyword); + /* * Look for default keywords with no corresponding option... */ @@ -1246,22 +1229,6 @@ main(int argc, /* I - Number of command-line args */ attr->name); } - /* - * Check for old Duplex option names... - */ - - if ((option = ppdFindOption(ppd, "EFDuplex")) == NULL) - option = ppdFindOption(ppd, "KD03Duplex"); - - if (option) - { - _cupsLangPrintf(stdout, - _(" WARN Duplex option keyword %s " - "should be named Duplex or JCLDuplex!\n" - " REF: Page 122, section 5.17\n"), - option->keyword); - } - ppdMarkDefaults(ppd); if (ppdConflicts(ppd)) { @@ -1965,6 +1932,116 @@ check_constraints(ppd_file_t *ppd, /* I - PPD file */ /* + * 'check_case()' - Check that there are no duplicate groups, options, + * or choices that differ only by case. + */ + +static int /* O - Errors found */ +check_case(ppd_file_t *ppd, /* I - PPD file */ + int errors, /* I - Errors found */ + int verbose) /* I - Verbosity level */ +{ + int i, j; /* Looping vars */ + ppd_group_t *groupa, /* First group */ + *groupb; /* Second group */ + ppd_option_t *optiona, /* First option */ + *optionb; /* Second option */ + ppd_choice_t *choicea, /* First choice */ + *choiceb; /* Second choice */ + + + /* + * Check that the groups do not have any duplicate names... + */ + + for (i = ppd->num_groups, groupa = ppd->groups; i > 1; i --, groupa ++) + for (j = i - 1, groupb = groupa + 1; j > 0; j --, groupb ++) + if (!strcasecmp(groupa->name, groupb->name)) + { + if (!errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL\n")); + + if (verbose >= 0) + _cupsLangPrintf(stdout, + _(" **FAIL** Group names %s and %s differ only " + "by case!\n"), + groupa->name, groupb->name); + + errors ++; + } + + /* + * Check that the options do not have any duplicate names... + */ + + for (optiona = ppdFirstOption(ppd); optiona; optiona = ppdNextOption(ppd)) + { + cupsArraySave(ppd->options); + for (optionb = ppdNextOption(ppd); optionb; optionb = ppdNextOption(ppd)) + if (!strcasecmp(optiona->keyword, optionb->keyword)) + { + if (!errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL\n")); + + if (verbose >= 0) + _cupsLangPrintf(stdout, + _(" **FAIL** Option names %s and %s differ only " + "by case!\n"), + optiona->keyword, optionb->keyword); + + errors ++; + } + cupsArrayRestore(ppd->options); + + /* + * Then the choices... + */ + + for (i = optiona->num_choices, choicea = optiona->choices; + i > 1; + i --, choicea ++) + for (j = i - 1, choiceb = choicea + 1; j > 0; j --, choiceb ++) + if (!strcmp(choicea->choice, choiceb->choice)) + { + if (!errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL\n")); + + if (verbose >= 0) + _cupsLangPrintf(stdout, + _(" **FAIL** Multiple occurrences of %s " + "choice name %s!\n"), + optiona->keyword, choicea->choice); + + errors ++; + + choicea ++; + i --; + break; + } + else if (!strcasecmp(choicea->choice, choiceb->choice)) + { + if (!errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL\n")); + + if (verbose >= 0) + _cupsLangPrintf(stdout, + _(" **FAIL** %s choice names %s and %s " + "differ only by case!\n"), + optiona->keyword, choicea->choice, choiceb->choice); + + errors ++; + } + } + + /* + * Return the number of errors found... + */ + + return (errors); +} + + +/* * 'check_defaults()' - Check default option keywords in the PPD file. */ @@ -2032,6 +2109,76 @@ check_defaults(ppd_file_t *ppd, /* I - PPD file */ /* + * 'check_duplex()' - Check duplex keywords in the PPD file. + */ + +static int /* O - Errors found */ +check_duplex(ppd_file_t *ppd, /* I - PPD file */ + int errors, /* I - Error found */ + int verbose, /* I - Verbosity level */ + int warn) /* I - Warnings only? */ +{ + int i; /* Looping var */ + ppd_option_t *option; /* PPD option */ + ppd_choice_t *choice; /* Current choice */ + const char *prefix; /* Message prefix */ + + + prefix = warn ? " WARN " : "**FAIL**"; + + /* + * Check for a duplex option, and for standard values... + */ + + if ((option = ppdFindOption(ppd, "Duplex")) != NULL) + { + if (!ppdFindChoice(option, "None")) + { + if (verbose >= 0) + { + if (!warn && !errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL\n")); + + _cupsLangPrintf(stdout, + _(" %s REQUIRED %s does not define " + "choice None!\n" + " REF: Page 122, section 5.17\n"), + prefix, option->keyword); + } + + if (!warn) + errors ++; + } + + for (i = option->num_choices, choice = option->choices; + i > 0; + i --, choice ++) + if (strcmp(choice->choice, "None") && + strcmp(choice->choice, "DuplexNoTumble") && + strcmp(choice->choice, "DuplexTumble") && + strcmp(choice->choice, "SimplexTumble")) + { + if (verbose >= 0) + { + if (!warn && !errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL\n")); + + _cupsLangPrintf(stdout, + _(" %s Bad %s choice %s!\n" + " REF: Page 122, section 5.17\n"), + prefix, option->keyword, choice->choice); + } + + if (!warn) + errors ++; + } + } + + return (errors); +} + + +/* * 'check_filters()' - Check filters in the PPD file. */ @@ -2071,7 +2218,7 @@ check_filters(ppd_file_t *ppd, /* I - PPD file */ if (!warn) errors ++; } - else + else if (strcmp(program, "-")) { if (program[0] == '/') snprintf(pathprog, sizeof(pathprog), "%s%s", root, program); @@ -2122,7 +2269,7 @@ check_filters(ppd_file_t *ppd, /* I - PPD file */ if (!warn) errors ++; } - else + else if (strcmp(program, "-")) { if (program[0] == '/') snprintf(pathprog, sizeof(pathprog), "%s%s", root, program); @@ -2310,6 +2457,7 @@ check_translations(ppd_file_t *ppd, /* I - PPD file */ ppd_cparam_t *cparam; /* Custom parameter */ char ll[3]; /* Base language */ const char *prefix; /* WARN/FAIL prefix */ + const char *text; /* Pointer into UI text */ prefix = warn ? " WARN " : "**FAIL**"; @@ -2397,6 +2545,22 @@ check_translations(ppd_file_t *ppd, /* I - PPD file */ for (j = 0; j < option->num_choices; j ++) { + /* + * First see if this choice is a number; if so, don't require + * translation... + */ + + for (text = option->choices[j].text; *text; text ++) + if (!strchr("0123456789-+.", *text)) + break; + + if (!*text) + continue; + + /* + * Check custom choices differently... + */ + if (!strcasecmp(option->choices[j].choice, "Custom") && (coption = ppdFindCustomOption(ppd, option->keyword)) != NULL) @@ -2725,7 +2889,8 @@ usage(void) "Options:\n" "\n" " -R root-directory Set alternate root\n" - " -W {all,none,constraints,defaults,filters,translations}\n" + " -W {all,none,constraints,defaults,duplex,filters," + "translations}\n" " Issue warnings instead of errors\n" " -q Run silently\n" " -r Use 'relaxed' open mode\n" |