]> git.ipfire.org Git - thirdparty/cups-filters.git/log
thirdparty/cups-filters.git
2 years agoRe: Fix issue 6. 510/head
Zdenek Dohnal [Thu, 16 Feb 2023 14:48:32 +0000 (15:48 +0100)] 
Re: Fix issue 6.

Use default branch instead of specific one

2 years agoFix coverity issue 7.
Zdenek Dohnal [Wed, 15 Feb 2023 18:03:37 +0000 (19:03 +0100)] 
Fix coverity issue 7.

Alloc the array only in case we need it to prevent overwriting pointer

2 years agoFix coverity issue 6.
Zdenek Dohnal [Wed, 15 Feb 2023 17:58:08 +0000 (18:58 +0100)] 
Fix coverity issue 6.

Ensure that PrinterPlanes is not zero

2 years agoFix coverity issue 5.
Zdenek Dohnal [Wed, 15 Feb 2023 17:51:32 +0000 (18:51 +0100)] 
Fix coverity issue 5.

Free the struct at the end of function

2 years agoFix coverity issue 4.
Zdenek Dohnal [Wed, 15 Feb 2023 17:48:07 +0000 (18:48 +0100)] 
Fix coverity issue 4.

Move the allocation and big arrays into scope where it is needed

2 years agoFix coverity issue 3.
Zdenek Dohnal [Wed, 15 Feb 2023 17:40:55 +0000 (18:40 +0100)] 
Fix coverity issue 3.

Ensure we have NULL terminator

2 years agoFix coverity issue 2.
Zdenek Dohnal [Wed, 15 Feb 2023 17:39:17 +0000 (18:39 +0100)] 
Fix coverity issue 2.

Delete identical branch

2 years agoFix coverity issue 1.
Zdenek Dohnal [Wed, 15 Feb 2023 17:37:37 +0000 (18:37 +0100)] 
Fix coverity issue 1.

Close file descriptor in case of error

2 years agoconfigure.ac: Change deprecated AC_PROG_LIBTOOL for LT_INIT (#508)
zdohnal [Tue, 14 Feb 2023 18:15:03 +0000 (19:15 +0100)] 
configure.ac: Change deprecated AC_PROG_LIBTOOL for LT_INIT (#508)

2 years agoconfigure.ac: C++ not needed (#504)
zdohnal [Thu, 2 Feb 2023 22:58:36 +0000 (23:58 +0100)] 
configure.ac: C++ not needed (#504)

2 years agocups-filters 2.0b3 Release 2.0b3
Till Kamppeter [Tue, 31 Jan 2023 23:58:04 +0000 (20:58 -0300)] 
cups-filters 2.0b3 Release

2 years agoUpdated CHANGES.md
Till Kamppeter [Tue, 31 Jan 2023 21:37:12 +0000 (18:37 -0300)] 
Updated CHANGES.md

2 years agoAdd templates for issue reports.
Till Kamppeter [Mon, 30 Jan 2023 02:13:45 +0000 (23:13 -0300)] 
Add templates for issue reports.

2 years agoCOPYING: Fixed typo
Till Kamppeter [Thu, 26 Jan 2023 03:45:35 +0000 (00:45 -0300)] 
COPYING: Fixed typo

2 years agoCOPYING, NOTICE: Simplification for autotools-generated files
Till Kamppeter [Wed, 18 Jan 2023 20:48:10 +0000 (17:48 -0300)] 
COPYING, NOTICE: Simplification for autotools-generated files

autotools-generated files can be included under the license of the
upstream code, and FSF copyright added to upstream copyright
list. Simplified debian/copyright appropriately.

2 years agotexttopdf: Do not include fontconfig.h in the CUPS filter wrapper
Till Kamppeter [Tue, 17 Jan 2023 18:19:11 +0000 (15:19 -0300)] 
texttopdf: Do not include fontconfig.h in the CUPS filter wrapper

2 years agoBuild system: Do not explicitly check for libpoppler-cpp
Till Kamppeter [Tue, 17 Jan 2023 16:53:23 +0000 (13:53 -0300)] 
Build system: Do not explicitly check for libpoppler-cpp

The cups-filters does not contain any code using libpoppler-cpp,
therefore we let ./configure not check for it. This makes building
distribution packages easier.

2 years agoMakefile.am: Include LICENSE in distribution tarball
Till Kamppeter [Tue, 10 Jan 2023 01:46:16 +0000 (22:46 -0300)] 
Makefile.am: Include LICENSE in distribution tarball

2 years agocups-filters 2.0b2 Release 2.0b2
Till Kamppeter [Sun, 8 Jan 2023 22:51:57 +0000 (19:51 -0300)] 
cups-filters 2.0b2 Release

2 years agoUpdated CHANGES.md
Till Kamppeter [Sun, 8 Jan 2023 03:23:49 +0000 (00:23 -0300)] 
Updated CHANGES.md

2 years agoCleaned up .gitignore
Till Kamppeter [Sat, 7 Jan 2023 01:33:31 +0000 (22:33 -0300)] 
Cleaned up .gitignore

Still contained all the cups-filters entries from before the splitting
of the repositories.

2 years agoCorrected installation path for *.h files of *.drv files
Till Kamppeter [Fri, 6 Jan 2023 20:54:34 +0000 (17:54 -0300)] 
Corrected installation path for *.h files of *.drv files

The ppdc (and underlying functions) of libppd searches for include
files in /usr/share/ppdc and not in /usr/share/cups/ppdc any more.

2 years agoREADME.md: Removed Printer Application links
Till Kamppeter [Fri, 6 Jan 2023 19:13:29 +0000 (16:13 -0300)] 
README.md: Removed Printer Application links

The package cups-filters only contains classic CUPS filters and
backends, not relevant for Printer Applications, as they would use the
underlying filter functions of libcupsfilters.

2 years agoFixes in DEVELOPING.md
Till Kamppeter [Fri, 6 Jan 2023 19:08:32 +0000 (16:08 -0300)] 
Fixes in DEVELOPING.md

- Removed "Interfaces" and "Headers" sections in DEVELOPING.md, as
  cups-filters does not provide a library.

- No "cups" prefix for names in cups-filters C files

2 years agoconfigure.ac: Remove unnecessary "AVAHI_GLIB_..." definitions.
Till Kamppeter [Fri, 23 Dec 2022 18:20:23 +0000 (15:20 -0300)] 
configure.ac: Remove unnecessary "AVAHI_GLIB_..." definitions.

2 years agoMakefile.am: Include NOTICE in distribution tarball
Till Kamppeter [Fri, 23 Dec 2022 18:19:21 +0000 (15:19 -0300)] 
Makefile.am: Include NOTICE in distribution tarball

2 years agoconfigure.ac: Added "foreign" to to AM_INIT_AUTOMAKE() call.
Till Kamppeter [Fri, 25 Nov 2022 14:58:04 +0000 (15:58 +0100)] 
configure.ac: Added "foreign" to to AM_INIT_AUTOMAKE() call.

Makes automake not require a file named README.

2 years agoCHANGES.md: Improved formatting, general fixes of content.
Till Kamppeter [Fri, 18 Nov 2022 12:12:04 +0000 (13:12 +0100)] 
CHANGES.md: Improved formatting, general fixes of content.

2 years agoREADME.md: Remove Braille embossing part.
Till Kamppeter [Fri, 18 Nov 2022 00:12:03 +0000 (01:12 +0100)] 
README.md: Remove Braille embossing part.

2 years agocups-filters 2.0b1 Release 2.0b1
Till Kamppeter [Fri, 18 Nov 2022 00:08:39 +0000 (01:08 +0100)] 
cups-filters 2.0b1 Release

2 years ago.gitignore: Updated to changed filter executable names
Till Kamppeter [Fri, 18 Nov 2022 00:07:13 +0000 (01:07 +0100)] 
.gitignore: Updated to changed filter executable names

    rastertopdf  -> pwgtopdf
    rastertopclm -> pwgtopclm

2 years agoRemoved everything which got split out
Till Kamppeter [Thu, 17 Nov 2022 12:58:03 +0000 (13:58 +0100)] 
Removed everything which got split out

In the New Architecture for printing we switch to an all-IPP workflow
with PPD files being abolished and classic CUPS printer drivers
replaced by Printer Applications (software emulation of driverless IPP
printers).

To conserve the functionality of the CUPS filters which got developed
over the last 20+ years into a PPD-less, IPP-driven world without
having to maintain and include the legacy PPD support in OS
distributions and other system environments, the original cups-filters
package got split into 5 separate packages: libcupsfilters, libppd,
cups-filters, braille-printer-app, and cups-browsed, with
libcupsfilters and braille-printer-app not containing PPD file support
code any more and cups-browsed being planned to drop explicit use of
PPD files.

This commit drops everything from the cups-filters repository which
got split out into the other 4, new repositories.

What remains are the CUPS filter executables, from which most are
wrappers around filter functions implemented in the libcupsfilters and
libppd libraries, backends, the "driverless" utility for setting up
driverless printers with classic printer setup tools, and auxiliary
files (PPD files, *.drv files, MIME rules, ...).

This package is needed for using CUPS 2.x with filters from
libcupsfilters (2.x) and libppd.

It is not needed/does not make sense to be used with CUPS 3.x or the
CUPS Snap (or any other containerized CUPS implementation). If you
need printer drivers for such CUPS versions, use Printer Applications.

2 years agoDEVELOPING.md, CONTRIBUTING.md: Include them in tarball and installation
Till Kamppeter [Mon, 14 Nov 2022 23:20:37 +0000 (00:20 +0100)] 
DEVELOPING.md, CONTRIBUTING.md: Include them in tarball and installation

Added the new files to Makefile.am so that "make dist" amd "make
install" include them.

2 years agoAdded DEVELOPING.md and CONTRIBUTING.md
Till Kamppeter [Mon, 14 Nov 2022 22:33:16 +0000 (23:33 +0100)] 
Added DEVELOPING.md and CONTRIBUTING.md

These files are mainly overtaken from CUPS. They provide information
for contributors: Coding style, contact, where to report bugs/post
feature requests, ...

2 years agoCHANGES.md, README.md, INSTALL: Updated source package documentation
Till Kamppeter [Mon, 14 Nov 2022 21:00:03 +0000 (22:00 +0100)] 
CHANGES.md, README.md, INSTALL: Updated source package documentation

- Renamed NEWS to CHANGES.md
- Moved changes on 1.x to CHANGES-1.x.md
- As changes for 2.0b1 listed all changes compared to the last 1.x release
  (1.28.16), in preparation for the separation already divided up by the
  components.
- Converted README to README.md, some updates of the text.

2 years agoAUTHORS, COPYING, LICENSE, NOTICE: Switchover to Apache 2.0
Till Kamppeter [Fri, 11 Nov 2022 23:57:41 +0000 (00:57 +0100)] 
AUTHORS, COPYING, LICENSE, NOTICE: Switchover to Apache 2.0

Reflect the switchover to the Apache 2.0 license with CUPS extension
(same license as CUPS) in the appropriate files.

Also updated lists of copyright holders and authors.

2 years agoData files: Changed license info to Apache 2.0
Till Kamppeter [Fri, 11 Nov 2022 19:19:57 +0000 (20:19 +0100)] 
Data files: Changed license info to Apache 2.0

Changed the license info in the file headers to the license used by
CUPS, on PostScript files, *.drv PPD generator files, M4 files, MIME
rules, and PPD files.

2 years agolibcupsfilters: Updated all licence headers to Apache 2.0
Till Kamppeter [Sun, 23 Oct 2022 23:23:24 +0000 (01:23 +0200)] 
libcupsfilters: Updated all licence headers to Apache 2.0

Now the license headers contains infor what the file contains,
copyright info and the license info.

The license is now the same as in CUPS:

    Licensed under Apache License v2.0.  See the file "LICENSE" for more
    information.

Added the header where it was missing. Also used a unique format for all
headers.

2 years agocups-browsed, driverless: Code clean-up for code of the utilities
Till Kamppeter [Sun, 23 Oct 2022 19:21:41 +0000 (21:21 +0200)] 
cups-browsed, driverless: Code clean-up for code of the utilities

Cleaned up the code in the utils/ drirectory following the coding
style rules in the DEVELOPING.md file of the CUPS source code.

This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.

Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.

Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.

In addition, all the file's header comments reflect the new license,
Apache 2.0, the same license as used for CUPS.

Note that we did not clean up driverless.c, as here we still accept a
major code contribution from the GSoC.

2 years agoCUPS backends: Code clean-up for code in backend/
Till Kamppeter [Sat, 22 Oct 2022 14:32:45 +0000 (16:32 +0200)] 
CUPS backends: Code clean-up for code in backend/

Cleaned up the code of the legacy CUPS backends following the coding
style rules in the DEVELOPING.md file of the CUPS source code.

Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.

Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.

In addition, all the file's header comments reflect the new license
now, Apache 2.0, the same license as used for CUPS.

2 years agoCUPS filters: Code clean-up for code in filter/
Till Kamppeter [Fri, 21 Oct 2022 21:56:00 +0000 (23:56 +0200)] 
CUPS filters: Code clean-up for code in filter/

Cleaned up the code of the legacy CUPS filters/filter function
wrappers following the coding style rules in the DEVELOPING.md file of
the CUPS source code.

Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.

Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.

In addition, all the file's header comments reflect the new license
now, Apache 2.0, the same license as used for CUPS.

2 years agofoomatic-rip: Updated the license info of all source files
Till Kamppeter [Wed, 19 Oct 2022 22:06:58 +0000 (00:06 +0200)] 
foomatic-rip: Updated the license info of all source files

cups-filters will be put under the same license as CUPS. Updated the
source files of foomatic-rip appropriately.

2 years agolibppd: Code clean-up for code of foomatic-rip
Till Kamppeter [Wed, 19 Oct 2022 21:38:59 +0000 (23:38 +0200)] 
libppd: Code clean-up for code of foomatic-rip

Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.

Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.

The indent width is set to 2 spaces instead of 4, to match the other
files.

This way we get rid of the mix of many different coding styles which
came together from the many code contributions received during more
than a decade, even before the start of the cups-filters project.

2 years agolibcupsfilters/libppd: More coding style clean-up ...
Till Kamppeter [Mon, 17 Oct 2022 17:29:10 +0000 (19:29 +0200)] 
libcupsfilters/libppd: More coding style clean-up ...

2 years agolibcupsfilters, README: 2.x requires Ghostscript 10.00.0
Till Kamppeter [Mon, 17 Oct 2022 10:57:39 +0000 (12:57 +0200)] 
libcupsfilters, README: 2.x requires Ghostscript 10.00.0

libcupsfilters 2.x (cfFilterGhostscript() filter function) requires
Ghostscript 10.00.0 for a "cups"/"pwgraster"/"appleraster"/"urf"
output device with full support for PPD-less use. Ghostscript 10.01.0
is recommended, to fix

https://github.com/OpenPrinting/cups-filters/issues/484

Updated comments in cupsfilters/ghostscript.c and README
appropriately.

2 years agolibcupsfilters, libppd: cfFilterExternal() filter function
Till Kamppeter [Sun, 16 Oct 2022 07:19:26 +0000 (09:19 +0200)] 
libcupsfilters, libppd: cfFilterExternal() filter function

Moved the core functionality of the ppdFilterExternalCUPS() filter
function from libppd into libcupsfilters, as the new
cfFilterExternal() filter function.

This way also in applications without PPD file support, not using
libppd, external filter executables can be easily integrated in filter
function chains. This is for example needed if filters are not written
in C and conversion gets too awkward and error-prone, or is not even
possible (like with closed-source filters).

The Braille embosser printer driver for example contains filters which
are shell scripts.

External filters must use the call scheme of either CUPS filters or
System V interface scripts. Both call schemes are merely the same,
only in the CUPS filters there got added that input can come from
stdin instead of only via files named in the 6th and further command
line arguments.

ppdFilterExternalCUPS() is a wrapper around cfFilterExternal() now and
does not more than setting the cups-specific environment variables
CUPS_DATADIR, CUPS_SERVERBIN, CUPS_SERVERROOT, CUPS_STATEDIR,
SOFTWARE, CONTENT_TYPE, FINAL_CONTENT_TYPE, PRINTER, PPD, DEVICE_URI
to emulate a cUPS environment as good as possible. The PPD's file name
for the PPD environment variable is taken from the "libppd" extension
for the filter data.

For calling CUPS backends for job execution, the DEVICE_URI
environment variable must be set to the CUPS device URI of the
printer. This can be done by setting the variable right away or adding
it to the environment variable list in the parameters.

The parameters data structure for both cfFilterExternal() and
ppdFilterExternalCUPS() is cf_filter_external_t (in
cupsfilters/filter.h) now and not ppd_filter_external_cups_t any
more. Here the device_uri field got removed (the DEVICE_URI
environment variable has to be used instead) and the is_backend field
got replaced by exec_mode. exec_mode allows 4 setting: -1 for System V
interface scripts (input is file named by 6th command line argument),
0 for CUPS filter (input via stdin), 1 for CUPS backend in job
execution mode, 2 for CUPS backend in device discovery mode (no
command line arguments).

To allow easy handling of the environment variable list in the
parameters, the envp field, the internal helper functions
add_env_var() and get_env_var() got promoted into the API, as
cfFilterAddEnvVar() and cfFilterGetEnvVar(). This allows also libppd
to use these functions.

For testing and debugging any changes on cfFilterExternal() and
ppdFilterExternalCUPS() a new wrapper pseudo CUPS filter,
"test-external", source file filter/test-external.c, got added. This
one is mainly intended to be called manually. To tell which filter or
backend should be called and in which mode, one of the environment
variables INTERFACE, FILTER, CUPSFILTER, or CUPSBACKEND has to be set
to the filter/backend executable.

2 years agolibcupsfilters: Added info about source of human-readable option strings
Till Kamppeter [Sat, 15 Oct 2022 14:13:50 +0000 (16:13 +0200)] 
libcupsfilters: Added info about source of human-readable option strings

The files cupsfilters/catalog.c and cupsfilters/catalog.h contain an
API to obtain human-readable and translated strings for printer
options and choices. Document where the actual strings are taken from.

2 years agolibppd: Code clean-up for code of libppd
Till Kamppeter [Sat, 15 Oct 2022 13:23:10 +0000 (15:23 +0200)] 
libppd: Code clean-up for code of libppd

Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.

This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.

Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.

Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.

In addition, all the file's header comments reflect the new license,
Apache 2.0, the same license as used for CUPS.

2 years agolibcupsfilters: Removed unused and forgotten header file
Till Kamppeter [Wed, 12 Oct 2022 11:51:35 +0000 (13:51 +0200)] 
libcupsfilters: Removed unused and forgotten header file

The content of filter/textcommon.h has been completely moved into
cupsfilters/texttopdf.c. therefore we remove the file now.

2 years agolibcupsfilters: Code clean-up for code of testpdf1 and testpdf2
Till Kamppeter [Tue, 11 Oct 2022 23:02:42 +0000 (01:02 +0200)] 
libcupsfilters: Code clean-up for code of testpdf1 and testpdf2

Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.

This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.

Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.

In addition, one can now supply a fon file as argument to testpdf2, so
that this program embeds the supplied font instead of a standard one.

2 years agolibcupsfilters: Move test suite programs to cupsfilters/
Till Kamppeter [Tue, 11 Oct 2022 22:40:52 +0000 (00:40 +0200)] 
libcupsfilters: Move test suite programs to cupsfilters/

Two test suite programs for libcupsfilters, test_pdf1.c and
test_pdf2.c were still in the filter/ directory. This commit moves
them into cupsfilters and correct their naming style.

2 years agolibcupsfilters: Cleaned up coding style of test suite
Till Kamppeter [Tue, 11 Oct 2022 22:25:06 +0000 (00:25 +0200)] 
libcupsfilters: Cleaned up coding style of test suite

Cleaned up the coding style of the test programs run by "make check".

- Converted comments from "/* ... */" to "// ..."

- Suppressed warnings of unused return values of fgets() and fread(), via
  "fread(...);" -> "if (fread(...));"

2 years agolibcupsfilters: Renamed functions and types in fontembed code
Till Kamppeter [Tue, 11 Oct 2022 06:49:40 +0000 (08:49 +0200)] 
libcupsfilters: Renamed functions and types in fontembed code

Renamed all functions and types in the source files in the fontembed/
subdirectory tofollow the rules of DEVELOPING.md of CUPS.

To distinguish functions and types internal to only fontembed/ and
internal to the whole libcupsfilters, the ones internal to fontembed/
have two underscores in the beginning of their names now
("__cfFontEmbed...", "__cf_fontembed_...") while the ones which form
the internal API to libcupsfilters have only one ("_cfFontEmbed...",
"_cf_fontembed_...").

Also considered the API of fontembed as internal to
libcupsfilters. Therefore renamed cupsfilters/fontembed.h to
cupsfilters/fontembed-private.h and not installing it into
/usr/include.

2 years agolibfontembed, libcupsfilters: Merge libfontembed into libcupsfilters
Till Kamppeter [Mon, 10 Oct 2022 18:34:12 +0000 (20:34 +0200)] 
libfontembed, libcupsfilters: Merge libfontembed into libcupsfilters

libfontembed is only used by cups-filters, and here only by the
cfFilterTextToPDF() filter function ("texttopdf" CUPS filter, also
part of "universal" CUPS filter). It is also not used by any other
package (at least of Ubuntu Main and Universe).

To ease the separation of cups-filters into their components (similar
to CUPDS 3.x we will separate, into libcupsfilters, libppd,
cups-filters, and cups-browsed, to cleanly separate off the PPD file
support) we merge the functionality of libfontembed into
Libcupsfilters, to keep the cfFilterTextToPDF() filter function for
plain text file printing support.

2 years agolibfontembed: Code clean-up for code of libfontembed
Till Kamppeter [Mon, 10 Oct 2022 12:16:03 +0000 (14:16 +0200)] 
libfontembed: Code clean-up for code of libfontembed

Cleaned up the code following the coding style rules in the
DEVELOPING.md file of the CUPS source code.

This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.

Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.

Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.

2 years agolibcupsfilters: Moved IPP-attribute-related functions to ipp.c
Till Kamppeter [Sat, 8 Oct 2022 06:34:42 +0000 (08:34 +0200)] 
libcupsfilters: Moved IPP-attribute-related functions to ipp.c

There were some non-Raster-related but IPP-attribute-related functions
in raster.c. With this commit they are moved to ipp.c now.

The functions are:

    - cfGetBackSideOrientation()
    - cfGetPrintRenderIntent()
    - cfJoinJobOptionsAndAttrs()

2 years agolibcupsfilters: Added RGBW support to cfFilterPCLmToRaster()
Till Kamppeter [Fri, 7 Oct 2022 12:03:22 +0000 (14:03 +0200)] 
libcupsfilters: Added RGBW support to cfFilterPCLmToRaster()

Requesting RGBW as destination color space (to test, use pclmtoraster
CUPS filter wrapper and PPD for HP inkjet with hpcups driver of HPLIP)
leads to wrong color output on some input files and even to a crash on
others.

This is cause by missing support for RGBW and this, instead RGB being
output into the destination file with RGBW declared as the color space
in its header.

This commit adds explicit support for RGBW output and this way solves
the problem.

2 years agolibcupsfilters: Code clean-up for code of libcupsfilters
Till Kamppeter [Thu, 6 Oct 2022 15:59:38 +0000 (17:59 +0200)] 
libcupsfilters: Code clean-up for code of libcupsfilters

Completed the code clean-up of the source files of libcupsfilters in
the cupsfilters/ directory itself (no sub-directory) following the
coding style rules in the DEVELOPING.md file of the CUPS source code.

Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.

This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.

Also we get rid of the mix of many different coding styles which came
together from the many code contributions received during more than a
decade, even before the start of the cups-filters project.

2 years agolibcupsfilters: Code clean-up for code of libcupsfilters
Till Kamppeter [Thu, 29 Sep 2022 22:41:46 +0000 (00:41 +0200)] 
libcupsfilters: Code clean-up for code of libcupsfilters

Cleaned up the second bunch of source code files of libcupsfilters in
the cupsfilters/ directory itself (no sub-directory) following the
coding style rules in the DEVELOPING.md file of the CUPS source code.

Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.

This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.

Also we get rid of the mix of many different coding styles which came
together from the many code contributions rteceived during more than a
decade, even before the start of the cups-filters project.

2 years agolibcupsfilters: Removed portability implementationsn of functions
Till Kamppeter [Sun, 25 Sep 2022 21:03:08 +0000 (23:03 +0200)] 
libcupsfilters: Removed portability implementationsn of functions

For portability implementations of the GNU C functions getline() and
strcasestr() were included in the source code but there is nothing in
the build system making them actually used if the system does not
provide them.

Therefor we do not take them to 2.x and remove them here.

2 years agoAdd FrequentNetifUpdate option/directive (#482)
zdohnal [Thu, 15 Sep 2022 14:14:29 +0000 (16:14 +0200)] 
Add FrequentNetifUpdate option/directive (#482)

2 years agolibcupsfilters: Code clean-up for code of cfFilterPDFToPDF()
Till Kamppeter [Sat, 10 Sep 2022 06:48:48 +0000 (08:48 +0200)] 
libcupsfilters: Code clean-up for code of cfFilterPDFToPDF()

Cleaned up the first bunch of source code files of libcupsfilters in
the cupsfilters/ directory itself (no sub-directory) following the
coding stype rules in the DEVELOPING.md file of the CUPS source code.

Comments are re-formatted to use "// ..." instead of "/* ... */", like
in PAPPL, so C and C++ files get the same comment style.

This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.

Also we get rid of the mix of many different coding styles which came
together from the many code contributions rteceived during more than a
decade, even before the start of the cups-filters project.

2 years agolibcupsfilters: Code clean-up for code of cfFilterPDFToPDF()
Till Kamppeter [Mon, 5 Sep 2022 22:06:10 +0000 (00:06 +0200)] 
libcupsfilters: Code clean-up for code of cfFilterPDFToPDF()

Cleaned up all the source code files of the cfFilterPDFToPDF() filter
function (all files in cupsfilters/pdftopdf/) following the coding
stype rules in the DEVELOPING.md file of the CUPS source code.

This improves the readability of the code a lot, especially as missing
spaces got inserted in comma-separated lists ("xxx,yyy,zzz" -> "xxx,
yyy, zzz") and around operators ("x=a*(b+c)%4" -> "x = a * (b + c) %
4"), what got nearly completely missed out by several contributors.

2 years agoRemoved PHP and Perl APIs
Till Kamppeter [Sun, 4 Sep 2022 13:22:57 +0000 (15:22 +0200)] 
Removed PHP and Perl APIs

The included PHP and Perl APIs did not get actually maintained and
especially never used by anyone. They still were on the API level of
CUPS 1.2. And the Perl part was not even supported by the build system
(only the scripting/perl/ directory in EXTRA_DIST to get it into the
source tarball).

Therefore we do not take it over into cups-filters 2.x and drop it
here.

2 years agolibcupsfilters: Removed support for legacy image formats
Till Kamppeter [Sun, 4 Sep 2022 12:59:33 +0000 (14:59 +0200)] 
libcupsfilters: Removed support for legacy image formats

Removed support for the legacy image formats GIF, Photo CD, X Pixmap,
X Bitmap, PNM (Portable Anymap/Bitmap/Graymap/Pixmap), BMP, SGI RGB,
Sun Raster. This is to avoid the requirement to maintain gthe code
supporting these mostly obsolete image formats.

JPEG, PNG, and TIFF are still available.

2 years agolibcupsfilters: Update comments about filter functions in filter.h
Till Kamppeter [Sat, 3 Sep 2022 18:08:14 +0000 (20:08 +0200)] 
libcupsfilters: Update comments about filter functions in filter.h

The filter functions cfFilterGhostscript() and cfFilterPWGtoPDF()
allow the output format also to be supplied as parameter and not
only via filter data structure.

2 years agolibcupsfilters: Let cfFilterUniversal() not se unnecessary parameters
Till Kamppeter [Sat, 3 Sep 2022 18:00:30 +0000 (20:00 +0200)] 
libcupsfilters: Let cfFilterUniversal() not se unnecessary parameters

With the new fields content_type and final_content_type in the filter
data structure the output format does not need to get supplied as
parameter any more for most filter functions. So let
cfFilterUniversal() not supply any parameters any more to filter
functions which do not use them any more.

2 years agolibcupsfilters: Do not feed CUPS Raster into cfFilterPWGToPDF()
Till Kamppeter [Sat, 3 Sep 2022 16:31:42 +0000 (18:31 +0200)] 
libcupsfilters: Do not feed CUPS Raster into cfFilterPWGToPDF()

- In cfFilterUniversal() correct filter chains to always feed PWG
  Raster (or Apple Raster) into cfFilterPWGToPDF():

  o After cfFilterImageToRaster() call cfFilterRasterToPWG() before
    cfFilterPWGToPDF()

  o Do not accept CUPS Raster as input format for cfFilterUniversal(),
    so we only need to convert PWG Raster and Apple Raster to PDF,
    which works with cfFilterPWGToPDF(). CUPS Raster as input is
    actually not needed, as it is not used as network format for print
    jobs but only internally by CUPS, usually for Raster drivers. Also
    updated the MIME rules to not accept CUPS Raster.

  o Convert application/vnd.adobe-reader-postscript (PostScript from
    Adobe Reader) always to PDF via cfFilterGhostscript() (to PWG
    Raster) and cfFilterPWGToPDF() (to PDF). Removed the other paths
    for simplification. Also made sure that the filters to convert PDF
    to the final format get added to the chain.

- Let cfFilterRasterToPWG() also accept the final output format PCLm
  and then create PWG Raster, in preparation for cfFilterPWGToPDF().

- Let cfFilterPWGToRaster() not accept PCLm as final output format as
  its input format (PWG or Apple Raster) is directly accepted by
  cfFilterPWGToPDF() and so this filter is not needed for PCLm as
  final output format.

- These changes also fix printing
  application/vnd.adobe-reader-postscript (PostScript from Adobe
  Reader) with the cfFilterUniversal() filter function.

2 years agolibcupsfilters: Renamed cfFilterRasterToPDF() to cfFilterPWGToPDF()
Till Kamppeter [Fri, 2 Sep 2022 23:31:37 +0000 (01:31 +0200)] 
libcupsfilters: Renamed cfFilterRasterToPDF() to cfFilterPWGToPDF()

Renamed the filter function cfFilterRasterToPDF() to
cfFilterPWGToPDF() as it actually does not work with CUPS Raster input
but only with PWG Raster input (or URF/Apple Raster).

Also renamed the corresponding CUPS filters to pwgtopdf and pwgtopclm.

2 years agolibcupsfilters: In cfFilterPDFToRaster() Fixed margins of output pages
Till Kamppeter [Fri, 2 Sep 2022 22:58:48 +0000 (00:58 +0200)] 
libcupsfilters: In cfFilterPDFToRaster() Fixed margins of output pages

The PDF rasterizing filter function cfFilterPDFToRaster() which is
based on Poppler and usually only used when Ghostscript is not
available did not get enough testing and produced raster files with
wrong margins.

This commit fixes the problems:

- Apply "MediaClass"/"media-class" option only if final output format
  is CUPS Raster or PWG Raster. Let the option do not change any thing
  if not present. When switching the format due to this option, also
  change the outformat variable.

- Supply a pointer to the outformat to parse_opts(), so that if
  parse_opts() changes the outformat the caller gets this change.

- The cfFilterRasterToPCLm() filter function only accepts PWG Raster
  as input, not CUPS Raster.

2 years agolibcupsfilters: cfFilterUniversal() supports also Poppler's pdftops now
Till Kamppeter [Fri, 2 Sep 2022 11:24:51 +0000 (13:24 +0200)] 
libcupsfilters: cfFilterUniversal() supports also Poppler's pdftops now

Added support for Poppler's pdftops instead of Ghostscript for PDF
rendering by the universal filter function cfFilterUniversal().

By conditional compiling either the filter functions to use
Ghostscript or the ones to use pdftops are used. This can be
controlled via ./configure script, by using the "--disable-..."
argument for the unwished PDF renderer. If both PDF renderers are
enabled, Ghostscript is preferred.

If pdftops is used, the cfFilterUniversal() filter function does not
support PostScript input. For this Ghostscript is required.

If both Ghostscript and pdftops are disabled by ./configure arguments,
the "universal" CUPS filter wrapper is not installed, to not use the
then rather crippled cfFilterUniversal() filter function as CUPS
filter.

2 years agoBuild system: Improvements for ./configure script
Till Kamppeter [Thu, 1 Sep 2022 21:58:21 +0000 (23:58 +0200)] 
Build system: Improvements for ./configure script

- Make sure that always a valid PDF-to-PostScript renderer is
  selected, especially if one or another renderer is disabled, like
  "hybrid" ("--with-pdftops=hybrid") does not make sense if Ghostscipt
  is disabled ("--disable ghostscript"). In this case the first valid
  renderer found will beused.

- In the summary at the end report which PDF-to-PostScript renderer
  gets actually used.

- Changed oder of treating the PDF-to-PostScript renderer, so that as
  first choice Ghostscript would be taken and as second choice
  Poppler's pdftops.

- Generate for each supported PDF renderer a "HAVE_..." macro in
  config.h, for easily excluding unnecessary code.

2 years agolibppd: In ppdFilterUniversal() set output data type also if no PPD supplied
Till Kamppeter [Tue, 30 Aug 2022 18:02:49 +0000 (20:02 +0200)] 
libppd: In ppdFilterUniversal() set output data type also if no PPD supplied

Now both cfFilterUniversal() and its PPD file support wrapper
ppdFilterUniversal() are absolutely compatible if no PPD file got
supplied via named extension to the filter data.

Before, if no PPD was supplied and no actual_output_type in the
parameters, the output data type stayed undetermined and the function
errored out not being able to find a filter combination for the
requested conversion.

Now always final_content_type of thef ilter data is used if there is
no actual_output_type specified in the parameters, regardless of
whether we have a PPD file or not.

2 years agolibppd: Improvements on ppdLoadAttributes() PPD-to-printer-IPP-attributes
Till Kamppeter [Mon, 29 Aug 2022 16:13:06 +0000 (18:13 +0200)] 
libppd: Improvements on ppdLoadAttributes() PPD-to-printer-IPP-attributes

As this function is for telling filters and drivers how to print a job
on the printer for which the supplied PPD is and NOT for a PPD
retro-fitting Printer Application (or any other PPD-supporting IPP
print server) to answer a get-printer-attributes IPP request several
changes were needed.

- More sophisticated way to find the default resolution. Do not only
  look for "*DefaultResolution:" but also the result of a
  ppdRasterInterpretPPD() call, what is marked in the "Resolution"
  option, "*cupsUrfSupported:", "*cupsPwgRaster...", "*cupsPclm..."
  (from PPD generator of libppd).

- To determine the supported output formats take care that in
  "*cupsFilter2: ..." lines in the PPD the final output format is the
  second word and no the first, as in "*cupsFilter: ..." lines.

- For media-col-ready use the same entry as for media-col-default and
  for media-ready use the same entry as for media-default.

- For print-content-optimize-supported, use the 5 standard values, no
  just "auto".

- Removed the irrelevant parts about supplies. They produced constant,
  device-independent output anyway.

- Removed the document-password-supported attribute.

- When synthesizing a device ID, also create a CMD: field from the
  MIME rules in the "*cupsFilter(2): ..." lines.

2 years agolibppd: Corrections for determining resolution in ppdFilterPDFToPS()
Till Kamppeter [Sun, 28 Aug 2022 21:49:32 +0000 (23:49 +0200)] 
libppd: Corrections for determining resolution in ppdFilterPDFToPS()

If we have a PPD file we use ppdRasterInterpretPPD() to determine the
actual resolution of the current job. Only consider the resolution
invalid if both horizontal and vertical resolution are 100 dpi.

When getting resolution from PPD's "Resolution" option setting or
default resolution, set y resolution to x resolution if we have only
one number ("600dpi").

2 years agolibcupsfilters: Declare raster_base_header() function static
Till Kamppeter [Sun, 28 Aug 2022 21:46:56 +0000 (23:46 +0200)] 
libcupsfilters: Declare raster_base_header() function static

raster_base_header() is only used inside the cupsfilters/raster.c file
and not intended to be an API function.

2 years agolibcupsfilters, universal: Impoert template dir for cfFilterBannerToPDF()
Till Kamppeter [Sun, 28 Aug 2022 16:36:10 +0000 (18:36 +0200)] 
libcupsfilters, universal: Impoert template dir for cfFilterBannerToPDF()

Fixes Issue #471.

The cfFilterUniversal() filter function did not import the template
directory which cfFilterBannerToPDF() needs as parameter.

2 years agolibppd: In ppdLoadAttributes() complete custom page size support
Till Kamppeter [Sun, 28 Aug 2022 15:55:56 +0000 (17:55 +0200)] 
libppd: In ppdLoadAttributes() complete custom page size support

If the user has sent a job on a custom page size, these custom size is
correctly set as default size in the printer IPP attributes derived
from the PPD file, as media-col, with dimensions, margins, and PWG
specifying the size in the units originally used for it.

Also added the custom page size range keywords to the
"media-supported" printer IPP attribute.

2 years agolibcupsfilters: Compare case-insesitively in cfFilterUniversal()
Till Kamppeter [Sat, 27 Aug 2022 23:16:02 +0000 (01:16 +0200)] 
libcupsfilters: Compare case-insesitively in cfFilterUniversal()

Case-sensitive comparing of MIME types does not make sense, there are
no two MIME types where the names only differ by lower/uppar
case. This way wrongly written MIME types (like application/pclm
instead of application/PCLm) are no problem any more.

2 years agolibppd: In ppdFilterLoadPPD() let PDF filter log pages when output is PS
Till Kamppeter [Sat, 27 Aug 2022 23:04:32 +0000 (01:04 +0200)] 
libppd: In ppdFilterLoadPPD() let PDF filter log pages when output is PS

PostScript output is going through the ppdFilterPSToPS() filter to
insert the PostScript code of the option settings into the PostScript
output data stream. The ppdFilterPSToPS() filter only logs pages if
the PPD is a pure PostScript PPD (without "*cupsFilter(2): ..."
lines). If it is not, the PDF filter has to log. This change lets the
PDF filter log the pages in such a case.

2 years agolibppd: In ppdFilterLoadPPD() correct check for final output type
Till Kamppeter [Sat, 27 Aug 2022 20:53:45 +0000 (22:53 +0200)] 
libppd: In ppdFilterLoadPPD() correct check for final output type

To determine whether the PDF filter (usually cfFilterPDFToPDF()) has
to do the page logging for CUPS ("PAGE: XX YY" log messages) or the
driver filter, we check the final output type (FINAL_CONTENT_TYPE
environment cariable from CUPS) to see whether a driver filter is
involved which should log the pages by itself.

The code to compare the final output type with the "*cupsFilter(2):
..." lines in the PPD file was broken, which is fixed with this
commit.

2 years agolibcupsfilters: In cfFilterImageToRaster() removed unneeded media-type parsing
Till Kamppeter [Fri, 26 Aug 2022 11:38:39 +0000 (13:38 +0200)] 
libcupsfilters: In cfFilterImageToRaster() removed unneeded media-type parsing

The option/attribute "maedia-type"/"MediaType" got read out but
nowhere used, so removed the code reading it.

2 years agolibcupsfilters: _cupsImageReadEXIF() -> _cfImageReadEXIF()
Till Kamppeter [Thu, 25 Aug 2022 22:35:22 +0000 (00:35 +0200)] 
libcupsfilters:  _cupsImageReadEXIF() -> _cfImageReadEXIF()

Names of library-internal functions always start with "_cf".

2 years agolibcupsfilters: Fixed typo in function names: OutPut -> Output
Till Kamppeter [Thu, 25 Aug 2022 22:29:30 +0000 (00:29 +0200)] 
libcupsfilters: Fixed typo in function names: OutPut -> Output

2 years agolibfontembed, libcupsfilters, libppd: assert() only if DEBUG is set
Till Kamppeter [Thu, 25 Aug 2022 21:32:36 +0000 (23:32 +0200)] 
libfontembed, libcupsfilters, libppd: assert() only if DEBUG is set

A failing assert() makes the whole program crash, a daemon (Printer
Application) crashes when a filter fails on a damaged input file, a
distro-packaged program sends automatic bug reports to the distro,
... Sometimes assert() is really overkill.

But assert() can be useful for debugging, as one gets easily aware
when some values are wrong somewhere (this probably made the
contributors yo cups-filters insert that many assert() calls).

At least, assert() should only be used for debugging, not in
production code.

Therefore we have replaced all assert() calls by the DEBUG_assert()
macro and the macro is set to assert() when the code is compiled with
the DEBUG macro set and to nothing otherwise. For setting this macro
and other debugging macros there are */debug-internal.h files for all
the 3 libraries now.

Also defined functions for DEBUG_printf and DEBUG_puts in
libcupsfilters (cupsfilters/debug.c).

On a compilation with DEBUG set ("CXXFLAGS=-DDEBUG CFLAGS=-DDEBUG
./configure ...") found some build failures and fixed them.

Also silenced all remaining warnings.

2 years agoREADME: Mention build tools needed for compiling cups-filters
Till Kamppeter [Sun, 21 Aug 2022 12:32:51 +0000 (14:32 +0200)] 
README: Mention build tools needed for compiling cups-filters

2 years agolibppd: Added more NULL checks when "libppd" extension not present
Till Kamppeter [Sat, 20 Aug 2022 22:30:36 +0000 (00:30 +0200)] 
libppd: Added more NULL checks when "libppd" extension not present

This time added NULL checks in the ppdFilterPSToPS(),
ppdFilterImageToPS(), and ppdFilterPDFToPS() filter functions.

2 years agolibppd: Added NULL checks when "libppd" extension not present
Till Kamppeter [Sat, 20 Aug 2022 20:38:08 +0000 (22:38 +0200)] 
libppd: Added NULL checks when "libppd" extension not present

The functions ppdFilterExternalCUPS(), ppdFilterEmitJCL(), and
ppdFilterUniversal() get the PPD file via the "libppd" extension for
the filter data. There was no NULL check when the extension was not
present, without extension there was simply a crash, a hang, or other
unexpected behavior.

This commit adds NULL checks so that if the extension is missing, the
functions simply do what they can do without PPD file, but do not
cause a crash.

2 years agolibcupsfilters: Removed cfRasterMatchIPPSize() function
Till Kamppeter [Sat, 20 Aug 2022 18:16:58 +0000 (20:16 +0200)] 
libcupsfilters: Removed cfRasterMatchIPPSize() function

This function is not needed any more. It is replaced by the more
sophisticated cfGetPageDimensions().

2 years agolibppd: Make driverless printing PPDs from CUPS work correctly
Till Kamppeter [Sat, 20 Aug 2022 15:29:37 +0000 (17:29 +0200)] 
libppd: Make driverless printing PPDs from CUPS work correctly

If one sets up a driverless printer with CUPS, either manually by the
"-m everywhere" option for "lpadmin" (or equivalent functionality in
the web interface) or automatically when CUPS creates a temporary
queue, the generated PPD file did not work correctly with current
cups-filters.

CUPS' auto-generated PPD files to not contain "*cupsUrfSupported: ..."
or "*cupsPwgRaster..." lines, but instead, add pseudo-PostScript code
(as in PPDs for CUPS Raster drivers) to the "ColorModel" and
"cupsPrintQuality" options.

Therefore the ppdLoadAttributes() function should not create artifical
"urf-supported" or "pwg-raster-..." printer IPP attributes and the
ppdFilterLoadPPD() should instead create a sample Raster header as it
already does for PPDs for CUPS Raster drivers. This way color space,
depth, and resolution get supplied to the filters via the header.

This commit does the appropriate changes.

3 years agoMakefile.am: Move the libppd declarations after cups-filters (#477)
Carlos Nihelton [Tue, 16 Aug 2022 14:47:52 +0000 (11:47 -0300)] 
Makefile.am: Move the libppd declarations after cups-filters (#477)

When doing "sudo make install", the re-linking breaks because libppd depends on libcupsfilters (and not vice-versa, as before), not yet installed. Reordering the declarations in the Makefile.am seems to fix the bahavior.

To reproduce the issue try on a minimal Ubuntu environment, such as WSL or cloud images running on LXD or docker:
```
sudo apt install autotools-dev autoconf automake autopoint libavahi-client-dev libavahi-glib-dev libcurl4-gnutls-dev libglib2.0-dev libgnutls28-dev libjpeg-dev libpam0g-dev libpng-dev libusb-1.0-0-dev zlib1g-dev libcups2-dev libcupsimage2-dev libssl-dev libtool libqpdf-dev poppler-utils libfontconfig1-dev libpoppler-cpp-dev libtiff5-dev libdbus-1-dev libexif-dev librsvg2-bin sharutils liblcms2-dev ghostscript pkg-config g++ --no-install-recommends

git clone https://github.com/OpenPrinting/cups-filters
cd cups-filters
./autogen.sh
./configure --prefix=/usr --disable-ldap --disable-foomatic --disable-braille --disable-mutool
make
sudo make install
```
Only the install target should fail to relink the libppd against libcupsfilters due the latter not yet being installed. With this patch the order is corrected which should solve the problem.

3 years agoMakefile.am: Removed forgotten libppd dependency in test1284 build.
Till Kamppeter [Mon, 15 Aug 2022 22:07:32 +0000 (00:07 +0200)] 
Makefile.am: Removed forgotten libppd dependency in test1284 build.

3 years agolibcupsfilters, libppd: Separated PPD file support from libcupsfilters
Till Kamppeter [Thu, 11 Aug 2022 12:51:35 +0000 (14:51 +0200)] 
libcupsfilters, libppd: Separated PPD file support from libcupsfilters

This commit reverses the dependencies of the libcupsfilters and libppd
libraries. Instead of libcupsfilters depending on libppd no libppd
depends on libcupsfilters.

This is important for removing PPD file support from OS distributions
and so allow discontinuing the maintenance of PPD-file-supporting code
in the future. In a later step libppd and the filter executables for
CUPS will get separated from the cups-filters project/repository into
their own projects/repositories.

CUPS will not use PPD files any more from version 3.0.0 on, but go
all-IPP instead. CUPS iteself will only support driverless IPP
printers (IPP Everywhere, AirPrint, Mopria) and no classic printer
drivers which consist of PPD files and filter/backend executables any
more. For printers which still need drivers Printer Applications ar
the new driver format. A Printer Application is a software emulation
of a driverless IPP printer which on the other end talks with the
physical printer.

These modifications introduce several changes on the APIs of
libcupsfilters and libppd. Software depending on these libraries (like
pappl-retrofit) needs to get adapted. All filter executables,
backends, and utilities included in cups-filters got already adapted
with this commit.

The following changes have been done:

- cf_filter_data_t gets support for an array of named extension data
  structures and does not support field for the PPD name and data any
  more. libppd defines an extension named "libppd" to hold PPD name
  and data.  Filter functions (of libppd) which explicitly use/support
  PPD files access the PPD file through this extension, others simply
  ignore the extension if present.

- All filter functions in libcupsfilters drop PPD support completely.
  They get printer-specific data only by the printer IPP attributes
  and by option settings in the option list of the cf_filter_data_t
  structure. The full functionality of each filter function is
  conserved.

- Filter functions which process or generate raster data can also get
  the parameters for the raster data as a CUPS Raster sample header.

- To continue offering PPD-supporting CUPS filters libppd provides the
  ppdLoadAttributes() to convert a PPD file into printer IPP
  attributes, the ppdFilterLoadPPD() to convert further PPD attributes
  which have no IPP equivalent into option settings and a CUPS Raster
  sample header, and the wrapper function ppdFilterCUPSWrapper()
  called by the CUPS filter executable, making the mentioned two
  functions be called before the filter function itself (in most cases
  from libcupsfilters) gets called.

- Filter functions which need PPD file support, especially those which
  output PostScript, and also the former cfFilterExternalCUPS() (now
  ppdFilterExternalCUPS()) filter function have moved to libppd.

- The support for PostScript output has also been removed. Nowadays it
  only serves for printing on PostScript printers (where one usually
  also has a PPD file), as document exchange format PostScript got
  fully replaced by PDF.

- If PPD file support cannot be added to a filter function by only
  extracting the printer's properties from the PPD via printer IPP
  attributes and option settings, a wrapper filter function is created
  in libppd. This we do for cfFilterUniversal() (to correct the output
  format according to "*cupsFilters2: ..." lines in the PPD) and for
  cfFilterPDFToPDF()/cfFilterImageToPDF() (to add JCL/PJL commands
  from the PPD file for "classic" PDF printers).

- In raster driver support code moved the functions to read parameters
  from the PPD file to libppd.

- Moved the PPD file generator used by cups-browsed and by the
  driverless utility to libppd.

- Moved the handling of common parameters, like page size, duplex,
  backside orientation, color spaces and depths, Raster headers, ...,
  by the filter functions into separate functions to not duplicate the
  code in each filter function.

- Improved the page size handling, especially accepting all types of
  parameter supply (options, job attributes, printer attributes,
  Raster headers, handling borderless printing and overspray,
  specification of size by dimensions or by name, custom size,
  margins, recognition whether user explicitly requested a page size
  (if not, use input page size if possible) ...

- Made functions for handling human-readable/translation strings (of
  the PPD generator) API functions of libcupsfilters.

I addition, fixed several minor bugs.

3 years agolibcupsfilters: In the env variables for cfFilterExternalCUPS() use CUPS 2.5.99
Till Kamppeter [Fri, 20 May 2022 14:05:23 +0000 (16:05 +0200)] 
libcupsfilters: In the env variables for cfFilterExternalCUPS() use CUPS 2.5.99

Use CUPS version 2.5.99 for the "SOFTWARE" environment variable when
calling CUPS filters or backends via the cfFilterExternalCUPS() filter
function. This is the last CUPS version which supports PPD files and
classic printer drivers.

3 years agolibcupsfilters: Correct lengths of log message prefixes
Till Kamppeter [Fri, 20 May 2022 09:38:40 +0000 (11:38 +0200)] 
libcupsfilters: Correct lengths of log message prefixes

In the cfFilterExternalCUPS() filter function we catch the stderr
(log) output of the called CUPS filter and convert it into log
function calls with correct log levels. here we need to compare
exactly the prefix, not more and not less, to safely identify the log
level of each line.

This corrects the lengths in the strncmp() calls.

3 years agolibcupsfilters: Silenced warnings and added error handling when reading EXIF
Till Kamppeter [Sat, 14 May 2022 19:08:25 +0000 (21:08 +0200)] 
libcupsfilters: Silenced warnings and added error handling when reading EXIF

The code to read an image resolution from the images EXIF data (PR

- Use "unsigned char" consistemtly

- Error handling for fread(), in case of error return NULL buffer

- Free buffer after use

3 years agolibcupsfilters: Read image resolution from EXIF data of JPEG, PNG, TIFF
Sachin Thakan [Sat, 14 May 2022 07:12:36 +0000 (12:42 +0530)] 
libcupsfilters: Read image resolution from EXIF data of JPEG, PNG, TIFF

If images are printed with "print-scaling=none" one wants to have their original size. To get an original size in absolute dimensions (inches, cm) one needs the pixel count and resolution (dpi, ppi). The resolution is supposed to be in the image's own header but in practice it is often not there.

Images from cameras, and also from some scanners, have additional metadata, the so-called EXIF data which usually contains a resolution. So we read out this with the help of libexif.

In Linux distributions there we usually have libexif and so it is no big effort to let libcupsfilters use it. But it is not required, so for low-resource systems libcupsfilters can be built without (and then not having this feature).

This completes the fix of issue #362

Pull request #466

3 years agolibcupsfilters: For ghostscript() require GS 9.56.0
Till Kamppeter [Tue, 12 Apr 2022 08:37:40 +0000 (10:37 +0200)] 
libcupsfilters: For ghostscript() require GS 9.56.0

Removed the conditionals for the presence or absemse of the
"appleraster" output device in Ghostscript (version 9.56.0 and
newer). We already require that the "pclm" device is there (GS version
9.55.0 and newer). So we remove the conditionals now and simply
require Ghostscript 9.56.0.

3 years agolibcupsfilters: Added gray PCLm support to ghostscript()
Till Kamppeter [Tue, 12 Apr 2022 08:00:28 +0000 (10:00 +0200)] 
libcupsfilters: Added gray PCLm support to ghostscript()

PCLm does not only support 24-bit sRGB bur also 8-bit sGray. All PCLm
printers, regardless of whether they are color or monochrome accept
these two color spaces. Monochrome printers have to convert color into
gray if needed.

Ghhostscript has a grayscale PCLm output device, "pclm8" since version
9.56.0. We now make use of it if the job is monochrome. This also
allows us to supply the cortrecr sGray ICC profile instead of the sRGB
one.

3 years agolibcupsfilters: Let ghostscript() do raster PDF in gray on bw jobs
Till Kamppeter [Tue, 12 Apr 2022 07:44:31 +0000 (09:44 +0200)] 
libcupsfilters: Let ghostscript() do raster PDF in gray on bw jobs

The ghostscript() filter function did PDF Image (raster PDF) output in
color if the printer is a color printer, in gray only if the printer
is monochrome. Monochrome jobs were therefore printed in color on
color printers. This commit makes grayscale output also used if the
job is monochrome.