From: mike Date: Tue, 16 Aug 2011 23:49:31 +0000 (+0000) Subject: Several programs did not support the cupsFilter2 keyword in PPD files. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f7aaa87349911d375a5f6737547795d5163aabda;p=thirdparty%2Fcups.git Several programs did not support the cupsFilter2 keyword in PPD files. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@9898 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/CHANGES.txt b/CHANGES.txt index 11b0ef009..7d23f7726 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,7 @@ CHANGES.txt - 2011-08-11 CHANGES IN CUPS V1.5.1 - Documentation updates (STR #3885) + - Several programs did not support the cupsFilter2 keyword in PPD files. - The IPP backend incorrectly reported spool-area-full states. - cupsMarkOptions() did not protect against a bad PPD that was missing one or more standard Duplex options. diff --git a/cgi-bin/admin.c b/cgi-bin/admin.c index 99b8e7b48..f14e6d504 100644 --- a/cgi-bin/admin.c +++ b/cgi-bin/admin.c @@ -3354,10 +3354,22 @@ do_set_options(http_t *http, /* I - HTTP connection */ if (ppd) { - if (ppd->num_filters == 0 || + if ((ppd->num_filters == 0 && !ppdFindAttr(ppd, "cupsFilter2", NULL)) || ((ppdattr = ppdFindAttr(ppd, "cupsCommands", NULL)) != NULL && ppdattr->value && strstr(ppdattr->value, "AutoConfigure"))) cgiSetVariable("HAVE_AUTOCONFIGURE", "YES"); + else if ((ppdattr = ppdFindAttr(ppd, "cupsFilter2", NULL)) != NULL) + { + do + { + if (!strncmp(ppdattr->value, "application/vnd.cups-postscript", 31)) + { + cgiSetVariable("HAVE_AUTOCONFIGURE", "YES"); + break; + } + } + while ((ppdattr = ppdFindNextAttr(ppd, "cupsFilter2", NULL)) != NULL); + } else { for (i = 0; i < ppd->num_filters; i ++) diff --git a/cups/emit.c b/cups/emit.c index 9e871c21e..b63745280 100644 --- a/cups/emit.c +++ b/cups/emit.c @@ -558,7 +558,7 @@ ppdEmitJCLEnd(ppd_file_t *ppd, /* I - PPD file record */ if (!ppd->jcl_end) { - if (ppd->num_filters == 0) + if ((ppd->num_filters == 0 && !ppdFindAttr(ppd, "cupsFilter2", NULL))) putc(0x04, fp); return (0); @@ -1165,7 +1165,7 @@ ppd_handle_media(ppd_file_t *ppd) /* I - PPD file */ (!manual_feed && !input_slot) || (manual_feed && !_cups_strcasecmp(manual_feed->choice, "False") && (!input_slot || (input_slot->code && !input_slot->code[0]))) || - (!rpr && ppd->num_filters > 0)) + (!rpr && (ppd->num_filters > 0 || ppdFindAttr(ppd, "cupsFilter2", NULL)))) { /* * Use PageSize code... diff --git a/filter/imagetops.c b/filter/imagetops.c index 3662fdb32..1f51e459a 100644 --- a/filter/imagetops.c +++ b/filter/imagetops.c @@ -811,7 +811,8 @@ main(int argc, /* I - Number of command-line arguments */ for (xpage = 0; xpage < xpages; xpage ++) for (ypage = 0; ypage < ypages; ypage ++, page ++) { - if (ppd && ppd->num_filters == 0) + if (ppd && + ppd->num_filters == 0 && !ppdFindAttr(ppd, "cupsFilter2", NULL)) fprintf(stderr, "PAGE: %d %d\n", page, realcopies); _cupsLangPrintFilter(stderr, "INFO", _("Printing page %d."), page); diff --git a/filter/pstops.c b/filter/pstops.c index 148f99410..993adf90c 100644 --- a/filter/pstops.c +++ b/filter/pstops.c @@ -923,7 +923,8 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */ if (!doc->slow_order) { - if (!ppd || !ppd->num_filters) + if (!ppd || + (ppd->num_filters == 0 && !ppdFindAttr(ppd, "cupsFilter2", NULL))) fprintf(stderr, "PAGE: %d %d\n", doc->page, doc->slow_collate ? 1 : doc->copies); @@ -1028,7 +1029,8 @@ copy_dsc(cups_file_t *fp, /* I - File to read from */ number ++; - if (!ppd || !ppd->num_filters) + if (!ppd || + (ppd->num_filters == 0 && !ppdFindAttr(ppd, "cupsFilter2", NULL))) fprintf(stderr, "PAGE: %d %d\n", number, doc->slow_collate ? 1 : doc->copies); @@ -1171,7 +1173,7 @@ copy_non_dsc(cups_file_t *fp, /* I - File to read from */ * Finally, embed a copy of the file inside a %%Page... */ - if (!ppd || !ppd->num_filters) + if (!ppd || (ppd->num_filters == 0 && !ppdFindAttr(ppd, "cupsFilter2", NULL))) fprintf(stderr, "PAGE: 1 %d\n", doc->temp ? 1 : doc->copies); puts("%%Page: 1 1"); @@ -1220,7 +1222,8 @@ copy_non_dsc(cups_file_t *fp, /* I - File to read from */ if (JobCanceled) break; - if (!ppd || !ppd->num_filters) + if (!ppd || + (ppd->num_filters == 0 && !ppdFindAttr(ppd, "cupsFilter2", NULL))) fputs("PAGE: 1 1\n", stderr); printf("%%%%Page: %d %d\n", copy + 1, copy + 1); @@ -1524,7 +1527,8 @@ copy_page(cups_file_t *fp, /* I - File to read from */ if (!doc->slow_order && first_page) { - if (!ppd || !ppd->num_filters) + if (!ppd || + (ppd->num_filters == 0 && !ppdFindAttr(ppd, "cupsFilter2", NULL))) fprintf(stderr, "PAGE: %d %d\n", doc->page, doc->slow_collate ? 1 : doc->copies); diff --git a/monitor/bcp.c b/monitor/bcp.c index 2354d102d..97f113b7e 100644 --- a/monitor/bcp.c +++ b/monitor/bcp.c @@ -138,7 +138,8 @@ main(int argc, /* I - Number of command-line args */ if (ppd && ppd->jcl_end) fputs(ppd->jcl_end, stdout); - else if (!ppd || ppd->num_filters == 0) + else if (!ppd || + (ppd->num_filters == 0 && !ppdFindAttr(ppd, "cupsFilter2", NULL))) putchar(0x04); /* diff --git a/systemv/cupstestppd.c b/systemv/cupstestppd.c index 09cd39228..c498bdb87 100644 --- a/systemv/cupstestppd.c +++ b/systemv/cupstestppd.c @@ -439,13 +439,29 @@ main(int argc, /* I - Number of command-line args */ attr->value) ppdversion = (int)(10 * _cupsStrScand(attr->value, NULL, loc) + 0.5); - for (j = 0; j < ppd->num_filters; j ++) - if (strstr(ppd->filters[j], "application/vnd.cups-raster")) - { - if (!test_raster(ppd, verbose)) - errors ++; - break; + if ((attr = ppdFindAttr(ppd, "cupsFilter2", NULL)) != NULL) + { + do + { + if (strstr(attr->value, "application/vnd.cups-raster")) + { + if (!test_raster(ppd, verbose)) + errors ++; + break; + } } + while ((attr = ppdFindNextAttr(ppd, "cupsFilter2", NULL)) != NULL); + } + else + { + for (j = 0; j < ppd->num_filters; j ++) + if (strstr(ppd->filters[j], "application/vnd.cups-raster")) + { + if (!test_raster(ppd, verbose)) + errors ++; + break; + } + } /* * Look for default keywords with no matching option... @@ -2309,6 +2325,8 @@ check_filters(ppd_file_t *ppd, /* I - PPD file */ const char *ptr; /* Pointer into string */ char super[16], /* Super-type for filter */ type[256], /* Type for filter */ + dstsuper[16], /* Destination super-type for filter */ + dsttype[256], /* Destination type for filter */ program[1024], /* Program/filter name */ pathprog[1024]; /* Complete path to program/filter */ int cost; /* Cost of filter */ @@ -2387,6 +2405,102 @@ check_filters(ppd_file_t *ppd, /* I - PPD file */ } } + /* + * cupsFilter + */ + + for (attr = ppdFindAttr(ppd, "cupsFilter2", NULL); + attr; + attr = ppdFindNextAttr(ppd, "cupsFilter2", NULL)) + { + if (strcmp(attr->name, "cupsFilter2")) + { + if (!warn && !errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL")); + + if (verbose >= 0) + _cupsLangPrintf(stdout, + _(" %s Bad spelling of %s - should be %s."), + prefix, attr->name, "cupsFilter2"); + + if (!warn) + errors ++; + } + + if (!attr->value || + sscanf(ppd->filters[i], "%15[^/]/%255s%15[^/]/%255s%d%*[ \t]%1023[^\n]", + super, type, dstsuper, dsttype, &cost, program) != 6) + { + if (!warn && !errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL")); + + if (verbose >= 0) + _cupsLangPrintf(stdout, + _(" %s Bad cupsFilter2 value \"%s\"."), + prefix, ppd->filters[i]); + + if (!warn) + errors ++; + } + else if (strcmp(program, "-")) + { + if (strncmp(program, "maxsize(", 8) && + (ptr = strchr(program + 8, ')')) != NULL) + { + ptr ++; + while (_cups_isspace(*ptr)) + ptr ++; + + _cups_strcpy(program, ptr); + } + + if (program[0] == '/') + snprintf(pathprog, sizeof(pathprog), "%s%s", root, program); + else + { + if ((ptr = getenv("CUPS_SERVERBIN")) == NULL) + ptr = CUPS_SERVERBIN; + + if (*ptr == '/' || !*root) + snprintf(pathprog, sizeof(pathprog), "%s%s/filter/%s", root, ptr, + program); + else + snprintf(pathprog, sizeof(pathprog), "%s/%s/filter/%s", root, ptr, + program); + } + + if (stat(pathprog, &fileinfo)) + { + if (!warn && !errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL")); + + if (verbose >= 0) + _cupsLangPrintf(stdout, _(" %s Missing %s file \"%s\"."), + prefix, "cupsFilter2", pathprog); + + if (!warn) + errors ++; + } + else if (fileinfo.st_uid != 0 || + (fileinfo.st_mode & MODE_WRITE) || + (fileinfo.st_mode & MODE_MASK) != MODE_PROGRAM) + { + if (!warn && !errors && !verbose) + _cupsLangPuts(stdout, _(" FAIL")); + + if (verbose >= 0) + _cupsLangPrintf(stdout, + _(" %s Bad permissions on %s file \"%s\"."), + prefix, "cupsFilter2", pathprog); + + if (!warn) + errors ++; + } + else + errors = valid_path("cupsFilter2", pathprog, errors, verbose, warn); + } + } + /* * cupsPreFilter */