From c0bb0b26d9fd7959a2cbfadb73f1fb8d54386263 Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Sat, 5 Feb 2022 18:05:53 -0300 Subject: [PATCH] implicitclass: Do not check availability of "gs" and "pdftops" executables Instead, check by the presence of "gstoraster" and "pdftoraster" filters whether we have configured cups-filters for Ghostscript and/or Poppler use. Checking for the presence of an executable is too comlex, as we would need to go through the PATH environment variable. --- NEWS | 4 ++++ cupsfilters/pdftoippprinter.c | 42 +++++++++++++++++------------------ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/NEWS b/NEWS index 98a391a53..e883adbbd 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,10 @@ NEWS - OpenPrinting CUPS Filters v1.28.11 - 2022-01-15 CHANGES IN V1.28.12 + - implicitclass: Do not check availability of "gs" and + "pdftops" executables, instead, check by the presence of + "gstoraster" and "pdftoraster" filters whether we have + configured cups-filters for Ghostscript and/or Poppler use. - libcupsfilters: In the PPD generator for the driverless utility and cups-browsed add "*cupsFilter2: ..." lines for all supported driverless data formats (PDF, Apple/PWG diff --git a/cupsfilters/pdftoippprinter.c b/cupsfilters/pdftoippprinter.c index eaa4ad365..6927c6e67 100644 --- a/cupsfilters/pdftoippprinter.c +++ b/cupsfilters/pdftoippprinter.c @@ -284,12 +284,12 @@ apply_filters(int argc, char *argv[]) /* Page logging into page_log is not done by gstoraster/pdftoraster, so let it be done by pdftopdf */ set_option_in_str(argv_nt[5], optbuflen, "page-logging", "on"); - if (filter_present("gstoraster") && access(CUPS_GHOSTSCRIPT, X_OK) == 0) + if (filter_present("gstoraster")) cupsArrayAdd(filter_chain, "gstoraster"); else { fprintf(stderr, - "DEBUG: Filter gstoraster or Ghostscript (%s) missing for \"output-format=%s\", using pdftoraster.\n", - CUPS_GHOSTSCRIPT, val); + "DEBUG: Filter gstoraster missing for \"output-format=%s\", using pdftoraster.\n", + val); if (filter_present("pdftoraster")) cupsArrayAdd(filter_chain, "pdftoraster"); else { @@ -309,12 +309,12 @@ apply_filters(int argc, char *argv[]) /* Page logging into page_log is not done by gstoraster/pdftoraster, so let it be done by pdftopdf */ set_option_in_str(argv_nt[5], optbuflen, "page-logging", "on"); - if (filter_present("gstoraster") && access(CUPS_GHOSTSCRIPT, X_OK) == 0) + if (filter_present("gstoraster")) cupsArrayAdd(filter_chain, "gstoraster"); else { fprintf(stderr, - "DEBUG: Filter gstoraster or Ghostscript (%s) missing for \"output-format=%s\", using pdftoraster.\n", - CUPS_GHOSTSCRIPT, val); + "DEBUG: Filter gstoraster missing for \"output-format=%s\", using pdftoraster.\n", + val); if (filter_present("pdftoraster")) cupsArrayAdd(filter_chain, "pdftoraster"); else { @@ -346,16 +346,16 @@ apply_filters(int argc, char *argv[]) set_option_in_str(argv_nt[5], optbuflen, "page-logging", "off"); if (filter_present("pdftops")) { cupsArrayAdd(filter_chain, "pdftops"); - if (access(CUPS_GHOSTSCRIPT, X_OK) != 0) { + if (!filter_present("gstoraster")) { fprintf(stderr, - "DEBUG: Ghostscript (%s) missing for \"output-format=%s\", using Poppler's pdftops instead.\n", - CUPS_GHOSTSCRIPT, val); + "DEBUG: For \"output-format=%s\" using only Poppler's pdftops as we have no Ghostscript support.\n", + val); set_option_in_str(argv_nt[5], optbuflen, "pdftops-renderer", "pdftops"); - } else if (access(CUPS_POPPLER_PDFTOPS, X_OK) != 0) { + } else if (!filter_present("pdftoraster")) { fprintf(stderr, - "DEBUG: Poppler's pdftops (%s) missing for \"output-format=%s\", using Ghostscript instead.\n", - CUPS_POPPLER_PDFTOPS, val); + "DEBUG: For \"output-format=%s\", using only Ghostscript as we have no Poppler support.\n", + val); set_option_in_str(argv_nt[5], optbuflen, "pdftops-renderer", "gs"); } else @@ -371,15 +371,15 @@ apply_filters(int argc, char *argv[]) } else if ((p = strcasestr(val, "pcl")) != NULL) { if (!strcasecmp(p, "pclxl")) { output_format = PCLXL; - if (filter_present("gstopxl") && access(CUPS_GHOSTSCRIPT, X_OK) == 0) { + if (filter_present("gstopxl")) { cupsArrayAdd(filter_chain, "gstopxl"); /* Page logging into page_log is not done by gstopxl, so let it be done by pdftopdf */ set_option_in_str(argv_nt[5], optbuflen, "page-logging", "on"); } else { fprintf(stderr, - "DEBUG: Filter gstopxl or Ghostscript (%s) missing for \"output-format=%s\", falling back to PCL 5c/e.\n", - CUPS_GHOSTSCRIPT, val); + "DEBUG: Filter gstopxl missing for \"output-format=%s\", falling back to PCL 5c/e.\n", + val); output_format = PCL; } } else if (!strcasecmp(p, "pclm")) { @@ -390,12 +390,12 @@ apply_filters(int argc, char *argv[]) /* Page logging into page_log is not done by gstoraster/pdftoraster, so let it be done by pdftopdf */ set_option_in_str(argv_nt[5], optbuflen, "page-logging", "on"); - if (filter_present("gstoraster") && access(CUPS_GHOSTSCRIPT, X_OK) == 0) + if (filter_present("gstoraster")) cupsArrayAdd(filter_chain, "gstoraster"); else { fprintf(stderr, - "DEBUG: Filter gstoraster or Ghostscript (%s) missing for \"output-format=%s\", using pdftoraster.\n", - CUPS_GHOSTSCRIPT, val); + "DEBUG: Filter gstoraster missing for \"output-format=%s\", using pdftoraster.\n", + val); if (filter_present("pdftoraster")) cupsArrayAdd(filter_chain, "pdftoraster"); else { @@ -471,12 +471,12 @@ apply_filters(int argc, char *argv[]) /* Set RGB as color mode */ set_option_in_str(argv_nt[5], optbuflen, "print-color-mode", "RGB"); } - if (filter_present("gstoraster") && access(CUPS_GHOSTSCRIPT, X_OK) == 0) + if (filter_present("gstoraster")) cupsArrayAdd(filter_chain, "gstoraster"); else { fprintf(stderr, - "DEBUG: Filter gstoraster or Ghostscript (%s) missing for \"output-format=%s\", using pdftoraster.\n", - CUPS_GHOSTSCRIPT, val); + "DEBUG: Filter gstoraster missing for \"output-format=%s\", using pdftoraster.\n", + val); if (filter_present("pdftoraster")) cupsArrayAdd(filter_chain, "pdftoraster"); else { -- 2.47.3