]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters, mupdftoraster, mupdftopwg: Renamed filter function
authorTill Kamppeter <till.kamppeter@gmail.com>
Mon, 4 Apr 2022 13:39:43 +0000 (15:39 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Mon, 4 Apr 2022 13:39:43 +0000 (15:39 +0200)
Renamed the filter function mupdftoraster() and the corresponding CUPS
filter to mupdftopwg(). This is because the "mutool" utility of MuPDF
only supports PWG Raster output, no CUPS Raster and no Apple Raster.

It also does not make the impression that this will change anytime
soon, as this is already this way for many years and there is also no
feature request posted asking for adding the other formats.

This way it is easily communicated that the filter function has to be
followed by the pwgtoraster() filter function to get CUPS Raster.

Note that the "outformat" parameter (the CUPS filter feeds in the
value of the FINAL_CONTENT_TYPE environment variable here) does not
change the actual output format (PWG Raster) of mupdftopwg(), it is
only to tell the final output format of the print job, so that
mupdftopwg() can grab color space, color depth, and resolution info
for this final format from the PPD file (or from the printer IPP
attributes) and call "mutool" according to this format.

Makefile.am
cupsfilters/filter.h
cupsfilters/mupdftopwg.c [moved from cupsfilters/mupdftoraster.c with 88% similarity]
cupsfilters/pdftopdf/pdftopdf.cc
filter/mupdftopwg.c [moved from filter/mupdftoraster.c with 88% similarity]
mime/cupsfilters-mupdf.convs

index 15b71b73cefe78244cd45750b3e38995c375041c..0bfe5468d215468b6b40b077a24a602665baeff3 100644 (file)
@@ -471,7 +471,7 @@ libcupsfilters_la_SOURCES = \
        cupsfilters/imagetoraster.c \
        cupsfilters/ipp.c \
        cupsfilters/lut.c \
-       cupsfilters/mupdftoraster.c \
+       cupsfilters/mupdftopwg.c \
        cupsfilters/pack.c \
        cupsfilters/pclmtoraster.cxx \
        cupsfilters/pdf.cxx \
@@ -864,7 +864,7 @@ pkgfilter_PROGRAMS += \
 endif
 if ENABLE_MUTOOL
 pkgfilter_PROGRAMS += \
-       mupdftoraster
+       mupdftopwg
 endif
 if ENABLE_IMAGEFILTERS
 pkgfilter_PROGRAMS += \
@@ -1031,13 +1031,13 @@ rastertopdf_LDADD = \
        $(CUPS_LIBS) \
        libcupsfilters.la
 
-mupdftoraster_SOURCES = \
-       filter/mupdftoraster.c
-mupdftoraster_CFLAGS = \
+mupdftopwg_SOURCES = \
+       filter/mupdftopwg.c
+mupdftopwg_CFLAGS = \
        $(CUPS_CFLAGS) \
        -I$(srcdir)/cupsfilters/ \
        -I$(srcdir)/ppd/
-mupdftoraster_LDADD = \
+mupdftopwg_LDADD = \
        $(CUPS_LIBS) \
        libcupsfilters.la \
        libppd.la
index 1d0d4601475e32a4c713cb52798f496f74755a52..e7c345b47ba45810e356b5fdb49683add91d46fb 100644 (file)
@@ -267,7 +267,7 @@ extern int imagetoraster(int inputfd,
    this filter function. */
 
 
-extern int mupdftoraster(int inputfd,
+extern int mupdftopwg(int inputfd,
                         int outputfd,
                         int inputseekable,
                         filter_data_t *data,
similarity index 88%
rename from cupsfilters/mupdftoraster.c
rename to cupsfilters/mupdftopwg.c
index 8c3d431258a4630e76d6242617e165d915058dd7..899a223607715a0173d1bcc00565abde9d414895 100644 (file)
@@ -79,7 +79,7 @@ parse_doc_type(FILE *fp, filter_logfunc_t log, void *ld)
   if (strncmp(buf,"%PDF",4) == 0)
     return 0;
 
-  if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "mupdftoraster: input file cannot be identified");
+  if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "mupdftopwg: input file cannot be identified");
   return -1;
 }
 
@@ -205,7 +205,7 @@ mutool_spawn (const char *filename,
 
   if (log) {
     /* Debug output: Full mutool command line and environment variables */
-    snprintf(buf, sizeof(buf), "mupdftoraster: mutool command line:");
+    snprintf(buf, sizeof(buf), "mupdftopwg: mutool command line:");
     for (i = 0; mutoolargv[i]; i ++) {
       if ((strchr(mutoolargv[i],' ')) || (strchr(mutoolargv[i],'\t')))
        apos = "'";
@@ -223,7 +223,7 @@ mutool_spawn (const char *filename,
     errfds[0] = -1;
     errfds[1] = -1;
     if (log) log(ld, FILTER_LOGLEVEL_ERROR,
-                "mupdftoraster: Unable to establish stderr pipe for mutool "
+                "mupdftopwg: Unable to establish stderr pipe for mutool "
                 "call");
     goto out;
   }
@@ -236,7 +236,7 @@ mutool_spawn (const char *filename,
     errfds[0] = -1;
     errfds[1] = -1;
     if (log) log(ld, FILTER_LOGLEVEL_ERROR,
-                "mupdftoraster: Unable to set \"close on exec\" flag on read "
+                "mupdftopwg: Unable to set \"close on exec\" flag on read "
                 "end of the stderr pipe for mutool call");
     goto out;
   }
@@ -245,7 +245,7 @@ mutool_spawn (const char *filename,
     close(errfds[0]);
     close(errfds[1]);
     if (log) log(ld, FILTER_LOGLEVEL_ERROR,
-                "mupdftoraster: Unable to set \"close on exec\" flag on write "
+                "mupdftopwg: Unable to set \"close on exec\" flag on write "
                 "end of the stderr pipe for mutool call");
     goto out;
   }
@@ -257,7 +257,7 @@ mutool_spawn (const char *filename,
       if (errfds[1] != 2) {
        if (dup2(errfds[1], 2) < 0) {
          if (log) log(ld, FILTER_LOGLEVEL_ERROR,
-                      "mupdftoraster: Unable to couple pipe with stderr of "
+                      "mupdftopwg: Unable to couple pipe with stderr of "
                       "mutool process");
          exit(1);
        }
@@ -266,7 +266,7 @@ mutool_spawn (const char *filename,
       close(errfds[0]);
     } else {
       if (log) log(ld, FILTER_LOGLEVEL_ERROR,
-                  "mupdftoraster: invalid pipe file descriptor to couple with "
+                  "mupdftopwg: invalid pipe file descriptor to couple with "
                   "stderr of mutool process");
       exit(1);
     }
@@ -276,7 +276,7 @@ mutool_spawn (const char *filename,
       if (outputfd != 1) {
        if (dup2(outputfd, 1) < 0) {
          if (log) log(ld, FILTER_LOGLEVEL_ERROR,
-                      "mupdftoraster: Unable to couple stdout of mutool "
+                      "mupdftopwg: Unable to couple stdout of mutool "
                       "process");
          exit(1);
        }
@@ -284,7 +284,7 @@ mutool_spawn (const char *filename,
       }
     } else {
       if (log) log(ld, FILTER_LOGLEVEL_ERROR,
-                  "mupdftoraster: Invalid file descriptor to couple with "
+                  "mupdftopwg: Invalid file descriptor to couple with "
                   "stdout of mutool process");
       exit(1);
     }
@@ -292,12 +292,12 @@ mutool_spawn (const char *filename,
     /* Execute mutool command line ... */
     execvp(filename, mutoolargv);
     if (log) log(ld, FILTER_LOGLEVEL_ERROR,
-                "mupdftoraster: Unable to launch mutool: %s: %s", filename,
+                "mupdftopwg: Unable to launch mutool: %s: %s", filename,
                 strerror(errno));
     exit(1);
   }
   if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
-              "mupdftoraster: Started mutool (PID %d)", mutoolpid);
+              "mupdftopwg: Started mutool (PID %d)", mutoolpid);
 
   close(errfds[1]);
 
@@ -325,7 +325,7 @@ mutool_spawn (const char *filename,
          log_level = FILTER_LOGLEVEL_DEBUG;
          msg = buf;
        }
-       log(ld, log_level, "mupdftoraster: %s", msg);
+       log(ld, log_level, "mupdftopwg: %s", msg);
       }
     cupsFileClose(logfp);
     /* No need to close the fd errfds[0], as cupsFileClose(fp) does this
@@ -334,7 +334,7 @@ mutool_spawn (const char *filename,
     exit(0);
   }
   if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
-              "mupdftoraster: Started logging (PID %d)", errpid);
+              "mupdftopwg: Started logging (PID %d)", errpid);
 
   close(errfds[0]);
 
@@ -342,7 +342,7 @@ mutool_spawn (const char *filename,
     if ((pid = wait(&wstatus)) < 0) {
       if (errno == EINTR && iscanceled && iscanceled(icd)) {
        if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
-                    "mupdftoraster: Job canceled, killing mutool ...");
+                    "mupdftopwg: Job canceled, killing mutool ...");
        kill(mutoolpid, SIGTERM);
        mutoolpid = -1;
        kill(errpid, SIGTERM);
@@ -357,21 +357,21 @@ mutool_spawn (const char *filename,
       if (WIFEXITED(wstatus)) {
        /* Via exit() anywhere or return() in the main() function */
        if (log) log(ld, FILTER_LOGLEVEL_ERROR,
-                    "mupdftoraster: %s (PID %d) stopped with status %d",
+                    "mupdftopwg: %s (PID %d) stopped with status %d",
                     (pid == mutoolpid ? "mutool" : "Logging"), pid,
                     WEXITSTATUS(wstatus));
        status = WEXITSTATUS(wstatus);
       } else {
        /* Via signal */
        if (log) log(ld, FILTER_LOGLEVEL_ERROR,
-                    "mupdftoraster: %s (PID %d) crashed on signal %d",
+                    "mupdftopwg: %s (PID %d) crashed on signal %d",
                     (pid == mutoolpid ? "mutool" : "Logging"), pid,
                     WTERMSIG(wstatus));
        status = 256 * WTERMSIG(wstatus);
       }
     } else {
       if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
-                  "mupdftoraster: %s (PID %d) exited with no errors.",
+                  "mupdftopwg: %s (PID %d) exited with no errors.",
                   (pid == mutoolpid ? "mutool" : "Logging"), pid);
       status = 0;
     }
@@ -388,7 +388,7 @@ out:
 
 
 int
-mupdftoraster (int inputfd,         /* I - File descriptor input stream */
+mupdftopwg (int inputfd,         /* I - File descriptor input stream */
               int outputfd,        /* I - File descriptor output stream */
               int inputseekable,   /* I - Is input stream seekable? (unused)*/
               filter_data_t *data, /* I - Job and printer data */
@@ -435,7 +435,7 @@ mupdftoraster (int inputfd,         /* I - File descriptor input stream */
     outformat = OUTPUT_FORMAT_PWG_RASTER;
 
   if (log) log(ld, FILTER_LOGLEVEL_DEBUG,
-              "mupdftoraster: Output format: %s",
+              "mupdftopwg: Output format: %s",
               (outformat == OUTPUT_FORMAT_CUPS_RASTER ? "CUPS Raster" :
                (outformat == OUTPUT_FORMAT_PWG_RASTER ? "PWG Raster" :
                 (outformat == OUTPUT_FORMAT_APPLE_RASTER ? "Apple Raster" :
@@ -455,14 +455,14 @@ mupdftoraster (int inputfd,         /* I - File descriptor input stream */
 
   fd = cupsTempFd(infilename, 1024);
     if (fd < 0) {
-      if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftoraster: Can't create temporary file");
+      if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftopwg: Can't create temporary file");
       goto out;
     }
 
     /* copy input file to the tmp file */
     while ((n = read(inputfd, buf, BUFSIZ)) > 0) {
       if (write(fd,buf,n) != n) {
-        if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftoraster: Can't copy input to temporary file");
+        if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftopwg: Can't copy input to temporary file");
         close(fd);
         goto out;
       }
@@ -471,13 +471,13 @@ mupdftoraster (int inputfd,         /* I - File descriptor input stream */
   if (!inputfd) {
 
     if (lseek(fd,0,SEEK_SET) < 0) {
-      if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftoraster: Can't rewind temporary file");
+      if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftopwg: Can't rewind temporary file");
       close(fd);
       goto out;
     }
 
     if ((fp = fdopen(fd,"rb")) == 0) {
-      if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftoraster: Can't open temporary file");
+      if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftopwg: Can't open temporary file");
       close(fd);
       goto out;
     }
@@ -485,7 +485,7 @@ mupdftoraster (int inputfd,         /* I - File descriptor input stream */
     /* filename is specified */
 
     if ((fp = fdopen(fd,"rb")) == 0) {
-      if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftoraster: Can't open temporary file");
+      if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftopwg: Can't open temporary file");
       goto out;
     }
   }
@@ -516,11 +516,11 @@ mupdftoraster (int inputfd,         /* I - File descriptor input stream */
   /* mutool parameters */
   mupdf_args = cupsArrayNew(NULL, NULL);
   if (!mupdf_args) {
-    if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftoraster: Unable to allocate memory for mutool arguments array");
+    if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftopwg: Unable to allocate memory for mutool arguments array");
     goto out;
   }
 
-  if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "mupdftoraster: command: %s",
+  if(log) log(ld, FILTER_LOGLEVEL_DEBUG, "mupdftopwg: command: %s",
              CUPS_MUTOOL);
   snprintf(tmpstr, sizeof(tmpstr), "%s", CUPS_MUTOOL);
   cupsArrayAdd(mupdf_args, strdup(tmpstr));
@@ -586,7 +586,7 @@ mupdftoraster (int inputfd,         /* I - File descriptor input stream */
 
   if(empty)
   {
-    if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftoraster: Input is empty, outputting empty file.");
+    if(log) log(ld, FILTER_LOGLEVEL_ERROR, "mupdftopwg: Input is empty, outputting empty file.");
      status = 0;
   }
 out:
index be31039dd0a931f47011a7060fe26d3b160ac3ce..cf29037acf961a6a6a9c9992c4a5d564001c0e9c 100644 (file)
@@ -837,9 +837,11 @@ bool checkFeature(const char *feature, int num_options, cups_option_t *options)
            // log the pages
            param.page_logging = 1;
          } else if (!strcasecmp(lastfilter + strlen(lastfilter) - 8,
-                                "toraster")) {
+                                "toraster") ||
+                    !strcasecmp(lastfilter + strlen(lastfilter) - 5,
+                                "topwg")) {
            // On IPP Everywhere printers which accept PWG Raster data one
-           // of gstoraster, pdftoraster, or mupdftoraster is the last
+           // of gstoraster, pdftoraster, or mupdftopwg is the last
            // filter. These filters do not log pages so pdftopdf has to
            // do it
            param.page_logging = 1;
similarity index 88%
rename from filter/mupdftoraster.c
rename to filter/mupdftopwg.c
index 8684412e8f084ad8807093911bdf33e9e6ea34d9..398ab7f2c02cd69b00aa6cbac4c2de79c5651cca 100644 (file)
@@ -50,7 +50,7 @@ main(int  argc,          /* I - Number of command-line arguments */
 #endif /* HAVE_SIGSET */
 
  /*
-  * Fire up the mupdftoraster() filter function
+  * Fire up the mupdftopwg() filter function
   */
   
   filter_out_format_t outformat = OUTPUT_FORMAT_CUPS_RASTER;
@@ -64,10 +64,10 @@ main(int  argc,        /* I - Number of command-line arguments */
       outformat = OUTPUT_FORMAT_PCLM;
   }
 
-  ret = filterCUPSWrapper(argc, argv, mupdftoraster, &outformat, &JobCanceled);
+  ret = filterCUPSWrapper(argc, argv, mupdftopwg, &outformat, &JobCanceled);
 
   if (ret)
-    fprintf(stderr, "ERROR: mupdftoraster filter function failed.\n");
+    fprintf(stderr, "ERROR: mupdftopwg filter function failed.\n");
 
   return (ret);
 }
index de110c75d019e4a3bc49a66f102b2be1fcf02f99..334380911eb1ffeda7c7572a09d40303e4727693 100644 (file)
@@ -15,4 +15,4 @@
 # MuPDF-based filters...
 #
 
-application/vnd.cups-pdf       image/pwg-raster                101     mupdftoraster
+application/vnd.cups-pdf       image/pwg-raster                101     mupdftopwg