diff options
author | Till Kamppeter <till.kamppeter@gmail.com> | 2016-09-18 23:48:52 -0300 |
---|---|---|
committer | Till Kamppeter <till.kamppeter@gmail.com> | 2016-09-18 23:48:52 -0300 |
commit | 380256be36bc415c9ab10943b3588a3dd585e7b2 (patch) | |
tree | fab4906e36640794d44a11a5086fbb310cf1ee1f /filter | |
parent | 22f1bb4f0dc74ac408223750d0e2e42712cb866b (diff) |
Imported Upstream version 1.11.3
Diffstat (limited to 'filter')
-rw-r--r-- | filter/banner.c | 11 | ||||
-rw-r--r-- | filter/foomatic-rip/foomatic-rip.1 | 11 | ||||
-rw-r--r-- | filter/foomatic-rip/foomatic-rip.1.in | 11 | ||||
-rw-r--r-- | filter/foomatic-rip/foomaticrip.c | 44 | ||||
-rw-r--r-- | filter/foomatic-rip/options.c | 6 | ||||
-rw-r--r-- | filter/foomatic-rip/spooler.c | 6 | ||||
-rw-r--r-- | filter/gstoraster.c | 13 | ||||
-rw-r--r-- | filter/mupdftoraster.c | 7 | ||||
-rw-r--r-- | filter/pdftoopvp/pdftoopvp.cxx | 5 | ||||
-rw-r--r-- | filter/pdftoraster.cxx | 5 |
10 files changed, 70 insertions, 49 deletions
diff --git a/filter/banner.c b/filter/banner.c index a8230b73a..752ca026c 100644 --- a/filter/banner.c +++ b/filter/banner.c @@ -109,14 +109,19 @@ static unsigned parse_show(char *s) static char * template_path(const char *name) { - char *result; + char *datadir, *result; size_t len; if (name[0] == '/') return strdup(name); - result = malloc(strlen(BANNERTOPDF_DATADIR) + strlen(name) + 2); - sprintf(result, "%s/%s", BANNERTOPDF_DATADIR, name); + if ((datadir = getenv("CUPS_DATADIR")) == NULL) { + result = malloc(strlen(BANNERTOPDF_DATADIR) + strlen(name) + 2); + sprintf(result, "%s/%s", BANNERTOPDF_DATADIR, name); + } else { + result = malloc(strlen(datadir) + strlen(name) + 7); + sprintf(result, "%s/data/%s", datadir, name); + } return result; } diff --git a/filter/foomatic-rip/foomatic-rip.1 b/filter/foomatic-rip/foomatic-rip.1 index bb753af16..8a6949534 100644 --- a/filter/foomatic-rip/foomatic-rip.1 +++ b/filter/foomatic-rip/foomatic-rip.1 @@ -148,10 +148,11 @@ http://www.openprinting.org/ .SH "CONFIGURATION FILE" -The file \fB/etc/foomatic/filter.conf\fR is read whenever -foomatic-rip is executed. It allows to configure the behavior of -foomatic-rip as follows (lines beginning with \fB#\fR are comments and -therefore get ignored): +The file \fB/etc/cups/foomatic-rip.conf\fR or if it is not +readable the file \fB/etc/foomatic/filter.conf\fR is read +whenever foomatic-rip is executed. It allows to configure the behavior +of foomatic-rip as follows (lines beginning with \fB#\fR are comments +and therefore get ignored): .TP 10 .B debug: 0|1 @@ -194,6 +195,8 @@ modern shell like \fBbash\fR, \fBzsh\fR, or \fBksh\fR. The PPD files of the currently defined printers .TP 0 +/etc/cups/foomatic-rip.conf +.TP 0 /etc/foomatic/filter.conf Configuration file for foomatic-rip diff --git a/filter/foomatic-rip/foomatic-rip.1.in b/filter/foomatic-rip/foomatic-rip.1.in index db9d0b7a9..fc6d277b6 100644 --- a/filter/foomatic-rip/foomatic-rip.1.in +++ b/filter/foomatic-rip/foomatic-rip.1.in @@ -148,10 +148,11 @@ http://www.openprinting.org/ .SH "CONFIGURATION FILE" -The file \fB@sysconfdir@/foomatic/filter.conf\fR is read whenever -foomatic-rip is executed. It allows to configure the behavior of -foomatic-rip as follows (lines beginning with \fB#\fR are comments and -therefore get ignored): +The file \fB@sysconfdir@/cups/foomatic-rip.conf\fR or if it is not +readable the file \fB@sysconfdir@/foomatic/filter.conf\fR is read +whenever foomatic-rip is executed. It allows to configure the behavior +of foomatic-rip as follows (lines beginning with \fB#\fR are comments +and therefore get ignored): .TP 10 .B debug: 0|1 @@ -194,6 +195,8 @@ modern shell like \fBbash\fR, \fBzsh\fR, or \fBksh\fR. The PPD files of the currently defined printers .TP 0 +@sysconfdir@/cups/foomatic-rip.conf +.TP 0 @sysconfdir@/foomatic/filter.conf Configuration file for foomatic-rip diff --git a/filter/foomatic-rip/foomaticrip.c b/filter/foomatic-rip/foomaticrip.c index 1457ebb5e..79d74bfd6 100644 --- a/filter/foomatic-rip/foomaticrip.c +++ b/filter/foomatic-rip/foomaticrip.c @@ -152,11 +152,13 @@ char cupsfilter[256]; char **jclprepend = NULL; dstr_t *jclappend; -/* Set debug to 1 to enable the debug logfile for this filter; it will appear - * as defined by LOG_FILE. It will contain status from this filter, plus the - * renderer's stderr output. You can also add a line "debug: 1" to your - * /etc/foomatic/filter.conf to get all your Foomatic filters into debug mode. - * WARNING: This logfile is a security hole; do not use in production. */ +/* Set debug to 1 to enable the debug logfile for this filter; it will + * appear as defined by LOG_FILE. It will contain status from this + * filter, plus the renderer's stderr output. You can also add a line + * "debug: 1" to your /etc/cups/foomatic-rip.conf or + * /etc/foomatic/filter.conf to get all your Foomatic filters into + * debug mode. WARNING: This logfile is a security hole; do not use + * in production. */ int debug = 0; /* Path to the GhostScript which foomatic-rip shall use */ @@ -198,7 +200,7 @@ void config_set_option(const char *key, const char *value) strlcpy(echopath, value, PATH_MAX); } -void config_from_file(const char *filename) +int config_from_file(const char *filename) { FILE *fh; char line[256]; @@ -206,7 +208,7 @@ void config_from_file(const char *filename) fh = fopen(filename, "r"); if (fh == NULL) - return; /* no error here, only read config file if it is present */ + return 0; while (fgets(line, 256, fh) != NULL) { @@ -217,6 +219,8 @@ void config_from_file(const char *filename) config_set_option(key, value); } fclose(fh); + + return 1; } const char * get_modern_shell() @@ -721,7 +725,6 @@ int main(int argc, char** argv) const char* str; char *p, *filename; const char *path; - FILE *ppdfh = NULL; char tmp[1024], gstoraster[256]; int havefilter, havegstoraster; dstr_t *filelist; @@ -749,8 +752,16 @@ int main(int argc, char** argv) signal(SIGTERM, signal_terminate); signal(SIGINT, signal_terminate); - - config_from_file(CONFIG_PATH "/filter.conf"); + /* First try to find a config file in the CUS config directory, like + /etc/cups/foomatic-rip.conf */ + i = 0; + if ((str = getenv("CUPS_SERVERROOT")) != NULL) { + snprintf(tmp, sizeof(tmp), "%s/foomatic-rip.conf", str); + i = config_from_file(tmp); + } + /* If there is none, fall back to /etc/foomatic/filter.conf */ + if (i == 0) + i = config_from_file(CONFIG_PATH "/filter.conf"); /* Command line options for verbosity */ if (arglist_remove_flag(arglist, "-v")) @@ -800,6 +811,9 @@ int main(int argc, char** argv) if (getenv("PPD")) { strncpy(job->ppdfile, getenv("PPD"), 256); spooler = SPOOLER_CUPS; + if (getenv("CUPS_SERVERBIN")) + strncpy(cupsfilterpath, getenv("CUPS_SERVERBIN"), + sizeof(cupsfilterpath)); } /* Check status of printer color management from the color manager */ @@ -915,10 +929,12 @@ int main(int argc, char** argv) /* PPD File */ /* Load the PPD file and build a data structure for the renderer's command line and the options */ - if (!(ppdfh = fopen(job->ppdfile, "r"))) - rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS, "Unable to open PPD file %s\n", job->ppdfile); - - read_ppd_file(job->ppdfile); + if (spooler == SPOOLER_CUPS && job->printer && strlen(job->printer) > 0) { + str = cupsGetPPD(job->printer); + read_ppd_file(str); + unlink(str); + } else + read_ppd_file(job->ppdfile); /* We do not need to parse the PostScript job when we don't have any options. If we have options, we must check whether the diff --git a/filter/foomatic-rip/options.c b/filter/foomatic-rip/options.c index 8a784d85d..325a0a626 100644 --- a/filter/foomatic-rip/options.c +++ b/filter/foomatic-rip/options.c @@ -1566,10 +1566,8 @@ void read_ppd_file(const char *filename) icc_mapping_entry_t *entry; fh = fopen(filename, "r"); - if (!fh) { - _log("error opening %s\n", filename); - exit(EXIT_PRNERR_NORETRY_BAD_SETTINGS); - } + if (!fh) + rip_die(EXIT_PRNERR_NORETRY_BAD_SETTINGS, "Unable to open PPD file %s\n", filename); _log("Parsing PPD file ...\n"); dstrassure(value, 256); diff --git a/filter/foomatic-rip/spooler.c b/filter/foomatic-rip/spooler.c index 9a05f2b28..5b4a4272c 100644 --- a/filter/foomatic-rip/spooler.c +++ b/filter/foomatic-rip/spooler.c @@ -89,9 +89,9 @@ void init_cups(list_t *arglist, dstr_t *filelist, jobparams_t *job) } /* On which queue are we printing? - CUPS gives the PPD file the same name as the printer queue, - so we can get the queue name from the name of the PPD file. */ - file_basename(job->printer, job->ppdfile, 256); + CUPS puts the print queue name into the PRINTER environment variable + when calling filters. */ + strncpy(job->printer, getenv("PRINTER"), 256); free(cups_options); } diff --git a/filter/gstoraster.c b/filter/gstoraster.c index cbe72d9b1..8488fe54e 100644 --- a/filter/gstoraster.c +++ b/filter/gstoraster.c @@ -50,13 +50,6 @@ MIT Open Source License - http://www.opensource.org/ #define PDF_MAX_CHECK_COMMENT_LINES 20 -#ifndef CUPS_FONTPATH -#define CUPS_FONTPATH "/usr/share/cups/fonts" -#endif -#ifndef CUPSDATA -#define CUPSDATA "/usr/share/cups" -#endif - typedef enum { GS_DOC_TYPE_PDF, GS_DOC_TYPE_PS, @@ -561,6 +554,7 @@ get_ppd_icc_fallback (ppd_file_t *ppd, char **qualifier) char qualifer_tmp[1024]; const char *profile_key; ppd_attr_t *attr; + char *datadir; /* get profile attr, falling back to CUPS */ profile_key = "APTiogaProfile"; @@ -583,6 +577,9 @@ get_ppd_icc_fallback (ppd_file_t *ppd, char **qualifier) goto out; } + if ((datadir = getenv("CUPS_DATADIR")) == NULL) + datadir = CUPS_DATADIR; + /* try to find a profile that matches the qualifier exactly */ for (;attr != NULL; attr = ppdFindNextAttr(ppd, profile_key, NULL)) { fprintf(stderr, "INFO: found profile %s in PPD with qualifier '%s'\n", @@ -595,7 +592,7 @@ get_ppd_icc_fallback (ppd_file_t *ppd, char **qualifier) /* expand to a full path if not already specified */ if (attr->value[0] != '/') snprintf(full_path, sizeof(full_path), - "%s/profiles/%s", CUPSDATA, attr->value); + "%s/profiles/%s", datadir, attr->value); else strncpy(full_path, attr->value, sizeof(full_path)); diff --git a/filter/mupdftoraster.c b/filter/mupdftoraster.c index ac1def8c7..96bfce4cd 100644 --- a/filter/mupdftoraster.c +++ b/filter/mupdftoraster.c @@ -52,13 +52,6 @@ MIT Open Source License - http://www.opensource.org/ #define PDF_MAX_CHECK_COMMENT_LINES 20 -#ifndef CUPS_FONTPATH -#define CUPS_FONTPATH "/usr/share/cups/fonts" -#endif -#ifndef CUPSDATA -#define CUPSDATA "/usr/share/cups" -#endif - #define CUPS_IPTEMPFILE "/tmp/ip-XXXXXX" #define CUPS_OPTEMPFILE "/tmp/op-XXXXXX" diff --git a/filter/pdftoopvp/pdftoopvp.cxx b/filter/pdftoopvp/pdftoopvp.cxx index e1eef8a61..a4e40c511 100644 --- a/filter/pdftoopvp/pdftoopvp.cxx +++ b/filter/pdftoopvp/pdftoopvp.cxx @@ -156,6 +156,7 @@ static GBool getColorProfilePath(ppd_file_t *ppd, GooString *path) const char *cupsICCQualifier3Choice; ppd_attr_t *attr; ppd_choice_t *choice; + char *datadir; if ((attr = ppdFindAttr(ppd,"ColorModel",NULL)) != NULL) { colorModel = attr->value; @@ -220,7 +221,9 @@ static GBool getColorProfilePath(ppd_file_t *ppd, GooString *path) // matched path->clear(); if (attr->value[0] != '/') { - path->append(CUPS_DATADIR); + if ((datadir = getenv("CUPS_DATADIR")) == NULL) + datadir = CUPS_DATADIR; + path->append(datadir); path->append("/profiles/"); } path->append(attr->value); diff --git a/filter/pdftoraster.cxx b/filter/pdftoraster.cxx index 926d78671..2db93f8ac 100644 --- a/filter/pdftoraster.cxx +++ b/filter/pdftoraster.cxx @@ -374,6 +374,7 @@ static GBool getColorProfilePath(ppd_file_t *ppd, GooString *path) // check color model char buf[PPD_MAX_NAME]; char *p, *r; + char *datadir; strncpy(buf,attr->spec,sizeof(buf)); if ((p = strchr(buf,'.')) != NULL) { @@ -406,7 +407,9 @@ static GBool getColorProfilePath(ppd_file_t *ppd, GooString *path) // matched path->clear(); if (attr->value[0] != '/') { - path->append(CUPS_DATADIR); + if ((datadir = getenv("CUPS_DATADIR")) == NULL) + datadir = CUPS_DATADIR; + path->append(datadir); path->append("/profiles/"); } path->append(attr->value); |