summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2019-08-18 16:00:34 +0200
committerDidier Raboud <odyx@debian.org>2019-08-17 16:51:34 +0200
commit639a21dc0055a25ff5cf04a8be292a809fbaeaa0 (patch)
tree9f86c68684785120777fb98a5c5c615f9141d9ec
parentafbc3b66340f18427f067fd2fcf36ae4859d79c2 (diff)
parent888df0951fd76b8b1a81a9d22eeab345536bad80 (diff)
Merge branch 'debian/experimental' into debian/master
-rw-r--r--.gitignore1
-rw-r--r--AUTHORS4
-rw-r--r--COPYING36
-rw-r--r--INSTALL4
-rw-r--r--Makefile.am94
-rw-r--r--Makefile.in462
-rw-r--r--NEWS186
-rw-r--r--README336
-rw-r--r--backend/implicitclass.c284
-rw-r--r--config.h.in3
-rwxr-xr-xconfigure234
-rw-r--r--configure.ac42
-rw-r--r--cupsfilters/image-gif.c15
-rw-r--r--cupsfilters/image.c50
-rw-r--r--cupsfilters/image.h3
-rw-r--r--cupsfilters/pdftoippprinter.c905
-rw-r--r--cupsfilters/pdftoippprinter.h7
-rw-r--r--cupsfilters/ppdgenerator.c1829
-rw-r--r--cupsfilters/ppdgenerator.h31
-rw-r--r--cupsfilters/raster.c14
-rw-r--r--debian/.git-dpm14
-rw-r--r--debian/changelog68
-rw-r--r--debian/control3
-rw-r--r--debian/copyright38
-rw-r--r--debian/libcupsfilters1.symbols5
-rw-r--r--debian/patches/0001-In-liblouis1.defs.gen.in-launch-sort-with-LC_ALL-C-f.patch23
-rw-r--r--debian/patches/0002-cups-browsed-Fixed-crash-in-applying-the-BrowseFilte.patch44
-rw-r--r--debian/patches/0003-pdftopdf-Fixed-bug-of-closing-temporary-file-prematu.patch33
-rw-r--r--debian/patches/0004-cups-browsed-driverless-Correct-attributes-of-get-pr.patch48
-rw-r--r--debian/patches/0005-foomatic-rip-Changed-Ghostscript-call-to-count-pages.patch26
-rw-r--r--debian/patches/series5
-rw-r--r--filter/PDFError.h44
-rw-r--r--filter/bannertopdf.c2
-rw-r--r--filter/foomatic-rip/foomaticrip.c2
-rw-r--r--filter/foomatic-rip/foomaticrip.h2
-rw-r--r--filter/foomatic-rip/options.c2
-rw-r--r--filter/foomatic-rip/options.h2
-rw-r--r--filter/foomatic-rip/pdf.c2
-rw-r--r--filter/foomatic-rip/pdf.h2
-rw-r--r--filter/foomatic-rip/postscript.c2
-rw-r--r--filter/foomatic-rip/postscript.h2
-rw-r--r--filter/foomatic-rip/process.c2
-rw-r--r--filter/foomatic-rip/process.h2
-rw-r--r--filter/foomatic-rip/renderer.c2
-rw-r--r--filter/foomatic-rip/renderer.h2
-rw-r--r--filter/foomatic-rip/spooler.c2
-rw-r--r--filter/foomatic-rip/spooler.h2
-rw-r--r--filter/foomatic-rip/util.c2
-rw-r--r--filter/foomatic-rip/util.h2
-rw-r--r--filter/imagetopdf.c239
-rw-r--r--filter/imagetoraster.c240
-rw-r--r--filter/mupdftoraster.c81
-rw-r--r--filter/pdftoijs.cxx544
-rw-r--r--filter/pdftoopvp/99pdftoopvp.conf18
-rw-r--r--filter/pdftoopvp/OPVPError.h44
-rw-r--r--filter/pdftoopvp/OPVPOutputDev.cxx2003
-rw-r--r--filter/pdftoopvp/OPVPOutputDev.h250
-rw-r--r--filter/pdftoopvp/oprs/OPRS.cxx604
-rw-r--r--filter/pdftoopvp/oprs/OPRS.h188
-rw-r--r--filter/pdftoopvp/oprs/OPVPSplash.cxx2327
-rw-r--r--filter/pdftoopvp/oprs/OPVPSplash.h244
-rw-r--r--filter/pdftoopvp/oprs/OPVPSplashClip.cxx91
-rw-r--r--filter/pdftoopvp/oprs/OPVPSplashClip.h30
-rw-r--r--filter/pdftoopvp/oprs/OPVPSplashPath.cxx185
-rw-r--r--filter/pdftoopvp/oprs/OPVPSplashPath.h28
-rw-r--r--filter/pdftoopvp/oprs/OPVPSplashState.cxx178
-rw-r--r--filter/pdftoopvp/oprs/OPVPSplashState.h95
-rw-r--r--filter/pdftoopvp/oprs/OPVPSplashXPath.cxx426
-rw-r--r--filter/pdftoopvp/oprs/OPVPSplashXPath.h39
-rw-r--r--filter/pdftoopvp/oprs/OPVPWrapper.cxx910
-rw-r--r--filter/pdftoopvp/oprs/OPVPWrapper.h205
-rw-r--r--filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx1172
-rw-r--r--filter/pdftoopvp/oprs/OPVPWrapper_0_2.h127
-rw-r--r--filter/pdftoopvp/opvp/opvp.h292
-rw-r--r--filter/pdftoopvp/opvp/opvp_0_2_0.h298
-rw-r--r--filter/pdftoopvp/opvp/opvp_common.h54
-rw-r--r--filter/pdftoopvp/pdftoopvp.cxx797
-rw-r--r--filter/pdftopdf/pdftopdf.cc134
-rw-r--r--filter/pdftopdf/pdftopdf_processor.cc71
-rw-r--r--filter/pdftopdf/pdftopdf_processor.h19
-rw-r--r--filter/pdftopdf/qpdf_pdftopdf_processor.cc103
-rw-r--r--filter/pdftopdf/qpdf_pdftopdf_processor.h9
-rw-r--r--filter/pdftops.c293
-rw-r--r--filter/pdftoraster.cxx407
-rw-r--r--filter/rastertops.c33
-rw-r--r--filter/urftopdf.cpp4
-rw-r--r--ltmain.sh375
-rw-r--r--m4/libtool.m49
-rw-r--r--ppd/HP-PhotoSmart_Pro_B8300-hpijs-pdftoijs.ppd342
-rw-r--r--utils/cups-browsed.c4646
-rw-r--r--utils/cups-browsed.conf.55
-rw-r--r--utils/cups-browsed.conf.in6
-rw-r--r--utils/driverless.122
-rw-r--r--utils/driverless.c3
94 files changed, 7748 insertions, 15367 deletions
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 845ca0677..000000000
--- a/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-.pc
diff --git a/AUTHORS b/AUTHORS
index d47a3269b..277019118 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -2,7 +2,7 @@ Till Kamppeter, OpenPrinting/Canonical (till.kamppeter@gmail.com)
Michael Sweet, Apple (msweet@apple.com)
Koji Otani, BBR Inc. (sho@bbr.jp)
Tobias Hoffmann (th55@gmx.de)
-Lars Übernickel, Canonical (lars@uebernic.de)
+Lars Karlitski (formerly Übernickel), Red Hat (lars@karlitski.net)
Tim Waugh (twaugh@redhat.com)
Tomáš Chvátal (tomas.chvatal@gmail.com)
Franz Pförtsch (Franz.Pfoertsch@brose.com)
@@ -10,3 +10,5 @@ Neil 'Superna' Armstrong (superna9999@gmail.com)
Samuel Thibault (samuel.thibault@ens-lyon.org)
Pranjal Bhor (bhor.pranjal@gmail.com)
Sahil Arora (sahilarora.535@gmail.com)
+Deepak Patankar (patankardeepak04@gmail.com)
+Tanmay Anand (tanand@iitk.ac.in)
diff --git a/COPYING b/COPYING
index 140aae1d0..66ebde121 100644
--- a/COPYING
+++ b/COPYING
@@ -16,11 +16,16 @@ Copyright: 1993-2007 Easy Software Products
2012 Tomáš Chvátal
2010 Neil 'Superna' Armstrong
2015-2016 Samuel Thibault
- 2008 Lars Übernickel
+ 2008 Lars Karlitski (formerly Übernickel)
License: GPL-2+
+Files: backend/implicitclass.c
+Copyright: 2015, Till Kamppeter
+ 2008-2015, Apple Inc
+ 2018-2019, Deepak Patankar
+License: GPL-2
+
Files: backend/beh.c
- backend/implicitclass.c
Copyright: 2015, Till Kamppeter
2008-2015, Apple Inc
License: GPL-2
@@ -39,9 +44,10 @@ Copyright: 2007-2016 Apple Inc
1993-2007 by Easy Software Products
2011-2013, Richard Hughes
2011, Tim Waugh
- 2013-2016, Till Kamppeter
+ 2013-2019, Till Kamppeter
2014, Joseph Simon
2017, Sahil Arora
+ 2018-2019, Deepak Patankar
License: LGPL-2
Files: cupsfilters/colord.c
@@ -62,9 +68,9 @@ Files: cupsfilters/colormanager.h
Copyright: 2014, Joseph Simon
License: Expat
-Files: filter/PDFError.h
- filter/pdftoraster.cxx
+Files: filter/pdftoraster.cxx
Copyright: 2008-2012, BBR Inc.
+ 2019, Tanmay Anand
License: Expat
Files: filter/banner.c
@@ -117,7 +123,7 @@ License: GPL-2
Files: filter/foomatic-rip/*
Copyright: 2008, Till Kamppeter <till.kamppeter@gmail.com>
- 2008, Lars Uebernickel <larsuebernickel@gmx.de>
+ 2008, Lars Karlitski (formerly Übernickel) <lars@karlitski.net>
License: GPL-2+
Files: filter/getline.c
@@ -145,21 +151,6 @@ Files: filter/imagetopdf*
Copyright: 1993-2007, Easy Software Products
License: GPL-2
-Files: filter/pdftoijs.cxx
- ppd/HP-PhotoSmart_Pro_B8300-hpijs-pdftoijs.ppd
-Copyright: 2008, Tobias Hoffmann
- 2008, BBR Inc.
-License: Expat
-
-Files: filter/pdftoopvp/*
-Copyright: 2003, 2004, 2005, 2006, AXE,Inc
- 2007, 2008, ModifiedBBR Inc.
- 2003, Glyph & Cog, LLC
- 2006, Fuji Xerox Printing Systems Co., Ltd
- 2006, Free Standards Group
- 2006, Canon Inc
-License: Expat
-
Files: filter/pdftopdf/*
Copyright: 2012 Tobias Hoffmann
2006-2011, BBR Inc
@@ -246,8 +237,9 @@ License: GPL-2+
Files: utils/cups-browsed*
org.cups.cupsd.Notifier.xml
-Copyright: 2012-2016 Till Kamppeter
+Copyright: 2012-2019 Till Kamppeter
2013-2015 Tim Waugh
+ 2018-2019 Deepak Patankar
License: LGPL-2.1+
Files: utils/driverless*
diff --git a/INSTALL b/INSTALL
index 461c3b144..70469863d 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,4 +1,4 @@
-INSTALL - OpenPrinting CUPS Filters v1.21.6 - 2018-12-17
+INSTALL - OpenPrinting CUPS Filters v1.25.0 - 2019-06-06
--------------------------------------------------------
This file describes how to compile and install OpenPrinting CUPS
@@ -24,7 +24,7 @@ BEFORE YOU BEGIN
Compaq, HP, SGI, and Sun. BSD users should use GNU make (gmake) since BSD
make does not support "include".
- Poppler, libijs, freetype, fontconfig, and liblcms (liblcms2 recommended)
+ Poppler, freetype, fontconfig, and liblcms (liblcms2 recommended)
must be installed to be able to compile this package.
Note that Poppler has to be compiled with the
diff --git a/Makefile.am b/Makefile.am
index cfefa5a2c..72e023ed4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -68,8 +68,10 @@ beh_CFLAGS = $(CUPS_CFLAGS)
implicitclass_SOURCES = \
backend/backend-private.h \
backend/implicitclass.c
-implicitclass_LDADD = $(CUPS_LIBS)
-implicitclass_CFLAGS = $(CUPS_CFLAGS)
+implicitclass_LDADD = $(CUPS_LIBS)\
+ libcupsfilters.la
+implicitclass_CFLAGS = $(CUPS_CFLAGS)\
+ -I$(srcdir)/cupsfilters/
test1284_SOURCES = \
backend/backend-private.h \
@@ -143,7 +145,8 @@ pkgfiltersinclude_DATA = \
cupsfilters/driver.h \
cupsfilters/image.h \
cupsfilters/raster.h \
- cupsfilters/ppdgenerator.h
+ cupsfilters/ppdgenerator.h \
+ cupsfilters/pdftoippprinter.h
lib_LTLIBRARIES = libcupsfilters.la
@@ -176,6 +179,7 @@ libcupsfilters_la_SOURCES = \
cupsfilters/colormanager.c \
cupsfilters/dither.c \
cupsfilters/image.c \
+ cupsfilters/pdftoippprinter.c \
cupsfilters/image-bmp.c \
cupsfilters/image-colorspace.c \
cupsfilters/image-gif.c \
@@ -482,61 +486,6 @@ EXTRA_DIST += \
pkgfilter_PROGRAMS =
pkgfilterdir = $(CUPS_SERVERBIN)/filter
-# ===========
-# PDF to OPVP
-# ===========
-if ENABLE_OPVP
-if ENABLE_POPPLER
-pkgfilter_PROGRAMS += \
- pdftoopvp
-
-pkgfontconfigdir = $(sysconfdir)/$(FONTDIR)
-pkgfontconfig_DATA = filter/pdftoopvp/99pdftoopvp.conf
-endif
-endif
-EXTRA_DIST += filter/pdftoopvp/99pdftoopvp.conf
-
-pdftoopvp_SOURCES = \
- filter/pdftoopvp/oprs/OPRS.cxx \
- filter/pdftoopvp/oprs/OPRS.h \
- filter/pdftoopvp/oprs/OPVPSplashClip.cxx \
- filter/pdftoopvp/oprs/OPVPSplashClip.h \
- filter/pdftoopvp/oprs/OPVPSplash.cxx \
- filter/pdftoopvp/oprs/OPVPSplash.h \
- filter/pdftoopvp/oprs/OPVPSplashPath.cxx \
- filter/pdftoopvp/oprs/OPVPSplashPath.h \
- filter/pdftoopvp/oprs/OPVPSplashState.cxx \
- filter/pdftoopvp/oprs/OPVPSplashState.h \
- filter/pdftoopvp/oprs/OPVPSplashXPath.cxx \
- filter/pdftoopvp/oprs/OPVPSplashXPath.h \
- filter/pdftoopvp/oprs/OPVPWrapper.cxx \
- filter/pdftoopvp/oprs/OPVPWrapper.h \
- filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx \
- filter/pdftoopvp/oprs/OPVPWrapper_0_2.h \
- filter/pdftoopvp/OPVPError.h \
- filter/pdftoopvp/opvp/opvp_common.h \
- filter/pdftoopvp/opvp/opvp.h \
- filter/pdftoopvp/opvp/opvp_0_2_0.h \
- filter/pdftoopvp/OPVPOutputDev.cxx \
- filter/pdftoopvp/OPVPOutputDev.h \
- filter/pdftoopvp/pdftoopvp.cxx
-pdftoopvp_CFLAGS = \
- $(CUPS_CFLAGS) \
- $(FREETYPE_CFLAGS) \
- $(FONTCONFIG_CFLAGS) \
- $(LIBPNG_CFLAGS) \
- $(POPPLER_CFLAGS) \
- -I$(srcdir)/filter/pdftoopvp/oprs \
- -I$(srcdir)/filter/pdftoopvp/opvp
-pdftoopvp_CXXFLAGS = $(pdftoopvp_CFLAGS)
-pdftoopvp_LDADD = \
- $(CUPS_LIBS) \
- $(FREETYPE_LIBS) \
- $(FONTCONFIG_LIBS) \
- $(LIBPNG_LIBS) \
- $(POPPLER_LIBS) \
- $(DLOPEN_LIBS)
-
# ==========
# PDF to PDF
# ==========
@@ -619,10 +568,6 @@ endif
if ENABLE_POPPLER
pkgfilter_PROGRAMS += \
pdftoraster
-if ENABLE_IJS
-pkgfilter_PROGRAMS += \
- pdftoijs
-endif
endif
if ENABLE_GHOSTSCRIPT
pkgfilter_PROGRAMS += \
@@ -729,6 +674,7 @@ foomatic_rip_SOURCES = \
cupsfilters/colord.h
foomatic_rip_CFLAGS = \
-DCONFIG_PATH='"$(sysconfdir)/foomatic"' \
+ $(CUPS_CFLAGS) \
-I$(srcdir)/cupsfilters/
foomatic_rip_LDADD = \
$(CUPS_LIBS) \
@@ -819,19 +765,6 @@ rastertops_LDADD = \
-lz \
libcupsfilters.la
-pdftoijs_SOURCES = \
- filter/pdftoijs.cxx \
- filter/PDFError.h
-pdftoijs_CFLAGS = \
- $(CUPS_CFLAGS) \
- $(IJS_CFLAGS) \
- $(POPPLER_CFLAGS)
-pdftoijs_CXXFLAGS = $(pdftoijs_CFLAGS)
-pdftoijs_LDADD = \
- $(CUPS_LIBS) \
- $(IJS_LIBS) \
- $(POPPLER_LIBS)
-
sys5ippprinter_SOURCES = \
filter/common.c \
filter/common.h \
@@ -858,8 +791,7 @@ pdftops_LDADD = $(STRCASESTR) $(CUPS_LIBS)
pdftops_DEPENDENCIES = $(STRCASESTR)
pdftoraster_SOURCES = \
- filter/pdftoraster.cxx \
- filter/PDFError.h
+ filter/pdftoraster.cxx
pdftoraster_CFLAGS = \
$(CUPS_CFLAGS) \
$(LCMS_CFLAGS) \
@@ -1017,13 +949,6 @@ genppdfiles = \
ppd/HP-Color_LaserJet_CM3530_MFP-PDF.ppd \
ppd/Ricoh-PDF_Printer-PDF.ppd
ppd_DATA = $(genppdfiles)
-ijsppdfiles = \
- ppd/HP-PhotoSmart_Pro_B8300-hpijs-pdftoijs.ppd
-if ENABLE_POPPLER
-if ENABLE_IJS
-ppd_DATA += $(ijsppdfiles)
-endif
-endif
gsppdfiles = \
ppd/pxlcolor.ppd \
ppd/pxlmono.ppd
@@ -1033,7 +958,6 @@ endif
EXTRA_DIST += \
$(genppdfiles) \
- $(ijsppdfiles) \
$(gsppdfiles)
# =========
diff --git a/Makefile.in b/Makefile.in
index fc48d5ab5..72ba5c93c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -110,49 +110,37 @@ TESTS = testdither$(EXEEXT) test_analyze$(EXEEXT) test_pdf$(EXEEXT) \
@ENABLE_MUTOOL_TRUE@am__append_8 = $(mutoolmimefiles)
@ENABLE_BRAILLE_TRUE@am__append_9 = $(brlmimefiles)
bin_PROGRAMS = ttfread$(EXEEXT)
-pkgfilter_PROGRAMS = $(am__EXEEXT_2) pdftopdf$(EXEEXT) \
- commandtoescpx$(EXEEXT) commandtopclx$(EXEEXT) \
- sys5ippprinter$(EXEEXT) texttotext$(EXEEXT) pdftops$(EXEEXT) \
- rastertoescpx$(EXEEXT) rastertopclx$(EXEEXT) \
- texttopdf$(EXEEXT) rastertopdf$(EXEEXT) bannertopdf$(EXEEXT) \
- rastertops$(EXEEXT) $(am__EXEEXT_3) $(am__EXEEXT_4) \
- $(am__EXEEXT_5) $(am__EXEEXT_6) $(am__EXEEXT_7) \
- $(am__EXEEXT_8) $(am__EXEEXT_9)
-
-# ===========
-# PDF to OPVP
-# ===========
-@ENABLE_OPVP_TRUE@@ENABLE_POPPLER_TRUE@am__append_10 = \
-@ENABLE_OPVP_TRUE@@ENABLE_POPPLER_TRUE@ pdftoopvp
-
-@ENABLE_GHOSTSCRIPT_TRUE@am__append_11 = $(gsfilterscripts)
-@ENABLE_URFTOPDF_TRUE@am__append_12 = \
+pkgfilter_PROGRAMS = pdftopdf$(EXEEXT) commandtoescpx$(EXEEXT) \
+ commandtopclx$(EXEEXT) sys5ippprinter$(EXEEXT) \
+ texttotext$(EXEEXT) pdftops$(EXEEXT) rastertoescpx$(EXEEXT) \
+ rastertopclx$(EXEEXT) texttopdf$(EXEEXT) rastertopdf$(EXEEXT) \
+ bannertopdf$(EXEEXT) rastertops$(EXEEXT) $(am__EXEEXT_2) \
+ $(am__EXEEXT_3) $(am__EXEEXT_4) $(am__EXEEXT_5) \
+ $(am__EXEEXT_6) $(am__EXEEXT_7)
+@ENABLE_GHOSTSCRIPT_TRUE@am__append_10 = $(gsfilterscripts)
+@ENABLE_URFTOPDF_TRUE@am__append_11 = \
@ENABLE_URFTOPDF_TRUE@ urftopdf
-@ENABLE_POPPLER_TRUE@am__append_13 = \
+@ENABLE_POPPLER_TRUE@am__append_12 = \
@ENABLE_POPPLER_TRUE@ pdftoraster
-@ENABLE_IJS_TRUE@@ENABLE_POPPLER_TRUE@am__append_14 = \
-@ENABLE_IJS_TRUE@@ENABLE_POPPLER_TRUE@ pdftoijs
-
-@ENABLE_GHOSTSCRIPT_TRUE@am__append_15 = \
+@ENABLE_GHOSTSCRIPT_TRUE@am__append_13 = \
@ENABLE_GHOSTSCRIPT_TRUE@ gstoraster
-@ENABLE_MUTOOL_TRUE@am__append_16 = \
+@ENABLE_MUTOOL_TRUE@am__append_14 = \
@ENABLE_MUTOOL_TRUE@ mupdftoraster
-@ENABLE_FOOMATIC_TRUE@am__append_17 = \
+@ENABLE_FOOMATIC_TRUE@am__append_15 = \
@ENABLE_FOOMATIC_TRUE@ foomatic-rip
-@ENABLE_IMAGEFILTERS_TRUE@am__append_18 = \
+@ENABLE_IMAGEFILTERS_TRUE@am__append_16 = \
@ENABLE_IMAGEFILTERS_TRUE@ imagetopdf \
@ENABLE_IMAGEFILTERS_TRUE@ imagetoraster
sbin_PROGRAMS = cups-browsed$(EXEEXT)
-@ENABLE_DRIVERLESS_TRUE@am__append_19 = $(driverlessmanpages)
-@ENABLE_FOOMATIC_TRUE@am__append_20 = $(foomaticmanpages)
-@ENABLE_IJS_TRUE@@ENABLE_POPPLER_TRUE@am__append_21 = $(ijsppdfiles)
-@ENABLE_GHOSTSCRIPT_TRUE@am__append_22 = $(gsppdfiles)
+@ENABLE_DRIVERLESS_TRUE@am__append_17 = $(driverlessmanpages)
+@ENABLE_FOOMATIC_TRUE@am__append_18 = $(foomaticmanpages)
+@ENABLE_GHOSTSCRIPT_TRUE@am__append_19 = $(gsppdfiles)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \
@@ -204,21 +192,16 @@ am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgbackenddir)" \
"$(DESTDIR)$(pkgcupsserverrootdir)" \
"$(DESTDIR)$(pkgdriverdir)" \
"$(DESTDIR)$(pkgfiltersincludedir)" \
- "$(DESTDIR)$(pkgfontconfigdir)" \
"$(DESTDIR)$(pkgfontembedincludedir)" \
"$(DESTDIR)$(pkgmimedir)" "$(DESTDIR)$(pkgppdcdir)" \
"$(DESTDIR)$(ppddir)"
@ENABLE_BRAILLE_TRUE@am__EXEEXT_1 = cups-brf$(EXEEXT)
-@ENABLE_OPVP_TRUE@@ENABLE_POPPLER_TRUE@am__EXEEXT_2 = \
-@ENABLE_OPVP_TRUE@@ENABLE_POPPLER_TRUE@ pdftoopvp$(EXEEXT)
-@ENABLE_URFTOPDF_TRUE@am__EXEEXT_3 = urftopdf$(EXEEXT)
-@ENABLE_POPPLER_TRUE@am__EXEEXT_4 = pdftoraster$(EXEEXT)
-@ENABLE_IJS_TRUE@@ENABLE_POPPLER_TRUE@am__EXEEXT_5 = \
-@ENABLE_IJS_TRUE@@ENABLE_POPPLER_TRUE@ pdftoijs$(EXEEXT)
-@ENABLE_GHOSTSCRIPT_TRUE@am__EXEEXT_6 = gstoraster$(EXEEXT)
-@ENABLE_MUTOOL_TRUE@am__EXEEXT_7 = mupdftoraster$(EXEEXT)
-@ENABLE_FOOMATIC_TRUE@am__EXEEXT_8 = foomatic-rip$(EXEEXT)
-@ENABLE_IMAGEFILTERS_TRUE@am__EXEEXT_9 = imagetopdf$(EXEEXT) \
+@ENABLE_URFTOPDF_TRUE@am__EXEEXT_2 = urftopdf$(EXEEXT)
+@ENABLE_POPPLER_TRUE@am__EXEEXT_3 = pdftoraster$(EXEEXT)
+@ENABLE_GHOSTSCRIPT_TRUE@am__EXEEXT_4 = gstoraster$(EXEEXT)
+@ENABLE_MUTOOL_TRUE@am__EXEEXT_5 = mupdftoraster$(EXEEXT)
+@ENABLE_FOOMATIC_TRUE@am__EXEEXT_6 = foomatic-rip$(EXEEXT)
+@ENABLE_IMAGEFILTERS_TRUE@am__EXEEXT_7 = imagetopdf$(EXEEXT) \
@ENABLE_IMAGEFILTERS_TRUE@ imagetoraster$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS) $(pkgbackend_PROGRAMS) \
$(pkgfilter_PROGRAMS) $(pkgppdgen_PROGRAMS) $(sbin_PROGRAMS)
@@ -260,6 +243,7 @@ am_libcupsfilters_la_OBJECTS = libcupsfilters_la-attr.lo \
libcupsfilters_la-check.lo libcupsfilters_la-cmyk.lo \
libcupsfilters_la-colord.lo libcupsfilters_la-colormanager.lo \
libcupsfilters_la-dither.lo libcupsfilters_la-image.lo \
+ libcupsfilters_la-pdftoippprinter.lo \
libcupsfilters_la-image-bmp.lo \
libcupsfilters_la-image-colorspace.lo \
libcupsfilters_la-image-gif.lo libcupsfilters_la-image-jpeg.lo \
@@ -376,7 +360,7 @@ imagetoraster_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
am_implicitclass_OBJECTS = implicitclass-implicitclass.$(OBJEXT)
implicitclass_OBJECTS = $(am_implicitclass_OBJECTS)
-implicitclass_DEPENDENCIES = $(am__DEPENDENCIES_1)
+implicitclass_DEPENDENCIES = $(am__DEPENDENCIES_1) libcupsfilters.la
implicitclass_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(implicitclass_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
@@ -393,30 +377,6 @@ parallel_DEPENDENCIES = $(am__DEPENDENCIES_1)
parallel_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(parallel_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-am_pdftoijs_OBJECTS = pdftoijs-pdftoijs.$(OBJEXT)
-pdftoijs_OBJECTS = $(am_pdftoijs_OBJECTS)
-pdftoijs_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
-pdftoijs_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(pdftoijs_CXXFLAGS) \
- $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-am_pdftoopvp_OBJECTS = pdftoopvp-OPRS.$(OBJEXT) \
- pdftoopvp-OPVPSplashClip.$(OBJEXT) \
- pdftoopvp-OPVPSplash.$(OBJEXT) \
- pdftoopvp-OPVPSplashPath.$(OBJEXT) \
- pdftoopvp-OPVPSplashState.$(OBJEXT) \
- pdftoopvp-OPVPSplashXPath.$(OBJEXT) \
- pdftoopvp-OPVPWrapper.$(OBJEXT) \
- pdftoopvp-OPVPWrapper_0_2.$(OBJEXT) \
- pdftoopvp-OPVPOutputDev.$(OBJEXT) \
- pdftoopvp-pdftoopvp.$(OBJEXT)
-pdftoopvp_OBJECTS = $(am_pdftoopvp_OBJECTS)
-pdftoopvp_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-pdftoopvp_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(pdftoopvp_CXXFLAGS) \
- $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
am_pdftopdf_OBJECTS = pdftopdf-pdftopdf.$(OBJEXT) \
pdftopdf-pdftopdf_jcl.$(OBJEXT) \
pdftopdf-pdftopdf_processor.$(OBJEXT) \
@@ -619,6 +579,7 @@ am__depfiles_remade = ./$(DEPDIR)/aglfn13.Plo \
./$(DEPDIR)/libcupsfilters_la-image.Plo \
./$(DEPDIR)/libcupsfilters_la-lut.Plo \
./$(DEPDIR)/libcupsfilters_la-pack.Plo \
+ ./$(DEPDIR)/libcupsfilters_la-pdftoippprinter.Plo \
./$(DEPDIR)/libcupsfilters_la-ppdgenerator.Plo \
./$(DEPDIR)/libcupsfilters_la-raster.Plo \
./$(DEPDIR)/libcupsfilters_la-rgb.Plo \
@@ -627,16 +588,6 @@ am__depfiles_remade = ./$(DEPDIR)/aglfn13.Plo \
./$(DEPDIR)/mupdftoraster-mupdftoraster.Po \
./$(DEPDIR)/parallel-ieee1284.Po \
./$(DEPDIR)/parallel-parallel.Po \
- ./$(DEPDIR)/pdftoijs-pdftoijs.Po ./$(DEPDIR)/pdftoopvp-OPRS.Po \
- ./$(DEPDIR)/pdftoopvp-OPVPOutputDev.Po \
- ./$(DEPDIR)/pdftoopvp-OPVPSplash.Po \
- ./$(DEPDIR)/pdftoopvp-OPVPSplashClip.Po \
- ./$(DEPDIR)/pdftoopvp-OPVPSplashPath.Po \
- ./$(DEPDIR)/pdftoopvp-OPVPSplashState.Po \
- ./$(DEPDIR)/pdftoopvp-OPVPSplashXPath.Po \
- ./$(DEPDIR)/pdftoopvp-OPVPWrapper.Po \
- ./$(DEPDIR)/pdftoopvp-OPVPWrapper_0_2.Po \
- ./$(DEPDIR)/pdftoopvp-pdftoopvp.Po \
./$(DEPDIR)/pdftopdf-intervalset.Po \
./$(DEPDIR)/pdftopdf-nup.Po ./$(DEPDIR)/pdftopdf-pdftopdf.Po \
./$(DEPDIR)/pdftopdf-pdftopdf_jcl.Po \
@@ -721,8 +672,7 @@ SOURCES = $(libcupsfilters_la_SOURCES) $(libfontembed_la_SOURCES) \
$(foomatic_rip_SOURCES) $(gstoraster_SOURCES) \
$(imagetopdf_SOURCES) $(imagetoraster_SOURCES) \
$(implicitclass_SOURCES) $(mupdftoraster_SOURCES) \
- $(parallel_SOURCES) $(pdftoijs_SOURCES) $(pdftoopvp_SOURCES) \
- $(pdftopdf_SOURCES) $(pdftops_SOURCES) \
+ $(parallel_SOURCES) $(pdftopdf_SOURCES) $(pdftops_SOURCES) \
$(EXTRA_pdftops_SOURCES) $(pdftoraster_SOURCES) \
$(rastertoescpx_SOURCES) $(rastertopclx_SOURCES) \
$(rastertopdf_SOURCES) $(rastertops_SOURCES) $(serial_SOURCES) \
@@ -742,11 +692,10 @@ DIST_SOURCES = $(libcupsfilters_la_SOURCES) $(libfontembed_la_SOURCES) \
$(gstoraster_SOURCES) $(imagetopdf_SOURCES) \
$(imagetoraster_SOURCES) $(implicitclass_SOURCES) \
$(mupdftoraster_SOURCES) $(parallel_SOURCES) \
- $(pdftoijs_SOURCES) $(pdftoopvp_SOURCES) $(pdftopdf_SOURCES) \
- $(pdftops_SOURCES) $(EXTRA_pdftops_SOURCES) \
- $(pdftoraster_SOURCES) $(rastertoescpx_SOURCES) \
- $(rastertopclx_SOURCES) $(rastertopdf_SOURCES) \
- $(rastertops_SOURCES) $(serial_SOURCES) \
+ $(pdftopdf_SOURCES) $(pdftops_SOURCES) \
+ $(EXTRA_pdftops_SOURCES) $(pdftoraster_SOURCES) \
+ $(rastertoescpx_SOURCES) $(rastertopclx_SOURCES) \
+ $(rastertopdf_SOURCES) $(rastertops_SOURCES) $(serial_SOURCES) \
$(sys5ippprinter_SOURCES) $(EXTRA_sys5ippprinter_SOURCES) \
$(test1284_SOURCES) $(test_analyze_SOURCES) \
$(test_pdf_SOURCES) $(test_pdf1_SOURCES) $(test_pdf2_SOURCES) \
@@ -767,9 +716,8 @@ MANS = $(man_MANS)
DATA = $(doc_DATA) $(nodist_pkgppdc_DATA) $(pkgbanner_DATA) \
$(pkgcharset_DATA) $(pkgconf_DATA) $(pkgcupsdata_DATA) \
$(pkgcupsserverroot_DATA) $(pkgdriver_DATA) \
- $(pkgfiltersinclude_DATA) $(pkgfontconfig_DATA) \
- $(pkgfontembedinclude_DATA) $(pkgmime_DATA) $(pkgppdc_DATA) \
- $(ppd_DATA)
+ $(pkgfiltersinclude_DATA) $(pkgfontembedinclude_DATA) \
+ $(pkgmime_DATA) $(pkgppdc_DATA) $(ppd_DATA)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)config.h.in
# Read a list of newline-separated strings from the standard input,
@@ -1073,8 +1021,6 @@ GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
GREP = @GREP@
HAVE_CXX11 = @HAVE_CXX11@
-IJS_CFLAGS = @IJS_CFLAGS@
-IJS_LIBS = @IJS_LIBS@
INITDDIR = @INITDDIR@
INITDIR = @INITDIR@
INSTALL = @INSTALL@
@@ -1224,13 +1170,11 @@ EXTRA_DIST = $(doc_DATA) autogen.sh libcupsfilters.pc.in \
$(brlppdcfiles) $(genmimefiles) $(popplermimefiles) \
$(gsmimefiles) $(mutoolmimefiles) $(brlmimefiles) \
mime/cupsfilters.convs.in $(pkgfontembedinclude_DATA) \
- fontembed/README filter/pdftoopvp/99pdftoopvp.conf \
- $(genfilterscripts) $(gsfilterscripts) filter/test.sh \
- utils/cups-browsed.in $(cupsbrowsedmanpages) \
+ fontembed/README $(genfilterscripts) $(gsfilterscripts) \
+ filter/test.sh utils/cups-browsed.in $(cupsbrowsedmanpages) \
$(driverlessmanpages) filter/foomatic-rip/foomatic-rip.1.in \
- utils/org.cups.cupsd.Notifier.xml $(genppdfiles) \
- $(ijsppdfiles) $(gsppdfiles) scripting/perl \
- scripting/php/README scripting/php/phpcups.php
+ utils/org.cups.cupsd.Notifier.xml $(genppdfiles) $(gsppdfiles) \
+ scripting/perl scripting/php/README scripting/php/phpcups.php
# ========
# Backends
@@ -1262,8 +1206,12 @@ implicitclass_SOURCES = \
backend/backend-private.h \
backend/implicitclass.c
-implicitclass_LDADD = $(CUPS_LIBS)
-implicitclass_CFLAGS = $(CUPS_CFLAGS)
+implicitclass_LDADD = $(CUPS_LIBS)\
+ libcupsfilters.la
+
+implicitclass_CFLAGS = $(CUPS_CFLAGS)\
+ -I$(srcdir)/cupsfilters/
+
test1284_SOURCES = \
backend/backend-private.h \
backend/ieee1284.c \
@@ -1326,7 +1274,8 @@ pkgfiltersinclude_DATA = \
cupsfilters/driver.h \
cupsfilters/image.h \
cupsfilters/raster.h \
- cupsfilters/ppdgenerator.h
+ cupsfilters/ppdgenerator.h \
+ cupsfilters/pdftoippprinter.h
lib_LTLIBRARIES = libcupsfilters.la libfontembed.la
# testcmyk # fails as it opens some image.ppm which is nowerhe to be found.
@@ -1349,6 +1298,7 @@ libcupsfilters_la_SOURCES = \
cupsfilters/colormanager.c \
cupsfilters/dither.c \
cupsfilters/image.c \
+ cupsfilters/pdftoippprinter.c \
cupsfilters/image-bmp.c \
cupsfilters/image-colorspace.c \
cupsfilters/image-gif.c \
@@ -1575,51 +1525,6 @@ test_pdf_LDADD = libfontembed.la
test_ps_SOURCES = fontembed/test_ps.c
test_ps_LDADD = libfontembed.la
pkgfilterdir = $(CUPS_SERVERBIN)/filter
-@ENABLE_OPVP_TRUE@@ENABLE_POPPLER_TRUE@pkgfontconfigdir = $(sysconfdir)/$(FONTDIR)
-@ENABLE_OPVP_TRUE@@ENABLE_POPPLER_TRUE@pkgfontconfig_DATA = filter/pdftoopvp/99pdftoopvp.conf
-pdftoopvp_SOURCES = \
- filter/pdftoopvp/oprs/OPRS.cxx \
- filter/pdftoopvp/oprs/OPRS.h \
- filter/pdftoopvp/oprs/OPVPSplashClip.cxx \
- filter/pdftoopvp/oprs/OPVPSplashClip.h \
- filter/pdftoopvp/oprs/OPVPSplash.cxx \
- filter/pdftoopvp/oprs/OPVPSplash.h \
- filter/pdftoopvp/oprs/OPVPSplashPath.cxx \
- filter/pdftoopvp/oprs/OPVPSplashPath.h \
- filter/pdftoopvp/oprs/OPVPSplashState.cxx \
- filter/pdftoopvp/oprs/OPVPSplashState.h \
- filter/pdftoopvp/oprs/OPVPSplashXPath.cxx \
- filter/pdftoopvp/oprs/OPVPSplashXPath.h \
- filter/pdftoopvp/oprs/OPVPWrapper.cxx \
- filter/pdftoopvp/oprs/OPVPWrapper.h \
- filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx \
- filter/pdftoopvp/oprs/OPVPWrapper_0_2.h \
- filter/pdftoopvp/OPVPError.h \
- filter/pdftoopvp/opvp/opvp_common.h \
- filter/pdftoopvp/opvp/opvp.h \
- filter/pdftoopvp/opvp/opvp_0_2_0.h \
- filter/pdftoopvp/OPVPOutputDev.cxx \
- filter/pdftoopvp/OPVPOutputDev.h \
- filter/pdftoopvp/pdftoopvp.cxx
-
-pdftoopvp_CFLAGS = \
- $(CUPS_CFLAGS) \
- $(FREETYPE_CFLAGS) \
- $(FONTCONFIG_CFLAGS) \
- $(LIBPNG_CFLAGS) \
- $(POPPLER_CFLAGS) \
- -I$(srcdir)/filter/pdftoopvp/oprs \
- -I$(srcdir)/filter/pdftoopvp/opvp
-
-pdftoopvp_CXXFLAGS = $(pdftoopvp_CFLAGS)
-pdftoopvp_LDADD = \
- $(CUPS_LIBS) \
- $(FREETYPE_LIBS) \
- $(FONTCONFIG_LIBS) \
- $(LIBPNG_LIBS) \
- $(POPPLER_LIBS) \
- $(DLOPEN_LIBS)
-
pdftopdf_SOURCES = \
filter/pdftopdf/pdftopdf.cc \
filter/pdftopdf/pdftopdf_jcl.cc \
@@ -1661,7 +1566,7 @@ genfilterscripts = \
filter/texttops \
filter/rastertopclm
-pkgfilter_SCRIPTS = $(genfilterscripts) $(am__append_11)
+pkgfilter_SCRIPTS = $(genfilterscripts) $(am__append_10)
gsfilterscripts = \
filter/gstopxl \
filter/gstopdf
@@ -1753,6 +1658,7 @@ foomatic_rip_SOURCES = \
foomatic_rip_CFLAGS = \
-DCONFIG_PATH='"$(sysconfdir)/foomatic"' \
+ $(CUPS_CFLAGS) \
-I$(srcdir)/cupsfilters/
foomatic_rip_LDADD = \
@@ -1858,21 +1764,6 @@ rastertops_LDADD = \
-lz \
libcupsfilters.la
-pdftoijs_SOURCES = \
- filter/pdftoijs.cxx \
- filter/PDFError.h
-
-pdftoijs_CFLAGS = \
- $(CUPS_CFLAGS) \
- $(IJS_CFLAGS) \
- $(POPPLER_CFLAGS)
-
-pdftoijs_CXXFLAGS = $(pdftoijs_CFLAGS)
-pdftoijs_LDADD = \
- $(CUPS_LIBS) \
- $(IJS_LIBS) \
- $(POPPLER_LIBS)
-
sys5ippprinter_SOURCES = \
filter/common.c \
filter/common.h \
@@ -1899,8 +1790,7 @@ pdftops_CFLAGS = $(CUPS_CFLAGS)
pdftops_LDADD = $(STRCASESTR) $(CUPS_LIBS)
pdftops_DEPENDENCIES = $(STRCASESTR)
pdftoraster_SOURCES = \
- filter/pdftoraster.cxx \
- filter/PDFError.h
+ filter/pdftoraster.cxx
pdftoraster_CFLAGS = \
$(CUPS_CFLAGS) \
@@ -2032,7 +1922,7 @@ cupsbrowsedmanpages = \
utils/cups-browsed.8 \
utils/cups-browsed.conf.5
-man_MANS = $(cupsbrowsedmanpages) $(am__append_19) $(am__append_20)
+man_MANS = $(cupsbrowsedmanpages) $(am__append_17) $(am__append_18)
driverlessmanpages = \
utils/driverless.1
@@ -2052,10 +1942,7 @@ genppdfiles = \
ppd/HP-Color_LaserJet_CM3530_MFP-PDF.ppd \
ppd/Ricoh-PDF_Printer-PDF.ppd
-ppd_DATA = $(genppdfiles) $(am__append_21) $(am__append_22)
-ijsppdfiles = \
- ppd/HP-PhotoSmart_Pro_B8300-hpijs-pdftoijs.ppd
-
+ppd_DATA = $(genppdfiles) $(am__append_19)
gsppdfiles = \
ppd/pxlcolor.ppd \
ppd/pxlmono.ppd
@@ -2558,14 +2445,6 @@ parallel$(EXEEXT): $(parallel_OBJECTS) $(parallel_DEPENDENCIES) $(EXTRA_parallel
@rm -f parallel$(EXEEXT)
$(AM_V_CCLD)$(parallel_LINK) $(parallel_OBJECTS) $(parallel_LDADD) $(LIBS)
-pdftoijs$(EXEEXT): $(pdftoijs_OBJECTS) $(pdftoijs_DEPENDENCIES) $(EXTRA_pdftoijs_DEPENDENCIES)
- @rm -f pdftoijs$(EXEEXT)
- $(AM_V_CXXLD)$(pdftoijs_LINK) $(pdftoijs_OBJECTS) $(pdftoijs_LDADD) $(LIBS)
-
-pdftoopvp$(EXEEXT): $(pdftoopvp_OBJECTS) $(pdftoopvp_DEPENDENCIES) $(EXTRA_pdftoopvp_DEPENDENCIES)
- @rm -f pdftoopvp$(EXEEXT)
- $(AM_V_CXXLD)$(pdftoopvp_LINK) $(pdftoopvp_OBJECTS) $(pdftoopvp_LDADD) $(LIBS)
-
pdftopdf$(EXEEXT): $(pdftopdf_OBJECTS) $(pdftopdf_DEPENDENCIES) $(EXTRA_pdftopdf_DEPENDENCIES)
@rm -f pdftopdf$(EXEEXT)
$(AM_V_CXXLD)$(pdftopdf_LINK) $(pdftopdf_OBJECTS) $(pdftopdf_LDADD) $(LIBS)
@@ -2858,6 +2737,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcupsfilters_la-image.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcupsfilters_la-lut.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcupsfilters_la-pack.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcupsfilters_la-pdftoippprinter.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcupsfilters_la-ppdgenerator.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcupsfilters_la-raster.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcupsfilters_la-rgb.Plo@am__quote@ # am--include-marker
@@ -2867,17 +2747,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mupdftoraster-mupdftoraster.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parallel-ieee1284.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parallel-parallel.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoijs-pdftoijs.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoopvp-OPRS.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoopvp-OPVPOutputDev.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoopvp-OPVPSplash.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoopvp-OPVPSplashClip.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoopvp-OPVPSplashPath.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoopvp-OPVPSplashState.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoopvp-OPVPSplashXPath.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoopvp-OPVPWrapper.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoopvp-OPVPWrapper_0_2.Po@am__quote@ # am--include-marker
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftoopvp-pdftoopvp.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftopdf-intervalset.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftopdf-nup.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdftopdf-pdftopdf.Po@am__quote@ # am--include-marker
@@ -3001,6 +2870,13 @@ libcupsfilters_la-image.lo: cupsfilters/image.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcupsfilters_la_CFLAGS) $(CFLAGS) -c -o libcupsfilters_la-image.lo `test -f 'cupsfilters/image.c' || echo '$(srcdir)/'`cupsfilters/image.c
+libcupsfilters_la-pdftoippprinter.lo: cupsfilters/pdftoippprinter.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcupsfilters_la_CFLAGS) $(CFLAGS) -MT libcupsfilters_la-pdftoippprinter.lo -MD -MP -MF $(DEPDIR)/libcupsfilters_la-pdftoippprinter.Tpo -c -o libcupsfilters_la-pdftoippprinter.lo `test -f 'cupsfilters/pdftoippprinter.c' || echo '$(srcdir)/'`cupsfilters/pdftoippprinter.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcupsfilters_la-pdftoippprinter.Tpo $(DEPDIR)/libcupsfilters_la-pdftoippprinter.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='cupsfilters/pdftoippprinter.c' object='libcupsfilters_la-pdftoippprinter.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcupsfilters_la_CFLAGS) $(CFLAGS) -c -o libcupsfilters_la-pdftoippprinter.lo `test -f 'cupsfilters/pdftoippprinter.c' || echo '$(srcdir)/'`cupsfilters/pdftoippprinter.c
+
libcupsfilters_la-image-bmp.lo: cupsfilters/image-bmp.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcupsfilters_la_CFLAGS) $(CFLAGS) -MT libcupsfilters_la-image-bmp.lo -MD -MP -MF $(DEPDIR)/libcupsfilters_la-image-bmp.Tpo -c -o libcupsfilters_la-image-bmp.lo `test -f 'cupsfilters/image-bmp.c' || echo '$(srcdir)/'`cupsfilters/image-bmp.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcupsfilters_la-image-bmp.Tpo $(DEPDIR)/libcupsfilters_la-image-bmp.Plo
@@ -4051,160 +3927,6 @@ bannertopdf-pdf.obj: filter/pdf.cxx
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(bannertopdf_CXXFLAGS) $(CXXFLAGS) -c -o bannertopdf-pdf.obj `if test -f 'filter/pdf.cxx'; then $(CYGPATH_W) 'filter/pdf.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdf.cxx'; fi`
-pdftoijs-pdftoijs.o: filter/pdftoijs.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoijs_CXXFLAGS) $(CXXFLAGS) -MT pdftoijs-pdftoijs.o -MD -MP -MF $(DEPDIR)/pdftoijs-pdftoijs.Tpo -c -o pdftoijs-pdftoijs.o `test -f 'filter/pdftoijs.cxx' || echo '$(srcdir)/'`filter/pdftoijs.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoijs-pdftoijs.Tpo $(DEPDIR)/pdftoijs-pdftoijs.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoijs.cxx' object='pdftoijs-pdftoijs.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoijs_CXXFLAGS) $(CXXFLAGS) -c -o pdftoijs-pdftoijs.o `test -f 'filter/pdftoijs.cxx' || echo '$(srcdir)/'`filter/pdftoijs.cxx
-
-pdftoijs-pdftoijs.obj: filter/pdftoijs.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoijs_CXXFLAGS) $(CXXFLAGS) -MT pdftoijs-pdftoijs.obj -MD -MP -MF $(DEPDIR)/pdftoijs-pdftoijs.Tpo -c -o pdftoijs-pdftoijs.obj `if test -f 'filter/pdftoijs.cxx'; then $(CYGPATH_W) 'filter/pdftoijs.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoijs.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoijs-pdftoijs.Tpo $(DEPDIR)/pdftoijs-pdftoijs.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoijs.cxx' object='pdftoijs-pdftoijs.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoijs_CXXFLAGS) $(CXXFLAGS) -c -o pdftoijs-pdftoijs.obj `if test -f 'filter/pdftoijs.cxx'; then $(CYGPATH_W) 'filter/pdftoijs.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoijs.cxx'; fi`
-
-pdftoopvp-OPRS.o: filter/pdftoopvp/oprs/OPRS.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPRS.o -MD -MP -MF $(DEPDIR)/pdftoopvp-OPRS.Tpo -c -o pdftoopvp-OPRS.o `test -f 'filter/pdftoopvp/oprs/OPRS.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPRS.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPRS.Tpo $(DEPDIR)/pdftoopvp-OPRS.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPRS.cxx' object='pdftoopvp-OPRS.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPRS.o `test -f 'filter/pdftoopvp/oprs/OPRS.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPRS.cxx
-
-pdftoopvp-OPRS.obj: filter/pdftoopvp/oprs/OPRS.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPRS.obj -MD -MP -MF $(DEPDIR)/pdftoopvp-OPRS.Tpo -c -o pdftoopvp-OPRS.obj `if test -f 'filter/pdftoopvp/oprs/OPRS.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPRS.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPRS.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPRS.Tpo $(DEPDIR)/pdftoopvp-OPRS.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPRS.cxx' object='pdftoopvp-OPRS.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPRS.obj `if test -f 'filter/pdftoopvp/oprs/OPRS.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPRS.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPRS.cxx'; fi`
-
-pdftoopvp-OPVPSplashClip.o: filter/pdftoopvp/oprs/OPVPSplashClip.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPSplashClip.o -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPSplashClip.Tpo -c -o pdftoopvp-OPVPSplashClip.o `test -f 'filter/pdftoopvp/oprs/OPVPSplashClip.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPSplashClip.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPSplashClip.Tpo $(DEPDIR)/pdftoopvp-OPVPSplashClip.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPSplashClip.cxx' object='pdftoopvp-OPVPSplashClip.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPSplashClip.o `test -f 'filter/pdftoopvp/oprs/OPVPSplashClip.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPSplashClip.cxx
-
-pdftoopvp-OPVPSplashClip.obj: filter/pdftoopvp/oprs/OPVPSplashClip.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPSplashClip.obj -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPSplashClip.Tpo -c -o pdftoopvp-OPVPSplashClip.obj `if test -f 'filter/pdftoopvp/oprs/OPVPSplashClip.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPSplashClip.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPSplashClip.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPSplashClip.Tpo $(DEPDIR)/pdftoopvp-OPVPSplashClip.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPSplashClip.cxx' object='pdftoopvp-OPVPSplashClip.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPSplashClip.obj `if test -f 'filter/pdftoopvp/oprs/OPVPSplashClip.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPSplashClip.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPSplashClip.cxx'; fi`
-
-pdftoopvp-OPVPSplash.o: filter/pdftoopvp/oprs/OPVPSplash.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPSplash.o -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPSplash.Tpo -c -o pdftoopvp-OPVPSplash.o `test -f 'filter/pdftoopvp/oprs/OPVPSplash.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPSplash.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPSplash.Tpo $(DEPDIR)/pdftoopvp-OPVPSplash.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPSplash.cxx' object='pdftoopvp-OPVPSplash.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPSplash.o `test -f 'filter/pdftoopvp/oprs/OPVPSplash.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPSplash.cxx
-
-pdftoopvp-OPVPSplash.obj: filter/pdftoopvp/oprs/OPVPSplash.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPSplash.obj -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPSplash.Tpo -c -o pdftoopvp-OPVPSplash.obj `if test -f 'filter/pdftoopvp/oprs/OPVPSplash.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPSplash.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPSplash.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPSplash.Tpo $(DEPDIR)/pdftoopvp-OPVPSplash.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPSplash.cxx' object='pdftoopvp-OPVPSplash.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPSplash.obj `if test -f 'filter/pdftoopvp/oprs/OPVPSplash.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPSplash.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPSplash.cxx'; fi`
-
-pdftoopvp-OPVPSplashPath.o: filter/pdftoopvp/oprs/OPVPSplashPath.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPSplashPath.o -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPSplashPath.Tpo -c -o pdftoopvp-OPVPSplashPath.o `test -f 'filter/pdftoopvp/oprs/OPVPSplashPath.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPSplashPath.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPSplashPath.Tpo $(DEPDIR)/pdftoopvp-OPVPSplashPath.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPSplashPath.cxx' object='pdftoopvp-OPVPSplashPath.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPSplashPath.o `test -f 'filter/pdftoopvp/oprs/OPVPSplashPath.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPSplashPath.cxx
-
-pdftoopvp-OPVPSplashPath.obj: filter/pdftoopvp/oprs/OPVPSplashPath.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPSplashPath.obj -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPSplashPath.Tpo -c -o pdftoopvp-OPVPSplashPath.obj `if test -f 'filter/pdftoopvp/oprs/OPVPSplashPath.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPSplashPath.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPSplashPath.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPSplashPath.Tpo $(DEPDIR)/pdftoopvp-OPVPSplashPath.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPSplashPath.cxx' object='pdftoopvp-OPVPSplashPath.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPSplashPath.obj `if test -f 'filter/pdftoopvp/oprs/OPVPSplashPath.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPSplashPath.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPSplashPath.cxx'; fi`
-
-pdftoopvp-OPVPSplashState.o: filter/pdftoopvp/oprs/OPVPSplashState.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPSplashState.o -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPSplashState.Tpo -c -o pdftoopvp-OPVPSplashState.o `test -f 'filter/pdftoopvp/oprs/OPVPSplashState.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPSplashState.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPSplashState.Tpo $(DEPDIR)/pdftoopvp-OPVPSplashState.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPSplashState.cxx' object='pdftoopvp-OPVPSplashState.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPSplashState.o `test -f 'filter/pdftoopvp/oprs/OPVPSplashState.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPSplashState.cxx
-
-pdftoopvp-OPVPSplashState.obj: filter/pdftoopvp/oprs/OPVPSplashState.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPSplashState.obj -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPSplashState.Tpo -c -o pdftoopvp-OPVPSplashState.obj `if test -f 'filter/pdftoopvp/oprs/OPVPSplashState.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPSplashState.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPSplashState.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPSplashState.Tpo $(DEPDIR)/pdftoopvp-OPVPSplashState.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPSplashState.cxx' object='pdftoopvp-OPVPSplashState.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPSplashState.obj `if test -f 'filter/pdftoopvp/oprs/OPVPSplashState.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPSplashState.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPSplashState.cxx'; fi`
-
-pdftoopvp-OPVPSplashXPath.o: filter/pdftoopvp/oprs/OPVPSplashXPath.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPSplashXPath.o -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPSplashXPath.Tpo -c -o pdftoopvp-OPVPSplashXPath.o `test -f 'filter/pdftoopvp/oprs/OPVPSplashXPath.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPSplashXPath.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPSplashXPath.Tpo $(DEPDIR)/pdftoopvp-OPVPSplashXPath.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPSplashXPath.cxx' object='pdftoopvp-OPVPSplashXPath.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPSplashXPath.o `test -f 'filter/pdftoopvp/oprs/OPVPSplashXPath.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPSplashXPath.cxx
-
-pdftoopvp-OPVPSplashXPath.obj: filter/pdftoopvp/oprs/OPVPSplashXPath.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPSplashXPath.obj -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPSplashXPath.Tpo -c -o pdftoopvp-OPVPSplashXPath.obj `if test -f 'filter/pdftoopvp/oprs/OPVPSplashXPath.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPSplashXPath.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPSplashXPath.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPSplashXPath.Tpo $(DEPDIR)/pdftoopvp-OPVPSplashXPath.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPSplashXPath.cxx' object='pdftoopvp-OPVPSplashXPath.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPSplashXPath.obj `if test -f 'filter/pdftoopvp/oprs/OPVPSplashXPath.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPSplashXPath.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPSplashXPath.cxx'; fi`
-
-pdftoopvp-OPVPWrapper.o: filter/pdftoopvp/oprs/OPVPWrapper.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPWrapper.o -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPWrapper.Tpo -c -o pdftoopvp-OPVPWrapper.o `test -f 'filter/pdftoopvp/oprs/OPVPWrapper.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPWrapper.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPWrapper.Tpo $(DEPDIR)/pdftoopvp-OPVPWrapper.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPWrapper.cxx' object='pdftoopvp-OPVPWrapper.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPWrapper.o `test -f 'filter/pdftoopvp/oprs/OPVPWrapper.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPWrapper.cxx
-
-pdftoopvp-OPVPWrapper.obj: filter/pdftoopvp/oprs/OPVPWrapper.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPWrapper.obj -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPWrapper.Tpo -c -o pdftoopvp-OPVPWrapper.obj `if test -f 'filter/pdftoopvp/oprs/OPVPWrapper.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPWrapper.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPWrapper.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPWrapper.Tpo $(DEPDIR)/pdftoopvp-OPVPWrapper.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPWrapper.cxx' object='pdftoopvp-OPVPWrapper.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPWrapper.obj `if test -f 'filter/pdftoopvp/oprs/OPVPWrapper.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPWrapper.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPWrapper.cxx'; fi`
-
-pdftoopvp-OPVPWrapper_0_2.o: filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPWrapper_0_2.o -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPWrapper_0_2.Tpo -c -o pdftoopvp-OPVPWrapper_0_2.o `test -f 'filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPWrapper_0_2.Tpo $(DEPDIR)/pdftoopvp-OPVPWrapper_0_2.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx' object='pdftoopvp-OPVPWrapper_0_2.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPWrapper_0_2.o `test -f 'filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx
-
-pdftoopvp-OPVPWrapper_0_2.obj: filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPWrapper_0_2.obj -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPWrapper_0_2.Tpo -c -o pdftoopvp-OPVPWrapper_0_2.obj `if test -f 'filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPWrapper_0_2.Tpo $(DEPDIR)/pdftoopvp-OPVPWrapper_0_2.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx' object='pdftoopvp-OPVPWrapper_0_2.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPWrapper_0_2.obj `if test -f 'filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx'; fi`
-
-pdftoopvp-OPVPOutputDev.o: filter/pdftoopvp/OPVPOutputDev.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPOutputDev.o -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPOutputDev.Tpo -c -o pdftoopvp-OPVPOutputDev.o `test -f 'filter/pdftoopvp/OPVPOutputDev.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/OPVPOutputDev.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPOutputDev.Tpo $(DEPDIR)/pdftoopvp-OPVPOutputDev.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/OPVPOutputDev.cxx' object='pdftoopvp-OPVPOutputDev.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPOutputDev.o `test -f 'filter/pdftoopvp/OPVPOutputDev.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/OPVPOutputDev.cxx
-
-pdftoopvp-OPVPOutputDev.obj: filter/pdftoopvp/OPVPOutputDev.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-OPVPOutputDev.obj -MD -MP -MF $(DEPDIR)/pdftoopvp-OPVPOutputDev.Tpo -c -o pdftoopvp-OPVPOutputDev.obj `if test -f 'filter/pdftoopvp/OPVPOutputDev.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/OPVPOutputDev.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/OPVPOutputDev.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-OPVPOutputDev.Tpo $(DEPDIR)/pdftoopvp-OPVPOutputDev.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/OPVPOutputDev.cxx' object='pdftoopvp-OPVPOutputDev.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-OPVPOutputDev.obj `if test -f 'filter/pdftoopvp/OPVPOutputDev.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/OPVPOutputDev.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/OPVPOutputDev.cxx'; fi`
-
-pdftoopvp-pdftoopvp.o: filter/pdftoopvp/pdftoopvp.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-pdftoopvp.o -MD -MP -MF $(DEPDIR)/pdftoopvp-pdftoopvp.Tpo -c -o pdftoopvp-pdftoopvp.o `test -f 'filter/pdftoopvp/pdftoopvp.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/pdftoopvp.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-pdftoopvp.Tpo $(DEPDIR)/pdftoopvp-pdftoopvp.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/pdftoopvp.cxx' object='pdftoopvp-pdftoopvp.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-pdftoopvp.o `test -f 'filter/pdftoopvp/pdftoopvp.cxx' || echo '$(srcdir)/'`filter/pdftoopvp/pdftoopvp.cxx
-
-pdftoopvp-pdftoopvp.obj: filter/pdftoopvp/pdftoopvp.cxx
-@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -MT pdftoopvp-pdftoopvp.obj -MD -MP -MF $(DEPDIR)/pdftoopvp-pdftoopvp.Tpo -c -o pdftoopvp-pdftoopvp.obj `if test -f 'filter/pdftoopvp/pdftoopvp.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/pdftoopvp.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/pdftoopvp.cxx'; fi`
-@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftoopvp-pdftoopvp.Tpo $(DEPDIR)/pdftoopvp-pdftoopvp.Po
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='filter/pdftoopvp/pdftoopvp.cxx' object='pdftoopvp-pdftoopvp.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftoopvp_CXXFLAGS) $(CXXFLAGS) -c -o pdftoopvp-pdftoopvp.obj `if test -f 'filter/pdftoopvp/pdftoopvp.cxx'; then $(CYGPATH_W) 'filter/pdftoopvp/pdftoopvp.cxx'; else $(CYGPATH_W) '$(srcdir)/filter/pdftoopvp/pdftoopvp.cxx'; fi`
-
pdftopdf-pdftopdf.o: filter/pdftopdf/pdftopdf.cc
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pdftopdf_CXXFLAGS) $(CXXFLAGS) -MT pdftopdf-pdftopdf.o -MD -MP -MF $(DEPDIR)/pdftopdf-pdftopdf.Tpo -c -o pdftopdf-pdftopdf.o `test -f 'filter/pdftopdf/pdftopdf.cc' || echo '$(srcdir)/'`filter/pdftopdf/pdftopdf.cc
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pdftopdf-pdftopdf.Tpo $(DEPDIR)/pdftopdf-pdftopdf.Po
@@ -4769,27 +4491,6 @@ uninstall-pkgfiltersincludeDATA:
@list='$(pkgfiltersinclude_DATA)'; test -n "$(pkgfiltersincludedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(pkgfiltersincludedir)'; $(am__uninstall_files_from_dir)
-install-pkgfontconfigDATA: $(pkgfontconfig_DATA)
- @$(NORMAL_INSTALL)
- @list='$(pkgfontconfig_DATA)'; test -n "$(pkgfontconfigdir)" || list=; \
- if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(pkgfontconfigdir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(pkgfontconfigdir)" || exit 1; \
- fi; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgfontconfigdir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgfontconfigdir)" || exit $$?; \
- done
-
-uninstall-pkgfontconfigDATA:
- @$(NORMAL_UNINSTALL)
- @list='$(pkgfontconfig_DATA)'; test -n "$(pkgfontconfigdir)" || list=; \
- files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- dir='$(DESTDIR)$(pkgfontconfigdir)'; $(am__uninstall_files_from_dir)
install-pkgfontembedincludeDATA: $(pkgfontembedinclude_DATA)
@$(NORMAL_INSTALL)
@list='$(pkgfontembedinclude_DATA)'; test -n "$(pkgfontembedincludedir)" || list=; \
@@ -5306,7 +5007,7 @@ all-am: Makefile $(PROGRAMS) $(LTLIBRARIES) $(SCRIPTS) $(MANS) $(DATA) \
install-binPROGRAMS: install-libLTLIBRARIES
installdirs:
- for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgbackenddir)" "$(DESTDIR)$(pkgfilterdir)" "$(DESTDIR)$(pkgppdgendir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(phpextensiondir)" "$(DESTDIR)$(initrcdir)" "$(DESTDIR)$(pkgbrailledir)" "$(DESTDIR)$(pkgfilterdir)" "$(DESTDIR)$(pkgfilterdir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgppdcdir)" "$(DESTDIR)$(pkgbannerdir)" "$(DESTDIR)$(pkgcharsetdir)" "$(DESTDIR)$(pkgconfdir)" "$(DESTDIR)$(pkgcupsdatadir)" "$(DESTDIR)$(pkgcupsserverrootdir)" "$(DESTDIR)$(pkgdriverdir)" "$(DESTDIR)$(pkgfiltersincludedir)" "$(DESTDIR)$(pkgfontconfigdir)" "$(DESTDIR)$(pkgfontembedincludedir)" "$(DESTDIR)$(pkgmimedir)" "$(DESTDIR)$(pkgppdcdir)" "$(DESTDIR)$(ppddir)"; do \
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgbackenddir)" "$(DESTDIR)$(pkgfilterdir)" "$(DESTDIR)$(pkgppdgendir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(libdir)" "$(DESTDIR)$(phpextensiondir)" "$(DESTDIR)$(initrcdir)" "$(DESTDIR)$(pkgbrailledir)" "$(DESTDIR)$(pkgfilterdir)" "$(DESTDIR)$(pkgfilterdir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man5dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgppdcdir)" "$(DESTDIR)$(pkgbannerdir)" "$(DESTDIR)$(pkgcharsetdir)" "$(DESTDIR)$(pkgconfdir)" "$(DESTDIR)$(pkgcupsdatadir)" "$(DESTDIR)$(pkgcupsserverrootdir)" "$(DESTDIR)$(pkgdriverdir)" "$(DESTDIR)$(pkgfiltersincludedir)" "$(DESTDIR)$(pkgfontembedincludedir)" "$(DESTDIR)$(pkgmimedir)" "$(DESTDIR)$(pkgppdcdir)" "$(DESTDIR)$(ppddir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: $(BUILT_SOURCES)
@@ -5409,6 +5110,7 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/libcupsfilters_la-image.Plo
-rm -f ./$(DEPDIR)/libcupsfilters_la-lut.Plo
-rm -f ./$(DEPDIR)/libcupsfilters_la-pack.Plo
+ -rm -f ./$(DEPDIR)/libcupsfilters_la-pdftoippprinter.Plo
-rm -f ./$(DEPDIR)/libcupsfilters_la-ppdgenerator.Plo
-rm -f ./$(DEPDIR)/libcupsfilters_la-raster.Plo
-rm -f ./$(DEPDIR)/libcupsfilters_la-rgb.Plo
@@ -5418,17 +5120,6 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/mupdftoraster-mupdftoraster.Po
-rm -f ./$(DEPDIR)/parallel-ieee1284.Po
-rm -f ./$(DEPDIR)/parallel-parallel.Po
- -rm -f ./$(DEPDIR)/pdftoijs-pdftoijs.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPRS.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPOutputDev.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPSplash.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPSplashClip.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPSplashPath.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPSplashState.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPSplashXPath.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPWrapper.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPWrapper_0_2.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-pdftoopvp.Po
-rm -f ./$(DEPDIR)/pdftopdf-intervalset.Po
-rm -f ./$(DEPDIR)/pdftopdf-nup.Po
-rm -f ./$(DEPDIR)/pdftopdf-pdftopdf.Po
@@ -5499,9 +5190,9 @@ install-data-am: install-docDATA install-initrcSCRIPTS install-man \
install-pkgconfDATA install-pkgcupsdataDATA \
install-pkgcupsserverrootDATA install-pkgdriverDATA \
install-pkgfilterPROGRAMS install-pkgfilterSCRIPTS \
- install-pkgfiltersincludeDATA install-pkgfontconfigDATA \
- install-pkgfontembedincludeDATA install-pkgmimeDATA \
- install-pkgppdcDATA install-pkgppdgenPROGRAMS install-ppdDATA
+ install-pkgfiltersincludeDATA install-pkgfontembedincludeDATA \
+ install-pkgmimeDATA install-pkgppdcDATA \
+ install-pkgppdgenPROGRAMS install-ppdDATA
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-data-hook
install-dvi: install-dvi-am
@@ -5589,6 +5280,7 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/libcupsfilters_la-image.Plo
-rm -f ./$(DEPDIR)/libcupsfilters_la-lut.Plo
-rm -f ./$(DEPDIR)/libcupsfilters_la-pack.Plo
+ -rm -f ./$(DEPDIR)/libcupsfilters_la-pdftoippprinter.Plo
-rm -f ./$(DEPDIR)/libcupsfilters_la-ppdgenerator.Plo
-rm -f ./$(DEPDIR)/libcupsfilters_la-raster.Plo
-rm -f ./$(DEPDIR)/libcupsfilters_la-rgb.Plo
@@ -5598,17 +5290,6 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/mupdftoraster-mupdftoraster.Po
-rm -f ./$(DEPDIR)/parallel-ieee1284.Po
-rm -f ./$(DEPDIR)/parallel-parallel.Po
- -rm -f ./$(DEPDIR)/pdftoijs-pdftoijs.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPRS.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPOutputDev.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPSplash.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPSplashClip.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPSplashPath.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPSplashState.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPSplashXPath.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPWrapper.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-OPVPWrapper_0_2.Po
- -rm -f ./$(DEPDIR)/pdftoopvp-pdftoopvp.Po
-rm -f ./$(DEPDIR)/pdftopdf-intervalset.Po
-rm -f ./$(DEPDIR)/pdftopdf-nup.Po
-rm -f ./$(DEPDIR)/pdftopdf-pdftopdf.Po
@@ -5680,7 +5361,7 @@ uninstall-am: uninstall-binPROGRAMS uninstall-docDATA \
uninstall-pkgconfDATA uninstall-pkgcupsdataDATA \
uninstall-pkgcupsserverrootDATA uninstall-pkgdriverDATA \
uninstall-pkgfilterPROGRAMS uninstall-pkgfilterSCRIPTS \
- uninstall-pkgfiltersincludeDATA uninstall-pkgfontconfigDATA \
+ uninstall-pkgfiltersincludeDATA \
uninstall-pkgfontembedincludeDATA uninstall-pkgmimeDATA \
uninstall-pkgppdcDATA uninstall-pkgppdgenPROGRAMS \
uninstall-ppdDATA uninstall-sbinPROGRAMS
@@ -5717,11 +5398,10 @@ uninstall-man: uninstall-man1 uninstall-man5 uninstall-man8
install-pkgcupsdataDATA install-pkgcupsserverrootDATA \
install-pkgdriverDATA install-pkgfilterPROGRAMS \
install-pkgfilterSCRIPTS install-pkgfiltersincludeDATA \
- install-pkgfontconfigDATA install-pkgfontembedincludeDATA \
- install-pkgmimeDATA install-pkgppdcDATA \
- install-pkgppdgenPROGRAMS install-ppdDATA install-ps \
- install-ps-am install-sbinPROGRAMS install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
+ install-pkgfontembedincludeDATA install-pkgmimeDATA \
+ install-pkgppdcDATA install-pkgppdgenPROGRAMS install-ppdDATA \
+ install-ps install-ps-am install-sbinPROGRAMS install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
recheck tags tags-am uninstall uninstall-am \
@@ -5735,7 +5415,7 @@ uninstall-man: uninstall-man1 uninstall-man5 uninstall-man8
uninstall-pkgconfDATA uninstall-pkgcupsdataDATA \
uninstall-pkgcupsserverrootDATA uninstall-pkgdriverDATA \
uninstall-pkgfilterPROGRAMS uninstall-pkgfilterSCRIPTS \
- uninstall-pkgfiltersincludeDATA uninstall-pkgfontconfigDATA \
+ uninstall-pkgfiltersincludeDATA \
uninstall-pkgfontembedincludeDATA uninstall-pkgmimeDATA \
uninstall-pkgppdcDATA uninstall-pkgppdgenPROGRAMS \
uninstall-ppdDATA uninstall-sbinPROGRAMS
diff --git a/NEWS b/NEWS
index 9c671bdcf..f83dc910c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,186 @@
-NEWS - OpenPrinting CUPS Filters v1.21.6 - 2018-12-17
+NEWS - OpenPrinting CUPS Filters v1.25.0 - 2019-06-06
-----------------------------------------------------
+CHANGES IN V1.25.0
+
+ - pdftoijs, pdftoopvp: Removed these deprecated filters
+ completely as there is no demand for them any more. They
+ also used unstable, undocumented APIs of Poppler.
+ - pdftoraster: Changed from using unstable, undocumented APIs
+ of Poppler to stable, documented ones, to improve
+ maintainability of this filter, and with it of the
+ cups-filters package. Thanks to Tanmay Anand for
+ contributing this as his Google Summer of Code 2019 project.
+ - libcupsfilters: Added support for color spaces CMY and RGBW
+ when using filters without PPD file (mainly for development
+ and debugging, option "print-color-mode" with values
+ "cmy-XX" and "rgbw-XX" with XX being the number of bits per
+ color).
+
+CHANGES IN V1.24.0
+
+ - cups-browsed: Integration of Deepak Patankar's Google Summer
+ of Code 2018 project with the main goal of clustering
+ different printers and automatically selecting the
+ destination printers by job content and option/attribute
+ settings. All changes of this release are done by Deepak as
+ parts of his project.
+ - cups-browsed, implicitclass: Support for mixed clusters of
+ remote CUPS queues and IPP network printers. For this PPD
+ files of remote CUPS queues are generated by cups-browsed
+ based on IPP queries, as for native IPP printers, the number
+ of jobs for load balancing is polled in a way that it works
+ also with native IPP printers, the implicitclass backend
+ sends jobs directky to the printer instead of re-queueing
+ them via CUPS.
+ - cups-browsed: Merge IPP attributes of several printers to
+ combined attributes for the cluster to generate the
+ cluster's PPD file, including PPD constraints for option
+ combinations not fulfillable by any of the member printers,
+ and finding reasonable, non-conflicting default settings,
+ - cups-browsed: Selection algorithm for the destination
+ printer for a job sent to the cluster. Based on the job
+ settings requested such as page size, media type, print
+ quality, ... the best most suitable printer in the cluster
+ for the job will be selected.
+ - cups-browsed, implicitclass: Filter jobs to clusters already
+ locally. Due to the fact that a cluster's member printers
+ are not exclusively non-raw CUPS queues with the complete
+ filtering framework on the remote server, but also native
+ IPP printers, we need to support generic driverless printers
+ as destination. So we cannot pass on the input data
+ unfiltered but need to filter locally. We let the cluster's
+ PPD file emulate a PDF printer, letting the local CUPS queue
+ of the cluster run pdftopdf and any pre-filters to turn the
+ input into PDF and we let the implicitclass backend turn PDF
+ into a format understood by the destination printer,
+ supporting the 4 formats of driverless IPP printing: PDF,
+ PWG Raster, Apple Raster, PCLm.
+
+CHANGES IN V1.23.0
+
+ - pdftops, mupdftoraster: Let pdftops call mutool directly and
+ so that it directly outputs PostScript, eliminating the need
+ to call the mupdftoraster and rastertops filters.
+ - mupdftoraster: Reduced the use of temporary files from 3 to
+ just one.
+ - imagetopdf, imagetoraster, pdftopdf: Add support for
+ print-scaling option (Issue #108, Pull request #118).
+
+CHANGES IN V1.22.6
+
+ - rastertops: Fixed PageSize settings in the PostScript output
+ (Must be in points not in pixels).
+ - pdftops, mupdftoraster: Produce actual grayscale/monochrome
+ PostScript (and not only instructions to print grayscale/
+ monochrome) for jobs to be printed in grayscale/monochrome
+ (Issue #96, Pull request #115).
+ - mupdftoraster: Fixed filter not producing output at all.
+ - Build system: ENABLE_DRIVERLESS got only defined with CUPS
+ 1.6 and newer, not with older CUPS versions (Issue #111).
+ - pdftopdf, imagetopdf, imagetoraster: Silenced compiler
+ warnings.
+ - cups-browsed, driverless: Replaced httpConnect() calls by
+ httpConnect2() calls as the former CUPS library function is
+ deprecated.
+ - Build system: Compile everything using the CUPS libraries
+ with '-D_PPD_DEPRECATED=""' for the time being until the
+ deprecated PPD API calls get replaced, to stop the flooding
+ with PPD API deprecation warnings making more important
+ warnings being overlooked.
+ - cups-browsed: When removing a local queue on shutdown or
+ when DNS-SD reports the printer as disappeared check whether
+ the local queue got overwritten by an external process as
+ sometimes the shutdown or disappearing event comes too close
+ for cups-browsed receiving a printer-modified notification
+ from CUPS before (Ubuntu bug #1731417).
+
+CHANGES IN V1.22.5
+
+ - foomatic-rip: Changed Ghostscript call to count pages in a
+ PDF file to use "runpdfbegin" and not the undocumented
+ Ghostscript internal "pdfdict", so that it works with
+ Ghostscript 9.27 and later (Debian bug #926576, Arch Linux
+ bug #62251).
+
+CHANGES IN V1.22.4
+
+ - cups-browsed: Fix broken trailing space removal on
+ "NickName" (Pull request #103).
+ - pdftops: Emit PostScript Level 2 instead of Level 3 for
+ Brother PostScript printers as at least some of them
+ report to support level 3 but ontly work with Level 2
+ (Ubuntu bug #1306849, comment #42).
+ - bannertopdf: When multiplying the page for N-up or Duplex
+ printing one page too much was generated (Issue #102).
+
+CHANGES IN V1.22.3
+
+ - libcupsfilters: Added error checks for processing GIF, to
+ avoid crashes or hangs on broken GIF files (Issues #81, #82,
+ Pull request #100).
+ - cups-browsed: Added hint to the man page and configuration
+ file that with "DebugLogging stderr" the logging output goes
+ to journal or syslog if cups-browsed is running as system
+ service (Issue #28).
+
+CHANGES IN V1.22.2
+
+ - cups-browsed: Let distribution of jobs sent to queues with
+ "implicitclass" backend (usually clusters) be done by a
+ "job-state" CUPS notification and not by
+ "printer-state-changed" any more. The "job-state"
+ notification already contains the job ID. Before we had to
+ poll the job ID from CUPS via IPP which was sometimes
+ unreliable (Issue #97).
+ - imagetopdf, imagetoraster, pdftopdf, libcupsfilters: Added
+ new page scaling options: "fill" scales the input page
+ (typically a photo) so that the output page (typically with
+ different aspect ratio) gets completely filled, aloowing for
+ some content of the input page getting lost. "crop-to-fit"
+ allows for easy printing of documents on slightly different
+ output page sizes (A4 <-> Letter) maintaining the size and
+ centering and cropping into the destination page. Thanks to
+ Dheeraj Yadav (dhirajyadav135 at gmail dot com) for the
+ patch (Pull request #92).
+ - cups-browsed: Do not do IPP request for printer-is-shared
+ option for remote cups queues with CUPS 2.2.x and newer
+ (Pull request #91).
+ - cups-browsed: Fix crash bug when reading "Cluster"
+ directive from configuration file (Issue #94).
+ - driverless: Updated man page as now also Mopria and
+ Wi-Fi Direct printers are supported. Mentioned also
+ ippusbxd.
+
+CHANGES IN V1.22.1
+
+ - braille: Use sort command with LC_ALL=C for reproducibility
+ of the genrated files, needed for distribution packaging.
+ - cups-browsed, driverless: When polling the printer's
+ capabilities via get-printer-attributes IPP request for
+ driverless printing, use the attributes "all" and
+ "media-col-database". Without "all" some printers do not
+ report "urf-supported" and without "media-col-database" not
+ all paper size and marging info gets reported (Issue #22,
+ Pull request #86, CUPS issue #5484).
+ - braille: Document how to rework output before
+ embossing. Thanks to Samuel Thibault for this patch (Pull
+ request #90).
+
+CHANGES IN V1.22.0
+
+ - pdftopdf: Use QPDF for flattening interactive PDF forms
+ (Issues #2, #23, #36, Pull request #88).
+ - pdftopdf: Fixed bug of closing temporary file prematurely
+ when external PDF form flattening utilities fail (Thanks to
+ Tobias Hoffmann for finding this, see pull request #88).
+ - pdftoopvp: More fixes for building with Poppler 0.72
+ (Pull request #83, Issue #75).
+ - pdftoraster, pdftoijs, pdftoopvp: Removed support for
+ Poppler 0.18 (Pull request #83).
+ - cups-browsed: Fixed crash in applying the BrowseFilter
+ cups-browsed.conf directives (Debian bug #916765).
+
CHANGES IN V1.21.6
- cups-browsed: To find out whether a DNS-SD-discovered
@@ -2618,8 +2798,8 @@ CHANGES IN V1.0b1
- Named the package "OpenPrinting CUPS Filters"
- Renamed libcupslegacy to libcupsfilters
- Joined pdftops and cpdftocps filters into one C program
- - Added new bannertopdf filter from Lars Uebernickel:
- https://launchpad.net/bannertopdf
+ - Added new bannertopdf filter from Lars Karlitski (formerly
+ Uebernickel): https://launchpad.net/bannertopdf
- Added the filters for the PDF-based printing workflow, from
OpenPrinting: http://sourceforge.jp/projects/opfc/ and
http://www.openprinting.org/download/printing/pdf-printing/
diff --git a/README b/README
index ecfc48336..ab1d75ac9 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README - OpenPrinting CUPS Filters v1.21.6 - 2018-12-17
+README - OpenPrinting CUPS Filters v1.25.0 - 2019-06-06
-------------------------------------------------------
Looking for compile instructions? Read the file "INSTALL.txt"
@@ -28,18 +28,22 @@ INTRODUCTION
by both CUPS and this package. Then the filters of this package
should be used.
- For compiling and using this package CUPS, libqpdf (8.1.0 or
+ For compiling and using this package CUPS, libqpdf (8.3.0 or
newer), libjpeg, libpng, libtiff, freetype, fontconfig, liblcms
(liblcms2 recommended), libavahi-common, libavahi-client, libdbus,
and glib are needed. It is highly recommended, especially if
non-PDF printers are used, to have at least one of Ghostscript,
Poppler, or MuPDF.
- The Poppler-based filters need a C++ compiler which supports C++11
- and Poppler being built with the "./configure" options
- "--enable-splash --disable-fixedpoint --disable-single-precision"
- (if in the actually used Poppler version such options are
- available). This is the case for most modern Linux distributions.
+ The Poppler-based pdftoraster filter needs a C++ compiler which
+ supports C++11 and Poppler being built with the "./configure"
+ option "-DENABLE_CPP=ON" for building the C++ support library
+ libpoppler-cpp. This is the case for most modern Linux
+ distributions.
+
+ If you use MuPDF as PDF renderer make sure to use at least version
+ 1.15, as the older versions have bugs and so some files get not
+ printed correctly.
For Apple Raster output (used by AirPrint printers) at least CUPS
2.2.2 is required.
@@ -455,7 +459,7 @@ CUPS FILTERS FOR PDF AS STANDARD PRINT JOB FORMAT
Here is documentation from the former CUPS add-on tarball with the filters
for the PDF-based printing workflow: imagetopdf, texttopdf,
- pdftopdf, pdftoraster, pdftoopvp, and pdftoijs
+ pdftopdf, and pdftoraster
The original filters are from http://sourceforge.jp/projects/opfc/
@@ -718,7 +722,10 @@ output NEWLINE
Thus, if you want to use both PDF filters and GS by single PPD file,
what you should do is to add the following line in the PPD file;
-*pdftopdfJCLBegin: "pdftoopvp jobInfo:"
+*pdftopdfJCLBegin: "pdfto... jobInfo:"
+
+Replace "pdfto..." by the name of the actual filter to be called after
+pdftopdf.
Note:
If you specify JCLBegin, you have to specify JCLToPSInterpreter as well.
@@ -845,9 +852,54 @@ non-landscape pages are rotated instead.
Note: Some pages might end up 180 degree rotated (instead of 0 degree).
Those should probably be rotated manually before binding the pages together.
+3) Method of flattening interactive PDF forms and annotations.
+
+Some PDF files (like application forms) contain interactive forms
+which the user can fill in inside a PDF viewer like evince. The filled
+in data is not integrated in each page of the PDF file but stored in
+an extra layer. Due to this the data gets lost when applying
+manipulations like scaling or N-up to the pages. To prevent the loss
+of the data pdftopdf flattens the form before doing the
+manipulations. This means the PDF will be converted into a static PDF
+file with the data being integral part of the pages.
+
+The same flattening is needed for annotations in PDF files.
+
+By default the actual flattening work is done by QPDF, as QPDF is also
+doing everything else in pdftopdf. This way no external utilities need
+to be called and so extra piping between processes and extra PDF
+interpreter runs are avoided which makes the filtering process faster.
+
+As we did not test the new QPDF-based form-flattening with thousands
+of PDF files yet and it has not been available to actual users yet it
+is possible that there are still some bugs. To give users a
+possibility to work around possible bugs in QPDF's form flattening, we
+have introduced an option to get back to the old flattening by the
+external tools pdftocairo or Ghostscript.
+
+The selection of the method is done by the "pdftopdf-form-flattening"
+option, setting it to "auto", "qpdf", "pdftocairo", "ghostscript",
+"gs", "internal" or "external":
+
+Per-job: lpr -o pdftopdf-form-flattening=pdftocairo ...
+Per-queue default: lpadmin -p printer -o pdftopdf-form-flattening-default=gs
+Remove default: lpadmin -p printer -R pdftopdf-form-flattening-default
+
+By default, pdftopdf uses QPDF if the option is not supplied, also the
+settings "auto" and "internal" make QPDF being used. "external"
+auto-selects from the two external utilities, trying pdftocairo at
+first and on failure Ghostscript. If the selected utility fails, the
+form stays unflattened and so the filled in data will possibly not get
+printed.
+
Native PDF Printer / JCL Support
--------------------------------
+Note that for most modern native PDF printers JCL is not needed any
+more as they are controlled via IPP. For these the PPD files get
+auto-generated by the support of CUPS and cups-filters for driverless
+IPP printing.
+
pdftopdf will emit JCL when provided with a PPD file that includes the
"*JCLToPDFInterpreter:" keyword.
@@ -915,7 +967,7 @@ License
pdftopdf is released under the MIT license.
-The required libqpdf is available under version 2 of the Artistic License,
+The required libqpdf is available under version 2.0 of the Apache License,
e.g. here: https://github.com/qpdf/qpdf
@@ -1055,247 +1107,6 @@ in the location specified by TMPDIR environment variable. Default location
is "/tmp".
-PDFTOIJS
-========
-
-(Optional, only included when building with "./configure ... --enable-ijs ...")
-
-1. INTRODUCTION
-
-"pdftoijs" is a filter for CUPS. It reads PDF files, converts it
-and sends it to an IJS server.
-
-2. LICENSE
-
-Almost source files are under MIT like license. However, "pdftoijs" links
-some "poppler" libraries, and these files are under GNU public license.
-See copyright notice of each file for details.
-
-3. COMMAND LINE
-
-"pdftoijs" is a CUPS filter, and the command line arguments, environment
-variables and configuration files are in accordance with the CUPS filter
-interface.
-
-pdftoijs <job> <user> <title> <num-copies> <options> [<filename>]
-
-"pdftoijs" ignores <job> and <user>.
-<title> is appended into the PDF dictionary as /Title.
-<num-copies> specifies the number of document copies.
-<options> is a CUPS option list.
-<filename> is an input PDF file name.
-
-When omit the <filename>, "pdftoijs" reads a PDF file from the stdin,
-and save it as a temporary file.
-
-4. ENVIRONMENT VARIABLES
-
-This program refers the following environment variable;
- PPD: PPD file name of the printer.
-
-5. NEW PPD KEYWORDS
-
-*ijsServer : the ijsserver executable
-*ijsManufacturer, *ijsModel : as used by the ijs server
-*ijsColorspace : the desired output colorspace, one of
- 'rgb'
- 'cmyk' (availability depending on poppler compile-options)
- 'white1', 'black1': 1-bit normal/inverted
- 'white8', 'black8': 8-bit greyscale normal/inverted
-*ijsResolution [option]=[choice]: the desired output resolution e.g. "600 600"
-*ijsParams [option]=[choice]: custom ijs parameters, separated by ','
- (to escape: use \,)
-
-6. COMMAND OPTIONS
-
-(See CUPS documents for details.)
-
-ijsOutputFile : the destination file, stdout otherwise
-
-7. INFORMATION FOR DEVELOPERS
-
-Following information is for developers, not for driver users.
-
-7.1 Temporally files location
-
-"pdftoijs" creates temporary files if needed. Temporary files are created
-in the location specified by TMPDIR environment variable. Default location
-is "/tmp".
-
-
-PDFTOOPVP
-=========
-
-(Optional, only included when building with "./configure ... --enable-opvp ...")
-
-1. INTRODUCTION
-
-"pdftoopvp" is a CUPS filter which reads PDF file, renders pages and
-outputs PDL to a printer driver which is compliant with the OpenPrinting
-Vector Printer Driver Interface "opvp".
-
-2. CONFIGURATION
-
-"pdftoopvp" refers the poppler configuration file. Be aware that poppler
-uses "fontconfig" for its font configuration.
-
-3. JCL
-
-When "pdftoopvp" reads a PDF file from stdin, "pdftoopvp" handles the data
-prior to PDF header (%PDF ...) as JCL options. JCL options for "pdftoopvp"
-must begin with "pdftoopvp jobInfo:". "pdftoopvp" passes the option string
-just after ":" to the driver as the jobInfo option.
-
-4. COMMAND LINE
-
-"pdftoopvp" is a CUPS filter, and the command line arguments,
-environment variables and configuration files are in accordance with
-the CUPS filter interface.
-
-pdftoopvp <job> <user> <title> <num-copies> <options> [<filename>]
-
-"pdftoopvp" ignores <job>, <user>, <title> and <num-copies>.
-<options> is a CUPS option list.
-
-When omit the <filename>, "pdftoopvp" reads a PDF file from stdin,
-and save it as a temporary file.
-
-CUPS options defined in <options> are delimited by space. Boolean
-type CUPS option is defined only by the option key, and other type
-CUPS option are defined by pairs of key and value, <key>=<value>.
-
-5. COMMAND OPTIONS
-
-"pdftoopvp" accepts the following CUPS standard options;
-
-Resolution=<int>
- Specifies a printer resolution in dpi.
- When this option is omitted, the resolution is treated as 300dpi.
- Horizontal and vertical resolution are treated as the same resolution.
-
-PageSize=<string>
- Specifies a paper size by name defined in the PPD file.
- This option is ignored when no PPD file is assigned for the printer
- queue.
-
-"pdftoopvp" accepts the following original options;
-
-opvpDriver=<string>
- Specifies a driver library name.
-
-opvpModel=<string>
- Specifies a printer model name.
-
-opvpJobInfo=<string>
- Specifies "jobInfo" printing options that are passed to the driver.
- Printing options are overridden by JCL options.
-
-opvpDocInfo=<string>
- Specifies "docInfo" document options that are passed to the driver.
-
-opvpPageInfo=<string>
- Specifies "pageInfo" page options that are passed to the driver.
-
-pdftoopvpClipPathNotSaved (Boolean option)
- Specifies that the driver cannot save clipping path operators in PDF.
-
-nopdftoopvpShearImage (Boolean option)
- Specifies that the driver cannot rotate/shear images by CTM.
-
-nopdftoopvpMiterLimit (Boolean option)
- Specifies that the driver does not support miter limit.
- If the driver does not prepare the opvpSetMiterLimit function entry,
- this option setting is ignored, and also miter limit is ignored.
-
-pdftoopvpIgnoreMiterLimit (Boolean option)
- When nopdftoopvpMiterLimit option is set, pdftoopvp automatically
- replace paths to multiple lines or drawing images. This option
- specifies to avoid the path replacement even when nopdftoopvpMiterLimit
- option is set.
-
-pdftoopvpMaxClipPathLength=<int>
- Specifies the maximum number of clipping path points that the driver
- supports. Default value is 2000 points.
-
-pdftoopvpMaxFillPathLength=<int>
- Specifies the maximum number of fill path points that the driver supports.
- Default value is 4000 points.
-
-nopdftoopvpLineStyle (Boolean option)
- Specifies that the driver ignores the line style settings in PDF.
- If the driver does not prepare the SetLineStyle , SetLineDash or
- SetLineDashOffset function entry, this option setting is ignored, and
- also line style, line dash and line dash offset are ignored.
-
-nopdftoopvpClipPath (Boolean option)
- Specifies that the driver does not support clipping path.
- If the driver does not prepare the opvpSetClipPath function entry, this
- option is ignored, and also clip path setting is ignored.
-
-nopdftoopvpBitmapChar (Boolean option)
- Specifies that the driver does not output characters as images.
- Default setting is that "pdftoopvp" outputs small characters as images.
-
-pdftoopvpBitmapCharThreshold=<int>
- Specifies the threshold value that "pdftoopvp" outputs characters as
- images. Threshold value is defined as W x H where character's width
- is given by W pixels and height is given by H pixels.
- Default threshold value is 2000 points.
-
-nopdftoopvpImageMask (Boolean option)
- Specifies that the driver does not support image mask.
- If this option is set, "pdftoopvp" treats as the nopdftoopvpBitmapChar
- option is given.
-
-6. PPD OPTIONS
-
-Following options can be defined in a PPD.
-
-Resolution=<int>
-PageSize=<string>
-opvpDriver=<string>
-opvpModel=<string>
-opvpJobInfo=<string>
-opvpDocInfo=<string>
-opvpPageInfo=<string>
-pdftoopvpClipPathNotSaved=True
-pdftoopvpShearImage=False
-pdftoopvpMiterLimit=False
-pdftoopvpIgnoreMiterLimit=True
-pdftoopvpMaxClipPathLength=<int>
-pdftoopvpMaxFillPathLength=<int>
-pdftoopvpLineStyle=False
-pdftoopvpClipPath=False
-pdftoopvpBitmapChar=False
-pdftoopvpBitmapCharThreshold=<int>
-pdftoopvpImageMask=False
-
-7. OPTIONS OVERRIDING RULE
-
-"jobInfo" printing options in a PPD is used as a initial "jobInfo" printing
-options. If opvpJobInfo option is given in the command line, precedent
-"jobInfo" printing options are overridden by the opvpJobInfo options.
-
-After the "jobInfo" printing options are overridden by the opvpJobInfo
-options, if JCL options are given, precedent "jobInfo" printing options are
-overridden by the options given by JCL options.
-
-8. INFORMATION FOR CUPS 1.1
-
-To use this program under CUPS 1.1, following lines must be defined
-in the CUPS's "mime.types" file.
-
-application/vnd.cups-pdf
-
-9. KNOWN PROBLEMS
-
-Problem:
- When a page is rotated and a character is small, character might not be
- rotated correctly. This problem is caused by free type library.
-Solution:
- Define the nopdftoopvpBitmapChar to inhibit characters output as images.
-
-
URFTOPDF
========
@@ -1772,6 +1583,29 @@ the default values are shown here.
lp -o "LibLouis=fr-fr-g1 LibLouis2=gr-gr-g1 TextDotDistance=250 LineSpacing=500" file.txt
+---------------------------------
+Reworking output before embossing
+---------------------------------
+
+One may want to check and modify the .brf or .ubrl output before sending it to
+the embosser. This can be achieved by first generating the .brf file:
+
+ /usr/sbin/cupsfilter -m application/vnd.cups-brf -p /etc/cups/ppd/yourprinter.ppd yourdocument.txt > ~/test.brf
+
+One can choose a ppd file and additionally pass -o options to control the
+generated output. One can then modify the .brf file with a text editor. One can
+then emboss it:
+
+ lp -o document-format=application/vnd.cups-brf ~/test.brf
+
+
+The same can be achieved for images:
+
+ /usr/sbin/cupsfilter -m image/vnd.cups-ubrl -p /etc/cups/ppd/yourprinter.ppd yourimage.png > ~/test.ubrl
+
+ lp -o document-format=image/vnd.cups-ubrl ~/test.ubrl
+
+
---------------
BRF file output
---------------
diff --git a/backend/implicitclass.c b/backend/implicitclass.c
index 39aa4c0f5..9ed082929 100644
--- a/backend/implicitclass.c
+++ b/backend/implicitclass.c
@@ -2,7 +2,8 @@
* implicitclass backend for implementing an implicit-class-like behavior
* of redundant print servers managed by cups-browsed.
*
- * Copyright 2015 by Till Kamppeter
+ * Copyright 2015-2019 by Till Kamppeter
+ * Copyright 2018-2019 by Deepak Patankar
*
* This is based on dnssd.c of CUPS
* dnssd.c copyright notice is follows:
@@ -22,6 +23,12 @@
#include "backend-private.h"
#include <cups/array.h>
#include <ctype.h>
+#include <cups/array.h>
+#include <ctype.h>
+#include <cups/cups.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <cupsfilters/pdftoippprinter.h>
/*
* Local globals...
@@ -31,14 +38,81 @@
the current job */
#define CUPS_BROWSED_DEST_PRINTER "cups-browsed-dest-printer"
-static int job_canceled = 0;
- /* Set to 1 on SIGTERM */
+static int job_canceled = 0; /* Set to 1 on SIGTERM */
/*
* Local functions... */
static void sigterm_handler(int sig);
+#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
+#define HAVE_CUPS_1_6 1
+#endif
+
+#ifndef HAVE_CUPS_1_6
+int
+ippGetInteger(ipp_attribute_t *attr,
+ int element)
+{
+ return (attr->values[element].integer);
+}
+#endif
+
+
+int /* O - Next delay value */
+next_delay(int current, /* I - Current delay value or 0 */
+ int *previous) /* IO - Previous delay value */
+{
+ int next; /* Next delay value */
+ if (current > 0) {
+ next = (current + *previous) % 12;
+ *previous = next < current ? 0 : current;
+ } else {
+ next = 1;
+ *previous = 0;
+ }
+ return (next);
+}
+
+/*
+ * Set an option in a string of options
+ */
+
+void /* O - 0 on success, 1 on error */
+set_option_in_str(char *buf, /* I - Buffer with option list string */
+ int buflen, /* I - Length of buffer */
+ const char *option, /* I - Option to change/add */
+ const char *value) /* I - New value for option, NULL
+ removes option */
+{
+ char *p1, *p2;
+
+ if (!buf || buflen == 0 || !option)
+ return;
+ /* Remove any occurrence of option in the string */
+ p1 = buf;
+ while (*p1 != '\0' && (p2 = strcasestr(p1, option)) != NULL) {
+ if (p2 > buf && *(p2 - 1) != ' ' && *(p2 - 1) != '\t') {
+ p1 = p2 + 1;
+ continue;
+ }
+ p1 = p2 + strlen(option);
+ if (*p1 != '=' && *p1 != ' ' && *p1 != '\t' && *p1 != '\0')
+ continue;
+ while (*p1 != ' ' && *p1 != '\t' && *p1 != '\0') p1 ++;
+ while ((*p1 == ' ' || *p1 == '\t') && *p1 != '\0') p1 ++;
+ memmove(p2, p1, strlen(buf) - (buf - p1) + 1);
+ p1 = p2;
+ }
+ /* Add option=value to the end of the string */
+ if (!value)
+ return;
+ p1 = buf + strlen(buf);
+ *p1 = ' ';
+ p1 ++;
+ snprintf(p1, buflen - (buf - p1), "%s=%s", option, value);
+ buf[buflen - 1] = '\0';
+}
/*
* 'main()' - Browse for printers.
@@ -49,16 +123,23 @@ main(int argc, /* I - Number of command-line args */
char *argv[]) /* I - Command-line arguments */
{
const char *device_uri; /* URI with which we were called */
- char scheme[32], username[10], queue_name[1024], resource[10];
+ char scheme[64], username[32], queue_name[1024], resource[32],
+ printer_uri[1024],document_format[256],resolution[16];
int port, status;
const char *ptr1 = NULL;
- char *ptr2;
+ char *ptr2,*ptr3,*ptr4;
const char *job_id;
+ char *filename, /* PDF file to convert */
+ tempfile[1024],
+ tempfile_filter[1024]; /* Temporary file */
int i;
char dest_host[1024]; /* Destination host */
ipp_t *request, *response;
ipp_attribute_t *attr;
+ int bytes; /* Bytes copied */
char uri[HTTP_MAX_URI];
+ char *argv_nt[7];
+ int outbuflen,filefd,exit_status,dup_status;
static const char *pattrs[] =
{
"printer-defaults"
@@ -89,10 +170,8 @@ main(int argc, /* I - Number of command-line args */
* Check command-line...
*/
- if (argc >= 6)
- {
- if ((device_uri = getenv("DEVICE_URI")) == NULL)
- {
+ if (argc >= 6) {
+ if ((device_uri = getenv("DEVICE_URI")) == NULL) {
if (!argv || !argv[0] || !strchr(argv[0], ':'))
return (-1);
@@ -149,7 +228,8 @@ main(int argc, /* I - Number of command-line args */
if (ptr1 != NULL)
break;
}
- fprintf(stderr, "DEBUG: Read " CUPS_BROWSED_DEST_PRINTER " option: %s\n", ptr1);
+ fprintf(stderr, "DEBUG: Read " CUPS_BROWSED_DEST_PRINTER " option: %s\n",
+ ptr1);
if (ptr1 == NULL)
goto failed;
/* Destination host is between double quotes, as double quotes are
@@ -167,15 +247,11 @@ main(int argc, /* I - Number of command-line args */
ptr1 ++;
/* Read destination host name (or message) and check whether it is
complete (second double quote) */
- strncpy(dest_host, ptr1, sizeof(dest_host));
- ptr1 = dest_host;
if ((ptr2 = strchr(ptr1, '"')) != NULL) {
*ptr2 = '\0';
- ippDelete(response);
break;
}
failed:
- ippDelete(response);
/* Pause half a second before next attempt */
usleep(500000);
}
@@ -200,33 +276,16 @@ main(int argc, /* I - Number of command-line args */
return (CUPS_BACKEND_RETRY_CURRENT);
} else {
/* We have the destination host name now, do the job */
- char server_str[1024];
const char *title;
int num_options = 0;
cups_option_t *options = NULL;
- int fd, job_id;
+ int fd;
char buffer[8192];
-
- ptr2 = strrchr(dest_host, '/');
- if (ptr2) {
- *ptr2 = '\0';
- ptr2 ++;
- } else
- ptr2 = queue_name;
- fprintf(stderr, "DEBUG: Received destination host name from cups-browsed: %s\n",
- dest_host);
- fprintf(stderr, "DEBUG: Received destination queue name from cups-browsed: %s\n",
- ptr2);
-
- /* Instead of feeding the job into the IPP backend, we re-print it into
- the server's CUPS queue. This way the job gets spooled on the server
- and we are not blocked until the job is printed. So a subsequent job
- will be immediately processed and sent out to another server */
- /* Set destination server */
- snprintf(server_str, sizeof(server_str), "%s", dest_host);
- cupsSetServer(server_str);
- /* Parse the command line option and prepare them for the new print
+ fprintf(stderr, "DEBUG: Received destination host name from cups-browsed: printer-uri %s\n",
+ ptr1);
+
+ /* Parse the command line options and prepare them for the new print
job */
cupsSetUser(argv[2]);
title = argv[3];
@@ -246,55 +305,123 @@ main(int argc, /* I - Number of command-line args */
fd = open(argv[6], O_RDONLY);
else
fd = 0; /* stdin */
-
- /* Queue the job directly on the server */
- if ((job_id = cupsCreateJob(CUPS_HTTP_DEFAULT, ptr2,
- title ? title : "(stdin)",
- num_options, options)) > 0) {
- http_status_t status; /* Write status */
- const char *format; /* Document format */
- ssize_t bytes; /* Bytes read */
-
- if (cupsGetOption("raw", num_options, options))
- format = CUPS_FORMAT_RAW;
- else if ((format = cupsGetOption("document-format", num_options,
- options)) == NULL)
- format = CUPS_FORMAT_AUTO;
-
- status = cupsStartDocument(CUPS_HTTP_DEFAULT, ptr2, job_id, NULL,
- format, 1);
-
- while (status == HTTP_CONTINUE &&
- (bytes = read(fd, buffer, sizeof(buffer))) > 0)
- status = cupsWriteRequestData(CUPS_HTTP_DEFAULT, buffer, (size_t)bytes);
-
- if (status != HTTP_CONTINUE) {
- fprintf(stderr, "ERROR: %s: Unable to queue the print data - %s. Retrying.",
- argv[0], httpStatus(status));
- cupsFinishDocument(CUPS_HTTP_DEFAULT, ptr2);
- cupsCancelJob2(CUPS_HTTP_DEFAULT, ptr2, job_id, 0);
- return (CUPS_BACKEND_RETRY);
- }
- if (cupsFinishDocument(CUPS_HTTP_DEFAULT, ptr2) != IPP_OK) {
- fprintf(stderr, "ERROR: %s: Unable to complete the job - %s. Retrying.",
- argv[0], cupsLastErrorString());
- cupsCancelJob2(CUPS_HTTP_DEFAULT, ptr2, job_id, 0);
- return (CUPS_BACKEND_RETRY);
+ /* Finding the document format in which the pdftoippprinter will
+ convert the pdf file */
+ if ((ptr3 = strchr(ptr1, ' ')) != NULL) {
+ *ptr3='\0';
+ ptr3++;
+ }
+
+ /* Finding the resolution requested for the job*/
+ if ((ptr4 = strchr(ptr3, ' ')) != NULL) {
+ *ptr4='\0';
+ ptr4++;
+ }
+
+ strncpy(printer_uri, ptr1, sizeof(printer_uri));
+ strncpy(document_format, ptr3, sizeof(document_format));
+ strncpy(resolution, ptr4, sizeof(resolution));
+
+ fprintf(stderr,"DEBUG: Received job for the printer with the destination uri - %s, Final-document format for the printer - %s and requested resolution - %s\n",
+ printer_uri, document_format, resolution);
+
+ /* We need to send modified arguments to the IPP backend */
+ if (argc == 6) {
+ /* Copy stdin to a temp file...*/
+ if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0){
+ fprintf(stderr,"Debug: Can't Read PDF file.\n");
+ return CUPS_BACKEND_FAILED;
}
+ fprintf(stderr, "Debug: implicitclass - copying to temp print file \"%s\"\n",
+ tempfile);
+ while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0)
+ bytes = write(fd, buffer, bytes);
+ close(fd);
+ filename = tempfile;
+ } else{
+ /** Use the filename on the command-line...*/
+ filename = argv[6];
+ tempfile[0] = '\0';
}
- if (job_id < 1) {
- fprintf(stderr, "ERROR: %s: Unable to create job - %s. Retrying.",
- argv[0], cupsLastErrorString());
- return (CUPS_BACKEND_RETRY);
+ /* Copying the argument to a new char** which will be sent to the filter
+ and the ipp backend*/
+ for (i = 0; i < 5; i++)
+ argv_nt[i] = argv[i];
+
+ /* Few new options will be added to the argv[5]*/
+ outbuflen = strlen(argv[5]) + 256;
+ argv_nt[5] = calloc(outbuflen, sizeof(char));
+ strcpy(argv_nt[5], (const char*)argv[5]);
+
+ /* Filter pdftoippprinter.c will read the input from this file*/
+ argv_nt[6] = filename;
+ set_option_in_str(argv_nt[5], outbuflen, "output-format",
+ document_format);
+ set_option_in_str(argv_nt[5], outbuflen, "Resolution",resolution);
+ setenv("DEVICE_URI",printer_uri, 1);
+
+ filefd = cupsTempFd(tempfile_filter, sizeof(tempfile_filter));
+
+ /* The output of the last filter in pdftoippprinter will be
+ written to this file. We could have sent the output directly
+ to the backend, but having this temperory file will help us
+ find whether the filter worked correctly and what was the
+ document-format of the filtered output.*/
+ close(1);
+ dup_status = dup(filefd);
+ if(dup_status < 0) {
+ fprintf(stderr, "Could not write the output of pdftoippprinter printer to tmp file\n");
+ return CUPS_BACKEND_FAILED;
}
- return (CUPS_BACKEND_OK);
+ /* Calling pdftoippprinter.c filter*/
+ apply_filters(7,argv_nt);
+
+ close(filefd);
+
+ /* We will send the filtered output of the pdftoippprinter.c to
+ the IPP Backend*/
+ argv_nt[6] = tempfile_filter;
+ fprintf(stderr, "DEBUG: The filtered output of pdftoippprinter is written to file %s\n",
+ tempfile_filter);
+
+ /* Setting the final content type to the best pdl supported by
+ the printer.*/
+ if(!strcmp(document_format,"pdf"))
+ setenv("FINAL_CONTENT_TYPE", "application/pdf", 1);
+ else if(!strcmp(document_format,"raster"))
+ setenv("FINAL_CONTENT_TYPE", "image/pwg-raster", 1);
+ else if(!strcmp(document_format,"apple-raster"))
+ setenv("FINAL_CONTENT_TYPE", "image/urf", 1);
+ else if(!strcmp(document_format,"pclm"))
+ setenv("FINAL_CONTENT_TYPE", "application/PCLm", 1);
+ else if(!strcmp(document_format,"pclxl"))
+ setenv("FINAL_CONTENT_TYPE", "application/vnd.hp-pclxl", 1);
+ else if(!strcmp(document_format,"pcl"))
+ setenv("FINAL_CONTENT_TYPE", "application/pcl", 1);
+
+ ippDelete(response);
+
+ /* The implicitclass backend will send the job directly to the
+ ipp backend*/
+ pid_t pid = fork();
+ if ( pid == 0 ) {
+ fprintf(stderr, "DEBUG: Started IPP Backend with pid: %d\n",getpid());
+ execv("/usr/lib/cups/backend/ipp",argv_nt);
+ } else {
+ int status;
+ waitpid(pid, &status, 0);
+ if (WIFEXITED(status)) {
+ exit_status = WEXITSTATUS(status);
+ fprintf(stderr, "DEBUG: The IPP Backend exited with the status %d\n",
+ exit_status);
+ }
+ return exit_status;
+ }
}
- }
- else if (argc != 1)
- {
+ } else if (argc != 1) {
fprintf(stderr,
"Usage: %s job-id user title copies options [file]",
argv[0]);
@@ -323,4 +450,3 @@ sigterm_handler(int sig) /* I - Signal number (unused) */
else
job_canceled = 1;
}
-
diff --git a/config.h.in b/config.h.in
index 59afb6114..0f83a25e5 100644
--- a/config.h.in
+++ b/config.h.in
@@ -135,9 +135,6 @@
/* pdftops supports -r argument. */
#undef HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION
-/* Define to 1 if you have the <qpdf/Pl_RunLength.hh> header file. */
-#undef HAVE_QPDF_PL_RUNLENGTH_HH
-
/* Define to 1 if you have the `sigaction' function. */
#undef HAVE_SIGACTION
diff --git a/configure b/configure
index ed655c94d..1ca4f0651 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for cups-filters 1.21.6.
+# Generated by GNU Autoconf 2.69 for cups-filters 1.25.0.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -587,8 +587,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='cups-filters'
PACKAGE_TARNAME='cups-filters'
-PACKAGE_VERSION='1.21.6'
-PACKAGE_STRING='cups-filters 1.21.6'
+PACKAGE_VERSION='1.25.0'
+PACKAGE_STRING='cups-filters 1.25.0'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -649,10 +649,6 @@ CUPS_MUTOOL
ENABLE_GHOSTSCRIPT_FALSE
ENABLE_GHOSTSCRIPT_TRUE
CUPS_GHOSTSCRIPT
-ENABLE_OPVP_FALSE
-ENABLE_OPVP_TRUE
-ENABLE_IJS_FALSE
-ENABLE_IJS_TRUE
LARGEFILE
DBUS_LIBS
DBUS_CFLAGS
@@ -667,8 +663,6 @@ LIBQPDF_LIBS
LIBQPDF_CFLAGS
ZLIB_LIBS
ZLIB_CFLAGS
-IJS_LIBS
-IJS_CFLAGS
FONTCONFIG_LIBS
FONTCONFIG_CFLAGS
FREETYPE_LIBS
@@ -887,8 +881,6 @@ enable_largefile
enable_mutool
with_mutool_path
enable_ghostscript
-enable_ijs
-enable_opvp
with_pdftops
with_gs_path
with_pdftops_path
@@ -940,8 +932,6 @@ FREETYPE_CFLAGS
FREETYPE_LIBS
FONTCONFIG_CFLAGS
FONTCONFIG_LIBS
-IJS_CFLAGS
-IJS_LIBS
ZLIB_CFLAGS
ZLIB_LIBS
LIBQPDF_CFLAGS
@@ -1500,7 +1490,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures cups-filters 1.21.6 to adapt to many kinds of systems.
+\`configure' configures cups-filters 1.25.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1571,7 +1561,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of cups-filters 1.21.6:";;
+ short | recursive ) echo "Configuration of cups-filters 1.25.0:";;
esac
cat <<\_ACEOF
@@ -1605,8 +1595,6 @@ Optional Features:
--disable-largefile omit support for large files
--disable-mutool Disable filters using mutool.
--disable-ghostscript Disable filters using Ghostscript.
- --enable-ijs Enable filters using IJS.
- --enable-opvp Enable filters using OpenPrinting Vector (OPVP).
--disable-gs-ps2write Ghostscript doesn't support ps2write device.
--disable-foomatic Disable Foomatic-based filters.
--enable-werror Treat all warnings as errors, useful for
@@ -1720,8 +1708,6 @@ Some influential environment variables:
C compiler flags for FONTCONFIG, overriding pkg-config
FONTCONFIG_LIBS
linker flags for FONTCONFIG, overriding pkg-config
- IJS_CFLAGS C compiler flags for IJS, overriding pkg-config
- IJS_LIBS linker flags for IJS, overriding pkg-config
ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config
ZLIB_LIBS linker flags for ZLIB, overriding pkg-config
LIBQPDF_CFLAGS
@@ -1801,7 +1787,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-cups-filters configure 1.21.6
+cups-filters configure 1.25.0
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2439,7 +2425,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by cups-filters $as_me 1.21.6, which was
+It was created by cups-filters $as_me 1.25.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3474,7 +3460,7 @@ fi
# Define the identity of the package.
PACKAGE='cups-filters'
- VERSION='1.21.6'
+ VERSION='1.25.0'
cat >>confdefs.h <<_ACEOF
@@ -8052,11 +8038,8 @@ _LT_EOF
test $ac_status = 0; }; then
# Now try to grab the symbols.
nlist=conftest.nm
- if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
- (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; } && test -s "$nlist"; then
+ $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&5
+ if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&5 && test -s "$nlist"; then
# Try sorting and uniquifying the output.
if sort "$nlist" | uniq > "$nlist"T; then
mv -f "$nlist"T "$nlist"
@@ -10279,6 +10262,12 @@ lt_prog_compiler_static=
lt_prog_compiler_pic='-KPIC'
lt_prog_compiler_static='-static'
;;
+ # flang / f18. f95 an alias for gfortran or flang on Debian
+ flang* | f18* | f95*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fPIC'
+ lt_prog_compiler_static='-static'
+ ;;
# icc used to be incompatible with GCC.
# ICC 10 doesn't accept -KPIC any more.
icc* | ifort*)
@@ -17416,7 +17405,7 @@ fi
fi
fi
-CUPS_CFLAGS=`$CUPSCONFIG --cflags`
+CUPS_CFLAGS=`$CUPSCONFIG --cflags`' -D_PPD_DEPRECATED=""'
CUPS_LIBS=`$CUPSCONFIG --image --libs`
CUPS_VERSION=`$CUPSCONFIG --version`
@@ -17529,13 +17518,17 @@ fi
ax_compare_version=`echo "x$ax_compare_version_A
-x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/true/;s/x${ax_compare_version_B}/false/;1q"`
+x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version_A}/false/;s/x${ax_compare_version_B}/true/;1q"`
if test "$ax_compare_version" = "true" ; then
- if test "x$enable_driverless" != "xno"; then
+ enable_driverless=no
+
+ fi
+
+ if test "x$enable_driverless" != "xno"; then
ENABLE_DRIVERLESS_TRUE=
ENABLE_DRIVERLESS_FALSE='#'
else
@@ -17544,9 +17537,6 @@ else
fi
- fi
-
-
APPLE_RASTER_FILTER=rastertopdf
@@ -19609,77 +19599,6 @@ $as_echo "yes" >&6; }
fi
pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for IJS" >&5
-$as_echo_n "checking for IJS... " >&6; }
-
-if test -n "$IJS_CFLAGS"; then
- pkg_cv_IJS_CFLAGS="$IJS_CFLAGS"
- elif test -n "$PKG_CONFIG"; then
- if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ijs\""; } >&5
- ($PKG_CONFIG --exists --print-errors "ijs") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then
- pkg_cv_IJS_CFLAGS=`$PKG_CONFIG --cflags "ijs" 2>/dev/null`
- test "x$?" != "x0" && pkg_failed=yes
-else
- pkg_failed=yes
-fi
- else
- pkg_failed=untried
-fi
-if test -n "$IJS_LIBS"; then
- pkg_cv_IJS_LIBS="$IJS_LIBS"
- elif test -n "$PKG_CONFIG"; then
- if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"ijs\""; } >&5
- ($PKG_CONFIG --exists --print-errors "ijs") 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; then
- pkg_cv_IJS_LIBS=`$PKG_CONFIG --libs "ijs" 2>/dev/null`
- test "x$?" != "x0" && pkg_failed=yes
-else
- pkg_failed=yes
-fi
- else
- pkg_failed=untried
-fi
-
-
-
-if test $pkg_failed = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-
-if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
- _pkg_short_errors_supported=yes
-else
- _pkg_short_errors_supported=no
-fi
- if test $_pkg_short_errors_supported = yes; then
- IJS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "ijs" 2>&1`
- else
- IJS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "ijs" 2>&1`
- fi
- # Put the nasty error message in config.log where it belongs
- echo "$IJS_PKG_ERRORS" >&5
-
- have_ijs=no
-elif test $pkg_failed = untried; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
- have_ijs=no
-else
- IJS_CFLAGS=$pkg_cv_IJS_CFLAGS
- IJS_LIBS=$pkg_cv_IJS_LIBS
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
- have_ijs=yes
-fi
-
-pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZLIB" >&5
$as_echo_n "checking for ZLIB... " >&6; }
@@ -19781,12 +19700,12 @@ if test -n "$LIBQPDF_CFLAGS"; then
pkg_cv_LIBQPDF_CFLAGS="$LIBQPDF_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libqpdf >= 8.1.0\""; } >&5
- ($PKG_CONFIG --exists --print-errors "libqpdf >= 8.1.0") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libqpdf >= 8.3.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libqpdf >= 8.3.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_LIBQPDF_CFLAGS=`$PKG_CONFIG --cflags "libqpdf >= 8.1.0" 2>/dev/null`
+ pkg_cv_LIBQPDF_CFLAGS=`$PKG_CONFIG --cflags "libqpdf >= 8.3.0" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -19798,12 +19717,12 @@ if test -n "$LIBQPDF_LIBS"; then
pkg_cv_LIBQPDF_LIBS="$LIBQPDF_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libqpdf >= 8.1.0\""; } >&5
- ($PKG_CONFIG --exists --print-errors "libqpdf >= 8.1.0") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libqpdf >= 8.3.0\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "libqpdf >= 8.3.0") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_LIBQPDF_LIBS=`$PKG_CONFIG --libs "libqpdf >= 8.1.0" 2>/dev/null`
+ pkg_cv_LIBQPDF_LIBS=`$PKG_CONFIG --libs "libqpdf >= 8.3.0" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -19824,14 +19743,14 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
- LIBQPDF_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libqpdf >= 8.1.0" 2>&1`
+ LIBQPDF_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libqpdf >= 8.3.0" 2>&1`
else
- LIBQPDF_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libqpdf >= 8.1.0" 2>&1`
+ LIBQPDF_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libqpdf >= 8.3.0" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$LIBQPDF_PKG_ERRORS" >&5
- as_fn_error $? "Package requirements (libqpdf >= 8.1.0) were not met:
+ as_fn_error $? "Package requirements (libqpdf >= 8.3.0) were not met:
$LIBQPDF_PKG_ERRORS
@@ -19876,24 +19795,6 @@ else
fi
if test "x$enable_pclm" != "xno"; then
- # Do we have QPDF 7.0.0 or newer?
- for ac_header in qpdf/Pl_RunLength.hh
-do :
- ac_fn_cxx_check_header_mongrel "$LINENO" "qpdf/Pl_RunLength.hh" "ac_cv_header_qpdf_Pl_RunLength_hh" "$ac_includes_default"
-if test "x$ac_cv_header_qpdf_Pl_RunLength_hh" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_QPDF_PL_RUNLENGTH_HH 1
-_ACEOF
-
-else
- enable_pclm=no
-
-fi
-
-done
-
-fi
-if test "x$enable_pclm" != "xno"; then
$as_echo "#define QPDF_HAVE_PCLM 1" >>confdefs.h
@@ -19933,12 +19834,12 @@ if test -n "$POPPLER_CFLAGS"; then
pkg_cv_POPPLER_CFLAGS="$POPPLER_CFLAGS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"poppler >= 0.18\""; } >&5
- ($PKG_CONFIG --exists --print-errors "poppler >= 0.18") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"poppler-cpp >= 0.19\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "poppler-cpp >= 0.19") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_POPPLER_CFLAGS=`$PKG_CONFIG --cflags "poppler >= 0.18" 2>/dev/null`
+ pkg_cv_POPPLER_CFLAGS=`$PKG_CONFIG --cflags "poppler-cpp >= 0.19" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -19950,12 +19851,12 @@ if test -n "$POPPLER_LIBS"; then
pkg_cv_POPPLER_LIBS="$POPPLER_LIBS"
elif test -n "$PKG_CONFIG"; then
if test -n "$PKG_CONFIG" && \
- { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"poppler >= 0.18\""; } >&5
- ($PKG_CONFIG --exists --print-errors "poppler >= 0.18") 2>&5
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"poppler-cpp >= 0.19\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "poppler-cpp >= 0.19") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
- pkg_cv_POPPLER_LIBS=`$PKG_CONFIG --libs "poppler >= 0.18" 2>/dev/null`
+ pkg_cv_POPPLER_LIBS=`$PKG_CONFIG --libs "poppler-cpp >= 0.19" 2>/dev/null`
test "x$?" != "x0" && pkg_failed=yes
else
pkg_failed=yes
@@ -19976,14 +19877,14 @@ else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
- POPPLER_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "poppler >= 0.18" 2>&1`
+ POPPLER_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "poppler-cpp >= 0.19" 2>&1`
else
- POPPLER_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "poppler >= 0.18" 2>&1`
+ POPPLER_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "poppler-cpp >= 0.19" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$POPPLER_PKG_ERRORS" >&5
- as_fn_error $? "Package requirements (poppler >= 0.18) were not met:
+ as_fn_error $? "Package requirements (poppler-cpp >= 0.19) were not met:
$POPPLER_PKG_ERRORS
@@ -20402,43 +20303,6 @@ else
fi
-# Check whether --enable-ijs was given.
-if test "${enable_ijs+set}" = set; then :
- enableval=$enable_ijs; enable_ijs="$enableval"
-else
- enable_ijs=no
-
-fi
-
-if test "x$enable_ijs" = "xyes" -a "x$have_ijs" != "xyes"; then :
-
- as_fn_error $? "IJS not found, but requested." "$LINENO" 5
-
-fi
- if test "x$enable_ijs" = "xyes"; then
- ENABLE_IJS_TRUE=
- ENABLE_IJS_FALSE='#'
-else
- ENABLE_IJS_TRUE='#'
- ENABLE_IJS_FALSE=
-fi
-
-# Check whether --enable-opvp was given.
-if test "${enable_opvp+set}" = set; then :
- enableval=$enable_opvp; enable_opvp="$enableval"
-else
- enable_opvp=no
-
-fi
-
- if test "x$enable_opvp" = "xyes"; then
- ENABLE_OPVP_TRUE=
- ENABLE_OPVP_FALSE='#'
-else
- ENABLE_OPVP_TRUE='#'
- ENABLE_OPVP_FALSE=
-fi
-
# Check whether --with-pdftops was given.
if test "${with_pdftops+set}" = set; then :
@@ -21383,14 +21247,6 @@ if test -z "${BUILD_DBUS_TRUE}" && test -z "${BUILD_DBUS_FALSE}"; then
as_fn_error $? "conditional \"BUILD_DBUS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
-if test -z "${ENABLE_IJS_TRUE}" && test -z "${ENABLE_IJS_FALSE}"; then
- as_fn_error $? "conditional \"ENABLE_IJS\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
-if test -z "${ENABLE_OPVP_TRUE}" && test -z "${ENABLE_OPVP_FALSE}"; then
- as_fn_error $? "conditional \"ENABLE_OPVP\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
if test -z "${ENABLE_GHOSTSCRIPT_TRUE}" && test -z "${ENABLE_GHOSTSCRIPT_FALSE}"; then
as_fn_error $? "conditional \"ENABLE_GHOSTSCRIPT\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -21808,7 +21664,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by cups-filters $as_me 1.21.6, which was
+This file was extended by cups-filters $as_me 1.25.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -21874,7 +21730,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-cups-filters config.status 1.21.6
+cups-filters config.status 1.25.0
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@@ -23892,8 +23748,6 @@ Build configuration:
apple-raster: ${APPLE_RASTER_FILTER}
pclm: ${enable_pclm}
driverless auto-setup: ${enable_auto_setup_driverless}
- ijs: ${enable_ijs}
- opvp: ${enable_opvp}
==============================================================================
" >&5
$as_echo "$as_me:
@@ -23935,7 +23789,5 @@ Build configuration:
apple-raster: ${APPLE_RASTER_FILTER}
pclm: ${enable_pclm}
driverless auto-setup: ${enable_auto_setup_driverless}
- ijs: ${enable_ijs}
- opvp: ${enable_opvp}
==============================================================================
" >&6;}
diff --git a/configure.ac b/configure.ac
index bd9816cd5..c472457f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,8 +6,8 @@ AC_PREREQ([2.65])
# Version informations
# ====================
m4_define([cups_filters_version_major],[1])
-m4_define([cups_filters_version_minor],[21])
-m4_define([cups_filters_version_micro],[6])
+m4_define([cups_filters_version_minor],[25])
+m4_define([cups_filters_version_micro],[0])
m4_define([cups_filters_version],[cups_filters_version_major.cups_filters_version_minor.cups_filters_version_micro])
# =============
@@ -88,7 +88,7 @@ AS_IF([test "x$with_cups_config" != "xsystem"], [
AC_MSG_ERROR([Required cups-config is missing. Please install CUPS developer packages.])
])
])
-CUPS_CFLAGS=`$CUPSCONFIG --cflags`
+CUPS_CFLAGS=`$CUPSCONFIG --cflags`' -D_PPD_DEPRECATED=""'
CUPS_LIBS=`$CUPSCONFIG --image --libs`
CUPS_VERSION=`$CUPSCONFIG --version`
AC_SUBST(CUPS_CFLAGS)
@@ -118,10 +118,11 @@ AC_ARG_ENABLE([driverless], [AS_HELP_STRING([--enable-driverless], [enable PPD g
[enable_driverless="$enableval"],
[enable_driverless=yes]
)
-AX_COMPARE_VERSION([$CUPS_VERSION],[ge],[1.6], [
- AM_CONDITIONAL([ENABLE_DRIVERLESS],
- [test "x$enable_driverless" != "xno"])
+AX_COMPARE_VERSION([$CUPS_VERSION],[lt],[1.6], [
+ enable_driverless=no
])
+AM_CONDITIONAL([ENABLE_DRIVERLESS],
+[test "x$enable_driverless" != "xno"])
APPLE_RASTER_FILTER=rastertopdf
AX_COMPARE_VERSION([$CUPS_VERSION],[lt],[2.2.2], [
@@ -459,10 +460,9 @@ AS_IF([test x"$lcms2" = "xno"], [
])
PKG_CHECK_MODULES([FREETYPE], [freetype2], [AC_DEFINE([HAVE_FREETYPE_H], [1], [Have FreeType2 include files])])
PKG_CHECK_MODULES([FONTCONFIG], [fontconfig >= 2.0.0])
-PKG_CHECK_MODULES([IJS], [ijs], [have_ijs=yes], [have_ijs=no])
PKG_CHECK_MODULES([ZLIB], [zlib])
AC_DEFINE([HAVE_LIBZ], [], [Define that we use zlib])
-PKG_CHECK_MODULES([LIBQPDF], [libqpdf >= 8.1.0])
+PKG_CHECK_MODULES([LIBQPDF], [libqpdf >= 8.3.0])
# ===============================
# Check for PCLm printing support
@@ -472,13 +472,6 @@ AC_ARG_ENABLE([pclm], [AS_HELP_STRING([--enable-pclm], [enable PCLm printing.])]
[enable_pclm=yes]
)
if test "x$enable_pclm" != "xno"; then
- # Do we have QPDF 7.0.0 or newer?
- AC_CHECK_HEADERS([qpdf/Pl_RunLength.hh],
- [],
- [enable_pclm=no]
- )
-fi
-if test "x$enable_pclm" != "xno"; then
AC_DEFINE([QPDF_HAVE_PCLM], [1], [QPDF has PCLm support?])
QPDF_NO_PCLM=
else
@@ -495,7 +488,7 @@ AC_ARG_ENABLE(poppler, AS_HELP_STRING([--enable-poppler],[enable Poppler-based f
enable_poppler=$enableval,enable_poppler=yes)
AM_CONDITIONAL(ENABLE_POPPLER, test x$enable_poppler = xyes)
if test x$enable_poppler = xyes; then
- PKG_CHECK_MODULES([POPPLER], [poppler >= 0.18])
+ PKG_CHECK_MODULES([POPPLER], [poppler-cpp >= 0.19])
AC_CHECK_HEADER([poppler/cpp/poppler-version.h], [AC_DEFINE([HAVE_CPP_POPPLER_VERSION_H],,[Define if you have Poppler's "cpp/poppler-version.h" header file.])], [])
fi
@@ -549,21 +542,6 @@ AC_ARG_ENABLE([ghostscript],
[enable_ghostscript="$enableval"],
[enable_ghostscript=yes]
)
-AC_ARG_ENABLE([ijs],
- [AS_HELP_STRING([--enable-ijs], [Enable filters using IJS.])],
- [enable_ijs="$enableval"],
- [enable_ijs=no]
-)
-AS_IF([test "x$enable_ijs" = "xyes" -a "x$have_ijs" != "xyes"], [
- AC_MSG_ERROR([IJS not found, but requested.])
-])
-AM_CONDITIONAL(ENABLE_IJS, test "x$enable_ijs" = "xyes")
-AC_ARG_ENABLE([opvp],
- [AS_HELP_STRING([--enable-opvp], [Enable filters using OpenPrinting Vector (OPVP).])],
- [enable_opvp="$enableval"],
- [enable_opvp=no]
-)
-AM_CONDITIONAL(ENABLE_OPVP, test "x$enable_opvp" = "xyes")
AC_ARG_WITH([pdftops],
[AS_HELP_STRING([--with-pdftops=value], [Set which pdftops to use (gs,pdftops,pdftocairo,acroread,mupdf,hybrid).])],
[with_pdftops="$withval"],
@@ -910,7 +888,5 @@ Build configuration:
apple-raster: ${APPLE_RASTER_FILTER}
pclm: ${enable_pclm}
driverless auto-setup: ${enable_auto_setup_driverless}
- ijs: ${enable_ijs}
- opvp: ${enable_opvp}
==============================================================================
])
diff --git a/cupsfilters/image-gif.c b/cupsfilters/image-gif.c
index 53cd86a52..c225dc709 100644
--- a/cupsfilters/image-gif.c
+++ b/cupsfilters/image-gif.c
@@ -126,7 +126,13 @@ _cupsImageReadGIF(
transparent = buf[3];
}
- while (gif_get_block(fp, buf) != 0);
+ while (gif_get_block(fp, buf) != 0)
+ {
+ if(gif_eof)
+ {
+ return (-1);
+ }
+ }
break;
case ',' : /* cupsImage data */
@@ -487,8 +493,11 @@ gif_read_image(FILE *fp, /* I - Input file */
temp += bpp;
if (xpos == img->xsize)
{
- _cupsImagePutRow(img, 0, ypos, img->xsize, pixels);
-
+ int res = _cupsImagePutRow(img, 0, ypos, img->xsize, pixels);
+ if(res)
+ {
+ return (-1);
+ }
xpos = 0;
temp = pixels;
diff --git a/cupsfilters/image.c b/cupsfilters/image.c
index 736c7fea7..ac96541be 100644
--- a/cupsfilters/image.c
+++ b/cupsfilters/image.c
@@ -39,7 +39,7 @@
* Local functions...
*/
-static void flush_tile(cups_image_t *img);
+static int flush_tile(cups_image_t *img);
static cups_ib_t *get_tile(cups_image_t *img, int x, int y);
@@ -614,7 +614,7 @@ cupsImageSetMaxTiles(
* 'flush_tile()' - Flush the least-recently-used tile in the cache.
*/
-static void
+static int
flush_tile(cups_image_t *img) /* I - Image */
{
int bpp; /* Bytes per pixel */
@@ -622,12 +622,16 @@ flush_tile(cups_image_t *img) /* I - Image */
bpp = cupsImageGetDepth(img);
+ if(img==NULL||img->first==NULL||img->first->tile==NULL)
+ {
+ return -1;
+ }
tile = img->first->tile;
if (!tile->dirty)
{
tile->ic = NULL;
- return;
+ return 0;
}
if (img->cachefile < 0)
@@ -637,7 +641,7 @@ flush_tile(cups_image_t *img) /* I - Image */
{
tile->ic = NULL;
tile->dirty = 0;
- return;
+ return 0;
}
DEBUG_printf(("Created swap file \"%s\"...\n", img->cachename));
@@ -649,7 +653,7 @@ flush_tile(cups_image_t *img) /* I - Image */
{
tile->ic = NULL;
tile->dirty = 0;
- return;
+ return 0;
}
}
else
@@ -658,7 +662,7 @@ flush_tile(cups_image_t *img) /* I - Image */
{
tile->ic = NULL;
tile->dirty = 0;
- return;
+ return 0;
}
}
@@ -668,6 +672,7 @@ flush_tile(cups_image_t *img) /* I - Image */
tile->ic = NULL;
tile->dirty = 0;
+ return 0;
}
@@ -743,7 +748,11 @@ get_tile(cups_image_t *img, /* I - Image */
{
DEBUG_printf(("Flushing old cache tile (%p)...\n", img->first));
- flush_tile(img);
+ int res = flush_tile(img);
+ if(res)
+ {
+ return NULL;
+ }
ic = img->first;
}
@@ -807,3 +816,30 @@ get_tile(cups_image_t *img, /* I - Image */
return (ic->pixels + bpp * (y * CUPS_TILE_SIZE + x));
}
+/*
+ * Crop a image.
+ * (posw,posh): Position of left corner
+ * (width,height): width and height of required image.
+ */
+cups_image_t* cupsImageCrop(cups_image_t* img,int posw,int posh,int width,int height)
+{
+ int image_width = cupsImageGetWidth(img);
+ cups_image_t* temp=calloc(sizeof(cups_image_t),1);
+ cups_ib_t *pixels=(cups_ib_t*)malloc(img->xsize*cupsImageGetDepth(img));
+ temp->cachefile = -1;
+ temp->max_ics = CUPS_TILE_MINIMUM;
+ temp->colorspace=img->colorspace;
+ temp->xppi = img->xppi;
+ temp->yppi = img->yppi;
+ temp->num_ics = 0;
+ temp->first =temp->last = NULL;
+ temp->tiles = NULL;
+ temp->xsize = width;
+ temp->ysize = height;
+ for(int i=posh;i<min(cupsImageGetHeight(img),posh+height);i++){
+ cupsImageGetRow(img,posw,i,min(width,image_width-posw),pixels);
+ _cupsImagePutRow(temp,0,i-posh,min(width,image_width-posw),pixels);
+ }
+ free(pixels);
+ return temp;
+}
diff --git a/cupsfilters/image.h b/cupsfilters/image.h
index 3c7e48078..afeb74d20 100644
--- a/cupsfilters/image.h
+++ b/cupsfilters/image.h
@@ -112,7 +112,8 @@ extern void cupsImageWhiteToRGB(const cups_ib_t *in,
cups_ib_t *out, int count) _CUPS_API_1_2;
extern void cupsImageWhiteToWhite(const cups_ib_t *in,
cups_ib_t *out, int count) _CUPS_API_1_2;
-
+extern cups_image_t* cupsImageCrop(cups_image_t* img,int posw,
+ int posh,int width,int height);
# ifdef __cplusplus
}
diff --git a/cupsfilters/pdftoippprinter.c b/cupsfilters/pdftoippprinter.c
new file mode 100644
index 000000000..9bf0e4eb4
--- /dev/null
+++ b/cupsfilters/pdftoippprinter.c
@@ -0,0 +1,905 @@
+/*
+ * pdftoippprinter.c
+ *
+ * Function to convert PDF into PWG/Apple Raster and PCLm for printing
+ * on driverless IPP printers.
+ *
+ * Copyright 2007-2011 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2011-2013 by Till Kamppeter
+ *
+ * Contents:
+ *
+ * apply_filters() - Main function...
+ * cancel_job() - Flag the job as canceled.
+ * filter_present() - Is the requested filter actually installed?
+ * compare_pids() - Compare process IDs for sorting PID list
+ * exec_filter() - Execute a filter process
+ * exec_filters() - Execute a filter chain
+ * open_pipe() - Create a pipe to transfer data from filter to filter
+ * get_option_in_str() - Get an option value from a string like argv[5]
+ * set_option_in_str() - Set an option value in a string like argv[5]
+ */
+
+/*
+ * Include necessary headers...
+ */
+
+#include <config.h>
+#include <cups/cups.h>
+#include <cups/ppd.h>
+#include <cups/file.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <limits.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <ctype.h>
+#include <cupsfilters/image-private.h>
+
+#define MAX_CHECK_COMMENT_LINES 20
+
+/*
+ * Type definitions
+ */
+
+typedef unsigned output_format_t;
+enum output_format_e {PDF = 0, POSTSCRIPT = 1, PWGRASTER = 2, PCLXL = 3, PCL = 4, APPLERASTER = 5, PCLM = 6};
+typedef struct filter_pid_s /* Filter in filter chain */
+{
+ char *name; /* Filter executable name */
+ int pid; /* PID of filter process */
+} filter_pid_t;
+
+/*
+ * Local functions...
+ */
+
+static void cancel_job(int sig);
+static int filter_present(const char *filter);
+static int compare_pids(filter_pid_t *a, filter_pid_t *b);
+static int exec_filter(const char *filter, char **argv,
+ int infd, int outfd);
+static int exec_filters(cups_array_t *filters, char **argv);
+static int open_pipe(int *fds);
+static char* get_option_in_str(char *buf, const char *option,
+ int return_value);
+static void set_option_in_str(char *buf, int buflen,
+ const char *option,
+ const char *value);
+
+/*
+ * Local globals...
+ */
+
+static int job_canceled = 0;
+
+
+/*
+ * 'apply_filters()' - Main function...
+ */
+
+int
+apply_filters(int argc, char *argv[])
+{
+ int i; /* Looping var */
+ output_format_t output_format; /* Output format */
+ int fd = 0; /* Copy file descriptor */
+ char *filename, /* PDF file to convert */
+ tempfile[1024]; /* Temporary file */
+ char buffer[8192]; /* Copy buffer */
+ int bytes; /* Bytes copied */
+ int num_options; /* Number of options */
+ cups_option_t *options; /* Options */
+ const char *val; /* Option value */
+ char *argv_nt[8]; /* NULL-terminated array of the command
+ line arguments */
+ int optbuflen;
+ cups_array_t *filter_chain; /* Filter chain to execute */
+ int exit_status = 0; /* Exit status */
+ int color_printing; /* Do we print in color? */
+ char *filter, *p;
+#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
+ struct sigaction action; /* Actions for POSIX signals */
+#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+ static const char * const color_mode_option_names[] =
+ { /* Possible names for a color mode option */
+ "pwg-raster-document-type",
+ "PwgRasterDocumentType",
+ "print-color-mode",
+ "PrintColorMode",
+ "color-space",
+ "ColorSpace",
+ "color-model",
+ "ColorModel",
+ NULL
+ };
+
+
+ /*
+ * Make sure status messages are not buffered...
+ */
+
+ setbuf(stderr, NULL);
+
+ /*
+ * Ignore broken pipe signals...
+ */
+
+ signal(SIGPIPE, SIG_IGN);
+
+ /*
+ * Make sure we have the right number of arguments for CUPS!
+ */
+
+ if (argc < 6 || argc > 7)
+ {
+ fprintf(stderr, "Usage: %s job user title copies options [file]\n",
+ argv[0]);
+ return (1);
+ }
+
+ /*
+ * Register a signal handler to cleanly cancel a job.
+ */
+
+#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
+ sigset(SIGTERM, cancel_job);
+#elif defined(HAVE_SIGACTION)
+ memset(&action, 0, sizeof(action));
+
+ sigemptyset(&action.sa_mask);
+ action.sa_handler = cancel_job;
+ sigaction(SIGTERM, &action, NULL);
+#else
+ signal(SIGTERM, cancel_job);
+#endif /* HAVE_SIGSET */
+
+ /*
+ * Copy stdin if needed...
+ */
+
+ if (argc == 6) {
+ /*
+ * Copy stdin to a temp file...
+ */
+
+ if ((fd = cupsTempFd(tempfile, sizeof(tempfile))) < 0) {
+ perror("DEBUG: Unable to copy PDF file");
+ return (1);
+ }
+
+ fprintf(stderr,
+ "DEBUG: sys5ippprinter - copying to temp print file \"%s\"\n",
+ tempfile);
+
+ while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0)
+ bytes = write(fd, buffer, bytes);
+
+ close(fd);
+
+ filename = tempfile;
+ } else {
+ /*
+ * Use the filename on the command-line...
+ */
+
+ filename = argv[6];
+ tempfile[0] = '\0';
+ }
+
+ /*
+ * Get the options from the fifth command line argument
+ */
+
+ num_options = cupsParseOptions(argv[5], 0, &options);
+
+ /*
+ * Copy the command line arguments into a NULL-terminated array
+ */
+
+ for (i = 0; i < 5; i++)
+ argv_nt[i] = argv[i];
+ /* We copy the contents of argv[5] into a somewhat larger buffer so that
+ we can manipulate it */
+ optbuflen = strlen(argv[5]) + 256;
+ argv_nt[5] = calloc(optbuflen, sizeof(char));
+ strcpy(argv_nt[5], (const char*)argv[5]);
+ argv_nt[6] = filename;
+ argv_nt[7] = NULL;
+
+ /*
+ * Create filter chain
+ */
+
+ filter_chain = cupsArrayNew(NULL, NULL);
+
+ /*
+ * Add the gziptoany filter if installed
+ */
+
+ if (filter_present("gziptoany"))
+ cupsArrayAdd(filter_chain, "gziptoany");
+
+ /*
+ * Select the output format: PDF, PostScript, PWG Raster, PCL-XL, and
+ * PCL 5c/e
+ * Add the needed filters to the filter chain
+ */
+
+ if ((val = cupsGetOption("output-format", num_options, options)) != NULL) {
+ if (strcasestr(val, "raster")) {
+ output_format = PWGRASTER;
+ /* PWG Raster output */
+ set_option_in_str(argv_nt[5], optbuflen, "MediaClass", NULL);
+ set_option_in_str(argv_nt[5], optbuflen, "media-class", "pwg");
+ /* 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)
+ cupsArrayAdd(filter_chain, "gstoraster");
+ else {
+ fprintf(stderr,
+ "DEBUG: Filter gstoraster or Ghostscript (%s) missing for \"output-format=%s\", using pdftoraster.\n",
+ CUPS_GHOSTSCRIPT, val);
+ if (filter_present("pdftoraster"))
+ cupsArrayAdd(filter_chain, "pdftoraster");
+ else {
+ fprintf(stderr,
+ "ERROR: Filter pdftoraster missing for \"output-format=%s\"\n",
+ val);
+ exit_status = 1;
+ goto error;
+ }
+ setenv("FINAL_CONTENT_TYPE", "pwg", 1);
+ }
+ } else if (strcasestr(val, "apple-raster")) {
+ output_format = APPLERASTER;
+ /* PWG Raster output */
+ set_option_in_str(argv_nt[5], optbuflen, "MediaClass", NULL);
+ set_option_in_str(argv_nt[5], optbuflen, "media-class", "");
+ /* 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)
+ cupsArrayAdd(filter_chain, "gstoraster");
+ else {
+ fprintf(stderr,
+ "DEBUG: Filter gstoraster or Ghostscript (%s) missing for \"output-format=%s\", using pdftoraster.\n",
+ CUPS_GHOSTSCRIPT, val);
+ if (filter_present("pdftoraster"))
+ cupsArrayAdd(filter_chain, "pdftoraster");
+ else {
+ fprintf(stderr,
+ "ERROR: Filter pdftoraster missing for \"output-format=%s\"\n",
+ val);
+ exit_status = 1;
+ goto error;
+ }
+ }
+ if (filter_present("rastertopwg"))
+ cupsArrayAdd(filter_chain, "rastertopwg");
+ else {
+ fprintf(stderr,
+ "ERROR: Filter rastertopwg missing for \"output-format=%s\"\n",
+ val);
+ exit_status = 1;
+ goto error;
+ }
+ setenv("FINAL_CONTENT_TYPE", "image/urf", 1);
+ } else if (strcasestr(val, "pdf")) {
+ output_format = PDF;
+ /* Page logging into page_log has to be done by pdftopdf */
+ set_option_in_str(argv_nt[5], optbuflen, "page-logging", "on");
+ } else if (strcasestr(val, "postscript")) {
+ output_format = POSTSCRIPT;
+ /* Page logging into page_log is done by pstops, so no need by
+ pdftopdf */
+ 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) {
+ fprintf(stderr,
+ "DEBUG: Ghostscript (%s) missing for \"output-format=%s\", using Poppler's pdftops instead.\n",
+ CUPS_GHOSTSCRIPT, val);
+ set_option_in_str(argv_nt[5], optbuflen, "pdftops-renderer",
+ "pdftops");
+ } else if (access(CUPS_POPPLER_PDFTOPS, X_OK) != 0) {
+ fprintf(stderr,
+ "DEBUG: Poppler's pdftops (%s) missing for \"output-format=%s\", using Ghostscript instead.\n",
+ CUPS_POPPLER_PDFTOPS, val);
+ set_option_in_str(argv_nt[5], optbuflen, "pdftops-renderer",
+ "gs");
+ } else
+ set_option_in_str(argv_nt[5], optbuflen, "pdftops-renderer",
+ "hybrid");
+ } else {
+ fprintf(stderr,
+ "ERROR: Filter pdftops missing for \"output-format=%s\"\n",
+ val);
+ exit_status = 1;
+ goto error;
+ }
+ } else if ((p = strcasestr(val, "pcl")) != NULL) {
+ if (!strcasecmp(p, "pclxl")) {
+ output_format = PCLXL;
+ if (filter_present("gstopxl") && access(CUPS_GHOSTSCRIPT, X_OK) == 0) {
+ 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);
+ output_format = PCL;
+ }
+ } else if (!strcasecmp(p, "pclm")) {
+ output_format = PCLM;
+ /* PWG Raster output */
+ set_option_in_str(argv_nt[5], optbuflen, "MediaClass", NULL);
+ set_option_in_str(argv_nt[5], optbuflen, "media-class", "");
+ /* 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)
+ cupsArrayAdd(filter_chain, "gstoraster");
+ else {
+ fprintf(stderr,
+ "DEBUG: Filter gstoraster or Ghostscript (%s) missing for \"output-format=%s\", using pdftoraster.\n",
+ CUPS_GHOSTSCRIPT, val);
+ if (filter_present("pdftoraster"))
+ cupsArrayAdd(filter_chain, "pdftoraster");
+ else {
+ fprintf(stderr,
+ "ERROR: Filter pdftoraster missing for \"output-format=%s\"\n",
+ val);
+ exit_status = 1;
+ goto error;
+ }
+ }
+ if (filter_present("rastertopclm"))
+ cupsArrayAdd(filter_chain, "rastertopclm");
+ else {
+ fprintf(stderr,
+ "ERROR: Filter rastertopclm missing for \"output-format=%s\"\n",
+ val);
+ exit_status = 1;
+ goto error;
+ }
+ }
+ if (!strcasecmp(p, "pclxl")) {
+ output_format = PCLXL;
+ if (filter_present("gstopxl") && access(CUPS_GHOSTSCRIPT, X_OK) == 0) {
+ 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);
+ output_format = PCL;
+ }
+ } else {
+ output_format = PCL;
+ }
+ } else {
+ fprintf(stderr,
+ "ERROR: Invalid value for \"output-format\": \"%s\"\n", val);
+ exit_status = 1;
+ goto error;
+ }
+ } else {
+ fprintf(stderr,
+ "ERROR: Missing option \"output-format\".\n");
+ exit_status = 1;
+ goto error;
+ }
+ if (output_format == PCL) {
+ /* We need CUPS Raster as we want to use rastertopclx with unprintable
+ margins */
+ set_option_in_str(argv_nt[5], optbuflen, "MediaClass", NULL);
+ set_option_in_str(argv_nt[5], optbuflen, "media-class", "");
+ /* Page logging into page_log is done by rastertopclx, so no need by
+ pdftopdf */
+ set_option_in_str(argv_nt[5], optbuflen, "page-logging", "off");
+ /* Does the client send info about margins? */
+ if (!get_option_in_str(argv_nt[5], "media-left-margin", 0) &&
+ !get_option_in_str(argv_nt[5], "media-right-margin", 0) &&
+ !get_option_in_str(argv_nt[5], "media-top-margin", 0) &&
+ !get_option_in_str(argv_nt[5], "media-bottom-margin", 0)) {
+ /* Set default 12pt margins if there is no info about printer's
+ unprintable margins (100th of mm units, 12.0 * 2540.0 / 72.0 = 423.33)
+ */
+ set_option_in_str(argv_nt[5], optbuflen, "media-left-margin", "423.33");
+ set_option_in_str(argv_nt[5], optbuflen, "media-right-margin", "423.33");
+ set_option_in_str(argv_nt[5], optbuflen, "media-top-margin", "423.33");
+ set_option_in_str(argv_nt[5], optbuflen, "media-bottom-margin", "423.33");
+ }
+ /* Check whether the job is requested to be printed in color and if so,
+ set the color space to RGB as this is the best color printing support
+ in PCL 5c */
+ color_printing = 0;
+ for (i = 0; color_mode_option_names[i]; i ++) {
+ p = get_option_in_str(argv_nt[5], color_mode_option_names[i], 1);
+ if (p && (strcasestr(p, "RGB") || strcasestr(p, "CMY") ||
+ strcasestr(p, "color"))) {
+ color_printing = 1;
+ break;
+ }
+ }
+ if (color_printing == 1) {
+ /* Remove unneeded color mode options */
+ for (i = 0; color_mode_option_names[i]; i ++)
+ set_option_in_str(argv_nt[5], optbuflen, color_mode_option_names[i],
+ NULL);
+ /* 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)
+ cupsArrayAdd(filter_chain, "gstoraster");
+ else {
+ fprintf(stderr,
+ "DEBUG: Filter gstoraster or Ghostscript (%s) missing for \"output-format=%s\", using pdftoraster.\n",
+ CUPS_GHOSTSCRIPT, val);
+ if (filter_present("pdftoraster"))
+ cupsArrayAdd(filter_chain, "pdftoraster");
+ else {
+ fprintf(stderr,
+ "ERROR: Filter pdftoraster missing for \"output-format=%s\"\n",
+ val);
+ exit_status = 1;
+ goto error;
+ }
+ }
+ if (filter_present("rastertopclx"))
+ cupsArrayAdd(filter_chain, "rastertopclx");
+ else {
+ fprintf(stderr,
+ "ERROR: Filter rastertopclx missing for \"output-format=%s\"\n",
+ val);
+ exit_status = 1;
+ goto error;
+ }
+ }
+
+ fprintf(stderr,
+ "DEBUG: Printer supports output formats: %s\nDEBUG: Using following CUPS filter chain to convert input data to the %s format:",
+ val,
+ output_format == PDF ? "PDF" :
+ (output_format == POSTSCRIPT ? "Postscript" :
+ (output_format == PWGRASTER ? "PWG Raster" :
+ (output_format == PCLXL ? "PCL XL" :
+ (output_format == PCL ? "PCL 5c/e" :
+ (output_format == APPLERASTER ? "APPLE Raster" :
+ (output_format == PCLM ? "PCLm" : "unknown")))))));
+ for (filter = (char *)cupsArrayFirst(filter_chain);
+ filter;
+ filter = (char *)cupsArrayNext(filter_chain))
+ fprintf(stderr, " %s", filter);
+ fprintf(stderr, "\n");
+
+ /*
+ * Execute the filter chain
+ */
+
+ exit_status = exec_filters(filter_chain, (char **)argv_nt);
+
+ /*
+ * Cleanup and exit...
+ */
+
+ error:
+
+ if (tempfile[0])
+ unlink(tempfile);
+
+ return (exit_status);
+}
+
+
+/*
+ * 'cancel_job()' - Flag the job as canceled.
+ */
+
+static void
+cancel_job(int sig) /* I - Signal number (unused) */
+{
+ (void)sig;
+
+ job_canceled = 1;
+}
+
+
+static int
+filter_present(const char *filter) /* I - Filter name */
+{
+ char filter_path[1024]; /* Path to filter executable */
+ const char *cups_serverbin; /* CUPS_SERVERBIN environment variable */
+
+ if ((cups_serverbin = getenv("CUPS_SERVERBIN")) == NULL)
+ cups_serverbin = CUPS_SERVERBIN;
+
+ snprintf(filter_path, sizeof(filter_path), "%s/filter/%s",
+ cups_serverbin, filter);
+
+ if (access(filter_path, X_OK) == 0)
+ return 1;
+
+ return 0;
+}
+
+
+/*
+ * 'compare_pids()' - Compare two filter PIDs...
+ */
+
+static int /* O - Result of comparison */
+compare_pids(filter_pid_t *a, /* I - First filter */
+ filter_pid_t *b) /* I - Second filter */
+{
+ return (a->pid - b->pid);
+}
+
+
+/*
+ * 'exec_filter()' - Execute a single filter.
+ */
+
+static int /* O - Process ID or -1 on error */
+exec_filter(const char *filter, /* I - Filter to execute */
+ char **argv, /* I - Original command line args */
+ int infd, /* I - Stdin file descriptor */
+ int outfd) /* I - Stdout file descriptor */
+{
+ int pid, /* Process ID */
+ fd; /* Temporary file descriptor */
+
+ if ((pid = fork()) == 0) {
+ /*
+ * Child process goes here...
+ *
+ * Update stdin/stdout/stderr as needed...
+ */
+
+ if (infd != 0) {
+ if (infd < 0)
+ infd = open("/dev/null", O_RDONLY);
+
+ if (infd > 0) {
+ dup2(infd, 0);
+ close(infd);
+ }
+ }
+
+ if (outfd != 1) {
+ if (outfd < 0)
+ outfd = open("/dev/null", O_WRONLY);
+
+ if (outfd > 1) {
+ dup2(outfd, 1);
+ close(outfd);
+ }
+ }
+
+ /* Send stderr to the Nirwana if we are running gziptoany, as
+ gziptoany emits a false "PAGE: 1 1" */
+ if (strcasestr(filter, "gziptoany")) {
+ if ((fd = open("/dev/null", O_RDWR)) > 2) {
+ dup2(fd, 2);
+ close(fd);
+ } else
+ close(fd);
+ fcntl(2, F_SETFL, O_NDELAY);
+ }
+
+ if ((fd = open("/dev/null", O_RDWR)) > 3) {
+ dup2(fd, 3);
+ close(fd);
+ }
+ else
+ close(fd);
+ fcntl(3, F_SETFL, O_NDELAY);
+
+ if ((fd = open("/dev/null", O_RDWR)) > 4) {
+ dup2(fd, 4);
+ close(fd);
+ } else
+ close(fd);
+ fcntl(4, F_SETFL, O_NDELAY);
+
+ /*
+ * Execute command...
+ */
+
+ execvp(filter, argv);
+
+ perror(filter);
+
+ exit(errno);
+ }
+
+ return (pid);
+}
+
+
+/*
+ * 'exec_filters()' - Execute filters for the given file and options.
+ */
+
+static int /* O - 0 on success, 1 on error */
+exec_filters(cups_array_t *filters, /* I - Array of filters to run */
+ char **argv) /* I - Filter options */
+{
+ int i; /* Looping var */
+ char program[1024]; /* Program to run */
+ char *filter, /* Current filter */
+ *next; /* Next filter */
+ int current, /* Current filter */
+ filterfds[2][2], /* Pipes for filters */
+ pid, /* Process ID of filter */
+ status, /* Exit status */
+ retval; /* Return value */
+ cups_array_t *pids; /* Executed filters array */
+ filter_pid_t *pid_entry, /* Entry in executed filters array */
+ key; /* Search key for filters */
+ const char *cups_serverbin; /* CUPS_SERVERBIN environment variable */
+
+ /*
+ * Remove NULL ("-") filters...
+ */
+
+ for (filter = (char *)cupsArrayFirst(filters);
+ filter;
+ filter = (char *)cupsArrayNext(filters))
+ if (!strcmp(filter, "-"))
+ cupsArrayRemove(filters, filter);
+
+ for (i = 0; argv[i]; i ++)
+ fprintf(stderr, "DEBUG: argv[%d]=\"%s\"\n", i, argv[i]);
+
+ /*
+ * Execute all of the filters...
+ */
+
+ pids = cupsArrayNew((cups_array_func_t)compare_pids, NULL);
+ current = 0;
+ filterfds[0][0] = 0;
+ filterfds[0][1] = -1;
+ filterfds[1][0] = -1;
+ filterfds[1][1] = -1;
+
+ for (filter = (char *)cupsArrayFirst(filters);
+ filter;
+ filter = next, current = 1 - current) {
+ next = (char *)cupsArrayNext(filters);
+
+ if (filter[0] == '/') {
+ strncpy(program, filter, sizeof(program));
+ if (strlen(filter) > 1023)
+ program[1023] = '\0';
+ } else {
+ if ((cups_serverbin = getenv("CUPS_SERVERBIN")) == NULL)
+ cups_serverbin = CUPS_SERVERBIN;
+ snprintf(program, sizeof(program), "%s/filter/%s", cups_serverbin,
+ filter);
+ }
+
+ if (filterfds[!current][1] > 1) {
+ close(filterfds[1 - current][0]);
+ close(filterfds[1 - current][1]);
+
+ filterfds[1 - current][0] = -1;
+ filterfds[1 - current][0] = -1;
+ }
+
+ if (next)
+ open_pipe(filterfds[1 - current]);
+ else
+ filterfds[1 - current][1] = 1;
+
+ pid = exec_filter(program, argv,
+ filterfds[current][0], filterfds[1 - current][1]);
+
+ if (pid > 0) {
+ fprintf(stderr, "INFO: %s (PID %d) started.\n", filter, pid);
+
+ pid_entry = malloc(sizeof(filter_pid_t));
+ pid_entry->pid = pid;
+ pid_entry->name = filter;
+ cupsArrayAdd(pids, pid_entry);
+ } else
+ break;
+
+ argv[6] = NULL;
+ }
+
+ /*
+ * Close remaining pipes...
+ */
+
+ if (filterfds[0][1] > 1) {
+ close(filterfds[0][0]);
+ close(filterfds[0][1]);
+ }
+
+ if (filterfds[1][1] > 1) {
+ close(filterfds[1][0]);
+ close(filterfds[1][1]);
+ }
+
+ /*
+ * Wait for the children to exit...
+ */
+
+ retval = 0;
+
+ while (cupsArrayCount(pids) > 0) {
+ if ((pid = wait(&status)) < 0) {
+ if (errno == EINTR && job_canceled) {
+ fprintf(stderr, "DEBUG: Job canceled, killing filters ...\n");
+ for (pid_entry = (filter_pid_t *)cupsArrayFirst(pids);
+ pid_entry;
+ pid_entry = (filter_pid_t *)cupsArrayNext(pids))
+ kill(pid_entry->pid, SIGTERM);
+ job_canceled = 0;
+ } else
+ continue;
+ }
+
+ key.pid = pid;
+ if ((pid_entry = (filter_pid_t *)cupsArrayFind(pids, &key)) != NULL) {
+ cupsArrayRemove(pids, pid_entry);
+
+ if (status) {
+ if (WIFEXITED(status))
+ fprintf(stderr, "ERROR: %s (PID %d) stopped with status %d\n",
+ pid_entry->name, pid, WEXITSTATUS(status));
+ else
+ fprintf(stderr, "ERROR: %s (PID %d) crashed on signal %d\n",
+ pid_entry->name, pid, WTERMSIG(status));
+
+ retval = 1;
+ } else
+ fprintf(stderr, "INFO: %s (PID %d) exited with no errors.\n",
+ pid_entry->name, pid);
+
+ free(pid_entry);
+ }
+ }
+
+ cupsArrayDelete(pids);
+
+ return (retval);
+}
+
+
+/*
+ * 'open_pipe()' - Create a pipe which is closed on exec.
+ */
+
+static int /* O - 0 on success, -1 on error */
+open_pipe(int *fds) /* O - Pipe file descriptors (2) */
+{
+ /*
+ * Create the pipe...
+ */
+
+ if (pipe(fds)) {
+ fds[0] = -1;
+ fds[1] = -1;
+
+ return (-1);
+ }
+
+ /*
+ * Set the "close on exec" flag on each end of the pipe...
+ */
+
+ if (fcntl(fds[0], F_SETFD, fcntl(fds[0], F_GETFD) | FD_CLOEXEC)) {
+ close(fds[0]);
+ close(fds[1]);
+
+ fds[0] = -1;
+ fds[1] = -1;
+
+ return (-1);
+ }
+
+ if (fcntl(fds[1], F_SETFD, fcntl(fds[1], F_GETFD) | FD_CLOEXEC)) {
+ close(fds[0]);
+ close(fds[1]);
+
+ fds[0] = -1;
+ fds[1] = -1;
+
+ return (-1);
+ }
+
+ /*
+ * Return 0 indicating success...
+ */
+
+ return (0);
+}
+
+
+/*
+ * Get option value in a string of options
+ */
+
+static char* /* O - Value, NULL if option not set */
+get_option_in_str(char *buf, /* I - Buffer with option list string */
+ const char *option, /* I - Option of which to get value */
+ int return_value) /* I - Return value or only check
+ presence of option? */
+{
+ char *p1, *p2;
+ char *result;
+
+ if (!buf || !option)
+ return NULL;
+ if ((p1 = strcasestr(buf, option)) == NULL)
+ return NULL;
+ if (p1 > buf && *(p1 - 1) != ' ' && *(p1 - 1) != '\t')
+ return NULL;
+ p2 = p1 + strlen(option);
+ if (*p2 == ' ' || *p2 == '\t' || *p2 == '\0')
+ return "";
+ if (*p2 != '=')
+ return NULL;
+ if (!return_value)
+ return "";
+ p1 = p2 + 1;
+ for (p2 = p1; *p2 != ' ' && *p2 != '\t' && *p2 != '\0'; p2 ++);
+ if (p2 == p1)
+ return "";
+ result = calloc(p2 - p1 + 1, sizeof(char));
+ memcpy(result, p1, p2 - p1);
+ result[p2 - p1] = '\0';
+ return result;
+}
+
+
+/*
+ * Set an option in a string of options
+ */
+
+void /* O - 0 on success, 1 on error */
+set_option_in_str(char *buf, /* I - Buffer with option list string */
+ int buflen, /* I - Length of buffer */
+ const char *option, /* I - Option to change/add */
+ const char *value) /* I - New value for option, NULL
+ removes option */
+{
+ char *p1, *p2;
+
+ if (!buf || buflen == 0 || !option)
+ return;
+ /* Remove any occurrence of option in the string */
+ p1 = buf;
+ while (*p1 != '\0' && (p2 = strcasestr(p1, option)) != NULL) {
+ if (p2 > buf && *(p2 - 1) != ' ' && *(p2 - 1) != '\t') {
+ p1 = p2 + 1;
+ continue;
+ }
+ p1 = p2 + strlen(option);
+ if (*p1 != '=' && *p1 != ' ' && *p1 != '\t' && *p1 != '\0')
+ continue;
+ while (*p1 != ' ' && *p1 != '\t' && *p1 != '\0') p1 ++;
+ while ((*p1 == ' ' || *p1 == '\t') && *p1 != '\0') p1 ++;
+ memmove(p2, p1, strlen(buf) - (buf - p1) + 1);
+ p1 = p2;
+ }
+ /* Add option=value to the end of the string */
+ if (!value)
+ return;
+ p1 = buf + strlen(buf);
+ *p1 = ' ';
+ p1 ++;
+ snprintf(p1, buflen - (buf - p1), "%s=%s", option, value);
+ buf[buflen - 1] = '\0';
+}
diff --git a/cupsfilters/pdftoippprinter.h b/cupsfilters/pdftoippprinter.h
new file mode 100644
index 000000000..a3fd14be5
--- /dev/null
+++ b/cupsfilters/pdftoippprinter.h
@@ -0,0 +1,7 @@
+#ifndef _CUPS_FILTERS_PDFTOIPPPRINTER_H
+# define _CUPS_FILTERS_PDFTOIPPPRINTER_H
+
+extern int
+apply_filters(int argc, char *argv[]);
+
+#endif
diff --git a/cupsfilters/ppdgenerator.c b/cupsfilters/ppdgenerator.c
index 934b1ce27..7aa47c7c1 100644
--- a/cupsfilters/ppdgenerator.c
+++ b/cupsfilters/ppdgenerator.c
@@ -1,8 +1,9 @@
/*
* PWG Raster/Apple Raster/PCLm/PDF/IPP legacy PPD generator
*
- * Copyright 2016 by Till Kamppeter.
- * Copyright 2017 by Sahil Arora.
+ * Copyright 2016-2019 by Till Kamppeter.
+ * Copyright 2017-2019 by Sahil Arora.
+ * Copyright 2018-2019 by Deepak Patankar.
*
* The PPD generator is based on the PPD generator for the CUPS
* "lpadmin -m everywhere" functionality in the cups/ppd-cache.c
@@ -14,17 +15,13 @@
* property of Apple Inc. and are protected by Federal copyright
* law. Distribution and use rights are outlined in the file "COPYING"
* which should have been included with this file.
- *
- * Contents:
- *
- * ppdCreateFromIPP() - Create a PPD file based on the result of an
- * get-printer-attributes IPP request
*/
#include <config.h>
#include <limits.h>
#include <cups/cups.h>
#include <cups/dir.h>
+#include <cupsfilters/ppdgenerator.h>
#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
#define HAVE_CUPS_1_6 1
#endif
@@ -81,7 +78,8 @@ typedef struct _pwg_finishings_s /**** PWG finishings mapping data ****/
#define _PWG_EQUIVALENT(x, y) (abs((x)-(y)) < 2)
static void pwg_ppdize_name(const char *ipp, char *name, size_t namesize);
-static void pwg_ppdize_resolution(ipp_attribute_t *attr, int element, int *xres, int *yres, char *name, size_t namesize);
+static void pwg_ppdize_resolution(ipp_attribute_t *attr, int element,
+ int *xres, int *yres, char *name, size_t namesize);
/*
* '_cupsSetError()' - Set the last PPD generator status-message.
@@ -224,13 +222,10 @@ _cupsStrFormatd(char *buf, /* I - String */
* Next, find the decimal point...
*/
- if (loc && loc->decimal_point)
- {
+ if (loc && loc->decimal_point) {
dec = loc->decimal_point;
declen = (int)strlen(dec);
- }
- else
- {
+ } else {
dec = ".";
declen = 1;
}
@@ -244,16 +239,14 @@ _cupsStrFormatd(char *buf, /* I - String */
* Copy everything up to the decimal point...
*/
- if (tempdec)
- {
+ if (tempdec) {
for (tempptr = temp, bufptr = buf;
tempptr < tempdec && bufptr < bufend;
*bufptr++ = *tempptr++);
tempptr += declen;
- if (*tempptr && bufptr < bufend)
- {
+ if (*tempptr && bufptr < bufend) {
*bufptr++ = '.';
while (*tempptr && bufptr < bufend)
@@ -261,9 +254,7 @@ _cupsStrFormatd(char *buf, /* I - String */
}
*bufptr = '\0';
- }
- else
- {
+ } else {
strlcpy(buf, temp, (size_t)(bufend - buf + 1));
bufptr = buf + strlen(buf);
}
@@ -280,8 +271,7 @@ int /* O - Result of comparison (-1, 0, or 1) */
_cups_strcasecmp(const char *s, /* I - First string */
const char *t) /* I - Second string */
{
- while (*s != '\0' && *t != '\0')
- {
+ while (*s != '\0' && *t != '\0') {
if (_cups_tolower(*s) < _cups_tolower(*t))
return (-1);
else if (_cups_tolower(*s) > _cups_tolower(*t))
@@ -303,13 +293,13 @@ _cups_strcasecmp(const char *s, /* I - First string */
* '_cups_strncasecmp()' - Do a case-insensitive comparison on up to N chars.
*/
-int /* O - Result of comparison (-1, 0, or 1) */
-_cups_strncasecmp(const char *s, /* I - First string */
- const char *t, /* I - Second string */
- size_t n) /* I - Maximum number of characters to compare */
+int /* O - Result of comparison (-1, 0, or 1) */
+_cups_strncasecmp(const char *s, /* I - First string */
+ const char *t, /* I - Second string */
+ size_t n) /* I - Maximum number of characters to
+ compare */
{
- while (*s != '\0' && *t != '\0' && n > 0)
- {
+ while (*s != '\0' && *t != '\0' && n > 0) {
if (_cups_tolower(*s) < _cups_tolower(*t))
return (-1);
else if (_cups_tolower(*s) > _cups_tolower(*t))
@@ -362,7 +352,8 @@ pwg_copy_size(cups_size_t *size) /* I - Media size to copy */
static int /* O - 1 on success, 0 on failure */
get_url(const char *url, /* I - URL to get */
char *name, /* I - Temporary filename */
- size_t namesize) /* I - Size of temporary filename buffer */
+ size_t namesize) /* I - Size of temporary filename
+ buffer */
{
http_t *http = NULL;
char scheme[32], /* URL scheme */
@@ -375,7 +366,9 @@ get_url(const char *url, /* I - URL to get */
int fd; /* Temporary file */
- if (httpSeparateURI(HTTP_URI_CODING_ALL, url, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, url, scheme, sizeof(scheme),
+ userpass, sizeof(userpass), host, sizeof(host), &port,
+ resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
return (0);
if (port == 443 || !strcmp(scheme, "https"))
@@ -396,8 +389,7 @@ get_url(const char *url, /* I - URL to get */
close(fd);
httpClose(http);
- if (status != HTTP_STATUS_OK)
- {
+ if (status != HTTP_STATUS_OK) {
unlink(name);
*name = '\0';
return (0);
@@ -564,13 +556,15 @@ typedef struct ipp_opt_strings_s {
int
compare_choices(void *a, void *b, void *user_data)
{
- return strcasecmp(((ipp_choice_strings_t *)a)->name, ((ipp_choice_strings_t *)b)->name);
+ return strcasecmp(((ipp_choice_strings_t *)a)->name,
+ ((ipp_choice_strings_t *)b)->name);
}
int
compare_options(void *a, void *b, void *user_data)
{
- return strcasecmp(((ipp_opt_strings_t *)a)->name, ((ipp_opt_strings_t *)b)->name);
+ return strcasecmp(((ipp_opt_strings_t *)a)->name,
+ ((ipp_opt_strings_t *)b)->name);
}
void
@@ -661,7 +655,8 @@ add_opt_to_array(char *name, char *human_readable, cups_array_t *options)
}
ipp_choice_strings_t *
-add_choice_to_array(char *name, char *human_readable, char *opt_name, cups_array_t *options)
+add_choice_to_array(char *name, char *human_readable, char *opt_name,
+ cups_array_t *options)
{
ipp_choice_strings_t *choice = NULL;
ipp_opt_strings_t *opt;
@@ -723,7 +718,7 @@ lookup_choice(char *name, char *opt_name, cups_array_t *options,
(choice = find_choice_in_array(opt->choices, name)) != NULL)
return choice->human_readable;
else if ((opt = find_opt_in_array(options, opt_name)) != NULL &&
- (choice = find_choice_in_array(opt->choices, name)) != NULL)
+ (choice = find_choice_in_array(opt->choices, name)) != NULL)
return choice->human_readable;
else
return NULL;
@@ -751,7 +746,8 @@ load_opt_strings_catalog(const char *location, cups_array_t *options)
if (location == NULL || (strncasecmp(location, "http:", 5) &&
strncasecmp(location, "https:", 6))) {
if (location == NULL ||
- (stat(location, &statbuf) == 0 && S_ISDIR(statbuf.st_mode))) /* directory? */
+ (stat(location, &statbuf) == 0 &&
+ S_ISDIR(statbuf.st_mode))) /* directory? */
filename = _findCUPSMessageCatalog(location);
else
filename = location;
@@ -939,11 +935,6 @@ load_opt_strings_catalog(const char *location, cups_array_t *options)
}
-/* Data structure for resolution (X x Y dpi) */
-typedef struct res_s {
- int x, y;
-} res_t;
-
int
compare_resolutions(void *resolution_a, void *resolution_b,
void *user_data)
@@ -1150,22 +1141,409 @@ joinResolutionArrays(cups_array_t **current, cups_array_t **new,
return retval;
}
+cups_array_t* generate_sizes(ipp_t *response,
+ ipp_attribute_t **defattr,
+ int* min_length,
+ int* min_width,
+ int* max_length,
+ int* max_width,
+ int* bottom,
+ int* left,
+ int* right,
+ int* top,
+ char* ppdname)
+{
+ cups_array_t *sizes; /* Media sizes we've added */
+ ipp_attribute_t *attr, /* xxx-supported */
+ *x_dim, *y_dim; /* Media dimensions */
+ ipp_t *media_col, /* Media collection */
+ *media_size; /* Media size collection */
+ int i,count = 0;
+ pwg_media_t *pwg; /* PWG media size */
+ int left_def,right_def,bottom_def,top_def;
+ ipp_attribute_t *margin; /* media-xxx-margin attribute */
+
+ if ((attr = ippFindAttribute(response, "media-bottom-margin-supported",
+ IPP_TAG_INTEGER)) != NULL) {
+ for (i = 1, *bottom = ippGetInteger(attr, 0), count = ippGetCount(attr);
+ i < count; i ++)
+ if (ippGetInteger(attr, i) > *bottom)
+ *bottom = ippGetInteger(attr, i);
+ } else
+ *bottom = 1270;
+
+ if ((attr = ippFindAttribute(response, "media-left-margin-supported",
+ IPP_TAG_INTEGER)) != NULL) {
+ for (i = 1, *left = ippGetInteger(attr, 0), count = ippGetCount(attr);
+ i < count; i ++)
+ if (ippGetInteger(attr, i) > *left)
+ *left = ippGetInteger(attr, i);
+ } else
+ *left = 635;
+
+ if ((attr = ippFindAttribute(response, "media-right-margin-supported",
+ IPP_TAG_INTEGER)) != NULL) {
+ for (i = 1, *right = ippGetInteger(attr, 0), count = ippGetCount(attr);
+ i < count; i ++)
+ if (ippGetInteger(attr, i) > *right)
+ *right = ippGetInteger(attr, i);
+ } else
+ *right = 635;
+
+ if ((attr = ippFindAttribute(response, "media-top-margin-supported",
+ IPP_TAG_INTEGER)) != NULL) {
+ for (i = 1, *top = ippGetInteger(attr, 0), count = ippGetCount(attr);
+ i < count; i ++)
+ if (ippGetInteger(attr, i) > *top)
+ *top = ippGetInteger(attr, i);
+ } else
+ *top = 1270;
+
+ if ((*defattr = ippFindAttribute(response, "media-col-default",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
+ if ((attr = ippFindAttribute(ippGetCollection(*defattr, 0), "media-size",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
+ media_size = ippGetCollection(attr, 0);
+ x_dim = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
+ y_dim = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
+
+ if ((margin = ippFindAttribute(ippGetCollection(*defattr, 0),
+ "media-bottom-margin", IPP_TAG_INTEGER))
+ != NULL)
+ bottom_def = ippGetInteger(margin, 0);
+ else
+ bottom_def = *bottom;
+
+ if ((margin = ippFindAttribute(ippGetCollection(*defattr, 0),
+ "media-left-margin", IPP_TAG_INTEGER))
+ != NULL)
+ left_def = ippGetInteger(margin, 0);
+ else
+ left_def = *left;
+
+ if ((margin = ippFindAttribute(ippGetCollection(*defattr, 0),
+ "media-right-margin", IPP_TAG_INTEGER))
+ != NULL)
+ right_def = ippGetInteger(margin, 0);
+ else
+ right_def = *right;
+
+ if ((margin = ippFindAttribute(ippGetCollection(*defattr, 0),
+ "media-top-margin", IPP_TAG_INTEGER))
+ != NULL)
+ top_def = ippGetInteger(margin, 0);
+ else
+ top_def = *top;
+
+ if (x_dim && y_dim &&
+ (pwg = pwgMediaForSize(ippGetInteger(x_dim, 0),
+ ippGetInteger(y_dim, 0))) != NULL) {
+ if (bottom_def == 0 && left_def == 0 && right_def == 0 && top_def == 0)
+ snprintf(ppdname, PPD_MAX_NAME, "%s.Borderless", pwg->ppd);
+ else
+ strlcpy(ppdname, pwg->ppd, PPD_MAX_NAME);
+ } else
+ strlcpy(ppdname, "Unknown", PPD_MAX_NAME);
+ } else
+ strlcpy(ppdname, "Unknown", PPD_MAX_NAME);
+ } else if ((pwg =
+ pwgMediaForPWG(ippGetString(ippFindAttribute(response,
+ "media-default",
+ IPP_TAG_ZERO), 0,
+ NULL))) != NULL)
+ strlcpy(ppdname, pwg->ppd, PPD_MAX_NAME);
+ else
+ strlcpy(ppdname, "Unknown", PPD_MAX_NAME);
+
+ sizes = cupsArrayNew3((cups_array_func_t)pwg_compare_sizes, NULL, NULL, 0,
+ (cups_acopy_func_t)pwg_copy_size,
+ (cups_afree_func_t)free);
+
+ if ((attr = ippFindAttribute(response, "media-col-database",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ cups_size_t temp; /* Current size */
+
+ media_col = ippGetCollection(attr, i);
+ media_size =
+ ippGetCollection(ippFindAttribute(media_col, "media-size",
+ IPP_TAG_BEGIN_COLLECTION), 0);
+ x_dim = ippFindAttribute(media_size, "x-dimension", IPP_TAG_ZERO);
+ y_dim = ippFindAttribute(media_size, "y-dimension", IPP_TAG_ZERO);
+ pwg = pwgMediaForSize(ippGetInteger(x_dim, 0),
+ ippGetInteger(y_dim, 0));
+
+ if (pwg) {
+ temp.width = pwg->width;
+ temp.length = pwg->length;
+
+ if ((margin = ippFindAttribute(media_col, "media-bottom-margin",
+ IPP_TAG_INTEGER)) != NULL)
+ temp.bottom = ippGetInteger(margin, 0);
+ else
+ temp.bottom = *bottom;
+
+ if ((margin = ippFindAttribute(media_col, "media-left-margin",
+ IPP_TAG_INTEGER)) != NULL)
+ temp.left = ippGetInteger(margin, 0);
+ else
+ temp.left = *left;
+
+ if ((margin = ippFindAttribute(media_col, "media-right-margin",
+ IPP_TAG_INTEGER)) != NULL)
+ temp.right = ippGetInteger(margin, 0);
+ else
+ temp.right = *right;
+
+ if ((margin = ippFindAttribute(media_col, "media-top-margin",
+ IPP_TAG_INTEGER)) != NULL)
+ temp.top = ippGetInteger(margin, 0);
+ else
+ temp.top = *top;
+
+ if (temp.bottom == 0 && temp.left == 0 && temp.right == 0 &&
+ temp.top == 0)
+ snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
+ else
+ strlcpy(temp.media, pwg->ppd, sizeof(temp.media));
+
+ if (!cupsArrayFind(sizes, &temp))
+ cupsArrayAdd(sizes, &temp);
+ } else if (ippGetValueTag(x_dim) == IPP_TAG_RANGE ||
+ ippGetValueTag(y_dim) == IPP_TAG_RANGE) {
+ /*
+ * Custom size - record the min/max values...
+ */
+
+ int lower, upper; /* Range values */
+
+ if (ippGetValueTag(x_dim) == IPP_TAG_RANGE)
+ lower = ippGetRange(x_dim, 0, &upper);
+ else
+ lower = upper = ippGetInteger(x_dim, 0);
+
+ if (lower < *min_width)
+ *min_width = lower;
+ if (upper > *max_width)
+ *max_width = upper;
+
+ if (ippGetValueTag(y_dim) == IPP_TAG_RANGE)
+ lower = ippGetRange(y_dim, 0, &upper);
+ else
+ lower = upper = ippGetInteger(y_dim, 0);
+
+ if (lower < *min_length)
+ *min_length = lower;
+ if (upper > *max_length)
+ *max_length = upper;
+ }
+ }
+ }
+ if ((attr = ippFindAttribute(response, "media-size-supported",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ cups_size_t temp; /* Current size */
+
+ media_size = ippGetCollection(attr, i);
+ x_dim = ippFindAttribute(media_size, "x-dimension", IPP_TAG_ZERO);
+ y_dim = ippFindAttribute(media_size, "y-dimension", IPP_TAG_ZERO);
+ pwg = pwgMediaForSize(ippGetInteger(x_dim, 0),
+ ippGetInteger(y_dim, 0));
+
+ if (pwg) {
+ temp.width = pwg->width;
+ temp.length = pwg->length;
+ temp.bottom = *bottom;
+ temp.left = *left;
+ temp.right = *right;
+ temp.top = *top;
+
+ if (temp.bottom == 0 && temp.left == 0 && temp.right == 0 &&
+ temp.top == 0)
+ snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
+ else
+ strlcpy(temp.media, pwg->ppd, sizeof(temp.media));
+
+ if (!cupsArrayFind(sizes, &temp))
+ cupsArrayAdd(sizes, &temp);
+ } else if (ippGetValueTag(x_dim) == IPP_TAG_RANGE ||
+ ippGetValueTag(y_dim) == IPP_TAG_RANGE) {
+ /*
+ * Custom size - record the min/max values...
+ */
+
+ int lower, upper; /* Range values */
+
+ if (ippGetValueTag(x_dim) == IPP_TAG_RANGE)
+ lower = ippGetRange(x_dim, 0, &upper);
+ else
+ lower = upper = ippGetInteger(x_dim, 0);
+
+ if (lower < *min_width)
+ *min_width = lower;
+ if (upper > *max_width)
+ *max_width = upper;
+
+ if (ippGetValueTag(y_dim) == IPP_TAG_RANGE)
+ lower = ippGetRange(y_dim, 0, &upper);
+ else
+ lower = upper = ippGetInteger(y_dim, 0);
+
+ if (lower < *min_length)
+ *min_length = lower;
+ if (upper > *max_length)
+ *max_length = upper;
+ }
+ }
+ }
+ if ((attr = ippFindAttribute(response, "media-supported", IPP_TAG_ZERO))
+ != NULL) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ const char *pwg_size = ippGetString(attr, i, NULL);
+ /* PWG size name */
+ cups_size_t temp, *temp2; /* Current size, found size */
+
+ if ((pwg = pwgMediaForPWG(pwg_size)) != NULL) {
+ if (strstr(pwg_size, "_max_") || strstr(pwg_size, "_max.")) {
+ if (pwg->width > *max_width)
+ *max_width = pwg->width;
+ if (pwg->length > *max_length)
+ *max_length = pwg->length;
+ } else if (strstr(pwg_size, "_min_") || strstr(pwg_size, "_min.")) {
+ if (pwg->width < *min_width)
+ *min_width = pwg->width;
+ if (pwg->length < *min_length)
+ *min_length = pwg->length;
+ } else {
+ temp.width = pwg->width;
+ temp.length = pwg->length;
+ temp.bottom = *bottom;
+ temp.left = *left;
+ temp.right = *right;
+ temp.top = *top;
+
+ if (temp.bottom == 0 && temp.left == 0 && temp.right == 0 &&
+ temp.top == 0)
+ snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
+ else
+ strlcpy(temp.media, pwg->ppd, sizeof(temp.media));
+
+ /* Add the printer's original IPP name to an already found size */
+ if ((temp2 = cupsArrayFind(sizes, &temp)) != NULL) {
+ snprintf(temp2->media + strlen(temp2->media),
+ sizeof(temp2->media) - strlen(temp2->media),
+ " %s", pwg_size);
+ /* Check if we have also a borderless version of the size and add
+ the original IPP name also there */
+ snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
+ if ((temp2 = cupsArrayFind(sizes, &temp)) != NULL)
+ snprintf(temp2->media + strlen(temp2->media),
+ sizeof(temp2->media) - strlen(temp2->media),
+ " %s", pwg_size);
+ } else
+ cupsArrayAdd(sizes, &temp);
+ }
+ }
+ }
+ }
+ return sizes;
+}
+
+int is_colordevice(const char *keyword,ipp_attribute_t *attr)
+{
+ if (!strcasecmp(keyword, "sgray_16") || !strncmp(keyword, "W8-16", 5) ||
+ !strncmp(keyword, "W16", 3))
+ return 1;
+ else if (!strcasecmp(keyword, "srgb_8") || !strncmp(keyword, "SRGB24", 6) ||
+ !strcmp(keyword, "color"))
+ return 1;
+ else if ((!strcasecmp(keyword, "srgb_16") ||
+ !strncmp(keyword, "SRGB48", 6)) &&
+ !ippContainsString(attr, "srgb_8"))
+ return 1;
+ else if (!strcasecmp(keyword, "adobe-rgb_16") ||
+ !strncmp(keyword, "ADOBERGB48", 10) ||
+ !strncmp(keyword, "ADOBERGB24-48", 13))
+ return 1;
+ else if ((!strcasecmp(keyword, "adobe-rgb_8") ||
+ !strcmp(keyword, "ADOBERGB24")) &&
+ !ippContainsString(attr, "adobe-rgb_16"))
+ return 1;
+ else if ((!strcasecmp(keyword, "cmyk_8") &&
+ !ippContainsString(attr, "cmyk_16")) ||
+ !strcmp(keyword, "DEVCMYK32"))
+ return 1;
+ else if (!strcasecmp(keyword, "cmyk_16") ||
+ !strcmp(keyword, "DEVCMYK32-64") ||
+ !strcmp(keyword, "DEVCMYK64"))
+ return 1;
+ else if ((!strcasecmp(keyword, "rgb_8") &&
+ !ippContainsString(attr, "rgb_16"))
+ || !strcmp(keyword, "DEVRGB24"))
+ return 1;
+ else if (!strcasecmp(keyword, "rgb_16") ||
+ !strcmp(keyword, "DEVRGB24-48") ||
+ !strcmp(keyword, "DEVRGB48"))
+ return 1;
+ return 0;
+}
+
/*
* 'ppdCreateFromIPP()' - Create a PPD file describing the capabilities
- * of an IPP printer.
+ * of an IPP printer (legacy interface).
+ */
+
+char * /* O - PPD filename or NULL on
+ error */
+ppdCreateFromIPP (char *buffer, /* I - Filename buffer */
+ size_t bufsize, /* I - Size of filename
+ buffer */
+ ipp_t *response, /* I - Get-Printer-Attributes
+ response */
+ const char *make_model, /* I - Make and model from
+ DNS-SD */
+ const char *pdl, /* I - List of PDLs from
+ DNS-SD */
+ int color, /* I - Color printer? (from
+ DNS-SD) */
+ int duplex) /* I - Duplex printer? (from
+ DNS-SD) */
+{
+ return ppdCreateFromIPP2(buffer, bufsize, response, make_model, pdl,
+ color, duplex, NULL, NULL, NULL, NULL);
+}
+
+/*
+ * 'ppdCreateFromIPP2()' - Create a PPD file describing the capabilities
+ * of an IPP printer.
*/
-char * /* O - PPD filename or NULL on error */
-ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
- size_t bufsize, /* I - Size of filename buffer */
- ipp_t *response, /* I - Get-Printer-Attributes response */
- const char *make_model,/* I - Make and model from DNS-SD */
- const char *pdl, /* I - List of PDLs from DNS-SD */
- int color, /* I - Color printer? (from DNS-SD) */
- int duplex) /* I - Duplex printer? (from DNS-SD) */
+char * /* O - PPD filename or NULL on
+ error */
+ppdCreateFromIPP2(char *buffer, /* I - Filename buffer */
+ size_t bufsize, /* I - Size of filename
+ buffer */
+ ipp_t *response, /* I - Get-Printer-Attributes
+ response */
+ const char *make_model, /* I - Make and model from
+ DNS-SD */
+ const char *pdl, /* I - List of PDLs from
+ DNS-SD */
+ int color, /* I - Color printer? (from
+ DNS-SD) */
+ int duplex, /* I - Duplex printer? (from
+ DNS-SD) */
+ cups_array_t *conflicts, /* I - Array of constraints */
+ cups_array_t *sizes, /* I - Media sizes we've
+ added */
+ char* default_pagesize, /* I - Default page size*/
+ const char *default_cluster_color) /* I - cluster def
+ color (if cluster's
+ attributes are
+ returned) */
{
cups_file_t *fp; /* PPD file */
- cups_array_t *sizes; /* Media sizes we've added */
+ cups_array_t *printer_sizes; /* Media sizes we've added */
cups_size_t *size; /* Current media size */
ipp_attribute_t *attr, /* xxx-supported */
*attr2,
@@ -1237,14 +1615,12 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
if (buffer)
*buffer = '\0';
- if (!buffer || bufsize < 1)
- {
+ if (!buffer || bufsize < 1) {
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
return (NULL);
}
- if (!response)
- {
+ if (!response) {
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("No IPP attributes."), 1);
return (NULL);
}
@@ -1253,8 +1629,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* Open a temporary file for the PPD...
*/
- if ((fp = cupsTempFile2(buffer, (int)bufsize)) == NULL)
- {
+ if ((fp = cupsTempFile2(buffer, (int)bufsize)) == NULL) {
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(errno), 0);
return (NULL);
}
@@ -1273,7 +1648,8 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePuts(fp, "*FileSystem: False\n");
cupsFilePuts(fp, "*PCFileName: \"drvless.ppd\"\n");
- if ((attr = ippFindAttribute(response, "printer-make-and-model", IPP_TAG_TEXT)) != NULL)
+ if ((attr = ippFindAttribute(response, "printer-make-and-model",
+ IPP_TAG_TEXT)) != NULL)
strlcpy(make, ippGetString(attr, 0, NULL), sizeof(make));
else if (make_model && make_model[0] != '\0')
strlcpy(make, make_model, sizeof(make));
@@ -1281,8 +1657,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
strlcpy(make, "Unknown Printer", sizeof(make));
if (!_cups_strncasecmp(make, "Hewlett Packard ", 16) ||
- !_cups_strncasecmp(make, "Hewlett-Packard ", 16))
- {
+ !_cups_strncasecmp(make, "Hewlett-Packard ", 16)) {
model = make + 16;
strlcpy(make, "HP", sizeof(make));
}
@@ -1294,50 +1669,48 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePrintf(fp, "*Manufacturer: \"%s\"\n", make);
cupsFilePrintf(fp, "*ModelName: \"%s %s\"\n", make, model);
cupsFilePrintf(fp, "*Product: \"(%s %s)\"\n", make, model);
- cupsFilePrintf(fp, "*NickName: \"%s %s, driverless, cups-filters %s\"\n", make, model,
- VERSION);
+ cupsFilePrintf(fp, "*NickName: \"%s %s, driverless, cups-filters %s\"\n",
+ make, model, VERSION);
cupsFilePrintf(fp, "*ShortNickName: \"%s %s\"\n", make, model);
/* Which is the default output bin? */
- if ((attr = ippFindAttribute(response, "output-bin-default", IPP_TAG_ZERO)) != NULL)
+ if ((attr = ippFindAttribute(response, "output-bin-default", IPP_TAG_ZERO))
+ != NULL)
defaultoutbin = strdup(ippGetString(attr, 0, NULL));
- /* Find out on which position of the list of output bins the default one is, if there
- is no default bin, take the first of this list */
+ /* Find out on which position of the list of output bins the default one is,
+ if there is no default bin, take the first of this list */
i = 0;
- if ((attr = ippFindAttribute(response, "output-bin-supported", IPP_TAG_ZERO)) != NULL)
- {
+ if ((attr = ippFindAttribute(response, "output-bin-supported",
+ IPP_TAG_ZERO)) != NULL) {
count = ippGetCount(attr);
- for (i = 0; i < count; i ++)
- {
+ for (i = 0; i < count; i ++) {
outbin = ippGetString(attr, i, NULL);
if (outbin == NULL)
continue;
- if (defaultoutbin == NULL)
- {
+ if (defaultoutbin == NULL) {
defaultoutbin = strdup(outbin);
break;
- }
- else if (strcasecmp(outbin, defaultoutbin) == 0)
+ } else if (strcasecmp(outbin, defaultoutbin) == 0)
break;
}
}
- if ((attr = ippFindAttribute(response, "printer-output-tray", IPP_TAG_STRING)) != NULL &&
- i < ippGetCount(attr))
- {
+ if ((attr = ippFindAttribute(response, "printer-output-tray",
+ IPP_TAG_STRING)) != NULL &&
+ i < ippGetCount(attr)) {
outbin_properties_octet = ippGetOctetString(attr, i, &octet_str_len);
memset(outbin_properties, 0, sizeof(outbin_properties));
memcpy(outbin_properties, outbin_properties_octet,
((size_t)octet_str_len < sizeof(outbin_properties) - 1 ?
(size_t)octet_str_len : sizeof(outbin_properties) - 1));
- if (strcasestr(outbin_properties, "pagedelivery=faceUp"))
- {
+ if (strcasestr(outbin_properties, "pagedelivery=faceUp")) {
outputorderinfofound = 1;
faceupdown = -1;
}
if (strcasestr(outbin_properties, "stackingorder=lastToFirst"))
firsttolast = -1;
}
- if (outputorderinfofound == 0 && defaultoutbin && strcasestr(defaultoutbin, "face-up"))
+ if (outputorderinfofound == 0 && defaultoutbin &&
+ strcasestr(defaultoutbin, "face-up"))
faceupdown = -1;
if (defaultoutbin)
free (defaultoutbin);
@@ -1346,31 +1719,71 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
else
cupsFilePuts(fp, "*DefaultOutputOrder: Normal\n");
- if (((attr = ippFindAttribute(response, "color-supported", IPP_TAG_BOOLEAN)) != NULL && ippGetBoolean(attr, 0)) || color)
- cupsFilePuts(fp, "*ColorDevice: True\n");
- else
- cupsFilePuts(fp, "*ColorDevice: False\n");
+ /* To decide whether the printer is coloured or not we see the various
+ colormodel supported by the printer*/
+ if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD))
+ == NULL)
+ if ((attr = ippFindAttribute(response,
+ "pwg-raster-document-type-supported",
+ IPP_TAG_KEYWORD)) == NULL)
+ if ((attr = ippFindAttribute(response, "print-color-mode-supported",
+ IPP_TAG_KEYWORD)) == NULL)
+ attr = ippFindAttribute(response, "output-mode-supported",
+ IPP_TAG_KEYWORD);
+ if (attr==NULL || !ippGetCount(attr)) {
+ if ((attr = ippFindAttribute(response, "color-supported", IPP_TAG_BOOLEAN))
+ != NULL) {
+ if(ippGetBoolean(attr, 0))
+ cupsFilePuts(fp, "*ColorDevice: True\n");
+ else
+ cupsFilePuts(fp, "*ColorDevice: False\n");
+ } else {
+ if(color)
+ cupsFilePuts(fp, "*ColorDevice: True\n");
+ else
+ cupsFilePuts(fp, "*ColorDevice: False\n");
+ }
+ } else {
+ int colordevice = 0;
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ keyword = ippGetString(attr, i, NULL);
+ colordevice = is_colordevice(keyword,attr);
+ if (colordevice) {
+ cupsFilePuts(fp, "*ColorDevice: True\n");
+ break;
+ }
+ }
+ if(colordevice==0)
+ cupsFilePuts(fp, "*ColorDevice: False\n");
+ }
- cupsFilePrintf(fp, "*cupsVersion: %d.%d\n", CUPS_VERSION_MAJOR, CUPS_VERSION_MINOR);
+ cupsFilePrintf(fp, "*cupsVersion: %d.%d\n", CUPS_VERSION_MAJOR,
+ CUPS_VERSION_MINOR);
cupsFilePuts(fp, "*cupsSNMPSupplies: False\n");
cupsFilePuts(fp, "*cupsLanguages: \"en\"\n");
- if ((attr = ippFindAttribute(response, "printer-more-info", IPP_TAG_URI)) != NULL)
+ if ((attr = ippFindAttribute(response, "printer-more-info", IPP_TAG_URI)) !=
+ NULL)
cupsFilePrintf(fp, "*APSupplies: \"%s\"\n", ippGetString(attr, 0, NULL));
- if ((attr = ippFindAttribute(response, "printer-charge-info-uri", IPP_TAG_URI)) != NULL)
- cupsFilePrintf(fp, "*cupsChargeInfoURI: \"%s\"\n", ippGetString(attr, 0, NULL));
+ if ((attr = ippFindAttribute(response, "printer-charge-info-uri",
+ IPP_TAG_URI)) != NULL)
+ cupsFilePrintf(fp, "*cupsChargeInfoURI: \"%s\"\n", ippGetString(attr, 0,
+ NULL));
/* Message catalogs for UI strings */
if (opt_strings_catalog == NULL) {
opt_strings_catalog = optArrayNew();
load_opt_strings_catalog(NULL, opt_strings_catalog);
}
- if ((attr = ippFindAttribute(response, "printer-strings-uri", IPP_TAG_URI)) != NULL) {
+ if ((attr = ippFindAttribute(response, "printer-strings-uri",
+ IPP_TAG_URI)) != NULL) {
printer_opt_strings_catalog = optArrayNew();
- load_opt_strings_catalog(ippGetString(attr, 0, NULL), printer_opt_strings_catalog);
+ load_opt_strings_catalog(ippGetString(attr, 0, NULL),
+ printer_opt_strings_catalog);
if (printer_opt_strings_catalog)
- cupsFilePrintf(fp, "*cupsStringsURI: \"%s\"\n", ippGetString(attr, 0, NULL));
+ cupsFilePrintf(fp, "*cupsStringsURI: \"%s\"\n", ippGetString(attr, 0,
+ NULL));
}
/*
@@ -1391,15 +1804,16 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
goto bad_ppd;
int formatfound = 0;
- if (((attr = ippFindAttribute(response, "document-format-supported", IPP_TAG_MIMETYPE)) != NULL) || (pdl && pdl[0] != '\0'))
- {
+ if (((attr = ippFindAttribute(response, "document-format-supported",
+ IPP_TAG_MIMETYPE)) != NULL) ||
+ (pdl && pdl[0] != '\0')) {
const char *format = pdl;
i = 0;
count = ippGetCount(attr);
while ((attr && i < count) || /* Go through formats in attribute */
- (!attr && pdl && pdl[0] != '\0' && format[0] != '\0'))
- /* Go through formats in pdl string (from DNS-SD record) */
- {
+ (!attr && pdl && pdl[0] != '\0' && format[0] != '\0')) {
+ /* Go through formats in pdl string (from DNS-SD record) */
+
/* Pick next format from attribute */
if (attr) format = ippGetString(attr, i, NULL);
/* Add format to list of supported PDLs, skip duplicates */
@@ -1449,7 +1863,9 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
is_pdf = 1;
}
if (cupsArrayFind(pdl_list, "image/pwg-raster")) {
- if ((attr = ippFindAttribute(response, "pwg-raster-document-resolution-supported", IPP_TAG_RESOLUTION)) != NULL) {
+ if ((attr = ippFindAttribute(response,
+ "pwg-raster-document-resolution-supported",
+ IPP_TAG_RESOLUTION)) != NULL) {
current_def = NULL;
if ((current_res = ippResolutionListToArray(attr)) != NULL &&
joinResolutionArrays(&common_res, &current_res, &common_def,
@@ -1463,7 +1879,8 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
}
#ifdef CUPS_RASTER_HAVE_APPLERASTER
if (cupsArrayFind(pdl_list, "image/urf")) {
- if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD)) != NULL) {
+ if ((attr = ippFindAttribute(response, "urf-supported",
+ IPP_TAG_KEYWORD)) != NULL) {
int lowdpi = 0, hidpi = 0; /* Lower and higher resolution */
for (i = 0, count = ippGetCount(attr); i < count; i ++) {
const char *rs = ippGetString(attr, i, NULL); /* RS value */
@@ -1502,8 +1919,11 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
#endif
#ifdef QPDF_HAVE_PCLM
if (cupsArrayFind(pdl_list, "application/PCLm")) {
- if ((attr = ippFindAttribute(response, "pclm-source-resolution-supported", IPP_TAG_RESOLUTION)) != NULL) {
- if ((defattr = ippFindAttribute(response, "pclm-source-resolution-default", IPP_TAG_RESOLUTION)) != NULL)
+ if ((attr = ippFindAttribute(response, "pclm-source-resolution-supported",
+ IPP_TAG_RESOLUTION)) != NULL) {
+ if ((defattr = ippFindAttribute(response,
+ "pclm-source-resolution-default",
+ IPP_TAG_RESOLUTION)) != NULL)
current_def = ippResolutionToRes(defattr, 0);
else
current_def = NULL;
@@ -1569,8 +1989,10 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
/* No resolution requirements by any of the supported PDLs?
Use "printer-resolution-supported" attribute */
if (common_res == NULL) {
- if ((attr = ippFindAttribute(response, "printer-resolution-supported", IPP_TAG_RESOLUTION)) != NULL) {
- if ((defattr = ippFindAttribute(response, "printer-resolution-default", IPP_TAG_RESOLUTION)) != NULL)
+ if ((attr = ippFindAttribute(response, "printer-resolution-supported",
+ IPP_TAG_RESOLUTION)) != NULL) {
+ if ((defattr = ippFindAttribute(response, "printer-resolution-default",
+ IPP_TAG_RESOLUTION)) != NULL)
current_def = ippResolutionToRes(defattr, 0);
else
current_def = NULL;
@@ -1590,7 +2012,8 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
}
/* No default resolution determined yet */
if (common_def == NULL) {
- if ((defattr = ippFindAttribute(response, "printer-resolution-default", IPP_TAG_RESOLUTION)) != NULL) {
+ if ((defattr = ippFindAttribute(response, "printer-resolution-default",
+ IPP_TAG_RESOLUTION)) != NULL) {
common_def = ippResolutionToRes(defattr, 0);
if (!cupsArrayFind(common_res, common_def)) {
free(common_def);
@@ -1613,29 +2036,23 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* and ppdize them one by one
*/
- if (is_pclm)
- {
+ if (is_pclm) {
attr = ippFirstAttribute(response); /* first attribute */
- while (attr) /* loop through all the attributes */
- {
- if (_cups_strncasecmp(ippGetName(attr), "pclm", 4) == 0)
- {
+ while (attr) { /* loop through all the attributes */
+ if (_cups_strncasecmp(ippGetName(attr), "pclm", 4) == 0) {
pwg_ppdize_name(ippGetName(attr), ppdname, sizeof(ppdname));
cupsFilePrintf(fp, "*cups%s: ", ppdname);
ipp_tag_t tag = ippGetValueTag(attr);
count = ippGetCount(attr);
- if (tag == IPP_TAG_RESOLUTION) /* ppdize values of type resolution */
- {
- if ((current_res = ippResolutionListToArray(attr)) != NULL)
- {
+ if (tag == IPP_TAG_RESOLUTION) { /* ppdize values of type resolution */
+ if ((current_res = ippResolutionListToArray(attr)) != NULL) {
count = cupsArrayCount(current_res);
if (count > 1)
cupsFilePuts(fp, "\"");
for (i = 0, current_def = cupsArrayFirst(current_res);
current_def;
- i ++, current_def = cupsArrayNext(current_res))
- {
+ i ++, current_def = cupsArrayNext(current_res)) {
int x = current_def->x;
int y = current_def->y;
if (x == y)
@@ -1648,13 +2065,10 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
if (count > 1)
cupsFilePuts(fp, "\"");
cupsFilePuts(fp, "\n");
- }
- else
+ } else
cupsFilePuts(fp, "\"\"\n");
cupsArrayDelete(current_res);
- }
- else
- {
+ } else {
ippAttributeString(attr, ppdname, sizeof(ppdname));
if (count > 1 || /* quotes around multi-valued and string
attributes */
@@ -1674,259 +2088,15 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
/*
* PageSize/PageRegion/ImageableArea/PaperDimension
*/
+ printer_sizes = generate_sizes(response, &defattr, &min_length, &min_width,
+ &max_length, &max_width,
+ &bottom, &left, &right, &top, ppdname);
+ if (sizes==NULL) {
+ sizes = printer_sizes;
+ } else
+ strcpy(ppdname, default_pagesize);
- if ((attr = ippFindAttribute(response, "media-bottom-margin-supported", IPP_TAG_INTEGER)) != NULL)
- {
- for (i = 1, bottom = ippGetInteger(attr, 0), count = ippGetCount(attr); i < count; i ++)
- if (ippGetInteger(attr, i) > bottom)
- bottom = ippGetInteger(attr, i);
- }
- else
- bottom = 1270;
-
- if ((attr = ippFindAttribute(response, "media-left-margin-supported", IPP_TAG_INTEGER)) != NULL)
- {
- for (i = 1, left = ippGetInteger(attr, 0), count = ippGetCount(attr); i < count; i ++)
- if (ippGetInteger(attr, i) > left)
- left = ippGetInteger(attr, i);
- }
- else
- left = 635;
-
- if ((attr = ippFindAttribute(response, "media-right-margin-supported", IPP_TAG_INTEGER)) != NULL)
- {
- for (i = 1, right = ippGetInteger(attr, 0), count = ippGetCount(attr); i < count; i ++)
- if (ippGetInteger(attr, i) > right)
- right = ippGetInteger(attr, i);
- }
- else
- right = 635;
-
- if ((attr = ippFindAttribute(response, "media-top-margin-supported", IPP_TAG_INTEGER)) != NULL)
- {
- for (i = 1, top = ippGetInteger(attr, 0), count = ippGetCount(attr); i < count; i ++)
- if (ippGetInteger(attr, i) > top)
- top = ippGetInteger(attr, i);
- }
- else
- top = 1270;
-
- if ((defattr = ippFindAttribute(response, "media-col-default", IPP_TAG_BEGIN_COLLECTION)) != NULL)
- {
- if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-size", IPP_TAG_BEGIN_COLLECTION)) != NULL)
- {
- media_size = ippGetCollection(attr, 0);
- x_dim = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
- y_dim = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
-
- if (x_dim && y_dim && (pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0))) != NULL)
- strlcpy(ppdname, pwg->ppd, sizeof(ppdname));
- else
- strlcpy(ppdname, "Unknown", sizeof(ppdname));
- }
- else
- strlcpy(ppdname, "Unknown", sizeof(ppdname));
- }
- else if ((pwg = pwgMediaForPWG(ippGetString(ippFindAttribute(response, "media-default", IPP_TAG_ZERO), 0, NULL))) != NULL)
- strlcpy(ppdname, pwg->ppd, sizeof(ppdname));
- else
- strlcpy(ppdname, "Unknown", sizeof(ppdname));
-
- sizes = cupsArrayNew3((cups_array_func_t)pwg_compare_sizes, NULL, NULL, 0, (cups_acopy_func_t)pwg_copy_size, (cups_afree_func_t)free);
-
- if ((attr = ippFindAttribute(response, "media-col-database", IPP_TAG_BEGIN_COLLECTION)) != NULL)
- {
- for (i = 0, count = ippGetCount(attr); i < count; i ++)
- {
- cups_size_t temp; /* Current size */
- ipp_attribute_t *margin; /* media-xxx-margin attribute */
-
- media_col = ippGetCollection(attr, i);
- media_size = ippGetCollection(ippFindAttribute(media_col, "media-size", IPP_TAG_BEGIN_COLLECTION), 0);
- x_dim = ippFindAttribute(media_size, "x-dimension", IPP_TAG_ZERO);
- y_dim = ippFindAttribute(media_size, "y-dimension", IPP_TAG_ZERO);
- pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0));
-
- if (pwg)
- {
- temp.width = pwg->width;
- temp.length = pwg->length;
-
- if ((margin = ippFindAttribute(media_col, "media-bottom-margin", IPP_TAG_INTEGER)) != NULL)
- temp.bottom = ippGetInteger(margin, 0);
- else
- temp.bottom = bottom;
-
- if ((margin = ippFindAttribute(media_col, "media-left-margin", IPP_TAG_INTEGER)) != NULL)
- temp.left = ippGetInteger(margin, 0);
- else
- temp.left = left;
-
- if ((margin = ippFindAttribute(media_col, "media-right-margin", IPP_TAG_INTEGER)) != NULL)
- temp.right = ippGetInteger(margin, 0);
- else
- temp.right = right;
-
- if ((margin = ippFindAttribute(media_col, "media-top-margin", IPP_TAG_INTEGER)) != NULL)
- temp.top = ippGetInteger(margin, 0);
- else
- temp.top = top;
-
- if (temp.bottom == 0 && temp.left == 0 && temp.right == 0 && temp.top == 0)
- snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
- else
- strlcpy(temp.media, pwg->ppd, sizeof(temp.media));
-
- if (!cupsArrayFind(sizes, &temp))
- cupsArrayAdd(sizes, &temp);
- }
- else if (ippGetValueTag(x_dim) == IPP_TAG_RANGE || ippGetValueTag(y_dim) == IPP_TAG_RANGE)
- {
- /*
- * Custom size - record the min/max values...
- */
-
- int lower, upper; /* Range values */
-
- if (ippGetValueTag(x_dim) == IPP_TAG_RANGE)
- lower = ippGetRange(x_dim, 0, &upper);
- else
- lower = upper = ippGetInteger(x_dim, 0);
-
- if (lower < min_width)
- min_width = lower;
- if (upper > max_width)
- max_width = upper;
-
- if (ippGetValueTag(y_dim) == IPP_TAG_RANGE)
- lower = ippGetRange(y_dim, 0, &upper);
- else
- lower = upper = ippGetInteger(y_dim, 0);
-
- if (lower < min_length)
- min_length = lower;
- if (upper > max_length)
- max_length = upper;
- }
- }
- }
- if ((attr = ippFindAttribute(response, "media-size-supported", IPP_TAG_BEGIN_COLLECTION)) != NULL)
- {
- for (i = 0, count = ippGetCount(attr); i < count; i ++)
- {
- cups_size_t temp; /* Current size */
-
- media_size = ippGetCollection(attr, i);
- x_dim = ippFindAttribute(media_size, "x-dimension", IPP_TAG_ZERO);
- y_dim = ippFindAttribute(media_size, "y-dimension", IPP_TAG_ZERO);
- pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0));
-
- if (pwg)
- {
- temp.width = pwg->width;
- temp.length = pwg->length;
- temp.bottom = bottom;
- temp.left = left;
- temp.right = right;
- temp.top = top;
-
- if (temp.bottom == 0 && temp.left == 0 && temp.right == 0 && temp.top == 0)
- snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
- else
- strlcpy(temp.media, pwg->ppd, sizeof(temp.media));
-
- if (!cupsArrayFind(sizes, &temp))
- cupsArrayAdd(sizes, &temp);
- }
- else if (ippGetValueTag(x_dim) == IPP_TAG_RANGE || ippGetValueTag(y_dim) == IPP_TAG_RANGE)
- {
- /*
- * Custom size - record the min/max values...
- */
-
- int lower, upper; /* Range values */
-
- if (ippGetValueTag(x_dim) == IPP_TAG_RANGE)
- lower = ippGetRange(x_dim, 0, &upper);
- else
- lower = upper = ippGetInteger(x_dim, 0);
-
- if (lower < min_width)
- min_width = lower;
- if (upper > max_width)
- max_width = upper;
-
- if (ippGetValueTag(y_dim) == IPP_TAG_RANGE)
- lower = ippGetRange(y_dim, 0, &upper);
- else
- lower = upper = ippGetInteger(y_dim, 0);
-
- if (lower < min_length)
- min_length = lower;
- if (upper > max_length)
- max_length = upper;
- }
- }
- }
- if ((attr = ippFindAttribute(response, "media-supported", IPP_TAG_ZERO)) != NULL)
- {
- for (i = 0, count = ippGetCount(attr); i < count; i ++)
- {
- const char *pwg_size = ippGetString(attr, i, NULL);
- /* PWG size name */
- cups_size_t temp, *temp2; /* Current size, found size */
-
- if ((pwg = pwgMediaForPWG(pwg_size)) != NULL)
- {
- if (strstr(pwg_size, "_max_") || strstr(pwg_size, "_max."))
- {
- if (pwg->width > max_width)
- max_width = pwg->width;
- if (pwg->length > max_length)
- max_length = pwg->length;
- }
- else if (strstr(pwg_size, "_min_") || strstr(pwg_size, "_min."))
- {
- if (pwg->width < min_width)
- min_width = pwg->width;
- if (pwg->length < min_length)
- min_length = pwg->length;
- }
- else
- {
- temp.width = pwg->width;
- temp.length = pwg->length;
- temp.bottom = bottom;
- temp.left = left;
- temp.right = right;
- temp.top = top;
-
- if (temp.bottom == 0 && temp.left == 0 && temp.right == 0 && temp.top == 0)
- snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
- else
- strlcpy(temp.media, pwg->ppd, sizeof(temp.media));
-
- /* Add the printer's original IPP name to an already found size */
- if ((temp2 = cupsArrayFind(sizes, &temp)) != NULL) {
- snprintf(temp2->media + strlen(temp2->media),
- sizeof(temp2->media) - strlen(temp2->media),
- " %s", pwg_size);
- /* Check if we have also a borderless version of the size and add
- the original IPP name also there */
- snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
- if ((temp2 = cupsArrayFind(sizes, &temp)) != NULL)
- snprintf(temp2->media + strlen(temp2->media),
- sizeof(temp2->media) - strlen(temp2->media),
- " %s", pwg_size);
- } else
- cupsArrayAdd(sizes, &temp);
- }
- }
- }
- }
-
- if (cupsArrayCount(sizes) > 0)
- {
+ if (cupsArrayCount(sizes) > 0) {
/*
* List all of the standard sizes...
*/
@@ -1942,10 +2112,12 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePrintf(fp, "*OpenUI *PageSize/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *PageSize\n"
"*DefaultPageSize: %s\n", "Media Size", ppdname);
- for (size = (cups_size_t *)cupsArrayFirst(sizes); size; size = (cups_size_t *)cupsArrayNext(sizes))
- {
- _cupsStrFormatd(twidth, twidth + sizeof(twidth), size->width * 72.0 / 2540.0, loc);
- _cupsStrFormatd(tlength, tlength + sizeof(tlength), size->length * 72.0 / 2540.0, loc);
+ for (size = (cups_size_t *)cupsArrayFirst(sizes); size;
+ size = (cups_size_t *)cupsArrayNext(sizes)) {
+ _cupsStrFormatd(twidth, twidth + sizeof(twidth),
+ size->width * 72.0 / 2540.0, loc);
+ _cupsStrFormatd(tlength, tlength + sizeof(tlength),
+ size->length * 72.0 / 2540.0, loc);
strlcpy(ppdsizename, size->media, sizeof(ppdsizename));
if ((ippsizename = strchr(ppdsizename, ' ')) != NULL) {
*ippsizename = '\0';
@@ -1953,17 +2125,20 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
}
if (ippsizename)
- human_readable = lookup_choice(ippsizename, "media", opt_strings_catalog,
+ human_readable = lookup_choice(ippsizename, "media",
+ opt_strings_catalog,
printer_opt_strings_catalog);
else
human_readable = NULL;
if (!human_readable) {
pwg = pwgMediaForSize(size->width, size->length);
if (pwg)
- human_readable = lookup_choice((char *)pwg->pwg, "media", opt_strings_catalog,
+ human_readable = lookup_choice((char *)pwg->pwg, "media",
+ opt_strings_catalog,
printer_opt_strings_catalog);
}
- cupsFilePrintf(fp, "*PageSize %s%s%s%s: \"<</PageSize[%s %s]>>setpagedevice\"\n", ppdsizename,
+ cupsFilePrintf(fp, "*PageSize %s%s%s%s: \"<</PageSize[%s %s]>>setpagedevice\"\n",
+ ppdsizename,
(human_readable ? "/" : ""),
(human_readable ? human_readable : ""),
(human_readable && strstr(ppdsizename, ".Borderless") ?
@@ -1975,10 +2150,12 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePrintf(fp, "*OpenUI *PageRegion/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *PageRegion\n"
"*DefaultPageRegion: %s\n", "Media Size", ppdname);
- for (size = (cups_size_t *)cupsArrayFirst(sizes); size; size = (cups_size_t *)cupsArrayNext(sizes))
- {
- _cupsStrFormatd(twidth, twidth + sizeof(twidth), size->width * 72.0 / 2540.0, loc);
- _cupsStrFormatd(tlength, tlength + sizeof(tlength), size->length * 72.0 / 2540.0, loc);
+ for (size = (cups_size_t *)cupsArrayFirst(sizes); size;
+ size = (cups_size_t *)cupsArrayNext(sizes)) {
+ _cupsStrFormatd(twidth, twidth + sizeof(twidth),
+ size->width * 72.0 / 2540.0, loc);
+ _cupsStrFormatd(tlength, tlength + sizeof(tlength),
+ size->length * 72.0 / 2540.0, loc);
strlcpy(ppdsizename, size->media, sizeof(ppdsizename));
if ((ippsizename = strchr(ppdsizename, ' ')) != NULL) {
*ippsizename = '\0';
@@ -1986,17 +2163,20 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
}
if (ippsizename)
- human_readable = lookup_choice(ippsizename, "media", opt_strings_catalog,
+ human_readable = lookup_choice(ippsizename, "media",
+ opt_strings_catalog,
printer_opt_strings_catalog);
else
human_readable = NULL;
if (!human_readable) {
pwg = pwgMediaForSize(size->width, size->length);
if (pwg)
- human_readable = lookup_choice((char *)pwg->pwg, "media", opt_strings_catalog,
+ human_readable = lookup_choice((char *)pwg->pwg, "media",
+ opt_strings_catalog,
printer_opt_strings_catalog);
}
- cupsFilePrintf(fp, "*PageRegion %s%s%s%s: \"<</PageSize[%s %s]>>setpagedevice\"\n", ppdsizename,
+ cupsFilePrintf(fp, "*PageRegion %s%s%s%s: \"<</PageSize[%s %s]>>setpagedevice\"\n",
+ ppdsizename,
(human_readable ? "/" : ""),
(human_readable ? human_readable : ""),
(human_readable && strstr(ppdsizename, ".Borderless") ?
@@ -2006,22 +2186,30 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePuts(fp, "*CloseUI: *PageRegion\n");
cupsFilePrintf(fp, "*DefaultImageableArea: %s\n"
- "*DefaultPaperDimension: %s\n", ppdname, ppdname);
-
- for (size = (cups_size_t *)cupsArrayFirst(sizes); size; size = (cups_size_t *)cupsArrayNext(sizes))
- {
- _cupsStrFormatd(tleft, tleft + sizeof(tleft), size->left * 72.0 / 2540.0, loc);
- _cupsStrFormatd(tbottom, tbottom + sizeof(tbottom), size->bottom * 72.0 / 2540.0, loc);
- _cupsStrFormatd(tright, tright + sizeof(tright), (size->width - size->right) * 72.0 / 2540.0, loc);
- _cupsStrFormatd(ttop, ttop + sizeof(ttop), (size->length - size->top) * 72.0 / 2540.0, loc);
- _cupsStrFormatd(twidth, twidth + sizeof(twidth), size->width * 72.0 / 2540.0, loc);
- _cupsStrFormatd(tlength, tlength + sizeof(tlength), size->length * 72.0 / 2540.0, loc);
+ "*DefaultPaperDimension: %s\n", ppdname, ppdname);
+
+ for (size = (cups_size_t *)cupsArrayFirst(sizes); size;
+ size = (cups_size_t *)cupsArrayNext(sizes)) {
+ _cupsStrFormatd(tleft, tleft + sizeof(tleft),
+ size->left * 72.0 / 2540.0, loc);
+ _cupsStrFormatd(tbottom, tbottom + sizeof(tbottom),
+ size->bottom * 72.0 / 2540.0, loc);
+ _cupsStrFormatd(tright, tright + sizeof(tright),
+ (size->width - size->right) * 72.0 / 2540.0, loc);
+ _cupsStrFormatd(ttop, ttop + sizeof(ttop),
+ (size->length - size->top) * 72.0 / 2540.0, loc);
+ _cupsStrFormatd(twidth, twidth + sizeof(twidth),
+ size->width * 72.0 / 2540.0, loc);
+ _cupsStrFormatd(tlength, tlength + sizeof(tlength),
+ size->length * 72.0 / 2540.0, loc);
strlcpy(ppdsizename, size->media, sizeof(ppdsizename));
if ((ippsizename = strchr(ppdsizename, ' ')) != NULL)
*ippsizename = '\0';
- cupsFilePrintf(fp, "*ImageableArea %s: \"%s %s %s %s\"\n", ppdsizename, tleft, tbottom, tright, ttop);
- cupsFilePrintf(fp, "*PaperDimension %s: \"%s %s\"\n", ppdsizename, twidth, tlength);
+ cupsFilePrintf(fp, "*ImageableArea %s: \"%s %s %s %s\"\n", ppdsizename,
+ tleft, tbottom, tright, ttop);
+ cupsFilePrintf(fp, "*PaperDimension %s: \"%s %s\"\n", ppdsizename,
+ twidth, tlength);
}
cupsArrayDelete(sizes);
@@ -2030,33 +2218,40 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* Custom size support...
*/
- if (max_width > 0 && min_width < INT_MAX && max_length > 0 && min_length < INT_MAX)
- {
+ if (max_width > 0 && min_width < INT_MAX && max_length > 0 &&
+ min_length < INT_MAX) {
char tmax[256], tmin[256]; /* Min/max values */
_cupsStrFormatd(tleft, tleft + sizeof(tleft), left * 72.0 / 2540.0, loc);
- _cupsStrFormatd(tbottom, tbottom + sizeof(tbottom), bottom * 72.0 / 2540.0, loc);
- _cupsStrFormatd(tright, tright + sizeof(tright), right * 72.0 / 2540.0, loc);
+ _cupsStrFormatd(tbottom, tbottom + sizeof(tbottom),
+ bottom * 72.0 / 2540.0, loc);
+ _cupsStrFormatd(tright, tright + sizeof(tright), right * 72.0 / 2540.0,
+ loc);
_cupsStrFormatd(ttop, ttop + sizeof(ttop), top * 72.0 / 2540.0, loc);
- cupsFilePrintf(fp, "*HWMargins: \"%s %s %s %s\"\n", tleft, tbottom, tright, ttop);
+ cupsFilePrintf(fp, "*HWMargins: \"%s %s %s %s\"\n", tleft, tbottom,
+ tright, ttop);
- _cupsStrFormatd(tmax, tmax + sizeof(tmax), max_width * 72.0 / 2540.0, loc);
- _cupsStrFormatd(tmin, tmin + sizeof(tmin), min_width * 72.0 / 2540.0, loc);
- cupsFilePrintf(fp, "*ParamCustomPageSize Width: 1 points %s %s\n", tmin, tmax);
+ _cupsStrFormatd(tmax, tmax + sizeof(tmax), max_width * 72.0 / 2540.0,
+ loc);
+ _cupsStrFormatd(tmin, tmin + sizeof(tmin), min_width * 72.0 / 2540.0,
+ loc);
+ cupsFilePrintf(fp, "*ParamCustomPageSize Width: 1 points %s %s\n", tmin,
+ tmax);
- _cupsStrFormatd(tmax, tmax + sizeof(tmax), max_length * 72.0 / 2540.0, loc);
- _cupsStrFormatd(tmin, tmin + sizeof(tmin), min_length * 72.0 / 2540.0, loc);
- cupsFilePrintf(fp, "*ParamCustomPageSize Height: 2 points %s %s\n", tmin, tmax);
+ _cupsStrFormatd(tmax, tmax + sizeof(tmax), max_length * 72.0 / 2540.0,
+ loc);
+ _cupsStrFormatd(tmin, tmin + sizeof(tmin), min_length * 72.0 / 2540.0,
+ loc);
+ cupsFilePrintf(fp, "*ParamCustomPageSize Height: 2 points %s %s\n", tmin,
+ tmax);
cupsFilePuts(fp, "*ParamCustomPageSize WidthOffset: 3 points 0 0\n");
cupsFilePuts(fp, "*ParamCustomPageSize HeightOffset: 4 points 0 0\n");
cupsFilePuts(fp, "*ParamCustomPageSize Orientation: 5 int 0 3\n");
cupsFilePuts(fp, "*CustomPageSize True: \"pop pop pop <</PageSize[5 -2 roll]/ImagingBBox null>>setpagedevice\"\n");
}
- }
- else
- {
+ } else {
cupsArrayDelete(sizes);
cupsFilePrintf(fp,
"*%% Printer did not supply page size info via IPP, using defaults\n"
@@ -2128,13 +2323,15 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* InputSlot...
*/
- if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-source", IPP_TAG_KEYWORD)) != NULL)
+ if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-source",
+ IPP_TAG_KEYWORD)) != NULL)
pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
else
strlcpy(ppdname, "Unknown", sizeof(ppdname));
- if ((attr = ippFindAttribute(response, "media-source-supported", IPP_TAG_KEYWORD)) != NULL && (count = ippGetCount(attr)) > 1)
- {
+ if ((attr = ippFindAttribute(response, "media-source-supported",
+ IPP_TAG_KEYWORD)) != NULL &&
+ (count = ippGetCount(attr)) > 1) {
static const char * const sources[][2] =
{ /* "media-source" strings */
{ "Auto", _("Automatic") },
@@ -2192,17 +2389,17 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
human_readable = lookup_option("media-source", opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *InputSlot/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *InputSlot\n"
- "*DefaultInputSlot: %s\n",
- (human_readable ? human_readable : "Media Source"),
- ppdname);
- for (i = 0, count = ippGetCount(attr); i < count; i ++)
- {
+ "*OrderDependency: 10 AnySetup *InputSlot\n"
+ "*DefaultInputSlot: %s\n",
+ (human_readable ? human_readable : "Media Source"),
+ ppdname);
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
keyword = ippGetString(attr, i, NULL);
pwg_ppdize_name(keyword, ppdname, sizeof(ppdname));
- human_readable = lookup_choice((char *)keyword, "media-source", opt_strings_catalog,
+ human_readable = lookup_choice((char *)keyword, "media-source",
+ opt_strings_catalog,
printer_opt_strings_catalog);
for (j = (int)(sizeof(sources) / sizeof(sources[0])) - 1; j >= 0; j --)
if (!strcmp(sources[j][0], ppdname)) {
@@ -2226,13 +2423,15 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* MediaType...
*/
- if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-type", IPP_TAG_KEYWORD)) != NULL)
+ if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-type",
+ IPP_TAG_KEYWORD)) != NULL)
pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
else
strlcpy(ppdname, "Unknown", sizeof(ppdname));
- if ((attr = ippFindAttribute(response, "media-type-supported", IPP_TAG_KEYWORD)) != NULL && (count = ippGetCount(attr)) > 1)
- {
+ if ((attr = ippFindAttribute(response, "media-type-supported",
+ IPP_TAG_KEYWORD)) != NULL &&
+ (count = ippGetCount(attr)) > 1) {
static const char * const media_types[][2] =
{ /* "media-type" strings */
{ "aluminum", _("Aluminum") },
@@ -2380,20 +2579,21 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
human_readable = lookup_option("media-type", opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *MediaType/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *MediaType\n"
- "*DefaultMediaType: %s\n",
- (human_readable ? human_readable : "Media Type"),
- ppdname);
- for (i = 0; i < count; i ++)
- {
+ "*OrderDependency: 10 AnySetup *MediaType\n"
+ "*DefaultMediaType: %s\n",
+ (human_readable ? human_readable : "Media Type"),
+ ppdname);
+ for (i = 0; i < count; i ++) {
keyword = ippGetString(attr, i, NULL);
pwg_ppdize_name(keyword, ppdname, sizeof(ppdname));
- human_readable = lookup_choice((char *)keyword, "media-type", opt_strings_catalog,
+ human_readable = lookup_choice((char *)keyword, "media-type",
+ opt_strings_catalog,
printer_opt_strings_catalog);
if (human_readable == NULL)
- for (j = 0; j < (int)(sizeof(media_types) / sizeof(media_types[0])); j ++)
+ for (j = 0; j < (int)(sizeof(media_types) / sizeof(media_types[0]));
+ j ++)
if (!strcmp(media_types[j][0], keyword)) {
human_readable = (char *)_cupsLangString(lang, media_types[j][1]);
break;
@@ -2411,236 +2611,247 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* ColorModel...
*/
- if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD)) == NULL)
- if ((attr = ippFindAttribute(response, "pwg-raster-document-type-supported", IPP_TAG_KEYWORD)) == NULL)
- if ((attr = ippFindAttribute(response, "print-color-mode-supported", IPP_TAG_KEYWORD)) == NULL)
- attr = ippFindAttribute(response, "output-mode-supported", IPP_TAG_KEYWORD);
+ if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD)) ==
+ NULL)
+ if ((attr = ippFindAttribute(response, "pwg-raster-document-type-supported",
+ IPP_TAG_KEYWORD)) == NULL)
+ if ((attr = ippFindAttribute(response, "print-color-mode-supported",
+ IPP_TAG_KEYWORD)) == NULL)
+ attr = ippFindAttribute(response, "output-mode-supported",
+ IPP_TAG_KEYWORD);
human_readable = lookup_option("print-color-mode", opt_strings_catalog,
printer_opt_strings_catalog);
- if (attr && ippGetCount(attr) > 0)
- {
+ if (attr && ippGetCount(attr) > 0) {
const char *default_color = NULL; /* Default */
int first_choice = 1,
- have_bi_level = 0,
- have_mono = 0;
+ have_bi_level = 0,
+ have_mono = 0;
- for (i = 0, count = ippGetCount(attr); i < count; i ++)
- {
- keyword = ippGetString(attr, i, NULL);
- /* Keyword for color/bit depth */
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ keyword = ippGetString(attr, i, NULL); /* Keyword for color/bit depth */
if (!have_bi_level &&
- (!strcasecmp(keyword, "black_1") || !strcmp(keyword, "bi-level") || !strcmp(keyword, "process-bi-level")))
- {
+ (!strcasecmp(keyword, "black_1") || !strcmp(keyword, "bi-level") ||
+ !strcmp(keyword, "process-bi-level"))) {
have_bi_level = 1;
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
- human_readable2 = lookup_choice("bi-level", "print-color-mode", opt_strings_catalog,
+ human_readable2 = lookup_choice("bi-level", "print-color-mode",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*ColorModel FastGray/%s: \"<</cupsColorSpace 3/cupsBitsPerColor 1/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- (human_readable2 ? human_readable2 :
- _cupsLangString(lang, _("Fast Grayscale"))));
+ (human_readable2 ? human_readable2 :
+ _cupsLangString(lang, _("Fast Grayscale"))));
if (!default_color)
default_color = "FastGray";
- }
- else if (!have_mono &&
- (!strcasecmp(keyword, "sgray_8") || !strncmp(keyword, "W8", 2) || !strcmp(keyword, "monochrome") || !strcmp(keyword, "process-monochrome")))
- {
+ } else if (!have_mono &&
+ (!strcasecmp(keyword, "sgray_8") ||
+ !strncmp(keyword, "W8", 2) ||
+ !strcmp(keyword, "monochrome") ||
+ !strcmp(keyword, "process-monochrome"))) {
have_mono = 1;
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
- human_readable2 = lookup_choice("monochrome", "print-color-mode", opt_strings_catalog,
+ human_readable2 = lookup_choice("monochrome", "print-color-mode",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*ColorModel Gray/%s: \"<</cupsColorSpace 18/cupsBitsPerColor 8/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- (human_readable2 ? human_readable2 :
- _cupsLangString(lang, _("Grayscale"))));
+ (human_readable2 ? human_readable2 :
+ _cupsLangString(lang, _("Grayscale"))));
if (!default_color || !strcmp(default_color, "FastGray"))
default_color = "Gray";
- }
- else if (!strcasecmp(keyword, "sgray_16") || !strncmp(keyword, "W8-16", 5) || !strncmp(keyword, "W16", 3))
- {
+ } else if (!strcasecmp(keyword, "sgray_16") ||
+ !strncmp(keyword, "W8-16", 5) ||
+ !strncmp(keyword, "W16", 3)) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
cupsFilePrintf(fp, "*ColorModel Gray16/%s: \"<</cupsColorSpace 18/cupsBitsPerColor 16/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- _cupsLangString(lang, _("Deep Gray (High Definition Grayscale)")));
+ _cupsLangString(lang, _("Deep Gray (High Definition Grayscale)")));
if (!default_color || !strcmp(default_color, "FastGray"))
default_color = "Gray16";
- }
- else if (!strcasecmp(keyword, "srgb_8") || !strncmp(keyword, "SRGB24", 6) || !strcmp(keyword, "color"))
- {
+ } else if (!strcasecmp(keyword, "srgb_8") ||
+ !strncmp(keyword, "SRGB24", 6) ||
+ !strcmp(keyword, "color")) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
- human_readable2 = lookup_choice("color", "print-color-mode", opt_strings_catalog,
+ human_readable2 = lookup_choice("color", "print-color-mode",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*ColorModel RGB/%s: \"<</cupsColorSpace 19/cupsBitsPerColor 8/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- (human_readable2 ? human_readable2 :
- _cupsLangString(lang, _("Color"))));
+ (human_readable2 ? human_readable2 :
+ _cupsLangString(lang, _("Color"))));
default_color = "RGB";
- }
- else if ((!strcasecmp(keyword, "srgb_16") || !strncmp(keyword, "SRGB48", 6)) &&
- !ippContainsString(attr, "srgb_8"))
- {
+ } else if ((!strcasecmp(keyword, "srgb_16") ||
+ !strncmp(keyword, "SRGB48", 6)) &&
+ !ippContainsString(attr, "srgb_8")) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
- human_readable2 = lookup_choice("color", "print-color-mode", opt_strings_catalog,
+ human_readable2 = lookup_choice("color", "print-color-mode",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*ColorModel RGB/%s: \"<</cupsColorSpace 19/cupsBitsPerColor 16/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- (human_readable2 ? human_readable2 :
- _cupsLangString(lang, _("Color"))));
+ (human_readable2 ? human_readable2 :
+ _cupsLangString(lang, _("Color"))));
default_color = "RGB";
- }
- else if (!strcasecmp(keyword, "adobe-rgb_16") || !strncmp(keyword, "ADOBERGB48", 10) ||
- !strncmp(keyword, "ADOBERGB24-48", 13))
- {
+ } else if (!strcasecmp(keyword, "adobe-rgb_16") ||
+ !strncmp(keyword, "ADOBERGB48", 10) ||
+ !strncmp(keyword, "ADOBERGB24-48", 13)) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
cupsFilePrintf(fp, "*ColorModel AdobeRGB/%s: \"<</cupsColorSpace 20/cupsBitsPerColor 16/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- _cupsLangString(lang, _("Deep Color (Wide Color Gamut, AdobeRGB)")));
+ _cupsLangString(lang, _("Deep Color (Wide Color Gamut, AdobeRGB)")));
if (!default_color)
default_color = "AdobeRGB";
- }
- else if ((!strcasecmp(keyword, "adobe-rgb_8") || !strcmp(keyword, "ADOBERGB24")) &&
- !ippContainsString(attr, "adobe-rgb_16"))
- {
+ } else if ((!strcasecmp(keyword, "adobe-rgb_8") ||
+ !strcmp(keyword, "ADOBERGB24")) &&
+ !ippContainsString(attr, "adobe-rgb_16")) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
cupsFilePrintf(fp, "*ColorModel AdobeRGB/%s: \"<</cupsColorSpace 20/cupsBitsPerColor 8/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- _cupsLangString(lang, _("Deep Color (Wide Color Gamut, AdobeRGB)")));
+ _cupsLangString(lang, _("Deep Color (Wide Color Gamut, AdobeRGB)")));
if (!default_color)
default_color = "AdobeRGB";
- }
- else if ((!strcasecmp(keyword, "black_8") && !ippContainsString(attr, "black_16")) || !strcmp(keyword, "DEVW8"))
- {
+ } else if ((!strcasecmp(keyword, "black_8") &&
+ !ippContainsString(attr, "black_16")) ||
+ !strcmp(keyword, "DEVW8")) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
cupsFilePrintf(fp, "*ColorModel DeviceGray/%s: \"<</cupsColorSpace 0/cupsBitsPerColor 8/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- _cupsLangString(lang, _("Device Gray")));
- }
- else if (!strcasecmp(keyword, "black_16") || !strcmp(keyword, "DEVW16") || !strcmp(keyword, "DEVW8-16"))
- {
+ _cupsLangString(lang, _("Device Gray")));
+ } else if (!strcasecmp(keyword, "black_16") ||
+ !strcmp(keyword, "DEVW16") ||
+ !strcmp(keyword, "DEVW8-16")) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
cupsFilePrintf(fp, "*ColorModel DeviceGray/%s: \"<</cupsColorSpace 0/cupsBitsPerColor 16/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- _cupsLangString(lang, _("Device Gray")));
- }
- else if ((!strcasecmp(keyword, "cmyk_8") && !ippContainsString(attr, "cmyk_16")) || !strcmp(keyword, "DEVCMYK32"))
- {
+ _cupsLangString(lang, _("Device Gray")));
+ } else if ((!strcasecmp(keyword, "cmyk_8") &&
+ !ippContainsString(attr, "cmyk_16")) ||
+ !strcmp(keyword, "DEVCMYK32")) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
cupsFilePrintf(fp, "*ColorModel CMYK/%s: \"<</cupsColorSpace 6/cupsBitsPerColor 8/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- _cupsLangString(lang, _("Device CMYK")));
- }
- else if (!strcasecmp(keyword, "cmyk_16") || !strcmp(keyword, "DEVCMYK32-64") || !strcmp(keyword, "DEVCMYK64"))
- {
+ _cupsLangString(lang, _("Device CMYK")));
+ } else if (!strcasecmp(keyword, "cmyk_16") ||
+ !strcmp(keyword, "DEVCMYK32-64") ||
+ !strcmp(keyword, "DEVCMYK64")) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
cupsFilePrintf(fp, "*ColorModel CMYK/%s: \"<</cupsColorSpace 6/cupsBitsPerColor 16/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- _cupsLangString(lang, _("Device CMYK")));
- }
- else if ((!strcasecmp(keyword, "rgb_8") && !ippContainsString(attr, "rgb_16")) || !strcmp(keyword, "DEVRGB24"))
- {
+ _cupsLangString(lang, _("Device CMYK")));
+ } else if ((!strcasecmp(keyword, "rgb_8") &&
+ !ippContainsString(attr, "rgb_16")) ||
+ !strcmp(keyword, "DEVRGB24")) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
cupsFilePrintf(fp, "*ColorModel DeviceRGB/%s: \"<</cupsColorSpace 1/cupsBitsPerColor 8/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- _cupsLangString(lang, _("Device RGB")));
- }
- else if (!strcasecmp(keyword, "rgb_16") || !strcmp(keyword, "DEVRGB24-48") || !strcmp(keyword, "DEVRGB48"))
- {
+ _cupsLangString(lang, _("Device RGB")));
+ } else if (!strcasecmp(keyword, "rgb_16") ||
+ !strcmp(keyword, "DEVRGB24-48") ||
+ !strcmp(keyword, "DEVRGB48")) {
if (first_choice) {
first_choice = 0;
cupsFilePrintf(fp, "*OpenUI *ColorModel/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *ColorModel\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Color Mode"))));
+ "*OrderDependency: 10 AnySetup *ColorModel\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Color Mode"))));
}
cupsFilePrintf(fp, "*ColorModel DeviceRGB/%s: \"<</cupsColorSpace 1/cupsBitsPerColor 16/cupsColorOrder 0/cupsCompression 0>>setpagedevice\"\n",
- _cupsLangString(lang, _("Device RGB")));
+ _cupsLangString(lang, _("Device RGB")));
}
}
- if (default_color)
- {
+ if (default_pagesize != NULL) {
+ /* Here we are dealing with a cluster, if the default cluster color
+ is not supplied we set it Gray*/
+ if (default_cluster_color != NULL) {
+ default_color = default_cluster_color;
+ } else
+ default_color = "Gray";
+ }
+
+ if (default_color) {
cupsFilePrintf(fp, "*DefaultColorModel: %s\n", default_color);
cupsFilePuts(fp, "*CloseUI: *ColorModel\n");
}
@@ -2666,36 +2877,36 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
if (((attr = ippFindAttribute(response, "sides-supported",
IPP_TAG_KEYWORD)) != NULL &&
ippContainsString(attr, "two-sided-long-edge")) ||
- (attr == NULL && duplex))
- {
+ (attr == NULL && duplex)) {
human_readable = lookup_option("sides", opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *Duplex/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *Duplex\n"
- "*DefaultDuplex: None\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("2-Sided Printing"))));
+ "*OrderDependency: 10 AnySetup *Duplex\n"
+ "*DefaultDuplex: None\n",
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("2-Sided Printing"))));
human_readable = lookup_choice("one-sided", "sides", opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*Duplex None/%s: \"<</Duplex false>>setpagedevice\"\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Off (1-Sided)"))));
- human_readable = lookup_choice("two-sided-long-edge", "sides", opt_strings_catalog,
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Off (1-Sided)"))));
+ human_readable = lookup_choice("two-sided-long-edge", "sides",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*Duplex DuplexNoTumble/%s: \"<</Duplex true/Tumble false>>setpagedevice\"\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Long-Edge (Portrait)"))));
- human_readable = lookup_choice("two-sided-short-edge", "sides", opt_strings_catalog,
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Long-Edge (Portrait)"))));
+ human_readable = lookup_choice("two-sided-short-edge", "sides",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*Duplex DuplexTumble/%s: \"<</Duplex true/Tumble true>>setpagedevice\"\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Short-Edge (Landscape)"))));
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Short-Edge (Landscape)"))));
cupsFilePrintf(fp, "*CloseUI: *Duplex\n");
- if ((attr = ippFindAttribute(response, "pwg-raster-document-sheet-back", IPP_TAG_KEYWORD)) != NULL)
- {
- keyword = ippGetString(attr, 0, NULL);
- /* Keyword value */
+ if ((attr = ippFindAttribute(response, "pwg-raster-document-sheet-back",
+ IPP_TAG_KEYWORD)) != NULL) {
+ keyword = ippGetString(attr, 0, NULL); /* Keyword value */
if (!strcmp(keyword, "flipped"))
cupsFilePuts(fp, "*cupsBackSide: Flipped\n");
@@ -2705,31 +2916,21 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePuts(fp, "*cupsBackSide: Normal\n");
else
cupsFilePuts(fp, "*cupsBackSide: Rotated\n");
- }
- else if ((attr = ippFindAttribute(response, "urf-supported", IPP_TAG_KEYWORD)) != NULL)
- {
- for (i = 0, count = ippGetCount(attr); i < count; i ++)
- {
- const char *dm = ippGetString(attr, i, NULL);
- /* DM value */
-
- if (!_cups_strcasecmp(dm, "DM1"))
- {
+ } else if ((attr = ippFindAttribute(response, "urf-supported",
+ IPP_TAG_KEYWORD)) != NULL) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ const char *dm = ippGetString(attr, i, NULL); /* DM value */
+
+ if (!_cups_strcasecmp(dm, "DM1")) {
cupsFilePuts(fp, "*cupsBackSide: Normal\n");
break;
- }
- else if (!_cups_strcasecmp(dm, "DM2"))
- {
+ } else if (!_cups_strcasecmp(dm, "DM2")) {
cupsFilePuts(fp, "*cupsBackSide: Flipped\n");
break;
- }
- else if (!_cups_strcasecmp(dm, "DM3"))
- {
+ } else if (!_cups_strcasecmp(dm, "DM3")) {
cupsFilePuts(fp, "*cupsBackSide: Rotated\n");
break;
- }
- else if (!_cups_strcasecmp(dm, "DM4"))
- {
+ } else if (!_cups_strcasecmp(dm, "DM4")) {
cupsFilePuts(fp, "*cupsBackSide: ManualTumble\n");
break;
}
@@ -2741,13 +2942,15 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* Output bin...
*/
- if ((attr = ippFindAttribute(response, "output-bin-default", IPP_TAG_ZERO)) != NULL)
+ if ((attr = ippFindAttribute(response, "output-bin-default",
+ IPP_TAG_ZERO)) != NULL)
pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
else
strlcpy(ppdname, "Unknown", sizeof(ppdname));
- if ((attr = ippFindAttribute(response, "output-bin-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1)
- {
+ if ((attr = ippFindAttribute(response, "output-bin-supported",
+ IPP_TAG_ZERO)) != NULL &&
+ (count = ippGetCount(attr)) > 1) {
static const char * const output_bins[][2] =
{ /* "output-bin" strings */
{ "auto", _("Automatic") },
@@ -2798,21 +3001,22 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
human_readable = lookup_option("output-bin", opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *OutputBin/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *OutputBin\n"
- "*DefaultOutputBin: %s\n",
- (human_readable ? human_readable : "Output Bin"),
- ppdname);
+ "*OrderDependency: 10 AnySetup *OutputBin\n"
+ "*DefaultOutputBin: %s\n",
+ (human_readable ? human_readable : "Output Bin"),
+ ppdname);
attr2 = ippFindAttribute(response, "printer-output-tray", IPP_TAG_STRING);
- for (i = 0; i < count; i ++)
- {
+ for (i = 0; i < count; i ++) {
keyword = ippGetString(attr, i, NULL);
pwg_ppdize_name(keyword, ppdname, sizeof(ppdname));
- human_readable = lookup_choice((char *)keyword, "output-bin", opt_strings_catalog,
+ human_readable = lookup_choice((char *)keyword, "output-bin",
+ opt_strings_catalog,
printer_opt_strings_catalog);
if (human_readable == NULL)
- for (j = 0; j < (int)(sizeof(output_bins) / sizeof(output_bins[0])); j ++)
+ for (j = 0; j < (int)(sizeof(output_bins) / sizeof(output_bins[0]));
+ j ++)
if (!strcmp(output_bins[j][0], keyword)) {
human_readable = (char *)_cupsLangString(lang, output_bins[j][1]);
break;
@@ -2824,43 +3028,33 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
outputorderinfofound = 0;
faceupdown = 1;
firsttolast = 1;
- if (attr2 && i < ippGetCount(attr2))
- {
+ if (attr2 && i < ippGetCount(attr2)) {
outbin_properties_octet = ippGetOctetString(attr2, i, &octet_str_len);
memset(outbin_properties, 0, sizeof(outbin_properties));
memcpy(outbin_properties, outbin_properties_octet,
((size_t)octet_str_len < sizeof(outbin_properties) - 1 ?
(size_t)octet_str_len : sizeof(outbin_properties) - 1));
- if (strcasestr(outbin_properties, "pagedelivery=faceUp"))
- {
+ if (strcasestr(outbin_properties, "pagedelivery=faceUp")) {
outputorderinfofound = 1;
faceupdown = -1;
- }
- else if (strcasestr(outbin_properties, "pagedelivery=faceDown"))
- {
+ } else if (strcasestr(outbin_properties, "pagedelivery=faceDown")) {
outputorderinfofound = 1;
faceupdown = 1;
}
- if (strcasestr(outbin_properties, "stackingorder=lastToFirst"))
- {
+ if (strcasestr(outbin_properties, "stackingorder=lastToFirst")) {
outputorderinfofound = 1;
firsttolast = -1;
- }
- else if (strcasestr(outbin_properties, "stackingorder=firstToLast"))
- {
+ } else if (strcasestr(outbin_properties, "stackingorder=firstToLast")) {
outputorderinfofound = 1;
firsttolast = 1;
}
}
- if (outputorderinfofound == 0)
- {
- if (strcasestr(keyword, "face-up"))
- {
+ if (outputorderinfofound == 0) {
+ if (strcasestr(keyword, "face-up")) {
outputorderinfofound = 1;
faceupdown = -1;
}
- if (strcasestr(keyword, "face-down"))
- {
+ if (strcasestr(keyword, "face-down")) {
outputorderinfofound = 1;
faceupdown = 1;
}
@@ -2882,8 +3076,8 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* punching, etc.)
*/
- if ((attr = ippFindAttribute(response, "finishings-supported", IPP_TAG_ENUM)) != NULL)
- {
+ if ((attr = ippFindAttribute(response, "finishings-supported",
+ IPP_TAG_ENUM)) != NULL) {
const char *name; /* String name */
int value; /* Enum value */
cups_array_t *names; /* Names we've added */
@@ -2957,61 +3151,65 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
};
count = ippGetCount(attr);
- names = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+ names = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
fin_options = cupsArrayNew((cups_array_func_t)strcmp, NULL);
/*
* Staple/Bind/Stitch
*/
- for (i = 0; i < count; i ++)
- {
+ for (i = 0; i < count; i ++) {
value = ippGetInteger(attr, i);
name = ippEnumString("finishings", value);
- if (!strncmp(name, "staple-", 7) || !strncmp(name, "bind-", 5) || !strncmp(name, "edge-stitch-", 12) || !strcmp(name, "saddle-stitch"))
+ if (!strncmp(name, "staple-", 7) || !strncmp(name, "bind-", 5) ||
+ !strncmp(name, "edge-stitch-", 12) || !strcmp(name, "saddle-stitch"))
break;
}
- if (i < count)
- {
+ if (i < count) {
cupsArrayAdd(fin_options, "*StapleLocation");
- human_readable = lookup_choice("staple", "finishing-template", opt_strings_catalog,
+ human_readable = lookup_choice("staple", "finishing-template",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *StapleLocation/%s: PickOne\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Staple"))));
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Staple"))));
cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *StapleLocation\n");
cupsFilePuts(fp, "*DefaultStapleLocation: None\n");
- cupsFilePrintf(fp, "*StapleLocation None/%s: \"\"\n", _cupsLangString(lang, _("None")));
+ cupsFilePrintf(fp, "*StapleLocation None/%s: \"\"\n",
+ _cupsLangString(lang, _("None")));
- for (; i < count; i ++)
- {
+ for (; i < count; i ++) {
value = ippGetInteger(attr, i);
name = ippEnumString("finishings", value);
snprintf(buf, sizeof(buf), "%d", value);
- if (strncmp(name, "staple-", 7) && strncmp(name, "bind-", 5) && strncmp(name, "edge-stitch-", 12) && strcmp(name, "saddle-stitch"))
+ if (strncmp(name, "staple-", 7) && strncmp(name, "bind-", 5) &&
+ strncmp(name, "edge-stitch-", 12) && strcmp(name, "saddle-stitch"))
continue;
if (cupsArrayFind(names, (char *)name))
- continue; /* Already did this finishing template */
+ continue; /* Already did this finishing template */
cupsArrayAdd(names, (char *)name);
human_readable = lookup_choice(buf, "finishings", opt_strings_catalog,
printer_opt_strings_catalog);
if (human_readable == NULL)
- for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0])); j ++)
+ for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0]));
+ j ++)
if (!strcmp(finishings[j][0], name)) {
human_readable = (char *)_cupsLangString(lang, finishings[j][1]);
break;
}
cupsFilePrintf(fp, "*StapleLocation %s%s%s: \"\"\n", name,
- (human_readable ? "/" : ""),
- (human_readable ? human_readable : ""));
- cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*StapleLocation %s\"\n", value, name, name);
+ (human_readable ? "/" : ""),
+ (human_readable ? human_readable : ""));
+ cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*StapleLocation %s\"\n",
+ value, name, name);
}
cupsFilePuts(fp, "*CloseUI: *StapleLocation\n");
@@ -3021,8 +3219,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* Fold
*/
- for (i = 0; i < count; i ++)
- {
+ for (i = 0; i < count; i ++) {
value = ippGetInteger(attr, i);
name = ippEnumString("finishings", value);
@@ -3030,21 +3227,21 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
break;
}
- if (i < count)
- {
+ if (i < count) {
cupsArrayAdd(fin_options, "*FoldType");
- human_readable = lookup_choice("fold", "finishing-template", opt_strings_catalog,
+ human_readable = lookup_choice("fold", "finishing-template",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *FoldType/%s: PickOne\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Fold"))));
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Fold"))));
cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *FoldType\n");
cupsFilePuts(fp, "*DefaultFoldType: None\n");
- cupsFilePrintf(fp, "*FoldType None/%s: \"\"\n", _cupsLangString(lang, _("None")));
+ cupsFilePrintf(fp, "*FoldType None/%s: \"\"\n",
+ _cupsLangString(lang, _("None")));
- for (; i < count; i ++)
- {
+ for (; i < count; i ++) {
value = ippGetInteger(attr, i);
name = ippEnumString("finishings", value);
snprintf(buf, sizeof(buf), "%d", value);
@@ -3053,22 +3250,24 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
continue;
if (cupsArrayFind(names, (char *)name))
- continue; /* Already did this finishing template */
+ continue; /* Already did this finishing template */
cupsArrayAdd(names, (char *)name);
human_readable = lookup_choice(buf, "finishings", opt_strings_catalog,
printer_opt_strings_catalog);
if (human_readable == NULL)
- for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0])); j ++)
+ for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0]));
+ j ++)
if (!strcmp(finishings[j][0], name)) {
human_readable = (char *)_cupsLangString(lang, finishings[j][1]);
break;
}
cupsFilePrintf(fp, "*FoldType %s%s%s: \"\"\n", name,
- (human_readable ? "/" : ""),
- (human_readable ? human_readable : ""));
- cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*FoldType %s\"\n", value, name, name);
+ (human_readable ? "/" : ""),
+ (human_readable ? human_readable : ""));
+ cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*FoldType %s\"\n",
+ value, name, name);
}
cupsFilePuts(fp, "*CloseUI: *FoldType\n");
@@ -3078,8 +3277,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* Punch
*/
- for (i = 0; i < count; i ++)
- {
+ for (i = 0; i < count; i ++) {
value = ippGetInteger(attr, i);
name = ippEnumString("finishings", value);
@@ -3087,21 +3285,21 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
break;
}
- if (i < count)
- {
+ if (i < count) {
cupsArrayAdd(fin_options, "*PunchMedia");
- human_readable = lookup_choice("punch", "finishing-template", opt_strings_catalog,
+ human_readable = lookup_choice("punch", "finishing-template",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *PunchMedia/%s: PickOne\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Punch"))));
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Punch"))));
cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *PunchMedia\n");
cupsFilePuts(fp, "*DefaultPunchMedia: None\n");
- cupsFilePrintf(fp, "*PunchMedia None/%s: \"\"\n", _cupsLangString(lang, _("None")));
+ cupsFilePrintf(fp, "*PunchMedia None/%s: \"\"\n",
+ _cupsLangString(lang, _("None")));
- for (; i < count; i ++)
- {
+ for (; i < count; i ++) {
value = ippGetInteger(attr, i);
name = ippEnumString("finishings", value);
snprintf(buf, sizeof(buf), "%d", value);
@@ -3110,22 +3308,24 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
continue;
if (cupsArrayFind(names, (char *)name))
- continue; /* Already did this finishing template */
+ continue; /* Already did this finishing template */
cupsArrayAdd(names, (char *)name);
human_readable = lookup_choice(buf, "finishings", opt_strings_catalog,
printer_opt_strings_catalog);
if (human_readable == NULL)
- for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0])); j ++)
+ for (j = 0; j < (int)(sizeof(finishings) / sizeof(finishings[0]));
+ j ++)
if (!strcmp(finishings[j][0], name)) {
human_readable = (char *)_cupsLangString(lang, finishings[j][1]);
break;
}
cupsFilePrintf(fp, "*PunchMedia %s%s%s: \"\"\n", name,
- (human_readable ? "/" : ""),
- (human_readable ? human_readable : ""));
- cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*PunchMedia %s\"\n", value, name, name);
+ (human_readable ? "/" : ""),
+ (human_readable ? human_readable : ""));
+ cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*PunchMedia %s\"\n",
+ value, name, name);
}
cupsFilePuts(fp, "*CloseUI: *PunchMedia\n");
@@ -3135,64 +3335,72 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* Booklet
*/
- if (ippContainsInteger(attr, IPP_FINISHINGS_BOOKLET_MAKER))
- {
+ if (ippContainsInteger(attr, IPP_FINISHINGS_BOOKLET_MAKER)) {
cupsArrayAdd(fin_options, "*Booklet");
- human_readable = lookup_choice("booklet-maker", "finishing-template", opt_strings_catalog,
+ human_readable = lookup_choice("booklet-maker", "finishing-template",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *Booklet/%s: Boolean\n",
- (human_readable ? human_readable :
- _cupsLangString(lang, _("Booklet"))));
+ (human_readable ? human_readable :
+ _cupsLangString(lang, _("Booklet"))));
cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *Booklet\n");
cupsFilePuts(fp, "*DefaultBooklet: False\n");
cupsFilePuts(fp, "*Booklet False: \"\"\n");
cupsFilePuts(fp, "*Booklet True: \"\"\n");
- cupsFilePrintf(fp, "*cupsIPPFinishings %d/booklet-maker: \"*Booklet True\"\n", IPP_FINISHINGS_BOOKLET_MAKER);
+ cupsFilePrintf(fp, "*cupsIPPFinishings %d/booklet-maker: \"*Booklet True\"\n",
+ IPP_FINISHINGS_BOOKLET_MAKER);
cupsFilePuts(fp, "*CloseUI: *Booklet\n");
}
cupsArrayDelete(names);
}
- if ((attr = ippFindAttribute(response, "finishings-col-database", IPP_TAG_BEGIN_COLLECTION)) != NULL)
- {
+ if ((attr = ippFindAttribute(response, "finishings-col-database",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
ipp_t *finishing_col; /* Current finishing collection */
ipp_attribute_t *finishing_attr; /* Current finishing member attribute */
cups_array_t *templates; /* Finishing templates */
- cupsFilePrintf(fp, "*OpenUI *cupsFinishingTemplate/%s: PickOne\n", _cupsLangString(lang, _("Finishing Preset")));
+ cupsFilePrintf(fp, "*OpenUI *cupsFinishingTemplate/%s: PickOne\n",
+ _cupsLangString(lang, _("Finishing Preset")));
cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *cupsFinishingTemplate\n");
cupsFilePuts(fp, "*DefaultcupsFinishingTemplate: none\n");
- cupsFilePrintf(fp, "*cupsFinishingTemplate none/%s: \"\"\n", _cupsLangString(lang, _("None")));
+ cupsFilePrintf(fp, "*cupsFinishingTemplate none/%s: \"\"\n",
+ _cupsLangString(lang, _("None")));
templates = cupsArrayNew((cups_array_func_t)strcmp, NULL);
count = ippGetCount(attr);
- for (i = 0; i < count; i ++)
- {
+ for (i = 0; i < count; i ++) {
finishing_col = ippGetCollection(attr, i);
- keyword = ippGetString(ippFindAttribute(finishing_col, "finishing-template", IPP_TAG_ZERO), 0, NULL);
+ keyword = ippGetString(ippFindAttribute(finishing_col,
+ "finishing-template",
+ IPP_TAG_ZERO), 0, NULL);
if (!keyword || cupsArrayFind(templates, (void *)keyword))
continue;
- if (strncmp(keyword, "fold-", 5) && (strstr(keyword, "-bottom") || strstr(keyword, "-left") || strstr(keyword, "-right") || strstr(keyword, "-top")))
+ if (strncmp(keyword, "fold-", 5) && (strstr(keyword, "-bottom") ||
+ strstr(keyword, "-left") ||
+ strstr(keyword, "-right") ||
+ strstr(keyword, "-top")))
continue;
cupsArrayAdd(templates, (void *)keyword);
- human_readable = lookup_choice((char *)keyword, "finishing-template", opt_strings_catalog,
+ human_readable = lookup_choice((char *)keyword, "finishing-template",
+ opt_strings_catalog,
printer_opt_strings_catalog);
if (human_readable == NULL)
human_readable = (char *)keyword;
- cupsFilePrintf(fp, "*cupsFinishingTemplate %s/%s: \"\n", keyword, human_readable);
- for (finishing_attr = ippFirstAttribute(finishing_col); finishing_attr; finishing_attr = ippNextAttribute(finishing_col))
- {
- if (ippGetValueTag(finishing_attr) == IPP_TAG_BEGIN_COLLECTION)
- {
- const char *name = ippGetName(finishing_attr);
- /* Member attribute name */
+ cupsFilePrintf(fp, "*cupsFinishingTemplate %s/%s: \"\n", keyword,
+ human_readable);
+ for (finishing_attr = ippFirstAttribute(finishing_col); finishing_attr;
+ finishing_attr = ippNextAttribute(finishing_col)) {
+ if (ippGetValueTag(finishing_attr) == IPP_TAG_BEGIN_COLLECTION) {
+ const char *name = ippGetName(finishing_attr); /* Member attribute
+ name */
if (strcmp(name, "media-size"))
cupsFilePrintf(fp, "%s\n", name);
@@ -3204,17 +3412,18 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePuts(fp, "*CloseUI: *cupsFinishingTemplate\n");
- if (cupsArrayCount(fin_options))
- {
+ if (cupsArrayCount(fin_options)) {
const char *fin_option; /* Current finishing option */
cupsFilePuts(fp, "*cupsUIConstraint finishing-template: \"*cupsFinishingTemplate");
- for (fin_option = (const char *)cupsArrayFirst(fin_options); fin_option; fin_option = (const char *)cupsArrayNext(fin_options))
+ for (fin_option = (const char *)cupsArrayFirst(fin_options); fin_option;
+ fin_option = (const char *)cupsArrayNext(fin_options))
cupsFilePrintf(fp, " %s", fin_option);
cupsFilePuts(fp, "\"\n");
cupsFilePuts(fp, "*cupsUIResolver finishing-template: \"*cupsFinishingTemplate None");
- for (fin_option = (const char *)cupsArrayFirst(fin_options); fin_option; fin_option = (const char *)cupsArrayNext(fin_options))
+ for (fin_option = (const char *)cupsArrayFirst(fin_options); fin_option;
+ fin_option = (const char *)cupsArrayNext(fin_options))
cupsFilePrintf(fp, " %s None", fin_option);
cupsFilePuts(fp, "\"\n");
}
@@ -3241,13 +3450,12 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
if ((quality =
ippFindAttribute(response, "print-quality-supported",
- IPP_TAG_ENUM)) != NULL)
- {
+ IPP_TAG_ENUM)) != NULL) {
human_readable = lookup_option("print-quality", opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *cupsPrintQuality/%s: PickOne\n"
- "*OrderDependency: 10 AnySetup *cupsPrintQuality\n"
- "*DefaultcupsPrintQuality: %d\n",
+ "*OrderDependency: 10 AnySetup *cupsPrintQuality\n"
+ "*DefaultcupsPrintQuality: %d\n",
(human_readable ? human_readable :
_cupsLangString(lang, _("Print Quality"))),
IPP_QUALITY_NORMAL);
@@ -3288,12 +3496,15 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* Print Optimization ...
*/
- if ((attr = ippFindAttribute(response, "print-content-optimize-default", IPP_TAG_ZERO)) != NULL)
+ if ((attr = ippFindAttribute(response, "print-content-optimize-default",
+ IPP_TAG_ZERO)) != NULL)
strlcpy(ppdname, ippGetString(attr, 0, NULL), sizeof(ppdname));
else
strlcpy(ppdname, "auto", sizeof(ppdname));
- if ((attr = ippFindAttribute(response, "print-content-optimize-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1) {
+ if ((attr = ippFindAttribute(response, "print-content-optimize-supported",
+ IPP_TAG_ZERO)) != NULL &&
+ (count = ippGetCount(attr)) > 1) {
static const char * const content_optimize_types[][2] =
{ /* "print-content-optimize" strings */
{ "auto", _("Automatic") },
@@ -3305,7 +3516,8 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
{ "text-and-graphics", _("Text And Graphics") }
};
- human_readable = lookup_option("print-content-optimize", opt_strings_catalog,
+ human_readable = lookup_option("print-content-optimize",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *print-content-optimize/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *print-content-optimize\n"
@@ -3315,12 +3527,19 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
for (i = 0; i < count; i ++) {
keyword = ippGetString(attr, i, NULL);
- human_readable = lookup_choice((char *)keyword, "print-content-optimize", opt_strings_catalog,
+ human_readable = lookup_choice((char *)keyword,
+ "print-content-optimize",
+ opt_strings_catalog,
printer_opt_strings_catalog);
if (human_readable == NULL)
- for (j = 0; j < (int)(sizeof(content_optimize_types) / sizeof(content_optimize_types[0])); j ++)
+ for (j = 0;
+ j < (int)(sizeof(content_optimize_types) /
+ sizeof(content_optimize_types[0]));
+ j ++)
if (!strcmp(content_optimize_types[j][0], keyword)) {
- human_readable = (char *)_cupsLangString(lang, content_optimize_types[j][1]);
+ human_readable =
+ (char *)_cupsLangString(lang,
+ content_optimize_types[j][1]);
break;
}
cupsFilePrintf(fp, "*print-content-optimize %s%s%s: \"\"\n",
@@ -3335,12 +3554,15 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* Print Rendering Intent ...
*/
- if ((attr = ippFindAttribute(response, "print-rendering-intent-default", IPP_TAG_ZERO)) != NULL)
+ if ((attr = ippFindAttribute(response, "print-rendering-intent-default",
+ IPP_TAG_ZERO)) != NULL)
strlcpy(ppdname, ippGetString(attr, 0, NULL), sizeof(ppdname));
else
strlcpy(ppdname, "auto", sizeof(ppdname));
- if ((attr = ippFindAttribute(response, "print-rendering-intent-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1) {
+ if ((attr = ippFindAttribute(response, "print-rendering-intent-supported",
+ IPP_TAG_ZERO)) != NULL &&
+ (count = ippGetCount(attr)) > 1) {
static const char * const rendering_intents[][2] =
{ /* "print-rendering-intent" strings */
{ "auto", _("Automatic") },
@@ -3351,22 +3573,31 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
{ "saturation", _("Saturation") }
};
- human_readable = lookup_option("print-rendering-intent", opt_strings_catalog,
+ human_readable = lookup_option("print-rendering-intent",
+ opt_strings_catalog,
printer_opt_strings_catalog);
cupsFilePrintf(fp, "*OpenUI *print-rendering-intent/%s: PickOne\n"
"*OrderDependency: 10 AnySetup *print-rendering-intent\n"
"*Defaultprint-rendering-intent: %s\n",
- (human_readable ? human_readable : "Print Rendering Intent"),
+ (human_readable ? human_readable :
+ "Print Rendering Intent"),
ppdname);
for (i = 0; i < count; i ++) {
keyword = ippGetString(attr, i, NULL);
- human_readable = lookup_choice((char *)keyword, "print-rendering-intent", opt_strings_catalog,
+ human_readable = lookup_choice((char *)keyword,
+ "print-rendering-intent",
+ opt_strings_catalog,
printer_opt_strings_catalog);
if (human_readable == NULL)
- for (j = 0; j < (int)(sizeof(rendering_intents) / sizeof(rendering_intents[0])); j ++)
+ for (j = 0;
+ j < (int)(sizeof(rendering_intents) /
+ sizeof(rendering_intents[0]));
+ j ++)
if (!strcmp(rendering_intents[j][0], keyword)) {
- human_readable = (char *)_cupsLangString(lang, rendering_intents[j][1]);
+ human_readable =
+ (char *)_cupsLangString(lang,
+ rendering_intents[j][1]);
break;
}
cupsFilePrintf(fp, "*print-rendering-intent %s%s%s: \"\"\n",
@@ -3376,16 +3607,20 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
}
cupsFilePuts(fp, "*CloseUI: *print-rendering-intent\n");
}
+
/*
* Print Scaling ...
*/
- if ((attr = ippFindAttribute(response, "print-scaling-default", IPP_TAG_ZERO)) != NULL)
+ if ((attr = ippFindAttribute(response, "print-scaling-default",
+ IPP_TAG_ZERO)) != NULL)
strlcpy(ppdname, ippGetString(attr, 0, NULL), sizeof(ppdname));
else
strlcpy(ppdname, "auto", sizeof(ppdname));
- if ((attr = ippFindAttribute(response, "print-scaling-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1) {
+ if ((attr = ippFindAttribute(response, "print-scaling-supported",
+ IPP_TAG_ZERO)) != NULL &&
+ (count = ippGetCount(attr)) > 1) {
static const char * const scaling_types[][2] =
{ /* "print-scaling" strings */
{ "auto", _("Automatic") },
@@ -3405,12 +3640,17 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
for (i = 0; i < count; i ++) {
keyword = ippGetString(attr, i, NULL);
- human_readable = lookup_choice((char *)keyword, "print-scaling", opt_strings_catalog,
+ human_readable = lookup_choice((char *)keyword, "print-scaling",
+ opt_strings_catalog,
printer_opt_strings_catalog);
if (human_readable == NULL)
- for (j = 0; j < (int)(sizeof(scaling_types) / sizeof(scaling_types[0])); j ++)
+ for (j = 0;
+ j < (int)(sizeof(scaling_types) /
+ sizeof(scaling_types[0]));
+ j ++)
if (!strcmp(scaling_types[j][0], keyword)) {
- human_readable = (char *)_cupsLangString(lang, scaling_types[j][1]);
+ human_readable =
+ (char *)_cupsLangString(lang, scaling_types[j][1]);
break;
}
cupsFilePrintf(fp, "*print-scaling %s%s%s: \"\"\n",
@@ -3426,45 +3666,43 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* Presets...
*/
- if ((attr = ippFindAttribute(response, "job-presets-supported", IPP_TAG_BEGIN_COLLECTION)) != NULL)
- {
- for (i = 0, count = ippGetCount(attr); i < count; i ++)
- {
- ipp_t *preset = ippGetCollection(attr, i);
- /* Preset collection */
- const char *preset_name = ippGetString(ippFindAttribute(preset, "preset-name", IPP_TAG_ZERO), 0, NULL),
- /* Preset name */
- *localized_name; /* Localized preset name */
+ if ((attr = ippFindAttribute(response, "job-presets-supported",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ ipp_t *preset = ippGetCollection(attr, i); /* Preset collection */
+ const char *preset_name = /* Preset name */
+ ippGetString(ippFindAttribute(preset,
+ "preset-name", IPP_TAG_ZERO), 0, NULL),
+ *localized_name; /* Localized preset name */
ipp_attribute_t *member; /* Member attribute in preset */
const char *member_name; /* Member attribute name */
- char member_value[256]; /* Member attribute value */
+ char member_value[256]; /* Member attribute value */
if (!preset || !preset_name)
continue;
- if ((localized_name = lookup_option((char *)preset_name, opt_strings_catalog,
+ if ((localized_name = lookup_option((char *)preset_name,
+ opt_strings_catalog,
printer_opt_strings_catalog)) == NULL)
cupsFilePrintf(fp, "*APPrinterPreset %s: \"\n", preset_name);
else
- cupsFilePrintf(fp, "*APPrinterPreset %s/%s: \"\n", preset_name, localized_name);
+ cupsFilePrintf(fp, "*APPrinterPreset %s/%s: \"\n", preset_name,
+ localized_name);
- for (member = ippFirstAttribute(preset); member; member = ippNextAttribute(preset))
- {
+ for (member = ippFirstAttribute(preset); member;
+ member = ippNextAttribute(preset)) {
member_name = ippGetName(member);
if (!member_name || !strcmp(member_name, "preset-name"))
continue;
- if (!strcmp(member_name, "finishings"))
- {
- for (i = 0, count = ippGetCount(member); i < count; i ++)
- {
+ if (!strcmp(member_name, "finishings")) {
+ for (i = 0, count = ippGetCount(member); i < count; i ++) {
const char *option = NULL; /* PPD option name */
keyword = ippEnumString("finishings", ippGetInteger(member, i));
- if (!strcmp(keyword, "booklet-maker"))
- {
+ if (!strcmp(keyword, "booklet-maker")) {
option = "Booklet";
keyword = "True";
}
@@ -3472,60 +3710,68 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
option = "FoldType";
else if (!strncmp(keyword, "punch-", 6))
option = "PunchMedia";
- else if (!strncmp(keyword, "bind-", 5) || !strncmp(keyword, "edge-stitch-", 12) || !strcmp(keyword, "saddle-stitch") || !strncmp(keyword, "staple-", 7))
+ else if (!strncmp(keyword, "bind-", 5) ||
+ !strncmp(keyword, "edge-stitch-", 12) ||
+ !strcmp(keyword, "saddle-stitch") ||
+ !strncmp(keyword, "staple-", 7))
option = "StapleLocation";
if (option && keyword)
cupsFilePrintf(fp, "*%s %s\n", option, keyword);
}
- }
- else if (!strcmp(member_name, "finishings-col"))
- {
+ } else if (!strcmp(member_name, "finishings-col")) {
ipp_t *fin_col; /* finishings-col value */
- for (i = 0, count = ippGetCount(member); i < count; i ++)
- {
+ for (i = 0, count = ippGetCount(member); i < count; i ++) {
fin_col = ippGetCollection(member, i);
- if ((keyword = ippGetString(ippFindAttribute(fin_col, "finishing-template", IPP_TAG_ZERO), 0, NULL)) != NULL)
+ if ((keyword =
+ ippGetString(ippFindAttribute(fin_col,
+ "finishing-template",
+ IPP_TAG_ZERO), 0, NULL)) != NULL)
cupsFilePrintf(fp, "*cupsFinishingTemplate %s\n", keyword);
}
- }
- else if (!strcmp(member_name, "media"))
- {
+ } else if (!strcmp(member_name, "media")) {
/*
* Map media to PageSize...
*/
- if ((pwg = pwgMediaForPWG(ippGetString(member, 0, NULL))) != NULL && pwg->ppd)
+ if ((pwg = pwgMediaForPWG(ippGetString(member, 0, NULL))) != NULL &&
+ pwg->ppd)
cupsFilePrintf(fp, "*PageSize %s\n", pwg->ppd);
- }
- else if (!strcmp(member_name, "media-col"))
- {
+ } else if (!strcmp(member_name, "media-col")) {
media_col = ippGetCollection(member, 0);
- if ((media_size = ippGetCollection(ippFindAttribute(media_col, "media-size", IPP_TAG_BEGIN_COLLECTION), 0)) != NULL)
- {
- x_dim = ippFindAttribute(media_size, "x-dimension", IPP_TAG_INTEGER);
- y_dim = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
- if ((pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0))) != NULL && pwg->ppd)
+ if ((media_size =
+ ippGetCollection(ippFindAttribute(media_col,
+ "media-size",
+ IPP_TAG_BEGIN_COLLECTION),
+ 0)) != NULL) {
+ x_dim = ippFindAttribute(media_size, "x-dimension",
+ IPP_TAG_INTEGER);
+ y_dim = ippFindAttribute(media_size, "y-dimension",
+ IPP_TAG_INTEGER);
+ if ((pwg = pwgMediaForSize(ippGetInteger(x_dim, 0),
+ ippGetInteger(y_dim, 0))) != NULL &&
+ pwg->ppd)
cupsFilePrintf(fp, "*PageSize %s\n", pwg->ppd);
}
- if ((keyword = ippGetString(ippFindAttribute(media_col, "media-source", IPP_TAG_ZERO), 0, NULL)) != NULL)
- {
+ if ((keyword = ippGetString(ippFindAttribute(media_col,
+ "media-source",
+ IPP_TAG_ZERO), 0,
+ NULL)) != NULL) {
pwg_ppdize_name(keyword, ppdname, sizeof(ppdname));
cupsFilePrintf(fp, "*InputSlot %s\n", keyword);
}
- if ((keyword = ippGetString(ippFindAttribute(media_col, "media-type", IPP_TAG_ZERO), 0, NULL)) != NULL)
- {
+ if ((keyword = ippGetString(ippFindAttribute(media_col, "media-type",
+ IPP_TAG_ZERO), 0,
+ NULL)) != NULL) {
pwg_ppdize_name(keyword, ppdname, sizeof(ppdname));
cupsFilePrintf(fp, "*MediaType %s\n", keyword);
}
- }
- else if (!strcmp(member_name, "print-quality"))
- {
+ } else if (!strcmp(member_name, "print-quality")) {
/*
* Map print-quality to cupsPrintQuality...
*/
@@ -3536,15 +3782,13 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
/* cupsPrintQuality values */
if (qval >= IPP_QUALITY_DRAFT && qval <= IPP_QUALITY_HIGH)
- cupsFilePrintf(fp, "*cupsPrintQuality %s\n", qualities[qval - IPP_QUALITY_DRAFT]);
- }
- else if (!strcmp(member_name, "output-bin"))
- {
- pwg_ppdize_name(ippGetString(member, 0, NULL), ppdname, sizeof(ppdname));
+ cupsFilePrintf(fp, "*cupsPrintQuality %s\n",
+ qualities[qval - IPP_QUALITY_DRAFT]);
+ } else if (!strcmp(member_name, "output-bin")) {
+ pwg_ppdize_name(ippGetString(member, 0, NULL), ppdname,
+ sizeof(ppdname));
cupsFilePrintf(fp, "*OutputBin %s\n", ppdname);
- }
- else if (!strcmp(member_name, "sides"))
- {
+ } else if (!strcmp(member_name, "sides")) {
keyword = ippGetString(member, 0, NULL);
if (keyword && !strcmp(keyword, "one-sided"))
cupsFilePuts(fp, "*Duplex None\n");
@@ -3552,9 +3796,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
cupsFilePuts(fp, "*Duplex DuplexNoTumble\n");
else if (keyword && !strcmp(keyword, "two-sided-short-edge"))
cupsFilePuts(fp, "*Duplex DuplexTumble\n");
- }
- else
- {
+ } else {
/*
* Add attribute name and value as-is...
*/
@@ -3569,6 +3811,17 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
}
/*
+ * constraints
+ */
+ if(conflicts != NULL) {
+ char* constraint;
+ for (constraint = (char *)cupsArrayFirst(conflicts); constraint;
+ constraint = (char *)cupsArrayNext(conflicts)) {
+ cupsFilePrintf(fp,"%s",constraint);
+ }
+ }
+
+ /*
* Close up and return...
*/
@@ -3594,7 +3847,7 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
* If we get here then there was a problem creating the PPD...
*/
- bad_ppd:
+ bad_ppd:
if (common_res) cupsArrayDelete(common_res);
if (common_def) free(common_def);
@@ -3607,7 +3860,9 @@ ppdCreateFromIPP(char *buffer, /* I - Filename buffer */
unlink(buffer);
*buffer = '\0';
- _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Printer does not support required IPP attributes or document formats."), 1);
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL,
+ _("Printer does not support required IPP attributes or document formats."),
+ 1);
return (NULL);
}
@@ -3734,8 +3989,7 @@ _pwgPageSizeForMedia(
* Copy or generate a PageSize name...
*/
- if (media->ppd)
- {
+ if (media->ppd) {
/*
* Use a standard Adobe name...
*/
@@ -3745,17 +3999,14 @@ _pwgPageSizeForMedia(
else if (!media->pwg || !strncmp(media->pwg, "custom_", 7) ||
(sizeptr = strchr(media->pwg, '_')) == NULL ||
(dimptr = strchr(sizeptr + 1, '_')) == NULL ||
- (size_t)(dimptr - sizeptr) > namesize)
- {
+ (size_t)(dimptr - sizeptr) > namesize) {
/*
* Use a name of the form "wNNNhNNN"...
*/
snprintf(name, namesize, "w%dh%d", (int)PWG_TO_POINTS(media->width),
(int)PWG_TO_POINTS(media->length));
- }
- else
- {
+ } else {
/*
* Copy the size name from class_sizename_dimensions...
*/
@@ -3783,14 +4034,11 @@ pwg_ppdize_name(const char *ipp, /* I - IPP keyword */
*name = (char)toupper(*ipp++);
- for (ptr = name + 1, end = name + namesize - 1; *ipp && ptr < end;)
- {
- if (*ipp == '-' && _cups_isalpha(ipp[1]))
- {
+ for (ptr = name + 1, end = name + namesize - 1; *ipp && ptr < end;) {
+ if (*ipp == '-' && _cups_isalpha(ipp[1])) {
ipp ++;
*ptr++ = (char)toupper(*ipp++ & 255);
- }
- else
+ } else
*ptr++ = *ipp++;
}
@@ -3814,17 +4062,14 @@ pwg_ppdize_resolution(
{
ipp_res_t units; /* Units for resolution */
-
*xres = ippGetResolution(attr, element, yres, &units);
- if (units == IPP_RES_PER_CM)
- {
+ if (units == IPP_RES_PER_CM) {
*xres = (int)(*xres * 2.54);
*yres = (int)(*yres * 2.54);
}
- if (name && namesize > 4)
- {
+ if (name && namesize > 4) {
if (*xres == *yres)
snprintf(name, namesize, "%ddpi", *xres);
else
@@ -3832,7 +4077,3 @@ pwg_ppdize_resolution(
}
}
#endif /* HAVE_CUPS_1_6 */
-
-/*
- * End
- */
diff --git a/cupsfilters/ppdgenerator.h b/cupsfilters/ppdgenerator.h
index 4bf642e2e..5e03e6d1b 100644
--- a/cupsfilters/ppdgenerator.h
+++ b/cupsfilters/ppdgenerator.h
@@ -55,9 +55,35 @@ extern "C" {
extern char ppdgenerator_msg[1024];
+/* Data structure for resolution (X x Y dpi) */
+typedef struct res_s {
+ int x, y;
+} res_t;
+
char *ppdCreateFromIPP(char *buffer, size_t bufsize,
ipp_t *response, const char *make_model,
const char *pdl, int color, int duplex);
+char *ppdCreateFromIPP2(char *buffer, size_t bufsize,
+ ipp_t *response, const char *make_model,
+ const char *pdl, int color, int duplex,
+ cups_array_t* conflicts,
+ cups_array_t *sizes,char* default_pagesize,
+ const char *default_cluster_color);
+int compare_resolutions(void *resolution_a, void *resolution_b,
+ void *user_data);
+res_t * ippResolutionToRes(ipp_attribute_t *attr, int index);
+cups_array_t * resolutionArrayNew();
+cups_array_t* generate_sizes(ipp_t *response,
+ ipp_attribute_t **defattr,
+ int *min_length,
+ int* min_width,
+ int* max_length,
+ int* max_width,
+ int* bottom,
+ int* left,
+ int* right,
+ int* top,
+ char* ppdname);
#endif /* HAVE_CUPS_1_6 */
# ifdef __cplusplus
@@ -65,8 +91,3 @@ char *ppdCreateFromIPP(char *buffer, size_t bufsize,
# endif /* __cplusplus */
#endif /* !_CUPS_FILTERS_PPDGENERATOR_H_ */
-
-/*
- * End
- */
-
diff --git a/cupsfilters/raster.c b/cupsfilters/raster.c
index 2670a0cf6..73fa868e8 100644
--- a/cupsfilters/raster.c
+++ b/cupsfilters/raster.c
@@ -786,6 +786,13 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */
colorspace = 6;
numcolors = 4;
}
+ else if (!strncasecmp(val, "Cmy", 3))
+ {
+ if (*(val + 3) == '_' || *(val + 3) == '-')
+ ptr = val + 4;
+ colorspace = 4;
+ numcolors = 3;
+ }
else if (!strncasecmp(val, "Device", 6))
{
ptr = val + 6;
@@ -815,6 +822,13 @@ cupsRasterParseIPPOptions(cups_page_header2_t *h, /* I - Raster header */
colorspace = 19;
numcolors = 3;
}
+ else if (!strncasecmp(val, "Rgbw", 4))
+ {
+ if (*(val + 4) == '_' || *(val + 4) == '-')
+ ptr = val + 5;
+ colorspace = 17;
+ numcolors = 4;
+ }
else if (!strncasecmp(val, "Rgb", 3))
{
if (*(val + 3) == '_' || *(val + 3) == '-')
diff --git a/debian/.git-dpm b/debian/.git-dpm
index b512e5597..3bba89730 100644
--- a/debian/.git-dpm
+++ b/debian/.git-dpm
@@ -1,8 +1,8 @@
# see git-dpm(1) from git-dpm package
-ac421831bde36d391900eba263cb6215eacb4927
-ac421831bde36d391900eba263cb6215eacb4927
-ec41f03b4dc5def5a6d53ea1dbb856f4b1bba169
-ec41f03b4dc5def5a6d53ea1dbb856f4b1bba169
-cups-filters_1.21.6.orig.tar.xz
-b50b613ef20d14cef8d184ecef15030ce17fdfa2
-1474944
+f898bd47af3228196fc4b41f6d276a44be5a4048
+f898bd47af3228196fc4b41f6d276a44be5a4048
+f898bd47af3228196fc4b41f6d276a44be5a4048
+f898bd47af3228196fc4b41f6d276a44be5a4048
+cups-filters_1.25.0.orig.tar.xz
+0b711c4977bd6e8d370c7d11b719661b6d990df0
+1447496
diff --git a/debian/changelog b/debian/changelog
index f01be6c07..45416bbf0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,71 @@
+cups-filters (1.25.0-1) experimental; urgency=medium
+
+ * New upstream version 1.25.0
+ - Refresh d/copyright with CF1.0-compatible upstream COPYING
+ - Remove now-unneeded libpoppler-private-dev from B-D
+
+ -- Didier Raboud <odyx@debian.org> Sat, 08 Jun 2019 08:57:32 +0200
+
+cups-filters (1.24.0-1) experimental; urgency=medium
+
+ * New upstream version 1.24.0
+ - Add 4 new symbols to libcupsfilters1
+
+ -- Didier Raboud <odyx@debian.org> Wed, 05 Jun 2019 08:10:31 +0200
+
+cups-filters (1.23.0-1) experimental; urgency=medium
+
+ * New upstream version 1.23.0
+ - cups-browsed: When removing a local queue on shutdown or
+ when DNS-SD reports the printer as disappeared check whether
+ the local queue got overwritten by an external process as
+ sometimes the shutdown or disappearing event comes too close
+ for cups-browsed receiving a printer-modified notification
+ from CUPS before (LP: #1731417)
+
+ -- Didier Raboud <odyx@debian.org> Fri, 17 May 2019 10:01:20 +0200
+
+cups-filters (1.22.5-1) experimental; urgency=medium
+
+ * New upstream version 1.22.5
+ - foomatic-rip: Changed Ghostscript call to count pages in a PDF file to
+ use "runpdfbegin" and not the undocumented Ghostscript internal
+ "pdfdict", so that it works with Ghostscript ≥ 9.27 (Closes: #926576)
+
+ -- Didier Raboud <odyx@debian.org> Wed, 10 Apr 2019 17:07:27 +0200
+
+cups-filters (1.22.4-1) experimental; urgency=medium
+
+ * New upstream version 1.22.4
+
+ -- Didier Raboud <odyx@debian.org> Sat, 06 Apr 2019 14:08:13 +0200
+
+cups-filters (1.22.3-1) experimental; urgency=medium
+
+ * New upstream version 1.22.3
+
+ -- Didier Raboud <odyx@debian.org> Wed, 27 Mar 2019 17:01:30 +0100
+
+cups-filters (1.22.2-1) experimental; urgency=medium
+
+ * New upstream version 1.22.2
+ - Add new cupsImageCrop@Base symbol
+
+ -- Didier Raboud <odyx@debian.org> Mon, 18 Mar 2019 17:41:12 +0100
+
+cups-filters (1.22.1-1) experimental; urgency=medium
+
+ * New upstream version 1.22.1
+
+ -- Didier Raboud <odyx@debian.org> Sat, 16 Feb 2019 14:09:02 +0100
+
+cups-filters (1.22.0-1) experimental; urgency=low
+
+ * New upstream version 1.22.0
+ * Bump libqpdf-dev B-D to >= 8.3
+
+ -- Didier Raboud <odyx@debian.org> Fri, 18 Jan 2019 14:36:00 +0100
+
cups-filters (1.21.6-5) unstable; urgency=medium
* Backport upstream patch:
diff --git a/debian/control b/debian/control
index 6f4a4d18a..1ab9c2073 100644
--- a/debian/control
+++ b/debian/control
@@ -14,9 +14,8 @@ Build-Depends: autoconf,
libglib2.0-dev,
liblcms2-dev,
libldap2-dev,
- libpoppler-private-dev,
libpoppler-cpp-dev,
- libqpdf-dev (>= 8.1~),
+ libqpdf-dev (>= 8.3~),
libjpeg-dev,
libpng-dev,
libtiff-dev,
diff --git a/debian/copyright b/debian/copyright
index 9ffac41f6..a8fe150f0 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -16,11 +16,16 @@ Copyright: 1993-2007 Easy Software Products
2012 Tomáš Chvátal
2010 Neil 'Superna' Armstrong
2015-2016 Samuel Thibault
- 2008 Lars Übernickel
+ 2008 Lars Karlitski (formerly Übernickel)
License: GPL-2+
+Files: backend/implicitclass.c
+Copyright: 2015, Till Kamppeter
+ 2008-2015, Apple Inc
+ 2018-2019, Deepak Patankar
+License: GPL-2
+
Files: backend/beh.c
- backend/implicitclass.c
Copyright: 2015, Till Kamppeter
2008-2015, Apple Inc
License: GPL-2
@@ -39,9 +44,10 @@ Copyright: 2007-2016 Apple Inc
1993-2007 by Easy Software Products
2011-2013, Richard Hughes
2011, Tim Waugh
- 2013-2016, Till Kamppeter
+ 2013-2019, Till Kamppeter
2014, Joseph Simon
2017, Sahil Arora
+ 2018-2019, Deepak Patankar
License: LGPL-2
Files: cupsfilters/colord.c
@@ -67,7 +73,7 @@ Copyright: 1999-2003, Jeff Licquia <licquia@debian.org>
2003-2007, Kenshi Muto <kmuto@debian.org>
2007-2012, Martin Pitt <mpitt@debian.org>
2012-2015, Till Kamppeter <till.kamppeter@gmail.com>
- 2013-2018, Didier Raboud <odyx@debian.org>
+ 2013-2019, Didier Raboud <odyx@debian.org>
License: GPL-2+
Files: debian/local/*
@@ -83,9 +89,9 @@ Files: debian/local/apport-hook.py
Copyright: 2009 Canonical Ltd.
License: GPL-2+
-Files: filter/PDFError.h
- filter/pdftoraster.cxx
+Files: filter/pdftoraster.cxx
Copyright: 2008-2012, BBR Inc.
+ 2019, Tanmay Anand
License: Expat
Files: filter/banner.c
@@ -138,7 +144,7 @@ License: GPL-2
Files: filter/foomatic-rip/*
Copyright: 2008, Till Kamppeter <till.kamppeter@gmail.com>
- 2008, Lars Uebernickel <larsuebernickel@gmx.de>
+ 2008, Lars Karlitski (formerly Übernickel) <lars@karlitski.net>
License: GPL-2+
Files: filter/getline.c
@@ -166,21 +172,6 @@ Files: filter/imagetopdf*
Copyright: 1993-2007, Easy Software Products
License: GPL-2
-Files: filter/pdftoijs.cxx
- ppd/HP-PhotoSmart_Pro_B8300-hpijs-pdftoijs.ppd
-Copyright: 2008, Tobias Hoffmann
- 2008, BBR Inc.
-License: Expat
-
-Files: filter/pdftoopvp/*
-Copyright: 2003, 2004, 2005, 2006, AXE,Inc
- 2007, 2008, ModifiedBBR Inc.
- 2003, Glyph & Cog, LLC
- 2006, Fuji Xerox Printing Systems Co., Ltd
- 2006, Free Standards Group
- 2006, Canon Inc
-License: Expat
-
Files: filter/pdftopdf/*
Copyright: 2012 Tobias Hoffmann
2006-2011, BBR Inc
@@ -267,8 +258,9 @@ License: GPL-2+
Files: utils/cups-browsed*
org.cups.cupsd.Notifier.xml
-Copyright: 2012-2016 Till Kamppeter
+Copyright: 2012-2019 Till Kamppeter
2013-2015 Tim Waugh
+ 2018-2019 Deepak Patankar
License: LGPL-2.1+
Files: utils/driverless*
diff --git a/debian/libcupsfilters1.symbols b/debian/libcupsfilters1.symbols
index 95b46018d..43e26c3c6 100644
--- a/debian/libcupsfilters1.symbols
+++ b/debian/libcupsfilters1.symbols
@@ -37,6 +37,7 @@ libcupsfilters.so.1 libcupsfilters1 #MINVER#
adobergb_gamma@Base 1.0.58
adobergb_matrix@Base 1.0.58
adobergb_wp@Base 1.0.58
+ apply_filters@Base 1.24.0
blackpoint_default@Base 1.0.58
cmBlackPointDefault@Base 1.0.58
cmGammaAdobeRgb@Base 1.0.58
@@ -78,6 +79,7 @@ libcupsfilters.so.1 libcupsfilters1 #MINVER#
cupsImageCMYKToRGB@Base 1.0~b1
cupsImageCMYKToWhite@Base 1.0~b1
cupsImageClose@Base 1.0~b1
+ cupsImageCrop@Base 1.22.2
cupsImageGetCol@Base 1.0~b1
cupsImageGetColorSpace@Base 1.0~b1
cupsImageGetDepth@Base 1.0~b1
@@ -122,15 +124,18 @@ libcupsfilters.so.1 libcupsfilters1 #MINVER#
free_choice_strings@Base 1.20.0
free_opt_strings@Base 1.20.0
free_resolution@Base 1.17.1
+ generate_sizes@Base 1.24.0
get_profile_inhibitors@Base 1.0.42
ippResolutionListToArray@Base 1.17.1
ippResolutionToRes@Base 1.17.1
+ is_colordevice@Base 1.24.0
joinResolutionArrays@Base 1.17.1
load_opt_strings_catalog@Base 1.20.0
lookup_choice@Base 1.20.0
lookup_option@Base 1.20.0
optArrayNew@Base 1.20.0
opt_strings_catalog@Base 1.20.0
+ ppdCreateFromIPP2@Base 1.24.0
ppdCreateFromIPP@Base 1.12.0
ppdgenerator_msg@Base 1.12.0
resolutionArrayNew@Base 1.17.1
diff --git a/debian/patches/0001-In-liblouis1.defs.gen.in-launch-sort-with-LC_ALL-C-f.patch b/debian/patches/0001-In-liblouis1.defs.gen.in-launch-sort-with-LC_ALL-C-f.patch
deleted file mode 100644
index a68ce6aac..000000000
--- a/debian/patches/0001-In-liblouis1.defs.gen.in-launch-sort-with-LC_ALL-C-f.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From 67c89a99ebc68cd5a1d7d149dc55dfecf9036c54 Mon Sep 17 00:00:00 2001
-From: Didier Raboud <odyx@debian.org>
-Date: Mon, 17 Dec 2018 21:55:31 +0100
-Subject: In liblouis1.defs.gen.in; launch sort with LC_ALL=C for
- reproducibility
-
----
- filter/braille/filters/liblouis1.defs.gen.in | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/filter/braille/filters/liblouis1.defs.gen.in b/filter/braille/filters/liblouis1.defs.gen.in
-index ae7480327..fc53bb5b4 100644
---- a/filter/braille/filters/liblouis1.defs.gen.in
-+++ b/filter/braille/filters/liblouis1.defs.gen.in
-@@ -277,7 +277,7 @@ echo ' Choice "HyphLocale/Default hyphenation rules for language" ""'
- echo "$file:$LANGUAGE:$LOCATION:hyphenation rules:"
- done
-
--) | sort -f -t : -k 2,3 | (
-+) | LC_ALL=C sort -f -t : -k 2,3 | (
-
- IFS=:
- while read file LANGUAGE LOCATION TYPE DISPLAY_NAME
diff --git a/debian/patches/0002-cups-browsed-Fixed-crash-in-applying-the-BrowseFilte.patch b/debian/patches/0002-cups-browsed-Fixed-crash-in-applying-the-BrowseFilte.patch
deleted file mode 100644
index e697e070e..000000000
--- a/debian/patches/0002-cups-browsed-Fixed-crash-in-applying-the-BrowseFilte.patch
+++ /dev/null
@@ -1,44 +0,0 @@
-From 818e68680b51da57d5931767331bea2fce2a899a Mon Sep 17 00:00:00 2001
-From: Till Kamppeter <till.kamppeter@gmail.com>
-Date: Fri, 21 Dec 2018 20:36:34 +0100
-Subject: cups-browsed: Fixed crash in applying the BrowseFilter
- cups-browsed.conf directives
-
-Closes: #916765
----
- utils/cups-browsed.c | 16 +++++++++-------
- 1 file changed, 9 insertions(+), 7 deletions(-)
-
-diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c
-index 0d5d521b6..220d862e6 100644
---- a/utils/cups-browsed.c
-+++ b/utils/cups-browsed.c
-@@ -5614,19 +5614,21 @@ matched_filters (const char *queue_name,
- if (filter->regexp) {
- /* match regexp */
- if (!value)
-- value = "";
-+ value = strdup("");
- if ((filter->cregexp &&
- regexec(filter->cregexp, value, 0, NULL, 0) == 0) ||
- (!filter->cregexp && !strcasecmp(filter->regexp, value))) {
-- avahi_free(key);
-- avahi_free(value);
-- if (filter->sense == FILTER_NOT_MATCH)
-+ if (filter->sense == FILTER_NOT_MATCH) {
-+ avahi_free(key);
-+ avahi_free(value);
- goto filter_failed;
-+ }
- } else {
-- avahi_free(key);
-- avahi_free(value);
-- if (filter->sense == FILTER_MATCH)
-+ if (filter->sense == FILTER_MATCH) {
-+ avahi_free(key);
-+ avahi_free(value);
- goto filter_failed;
-+ }
- }
- } else {
- /* match boolean value */
diff --git a/debian/patches/0003-pdftopdf-Fixed-bug-of-closing-temporary-file-prematu.patch b/debian/patches/0003-pdftopdf-Fixed-bug-of-closing-temporary-file-prematu.patch
deleted file mode 100644
index 615f1643f..000000000
--- a/debian/patches/0003-pdftopdf-Fixed-bug-of-closing-temporary-file-prematu.patch
+++ /dev/null
@@ -1,33 +0,0 @@
-From 4bd5d36f3eb53bf090f887c0ea12e718f38759ec Mon Sep 17 00:00:00 2001
-From: Till Kamppeter <till.kamppeter@gmail.com>
-Date: Mon, 14 Jan 2019 17:24:30 +0100
-Subject: pdftopdf: Fixed bug of closing temporary file prematurely when
- external PDF form flattening utilities fail.
-
----
- filter/pdftopdf/pdftopdf.cc | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/filter/pdftopdf/pdftopdf.cc b/filter/pdftopdf/pdftopdf.cc
-index b09749b2f..49d27c976 100644
---- a/filter/pdftopdf/pdftopdf.cc
-+++ b/filter/pdftopdf/pdftopdf.cc
-@@ -1164,7 +1164,8 @@ int main(int argc,char **argv)
- }
- }
- /* Clean up */
-- fclose(infile);
-+ if (infile != tmpfile)
-+ fclose(infile);
- /* Load the flattened PDF file into our PDF processor */
- if (flattening_done) {
- rewind(outfile);
-@@ -1202,6 +1203,8 @@ int main(int argc,char **argv)
-
- emitPostamble(ppd,param);
- ppdClose(ppd);
-+ if (tmpfile)
-+ fclose(tmpfile);
- } catch (std::exception &e) {
- // TODO? exception type
- error("Exception: %s",e.what());
diff --git a/debian/patches/0004-cups-browsed-driverless-Correct-attributes-of-get-pr.patch b/debian/patches/0004-cups-browsed-driverless-Correct-attributes-of-get-pr.patch
deleted file mode 100644
index 0f9c07cab..000000000
--- a/debian/patches/0004-cups-browsed-driverless-Correct-attributes-of-get-pr.patch
+++ /dev/null
@@ -1,48 +0,0 @@
-From c1ec6e6233f90f7944e796732bcb68b546e75512 Mon Sep 17 00:00:00 2001
-From: Till Kamppeter <till.kamppeter@gmail.com>
-Date: Mon, 11 Feb 2019 23:12:14 +0100
-Subject: cups-browsed, driverless: Correct attributes of
- get-printer-attributes IPP request
-
-cups-browsed, driverless: When polling the printer's
-capabilities via get-printer-attributes IPP request for
-driverless printing, use the attributes "all" and
-"media-col-database". Without "all" some printers do not
-report "urf-supported" and without "media-col-database" not
-all paper size and marging info gets reported (Issue #22,
-Pull request #86, CUPS issue #5484).
----
- utils/cups-browsed.c | 4 +---
- utils/driverless.c | 4 +---
- 2 files changed, 2 insertions(+), 6 deletions(-)
-
-diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c
-index 220d862e6..c1921d6f5 100644
---- a/utils/cups-browsed.c
-+++ b/utils/cups-browsed.c
-@@ -3846,9 +3846,7 @@ get_printer_attributes(const char* uri) {
- char valuebuffer[65536];
- static const char * const pattrs[] =
- {
-- "job-template",
-- "printer-defaults",
-- "printer-description",
-+ "all",
- "media-col-database"
- };
- /* Request printer properties via IPP to generate a PPD file for the
-diff --git a/utils/driverless.c b/utils/driverless.c
-index a46a2a3d0..6371bdbcd 100644
---- a/utils/driverless.c
-+++ b/utils/driverless.c
-@@ -479,9 +479,7 @@ generate_ppd (const char *uri)
- int i, fd, bytes;
- static const char * const pattrs[] =
- {
-- "job-template",
-- "printer-defaults",
-- "printer-description",
-+ "all",
- "media-col-database"
- };
-
diff --git a/debian/patches/0005-foomatic-rip-Changed-Ghostscript-call-to-count-pages.patch b/debian/patches/0005-foomatic-rip-Changed-Ghostscript-call-to-count-pages.patch
deleted file mode 100644
index 271a6b3f1..000000000
--- a/debian/patches/0005-foomatic-rip-Changed-Ghostscript-call-to-count-pages.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From ac421831bde36d391900eba263cb6215eacb4927 Mon Sep 17 00:00:00 2001
-From: Till Kamppeter <till.kamppeter@gmail.com>
-Date: Sun, 7 Apr 2019 16:34:16 +0200
-Subject: foomatic-rip: Changed Ghostscript call to count pages in a PDF file
- so that it works with GS 9.27.
-
----
- filter/foomatic-rip/pdf.c | 5 ++---
- 1 file changed, 2 insertions(+), 3 deletions(-)
-
-diff --git a/filter/foomatic-rip/pdf.c b/filter/foomatic-rip/pdf.c
-index 9c3979bb2..bc739bd80 100644
---- a/filter/foomatic-rip/pdf.c
-+++ b/filter/foomatic-rip/pdf.c
-@@ -47,9 +47,8 @@ static int pdf_count_pages(const char *filename)
- size_t bytes;
-
- snprintf(gscommand, CMDLINE_MAX, "%s -dNODISPLAY -q -c "
-- "'/pdffile (%s) (r) file def pdfdict begin pdffile pdfopen begin "
-- "(PageCount: ) print pdfpagecount == flush currentdict pdfclose "
-- "end end quit'",
-+ "'/pdffile (%s) (r) file runpdfbegin (PageCount: ) print "
-+ "pdfpagecount = quit'",
- gspath, filename);
-
- FILE *pd = popen(gscommand, "r");
diff --git a/debian/patches/series b/debian/patches/series
deleted file mode 100644
index e82ac0cf3..000000000
--- a/debian/patches/series
+++ /dev/null
@@ -1,5 +0,0 @@
-0001-In-liblouis1.defs.gen.in-launch-sort-with-LC_ALL-C-f.patch
-0002-cups-browsed-Fixed-crash-in-applying-the-BrowseFilte.patch
-0003-pdftopdf-Fixed-bug-of-closing-temporary-file-prematu.patch
-0004-cups-browsed-driverless-Correct-attributes-of-get-pr.patch
-0005-foomatic-rip-Changed-Ghostscript-call-to-count-pages.patch
diff --git a/filter/PDFError.h b/filter/PDFError.h
deleted file mode 100644
index 9fb58bcd4..000000000
--- a/filter/PDFError.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-
-Copyright (c) 2012, BBR Inc. All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-/*
- P2PError.h
-*/
-#ifndef _P2PERROR_H_
-#define _P2PERROR_H_
-
-#include <config.h>
-#include <stdarg.h>
-#include <Error.h>
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
-#define pdfError(pos,...) error(errInternal,pos,__VA_ARGS__)
-#else
-#define pdfError(pos,...) error(pos,__VA_ARGS__)
-#endif
-
-#endif
diff --git a/filter/bannertopdf.c b/filter/bannertopdf.c
index 6e171624f..028bf604a 100644
--- a/filter/bannertopdf.c
+++ b/filter/bannertopdf.c
@@ -511,7 +511,7 @@ static int generate_banner_pdf(banner_t *banner,
copies *= 2;
if (copies > 1)
- pdf_duplicate_page(doc, 1, copies);
+ pdf_duplicate_page(doc, 1, copies - 1);
pdf_write(doc, stdout);
diff --git a/filter/foomatic-rip/foomaticrip.c b/filter/foomatic-rip/foomaticrip.c
index f53d0eb91..a21b1a5ee 100644
--- a/filter/foomatic-rip/foomaticrip.c
+++ b/filter/foomatic-rip/foomaticrip.c
@@ -1,7 +1,7 @@
/* foomaticrip.c
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/foomaticrip.h b/filter/foomatic-rip/foomaticrip.h
index 6ed2c007b..35fd2429b 100644
--- a/filter/foomatic-rip/foomaticrip.h
+++ b/filter/foomatic-rip/foomaticrip.h
@@ -1,7 +1,7 @@
/* foomaticrip.h
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/options.c b/filter/foomatic-rip/options.c
index 0f46855a7..481e5c543 100644
--- a/filter/foomatic-rip/options.c
+++ b/filter/foomatic-rip/options.c
@@ -1,7 +1,7 @@
/* options.c
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/options.h b/filter/foomatic-rip/options.h
index 353ea9914..3dd09795f 100644
--- a/filter/foomatic-rip/options.h
+++ b/filter/foomatic-rip/options.h
@@ -1,7 +1,7 @@
/* options.h
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/pdf.c b/filter/foomatic-rip/pdf.c
index bc739bd80..c79b56450 100644
--- a/filter/foomatic-rip/pdf.c
+++ b/filter/foomatic-rip/pdf.c
@@ -1,7 +1,7 @@
/* pdf.c
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/pdf.h b/filter/foomatic-rip/pdf.h
index aa044453c..c9472a01a 100644
--- a/filter/foomatic-rip/pdf.h
+++ b/filter/foomatic-rip/pdf.h
@@ -1,7 +1,7 @@
/* pdf.h
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/postscript.c b/filter/foomatic-rip/postscript.c
index 75070d2b9..f0ddf0180 100644
--- a/filter/foomatic-rip/postscript.c
+++ b/filter/foomatic-rip/postscript.c
@@ -1,7 +1,7 @@
/* postscript.c
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/postscript.h b/filter/foomatic-rip/postscript.h
index cb6c52581..d3089cc98 100644
--- a/filter/foomatic-rip/postscript.h
+++ b/filter/foomatic-rip/postscript.h
@@ -1,7 +1,7 @@
/* postscript.h
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/process.c b/filter/foomatic-rip/process.c
index a91289a25..61492620f 100644
--- a/filter/foomatic-rip/process.c
+++ b/filter/foomatic-rip/process.c
@@ -1,7 +1,7 @@
/* process.c
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/process.h b/filter/foomatic-rip/process.h
index b95dcb4da..04c8b92eb 100644
--- a/filter/foomatic-rip/process.h
+++ b/filter/foomatic-rip/process.h
@@ -1,7 +1,7 @@
/* process.h
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/renderer.c b/filter/foomatic-rip/renderer.c
index 2fd3c689f..0ce4caf00 100644
--- a/filter/foomatic-rip/renderer.c
+++ b/filter/foomatic-rip/renderer.c
@@ -1,7 +1,7 @@
/* renderer.c
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/renderer.h b/filter/foomatic-rip/renderer.h
index 298f67b5c..fac8c2785 100644
--- a/filter/foomatic-rip/renderer.h
+++ b/filter/foomatic-rip/renderer.h
@@ -1,7 +1,7 @@
/* renderer.h
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/spooler.c b/filter/foomatic-rip/spooler.c
index 4f2756395..7f0cb8eeb 100644
--- a/filter/foomatic-rip/spooler.c
+++ b/filter/foomatic-rip/spooler.c
@@ -1,7 +1,7 @@
/* spooler.c
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/spooler.h b/filter/foomatic-rip/spooler.h
index 7025ccaf7..fc4cb34de 100644
--- a/filter/foomatic-rip/spooler.h
+++ b/filter/foomatic-rip/spooler.h
@@ -1,7 +1,7 @@
/* spooler.h
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/util.c b/filter/foomatic-rip/util.c
index 9038f9010..b3e59a050 100644
--- a/filter/foomatic-rip/util.c
+++ b/filter/foomatic-rip/util.c
@@ -1,7 +1,7 @@
/* util.c
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/foomatic-rip/util.h b/filter/foomatic-rip/util.h
index 33e3c8700..8aa884e0b 100644
--- a/filter/foomatic-rip/util.h
+++ b/filter/foomatic-rip/util.h
@@ -1,7 +1,7 @@
/* util.h
*
* Copyright (C) 2008 Till Kamppeter <till.kamppeter@gmail.com>
- * Copyright (C) 2008 Lars Uebernickel <larsuebernickel@gmx.de>
+ * Copyright (C) 2008 Lars Karlitski (formerly Uebernickel) <lars@karlitski.net>
*
* This file is part of foomatic-rip.
*
diff --git a/filter/imagetopdf.c b/filter/imagetopdf.c
index 658e1131a..c4efc3e1f 100644
--- a/filter/imagetopdf.c
+++ b/filter/imagetopdf.c
@@ -149,13 +149,13 @@ void emitJCLOptions(FILE *fp, int copies)
int i;
char buf[1024];
ppd_attr_t *attr;
- int pdftoopvp = 0;
+ int pdftopdfjcl = 0;
int datawritten = 0;
if (ppd == 0) return;
if ((attr = ppdFindAttr(ppd,"pdftopdfJCLBegin",NULL)) != NULL) {
int n = strlen(attr->value);
- pdftoopvp = 1;
+ pdftopdfjcl = 1;
for (i = 0;i < n;i++) {
if (attr->value[i] == '\r' || attr->value[i] == '\n') {
/* skip new line */
@@ -173,7 +173,7 @@ void emitJCLOptions(FILE *fp, int copies)
if ((attr = ppdFindAttr(ppd,"pdftopdfJCLCopies",buf)) != NULL) {
fputs(attr->value,fp);
datawritten = 1;
- } else if (pdftoopvp) {
+ } else if (pdftopdfjcl) {
fprintf(fp,"Copies=%d;",copies);
datawritten = 1;
}
@@ -189,7 +189,7 @@ void emitJCLOptions(FILE *fp, int copies)
if ((attr = ppdFindAttr(ppd,buf,choices[i]->choice)) != NULL) {
fputs(attr->value,fp);
datawritten = 1;
- } else if (pdftoopvp) {
+ } else if (pdftopdfjcl) {
fprintf(fp,"%s=%s;",
((ppd_option_t *)(choices[i]->option))->keyword,
choices[i]->choice);
@@ -693,7 +693,8 @@ main(int argc, /* I - Number of command-line arguments */
int deviceReverse = 0;
ppd_attr_t *attr;
int pl,pr;
-
+ int fillprint = 0; /* print-scaling = fill */
+ int cropfit = 0; /* -o crop-to-fit = true */
/*
* Make sure status messages are not buffered...
*/
@@ -810,7 +811,6 @@ main(int argc, /* I - Number of command-line arguments */
}
}
-
if ((val = cupsGetOption("OutputOrder",num_options,options)) != 0) {
if (!strcasecmp(val, "Reverse")) {
Reverse = 1;
@@ -876,21 +876,6 @@ main(int argc, /* I - Number of command-line arguments */
if ((val = cupsGetOption("brightness", num_options, options)) != NULL)
brightness = atoi(val) * 0.01f;
- if ((val = cupsGetOption("scaling", num_options, options)) != NULL)
- zoom = atoi(val) * 0.01;
- else if (((val =
- cupsGetOption("fit-to-page", num_options, options)) != NULL) ||
- ((val = cupsGetOption("fitplot", num_options, options)) != NULL))
- {
- if (!strcasecmp(val, "yes") || !strcasecmp(val, "on") ||
- !strcasecmp(val, "true"))
- zoom = 1.0;
- else
- zoom = 0.0;
- }
- else if ((val = cupsGetOption("natural-scaling", num_options, options)) != NULL)
- zoom = 0.0;
-
if ((val = cupsGetOption("ppi", num_options, options)) != NULL)
{
if (sscanf(val, "%dx%d", &xppi, &yppi) < 2)
@@ -973,6 +958,218 @@ main(int argc, /* I - Number of command-line arguments */
colorspace = ColorDevice ? CUPS_IMAGE_RGB_CMYK : CUPS_IMAGE_WHITE;
img = cupsImageOpen(filename, colorspace, CUPS_IMAGE_WHITE, sat, hue, NULL);
+ if(img!=NULL){
+
+ int margin_defined = 0;
+ int fidelity = 0;
+ int document_large = 0;
+
+ if(ppd->custom_margins[0]||ppd->custom_margins[1]||
+ ppd->custom_margins[2]||ppd->custom_margins[3]) // In case of custom margins
+ margin_defined = 1;
+ if(PageLength!=PageTop-PageBottom||PageWidth!=PageRight-PageLeft)
+ margin_defined = 1;
+
+ if((val = cupsGetOption("ipp-attribute-fidelity",num_options,options)) != NULL) {
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes")||
+ !strcasecmp(val,"on")) {
+ fidelity = 1;
+ }
+ }
+
+ float w = (float)cupsImageGetWidth(img);
+ float h = (float)cupsImageGetHeight(img);
+ float pw = PageRight-PageLeft;
+ float ph = PageTop-PageBottom;
+ int tempOrientation = Orientation;
+ if((val = cupsGetOption("orientation-requested",num_options,options))!=NULL) {
+ tempOrientation = atoi(val);
+ }
+ else if((val = cupsGetOption("landscape",num_options,options))!=NULL) {
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes")) {
+ tempOrientation = 4;
+ }
+ }
+ if(tempOrientation==0) {
+ int temp1 = pw,
+ temp2 = ph,
+ temp3 = pw,
+ temp4 = ph;
+ if(temp1>w) temp1 = w;
+ if(temp2>h) temp2 = h;
+ if(temp3>h) temp3 = h;
+ if(temp4>w) temp4 = w;
+ if(temp1*temp2<temp3*temp4) {
+ tempOrientation = 4;
+ }
+ }
+ if(tempOrientation==4||tempOrientation==5) {
+ int tmp = pw;
+ pw = ph;
+ ph = tmp;
+ }
+ if(w>pw||h>ph) {
+ document_large = 1;
+ }
+
+ if((val = cupsGetOption("print-scaling",num_options,options)) != NULL) {
+ if(!strcasecmp(val,"auto")) {
+ if(fidelity||document_large) {
+ if(margin_defined)
+ zoom = 1.0; // fit method
+ else
+ fillprint = 1; // fill method
+ }
+ else
+ cropfit = 1; // none method
+ }
+ else if(!strcasecmp(val,"auto-fit")) {
+ if(fidelity||document_large)
+ zoom = 1.0; // fit method
+ else
+ cropfit = 1; // none method
+ }
+ else if(!strcasecmp(val,"fill"))
+ fillprint = 1; // fill method
+ else if(!strcasecmp(val,"fit"))
+ zoom = 1.0; // fitplot = 1 or fit method
+ else
+ cropfit=1; // none or crop-to-fit
+ }
+ else{ // print-scaling is not defined, look for alternate options.
+
+ if ((val = cupsGetOption("scaling", num_options, options)) != NULL)
+ zoom = atoi(val) * 0.01;
+ else if (((val =
+ cupsGetOption("fit-to-page", num_options, options)) != NULL) ||
+ ((val = cupsGetOption("fitplot", num_options, options)) != NULL))
+ {
+ if (!strcasecmp(val, "yes") || !strcasecmp(val, "on") ||
+ !strcasecmp(val, "true"))
+ zoom = 1.0;
+ else
+ zoom = 0.0;
+ }
+ else if ((val = cupsGetOption("natural-scaling", num_options, options)) != NULL)
+ zoom = 0.0;
+
+ if((val = cupsGetOption("fill",num_options,options))!=0) {
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes")) {
+ fillprint = 1;
+ }
+ }
+
+ if((val = cupsGetOption("crop-to-fit",num_options,options))!= NULL){
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes")) {
+ cropfit=1;
+ }
+ } }
+ }
+ if(fillprint||cropfit)
+ {
+ float w = (float)cupsImageGetWidth(img);
+ float h = (float)cupsImageGetHeight(img);
+ float pw = PageRight-PageLeft;
+ float ph = PageTop-PageBottom;
+ int tempOrientation = Orientation;
+ const char *val;
+ int flag = 3;
+ if((val = cupsGetOption("orientation-requested",num_options,options))!=NULL)
+ {
+ tempOrientation = atoi(val);
+ }
+ else if((val = cupsGetOption("landscape",num_options,options))!=NULL)
+ {
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
+ {
+ tempOrientation = 4;
+ }
+ }
+ if(tempOrientation>0)
+ {
+ if(tempOrientation==4||tempOrientation==5)
+ {
+ float temp = pw;
+ pw = ph;
+ ph = temp;
+ flag = 4;
+ }
+ }
+ if(tempOrientation==0)
+ {
+ int temp1 = pw,
+ temp2 = ph,
+ temp3 = pw,
+ temp4 = ph;
+ if(temp1>w) temp1 = w;
+ if(temp2>h) temp2 = h;
+ if(temp3>h) temp3 = h;
+ if(temp4>w) temp4 = w;
+ if(temp1*temp2<temp3*temp4)
+ {
+ int temp = pw;
+ pw = ph;
+ ph = temp;
+ flag = 4;
+ }
+ }
+ if(fillprint){
+ float final_w,final_h;
+ if(w*ph/pw <=h){
+ final_w =w;
+ final_h =w*ph/pw;
+ }
+ else{
+ final_w = h*pw/ph;
+ final_h = h;
+ }
+ float posw=(w-final_w)/2,posh=(h-final_h)/2;
+ posw = (1+XPosition)*posw;
+ posh = (1-YPosition)*posh;
+ cups_image_t *img2 = cupsImageCrop(img,posw,posh,final_w,final_h);
+ cupsImageClose(img);
+ img = img2;
+ }
+ else {
+ float final_w=w,final_h=h;
+ if(final_w>pw)
+ {
+ final_w = pw;
+ }
+ if(final_h>ph)
+ {
+ final_h = ph;
+ }
+ if((fabs(final_w-w)>0.5*w)||(fabs(final_h-h)>0.5*h))
+ {
+ fprintf(stderr,"[DEBUG]: Ignoring crop-to-fit option!\n");
+ cropfit=0;
+ }
+ else{
+ float posw=(w-final_w)/2,posh=(h-final_h)/2;
+ posw = (1+XPosition)*posw;
+ posh = (1-YPosition)*posh;
+ cups_image_t *img2 = cupsImageCrop(img,posw,posh,final_w,final_h);
+ cupsImageClose(img);
+ img = img2;
+ if(flag==4)
+ {
+ PageBottom+=(PageTop-PageBottom-final_w)/2;
+ PageTop = PageBottom+final_w;
+ PageLeft +=(PageRight-PageLeft-final_h)/2;
+ PageRight = PageLeft+final_h;
+ }
+ else{
+ PageBottom+=(PageTop-PageBottom-final_h)/2;
+ PageTop = PageBottom+final_h;
+ PageLeft +=(PageRight-PageLeft-final_w)/2;
+ PageRight = PageLeft+final_w;
+ }
+ if(PageBottom<0) PageBottom = 0;
+ if(PageLeft<0) PageLeft = 0;
+ }
+ }
+ }
#if defined(USE_CONVERT_CMD) && defined(CONVERT_CMD)
if (img == NULL) {
diff --git a/filter/imagetoraster.c b/filter/imagetoraster.c
index 67876f389..aaa5ff2ee 100644
--- a/filter/imagetoraster.c
+++ b/filter/imagetoraster.c
@@ -190,8 +190,8 @@ main(int argc, /* I - Number of command-line arguments */
char filename[1024]; /* Name of file to print */
cm_calibration_t cm_calibrate; /* Are we color calibrating the device? */
int cm_disabled; /* Color management disabled? */
-
-
+ int fillprint = 0; /* print-scaling = fill */
+ int cropfit = 0; /* -o crop-to-fit */
/*
* Make sure status messages are not buffered...
*/
@@ -240,7 +240,6 @@ main(int argc, /* I - Number of command-line arguments */
perror("ERROR: Unable to create pipes for filters");
return (errno);
}
-
if ((pid = fork()) == 0)
{
/*
@@ -264,7 +263,6 @@ main(int argc, /* I - Number of command-line arguments */
perror("ERROR: Unable to fork filter");
return (errno);
}
-
/*
* Update stdout so it points at the new pstoraster...
*/
@@ -377,21 +375,6 @@ main(int argc, /* I - Number of command-line arguments */
b = 10.0f;
}
- if ((val = cupsGetOption("scaling", num_options, options)) != NULL)
- zoom = atoi(val) * 0.01;
- else if (((val =
- cupsGetOption("fit-to-page", num_options, options)) != NULL) ||
- ((val = cupsGetOption("fitplot", num_options, options)) != NULL))
- {
- if (!strcasecmp(val, "yes") || !strcasecmp(val, "on") ||
- !strcasecmp(val, "true"))
- zoom = 1.0;
- else
- zoom = 0.0;
- }
- else if ((val = cupsGetOption("natural-scaling", num_options, options)) != NULL)
- zoom = 0.0;
-
if ((val = cupsGetOption("ppi", num_options, options)) != NULL)
{
if (sscanf(val, "%dx%d", &xppi, &yppi) < 2)
@@ -692,6 +675,225 @@ main(int argc, /* I - Number of command-line arguments */
else
img = cupsImageOpen(filename, primary, secondary, sat, hue, lut);
+ if(img!=NULL){
+
+ int margin_defined = 0;
+ int fidelity = 0;
+ int document_large = 0;
+
+ if(ppd->custom_margins[0]||ppd->custom_margins[1]
+ ||ppd->custom_margins[2]||ppd->custom_margins[3])
+ margin_defined = 1;
+
+ if(PageLength!=PageTop-PageBottom||PageWidth!=PageRight-PageLeft)
+ {
+ margin_defined = 1;
+ }
+
+ if((val = cupsGetOption("ipp-attribute-fidelity",num_options,options)) != NULL)
+ {
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes")||
+ !strcasecmp(val,"on"))
+ {
+ fidelity = 1;
+ }
+ }
+
+ float w = (float)cupsImageGetWidth(img);
+ float h = (float)cupsImageGetHeight(img);
+ float pw = PageRight-PageLeft;
+ float ph = PageTop-PageBottom;
+ int tempOrientation = Orientation;
+ if((val = cupsGetOption("orientation-requested",num_options,options))!=NULL)
+ {
+ tempOrientation = atoi(val);
+ }
+ else if((val = cupsGetOption("landscape",num_options,options))!=NULL)
+ {
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
+ {
+ tempOrientation = 4;
+ }
+ }
+ if(tempOrientation==0)
+ {
+ if(min(pw,w)*min(ph,h)<min(pw,h)*min(ph,w))
+ {
+ tempOrientation = 4;
+ }
+ }
+ if(tempOrientation==4||tempOrientation==5)
+ {
+ int tmp = pw;
+ pw = ph;
+ ph = tmp;
+ }
+ if(w>pw||h>ph)
+ {
+ document_large = 1;
+ }
+
+ if((val = cupsGetOption("print-scaling",num_options,options)) != NULL)
+ {
+ if(!strcasecmp(val,"auto"))
+ {
+ if(fidelity||document_large)
+ {
+ if(margin_defined)
+ zoom = 1.0; // fit method
+ else
+ fillprint = 1; // fill method
+ }
+ else
+ cropfit = 1; // none method
+ }
+ else if(!strcasecmp(val,"auto-fit"))
+ {
+ if(fidelity||document_large)
+ zoom = 1.0; // fit method
+ else
+ cropfit = 1; // none method
+ }
+ else if(!strcasecmp(val,"fill"))
+ fillprint = 1; // fill method
+ else if(!strcasecmp(val,"fit"))
+ zoom = 1.0; // fitplot = 1 or fit method
+ else
+ cropfit=1; // none or crop-to-fit
+ }
+ else{ // print-scaling is not defined, look for alternate options.
+ if ((val = cupsGetOption("scaling", num_options, options)) != NULL)
+ zoom = atoi(val) * 0.01;
+ else if (((val =
+ cupsGetOption("fit-to-page", num_options, options)) != NULL) ||
+ ((val = cupsGetOption("fitplot", num_options, options)) != NULL))
+ {
+ if (!strcasecmp(val, "yes") || !strcasecmp(val, "on") ||
+ !strcasecmp(val, "true"))
+ zoom = 1.0;
+ else
+ zoom = 0.0;
+ }
+ else if ((val = cupsGetOption("natural-scaling", num_options, options)) != NULL)
+ zoom = 0.0;
+
+ if((val = cupsGetOption("fill",num_options,options))!=0) {
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
+ {
+ fillprint = 1;
+ }
+ }
+ if((val = cupsGetOption("crop-to-fit",num_options,options))!= NULL){
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
+ {
+ cropfit=1;
+ }
+ } }
+ }
+
+ if(img!=NULL)
+ {
+ if(fillprint||cropfit)
+ {
+ float w = (float)cupsImageGetWidth(img);
+ float h = (float)cupsImageGetHeight(img);
+ float pw = PageRight-PageLeft;
+ float ph = PageTop-PageBottom;
+ const char *val;
+ int tempOrientation = Orientation;
+ int flag =3;
+ if((val = cupsGetOption("orientation-requested",num_options,options))!=NULL)
+ {
+ tempOrientation = atoi(val);
+ }
+ else if((val = cupsGetOption("landscape",num_options,options))!=NULL)
+ {
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
+ {
+ tempOrientation = 4;
+ }
+ }
+ if(tempOrientation>0)
+ {
+ if(tempOrientation==4||tempOrientation==5)
+ {
+ float temp = pw;
+ pw = ph;
+ ph = temp;
+ flag = 4;
+ }
+ }
+ if(tempOrientation==0)
+ {
+ if(min(pw,w)*min(ph,h)<min(pw,h)*min(ph,w))
+ {
+ int temp = pw;
+ pw = ph;
+ ph = temp;
+ flag = 4;
+ }
+ }
+ if(fillprint)
+ {
+ // Final width and height of cropped image.
+ float final_w,final_h;
+ if(w*ph/pw <=h){
+ final_w =w;
+ final_h =w*ph/pw;
+ }
+ else{
+ final_w = h*pw/ph;
+ final_h = h;
+ }
+ // posw and posh are position of the cropped image along width and height.
+ float posw=(w-final_w)/2,posh=(h-final_h)/2;
+ posw = (1+XPosition)*posw;
+ posh = (1-YPosition)*posh;
+ cups_image_t *img2 = cupsImageCrop(img,posw,posh,final_w,final_h);
+ cupsImageClose(img);
+ img = img2;
+ }
+ else {
+ float final_w=w,final_h=h;
+ if(w>pw)
+ {
+ final_w = pw;
+ }
+ if(h>ph)
+ {
+ final_h = ph;
+ }
+ if((fabs(final_w-w)>0.5*w)||(fabs(final_h-h)>0.5*h))
+ {
+ fprintf(stderr,"[DEBUG]: Ignoring crop-to-fit option!\n");
+ cropfit=0;
+ }
+ else{
+ float posw=(w-final_w)/2,posh=(h-final_h)/2;
+ posw = (1+XPosition)*posw;
+ posh = (1-YPosition)*posh;
+ cups_image_t *img2 = cupsImageCrop(img,posw,posh,final_w,final_h);
+ cupsImageClose(img);
+ img = img2;
+ if(flag==4)
+ {
+ PageBottom+=(PageTop-PageBottom-final_w)/2;
+ PageTop = PageBottom+final_w;
+ PageLeft +=(PageRight-PageLeft-final_h)/2;
+ PageRight = PageLeft+final_h;
+ }
+ else{
+ PageBottom+=(PageTop-PageBottom-final_h)/2;
+ PageTop = PageBottom+final_h;
+ PageLeft +=(PageRight-PageLeft-final_w)/2;
+ PageRight = PageLeft+final_w;
+ }
+ if(PageBottom<0) PageBottom = 0;
+ if(PageLeft<0) PageLeft = 0;
+ }
+ }
+ }
+ }
if (argc == 6)
unlink(filename);
diff --git a/filter/mupdftoraster.c b/filter/mupdftoraster.c
index 3af235cb3..8ba7a5743 100644
--- a/filter/mupdftoraster.c
+++ b/filter/mupdftoraster.c
@@ -29,7 +29,7 @@ MIT Open Source License - http://www.opensource.org/
*/
-/* PS/PDF to CUPS Raster filter based on Mutool */
+/* PS/PDF to CUPS Raster filter based on mutool */
#include <config.h>
#include <cups/cups.h>
@@ -118,7 +118,7 @@ parse_pdf_header_options(FILE *fp, mupdf_page_header *h)
static void
add_pdf_header_options(mupdf_page_header *h,
- cups_array_t *mupdf_args)
+ cups_array_t *mupdf_args)
{
char tmpstr[1024];
@@ -158,29 +158,23 @@ add_pdf_header_options(mupdf_page_header *h,
case CUPS_CSPACE_W:
snprintf(tmpstr, sizeof(tmpstr), "-cmono");
break;
- }
+ }
cupsArrayAdd(mupdf_args, strdup(tmpstr));
}
static int
mutool_spawn (const char *filename,
cups_array_t *mupdf_args,
- char **envp,
- FILE *fp,
- int ipfiledes,
- int opfiledes)
+ char **envp)
{
char *argument;
- char buf[BUFSIZ];
char **mutoolargv;
const char* apos;
int i;
- int n;
int numargs;
int pid;
int status = 65536;
int wstatus;
- FILE *tempfp;
/* Put mutool command line argument into an array for the "exec()"
call */
@@ -192,8 +186,8 @@ mutool_spawn (const char *filename,
}
mutoolargv[i] = NULL;
- /* Debug output: Full Mutool command line and environment variables */
- fprintf(stderr, "DEBUG: Mutool command line:");
+ /* Debug output: Full mutool command line and environment variables */
+ fprintf(stderr, "DEBUG: mutool command line:");
for (i = 0; mutoolargv[i]; i ++) {
if ((strchr(mutoolargv[i],' ')) || (strchr(mutoolargv[i],'\t')))
apos = "'";
@@ -206,15 +200,8 @@ mutool_spawn (const char *filename,
for (i = 0; envp[i]; i ++)
fprintf(stderr, "DEBUG: envp[%d]=\"%s\"\n", i, envp[i]);
- /* save the contents for the file to a temporary location */
- tempfp = fdopen(ipfiledes, "wb");
- while ((n = fread(buf, 1, BUFSIZ, fp)) > 0)
- fwrite(buf, 1, n, tempfp);
-
- fclose(tempfp);
-
if ((pid = fork()) == 0) {
- /* Execute Mutool command line ... */
+ /* Execute mutool command line ... */
execvpe(filename, mutoolargv, envp);
perror(filename);
goto out;
@@ -224,24 +211,18 @@ mutool_spawn (const char *filename,
if (waitpid (pid, &wstatus, 0) == -1) {
if (errno == EINTR)
goto retry_wait;
- perror ("gs");
+ perror ("mutool");
goto out;
}
- /* How did Mutool process terminate */
+ /* How did mutool process terminate */
if (WIFEXITED(wstatus))
/* Via exit() anywhere or return() in the main() function */
status = WEXITSTATUS(wstatus);
else if (WIFSIGNALED(wstatus))
/* Via signal */
status = 256 * WTERMSIG(wstatus);
-
- /* write the output to stdout */
- tempfp = fdopen(opfiledes, "rb");
- while ((n = fread(buf, 1, BUFSIZ, tempfp)) > 0)
- fwrite(buf, 1, BUFSIZ, stdout);
-
- fclose(tempfp);
+ fprintf(stderr, "DEBUG: mutool completed, status: %d\n", status);
out:
free(mutoolargv);
@@ -254,16 +235,13 @@ main (int argc, char **argv, char *envp[])
char buf[BUFSIZ];
char *icc_profile = NULL;
char tmpstr[1024];
- char ipfilebuf[20],
- opfilebuf[20];
const char *t = NULL;
cups_array_t *mupdf_args = NULL;
cups_option_t *options = NULL;
FILE *fp = NULL;
+ char infilename[1024];
mupdf_page_header h;
- int fd,
- ipfiledes,
- opfiledes;
+ int fd = -1;
int cm_disabled;
int n;
int num_options;
@@ -302,13 +280,11 @@ main (int argc, char **argv, char *envp[])
if (argc == 6) {
/* stdin */
- fd = cupsTempFd(buf,BUFSIZ);
+ fd = cupsTempFd(infilename, 1024);
if (fd < 0) {
fprintf(stderr, "ERROR: Can't create temporary file\n");
goto out;
}
- /* remove name */
- unlink(buf);
/* copy stdin to the tmp file */
while ((n = read(0,buf,BUFSIZ)) > 0) {
@@ -336,6 +312,7 @@ main (int argc, char **argv, char *envp[])
fprintf(stderr, "ERROR: Can't open input file %s\n",argv[6]);
goto out;
}
+ strncpy(infilename, argv[6], 1024);
}
/* If doc type is not PDF exit */
@@ -352,18 +329,10 @@ main (int argc, char **argv, char *envp[])
if (!cm_disabled)
cmGetPrinterIccProfile(getenv("PRINTER"), &icc_profile, ppd);
- /* Create temporary input and output files */
- memset(ipfilebuf,0,sizeof(ipfilebuf));
- memset(opfilebuf,0,sizeof(opfilebuf));
- strncpy(ipfilebuf,CUPS_IPTEMPFILE,14);
- strncpy(opfilebuf,CUPS_OPTEMPFILE,14);
- ipfiledes = mkstemp(ipfilebuf);
- opfiledes = mkstemp(opfilebuf);
-
- /* Mutool parameters */
+ /* mutool parameters */
mupdf_args = cupsArrayNew(NULL, NULL);
if (!mupdf_args) {
- fprintf(stderr, "ERROR: Unable to allocate memory for Mutool arguments array\n");
+ fprintf(stderr, "ERROR: Unable to allocate memory for mutool arguments array\n");
goto out;
}
@@ -372,11 +341,10 @@ main (int argc, char **argv, char *envp[])
cupsArrayAdd(mupdf_args, strdup(tmpstr));
cupsArrayAdd(mupdf_args, strdup("draw"));
cupsArrayAdd(mupdf_args, strdup("-L"));
- snprintf(tmpstr, sizeof(tmpstr), "-o%s", opfilebuf);
- cupsArrayAdd(mupdf_args, strdup(tmpstr));
+ cupsArrayAdd(mupdf_args, strdup("-o-"));
cupsArrayAdd(mupdf_args, strdup("-smtf"));
- /* Mutool output parameters */
+ /* mutool output parameters */
cupsArrayAdd(mupdf_args, strdup("-Fpwg"));
/* Note that MuPDF only creates PWG Raster and never CUPS Raster,
@@ -431,18 +399,17 @@ main (int argc, char **argv, char *envp[])
h.MirrorPrint = CUPS_FALSE;
h.Orientation = CUPS_ORIENT_0;
- /* get all the data from the header and pass it to Mutool */
+ /* get all the data from the header and pass it to mutool */
add_pdf_header_options (&h, mupdf_args);
- snprintf(tmpstr, sizeof(tmpstr), "%s", ipfilebuf);
+ snprintf(tmpstr, sizeof(tmpstr), "%s", infilename);
cupsArrayAdd(mupdf_args, strdup(tmpstr));
- /* Execute Mutool command line ... */
+ /* Execute mutool command line ... */
snprintf(tmpstr, sizeof(tmpstr), "%s", CUPS_MUTOOL);
/* call mutool */
- rewind(fp);
- status = mutool_spawn (tmpstr, mupdf_args, envp, fp, ipfiledes, opfiledes);
+ status = mutool_spawn (tmpstr, mupdf_args, envp);
if (status != 0) status = 1;
out:
if (fp)
@@ -453,7 +420,7 @@ out:
free(icc_profile);
if (ppd)
ppdClose(ppd);
- unlink(ipfilebuf);
- unlink(opfilebuf);
+ if (fd >= 0)
+ unlink(infilename);
return status;
}
diff --git a/filter/pdftoijs.cxx b/filter/pdftoijs.cxx
deleted file mode 100644
index 777a131f4..000000000
--- a/filter/pdftoijs.cxx
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
-Copyright (c) 2008, BBR Inc. All rights reserved.
- (c) 2008 Tobias Hoffmann
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-/*
- pdftoijs.cc
- pdf to ijs filter
-*/
-
-#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-#include <goo/GooString.h>
-#include <goo/gmem.h>
-#include <Object.h>
-#include <Stream.h>
-#include <PDFDoc.h>
-#include <SplashOutputDev.h>
-#include <cups/cups.h>
-#include <cups/ppd.h>
-#include <stdarg.h>
-#include "PDFError.h"
-#include <GlobalParams.h>
-#include <splash/SplashTypes.h>
-#include <splash/SplashBitmap.h>
-extern "C" {
-#include <ijs/ijs.h>
-#include <ijs/ijs_client.h>
-}
-#include <vector>
-#include <string>
-
-#define MAX_CHECK_COMMENT_LINES 20
-
-namespace {
- int exitCode = 0;
- char *outputfile = NULL;
-// int deviceCopies = 1;
-// bool deviceCollate = false;
- const char *ijsserver = NULL;
- int resolution[2] = {0,0};
- enum ColEnum { NONE=-1, COL_RGB, COL_CMYK, COL_BLACK1, COL_WHITE1, COL_BLACK8, COL_WHITE8 } colspace=NONE;
- const char *devManu=NULL, *devModel=NULL;
- std::vector<std::pair<std::string,std::string> > params;
-
- ppd_file_t *ppd = 0; // holds the memory for the strings
-}
-
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 23
-void CDECL myErrorFun(void *data, ErrorCategory category,
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 70
- Goffset pos, const char *msg)
-#else
- Goffset pos, char *msg)
-#endif /* MAJOR > 0 || MINOR >= 70 */
-#else
-void CDECL myErrorFun(void *data, ErrorCategory category,
- int pos, char *msg)
-#endif
-{
- if (pos >= 0) {
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 23
- fprintf(stderr, "ERROR (%lld): ", pos);
-#else
- fprintf(stderr, "ERROR (%d): ", pos);
-#endif
- } else {
- fprintf(stderr, "ERROR: ");
- }
- fprintf(stderr, "%s\n",msg);
- fflush(stderr);
-}
-#else
-void CDECL myErrorFun(int pos, char *msg, va_list args)
-{
- if (pos >= 0) {
- fprintf(stderr, "ERROR (%d): ", pos);
- } else {
- fprintf(stderr, "ERROR: ");
- }
- vfprintf(stderr, msg, args);
- fprintf(stderr, "\n");
- fflush(stderr);
-}
-#endif
-
-/* parse "300 400" */
-void parse_resolution(const char *str)
-{
- const char *tmp=strchr(str,' ');
- if (tmp) {
- resolution[0]=atoi(str);
- resolution[1]=atoi(tmp+1);
- } else {
- resolution[0]=resolution[1]=atoi(str);
- }
-}
-
-/* parse "cmyk" "grey" "rgb" */
-void parse_colorspace(const char *str)
-{
- if (strcasecmp(str,"rgb")==0) {
- colspace=COL_RGB;
- } else if (strcasecmp(str,"black1")==0) {
- colspace=COL_BLACK1;
- } else if (strcasecmp(str,"white1")==0) {
- colspace=COL_WHITE1;
- } else if (strcasecmp(str,"black8")==0) {
- colspace=COL_BLACK8;
- } else if (strcasecmp(str,"white8")==0) {
- colspace=COL_WHITE8;
-#ifdef SPLASH_CMYK
- } else if (strcasecmp(str,"cmyk")==0) {
- colspace=COL_CMYK;
- } else {
- pdfError(-1,"Unknown colorspace; supported are 'rgb', 'cmyk', 'white1', 'black1', 'white8', 'black8'");
-#else
- } else {
- pdfError(-1,"Unknown colorspace; supported are 'rgb', 'white1', 'black1', 'white8', 'black8'");
-#endif
- exit(1);
- }
-}
-
-std::string str_trim(const char *str,int len)
-{
- int start=strspn(str," \r\n\t");
- for (len--;len>=0;len--) {
- if (!strchr(" \r\n\t",str[len])) {
- break;
- }
- }
- len++;
- if (start>=len) {
- return std::string();
- }
- return std::string(str+start,len-start);
-}
-
-/* parse key=value */
-void parse_param(const char *str)
-{
- const char *eq=strchr(str,'=');
- if (!eq) {
- fprintf(stderr, "WARNING: ignored ijsParam without '='");
- return;
- }
- params.push_back(make_pair(str_trim(str,eq-str),str_trim(eq+1,strlen(eq+1))));
-}
-
-/* parse key1=value1,key2=value2,... */
-void parse_paramlist(const char *str)
-{
- std::string tmp;
- const char *cur=str;
- while (*cur) {
- tmp.clear();
- for (;*cur;++cur) {
- if ( (*cur=='\\')&&(cur[1]) ) {
- ++cur;
- tmp.push_back(*cur);
- } else if(*cur==',') {
- ++cur;
- break;
- } else {
- tmp.push_back(*cur);
- }
- }
- parse_param(tmp.c_str());
- }
-}
-
-void parseOpts(int argc, char **argv)
-{
- int num_options = 0;
- cups_option_t *options = 0;
-
- if (argc < 6 || argc > 7) {
- pdfError(-1,"%s job-id user title copies options [file]",
- argv[0]);
- exit(1);
- }
-
- assert(!ppd);
- ppd = ppdOpenFile(getenv("PPD"));
- ppdMarkDefaults(ppd);
-
- // handle *ijsServer, *ijsManufacturer, *ijsModel, *ijsColorspace
- ppd_attr_t *attr;
- if ((attr = ppdFindAttr(ppd,"ijsServer",0)) != 0) {
- ijsserver=attr->value;
- }
- if ((attr = ppdFindAttr(ppd,"ijsManufacturer",0)) != 0) {
- devManu=attr->value;
- }
- if ((attr = ppdFindAttr(ppd,"ijsModel",0)) != 0) {
- devModel=attr->value;
- }
- if ((attr = ppdFindAttr(ppd,"ijsColorspace",0)) != 0) {
- parse_colorspace(attr->value);
- }
- if ( (!ijsserver)||(!devManu)||(!devModel)||(colspace==NONE) ) {
- pdfError(-1,"ijsServer, ijsManufacturer, ijsModel and ijsColorspace must be specified in the PPD");
- exit(1);
- }
-
- options = NULL;
-
- num_options = cupsParseOptions(argv[5],0,&options);
-// cupsMarkOptions(ppd,num_options,options); // TODO? returns 1 on conflict
- // handle *ijsResolution, *ijsParam here
- char spec[PPD_MAX_NAME];
- for (int iA=0;iA<num_options;iA++) {
- snprintf(spec,PPD_MAX_NAME,"%s=%s",options[iA].name,options[iA].value);
- if ((attr = ppdFindAttr(ppd,"ijsResolution",spec)) != 0) {
- parse_resolution(attr->value);
- }
- if ((attr = ppdFindAttr(ppd,"ijsParams",spec)) != 0) {
- parse_paramlist(attr->value);
- }
- if (strcmp(options[iA].name,"ijsOutputFile")==0) {
- outputfile=strdup(options[iA].value);
- }
- }
- if (!resolution[0]) {
- pdfError(-1,"ijsResolution must be specified");
- exit(1);
- }
- cupsFreeOptions(num_options,options);
-}
-
-#if 0
-void parsePDFTOPDFComment(FILE *fp)
-{
- char buf[4096];
- int i;
-
- /* skip until PDF start header */
- while (fgets(buf,sizeof(buf),fp) != 0) {
- if (strncmp(buf,"%PDF",4) == 0) {
- break;
- }
- }
- for (i = 0;i < MAX_CHECK_COMMENT_LINES;i++) {
- if (fgets(buf,sizeof(buf),fp) == 0) break;
- if (strncmp(buf,"%%PDFTOPDFNumCopies",19) == 0) {
- char *p;
-
- p = strchr(buf+19,':');
- deviceCopies = atoi(p+1);
- } else if (strncmp(buf,"%%PDFTOPDFCollate",17) == 0) {
- char *p;
-
- p = strchr(buf+17,':');
- while (*p == ' ' || *p == '\t') p++;
- if (strncasecmp(p,"true",4) == 0) {
- deviceCollate = true;
- } else {
- deviceCollate = false;
- }
- }
- }
-}
-#endif
-
-int main(int argc, char *argv[]) {
- PDFDoc *doc;
- SplashOutputDev *out;
- SplashColor paperColor;
- int i;
- int npages;
- IjsClientCtx *ctx=NULL;
- int job_id;
- enum SplashColorMode cmode;
- int rowpad;
- bool reverseVideo;
-
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- setErrorCallback(::myErrorFun,NULL);
-#else
- setErrorFunction(::myErrorFun);
-#endif
- globalParams = new GlobalParams();
- parseOpts(argc, argv);
-
- if (argc == 6) {
- /* stdin */
- int fd;
- char name[BUFSIZ];
- char buf[BUFSIZ];
- int n;
-
- fd = cupsTempFd(name,sizeof(name));
- if (fd < 0) {
- pdfError(-1,"Can't create temporary file");
- exit(1);
- }
-
- /* copy stdin to the tmp file */
- while ((n = read(0,buf,BUFSIZ)) > 0) {
- if (write(fd,buf,n) != n) {
- pdfError(-1,"Can't copy stdin to temporary file");
- close(fd);
- exit(1);
- }
- }
- close(fd);
- doc = new PDFDoc(new GooString(name));
- /* remove name */
- unlink(name);
- } else {
- GooString *fileName = new GooString(argv[6]);
- /* argc == 7 filenmae is specified */
- FILE *fp;
-
- if ((fp = fopen(argv[6],"rb")) == 0) {
- pdfError(-1,"Can't open input file %s",argv[6]);
- exit(1);
- }
-// parsePDFTOPDFComment(fp); // TODO?
- fclose(fp);
- doc = new PDFDoc(fileName,NULL,NULL);
- }
-
- if (!doc->isOk()) {
- exitCode = 1;
- goto err1;
- }
-
- char tmp[100];
- tmp[99]=0;
- // ... OutputFD=stdout .. needs to be done before forking
- int outfd;
- outfd=dup(fileno(stdout));
-
-#if 0
- /* fix NumCopies, Collate ccording to PDFTOPDFComments */
- header.NumCopies = deviceCopies;
- header.Collate = deviceCollate ? CUPS_TRUE : CUPS_FALSE;
- /* fixed other values that pdftopdf handles */
- header.MirrorPrint = CUPS_FALSE;
- header.Orientation = CUPS_ORIENT_0;
-#endif
-
- job_id=atoi(argv[1]);
- ctx = ijs_invoke_server (ijsserver);
- ijs_client_open (ctx);
- ijs_client_begin_job (ctx,job_id);
- if (outputfile) {
- ijs_client_set_param(ctx,job_id,"OutputFile",outputfile,strlen(outputfile));
- } else {
- snprintf(tmp,99,"%d",outfd);
- ijs_client_set_param(ctx,job_id,"OutputFD",tmp,strlen(tmp));
- close(outfd);
- }
- ijs_client_set_param(ctx,job_id,"DeviceManufacturer",devManu,strlen(devManu));
- ijs_client_set_param(ctx,job_id,"DeviceModel",devModel,strlen(devModel));
- // TODO: get supported output-formats from ijs-server, overriding PPD
-
- /* set image's values */
- int numChan,bitsPerSample;
- const char *devName;
- reverseVideo = false;
- switch (colspace) {
- case COL_RGB:
- numChan=3;
- bitsPerSample=8;
- cmode = splashModeRGB8;
- devName = "DeviceRGB";
- rowpad = 3;
- /* set paper color white */
- paperColor[0] = 255;
- paperColor[1] = 255;
- paperColor[2] = 255;
- break;
- case COL_BLACK1:
- reverseVideo = true;
- case COL_WHITE1:
- numChan=1;
- bitsPerSample=1;
- cmode = splashModeMono1;
- devName = "DeviceGray";
- /* set paper color white */
- paperColor[0] = 255;
- rowpad = 1;
- break;
- case COL_BLACK8:
- reverseVideo = true;
- case COL_WHITE8:
- numChan=1;
- bitsPerSample=8;
- cmode = splashModeMono8;
- devName = "DeviceGray";
- /* set paper color white */
- paperColor[0] = 255;
- rowpad = 1;
- break;
-#ifdef SPLASH_CMYK
- case COL_CMYK:
- numChan=4;
- bitsPerSample=8;
- cmode = splashModeCMYK8;
- devName = "DeviceCMYK";
- /* set paper color white */
- paperColor[0] = 0;
- paperColor[1] = 0;
- paperColor[2] = 0;
- paperColor[3] = 0;
- rowpad = 4;
- break;
-#endif
- default:
- pdfError(-1,"Specified ColorSpace is not supported");
- exit(1);
- break;
- }
-
- out = new SplashOutputDev(cmode,rowpad/* row padding */,
- reverseVideo,paperColor,true
-#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR <= 30
- ,false
-#endif
- );
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- out->startDoc(doc);
-#else
- out->startDoc(doc->getXRef());
-#endif
-
- snprintf(tmp,99,"%d",numChan);
- ijs_client_set_param(ctx,job_id,"NumChan",tmp,strlen(tmp));
- snprintf(tmp,99,"%d",bitsPerSample);
- ijs_client_set_param(ctx,job_id,"BitsPerSample",tmp,strlen(tmp));
- ijs_client_set_param(ctx,job_id,"ColorSpace",devName,strlen(devName));
- snprintf(tmp,99,"%dx%d",resolution[0],resolution[1]);
- ijs_client_set_param(ctx,job_id,"Dpi",tmp,strlen(tmp));
-
- { // set the custom ijs parameters
- const int plen=params.size();
- for (i=0;i<plen;i++) {
- ijs_client_set_param(ctx,job_id,params[i].first.c_str(),params[i].second.c_str(),params[i].second.size());
- }
- }
-
- npages = doc->getNumPages();
- for (i = 1;i <= npages;i++) {
- SplashBitmap *bitmap;
- unsigned int size;
-
- doc->displayPage(out,i,resolution[0],resolution[1],0,false,false,false);
- bitmap = out->getBitmap();
-
- /* set page parameters */
- snprintf(tmp,99,"%d",bitmap->getWidth());
- ijs_client_set_param(ctx,job_id,"Width",tmp,strlen(tmp));
- snprintf(tmp,99,"%d",bitmap->getHeight());
- ijs_client_set_param(ctx,job_id,"Height",tmp,strlen(tmp));
- ijs_client_begin_page(ctx,job_id);
-
- /* write page image */
- size = bitmap->getRowSize()*bitmap->getHeight();
- int status=ijs_client_send_data_wait(ctx,job_id,(const char *)bitmap->getDataPtr(),size);
- if (status) {
- pdfError(-1,"Can't write page %d image: %d",i,status);
- exit(1);
- }
-
- status=ijs_client_end_page(ctx,job_id);
- if (status) {
- pdfError(-1,"Can't finish page %d: %d",i,status);
- exit(1);
- }
- }
- ijs_client_end_job (ctx, job_id);
- ijs_client_close (ctx);
-
- ijs_client_begin_cmd (ctx, IJS_CMD_EXIT);
- ijs_client_send_cmd_wait (ctx);
-
- delete out;
-err1:
- delete doc;
- ppdClose(ppd);
- free(outputfile);
-
-#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR < 69
- // Check for memory leaks
- Object::memCheck(stderr);
- gMemReport(stderr);
-#endif
-
- return exitCode;
-}
-
-/* replace memory allocation methods for memory check */
-/* For compatibility with g++ >= 4.7 compilers _GLIBCXX_THROW
- * should be used as a guard, otherwise use traditional definition */
-#ifndef _GLIBCXX_THROW
-#define _GLIBCXX_THROW throw
-#endif
-
-void * operator new(size_t size) _GLIBCXX_THROW (std::bad_alloc)
-{
- return gmalloc(size);
-}
-
-void operator delete(void *p) throw ()
-{
- gfree(p);
-}
-
-void * operator new[](size_t size) _GLIBCXX_THROW (std::bad_alloc)
-{
- return gmalloc(size);
-}
-
-void operator delete[](void *p) throw ()
-{
- gfree(p);
-}
diff --git a/filter/pdftoopvp/99pdftoopvp.conf b/filter/pdftoopvp/99pdftoopvp.conf
deleted file mode 100644
index 2737e1784..000000000
--- a/filter/pdftoopvp/99pdftoopvp.conf
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
-<!-- conf.d/pdftoopvp.fconf -->
-<fontconfig>
-<!-- Symbol and ZapfDingbats -->
- <alias>
- <family>ZapfDingbats</family>
- <prefer>
- <family>Dingbats</family>
- </prefer>
- </alias>
- <alias>
- <family>Symbol</family>
- <prefer>
- <family>Standard Symbols L</family>
- </prefer>
- </alias>
-</fontconfig>
diff --git a/filter/pdftoopvp/OPVPError.h b/filter/pdftoopvp/OPVPError.h
deleted file mode 100644
index 5f1b9a317..000000000
--- a/filter/pdftoopvp/OPVPError.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-
-Copyright (c) 2012, BBR Inc. All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-/*
- OPVPError.h
-*/
-#ifndef _OPVPERROR_H_
-#define _OPVPERROR_H_
-
-#include <config.h>
-#include <stdarg.h>
-#include <Error.h>
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
-#define opvpError(pos,...) error(errInternal,pos,__VA_ARGS__)
-#else
-#define opvpError(pos,...) error(pos,__VA_ARGS__)
-#endif
-
-#endif
diff --git a/filter/pdftoopvp/OPVPOutputDev.cxx b/filter/pdftoopvp/OPVPOutputDev.cxx
deleted file mode 100644
index d98697964..000000000
--- a/filter/pdftoopvp/OPVPOutputDev.cxx
+++ /dev/null
@@ -1,2003 +0,0 @@
-//
-// OPVPOutputDev.cc
-// Based SplashOutputDev.cc : Copyright 2003 Glyph & Cog, LLC
-//
-// Copyright 2005 AXE,Inc.
-//
-// 2007,2008 Modified by BBR Inc.
-//========================================================================
-
-#include <config.h>
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-
-#ifdef USE_GCC_PRAGMAS
-#pragma implementation
-#endif
-
-#include <string.h>
-#include <math.h>
-#include "goo/gfile.h"
-#include "GlobalParams.h"
-#include "OPVPError.h"
-#include "Object.h"
-#include "GfxState.h"
-#include "GfxFont.h"
-#include "Link.h"
-#include "CharCodeToUnicode.h"
-#include "FontEncodingTables.h"
-#include "fofi/FoFiTrueType.h"
-#include "splash/SplashMath.h"
-#include "CMap.h"
-#include "splash/SplashBitmap.h"
-#include "splash/SplashGlyphBitmap.h"
-#include "splash/SplashPattern.h"
-#include "splash/SplashScreen.h"
-#include "splash/SplashErrorCodes.h"
-#include "splash/SplashFontEngine.h"
-#include "splash/SplashFont.h"
-#include "splash/SplashFontFile.h"
-#include "splash/SplashFontFileID.h"
-#include "OPVPSplashPath.h"
-#include "OPVPSplashState.h"
-#include "OPRS.h"
-#include "OPVPOutputDev.h"
-
-#define SLICE_FOR_PATTERN 1000
-
-//------------------------------------------------------------------------
-// Font substitutions
-//------------------------------------------------------------------------
-
-struct SplashOutFontSubst {
- char *name;
- double mWidth;
-};
-
-//------------------------------------------------------------------------
-
-#define soutRound(x) ((int)(x + 0.5))
-
-//------------------------------------------------------------------------
-// SplashOutFontFileID
-//------------------------------------------------------------------------
-
-class SplashOutFontFileID: public SplashFontFileID {
-public:
-
- SplashOutFontFileID(const Ref *rA) { r = *rA; substIdx = -1; }
-
- ~SplashOutFontFileID() {}
-
- bool matches(SplashFontFileID *id) {
- return ((SplashOutFontFileID *)id)->r.num == r.num &&
- ((SplashOutFontFileID *)id)->r.gen == r.gen;
- }
-
- void setSubstIdx(int substIdxA) { substIdx = substIdxA; }
- int getSubstIdx() { return substIdx; }
-
-private:
-
- Ref r;
- int substIdx;
-};
-
-//------------------------------------------------------------------------
-// T3FontCache
-//------------------------------------------------------------------------
-
-struct T3FontCacheTag {
- Gushort code;
- Gushort mru; // valid bit (0x8000) and MRU index
-};
-
-class T3FontCache {
-public:
-
- T3FontCache(Ref *fontID, double m11A, double m12A,
- double m21A, double m22A,
- int glyphXA, int glyphYA, int glyphWA, int glyphHA,
- bool aa);
- ~T3FontCache();
- bool matches(Ref *idA, double m11A, double m12A,
- double m21A, double m22A)
- { return fontID.num == idA->num && fontID.gen == idA->gen &&
- m11 == m11A && m12 == m12A && m21 == m21A && m22 == m22A; }
-
- Ref fontID; // PDF font ID
- double m11, m12, m21, m22; // transform matrix
- int glyphX, glyphY; // pixel offset of glyph bitmaps
- int glyphW, glyphH; // size of glyph bitmaps, in pixels
- int glyphSize; // size of glyph bitmaps, in bytes
- int cacheSets; // number of sets in cache
- int cacheAssoc; // cache associativity (glyphs per set)
- Guchar *cacheData; // glyph pixmap cache
- T3FontCacheTag *cacheTags; // cache tags, i.e., char codes
-};
-
-T3FontCache::T3FontCache(Ref *fontIDA, double m11A, double m12A,
- double m21A, double m22A,
- int glyphXA, int glyphYA, int glyphWA, int glyphHA,
- bool aa) {
- int i;
-
- fontID = *fontIDA;
- m11 = m11A;
- m12 = m12A;
- m21 = m21A;
- m22 = m22A;
- glyphX = glyphXA;
- glyphY = glyphYA;
- glyphW = glyphWA;
- glyphH = glyphHA;
- if (aa) {
- glyphSize = glyphW * glyphH;
- } else {
- glyphSize = ((glyphW + 7) >> 3) * glyphH;
- }
- cacheAssoc = 8;
- if (glyphSize <= 256) {
- cacheSets = 8;
- } else if (glyphSize <= 512) {
- cacheSets = 4;
- } else if (glyphSize <= 1024) {
- cacheSets = 2;
- } else {
- cacheSets = 1;
- }
- cacheData = (Guchar *)gmallocn3(cacheSets , cacheAssoc , glyphSize);
- cacheTags = (T3FontCacheTag *)gmallocn3(cacheSets , cacheAssoc ,
- sizeof(T3FontCacheTag));
- for (i = 0; i < cacheSets * cacheAssoc; ++i) {
- cacheTags[i].mru = i & (cacheAssoc - 1);
- }
-}
-
-T3FontCache::~T3FontCache() {
- gfree(cacheData);
- gfree(cacheTags);
-}
-
-struct T3GlyphStack {
- Gushort code; // character code
- double x, y; // position to draw the glyph
-
- //----- cache info
- T3FontCache *cache; // font cache for the current font
- T3FontCacheTag *cacheTag; // pointer to cache tag for the glyph
- Guchar *cacheData; // pointer to cache data for the glyph
-
- //----- saved state
- SplashBitmap *origBitmap;
- OPRS *origOPRS;
- double origCTM4, origCTM5;
-
- T3GlyphStack *next; // next object on stack
-};
-
-//------------------------------------------------------------------------
-// OPVPOutputDev
-//------------------------------------------------------------------------
-
-OPVPOutputDev::OPVPOutputDev()
-{
- xref = 0;
- bitmap = 0;
- fontEngine = 0;
- nT3Fonts = 0;
- t3GlyphStack = 0;
- font = NULL;
- needFontUpdate = false;
- textClipPath = 0;
- underlayCbk = 0;
- underlayCbkData = 0;
- scaleWidth = scaleHeight = -1;
- leftMargin = 0;
- bottomMargin = 0;
- rotate = 0;
- sliceHeight = 0;
- yoffset = 0;
- oprs = 0;
-}
-
-void OPVPOutputDev::setScale(double w, double h,
- double leftMarginA, double bottomMarginA, int rotateA,
- int yoffsetA, int sliceHeightA)
-{
- scaleWidth = w;
- scaleHeight = h;
- leftMargin = leftMarginA;
- bottomMargin = bottomMarginA;
- rotate = rotateA;
- yoffset = yoffsetA;
- sliceHeight = sliceHeightA;
-}
-
-int OPVPOutputDev::init(SplashColorMode colorModeA,
- bool colorProfile,
- bool reverseVideoA,
- SplashColor paperColorA,
- const char *driverName,
- int outputFD,
- const char *printerModel,
- int nOptions,
- const char *optionKeys[],
- const char *optionVals[]) {
- int result;
-
- oprs = new OPRS();
-
- if ((result = oprs->init(driverName, outputFD, printerModel,
- nOptions,optionKeys,optionVals)) < 0) {
- opvpError(-1,"OPRS initialization fail");
- return result;
- }
- colorMode = colorModeA;
- if ((result = oprs->setColorMode(colorMode,colorProfile)) < 0) {
- opvpError(-1,"Can't setColorMode");
- return result;
- }
- reverseVideo = reverseVideoA;
- splashColorCopy(paperColor,paperColorA);
-
- return 0;
-}
-
-OPVPOutputDev::~OPVPOutputDev() {
- int i;
-
- for (i = 0; i < nT3Fonts; ++i) {
- delete t3FontCache[i];
- }
- if (fontEngine) {
- delete fontEngine;
- }
- if (oprs) {
- delete oprs;
- }
- if (bitmap) {
- delete bitmap;
- }
-}
-
-void OPVPOutputDev::startDoc(XRef *xrefA) {
- int i;
-
- xref = xrefA;
- if (fontEngine) {
- delete fontEngine;
- }
- fontEngine = new SplashFontEngine(
-#if HAVE_T1LIB_H
- globalParams->getEnableT1lib(),
-#endif
-#if HAVE_FREETYPE_FREETYPE_H || HAVE_FREETYPE_H
- globalParams->getEnableFreeType(),
- false,
- false,
-#endif
-#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR <= 30
- globalParams->getAntialias());
-#else
- false);
-#endif
- for (i = 0; i < nT3Fonts; ++i) {
- delete t3FontCache[i];
- }
- nT3Fonts = 0;
-}
-
-void OPVPOutputDev::startPage(int pageNum, GfxState *state) {
- int w, h;
-
- if (state) {
- if (scaleWidth > 0 && scaleHeight > 0) {
- double *ctm = state->getCTM();
-
- switch (rotate) {
- case 90:
- state->setCTM(0,ctm[1],ctm[2],0,leftMargin,bottomMargin-yoffset);
- break;
- case 180:
- state->setCTM(ctm[0],0,0,ctm[3],paperWidth-leftMargin,
- bottomMargin-yoffset);
- break;
- case 270:
- state->setCTM(0,ctm[1],ctm[2],0,paperWidth-leftMargin,
- -bottomMargin+paperHeight-yoffset);
- break;
- default:
- state->setCTM(ctm[0],0,0,ctm[3],leftMargin,
- -bottomMargin+paperHeight-yoffset);
- break;
- }
- state->concatCTM(scaleWidth,0.0,0.0,scaleHeight,0,0);
- }
- w = (int)(state->getPageWidth()+0.5);
- h = (int)(state->getPageHeight()+0.5);
- } else {
- w = h = 1;
- }
- oprs->initGS(colorMode,w,h,paperColor);
-
- if (underlayCbk) {
- (*underlayCbk)(underlayCbkData);
- }
-}
-
-void OPVPOutputDev::endPage() {
- oprs->endPage();
-}
-
-void OPVPOutputDev::saveState(GfxState *state) {
- oprs->saveState();
-}
-
-void OPVPOutputDev::restoreState(GfxState *state) {
- oprs->restoreState();
- needFontUpdate = true;
-}
-
-void OPVPOutputDev::updateAll(GfxState *state) {
- updateLineDash(state);
- updateLineJoin(state);
- updateLineCap(state);
- updateLineWidth(state);
- updateFlatness(state);
- updateMiterLimit(state);
- updateFillColor(state);
- updateStrokeColor(state);
- needFontUpdate = true;
-}
-
-void OPVPOutputDev::updateCTM(GfxState *state, double m11, double m12,
- double m21, double m22,
- double m31, double m32) {
- updateLineDash(state);
- updateLineJoin(state);
- updateLineCap(state);
- updateLineWidth(state);
-}
-
-void OPVPOutputDev::transLineDash(GfxState *state, SplashCoord **adash,
- int *adashLength, SplashCoord *aphase) {
- double *dashPattern;
- double dashStart;
- static SplashCoord dash[20];
- int i;
-
- state->getLineDash(&dashPattern, adashLength, &dashStart);
- if (*adashLength > 20) {
- *adashLength = 20;
- }
- for (i = 0; i < *adashLength; ++i) {
- dash[i] = (SplashCoord)state->transformWidth(dashPattern[i]);
- if (dash[i] < 1) {
- dash[i] = 1;
- }
- }
- *adash = dash;
- *aphase = (SplashCoord)state->transformWidth(dashStart);
-}
-
-void OPVPOutputDev::updateSplashLineDash(GfxState *state, Splash *splash) {
- int dashLength;
- SplashCoord *dash;
- SplashCoord phase;
-
- transLineDash(state, &dash, &dashLength, &phase);
- splash->setLineDash(dash, dashLength, phase);
-}
-
-void OPVPOutputDev::updateLineDash(GfxState *state) {
- int dashLength;
- SplashCoord *dash;
- SplashCoord phase;
-
- transLineDash(state, &dash, &dashLength, &phase);
- oprs->setLineDash(dash, dashLength, phase);
-}
-
-void OPVPOutputDev::updateFlatness(GfxState *state) {
- oprs->setFlatness(state->getFlatness());
-}
-
-void OPVPOutputDev::updateLineJoin(GfxState *state) {
- oprs->setLineJoin(state->getLineJoin());
-}
-
-void OPVPOutputDev::updateLineCap(GfxState *state) {
- oprs->setLineCap(state->getLineCap());
-}
-
-void OPVPOutputDev::updateMiterLimit(GfxState *state) {
- oprs->setMiterLimit(state->getMiterLimit());
-}
-
-void OPVPOutputDev::updateLineWidth(GfxState *state) {
- oprs->setLineWidth(state->getTransformedLineWidth());
-}
-
-void OPVPOutputDev::updateFillColor(GfxState *state) {
- GfxGray gray;
- GfxRGB rgb;
-
- state->getFillGray(&gray);
- state->getFillRGB(&rgb);
- oprs->setFillPattern(getColor(gray, &rgb));
-}
-
-void OPVPOutputDev::updateStrokeColor(GfxState *state) {
- GfxGray gray;
- GfxRGB rgb;
-
- state->getStrokeGray(&gray);
- state->getStrokeRGB(&rgb);
- oprs->setStrokePattern(getColor(gray, &rgb));
-}
-
-#ifdef SPLASH_CMYK
-SplashPattern *OPVPOutputDev::getColor(double gray, GfxRGB *rgb,
- GfxCMYK *cmyk) {
-#else
-SplashPattern *OPVPOutputDev::getColor(GfxGray gray, GfxRGB *rgb) {
-#endif
- SplashPattern *pattern;
- SplashColor color1;
- GfxColorComp r, g, b;
-
- if (reverseVideo) {
- gray = gfxColorComp1 - gray;
- r = gfxColorComp1 - rgb->r;
- g = gfxColorComp1 - rgb->g;
- b = gfxColorComp1 - rgb->b;
- } else {
- r = rgb->r;
- g = rgb->g;
- b = rgb->b;
- }
-
- pattern = NULL; // make gcc happy
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- color1[0] = colToByte(gray);
- pattern = new SplashSolidColor(color1);
- break;
- case splashModeRGB8:
- color1[0] = colToByte(r);
- color1[1] = colToByte(g);
- color1[2] = colToByte(b);
- pattern = new SplashSolidColor(color1);
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- color[0] = colToByte(cmyk->c);
- color[1] = colToByte(cmyk->m);
- color[2] = colToByte(cmyk->y);
- color[3] = colToByte(cmyk->k);
- pattern = new SplashSolidColor(color);
- break;
-#endif
- default:
- opvpError(-1, "no supported color mode");
- break;
- }
-
- return pattern;
-}
-
-void OPVPOutputDev::updateFont(GfxState *state) {
- needFontUpdate = true;
-}
-
-void OPVPOutputDev::doUpdateFont(GfxState *state) {
- GfxFont *gfxFont;
- GfxFontType fontType;
- SplashOutFontFileID *id;
- SplashFontFile *fontFile;
- SplashFontSrc *fontsrc = NULL;
- FoFiTrueType *ff;
- Ref embRef;
- Object refObj, strObj;
- GooString *fileName;
- char *tmpBuf;
- int tmpBufLen;
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- int *codeToGID;
-#else
- Gushort *codeToGID;
-#endif
- double m11, m12, m21, m22;
- int n;
- int faceIndex = 0;
- bool recreateFont = false;
-
- needFontUpdate = false;
- font = NULL;
- fileName = NULL;
- tmpBuf = NULL;
-
- if (!(gfxFont = state->getFont())) {
- goto err1;
- }
- fontType = gfxFont->getType();
- if (fontType == fontType3) {
- goto err1;
- }
-
- // check the font file cache
- id = new SplashOutFontFileID(gfxFont->getID());
- if ((fontFile = fontEngine->getFontFile(id))) {
- delete id;
-
- } else {
-
- // if there is an embedded font, write it to disk
- if (gfxFont->getEmbeddedFontID(&embRef)) {
- tmpBuf = gfxFont->readEmbFontFile(xref, &tmpBufLen);
- if (! tmpBuf)
- goto err2;
-
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- } else {
- SysFontType sftype;
- fileName = globalParams->findSystemFontFile(gfxFont,&sftype,
- &faceIndex, NULL);
- if (fileName == 0) {
- opvpError(-1, "Couldn't find a font for '%s'",
- gfxFont->getName() ? gfxFont->getName()->getCString()
- : "(unnamed)");
- goto err2;
- }
- switch (sftype) {
- case sysFontPFA:
- case sysFontPFB:
- fontType = gfxFont->isCIDFont() ? fontCIDType0 : fontType1;
- break;
- case sysFontTTF:
- case sysFontTTC:
- fontType = gfxFont->isCIDFont() ? fontCIDType2 : fontTrueType;
- break;
- }
- }
-#else
- // if there is an external font file, use it
- } else if (!(fileName = gfxFont->getExtFontFile())) {
- DisplayFontParam *dfp;
- // look for a display font mapping or a substitute font
- dfp = NULL;
- if (gfxFont->getName()) {
- dfp = globalParams->getDisplayFont(gfxFont);
- }
- if (!dfp) {
- opvpError(-1, "Couldn't find a font for '%s'",
- gfxFont->getName() ? gfxFont->getName()->getCString()
- : "(unnamed)");
- goto err2;
- }
- switch (dfp->kind) {
- case displayFontT1:
- fileName = dfp->t1.fileName;
- fontType = gfxFont->isCIDFont() ? fontCIDType0 : fontType1;
- break;
- case displayFontTT:
- fileName = dfp->tt.fileName;
- fontType = gfxFont->isCIDFont() ? fontCIDType2 : fontTrueType;
- faceIndex = dfp->tt.faceIndex;
- break;
- }
- }
-#endif
-
- fontsrc = new SplashFontSrc;
- if (fileName)
- fontsrc->setFile(fileName, false);
- else
- fontsrc->setBuf(tmpBuf, tmpBufLen, true);
-
- // load the font file
- switch (fontType) {
- case fontType1:
- if (!(fontFile = fontEngine->loadType1Font(
- id,
- fontsrc,
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- (const char **)
-#endif
- ((Gfx8BitFont *)gfxFont)->getEncoding()))) {
- opvpError(-1, "Couldn't create a font for '%s'",
- gfxFont->getName() ? gfxFont->getName()->getCString()
- : "(unnamed)");
- goto err2;
- }
- break;
- case fontType1C:
- if (!(fontFile = fontEngine->loadType1CFont(
- id,
- fontsrc,
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- (const char **)
-#endif
- ((Gfx8BitFont *)gfxFont)->getEncoding()))) {
- opvpError(-1, "Couldn't create a font for '%s'",
- gfxFont->getName() ? gfxFont->getName()->getCString()
- : "(unnamed)");
- goto err2;
- }
- break;
- case fontType1COT:
- if (!(fontFile = fontEngine->loadOpenTypeT1CFont(
- id,
- fontsrc,
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- (const char **)
-#endif
- ((Gfx8BitFont *)gfxFont)->getEncoding()))) {
- opvpError(-1, "Couldn't create a font for '%s'",
- gfxFont->getName() ? gfxFont->getName()->getCString()
- : "(unnamed)");
- goto err2;
- }
- break;
- case fontTrueTypeOT:
- case fontTrueType:
- if (fileName)
- ff = FoFiTrueType::load(fileName->getCString());
- else
- ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
- if (ff) {
- codeToGID = ((Gfx8BitFont *)gfxFont)->getCodeToGIDMap(ff);
- n = 256;
- delete ff;
- } else {
- codeToGID = NULL;
- n = 0;
- }
- if (!(fontFile = fontEngine->loadTrueTypeFont(
- id,
- fontsrc,
- codeToGID, n))) {
- opvpError(-1, "Couldn't create a font for '%s'",
- gfxFont->getName() ? gfxFont->getName()->getCString()
- : "(unnamed)");
- goto err2;
- }
- break;
- case fontCIDType0:
- case fontCIDType0C:
- if (!(fontFile = fontEngine->loadCIDFont(
- id,
- fontsrc))) {
- opvpError(-1, "Couldn't create a font for '%s'",
- gfxFont->getName() ? gfxFont->getName()->getCString()
- : "(unnamed)");
- goto err2;
- }
- break;
- case fontCIDType0COT:
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
- if (n) {
- codeToGID = (int *)gmallocn(n, sizeof(int));
- memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
- n * sizeof(int));
- } else {
- codeToGID = NULL;
- }
- if (!(fontFile = fontEngine->loadOpenTypeCFFFont(
- id,
- fontsrc,codeToGID,n))) {
-#else
- if (!(fontFile = fontEngine->loadOpenTypeCFFFont(
- id,
- fontsrc))) {
-#endif
- opvpError(-1, "Couldn't create a font for '%s'",
- gfxFont->getName() ? gfxFont->getName()->getCString()
- : "(unnamed)");
- goto err2;
- }
- break;
- case fontCIDType2OT:
- case fontCIDType2:
- codeToGID = NULL;
- n = 0;
- if (((GfxCIDFont *)gfxFont)->getCIDToGID()) {
- n = ((GfxCIDFont *)gfxFont)->getCIDToGIDLen();
- if (n) {
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- codeToGID = (int *)gmallocn(n, sizeof(int));
- memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
- n * sizeof(int));
-#else
- codeToGID = (Gushort *)gmallocn(n, sizeof(Gushort));
- memcpy(codeToGID, ((GfxCIDFont *)gfxFont)->getCIDToGID(),
- n * sizeof(Gushort));
-#endif
- }
- } else {
- if (fileName)
- ff = FoFiTrueType::load(fileName->getCString());
- else
- ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
- if (! ff)
- goto err2;
- codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
- delete ff;
- }
- if (!(fontFile = fontEngine->loadTrueTypeFont(
- id,
- fontsrc,
- codeToGID, n, faceIndex))) {
- opvpError(-1, "Couldn't create a font for '%s'",
- gfxFont->getName() ? gfxFont->getName()->getCString()
- : "(unnamed)");
- goto err2;
- }
- break;
- default:
- // this shouldn't happen
- goto err2;
- }
- fontFile->doAdjustMatrix = true;
- }
-
- // get the font matrix
- state->getFontTransMat(&m11, &m12, &m21, &m22);
- m11 *= state->getHorizScaling();
- m12 *= state->getHorizScaling();
-
- // create the scaled font
- fontMat[0] = m11; fontMat[1] = m12;
- fontMat[2] = m21; fontMat[3] = m22;
- font = fontEngine->getFont(fontFile, fontMat, oprs->getMatrix());
-
- // for substituted fonts: adjust the font matrix -- compare the
- // width of 'm' in the original font and the substituted font
- if (fontFile->doAdjustMatrix && !gfxFont->isCIDFont()) {
- double w1, w2;
- CharCode code;
- char *name;
- for (code = 0; code < 256; ++code) {
- if ((name = ((Gfx8BitFont *)gfxFont)->getCharName(code)) &&
- name[0] == 'm' && name[1] == '\0') {
- break;
- }
- }
- if (code < 256) {
- w1 = ((Gfx8BitFont *)gfxFont)->getWidth(code);
- w2 = font->getGlyphAdvance(code);
- if (!gfxFont->isSymbolic() && w2 > 0) {
- // if real font is substantially narrower than substituted
- // font, reduce the font size accordingly
- if (w1 > 0.01 && w1 < 0.9 * w2) {
- w1 /= w2;
- m11 *= w1;
- m21 *= w1;
- recreateFont = true;
- }
- }
- }
- }
-
- if (recreateFont)
- {
- fontMat[0] = m11; fontMat[1] = m12;
- fontMat[2] = m21; fontMat[3] = m22;
- font = fontEngine->getFont(fontFile, fontMat, oprs->getMatrix());
- }
-
- if (fontsrc && !fontsrc->isFile)
- fontsrc->unref();
- return;
-
- err2:
- delete id;
- err1:
- if (fontsrc && !fontsrc->isFile)
- fontsrc->unref();
- return;
-}
-
-void OPVPOutputDev::stroke(GfxState *state) {
- OPVPSplashPath *path;
- GfxColorSpace *cs;
-
- /* check None separate color */
- if ((cs = state->getStrokeColorSpace()) == NULL) return;
- if (cs->getMode() == csSeparation) {
- GooString *name;
-
- name = (dynamic_cast<GfxSeparationColorSpace *>(cs))->getName();
- if (name == NULL) return;
- if (name->cmp("None") == 0) return;
- }
-
- path = convertPath(state, state->getPath());
- oprs->stroke(path);
- delete path;
-}
-
-void OPVPOutputDev::fill(GfxState *state) {
- OPVPSplashPath *path;
- GfxColorSpace *cs;
-
- /* check None separate color */
- if ((cs = state->getFillColorSpace()) == NULL) return;
- if (cs->getMode() == csSeparation) {
- GooString *name;
-
- name = (dynamic_cast<GfxSeparationColorSpace *>(cs))->getName();
- if (name == NULL) return;
- if (name->cmp("None") == 0) return;
- }
-
- path = convertPath(state, state->getPath());
- oprs->fill(path, false);
- delete path;
-}
-
-void OPVPOutputDev::eoFill(GfxState *state) {
- OPVPSplashPath *path;
- GfxColorSpace *cs;
-
- /* check None separate color */
- if ((cs = state->getFillColorSpace()) == NULL) return;
- if (cs->getMode() == csSeparation) {
- GooString *name;
-
- name = (dynamic_cast<GfxSeparationColorSpace *>(cs))->getName();
- if (name == NULL) return;
- if (name->cmp("None") == 0) return;
- }
-
- path = convertPath(state, state->getPath());
- oprs->fill(path, true);
- delete path;
-}
-
-void OPVPOutputDev::clip(GfxState *state) {
- OPVPSplashPath *path;
-
- path = convertPath(state, state->getPath());
- oprs->clipToPath(path, false);
- delete path;
-}
-
-void OPVPOutputDev::eoClip(GfxState *state) {
- OPVPSplashPath *path;
-
- path = convertPath(state, state->getPath());
- oprs->clipToPath(path, true);
- delete path;
-}
-
-OPVPSplashPath *OPVPOutputDev::bitmapToPath(SplashBitmap *bitmapA,
- int width, int height)
-{
- int x,y;
- OPVPSplashPath *path;
- int x1, x2;
- SplashColor pix;
-
- path = new OPVPSplashPath();
-
- for (y = 0;y < height;y++) {
- for (x = 0;x < width;x++) {
- bitmapA->getPixel(x,y,pix);
- if (pix[0] == 0) {
- /* start */
- x1 = x;
- for (x++;x < width;x++) {
- bitmapA->getPixel(x,y,pix);
- if (pix[0] != 0) {
- /* end */
- break;
- }
- }
- x2 = x-1;
- path->moveTo(x1,y);
- path->lineTo(x2,y);
- path->lineTo(x2,(y+1));
- path->lineTo(x1,(y+1));
- path->close();
- }
- }
- }
- return path;
-}
-
-void OPVPOutputDev::clipToStrokePath(GfxState *state) {
- SplashBitmap *tbitmap;
- Splash *tsplash;
- SplashPath *spath;
- OPVPSplashPath *path, *path2;
-
- // use splash for makeStrokePath
- // create dummy bitmap for creating splash
- tbitmap = new SplashBitmap(1, 1, 1, splashModeMono1, false);
- tsplash = new Splash(tbitmap, false);
- // set line parameters
- // except colors
- updateSplashLineDash(state, tsplash);
- tsplash->setLineJoin(state->getLineJoin());
- tsplash->setLineCap(state->getLineCap());
- tsplash->setMiterLimit(state->getMiterLimit());
- tsplash->setLineWidth(state->getTransformedLineWidth());
-
- path = convertPath(state, state->getPath());
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- spath = tsplash->makeStrokePath(path,0);
-#else
- spath = tsplash->makeStrokePath(path);
-#endif
- path2 = new OPVPSplashPath(spath);
- delete spath;
- delete path;
- delete tsplash;
- delete tbitmap;
- oprs->clipToPath(path2, false);
- delete path2;
-}
-
-OPVPSplashPath *OPVPOutputDev::convertPath(GfxState *state, GfxPath *path) {
- OPVPSplashPath *sPath;
- GfxSubpath *subpath;
- double x1, y1, x2, y2, x3, y3;
- int i, j;
-
- sPath = new OPVPSplashPath();
- for (i = 0; i < path->getNumSubpaths(); ++i) {
- subpath = path->getSubpath(i);
- if (subpath->getNumPoints() > 0) {
- state->transform(subpath->getX(0), subpath->getY(0), &x1, &y1);
- sPath->moveTo((SplashCoord)x1, (SplashCoord)y1);
- j = 1;
- while (j < subpath->getNumPoints()) {
- if (subpath->getCurve(j)) {
- state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1);
- state->transform(subpath->getX(j+1), subpath->getY(j+1), &x2, &y2);
- state->transform(subpath->getX(j+2), subpath->getY(j+2), &x3, &y3);
- sPath->curveTo((SplashCoord)x1, (SplashCoord)y1,
- (SplashCoord)x2, (SplashCoord)y2,
- (SplashCoord)x3, (SplashCoord)y3);
- j += 3;
- } else {
- state->transform(subpath->getX(j), subpath->getY(j), &x1, &y1);
- sPath->lineTo((SplashCoord)x1, (SplashCoord)y1);
- ++j;
- }
- }
- if (subpath->isClosed()) {
- sPath->close();
- }
- }
- }
- return sPath;
-}
-
-void OPVPOutputDev::drawChar(GfxState *state, double x, double y,
- double dx, double dy,
- double originX, double originY,
- CharCode code, int nBytes,
- Unicode *u, int uLen) {
- double x1, y1;
- SplashPath *spath;
- OPVPSplashPath *path;
- int render;
-
- // check for invisible text -- this is used by Acrobat Capture
- render = state->getRender();
- if (render == 3) {
- return;
- }
-
- if (needFontUpdate) {
- doUpdateFont(state);
- }
- if (!font) {
- return;
- }
-
- x -= originX;
- y -= originY;
- state->transform(x,y,&x1,&y1);
-
- // fill
- if (!(render & 1)) {
- oprs->fillChar((SplashCoord)x1, (SplashCoord)y1, code, font, u, fontMat);
- }
-
- // stroke
- if ((render & 3) == 1 || (render & 3) == 2) {
- if ((spath = font->getGlyphPath(code))) {
- path = new OPVPSplashPath(spath);
- delete spath;
- path->closeAllSubPath();
- path->offset((SplashCoord)x1, (SplashCoord)y1);
- oprs->stroke(path);
- delete path;
- } else {
- opvpError(-1,"No glyph outline infomation");
- }
- }
-
- // clip
- if (render & 4) {
- if ((spath = font->getGlyphPath(code)) != NULL) {
- path = new OPVPSplashPath(spath);
- delete spath;
- path->offset((SplashCoord)x1, (SplashCoord)y1);
- if (textClipPath) {
- textClipPath->append(path);
- delete path;
- } else {
- textClipPath = path;
- }
- } else {
- opvpError(-1,"No glyph outline infomation");
- }
- }
-}
-
-bool OPVPOutputDev::beginType3Char(GfxState *state, double x, double y,
- double dx, double dy,
- CharCode code, Unicode *u, int uLen) {
- /* In a vector mode, cache is not needed */
- return false;
-}
-
-void OPVPOutputDev::endType3Char(GfxState *state) {
- /* In a vector mode, cache is not needed */
- /* do nothing */
-}
-
-void OPVPOutputDev::type3D0(GfxState *state, double wx, double wy) {
- /* In a vector mode, cache is not needed */
- /* do nothing */
-}
-
-void OPVPOutputDev::type3D1(GfxState *state, double wx, double wy,
- double llx, double lly, double urx, double ury) {
-}
-
-void OPVPOutputDev::drawType3Glyph(T3FontCache *t3Font,
- T3FontCacheTag *tag, Guchar *data,
- double x, double y) {
- SplashGlyphBitmap glyph;
-
- glyph.x = -t3Font->glyphX;
- glyph.y = -t3Font->glyphY;
- glyph.w = t3Font->glyphW;
- glyph.h = t3Font->glyphH;
- glyph.aa = colorMode != splashModeMono1;
- glyph.data = data;
- glyph.freeData = false;
- oprs->fillGlyph((SplashCoord)x, (SplashCoord)y, &glyph);
-}
-
-void OPVPOutputDev::endTextObject(GfxState *state) {
- if (textClipPath) {
- oprs->clipToPath(textClipPath, false);
- delete textClipPath;
- textClipPath = NULL;
- }
-}
-
-struct SplashOutImageMaskData {
- ImageStream *imgStr;
- bool invert;
- int width, height, y;
-};
-
-bool OPVPOutputDev::imageMaskSrc(void *data, SplashColorPtr line) {
- SplashOutImageMaskData *imgMaskData = (SplashOutImageMaskData *)data;
- Guchar *p;
- SplashColorPtr q;
- int x;
-
- if (imgMaskData->y == imgMaskData->height) {
- return false;
- }
- for (x = 0, p = imgMaskData->imgStr->getLine(), q = line;
- x < imgMaskData->width;
- ++x) {
- *q++ = *p++ ^ imgMaskData->invert;
- }
- ++imgMaskData->y;
- return true;
-}
-
-void OPVPOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
- int width, int height, bool invert,
- bool interpolate,
- bool inlineImg) {
- double *ctm;
- SplashCoord mat[6];
- SplashOutImageMaskData imgMaskData;
-
- ctm = state->getCTM();
- mat[0] = ctm[0];
- mat[1] = ctm[1];
- mat[2] = -ctm[2];
- mat[3] = -ctm[3];
- mat[4] = ctm[2] + ctm[4];
- mat[5] = ctm[3] + ctm[5];
-
- imgMaskData.imgStr = new ImageStream(str, width, 1, 1);
- imgMaskData.imgStr->reset();
- imgMaskData.invert = invert ? 0 : 1;
- imgMaskData.width = width;
- imgMaskData.height = height;
- imgMaskData.y = 0;
-
- oprs->fillImageMask(&imageMaskSrc, &imgMaskData, width, height, mat,
- t3GlyphStack != NULL);
- if (inlineImg) {
- while (imgMaskData.y < height) {
- imgMaskData.imgStr->getLine();
- ++imgMaskData.y;
- }
- }
-
- delete imgMaskData.imgStr;
-}
-
-struct SplashOutImageData {
- ImageStream *imgStr;
- GfxImageColorMap *colorMap;
- SplashColorPtr lookup;
- int *maskColors;
- SplashColorMode colorMode;
- int width, height, y;
-};
-
-bool OPVPOutputDev::imageSrc(void *data, SplashColorPtr line,
- Guchar *alphaLine)
-{
- SplashOutImageData *imgData = (SplashOutImageData *)data;
- Guchar *p;
- SplashColorPtr q, col;
- GfxRGB rgb;
- GfxGray gray;
-#if SPLASH_CMYK
- GfxCMYK cmyk;
-#endif
- int nComps, x;
-
- if (imgData->y == imgData->height) {
- return false;
- }
-
- nComps = imgData->colorMap->getNumPixelComps();
-
- if (imgData->lookup) {
- switch (imgData->colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- for (x = 0, p = imgData->imgStr->getLine(), q = line;
- x < imgData->width;
- ++x, ++p) {
- *q++ = imgData->lookup[*p];
- }
- break;
- case splashModeRGB8:
- case splashModeBGR8:
- for (x = 0, p = imgData->imgStr->getLine(), q = line;
- x < imgData->width;
- ++x, ++p) {
- col = &imgData->lookup[3 * *p];
- *q++ = col[0];
- *q++ = col[1];
- *q++ = col[2];
- }
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- for (x = 0, p = imgData->imgStr->getLine(), q = line;
- x < imgData->width;
- ++x, ++p) {
- col = &imgData->lookup[4 * *p];
- *q++ = col[0];
- *q++ = col[1];
- *q++ = col[2];
- *q++ = col[3];
- }
- break;
-#endif
- default:
- //~ unimplemented
- break;
- }
- } else {
- switch (imgData->colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- for (x = 0, p = imgData->imgStr->getLine(), q = line;
- x < imgData->width;
- ++x, p += nComps) {
- imgData->colorMap->getGray(p, &gray);
- *q++ = colToByte(gray);
- }
- break;
- case splashModeRGB8:
- for (x = 0, p = imgData->imgStr->getLine(), q = line;
- x < imgData->width;
- ++x, p += nComps) {
- imgData->colorMap->getRGB(p, &rgb);
- *q++ = colToByte(rgb.r);
- *q++ = colToByte(rgb.g);
- *q++ = colToByte(rgb.b);
- }
- break;
- case splashModeBGR8:
- for (x = 0, p = imgData->imgStr->getLine(), q = line;
- x < imgData->width;
- ++x, p += nComps) {
- imgData->colorMap->getRGB(p, &rgb);
- *q++ = colToByte(rgb.b);
- *q++ = colToByte(rgb.g);
- *q++ = colToByte(rgb.r);
- }
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- for (x = 0, p = imgData->imgStr->getLine(), q = line;
- x < imgData->width;
- ++x, p += nComps) {
- imgData->colorMap->getCMYK(p, &cmyk);
- *q++ = colToByte(cmyk.c);
- *q++ = colToByte(cmyk.m);
- *q++ = colToByte(cmyk.y);
- *q++ = colToByte(cmyk.k);
- }
- break;
-#endif
- default:
- //~ unimplemented
- break;
- }
- }
-
- ++imgData->y;
- return true;
-}
-
-bool OPVPOutputDev::alphaImageSrc(void *data, SplashColorPtr line,
- Guchar *alphaLine) {
- SplashOutImageData *imgData = (SplashOutImageData *)data;
- Guchar *p;
- SplashColorPtr q, col;
- GfxRGB rgb;
- GfxGray gray;
-#if SPLASH_CMYK
- GfxCMYK cmyk;
-#endif
- Guchar alpha;
- int nComps, x, i;
-
- if (imgData->y == imgData->height) {
- return false;
- }
-
- nComps = imgData->colorMap->getNumPixelComps();
-
- for (x = 0, p = imgData->imgStr->getLine(), q = line;
- x < imgData->width;
- ++x, p += nComps) {
- alpha = 0;
- for (i = 0; i < nComps; ++i) {
- if (p[i] < imgData->maskColors[2*i] ||
- p[i] > imgData->maskColors[2*i+1]) {
- alpha = 0xff;
- break;
- }
- }
- if (imgData->lookup) {
- switch (imgData->colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- *q++ = alpha;
- *q++ = imgData->lookup[*p];
- break;
- case splashModeRGB8:
- *q++ = alpha;
- col = &imgData->lookup[3 * *p];
- *q++ = col[0];
- *q++ = col[1];
- *q++ = col[2];
- break;
- case splashModeBGR8:
- col = &imgData->lookup[3 * *p];
- *q++ = col[0];
- *q++ = col[1];
- *q++ = col[2];
- *q++ = alpha;
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- *q++ = alpha;
- col = &imgData->lookup[4 * *p];
- *q++ = col[0];
- *q++ = col[1];
- *q++ = col[2];
- *q++ = col[3];
- break;
-#endif
- default:
- //~ unimplemented
- break;
- }
- } else {
- switch (imgData->colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- imgData->colorMap->getGray(p, &gray);
- *q++ = alpha;
- *q++ = colToByte(gray);
- break;
- case splashModeRGB8:
- imgData->colorMap->getRGB(p, &rgb);
- *q++ = alpha;
- *q++ = colToByte(rgb.r);
- *q++ = colToByte(rgb.g);
- *q++ = colToByte(rgb.b);
- break;
- case splashModeBGR8:
- imgData->colorMap->getRGB(p, &rgb);
- *q++ = colToByte(rgb.b);
- *q++ = colToByte(rgb.g);
- *q++ = colToByte(rgb.r);
- *q++ = alpha;
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- imgData->colorMap->getCMYK(p, &cmyk);
- *q++ = alpha;
- *q++ = colToByte(cmyk.c);
- *q++ = colToByte(cmyk.m);
- *q++ = colToByte(cmyk.y);
- *q++ = colToByte(cmyk.k);
- break;
-#endif
- default:
- //~ unimplemented
- break;
- }
- }
- }
-
- ++imgData->y;
- return true;
-}
-
-void OPVPOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
- int width, int height,
- GfxImageColorMap *colorMap,
- bool interpolate,
- int *maskColors, bool inlineImg) {
- double *ctm;
- SplashCoord mat[6];
- SplashOutImageData imgData;
- SplashColorMode srcMode;
- SplashImageSource src;
- GfxGray gray;
- GfxRGB rgb;
-#if SPLASH_CMYK
- GfxCMYK cmyk;
-#endif
- Guchar pix;
- int n, i;
-
- ctm = state->getCTM();
- mat[0] = ctm[0];
- mat[1] = ctm[1];
- mat[2] = -ctm[2];
- mat[3] = -ctm[3];
- mat[4] = ctm[2] + ctm[4];
- mat[5] = ctm[3] + ctm[5];
-
- imgData.imgStr = new ImageStream(str, width,
- colorMap->getNumPixelComps(),
- colorMap->getBits());
- imgData.imgStr->reset();
- imgData.colorMap = colorMap;
- imgData.maskColors = maskColors;
- imgData.colorMode = colorMode;
- imgData.width = width;
- imgData.height = height;
- imgData.y = 0;
-
- // special case for one-channel (monochrome/gray/separation) images:
- // build a lookup table here
- imgData.lookup = NULL;
- if (colorMap->getNumPixelComps() == 1) {
- n = 1 << colorMap->getBits();
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,1);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getGray(&pix, &gray);
- imgData.lookup[i] = colToByte(gray);
- }
- break;
- case splashModeRGB8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,3);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getRGB(&pix, &rgb);
- imgData.lookup[3*i] = colToByte(rgb.r);
- imgData.lookup[3*i+1] = colToByte(rgb.g);
- imgData.lookup[3*i+2] = colToByte(rgb.b);
- }
- break;
- case splashModeBGR8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,3);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getRGB(&pix, &rgb);
- imgData.lookup[3*i] = colToByte(rgb.b);
- imgData.lookup[3*i+1] = colToByte(rgb.g);
- imgData.lookup[3*i+2] = colToByte(rgb.r);
- }
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,4);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getCMYK(&pix, &cmyk);
- imgData.lookup[4*i] = colToByte(cmyk.c);
- imgData.lookup[4*i+1] = colToByte(cmyk.m);
- imgData.lookup[4*i+2] = colToByte(cmyk.y);
- imgData.lookup[4*i+3] = colToByte(cmyk.k);
- }
- break;
-#endif
- default:
- //~ unimplemented
- break;
- }
- }
-
- if (colorMode == splashModeMono1) {
- srcMode = splashModeMono8;
- } else {
- srcMode = colorMode;
- }
- src = maskColors ? &alphaImageSrc : &imageSrc;
- oprs->drawImage(src, &imgData, srcMode, maskColors ? true : false,
- width, height, mat);
- if (inlineImg) {
- while (imgData.y < height) {
- imgData.imgStr->getLine();
- ++imgData.y;
- }
- }
-
- gfree(imgData.lookup);
- delete imgData.imgStr;
- str->close();
-}
-
-struct SplashOutMaskedImageData {
- ImageStream *imgStr;
- GfxImageColorMap *colorMap;
- SplashBitmap *mask;
- SplashColorPtr lookup;
- SplashColorMode colorMode;
- int width, height, y;
-};
-
-bool OPVPOutputDev::maskedImageSrc(void *data, SplashColorPtr line,
- Guchar *alphaLine) {
- SplashOutMaskedImageData *imgData = (SplashOutMaskedImageData *)data;
- Guchar *p;
- SplashColor maskColor;
- SplashColorPtr q, col;
- GfxRGB rgb;
- GfxGray gray;
-#if SPLASH_CMYK
- GfxCMYK cmyk;
-#endif
- Guchar alpha;
- int nComps, x;
-
- if (imgData->y == imgData->height) {
- return false;
- }
-
- nComps = imgData->colorMap->getNumPixelComps();
-
- for (x = 0, p = imgData->imgStr->getLine(), q = line;
- x < imgData->width;
- ++x, p += nComps) {
- imgData->mask->getPixel(x, imgData->y, maskColor);
- alpha = maskColor[0] ? 0xff : 0x00;
- if (imgData->lookup) {
- switch (imgData->colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- *q++ = alpha;
- *q++ = imgData->lookup[*p];
- break;
- case splashModeRGB8:
- *q++ = alpha;
- col = &imgData->lookup[3 * *p];
- *q++ = col[0];
- *q++ = col[1];
- *q++ = col[2];
- break;
- case splashModeBGR8:
- col = &imgData->lookup[3 * *p];
- *q++ = col[0];
- *q++ = col[1];
- *q++ = col[2];
- *q++ = alpha;
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- *q++ = alpha;
- col = &imgData->lookup[4 * *p];
- *q++ = col[0];
- *q++ = col[1];
- *q++ = col[2];
- *q++ = col[3];
- break;
-#endif
- default:
- //~ unimplemented
- break;
- }
- } else {
- switch (imgData->colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- imgData->colorMap->getGray(p, &gray);
- *q++ = alpha;
- *q++ = colToByte(gray);
- break;
- case splashModeRGB8:
- imgData->colorMap->getRGB(p, &rgb);
- *q++ = alpha;
- *q++ = colToByte(rgb.r);
- *q++ = colToByte(rgb.g);
- *q++ = colToByte(rgb.b);
- break;
- case splashModeBGR8:
- imgData->colorMap->getRGB(p, &rgb);
- *q++ = colToByte(rgb.b);
- *q++ = colToByte(rgb.g);
- *q++ = colToByte(rgb.r);
- *q++ = alpha;
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- imgData->colorMap->getCMYK(p, &cmyk);
- *q++ = alpha;
- *q++ = colToByte(cmyk.c);
- *q++ = colToByte(cmyk.m);
- *q++ = colToByte(cmyk.y);
- *q++ = colToByte(cmyk.k);
- break;
-#endif
- default:
- //~ unimplemented
- break;
- }
- }
- }
-
- ++imgData->y;
- return true;
-}
-
-void OPVPOutputDev::drawMaskedImage(GfxState *state, Object *ref,
- Stream *str, int width, int height,
- GfxImageColorMap *colorMap,
- bool interpolate,
- Stream *maskStr, int maskWidth,
- int maskHeight, bool maskInvert,
- bool maskInterpolate) {
- double *ctm;
- SplashCoord mat[6];
- SplashOutMaskedImageData imgData;
- SplashOutImageMaskData imgMaskData;
- SplashColorMode srcMode;
- SplashBitmap *maskBitmap;
- Splash *maskSplash;
- SplashColor maskColor;
- GfxGray gray;
- GfxRGB rgb;
-#if SPLASH_CMYK
- GfxCMYK cmyk;
-#endif
- Guchar pix;
- int n, i;
-
- //----- scale the mask image to the same size as the source image
-
- mat[0] = (SplashCoord)width;
- mat[1] = 0;
- mat[2] = 0;
- mat[3] = (SplashCoord)height;
- mat[4] = 0;
- mat[5] = 0;
- imgMaskData.imgStr = new ImageStream(maskStr, maskWidth, 1, 1);
- imgMaskData.imgStr->reset();
- imgMaskData.invert = maskInvert ? 0 : 1;
- imgMaskData.width = maskWidth;
- imgMaskData.height = maskHeight;
- imgMaskData.y = 0;
- maskBitmap = new SplashBitmap(width, height, 1, splashModeMono1, false);
- maskSplash = new Splash(maskBitmap, false);
- maskColor[0] = 0;
- maskSplash->clear(maskColor);
- maskColor[0] = 1;
- maskSplash->setFillPattern(new SplashSolidColor(maskColor));
- maskSplash->fillImageMask(&imageMaskSrc, &imgMaskData,
- maskWidth, maskHeight, mat, false);
- delete imgMaskData.imgStr;
- maskStr->close();
- delete maskSplash;
-
- //----- draw the source image
-
- ctm = state->getCTM();
- mat[0] = ctm[0];
- mat[1] = ctm[1];
- mat[2] = -ctm[2];
- mat[3] = -ctm[3];
- mat[4] = ctm[2] + ctm[4];
- mat[5] = ctm[3] + ctm[5];
-
- imgData.imgStr = new ImageStream(str, width,
- colorMap->getNumPixelComps(),
- colorMap->getBits());
- imgData.imgStr->reset();
- imgData.colorMap = colorMap;
- imgData.mask = maskBitmap;
- imgData.colorMode = colorMode;
- imgData.width = width;
- imgData.height = height;
- imgData.y = 0;
-
- // special case for one-channel (monochrome/gray/separation) images:
- // build a lookup table here
- imgData.lookup = NULL;
- if (colorMap->getNumPixelComps() == 1) {
- n = 1 << colorMap->getBits();
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,1);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getGray(&pix, &gray);
- imgData.lookup[i] = colToByte(gray);
- }
- break;
- case splashModeRGB8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,3);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getRGB(&pix, &rgb);
- imgData.lookup[3*i] = colToByte(rgb.r);
- imgData.lookup[3*i+1] = colToByte(rgb.g);
- imgData.lookup[3*i+2] = colToByte(rgb.b);
- }
- break;
- case splashModeBGR8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,3);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getRGB(&pix, &rgb);
- imgData.lookup[3*i] = colToByte(rgb.b);
- imgData.lookup[3*i+1] = colToByte(rgb.g);
- imgData.lookup[3*i+2] = colToByte(rgb.r);
- }
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,4);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getCMYK(&pix, &cmyk);
- imgData.lookup[4*i] = colToByte(cmyk.c);
- imgData.lookup[4*i+1] = colToByte(cmyk.m);
- imgData.lookup[4*i+2] = colToByte(cmyk.y);
- imgData.lookup[4*i+3] = colToByte(cmyk.k);
- }
- break;
-#endif
- default:
- //~ unimplemented
- break;
- }
- }
-
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- srcMode = splashModeMono8;
- break;
- case splashModeRGB8:
- srcMode = splashModeRGB8;
- break;
- case splashModeBGR8:
- srcMode = splashModeBGR8;
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- srcMode = splashModeCMYK8;
- break;
-#endif
- default:
- //~ unimplemented
- srcMode = splashModeRGB8;
- break;
- }
- oprs->drawImage(&maskedImageSrc, &imgData, srcMode, true,
- width, height, mat);
-
- delete maskBitmap;
- gfree(imgData.lookup);
- delete imgData.imgStr;
- str->close();
-}
-
-void OPVPOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref,
- Stream *str, int width, int height,
- GfxImageColorMap *colorMap,
- bool interpolate,
- Stream *maskStr,
- int maskWidth, int maskHeight,
- GfxImageColorMap *maskColorMap,
- bool maskInterpolate) {
- double *ctm;
- SplashCoord mat[6];
- SplashOutImageData imgData;
- SplashOutImageData imgMaskData;
- SplashColorMode srcMode;
- SplashBitmap *maskBitmap;
- Splash *maskSplash;
- SplashColor maskColor;
- GfxGray gray;
- GfxRGB rgb;
-#if SPLASH_CMYK
- GfxCMYK cmyk;
-#endif
- Guchar pix;
- int n, i;
-
- ctm = state->getCTM();
- mat[0] = ctm[0];
- mat[1] = ctm[1];
- mat[2] = -ctm[2];
- mat[3] = -ctm[3];
- mat[4] = ctm[2] + ctm[4];
- mat[5] = ctm[3] + ctm[5];
-
- //----- set up the soft mask
-
- imgMaskData.imgStr = new ImageStream(maskStr, maskWidth,
- maskColorMap->getNumPixelComps(),
- maskColorMap->getBits());
- imgMaskData.imgStr->reset();
- imgMaskData.colorMap = maskColorMap;
- imgMaskData.maskColors = NULL;
- imgMaskData.colorMode = splashModeMono8;
- imgMaskData.width = maskWidth;
- imgMaskData.height = maskHeight;
- imgMaskData.y = 0;
- n = 1 << maskColorMap->getBits();
- imgMaskData.lookup = (SplashColorPtr)gmallocn(n,1);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- maskColorMap->getGray(&pix, &gray);
- imgMaskData.lookup[i] = colToByte(gray);
- }
- maskBitmap = new SplashBitmap(maskWidth,maskHeight,
- 1, splashModeMono8, false);
- maskSplash = new Splash(maskBitmap, false);
- maskColor[0] = 0;
- maskSplash->clear(maskColor);
-#if POPPLER_VERSION_MAJOR <= 0 && (POPPLER_VERSION_MINOR <= 20 || (POPPLER_VERSION_MINOR == 21 && POPPLER_VERSION_MICRO <= 2))
- maskSplash->drawImage(&imageSrc, &imgMaskData,
- splashModeMono8, false, maskWidth, maskHeight, mat);
-#elif POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR <= 33
- maskSplash->drawImage(&imageSrc, &imgMaskData,
- splashModeMono8, false, maskWidth, maskHeight,
- mat,false);
-#else
- maskSplash->drawImage(&imageSrc, 0, &imgMaskData,
- splashModeMono8, false, maskWidth, maskHeight,
- mat,false);
-#endif
- delete imgMaskData.imgStr;
- maskStr->close();
- gfree(imgMaskData.lookup);
- delete maskSplash;
- oprs->setSoftMask(maskBitmap);
-
- //----- draw the source image
-
- imgData.imgStr = new ImageStream(str, width,
- colorMap->getNumPixelComps(),
- colorMap->getBits());
- imgData.imgStr->reset();
- imgData.colorMap = colorMap;
- imgData.maskColors = NULL;
- imgData.colorMode = colorMode;
- imgData.width = width;
- imgData.height = height;
- imgData.y = 0;
-
- // special case for one-channel (monochrome/gray/separation) images:
- // build a lookup table here
- imgData.lookup = NULL;
- if (colorMap->getNumPixelComps() == 1) {
- n = 1 << colorMap->getBits();
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,1);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getGray(&pix, &gray);
- imgData.lookup[i] = colToByte(gray);
- }
- break;
- case splashModeRGB8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,3);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getRGB(&pix, &rgb);
- imgData.lookup[3*i] = colToByte(rgb.r);
- imgData.lookup[3*i+1] = colToByte(rgb.g);
- imgData.lookup[3*i+2] = colToByte(rgb.b);
- }
- break;
- case splashModeBGR8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,3);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getRGB(&pix, &rgb);
- imgData.lookup[3*i] = colToByte(rgb.b);
- imgData.lookup[3*i+1] = colToByte(rgb.g);
- imgData.lookup[3*i+2] = colToByte(rgb.r);
- }
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- imgData.lookup = (SplashColorPtr)gmallocn(n,4);
- for (i = 0; i < n; ++i) {
- pix = (Guchar)i;
- colorMap->getCMYK(&pix, &cmyk);
- imgData.lookup[4*i] = colToByte(cmyk.c);
- imgData.lookup[4*i+1] = colToByte(cmyk.m);
- imgData.lookup[4*i+2] = colToByte(cmyk.y);
- imgData.lookup[4*i+3] = colToByte(cmyk.k);
- }
- break;
-#endif
- default:
- //~ unimplemented
- break;
- }
- }
-
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- srcMode = splashModeMono8;
- break;
- case splashModeRGB8:
- srcMode = splashModeRGB8;
- break;
- case splashModeBGR8:
- srcMode = splashModeBGR8;
- break;
-#if SPLASH_CMYK
- case splashModeCMYK8:
- srcMode = splashModeCMYK8;
- break;
-#endif
- default:
- //~ unimplemented
- srcMode = splashModeRGB8;
- break;
- }
- oprs->drawImage(&imageSrc, &imgData, srcMode, false, width, height, mat);
-
- oprs->setSoftMask(NULL);
- gfree(imgData.lookup);
- delete imgData.imgStr;
- str->close();
-}
-
-int OPVPOutputDev::getBitmapWidth() {
- return bitmap->getWidth();
-}
-
-int OPVPOutputDev::getBitmapHeight() {
- return bitmap->getHeight();
-}
-
-void OPVPOutputDev::xorRectangle(int x0, int y0, int x1, int y1,
- SplashPattern *pattern) {
- /* no need in printing */
-}
-
-void OPVPOutputDev::setFillColor(int r, int g, int b) {
- GfxRGB rgb;
- GfxGray gray;
-#if SPLASH_CMYK
- GfxCMYK cmyk;
-#endif
-
- rgb.r = byteToCol(r);
- rgb.g = byteToCol(g);
- rgb.b = byteToCol(b);
- gray = (GfxColorComp)(0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.g + 0.5);
- if (gray > gfxColorComp1) {
- gray = gfxColorComp1;
- }
-#if SPLASH_CMYK
- cmyk.c = gfxColorComp1 - rgb.r;
- cmyk.m = gfxColorComp1 - rgb.g;
- cmyk.y = gfxColorComp1 - rgb.b;
- cmyk.k = 0;
- oprs->setFillPattern(getColor(gray, &rgb, &cmyk));
-#else
- oprs->setFillPattern(getColor(gray, &rgb));
-#endif
-}
-
-int OPVPOutputDev::OPVPStartJob(char *jobInfo)
-{
- return oprs->OPVPStartJob(jobInfo);
-}
-
-int OPVPOutputDev::OPVPEndJob()
-{
- return oprs->OPVPEndJob();
-}
-
-int OPVPOutputDev::OPVPStartDoc(char *docInfo)
-{
- return oprs->OPVPStartDoc(docInfo);
-}
-
-int OPVPOutputDev::OPVPEndDoc()
-{
- return oprs->OPVPEndDoc();
-}
-
-int OPVPOutputDev::OPVPStartPage(char *pageInfo,
- int rasterWidth, int rasterHeight)
-{
- paperWidth = rasterWidth;
- paperHeight = rasterHeight;
- return oprs->OPVPStartPage(pageInfo,rasterWidth);
-}
-
-int OPVPOutputDev::OPVPEndPage()
-{
- return oprs->OPVPEndPage();
-}
-
-int OPVPOutputDev::outSlice()
-{
- return oprs->outSlice();
-}
-
-void OPVPOutputDev::psXObject(Stream *psStream, Stream *level1Stream)
-{
- opvpError(-1,"psXObject is found, but it is not supported");
-}
diff --git a/filter/pdftoopvp/OPVPOutputDev.h b/filter/pdftoopvp/OPVPOutputDev.h
deleted file mode 100644
index f3d08257f..000000000
--- a/filter/pdftoopvp/OPVPOutputDev.h
+++ /dev/null
@@ -1,250 +0,0 @@
-//========================================================================
-//
-// OPVPOutputDev.h
-//
-// Copyright 2005 AXE,Inc.
-//
-//========================================================================
-
-#ifndef OPVPOUTPUTDEV_H
-#define OPVPOUTPUTDEV_H
-
-#include <config.h>
-
-#ifdef USE_GCC_PRAGMAS
-#pragma interface
-#endif
-
-#include "goo/gtypes.h"
-#include "splash/SplashTypes.h"
-#include "config.h"
-#include "OutputDev.h"
-#include "GfxState.h"
-#include "GfxFont.h"
-
-class GfxState;
-class GfxPath;
-class Gfx8BitFont;
-class SplashBitmap;
-class OPRS;
-class OPVPSplashPath;
-class SplashPattern;
-class SplashFontEngine;
-class SplashFont;
-class T3FontCache;
-struct T3FontCacheTag;
-struct T3GlyphStack;
-struct GfxRGB;
-
-//------------------------------------------------------------------------
-
-// number of Type 3 fonts to cache
-#define splashOutT3FontCacheSize 8
-
-//------------------------------------------------------------------------
-// OPVPOutputDev
-//------------------------------------------------------------------------
-
-class OPVPOutputDev: public OutputDev {
-public:
-
- // Constructor.
- OPVPOutputDev();
-
- // Second Constructor
- int init(SplashColorMode colorModeA, bool colorProfile, bool reverseVideoA,
- SplashColor paperColorA,
- const char *driverName, int outputFD,
- const char *printerModel,
- int nOptions,
- const char *optionKeys[], const char *optionVals[]);
-
- // Destructor.
- virtual ~OPVPOutputDev();
-
- //----- get info about output device
-
- // Does this device use upside-down coordinates?
- // (Upside-down means (0,0) is the top left corner of the page.)
- virtual bool upsideDown() { return true; }
-
- // Does this device use drawChar() or drawString()?
- virtual bool useDrawChar() { return true; }
-
- // Does this device use beginType3Char/endType3Char? Otherwise,
- // text in Type 3 fonts will be drawn with drawChar/drawString.
- virtual bool interpretType3Chars() { return true; }
-
- //----- initialization and control
-
- // Start a page.
- virtual void startPage(int pageNum, GfxState *state);
-
- // End a page.
- virtual void endPage();
-
- //----- save/restore graphics state
- virtual void saveState(GfxState *state);
- virtual void restoreState(GfxState *state);
-
- //----- update graphics state
- virtual void updateAll(GfxState *state);
- virtual void updateCTM(GfxState *state, double m11, double m12,
- double m21, double m22, double m31, double m32);
- virtual void updateLineDash(GfxState *state);
- virtual void updateFlatness(GfxState *state);
- virtual void updateLineJoin(GfxState *state);
- virtual void updateLineCap(GfxState *state);
- virtual void updateMiterLimit(GfxState *state);
- virtual void updateLineWidth(GfxState *state);
- virtual void updateFillColor(GfxState *state);
- virtual void updateStrokeColor(GfxState *state);
-
- //----- update text state
- virtual void updateFont(GfxState *state);
-
- //----- path painting
- virtual void stroke(GfxState *state);
- virtual void fill(GfxState *state);
- virtual void eoFill(GfxState *state);
-
- //----- path clipping
- virtual void clip(GfxState *state);
- virtual void eoClip(GfxState *state);
- virtual void clipToStrokePath(GfxState *state);
-
- //----- text drawing
- virtual void drawChar(GfxState *state, double x, double y,
- double dx, double dy,
- double originX, double originY,
- CharCode code, int nBytes, Unicode *u, int uLen);
- virtual bool beginType3Char(GfxState *state, double x, double y,
- double dx, double dy,
- CharCode code, Unicode *u, int uLen);
- virtual void endType3Char(GfxState *state);
- virtual void endTextObject(GfxState *state);
-
- //----- image drawing
- virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
- int width, int height, bool invert,
- bool interpolate,
- bool inlineImg);
- virtual void drawImage(GfxState *state, Object *ref, Stream *str,
- int width, int height, GfxImageColorMap *colorMap,
- bool interpolate,
- int *maskColors, bool inlineImg);
- virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
- int width, int height,
- GfxImageColorMap *colorMap,
- bool interpolate,
- Stream *maskStr, int maskWidth, int maskHeight,
- bool maskInvert, bool maskeInterpolate);
- virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
- int width, int height,
- GfxImageColorMap *colorMap,
- bool interpolate,
- Stream *maskStr,
- int maskWidth, int maskHeight,
- GfxImageColorMap *maskColorMap,
- bool maskInterpolate);
-
- //----- Type 3 font operators
- virtual void type3D0(GfxState *state, double wx, double wy);
- virtual void type3D1(GfxState *state, double wx, double wy,
- double llx, double lly, double urx, double ury);
-
- //----- special access
-
- // Called to indicate that a new PDF document has been loaded.
- void startDoc(XRef *xrefA);
-
- bool isReverseVideo() { return reverseVideo; }
-
- // Get the bitmap and its size.
- SplashBitmap *getBitmap() { return bitmap; }
- int getBitmapWidth();
- int getBitmapHeight();
-
- // Get the Splash object.
- OPRS *getOPRS() { return oprs; }
-
- // XOR a rectangular region in the bitmap with <pattern>. <pattern>
- // is passed to Splash::setFillPattern, so it should not be used
- // after calling this function.
- void xorRectangle(int x0, int y0, int x1, int y1, SplashPattern *pattern);
-
- // Set the Splash fill color.
- void setFillColor(int r, int g, int b);
-
- void setUnderlayCbk(void (*cbk)(void *data), void *data)
- { underlayCbk = cbk; underlayCbkData = data; }
-
- int OPVPStartJob(char *jobInfo);
- int OPVPEndJob();
- int OPVPStartDoc(char *docInfo);
- int OPVPEndDoc();
- int OPVPStartPage(char *pageInfo, int rasterWidth, int rasterHeight);
- int OPVPEndPage();
- int outSlice();
- virtual void psXObject(Stream *psStream, Stream *level1Stream);
- void setScale(double w, double h, double leftMarginA, double bottomMarginA,
- int rotateA, int yoffsetA, int sliceHeightA);
-
-private:
-
- SplashPattern *getColor(GfxGray gray, GfxRGB *rgb);
- OPVPSplashPath *convertPath(GfxState *state, GfxPath *path);
- void drawType3Glyph(T3FontCache *t3Font,
- T3FontCacheTag *tag, Guchar *data,
- double x, double y);
- void patternFillChar(GfxState *state,
- double x, double y, CharCode code);
-
- static bool imageMaskSrc(void *data, SplashColorPtr line);
- static bool imageSrc(void *data, SplashColorPtr line,
- Guchar *alphaLine);
- static bool alphaImageSrc(void *data, SplashColorPtr line,
- Guchar *alphaLine);
- static bool maskedImageSrc(void *data, SplashColorPtr line,
- Guchar *alphaLine);
-
- OPVPSplashPath *bitmapToPath(SplashBitmap *bitmapA, int width, int height);
- void closeAllSubPath(OPVPSplashPath *path);
- void patternFillImageMask(GfxState *state,
- SplashImageMaskSource src, void *srcData, int w, int h, SplashCoord *mat);
- void doUpdateFont(GfxState *state);
- void transLineDash(GfxState *state, SplashCoord **adash,
- int *adashLength, SplashCoord *aphase);
- void updateSplashLineDash(GfxState *state, Splash *splash);
-
- SplashColorMode colorMode;
- bool reverseVideo; // reverse video mode
- SplashColor paperColor; // paper color
-
- XRef *xref; // xref table for current document
-
- SplashBitmap *bitmap;
- OPRS *oprs;
- SplashFontEngine *fontEngine;
-
- T3FontCache * // Type 3 font cache
- t3FontCache[splashOutT3FontCacheSize];
- int nT3Fonts; // number of valid entries in t3FontCache
- T3GlyphStack *t3GlyphStack; // Type 3 glyph context stack
-
- SplashFont *font; // current font
- bool needFontUpdate; // set when the font needs to be updated
- OPVPSplashPath *textClipPath; // clipping path built with text object
-
- void (*underlayCbk)(void *data);
- void *underlayCbkData;
- double fontMat[4];
- double scaleWidth, scaleHeight;
- int paperWidth, paperHeight;
- double leftMargin, bottomMargin;
- int rotate;
- int yoffset;
- int sliceHeight;
-};
-
-#endif
diff --git a/filter/pdftoopvp/oprs/OPRS.cxx b/filter/pdftoopvp/oprs/OPRS.cxx
deleted file mode 100644
index 21cabc00e..000000000
--- a/filter/pdftoopvp/oprs/OPRS.cxx
+++ /dev/null
@@ -1,604 +0,0 @@
-//========================================================================
-//
-// OPRS.cc
-//
-//========================================================================
-
-#include <config.h>
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-
-#ifdef USE_GCC_PRAGMAS
-#pragma implementation
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <string.h>
-#include <dlfcn.h>
-#include <stdarg.h>
-#include <math.h>
-#if defined __OpenBSD__
-#include <sys/endian.h>
-#if BYTE_ORDER == BIG_ENDIAN
-#define __BYTE_ORDER __BIG_ENDIAN
-#else
-#define __BYTE_ORDER __LITTLE_ENDIAN
-#endif
-#endif
-
-#include "goo/gmem.h"
-#include "splash/SplashErrorCodes.h"
-#include "splash/SplashMath.h"
-#include "splash/SplashBitmap.h"
-#include "splash/SplashState.h"
-#include "splash/SplashXPathScanner.h"
-#include "splash/SplashPattern.h"
-#include "splash/SplashScreen.h"
-#include "splash/SplashFont.h"
-#include "splash/SplashGlyphBitmap.h"
-#include "splash/Splash.h"
-#include "OPVPSplash.h"
-#include "OPVPSplashClip.h"
-#include "OPVPSplashPath.h"
-#include "OPVPSplashXPath.h"
-#include "OPRS.h"
-
-//------------------------------------------------------------------------
-// Splash
-//------------------------------------------------------------------------
-
-#define SPLASH(x) (rasterMode ? (splash->x) : (opvpSplash->x))
-
-OPRS::OPRS()
-{
- opvp = 0;
- splash = 0;
- opvpSplash = 0;
- rasterMode = false;
-}
-
-int OPRS::setBitmap(SplashBitmap *bitmapA) {
- if (splash != 0) {
- delete splash;
- }
- splash = new Splash(bitmapA, false);
- rasterMode = true;
- return 0;
-}
-
-OPRS::~OPRS() {
- if (splash != 0) {
- delete splash;
- splash = 0;
- }
- if (opvpSplash != 0) {
- opvpSplash->restoreAllDriverState();
- delete opvpSplash;
- opvpSplash = 0;
- }
-}
-
-//------------------------------------------------------------------------
-// state read
-//------------------------------------------------------------------------
-
-
-SplashPattern *OPRS::getStrokePattern() {
- return SPLASH(getStrokePattern());
-}
-
-SplashPattern *OPRS::getFillPattern() {
- return SPLASH(getFillPattern());
-}
-
-SplashScreen *OPRS::getScreen() {
- return SPLASH(getScreen());
-}
-
-SplashCoord OPRS::getLineWidth() {
- return SPLASH(getLineWidth());
-}
-
-int OPRS::getLineCap() {
- return SPLASH(getLineCap());
-}
-
-int OPRS::getLineJoin() {
- return SPLASH(getLineJoin());
-}
-
-SplashCoord OPRS::getMiterLimit() {
- return SPLASH(getMiterLimit());
-}
-
-SplashCoord OPRS::getFlatness() {
- return 1;
-}
-
-SplashCoord *OPRS::getLineDash() {
- return SPLASH(getLineDash());
-}
-
-int OPRS::getLineDashLength() {
- return SPLASH(getLineDashLength());
-}
-
-SplashCoord OPRS::getLineDashPhase() {
- return SPLASH(getLineDashPhase());
-}
-
-OPVPSplashClip *OPRS::getClip() {
- if (rasterMode) {
- SplashClip *sclip = splash->getClip();
- OPVPSplashClip *r = new OPVPSplashClip(sclip);
- delete sclip;
- return r;
- } else {
- return opvpSplash->getClip();
- }
-}
-
-//------------------------------------------------------------------------
-// state write
-//------------------------------------------------------------------------
-
-void OPRS::setStrokePattern(SplashPattern *strokePattern) {
- SPLASH(setStrokePattern(strokePattern));
-}
-
-void OPRS::setFillPattern(SplashPattern *fillPattern) {
- SPLASH(setFillPattern(fillPattern));
-}
-
-void OPRS::setScreen(SplashScreen *screen) {
- SPLASH(setScreen(screen));
-}
-
-void OPRS::setLineWidth(SplashCoord lineWidth) {
- SPLASH(setLineWidth(lineWidth));
-}
-
-void OPRS::setMiterLimit(SplashCoord miterLimit) {
- SPLASH(setMiterLimit(miterLimit));
-}
-
-void OPRS::setLineCap(int lineCap) {
- SPLASH(setLineCap(lineCap));
-}
-
-void OPRS::setLineJoin(int lineJoin) {
- SPLASH(setLineJoin(lineJoin));
-}
-
-void OPRS::setFlatness(SplashCoord flatness) {
-/* ignore flatness */
-}
-
-void OPRS::setLineDash(SplashCoord *lineDash, int lineDashLength,
- SplashCoord lineDashPhase) {
- SPLASH(setLineDash(lineDash,lineDashLength,lineDashPhase));
-}
-
-SplashError OPRS::clipToPath(OPVPSplashPath *path, bool eo) {
- return SPLASH(clipToPath(path,eo));
-}
-
-//------------------------------------------------------------------------
-// state save/restore
-//------------------------------------------------------------------------
-
-void OPRS::saveState() {
- SPLASH(saveState());
-}
-
-SplashError OPRS::restoreState() {
- SPLASH(restoreState());
- return splashOk;
-}
-
-//------------------------------------------------------------------------
-// drawing operations
-//------------------------------------------------------------------------
-
-void OPRS::clear(SplashColor color) {
- SPLASH(clear(color));
-}
-
-SplashError OPRS::stroke(OPVPSplashPath *path) {
- return SPLASH(stroke(path));
-}
-
-SplashError OPRS::fill(OPVPSplashPath *path, bool eo) {
- return SPLASH(fill(path,eo));
-}
-
-SplashError OPRS::fillChar(SplashCoord x, SplashCoord y,
- int c, SplashFont *font, Unicode *u,
- double *fontMat) {
- if (rasterMode) {
- return splash->fillChar(x,y,c,font);
- } else {
- return opvpSplash->fillChar(x,y,c,font,u,fontMat);
- }
-}
-
-SplashError OPRS::fillGlyph(SplashCoord x, SplashCoord y,
- SplashGlyphBitmap *glyph) {
- SPLASH(fillGlyph(x,y,glyph));
- return splashOk;
-}
-
-SplashError OPRS::fillImageMask(SplashImageMaskSource src, void *srcData,
- int w, int h, SplashCoord *mat, bool glyphMode) {
- return SPLASH(fillImageMask(src,srcData,w,h,mat,glyphMode));
-}
-
-SplashError OPRS::drawImage(SplashImageSource src, void *srcData,
- SplashColorMode srcMode, bool srcAlpha,
- int w, int h, SplashCoord *mat) {
- if (rasterMode) {
-#if POPPLER_VERSION_MAJOR <= 0 && (POPPLER_VERSION_MINOR <= 20 || (POPPLER_VERSION_MINOR == 21 && POPPLER_VERSION_MICRO <= 2))
- return splash->drawImage(src,srcData,srcMode,srcAlpha,w,h,mat);
-#elif POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR <= 33
- return splash->drawImage(src,srcData,srcMode,srcAlpha,w,h,mat,false);
-#else
- return splash->drawImage(src,0,srcData,srcMode,srcAlpha,w,h,mat,false);
-#endif
- } else {
- return opvpSplash->drawImage(src,srcData,srcMode,srcAlpha,w,h,mat);
- }
-}
-
-/*
- * initialize and load vector-driver
- */
-int OPRS::init(const char *driverName, int outputFD,
- const char *printerModel, int nOptions,
- const char *optionKeys[], const char *optionVals[])
-{
- opvp = OPVPWrapper::loadDriver(driverName,outputFD,printerModel);
- if (opvp == 0) return -1;
- rasterMode = false;
- if (!rasterMode) {
- opvpSplash = new OPVPSplash(opvp,nOptions,
- optionKeys, optionVals);
- }
- return 0;
-}
-
-int OPRS::OPVPStartJob(char *jobInfo)
-{
- if (!opvp->supportStartJob) {
- return 0;
- }
- return opvp->StartJob((const opvp_char_t *)jobInfo);
-}
-
-int OPRS::OPVPEndJob()
-{
- if (!opvp->supportEndJob) {
- return 0;
- }
- return opvp->EndJob();
-}
-
-int OPRS::OPVPStartDoc(char *docInfo)
-{
- if (!opvp->supportStartDoc) {
- return 0;
- }
- return opvp->StartDoc((const opvp_char_t *)docInfo);
-}
-
-int OPRS::OPVPEndDoc()
-{
- if (!opvp->supportEndDoc) {
- return 0;
- }
- return opvp->EndDoc();
-}
-
-int OPRS::OPVPStartPage(char *pageInfo, int rasterWidth)
-{
- int r;
-
- if (opvp->supportStartPage) {
- if ((r = opvp->StartPage((const opvp_char_t *)pageInfo)) < 0) {
- return r;
- }
- }
- if (rasterMode) {
- if (!opvp->supportStartRaster) {
- error("No StartRaster error in raster mode\n");
- return -1;
- }
- if (opvp->supportSetCurrentPoint) {
- opvp_fix_t x,y;
-
- OPVP_F2FIX(0.0,x);
- OPVP_F2FIX(0.0,y);
- opvp->SetCurrentPoint(x,y);
- }
- opvp->StartRaster(rasterWidth);
- }
- return 0;
-}
-
-int OPRS::OPVPEndPage()
-{
- int r;
-
- if (rasterMode) {
- if (!opvp->supportEndRaster) {
- error("No EndRaster error in raster mode\n");
- return -1;
- }
- opvp->EndRaster();
- }
- if (opvp->supportEndPage) {
- if ((r = opvp->EndPage()) < 0) {
- return r;
- }
- }
- return splashOk;
-}
-
-unsigned char *OPRS::getScanLineDataMono1(unsigned char *dst,
- unsigned char *bitmap, int rasterWidth)
-{
- int n = (rasterWidth+7)/8;
-
- memcpy(dst,bitmap,n);
- return bitmap+n;
-}
-
-unsigned char *OPRS::getScanLineDataMono8(unsigned char *dst,
- unsigned char *bitmap, int rasterWidth)
-{
- memcpy(dst,bitmap,rasterWidth);
- return bitmap+rasterWidth;
-}
-
-unsigned char *OPRS::getScanLineDataRGB8(unsigned char *dst,
- unsigned char *bitmap, int rasterWidth)
-{
- int i;
-
- for (i = 0;i < rasterWidth;i++) {
-#if defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN
- bitmap++;
- *dst++ = *bitmap++;
- *dst++ = *bitmap++;
- *dst++ = *bitmap++;
-#else
- dst[2] = *bitmap++;
- dst[1] = *bitmap++;
- dst[0] = *bitmap++;
- bitmap++;
- dst += 3;
-#endif
- }
- return bitmap;
-}
-
-unsigned char *OPRS::getScanLineDataBGR8Packed(unsigned char *dst,
- unsigned char *bitmap, int rasterWidth)
-{
- memcpy(dst,bitmap,rasterWidth*3);
- return bitmap+rasterWidth*3;
-}
-
-OPRS::GetScanLineDataFunT OPRS::getGetScanLineDataFun(SplashBitmap *bitmap)
-{
- switch (bitmap->getMode()) {
- case splashModeMono1:
- return getScanLineDataMono1;
- case splashModeMono8:
- return getScanLineDataMono8;
- case splashModeRGB8:
- return getScanLineDataRGB8;
- default:
- OPRS::error("Unknown bitmap mode\n");
- break;
- }
- return getScanLineDataMono8;
-}
-
-int OPRS::getRasterSize(SplashBitmap *bitmap)
-{
- int rw = bitmap->getWidth();
-
- switch (bitmap->getMode()) {
- case splashModeMono1:
- return (rw+7)/8;
- case splashModeMono8:
- return rw;
- case splashModeRGB8:
- return rw*3;
- default:
- OPRS::error("Unknown bitmap mode\n");
- break;
- }
- return 0;
-}
-
-bool OPRS::checkAll1(unsigned char *bp, int n, int width, int mode)
-{
- int lastbytemask = 0xff;
- int i;
-
- if (mode == splashModeMono1) {
- lastbytemask <<= (width & 0x7);
- lastbytemask &= 0xff;
- }
- for (i = 0;i < n-1;i++) {
- if (*bp++ != 0xff) return false;
- }
- return (*bp & lastbytemask) == lastbytemask;
-}
-
-int OPRS::outSlice()
-{
- if (rasterMode) {
- /* out bitmap */
- int rasterWidth;
- int nScanLines;
- int rasterSize;
- unsigned char *p;
- int i;
- SplashBitmap *bitmap;
- SplashColorPtr cp;
- unsigned char *bp;
- GetScanLineDataFunT fun;
- int mode;
-
- if (!opvp->supportStartRaster || !opvp->supportTransferRasterData
- || !opvp->supportEndRaster) {
- OPRS::error("No raster supporting printer driver\n");
- return -1;
- }
-
- bitmap = splash->getBitmap();
- rasterWidth = bitmap->getWidth();
- nScanLines = bitmap->getHeight();
- rasterSize = getRasterSize(bitmap);
- if ((bp = new unsigned char[rasterSize]) == 0) {
- OPRS::error("Not enough memory\n");
- return -1;
- }
- cp = (bitmap->getDataPtr());
- p = reinterpret_cast<unsigned char *>(cp);
- fun = getGetScanLineDataFun(bitmap);
- mode = bitmap->getMode();
- for (i = 0;i < nScanLines;i++) {
- p = (*fun)(bp,p,rasterWidth);
- if (opvp->supportSkipRaster
- && checkAll1(bp,rasterSize,rasterWidth,mode)) {
- /* all white, skip raster */
- opvp->SkipRaster(1);
- } else {
- opvp->TransferRasterData(rasterSize,bp);
- }
- }
- delete[] bp;
- }
- return 0;
-}
-
-int OPRS::setColorMode(int colorModeA, bool colorProfile)
-{
- opvp_cspace_t cspace = OPVP_CSPACE_STANDARDRGB;
-
- if (opvp->supportGetColorSpace) opvp->GetColorSpace(&cspace);
- switch (cspace){
- case OPVP_CSPACE_BW:
- if (colorModeA != splashModeMono1) {
- OPRS::error("not mono mode is specified on a monochrome printer\n");
- return -1;
- }
- break;
- case OPVP_CSPACE_DEVICEGRAY:
- if (colorModeA != splashModeMono1 && colorModeA != splashModeMono8) {
- OPRS::error("colorMode is specified on not a color printer\n");
- return -1;
- }
- break;
- case OPVP_CSPACE_DEVICERGB:
- if (colorProfile) break;
- default:
- /* rgb color */
- if (colorProfile) {
- /* try set colorspace to DEVICERGB */
- if (opvp->supportSetColorSpace) opvp->SetColorSpace(
- OPVP_CSPACE_DEVICERGB);
- if (opvp->supportGetColorSpace) opvp->GetColorSpace(&cspace);
- if (cspace == OPVP_CSPACE_DEVICERGB) break;
- /* fail to set, fall through */
- }
- if (opvp->supportSetColorSpace) opvp->SetColorSpace(
- OPVP_CSPACE_STANDARDRGB);
- break;
- }
- if (!rasterMode) {
- opvpSplash->setColorMode(colorModeA);
- }
- return 0;
-}
-
-SplashBitmap *OPRS::getBitmap()
-{
- return SPLASH(getBitmap());
-}
-
-void OPRS::setDebugMode(bool debugModeA)
-{
- SPLASH(setDebugMode(debugModeA));
-}
-
-void OPRS::initGS(int colorMode, int w, int h, SplashColor paperColor)
-{
- SplashColor color;
-
- if (!rasterMode && opvp->supportInitGS) {
- opvp->InitGS();
- }
- if (opvp->supportSetPaintMode) {
- opvp->SetPaintMode(OPVP_PAINTMODE_TRANSPARENT);
- }
- switch (colorMode) {
- case splashModeMono1: color[0] = 0; break;
- case splashModeMono8: color[0] = 0; break;
- case splashModeRGB8: color[0] = color[1] = color[2] = 0; break;
- }
- if (!rasterMode) {
- opvpSplash->setStateBypass(true);
- }
- SPLASH(setStrokePattern(new SplashSolidColor(color)));
- SPLASH(setFillPattern(new SplashSolidColor(color)));
- SPLASH(setLineCap(splashLineCapButt));
- SPLASH(setLineJoin(splashLineJoinMiter));
- SPLASH(setLineDash(0, 0, 0));
- SPLASH(setLineWidth(0));
- SPLASH(setMiterLimit(10));
- SPLASH(setFlatness(1));
- SPLASH(clipResetToRect(0,0,w-1,h-1));
- SPLASH(clear(paperColor));
- if (!rasterMode) {
- opvpSplash->setStateBypass(false);
- }
-}
-
-void OPRS::error(const char *msg, ...)
-{
- va_list args;
-
- fprintf(stderr,"ERROR:OPRS:");
- va_start(args, msg);
- vfprintf(stderr, msg, args);
- va_end(args);
- fflush(stderr);
-}
-
-void OPRS::endPage()
-{
- /* restore state */
- while (SPLASH(restoreState()) == splashOk);
- if (!rasterMode) {
- opvpSplash->endPage();
- }
-}
-
-void OPRS::setSoftMask(SplashBitmap *softMaskA)
-{
- /* Soft Mask is not supported in vector mode. */
- if (rasterMode) {
- splash->setSoftMask(softMaskA);
- }
-}
-
-SplashCoord *OPRS::getMatrix()
-{
- return SPLASH(getMatrix());
-}
diff --git a/filter/pdftoopvp/oprs/OPRS.h b/filter/pdftoopvp/oprs/OPRS.h
deleted file mode 100644
index e47804c51..000000000
--- a/filter/pdftoopvp/oprs/OPRS.h
+++ /dev/null
@@ -1,188 +0,0 @@
-//========================================================================
-//
-// OPRS.h
-//
-//========================================================================
-
-#ifndef OPRS_H
-#define OPRS_H
-
-#include <config.h>
-
-#ifdef USE_GCC_PRAGMAS
-#pragma interface
-#endif
-
-#include "splash/SplashTypes.h"
-#include "opvp_common.h"
-#include "splash/Splash.h"
-#include "OPVPSplash.h"
-#include "OPVPWrapper.h"
-
-#define OPVP_BUFF_SIZE 256
-
-class SplashBitmap;
-class SplashGlyphBitmap;
-class SplashState;
-class SplashPattern;
-class SplashScreen;
-class OPVPSplashPath;
-class SplashXPath;
-class OPVPSplashClip;
-class SplashFont;
-
-//------------------------------------------------------------------------
-// OPRS
-//------------------------------------------------------------------------
-
-class OPRS {
-public:
-
- static void error(const char *msg, ...);
- OPRS();
- ~OPRS();
-
- int setBitmap(SplashBitmap *bitmapA);
-
- //----- state read
-
- SplashPattern *getStrokePattern();
- SplashPattern *getFillPattern();
- SplashScreen *getScreen();
- SplashCoord getLineWidth();
- int getLineCap();
- int getLineJoin();
- SplashCoord getMiterLimit();
- SplashCoord getFlatness();
- SplashCoord *getLineDash();
- int getLineDashLength();
- SplashCoord getLineDashPhase();
- OPVPSplashClip *getClip();
-
- //----- state write
-
- void setStrokePattern(SplashPattern *strokeColor);
- void setFillPattern(SplashPattern *fillColor);
- void setScreen(SplashScreen *screen);
- void setLineWidth(SplashCoord lineWidth);
- void setMiterLimit(SplashCoord miterLimit);
- void setLineCap(int lineCap);
- void setLineJoin(int lineJoin);
- void setFlatness(SplashCoord flatness);
- // the <lineDash> array will be copied
- void setLineDash(SplashCoord *lineDash, int lineDashLength,
- SplashCoord lineDashPhase);
- SplashError clipToPath(OPVPSplashPath *path, bool eo);
-
- //----- state save/restore
-
- void saveState();
- SplashError restoreState();
-
- void setSoftMask(SplashBitmap *softMaskA);
-
- //----- drawing operations
-
- // Fill the bitmap with <color>. This is not subject to clipping.
- void clear(SplashColor color);
-
- // Stroke a path using the current stroke pattern.
- SplashError stroke(OPVPSplashPath *path);
-
- // Fill a path using the current fill pattern.
- SplashError fill(OPVPSplashPath *path, bool eo);
-
- // Draw a character, using the current fill pattern.
- SplashError fillChar(SplashCoord x, SplashCoord y, int c, SplashFont *font,
- Unicode *u, double *fontMat);
-
- // Draw a glyph, using the current fill pattern. This function does
- // not free any data, i.e., it ignores glyph->freeData.
- SplashError fillGlyph(SplashCoord x, SplashCoord y,
- SplashGlyphBitmap *glyph);
-
- // Draws an image mask using the fill color. This will read <w>*<h>
- // pixels from <src>, in raster order, starting with the top line.
- // "1" pixels will be drawn with the current fill color; "0" pixels
- // are transparent. The matrix:
- // [ mat[0] mat[1] 0 ]
- // [ mat[2] mat[3] 0 ]
- // [ mat[4] mat[5] 1 ]
- // maps a unit square to the desired destination for the image, in
- // PostScript style:
- // [x' y' 1] = [x y 1] * mat
- // Note that the Splash y axis points downward, and the image source
- // is assumed to produce pixels in raster order, starting from the
- // top line.
- SplashError fillImageMask(SplashImageMaskSource src, void *srcData,
- int w, int h, SplashCoord *mat, bool glyphMode);
-
- // Draw an image. This will read <w>*<h> pixels from <src>, in
- // raster order, starting with the top line. These pixels are
- // assumed to be in the source mode, <srcMode>. The following
- // combinations of source and target modes are supported:
- // source target
- // ------ ------
- // Mono1 Mono1
- // Mono8 Mono1 -- with dithering
- // Mono8 Mono8
- // RGB8 RGB8
- // BGR8packed BGR8Packed
- // The matrix behaves as for fillImageMask.
- SplashError drawImage(SplashImageSource src, void *srcData,
- SplashColorMode srcMode, bool srcAlpha,
- int w, int h, SplashCoord *mat);
-
- //~ drawMaskedImage
-
- //----- misc
-
- // Return the associated bitmap.
- SplashBitmap *getBitmap();
-
- // Toggle debug mode on or off.
- void setDebugMode(bool debugModeA);
-
- int init(const char *driverName, int outputFD,
- const char *printerModel, int nOptions,
- const char *optionKeys[], const char *optionVals[]);
- void initGS(int colorMode, int w, int h, SplashColor paperColor);
- int setColorMode(int colorModeA, bool colorProfile);
- int unloadVectorDriver();
-
- int OPVPStartJob(char *jobInfo);
- int OPVPEndJob();
- int OPVPStartDoc(char *docInfo);
- int OPVPEndDoc();
- int OPVPStartPage(char *pageInfo, int rasterWidth);
- int OPVPEndPage();
- int outSlice();
- Splash *getSplash() { return splash; }
- int getRasterMode() { return rasterMode; }
- void endPage();
- SplashCoord *getMatrix();
-
-private:
- int rasterMode;
- OPVPSplash *opvpSplash;
- Splash *splash;
- OPVPWrapper *opvp;
- int getRasterSize(SplashBitmap *bitmap);
-
- typedef unsigned char *(*GetScanLineDataFunT)(unsigned char *dst,
- unsigned char *bitmap, int rasterWidth);
-
- static unsigned char *getScanLineDataMono1(unsigned char *dst,
- unsigned char *bitmap, int rasterWidth);
- static unsigned char *getScanLineDataMono8(unsigned char *dst,
- unsigned char *bitmap, int rasterWidth);
- static unsigned char *getScanLineDataRGB8(unsigned char *dst,
- unsigned char *bitmap, int rasterWidth);
- static unsigned char *getScanLineDataBGR8Packed(unsigned char *dst,
- unsigned char *bitmap, int rasterWidth);
-
- GetScanLineDataFunT getGetScanLineDataFun(SplashBitmap *bitmap);
- bool checkAll1(unsigned char *bp, int n, int width, int mode);
-};
-
-#endif
diff --git a/filter/pdftoopvp/oprs/OPVPSplash.cxx b/filter/pdftoopvp/oprs/OPVPSplash.cxx
deleted file mode 100644
index 396a77358..000000000
--- a/filter/pdftoopvp/oprs/OPVPSplash.cxx
+++ /dev/null
@@ -1,2327 +0,0 @@
-//========================================================================
-//
-// OPVPSplash.cc
-//
-//========================================================================
-
-#include <config.h>
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-
-#ifdef USE_GCC_PRAGMAS
-#pragma implementation
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <limits.h>
-#include "goo/gmem.h"
-#include "splash/SplashErrorCodes.h"
-#include "splash/SplashMath.h"
-#include "splash/SplashBitmap.h"
-#include "splash/SplashXPathScanner.h"
-#include "splash/SplashPattern.h"
-#include "splash/SplashScreen.h"
-#include "splash/SplashFont.h"
-#include "splash/SplashGlyphBitmap.h"
-#include "splash/Splash.h"
-#include "OPRS.h"
-#include "OPVPSplashState.h"
-#include "OPVPSplash.h"
-#include "OPVPSplashPath.h"
-#include "OPVPSplashXPath.h"
-#include "OPVPSplashClip.h"
-
-//------------------------------------------------------------------------
-// OPVPSplash
-//------------------------------------------------------------------------
-
-inline void OPVPSplash::transform(SplashCoord *matrix,
- SplashCoord xi, SplashCoord yi,
- SplashCoord *xo, SplashCoord *yo) {
- // [ m[0] m[1] 0 ]
- // [xo yo 1] = [xi yi 1] * [ m[2] m[3] 0 ]
- // [ m[4] m[5] 1 ]
- *xo = xi * matrix[0] + yi * matrix[2] + matrix[4];
- *yo = xi * matrix[1] + yi * matrix[3] + matrix[5];
-}
-
-OPVPSplash::OPVPSplash(OPVPWrapper *opvpA,
- int nOptions, const char *optionKeys[], const char *optionVals[])
-{
- const char *opv;
-
- opvp = opvpA;
- // with default screen params
- state = new OPVPSplashState(0,0,false,(SplashScreenParams *)NULL);
- debugMode = false;
- stateBypass = false;
- clipPath = 0;
- if (getOption("OPVP_OLDLIPSDRIVER",nOptions,
- optionKeys,optionVals) != NULL) {
- oldLipsDriver = true;
- } else {
- oldLipsDriver = false;
- }
- if (getOption("OPVP_CLIPPATHNOTSAVED",nOptions,
- optionKeys,optionVals) != NULL) {
- clipPathNotSaved = true;
- } else {
- clipPathNotSaved = false;
- }
- if (getOption("OPVP_NOSHEARIMAGE",nOptions,
- optionKeys,optionVals) != NULL) {
- noShearImage = true;
- } else {
- noShearImage = false;
- }
- if (getOption("OPVP_NOLINESTYLE",nOptions,
- optionKeys,optionVals) != NULL) {
- noLineStyle = true;
- } else {
- noLineStyle = false;
- }
- if (!opvpA->supportSetLineStyle || !opvpA->supportSetLineDash
- || !opvpA->supportSetLineDashOffset) {
- noLineStyle = true;
- }
- if (getOption("OPVP_NOCLIPPATH",nOptions,
- optionKeys,optionVals) != NULL) {
- noClipPath = true;
- } else {
- noClipPath = false;
- }
- if (getOption("OPVP_IGNOREMITERLIMIT",nOptions,
- optionKeys,optionVals) != NULL) {
- ignoreMiterLimit = true;
- } else {
- ignoreMiterLimit = false;
- }
- if (getOption("OPVP_NOMITERLIMIT",nOptions,
- optionKeys,optionVals) != NULL) {
- noMiterLimit = true;
- } else {
- noMiterLimit = false;
- }
- if (!opvpA->supportSetMiterLimit) {
- noMiterLimit = true;
- }
- if ((opv = getOption("OPVP_BITMAPCHARTHRESHOLD",nOptions,
- optionKeys,optionVals)) != NULL) {
- bitmapCharThreshold = atoi(opv);
- } else {
- bitmapCharThreshold = OPVP_BITMAPCHAR_THRESHOLD;
- }
- if ((opv = getOption("OPVP_MAXCLIPPATHLENGTH",nOptions,
- optionKeys,optionVals)) != NULL) {
- maxClipPathLength = atoi(opv);
- } else {
- maxClipPathLength = OPVP_MAX_CLIPPATH_LENGTH;
- }
- if ((opv = getOption("OPVP_MAXFILLPATHLENGTH",nOptions,
- optionKeys,optionVals)) != NULL) {
- maxFillPathLength = atoi(opv);
- } else {
- maxFillPathLength = OPVP_MAX_FILLPATH_LENGTH;
- }
- if (getOption("OPVP_NOIMAGEMASK",nOptions,
- optionKeys,optionVals) != NULL) {
- noImageMask = true;
- } else {
- noImageMask = false;
- }
- if (getOption("OPVP_NOBITMAPCHAR",nOptions,
- optionKeys,optionVals) != NULL) {
- bitmapCharThreshold = 0;
- }
- if (!opvpA->supportSetClipPath) {
- noClipPath = true;
- }
- savedNoClipPath = noClipPath;
- saveDriverStateCount = 0;
- if (noImageMask) {
- /* We draw bitmapChar with imageMask feature.
- So, when noImageMask, noBitmapChar */
- bitmapCharThreshold = 0;
- }
-#ifdef OPTION_DEBUG
-fprintf(stderr,"noClipPath=%d\n",noClipPath);
-fprintf(stderr,"oldLipsDriver=%d\n",oldLipsDriver);
-fprintf(stderr,"noLineStyle=%d\n",noLineStyle);
-fprintf(stderr,"noMiterLimit=%d\n",noMiterLimit);
-fprintf(stderr,"ignoreMiterLimit=%d\n",ignoreMiterLimit);
-fprintf(stderr,"noShearImage=%d\n",noShearImage);
-fprintf(stderr,"clipPathNotSaved=%d\n",clipPathNotSaved);
-fprintf(stderr,"bitmapCharThreshold=%d\n",bitmapCharThreshold);
-fprintf(stderr,"maxClipPathLength=%d\n",maxClipPathLength);
-#endif
-}
-
-OPVPSplash::~OPVPSplash()
-{
- while (state->next) {
- restoreState();
- }
- delete state;
- if (opvp->supportClosePrinter) {
- opvp->ClosePrinter();
- }
- delete opvp;
-}
-
-//------------------------------------------------------------------------
-// state read
-//------------------------------------------------------------------------
-
-
-SplashPattern *OPVPSplash::getStrokePattern() {
- return state->strokePattern;
-}
-
-SplashPattern *OPVPSplash::getFillPattern() {
- return state->fillPattern;
-}
-
-SplashScreen *OPVPSplash::getScreen() {
- return state->screen;
-}
-
-SplashCoord OPVPSplash::getLineWidth() {
- return state->lineWidth;
-}
-
-int OPVPSplash::getLineCap() {
- return state->lineCap;
-}
-
-int OPVPSplash::getLineJoin() {
- return state->lineJoin;
-}
-
-SplashCoord OPVPSplash::getMiterLimit() {
- return state->miterLimit;
-}
-
-SplashCoord OPVPSplash::getFlatness() {
- return state->flatness;
-}
-
-SplashCoord *OPVPSplash::getLineDash() {
- return state->lineDash;
-}
-
-int OPVPSplash::getLineDashLength() {
- return state->lineDashLength;
-}
-
-SplashCoord OPVPSplash::getLineDashPhase() {
- return state->lineDashPhase;
-}
-
-OPVPSplashClip *OPVPSplash::getClip() {
- return state->clip;
-}
-
-//------------------------------------------------------------------------
-// state write
-//------------------------------------------------------------------------
-
-opvp_cspace_t OPVPSplash::getOPVPColorSpace()
-{
- switch (colorMode) {
- case splashModeMono1:
- return OPVP_CSPACE_BW;
- break;
- case splashModeMono8:
- return OPVP_CSPACE_DEVICEGRAY;
- break;
- case splashModeRGB8:
- default:
- break;
- }
- return OPVP_CSPACE_STANDARDRGB;
-}
-
-void OPVPSplash::makeBrush(SplashPattern *pattern, opvp_brush_t *brush)
-{
- brush->colorSpace = getOPVPColorSpace();
- brush->pbrush = NULL;
- brush->color[3] = -1;
- brush->xorg = brush->yorg = 0;
- if (pattern == NULL) {
- /* set default black color */
- brush->color[2] = 0;
- brush->color[1] = 0;
- brush->color[0] = 0;
- } else if (typeid(*pattern) == typeid(SplashSolidColor)) {
- /* solid color */
- SplashColor color;
-
- pattern->getColor(0,0,color);
- switch (colorMode) {
- case splashModeMono1:
- brush->color[2] = color[0];
- brush->color[1] = 0;
- brush->color[0] = 0;
- break;
- case splashModeMono8:
- brush->color[2] = color[0];
- brush->color[1] = 0;
- brush->color[0] = 0;
- break;
- case splashModeRGB8:
- brush->color[2] = splashRGB8R(color);
- brush->color[1] = splashRGB8G(color);
- brush->color[0] = splashRGB8B(color);
- break;
- default:
- OPRS::error("Unknown color mode\n");
- brush->color[2] = splashRGB8R(color);
- brush->color[1] = splashRGB8G(color);
- brush->color[0] = splashRGB8B(color);
- break;
- }
- } else {
- /* error */
- return;
- }
-}
-
-bool OPVPSplash::equalPattern(SplashPattern *pat1, SplashPattern *pat2)
-{
- SplashColor c1, c2;
- if (pat1 == NULL || pat2 == NULL) {
- return pat1 == pat2;
- }
- if (typeid(*pat1) != typeid(*pat2)) return false;
-
- pat1->getColor(0,0,c1);
- pat2->getColor(0,0,c2);
- switch (colorMode) {
- case splashModeMono1:
- return c1[0] == c2[0];
- break;
- case splashModeMono8:
- return c1[0] == c2[0];
- break;
- case splashModeRGB8:
- return c1[0] == c2[0] && c1[1] == c2[1] && c1[2] == c2[2];
- break;
- default:
- break;
- }
- return true;
-}
-
-void OPVPSplash::setStrokePattern(SplashPattern *strokePattern) {
- opvp_brush_t brush;
-
- if (!stateBypass && equalPattern(strokePattern,state->strokePattern)) {
- delete strokePattern;
- return;
- }
- state->setStrokePattern(strokePattern);
- makeBrush(strokePattern,&brush);
- if (opvp->SetStrokeColor(&brush) != 0) {
- OPRS::error("SetStrokeColor error\n");
- return;
- }
-}
-
-void OPVPSplash::setFillPattern(SplashPattern *fillPattern) {
- opvp_brush_t brush;
-
- if (!stateBypass && equalPattern(fillPattern,state->fillPattern)) {
- delete fillPattern;
- return;
- }
- state->setFillPattern(fillPattern);
- makeBrush(fillPattern,&brush);
- if (opvp->SetFillColor(&brush) != 0) {
- OPRS::error("SetFillColor error\n");
- return;
- }
-}
-
-void OPVPSplash::setScreen(SplashScreen *screen) {
- state->setScreen(screen);
-}
-
-void OPVPSplash::setLineWidth(SplashCoord lineWidth) {
- if (stateBypass || state->lineWidth != lineWidth) {
- opvp_fix_t width;
-
- state->lineWidth = lineWidth;
- OPVP_F2FIX(lineWidth,width);
- if (opvp->SetLineWidth(width) < 0) {
- OPRS::error("SetLineWidth error\n");
- return;
- }
- }
-}
-
-void OPVPSplash::setLineCap(int lineCap) {
- if (stateBypass || state->lineCap != lineCap) {
- opvp_linecap_t cap;
-
- state->lineCap = lineCap;
- switch (lineCap) {
- case splashLineCapButt:
- cap = OPVP_LINECAP_BUTT;
- break;
- case splashLineCapRound:
- cap = OPVP_LINECAP_ROUND;
- break;
- case splashLineCapProjecting:
- cap = OPVP_LINECAP_SQUARE;
- break;
- default:
- /* error */
- cap = OPVP_LINECAP_BUTT;
- break;
- }
- if (opvp->SetLineCap(cap) < 0) {
- OPRS::error("SetLineCap error\n");
- return;
- }
- }
-}
-
-void OPVPSplash::setLineJoin(int lineJoin) {
- if (stateBypass || state->lineJoin != lineJoin) {
- opvp_linejoin_t join;
-
- state->lineJoin = lineJoin;
- switch (lineJoin) {
- case splashLineJoinMiter:
- join = OPVP_LINEJOIN_MITER;
- break;
- case splashLineJoinRound:
- join = OPVP_LINEJOIN_ROUND;
- break;
- case splashLineJoinBevel:
- join = OPVP_LINEJOIN_BEVEL;
- break;
- default:
- /* error */
- join = OPVP_LINEJOIN_MITER;
- break;
- }
- if (opvp->SetLineJoin(join) < 0) {
- OPRS::error("SetLineJoin error\n");
- return;
- }
- }
-}
-
-void OPVPSplash::setMiterLimit(SplashCoord miterLimit) {
- if (stateBypass || state->miterLimit != miterLimit) {
- opvp_fix_t limit;
-
- state->miterLimit = miterLimit;
- if (noMiterLimit) return;
- if (oldLipsDriver) {
- /* for old driver for lips */
- /* miterLimit is length/2 */
- miterLimit = miterLimit*state->lineWidth*0.5;
- }
- OPVP_F2FIX(miterLimit,limit);
- if (opvp->SetMiterLimit(limit) < 0) {
- OPRS::error("SetMiterLimit error\n");
- return;
- }
- }
-}
-
-void OPVPSplash::setFlatness(SplashCoord flatness) {
- if (flatness < 1) {
- state->flatness = 1;
- } else {
- state->flatness = flatness;
- }
-}
-
-void OPVPSplash::setLineDash(SplashCoord *lineDash, int lineDashLength,
- SplashCoord lineDashPhase) {
- int i;
- opvp_fix_t *pdash;
- bool equal;
-
- if (stateBypass || lineDash != state->lineDash) {
- if (lineDash == NULL || lineDashLength == 0) {
- if (!noLineStyle
- && opvp->SetLineStyle(OPVP_LINESTYLE_SOLID) < 0) {
- OPRS::error("SetLineStyle error\n");
- return;
- }
- state->setLineDash(lineDash, lineDashLength, lineDashPhase);
- return;
- } else if (stateBypass || state->lineDash == NULL) {
- if (!noLineStyle
- && opvp->SetLineStyle(OPVP_LINESTYLE_DASH) < 0) {
- OPRS::error("SetLineStyle error\n");
- return;
- }
- }
- }
- if (lineDash == NULL || lineDashLength == 0) return;
- if (!noLineStyle) {
- equal = (state->lineDash != NULL);
- pdash = new opvp_fix_t[lineDashLength];
- for (i = 0;i < lineDashLength;i++) {
- if (equal && lineDash[i] != state->lineDash[i]) equal = false;
- OPVP_F2FIX(lineDash[i],pdash[i]);
- }
- if (!equal && opvp->SetLineDash(lineDashLength,pdash) < 0) {
- OPRS::error("SetLineDash error\n");
- goto err;
- }
- if (stateBypass || lineDashPhase != state->lineDashPhase) {
- opvp_fix_t offset;
-
- OPVP_F2FIX(lineDashPhase,offset);
- if (opvp->SetLineDashOffset(offset) < 0) {
- OPRS::error("SetLineDashOffset error\n");
- goto err;
- }
- }
-err:
- delete[] pdash;
- }
- state->setLineDash(lineDash, lineDashLength, lineDashPhase);
-}
-
-SplashError OPVPSplash::doClipPath(OPVPSplashPath *path, bool eo,
- OPVPClipPath *prevClip)
-{
- SplashError result;
-
- if (path->getLength() > maxClipPathLength) {
- if (!noClipPath) {
- if (prevClip != 0 &&
- prevClip->getPath()->getLength() <= maxClipPathLength) {
- /* previous clipping is printer clipping */
- if (opvp->ResetClipPath() != 0) {
- OPRS::error("ResetClipPath error\n");
- return splashErrOPVP;
- }
- }
- noClipPath = true;
- }
- } else {
- noClipPath = savedNoClipPath;
- }
- if (!noClipPath && path->getLength() > 0) {
- /* when path->length == 0, no drawable arae, and no output
- so, it isn't need to set ClipPath */
- if ((result = path->makePath(opvp)) != splashOk) {
- return result;
- }
- if (opvp->SetClipPath(
- eo ? OPVP_CLIPRULE_EVENODD : OPVP_CLIPRULE_WINDING) < 0) {
- OPRS::error("SetClipPath error\n");
- return splashErrOPVP;
- }
- }
- return splashOk;
-}
-
-SplashError OPVPSplash::makeRectanglePath(SplashCoord x0,
- SplashCoord y0, SplashCoord x1, SplashCoord y1, OPVPSplashPath **p)
-{
- SplashError result;
-
- *p = new OPVPSplashPath();
- if ((result = (*p)->moveTo(x0,y0)) != splashOk) return result;
- if ((result = (*p)->lineTo(x1,y0)) != splashOk) return result;
- if ((result = (*p)->lineTo(x1,y1)) != splashOk) return result;
- if ((result = (*p)->lineTo(x0,y1)) != splashOk) return result;
- if ((result = (*p)->close()) != splashOk) return result;
- return splashOk;
-}
-
-void OPVPSplash::clipResetToRect(SplashCoord x0, SplashCoord y0,
- SplashCoord x1, SplashCoord y1) {
- OPVPSplashPath *p;
- OPVPClipPath *cp;
-
- while ((cp = OPVPClipPath::pop()) != NULL) delete cp;
- if (clipPath != 0) {
- delete clipPath;
- clipPath = 0;
- }
-
- if (makeRectanglePath(x0,y0,x1,y1,&p) != splashOk) return;
-
- if (doClipPath(p,true,clipPath) != splashOk) return;
- clipPath = new OPVPClipPath(p,true);
- state->clip->resetToRect(x0, y0, x1, y1);
-}
-
-SplashError OPVPSplash::clipToPath(OPVPSplashPath *path, bool eo) {
- SplashError result;
- SplashCoord x0, y0, x1, y1;
- SplashCoord x2, y2, x3, y3;
- SplashClipResult clipResult;
- int xMin, yMin, xMax, yMax;
-
- if (path == 0) return splashErrBogusPath;
- if (path->getLength() == 0) return splashOk;
- if (clipPath == 0) {
- /* no clip region exist */
- if ((result = state->clip->clipToPath(path, state->matrix,
- state->flatness, eo)) != splashOk) {
- return result;
- }
- path = path->copy();
- } else {
- OPVPSplashPath *oldPath = clipPath->getPath();
- if (path->isRectanglePath(&x0,&y0,&x1,&y1)) {
- if ((clipResult = state->clip->testRect(
- splashRound(x0), splashRound(y0), splashRound(x1), splashRound(y1)))
- == splashClipAllOutside) {
- /* no drawable area */
- if ((result = state->clip->clipToPath(path, state->matrix,
- state->flatness, eo)) != splashOk) {
- return result;
- }
- path = new OPVPSplashPath();
- } else if (clipResult == splashClipPartial) {
- if (oldPath->isRectanglePath(&x2,&y2,&x3,&y3)) {
- if ((result = state->clip->clipToPath(path, state->matrix,
- state->flatness, eo)) != splashOk) {
- return result;
- }
- /* both rectangle */
- if (x0 < x2) x0 = x2;
- if (y0 < y2) y0 = y2;
- if (x1 > x3) x1 = x3;
- if (y1 > y3) y1 = y3;
- if ((result = makeRectanglePath(x0,y0,x1,y1,&path)) != splashOk) {
- return result;
- }
- } else {
- state->clip->getBBox(&xMin,&yMin,&xMax,&yMax);
- if (splashRound(x0) <= xMin && splashRound(y0) <= yMin
- && splashRound(x1) >= xMax && splashRound(y1)) {
- /* The old path is all inside the new path */
- /* We may ignore the new path */
- return splashOk;
- }
- if ((result = state->clip->clipToPath(path, state->matrix,
- state->flatness, eo)) != splashOk) {
- return result;
- }
- if (state->clip->getNumPaths() > 0) {
- path = state->clip->makePath();
- } else {
- path = new OPVPSplashPath();
- }
- }
- } else {
- /* splashClipAllInside */
- /* We may ignore the previous region. */
- if ((result = state->clip->clipToPath(path, state->matrix,
- state->flatness, eo)) != splashOk) {
- return result;
- }
- path = path->copy();
- }
- } else {
- /* non rectangle path */
-
- OPVPSplashXPath *xpath = new OPVPSplashXPath(path, state->matrix,
- state->flatness, false);
-
- xpath->sort();
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- SplashXPathScanner *scanner = new SplashXPathScanner(xpath,eo,
- INT_MIN,INT_MAX);
-#else
- SplashXPathScanner *scanner = new SplashXPathScanner(xpath,eo);
-#endif
- scanner->getBBox(&xMin,&yMin,&xMax,&yMax);
- delete scanner;
- delete xpath;
- if ((clipResult = state->clip->testRect(xMin,yMin,xMax,yMax))
- == splashClipAllOutside) {
- /* no efect */
- /* no drawable area */
- if ((result = state->clip->clipToPath(path, state->matrix,
- state->flatness, eo)) != splashOk) {
- return result;
- }
- path = new OPVPSplashPath();
- } else if (clipResult == splashClipPartial) {
- OPVPSplashClip *nclip = new OPVPSplashClip(xMin,yMin,xMax,yMax,false);
- nclip->clipToPath(path,state->matrix,state->flatness,eo);
- state->clip->getBBox(&xMin,&yMin,&xMax,&yMax);
- if ((clipResult = nclip->testRect(xMin,yMin,xMax,yMax))
- == splashClipAllOutside) {
- /* no drawable area */
- delete nclip;
- if ((result = state->clip->clipToPath(path, state->matrix,
- state->flatness, eo)) != splashOk) {
- return result;
- }
- path = new OPVPSplashPath();
- } else {
- delete nclip;
- if (clipResult == splashClipAllInside) {
- /* The old path is all inside the new path */
- /* We may ignore the new path */
- return splashOk;
- }
- if ((result = state->clip->clipToPath(path, state->matrix,
- state->flatness, eo)) != splashOk) {
- return result;
- }
- if (state->clip->getNumPaths() > 0) {
- path = state->clip->makePath();
- } else {
- path = new OPVPSplashPath();
- }
- }
- } else {
- /* splashClipAllInside */
- /* We may ignore the previous region. */
- if ((result = state->clip->clipToPath(path, state->matrix,
- state->flatness, eo)) != splashOk) {
- return result;
- }
- path = path->copy();
- }
- }
- }
- if ((result = doClipPath(path,eo,clipPath)) != splashOk) {
- delete path;
- return result;
- }
- if (clipPath != 0) delete clipPath;
- clipPath = new OPVPClipPath(path,eo);
-
- return splashOk;
-}
-
-//------------------------------------------------------------------------
-// state save/restore
-//------------------------------------------------------------------------
-
-void OPVPSplash::saveState() {
- OPVPSplashState *newState;
-
- newState = state->copy();
- newState->next = state;
- state = newState;
- if (clipPath != 0) clipPath->push();
- if (opvp->SaveGS() != 0) {
- OPRS::error("SaveGS error\n");
- return;
- }
- saveDriverStateCount++;
-}
-
-SplashError OPVPSplash::restoreState() {
- OPVPSplashState *oldState;
- OPVPClipPath *oldClip;
- OPVPSplashPath *path;
- bool saved = false;
-
- if (!state->next) {
- return splashErrNoSave;
- }
- oldState = state;
- state = state->next;
- delete oldState;
- if (saveDriverStateCount > 0 && opvp->RestoreGS() != 0) {
- OPRS::error("RestoreGS error\n");
- return splashErrOPVP;
- }
- saveDriverStateCount--;
- oldClip = clipPath;
- if (clipPath != 0) {
- saved = clipPath->getSaved();
- delete clipPath;
- clipPath = 0;
- }
- clipPath = OPVPClipPath::pop();
- if (clipPath != 0) {
- path = clipPath->getPath();
- if (path->getLength() > maxClipPathLength) {
- if (clipPathNotSaved && !noClipPath) {
- if (opvp->ResetClipPath() != 0) {
- OPRS::error("ResetClipPath error\n");
- return splashErrOPVP;
- }
- noClipPath = true;
- }
- } else {
- noClipPath = savedNoClipPath;
- }
- } else {
- noClipPath = savedNoClipPath;
- }
- if (clipPathNotSaved && !noClipPath) {
- if (clipPath != 0) {
- if (!saved) {
- SplashError result;
-
- if ((result = doClipPath(clipPath->getPath(),clipPath->getEo(),
- oldClip))
- != splashOk) return result;
- }
- } else if (oldClip != 0) {
- if (opvp->ResetClipPath() != 0) {
- OPRS::error("ResetClipPath error\n");
- return splashErrOPVP;
- }
- }
- }
- return splashOk;
-}
-
-//------------------------------------------------------------------------
-// drawing operations
-//------------------------------------------------------------------------
-
-void OPVPSplash::clear(SplashColor color)
-{
- opvp_brush_t brush;
-
- brush.colorSpace = getOPVPColorSpace();
- brush.pbrush = NULL;
- brush.color[3] = -1;
- brush.xorg = brush.yorg = 0;
- switch (colorMode) {
- case splashModeMono1:
- brush.color[2] = color[0];
- brush.color[1] = 0;
- brush.color[0] = 0;
- break;
- case splashModeMono8:
- brush.color[2] = color[0];
- brush.color[1] = 0;
- brush.color[0] = 0;
- break;
- case splashModeRGB8:
- brush.color[2] = splashRGB8R(color);
- brush.color[1] = splashRGB8G(color);
- brush.color[0] = splashRGB8B(color);
- break;
- default:
- OPRS::error("Unknown color mode\n");
- brush.color[2] = splashRGB8R(color);
- brush.color[1] = splashRGB8G(color);
- brush.color[0] = splashRGB8B(color);
- break;
- }
- opvp->SetBgColor(&brush);
-}
-
-/*
- Translate arc to Bezier Curve
-
- input start point (x0,y0) , center (cx, cy) and end point (x3, y3)
- return Bezier curve control points (rx1,ry1 and rx2, ry2)
-
- an angle should be less than eqaul 90 degree
-
-*/
-void OPVPSplash::arcToCurve(SplashCoord x0, SplashCoord y0,
- SplashCoord x3, SplashCoord y3,
- SplashCoord cx, SplashCoord cy, SplashCoord *rx1, SplashCoord *ry1,
- SplashCoord *rx2, SplashCoord *ry2)
-{
-#define ROTX(x,y) (x*rotcos-y*rotsin)*r+cx
-#define ROTY(x,y) (x*rotsin+y*rotcos)*r+cy
-
- SplashCoord x1,y1,x2,y2;
- SplashCoord r;
- SplashCoord rotcos, rotsin;
- SplashCoord ox,oy,hx,hy,d;
-
- hx = (x0+x3)/2;
- hy = (y0+y3)/2;
- r = splashDist(x0,y0,cx,cy);
- d = splashDist(x0,y0,hx,hy);
- rotcos = (hx-cx)/d;
- rotsin = (hy-cy)/d;
- oy = (splashDist(x0,y0,x3,y3)/2)/r;
- ox = splashDist(hx,hy,cx,cy)/r;
- x1 = ((4-ox)/3);
- y1 = ((1-ox)*(3-ox)/(3*oy));
- x2 = x1;
- y2 = -y1;
- *rx1 = ROTX(x1,y1);
- *ry1 = ROTY(x1,y1);
- *rx2 = ROTX(x2,y2);
- *ry2 = ROTY(x2,y2);
-#undef ROTX
-#undef ROTY
-}
-
-SplashError OPVPSplash::strokeByMyself(OPVPSplashPath *path)
-{
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- SplashPath *dPath;
- OPVPSplashPath *oPath;
- Splash *osplash;
- SplashPattern *savedPattern;
-
- /* draw dashed line by myself */
- if (path->getLength() == 0) {
- return splashOk;
- }
-
- osplash = new Splash(new SplashBitmap(1,1,4,splashModeMono1,false),false);
- state->setState(osplash);
- dPath = osplash->makeStrokePath(path,state->lineWidth);
- oPath = new OPVPSplashPath(dPath);
- delete dPath;
-
- if (state->lineWidth <= 1) {
- OPVPSplashXPath *xPath;
- xPath = new OPVPSplashXPath(oPath, state->matrix, state->flatness, false);
- xPath->strokeNarrow(this,state);
- delete xPath;
- } else {
- /* change fill pattern temprarily */
- savedPattern = state->fillPattern->copy();
- setFillPattern(state->strokePattern->copy());
-
- fillByMyself(oPath,false);
-
- /* restore fill pattern */
- setFillPattern(savedPattern);
- }
- delete osplash;
- return splashOk;
-#else
- OPVPSplashXPath *xPath, *xPath2;
- SplashPattern *savedPattern;
-
- /* draw dashed line by myself */
- if (path->getLength() == 0) {
- return splashOk;
- }
- xPath = new OPVPSplashXPath(path, state->matrix, state->flatness, false);
- if (state->lineDash != NULL && state->lineDashLength > 0) {
- xPath2 = xPath->makeDashedPath(state);
- delete xPath;
- xPath = xPath2;
- }
-
- if (state->lineWidth <= 1) {
- xPath->strokeNarrow(this,state);
- } else {
- /* change fill pattern temprarily */
- savedPattern = state->fillPattern->copy();
- setFillPattern(state->strokePattern->copy());
-
- xPath->strokeWide(this,state);
-
- /* restore fill pattern */
- setFillPattern(savedPattern);
- }
-
- delete xPath;
- return splashOk;
-#endif
-}
-
-SplashError OPVPSplash::stroke(OPVPSplashPath *path) {
- SplashError result;
-
- if (clipPath != 0 && clipPath->getPath()->getLength() == 0) {
- return splashOk;
- }
- if ((state->lineDash != NULL
- && state->lineDashLength > 0 && noLineStyle)) {
- return strokeByMyself(path);
- }
- if (noMiterLimit && (!ignoreMiterLimit) && state->lineWidth != 0
- && state->lineJoin == splashLineJoinMiter) {
- return strokeByMyself(path);
- }
- if (noClipPath) {
- int xMin, yMin, xMax, yMax;
- SplashClipResult clipResult;
- int fatOffset = splashCeil(state->lineWidth/2);
- int miterLimit = splashCeil(state->miterLimit/2);
-
- if (fatOffset < miterLimit) fatOffset = miterLimit;
- path->getBBox(&xMin,&yMin,&xMax,&yMax);
- xMin -= fatOffset;
- yMin -= fatOffset;
- xMax += fatOffset;
- yMax += fatOffset;
- clipResult = state->clip->testRect(xMin,yMin,xMax,yMax);
- if (clipResult == splashClipAllOutside) {
- /* not need to draw */
- return splashOk;
- } else if (clipResult == splashClipPartial) {
- return strokeByMyself(path);
- }
- /* splashClipAllInside */
- /* fall through */
- }
- if ((result = path->makePath(opvp)) != 0) return result;
- if (opvp->StrokePath() < 0) {
- OPRS::error("StrokePath error\n");
- return splashErrOPVP;
- }
- return splashOk;
-}
-
-SplashError OPVPSplash::fillByMyself(OPVPSplashPath *path, bool eo)
-{
- OPVPSplashXPath *xPath;
- SplashXPathScanner *scanner;
- int xMinI, yMinI, xMaxI, yMaxI, x0, x1, y;
- SplashClipResult clipRes, clipRes2;
-
- if (path->getLength() == 0) {
- return splashOk;
- }
- xPath = new OPVPSplashXPath(path, state->matrix, state->flatness, true);
- xPath->sort();
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- scanner = new SplashXPathScanner(xPath, eo, INT_MIN, INT_MAX);
-#else
- scanner = new SplashXPathScanner(xPath, eo);
-#endif
-
- // get the min and max x and y values
- scanner->getBBox(&xMinI, &yMinI, &xMaxI, &yMaxI);
-
- // check clipping
- if ((clipRes = state->clip->testRect(xMinI, yMinI, xMaxI, yMaxI))
- != splashClipAllOutside) {
- SplashPattern *savedPattern;
-
- /* change stroke pattern temporarily */
- savedPattern = state->strokePattern->copy();
- setStrokePattern(state->fillPattern->copy());
-
- for (y = yMinI; y < yMaxI; ++y) {
- while (scanner->getNextSpan(y, &x0, &x1)) {
- if (x0 == x1) continue;
- if (clipRes == splashClipAllInside) {
- drawSpan(x0, x1-1, y, true);
- } else {
- clipRes2 = state->clip->testSpan(x0, x1, y);
- drawSpan(x0, x1-1, y, clipRes2 == splashClipAllInside);
- }
- }
- }
- /* restore stroke pattern */
- setStrokePattern(savedPattern);
- }
-
- delete scanner;
- delete xPath;
- return splashOk;
-}
-
-SplashError OPVPSplash::fill(OPVPSplashPath *path, bool eo) {
- SplashError result;
- opvp_fillmode_t mode;
-
- if (path->getLength() <= 1) return splashOk;
- if (clipPath != 0 && clipPath->getPath()->getLength() == 0) {
- return splashOk;
- }
- if (path->getLength() > maxFillPathLength) {
- return fillByMyself(path,eo);
- }
- if (noClipPath) {
- int xMin, yMin, xMax, yMax;
- SplashClipResult clipResult;
-
- path->getBBox(&xMin,&yMin,&xMax,&yMax);
- clipResult = state->clip->testRect(xMin,yMin,xMax,yMax);
- if (clipResult == splashClipAllOutside) {
- /* not need to draw */
- return splashOk;
- } else if (clipResult == splashClipPartial) {
- return fillByMyself(path,eo);
- }
- /* splashClipAllInside */
- /* fall through */
- }
- if ((result = path->makePath(opvp)) != 0) return result;
- mode = eo ? OPVP_FILLMODE_EVENODD : OPVP_FILLMODE_WINDING;
- if (opvp->SetFillMode(mode) < 0) {
- OPRS::error("SetFillMode error\n");
- return splashErrOPVP;
- }
- if (opvp->FillPath() < 0) {
- OPRS::error("FillPath error\n");
- return splashErrOPVP;
- }
- return splashOk;
-}
-
-void OPVPSplash::fillGlyph(SplashCoord x, SplashCoord y,
- SplashGlyphBitmap *glyph)
-{
- opvp_fix_t opvpx,opvpy;
- int opvpbytes;
- int x0, y0;
- Guchar *bp;
- SplashClipResult clipRes;
- SplashCoord xt, yt;
-
- transform(state->matrix,x,y,&xt,&yt);
- x0 = splashFloor(xt)-glyph->x;
- y0 = splashFloor(yt)-glyph->y;
- clipRes = state->clip->testRect(x0,y0,
- x0 + glyph->w - 1,
- y0 + glyph->h - 1);
- if (clipRes == splashClipAllOutside) return;
- OPVP_i2Fix((x0),(opvpx));
- OPVP_i2Fix((y0),(opvpy));
- if (opvp->SetCurrentPoint(opvpx,opvpy) < 0) {
- OPRS::error("SetCurrentPoint error\n");
- }
-
- if (oldLipsDriver && (((glyph->w+7)/8) & 3) != 0) {
- /* not 4bytes aligned, so make aligned */
- int i;
- int m = (glyph->w+7)/8;
-
- opvpbytes = (m+3)/4;
- opvpbytes *= 4;
- bp = (Guchar *)gmallocn(glyph->h,opvpbytes);
- for (i = 0;i < glyph->h;i++) {
- memcpy(bp+i*opvpbytes,glyph->data+i*m,m);
- }
- } else {
- bp = glyph->data;
- opvpbytes = (glyph->w+7)/8;
- }
- if ((!noClipPath || clipRes != splashClipPartial) && !noImageMask) {
- if (opvp->DrawImage(glyph->w,glyph->h,opvpbytes,OPVP_IFORMAT_MASK,
- glyph->w,glyph->h,(void *)bp) < 0) {
- OPRS::error("DrawImage error\n");
- }
- } else {
- int tx,ty;
- int sx = 0;
- SplashPattern *savedPattern;
- SplashCoord *savedLineDash = 0;
- int savedLineDashLength;
- SplashCoord savedLineDashPhase;
- SplashCoord savedLineWidth;
-
- /* change stroke pattern temprarily */
- savedPattern = state->strokePattern->copy();
- setStrokePattern(state->fillPattern->copy());
- /* change lins style temporarily */
- savedLineDashLength = state->lineDashLength;
- savedLineDashPhase = state->lineDashPhase;
- if (savedLineDashLength > 0 && state->lineDash != 0) {
- savedLineDash = new SplashCoord[savedLineDashLength];
- memcpy(savedLineDash, state->lineDash,
- savedLineDashLength*sizeof(SplashCoord));
- }
- setLineDash(0,0,0);
- savedLineWidth = state->lineWidth;
- setLineWidth(0.0);
-
-
- for (ty = 0;ty < glyph->h;ty++) {
- bool dmode = false;
- for (tx = 0;tx < glyph->w;tx++) {
- bool on = (bp[opvpbytes*ty+(tx/8)] & (0x80 >> (tx & 7))) != 0;
-
- if (on && !dmode) {
- sx = tx;
- dmode = true;
- } else if (!on && dmode) {
- drawSpan(x0+sx,x0+tx-1,y0+ty,true);
- dmode = false;
- }
- }
- if (dmode) {
- drawSpan(x0+sx,x0+tx-1,y0+ty,true);
- }
- }
- /* restore stroke pattern */
- setStrokePattern(savedPattern);
- /* restore line style */
- setLineDash(savedLineDash,savedLineDashLength,
- savedLineDashPhase);
- if (savedLineDash != 0) {
- delete[] savedLineDash;
- }
- setLineWidth(savedLineWidth);
- }
- if (bp != glyph->data) gfree(bp);
-}
-
-SplashError OPVPSplash::fillChar(SplashCoord x, SplashCoord y,
- int c, SplashFont *font,
- Unicode *u, double *fontMat) {
- SplashError err = splashOk;
- SplashPath *spath;
- OPVPSplashPath *path;
- SplashCoord xt, yt;
- double mx,my;
-
- transform(state->matrix, x, y, &xt, &yt);
- if ((spath = font->getGlyphPath(c)) == 0) return splashOk;
- path = new OPVPSplashPath(spath);
- delete spath;
- if (bitmapCharThreshold > 0) {
- mx = splashAbs(fontMat[0]);
- if (mx < splashAbs(fontMat[1])) {
- mx = splashAbs(fontMat[1]);
- }
- my = splashAbs(fontMat[3]);
- if (my < splashAbs(fontMat[2])) {
- my = splashAbs(fontMat[2]);
- }
- if (path == 0 || (mx*my < bitmapCharThreshold)) {
- /* if a char is enough small, then out a char as a bitmask */
- SplashGlyphBitmap glyph;
- int x0, y0, xFrac, yFrac;
- SplashClipResult clipRes;
-
- x0 = splashFloor(xt);
- xFrac = splashFloor((xt - x0) * splashFontFraction);
- y0 = splashFloor(yt);
- yFrac = splashFloor((yt - y0) * splashFontFraction);
- if (font->getGlyph(c, xFrac, yFrac, &glyph, x0, y0, state->clip,
- &clipRes)) {
- if (path != 0) delete path;
- if (glyph.w == 0 || glyph.h == 0) {
- /* empty glyph */
- return splashOk;
- }
- if (clipRes != splashClipAllOutside) {
- fillGlyph(xt, yt, &glyph);
- }
- if (glyph.freeData) {
- gfree(glyph.data);
- }
- return err;
- }
- }
- /* fall through and out a char as a path */
- }
- if (path == 0) {
- //OPRS::error("FillPath error\n");
- err = splashErrOPVP;
- goto err0;
- }
- path->offset(xt,yt);
- err = fill(path,false);
-err0:
- if (path != 0) delete path;
- return err;
-}
-
-SplashError OPVPSplash::fillImageMaskFastWithCTM(SplashImageMaskSource src,
- void *srcData, int w, int h, int tx, int ty,SplashCoord *mat) {
- int i, j;
- opvp_fix_t opvpx,opvpy;
- int opvpbytes;
- opvp_ctm_t opvpctm;
- Guchar *buf = 0, *bp;
- SplashError result = splashOk;
- SplashColorPtr lineBuf;
-
- opvpbytes = (w+7)/8;
- /* align 4 */
- opvpbytes = (opvpbytes+3)/4;
- opvpbytes *= 4;
- buf = (Guchar *)gmallocn(h,opvpbytes);
- lineBuf = (SplashColorPtr)gmallocn(8,opvpbytes);
-
- for (i = 0;i < h;i++) {
- int k;
-
- bp = buf+opvpbytes*i;
- (*src)(srcData, lineBuf);
- for (j = 0;j < w;j += k) {
- Guchar d;
-
- d = 0;
- for (k = 0;k < 8 && j+k < w;k++) {
- d <<= 1;
- if (lineBuf[j+k] != 0) d |= 1;
- }
- d <<= 8-k;
- *bp++ = d;
- }
- }
- free(lineBuf);
- opvpctm.a = mat[0];
- opvpctm.b = mat[1];
- opvpctm.c = mat[2];
- opvpctm.d = mat[3];
- opvpctm.e = mat[4];
- opvpctm.f = mat[5];
- OPVP_i2Fix((tx),(opvpx));
- OPVP_i2Fix((ty),(opvpy));
- if (opvp->SetCurrentPoint(opvpx,opvpy) < 0) {
- OPRS::error("SetCurrentPoint error\n");
- }
-
- if (opvp->SetCTM(&opvpctm) < 0) {
- OPRS::error("SetCTM error\n");
- }
- if (opvp->DrawImage(w,h,opvpbytes,OPVP_IFORMAT_MASK,1,1,(void *)(buf)) < 0) {
- OPRS::error("DrawImage error\n");
- result = splashErrOPVP;
- }
- /* reset CTM */
- opvpctm.a = 1.0;
- opvpctm.b = 0.0;
- opvpctm.c = 0.0;
- opvpctm.d = 1.0;
- opvpctm.e = 0.0;
- opvpctm.f = 0.0;
- if (opvp->SetCTM(&opvpctm) < 0) {
- OPRS::error("SetCTM error\n");
- }
-
- if (buf != 0) gfree(buf);
- return result;
-}
-
-SplashError OPVPSplash::fillImageMask(SplashImageMaskSource src, void *srcData,
- int w, int h, SplashCoord *mat, bool glyphMode) {
- bool rot;
- SplashCoord xScale, yScale, xShear, yShear;
- int tx, ty, scaledWidth, scaledHeight, xSign, ySign;
- int ulx, uly, llx, lly, urx, ury, lrx, lry;
- int ulx1, uly1, llx1, lly1, urx1, ury1, lrx1, lry1;
- int xMin, xMax, yMin, yMax;
- SplashClipResult clipRes;
- SplashColorPtr pixBuf;
- SplashColorPtr p;
- int x, y;
- int i;
- SplashPattern *savedPattern;
- SplashCoord *savedLineDash = 0;
- int savedLineDashLength;
- SplashCoord savedLineDashPhase;
- SplashCoord savedLineWidth;
-
- if (debugMode) {
- printf("fillImageMask: w=%d h=%d mat=[%.2f %.2f %.2f %.2f %.2f %.2f]\n",
- w, h, mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
- }
-
- // check for singular matrix
- if (splashAbs(mat[0] * mat[3] - mat[1] * mat[2]) < 0.000001) {
- return splashErrSingularMatrix;
- }
-
- // compute scale, shear, rotation, translation parameters
- rot = splashAbs(mat[1]) > splashAbs(mat[0]);
- if (rot) {
- xScale = -mat[1];
- yScale = mat[2] - (mat[0] * mat[3]) / mat[1];
- xShear = -mat[3] / yScale;
- yShear = -mat[0] / mat[1];
- } else {
- xScale = mat[0];
- yScale = mat[3] - (mat[1] * mat[2]) / mat[0];
- xShear = mat[2] / yScale;
- yShear = mat[1] / mat[0];
- }
- tx = splashRound(mat[4]);
- ty = splashRound(mat[5]);
- scaledWidth = abs(splashRound(mat[4] + xScale) - tx) + 1;
- scaledHeight = abs(splashRound(mat[5] + yScale) - ty) + 1;
- xSign = (xScale < 0) ? -1 : 1;
- ySign = (yScale < 0) ? -1 : 1;
-
- // clipping
- ulx1 = 0;
- uly1 = 0;
- urx1 = xSign * (scaledWidth - 1);
- ury1 = splashRound(yShear * urx1);
- llx1 = splashRound(xShear * ySign * (scaledHeight - 1));
- lly1 = ySign * (scaledHeight - 1) + splashRound(yShear * llx1);
- lrx1 = xSign * (scaledWidth - 1) +
- splashRound(xShear * ySign * (scaledHeight - 1));
- lry1 = ySign * (scaledHeight - 1) + splashRound(yShear * lrx1);
- if (rot) {
- ulx = tx + uly1; uly = ty - ulx1;
- urx = tx + ury1; ury = ty - urx1;
- llx = tx + lly1; lly = ty - llx1;
- lrx = tx + lry1; lry = ty - lrx1;
- } else {
- ulx = tx + ulx1; uly = ty + uly1;
- urx = tx + urx1; ury = ty + ury1;
- llx = tx + llx1; lly = ty + lly1;
- lrx = tx + lrx1; lry = ty + lry1;
- }
- xMin = (ulx < urx) ? (ulx < llx) ? (ulx < lrx) ? ulx : lrx
- : (llx < lrx) ? llx : lrx
- : (urx < llx) ? (urx < lrx) ? urx : lrx
- : (llx < lrx) ? llx : lrx;
- xMax = (ulx > urx) ? (ulx > llx) ? (ulx > lrx) ? ulx : lrx
- : (llx > lrx) ? llx : lrx
- : (urx > llx) ? (urx > lrx) ? urx : lrx
- : (llx > lrx) ? llx : lrx;
- yMin = (uly < ury) ? (uly < lly) ? (uly < lry) ? uly : lry
- : (lly < lry) ? lly : lry
- : (ury < lly) ? (ury < lry) ? ury : lry
- : (lly < lry) ? lly : lry;
- yMax = (uly > ury) ? (uly > lly) ? (uly > lry) ? uly : lry
- : (lly > lry) ? lly : lry
- : (ury > lly) ? (ury > lry) ? ury : lry
- : (lly > lry) ? lly : lry;
- clipRes = state->clip->testRect(xMin, yMin, xMax, yMax);
- if (clipRes == splashClipAllOutside) return splashOk;
-
- if (!noClipPath || clipRes == splashClipAllInside) {
- if (!noShearImage && !noImageMask) {
- if (fillImageMaskFastWithCTM(src,srcData,w,h,tx,ty,mat)
- == splashOk) {
- return splashOk;
- }
- }
- }
-
- SplashError result = splashOk;
- /* change stroke pattern temprarily */
- savedPattern = state->strokePattern->copy();
- setStrokePattern(state->fillPattern->copy());
-
- /* change lins style temporarily */
- savedLineDashLength = state->lineDashLength;
- savedLineDashPhase = state->lineDashPhase;
- if (savedLineDashLength > 0 && state->lineDash != 0) {
- savedLineDash = new SplashCoord[savedLineDashLength];
- memcpy(savedLineDash, state->lineDash,
- savedLineDashLength*sizeof(SplashCoord));
- }
- setLineDash(0,0,0);
- savedLineWidth = state->lineWidth;
- setLineWidth(0.0);
-
- /* calculate inverse matrix */
- SplashCoord imat[4];
- double det = mat[0] * mat[3] - mat[1] * mat[2];
- imat[0] = mat[3]/det;
- imat[1] = -mat[1]/det;
- imat[2] = -mat[2]/det;
- imat[3] = mat[0]/det;
-
- /* read source image */
- pixBuf = (SplashColorPtr)gmallocn(h , w);
-
- p = pixBuf;
- for (i = 0; i < h; ++i) {
- (*src)(srcData, p);
- p += w;
- }
- int width = xMax-xMin+1;
- int height = yMax-yMin+1;
- OPVPSplashClip *clip = state->clip->copy();
-
- if (w < scaledWidth || h < scaledHeight) {
- OPVPSplashPath cpath;
-
- cpath.moveTo(tx,ty);
- cpath.lineTo(mat[0]+tx,mat[1]+ty);
- cpath.lineTo(mat[0]+mat[2]+tx,mat[1]+mat[3]+ty);
- cpath.lineTo(mat[2]+tx,mat[3]+ty);
- clip->clipToPath(&cpath,state->matrix,1.0,false);
- }
- for (y = 0;y < height;y++) {
- int dy = y+yMin-ty;
- int sx = 0;
- bool dmode = false;
-
- for (x = 0;x < width;x++) {
- if (!clip->test(x+xMin,y+yMin)) {
- if (dmode) {
- drawSpan(xMin+sx,xMin+x-1,yMin+y,true);
- dmode = false;
- }
- continue;
- }
- int ox,oy;
- /* calculate original coordinate */
- int dx = x+xMin-tx;
- ox = (int)trunc((imat[0]*dx+imat[2]*dy)*w);
- oy = (int)trunc((imat[1]*dx+imat[3]*dy)*h);
- if (ox >= 0 && ox < w && oy >= 0 && oy < h) {
- bool on = pixBuf[oy*w+ox] != 0;
-
- if (on && !dmode) {
- dmode = true;
- sx = x;
- } else if (!on && dmode) {
- drawSpan(xMin+sx,xMin+x-1,yMin+y,true);
- dmode = false;
- }
- } else if (dmode) {
- drawSpan(xMin+sx,xMin+x-1,yMin+y,true);
- dmode = false;
- }
- }
- if (dmode) {
- drawSpan(xMin+sx,xMin+x-1,yMin+y,true);
- }
- }
- delete clip;
- gfree(pixBuf);
-
- /* restore stroke pattern */
- setStrokePattern(savedPattern);
- /* restore line style */
- setLineDash(savedLineDash,savedLineDashLength,
- savedLineDashPhase);
- if (savedLineDash != 0) {
- delete[] savedLineDash;
- }
- setLineWidth(savedLineWidth);
-
- return result;
-}
-
-SplashError OPVPSplash::drawImageNotShear(SplashImageSource src,
- void *srcData,
- int w, int h,
- int tx, int ty,
- int scaledWidth, int scaledHeight,
- int xSign, int ySign, bool rot) {
- int i, j;
- opvp_fix_t opvpx,opvpy;
- int opvpbytes, linesize;
- opvp_ctm_t opvpctm;
- SplashError result = splashOk;
- Guchar *buf = 0, *bp;
- SplashColorPtr lineBuf = 0, color;
- float e,f;
- int hs,he, hstep;
- int ow = w;
- int lineBufSize;
-
- if (rot) {
- int t = h;
-
- h = w;
- w = t;
- t = scaledHeight;
- scaledHeight = scaledWidth;
- scaledWidth = t;
- if (xSign != ySign) {
- xSign = xSign >= 0 ? -1 : 1;
- } else {
- ySign = ySign >= 0 ? -1 : 1;
- }
- }
-
- if (xSign > 0) {
- OPVP_i2Fix((tx),(opvpx));
- e = tx;
- } else {
- OPVP_i2Fix((tx-scaledWidth),(opvpx));
- e = tx-scaledWidth;
- }
- if (ySign > 0) {
- OPVP_i2Fix((ty),(opvpy));
- f = ty;
- } else {
- OPVP_i2Fix((ty-scaledHeight),(opvpy));
- f = ty-scaledHeight;
- }
- if (opvp->SetCurrentPoint(opvpx,opvpy) < 0) {
- OPRS::error("SetCurrentPoint error\n");
- return splashErrOPVP;
- }
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- linesize = w;
- opvpbytes = (w+3)/4;
- opvpbytes *= 4;
- lineBufSize = (ow+3)/4;
- lineBufSize *= 4;
- break;
- case splashModeRGB8:
- linesize = w*3;;
- opvpbytes = (w*3+3)/4;
- opvpbytes *= 4;
- lineBufSize = (ow*3+3)/4;
- lineBufSize *= 4;
- break;
- default:
- OPRS::error("Image: no supported color mode\n");
- return splashErrOPVP;
- break;
- }
- if (ySign >= 0) {
- hstep = 1;
- hs = 0;
- he = h;
- } else {
- hstep = -1;
- hs = h-1;
- he = -1;
- }
- buf = (Guchar *)gmallocn(h,opvpbytes);
- lineBuf = (SplashColorPtr)gmallocn(lineBufSize,1);
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- if (rot) {
- if (xSign >= 0) {
- for (i = 0;i < w;i++) {
- (*src)(srcData, lineBuf, NULL);
- color = lineBuf;
- for (j = hs;j != he;j += hstep) {
- bp = buf+i+j*opvpbytes;
- *bp = *color++;
- }
- }
- } else {
- for (i = 0;i < w;i++) {
- (*src)(srcData, lineBuf, NULL);
- color = lineBuf;
- for (j = hs;j != he;j += hstep) {
- bp = buf+linesize-1-i+j*opvpbytes;
- *bp = *color++;
- }
- }
- }
- } else {
- if (xSign >= 0) {
- for (i = hs;i != he;i += hstep) {
- bp = buf+opvpbytes*i;
- (*src)(srcData, lineBuf, NULL);
- color = lineBuf;
- for (j = 0;j < w;j++) {
- *bp++ = *color++;
- }
- }
- } else {
- for (i = hs;i != he;i += hstep) {
- bp = buf+opvpbytes*i+linesize-1;
- (*src)(srcData, lineBuf, NULL);
- color = lineBuf;
- for (j = 0;j < w;j++) {
- *bp-- = *color++;
- }
- }
- }
- }
- break;
- case splashModeRGB8:
- if (rot) {
- if (xSign >= 0) {
- for (i = 0;i < w;i++) {
- (*src)(srcData, lineBuf, NULL);
- color = lineBuf;
- for (j = hs;j != he;j += hstep) {
- bp = buf+i*3+j*opvpbytes;
- bp[0] = *color++;
- bp[1] = *color++;
- bp[2] = *color++;
- }
- }
- } else {
- for (i = 0;i < w;i++) {
- (*src)(srcData, lineBuf, NULL);
- color = lineBuf;
- for (j = hs;j != he;j += hstep) {
- bp = buf+linesize-3-i*3+j*opvpbytes;
- bp[0] = *color++;
- bp[1] = *color++;
- bp[2] = *color++;
- }
- }
- }
- } else {
- if (xSign >= 0) {
- for (i = hs;i != he;i += hstep) {
- bp = buf+opvpbytes*i;
- (*src)(srcData, lineBuf, NULL);
- color = lineBuf;
- for (j = 0;j < w;j++) {
- *bp++ = *color++;
- *bp++ = *color++;
- *bp++ = *color++;
- }
- }
- } else {
- for (i = hs;i != he;i += hstep) {
- bp = buf+opvpbytes*i+linesize-1;
- (*src)(srcData, lineBuf, NULL);
- color = lineBuf;
- for (j = 0;j < w;j++) {
- *bp-- = color[2];
- *bp-- = color[1];
- *bp-- = color[0];
- color += 3;
- }
- }
- }
- }
- break;
- default:
- OPRS::error("Image: no supported color mode\n");
- result = splashErrOPVP;
- goto err1;
- break;
- }
- if (lineBuf != 0) gfree(lineBuf);
-
- /* canonlisp driver use CTM only, ignores currentPoint */
- /* So, set start point to CTM */
- opvpctm.a = 1.0;
- opvpctm.b = 0.0;
- opvpctm.c = 0.0;
- opvpctm.d = 1.0;
- opvpctm.e = e;
- opvpctm.f = f;
- if (opvp->SetCTM(&opvpctm) < 0) {
- OPRS::error("SetCTM error\n");
- }
-
- if (opvp->DrawImage(w,h,opvpbytes,OPVP_IFORMAT_RAW,
- scaledWidth,scaledHeight,(void *)(buf)) < 0) {
- OPRS::error("DrawImage error\n");
- result = splashErrOPVP;
- goto err1;
- }
-err1:
- /* reset CTM */
- opvpctm.e = 0.0;
- opvpctm.f = 0.0;
- if (opvp->SetCTM(&opvpctm) < 0) {
- OPRS::error("SetCTM error\n");
- }
-
- if (buf != 0) gfree(buf);
- return result;
-}
-
-SplashError OPVPSplash::drawImageFastWithCTM(SplashImageSource src,
- void *srcData,
- int w, int h, int tx, int ty,
- SplashCoord *mat) {
- int i;
- opvp_fix_t opvpx,opvpy;
- int opvpbytes;
- opvp_ctm_t opvpctm;
- Guchar *buf = 0, *bp;
-
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- opvpbytes = (w+3)/4;
- opvpbytes *= 4;
- break;
- case splashModeRGB8:
- opvpbytes = (w*3+3)/4;
- opvpbytes *= 4;
- break;
- default:
- OPRS::error("Image: no supported color mode\n");
- return splashErrOPVP;
- break;
- }
- buf = (Guchar *)gmallocn(h,opvpbytes);
-
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- for (i = 0;i < h;i++) {
- bp = buf+opvpbytes*i;
- (*src)(srcData, (SplashColorPtr)bp, NULL);
- }
- break;
- case splashModeRGB8:
- for (i = 0;i < h;i++) {
- bp = buf+opvpbytes*i;
- (*src)(srcData, (SplashColorPtr)bp, NULL);
- }
- break;
- default:
- OPRS::error("Image: no supported color mode\n");
- goto err0;
- break;
- }
-
- opvpctm.a = mat[0];
- opvpctm.b = mat[1];
- opvpctm.c = mat[2];
- opvpctm.d = mat[3];
- opvpctm.e = mat[4];
- opvpctm.f = mat[5];
- OPVP_i2Fix((tx),(opvpx));
- OPVP_i2Fix((ty),(opvpy));
- if (opvp->SetCurrentPoint(opvpx,opvpy) < 0) {
- OPRS::error("SetCurrentPoint error\n");
- }
-
- if (opvp->SetCTM(&opvpctm) < 0) {
- OPRS::error("SetCTM error\n");
- }
- if (opvp->DrawImage(w,h,opvpbytes,OPVP_IFORMAT_RAW,1,1,(void *)(buf)) < 0) {
- OPRS::error("DrawImage error\n");
- }
-err0:
- /* reset CTM */
- opvpctm.a = 1.0;
- opvpctm.b = 0.0;
- opvpctm.c = 0.0;
- opvpctm.d = 1.0;
- opvpctm.e = 0.0;
- opvpctm.f = 0.0;
- if (opvp->SetCTM(&opvpctm) < 0) {
- OPRS::error("SetCTM error\n");
- }
-
- if (buf != 0) gfree(buf);
- return splashOk;
-}
-
-SplashError OPVPSplash::drawImage(SplashImageSource src, void *srcData,
- SplashColorMode srcMode, bool srcAlpha,
- int w, int h, SplashCoord *mat) {
- bool ok, rot;
- SplashCoord xScale, yScale, xShear, yShear;
- int tx, ty, scaledWidth, scaledHeight, xSign, ySign;
- int ulx, uly, llx, lly, urx, ury, lrx, lry;
- int ulx1, uly1, llx1, lly1, urx1, ury1, lrx1, lry1;
- int xMin, xMax, yMin, yMax;
- SplashClipResult clipRes;
- SplashColorPtr pixBuf, p;
- int x, y;
- int i;
-
- if (debugMode) {
- printf("drawImage: srcMode=%d w=%d h=%d mat=[%.2f %.2f %.2f %.2f %.2f %.2f]\n",
- srcMode, w, h, mat[0], mat[1], mat[2], mat[3], mat[4], mat[5]);
- }
-
- // check color modes
- ok = false; // make gcc happy
- switch (colorMode) {
- case splashModeMono1:
- ok = srcMode == splashModeMono1 || srcMode == splashModeMono8;
- break;
- case splashModeMono8:
- ok = srcMode == splashModeMono8;
- break;
- case splashModeRGB8:
- ok = srcMode == splashModeRGB8;
- break;
- }
- if (!ok) {
- OPRS::error("Image Mode mismatch\n");
- return splashErrModeMismatch;
- }
-
- // check for singular matrix
- if (splashAbs(mat[0] * mat[3] - mat[1] * mat[2]) < 0.000001) {
- OPRS::error("Image Not Singular Matrix\n");
- return splashErrSingularMatrix;
- }
-
- // compute scale, shear, rotation, translation parameters
- rot = splashAbs(mat[1]) > splashAbs(mat[0]);
- if (rot) {
- xScale = -mat[1];
- yScale = mat[2] - (mat[0] * mat[3]) / mat[1];
- xShear = -mat[3] / yScale;
- yShear = -mat[0] / mat[1];
- } else {
- xScale = mat[0];
- yScale = mat[3] - (mat[1] * mat[2]) / mat[0];
- xShear = mat[2] / yScale;
- yShear = mat[1] / mat[0];
- }
- tx = splashRound(mat[4]);
- ty = splashRound(mat[5]);
- scaledWidth = abs(splashRound(mat[4] + xScale) - tx) + 1;
- scaledHeight = abs(splashRound(mat[5] + yScale) - ty) + 1;
- xSign = (xScale < 0) ? -1 : 1;
- ySign = (yScale < 0) ? -1 : 1;
-
- // clipping
- ulx1 = 0;
- uly1 = 0;
- urx1 = xSign * (scaledWidth - 1);
- ury1 = splashRound(yShear * urx1);
- llx1 = splashRound(xShear * ySign * (scaledHeight - 1));
- lly1 = ySign * (scaledHeight - 1) + splashRound(yShear * llx1);
- lrx1 = xSign * (scaledWidth - 1) +
- splashRound(xShear * ySign * (scaledHeight - 1));
- lry1 = ySign * (scaledHeight - 1) + splashRound(yShear * lrx1);
- if (rot) {
- ulx = tx + uly1; uly = ty - ulx1;
- urx = tx + ury1; ury = ty - urx1;
- llx = tx + lly1; lly = ty - llx1;
- lrx = tx + lry1; lry = ty - lrx1;
- } else {
- ulx = tx + ulx1; uly = ty + uly1;
- urx = tx + urx1; ury = ty + ury1;
- llx = tx + llx1; lly = ty + lly1;
- lrx = tx + lrx1; lry = ty + lry1;
- }
- xMin = (ulx < urx) ? (ulx < llx) ? (ulx < lrx) ? ulx : lrx
- : (llx < lrx) ? llx : lrx
- : (urx < llx) ? (urx < lrx) ? urx : lrx
- : (llx < lrx) ? llx : lrx;
- xMax = (ulx > urx) ? (ulx > llx) ? (ulx > lrx) ? ulx : lrx
- : (llx > lrx) ? llx : lrx
- : (urx > llx) ? (urx > lrx) ? urx : lrx
- : (llx > lrx) ? llx : lrx;
- yMin = (uly < ury) ? (uly < lly) ? (uly < lry) ? uly : lry
- : (lly < lry) ? lly : lry
- : (ury < lly) ? (ury < lry) ? ury : lry
- : (lly < lry) ? lly : lry;
- yMax = (uly > ury) ? (uly > lly) ? (uly > lry) ? uly : lry
- : (lly > lry) ? lly : lry
- : (ury > lly) ? (ury > lry) ? ury : lry
- : (lly > lry) ? lly : lry;
- if ((clipRes = state->clip->testRect(xMin, yMin, xMax, yMax))
- == splashClipAllOutside) {
- return splashOk;
- }
-
- if (!noClipPath || clipRes == splashClipAllInside) {
- if (!srcAlpha && !noShearImage) {
- if (drawImageFastWithCTM(src,srcData,w,h,tx,ty,mat) == splashOk) {
- return splashOk;
- }
- }
- if (!srcAlpha && splashRound(xShear) == 0 && splashRound(yShear) == 0) {
- /* no sheared case */
- if (drawImageNotShear(src,srcData,w,h,tx,ty,
- scaledWidth, scaledHeight,xSign,ySign,rot) == splashOk) {
- return splashOk;
- }
- }
- }
-
- /* shear case */
- SplashError result = splashOk;
-
- /* calculate inverse matrix */
- SplashCoord imat[4];
- double det = mat[0] * mat[3] - mat[1] * mat[2];
- imat[0] = mat[3]/det;
- imat[1] = -mat[1]/det;
- imat[2] = -mat[2]/det;
- imat[3] = mat[0]/det;
-
- opvp_fix_t opvpx,opvpy;
- int opvpbytes, linesize;
- int width = xMax-xMin+1;
- int height = yMax-yMin+1;
- opvp_ctm_t opvpctm;
-
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- if (srcAlpha) {
- /* alpha data exists */
- linesize = w*2;
- } else {
- linesize = w;
- }
- opvpbytes = (width+3)/4;
- opvpbytes *= 4;
- break;
- case splashModeRGB8:
- if (srcAlpha) {
- /* alpha data exists */
- linesize = w*4;
- } else {
- linesize = w*3;
- }
- opvpbytes = (width*3+3)/4;
- opvpbytes *= 4;
- break;
- default:
- OPRS::error("Image: no supported color mode\n");
- return splashErrOPVP;
- break;
- }
-
- /* read source image */
- pixBuf = (SplashColorPtr)gmallocn(h , linesize);
-
- p = pixBuf;
- for (i = 0; i < h; ++i) {
- (*src)(srcData, p, NULL);
- p += linesize;
- }
- /* allocate line buffer */
- Guchar *lineBuf = (Guchar *)gmallocn(opvpbytes,1);
- Guchar *onBuf = (Guchar *)gmallocn(width,1);
- OPVPSplashClip *clip;
- opvpctm.a = 1.0;
- opvpctm.b = 0.0;
- opvpctm.c = 0.0;
- opvpctm.d = 1.0;
-
- clip = state->clip->copy();
- if (w < scaledWidth || h < scaledHeight) {
- OPVPSplashPath cpath;
-
- cpath.moveTo(tx,ty);
- cpath.lineTo(mat[0]+tx,mat[1]+ty);
- cpath.lineTo(mat[0]+mat[2]+tx,mat[1]+mat[3]+ty);
- cpath.lineTo(mat[2]+tx,mat[3]+ty);
- clip->clipToPath(&cpath,state->matrix,1.0,false);
- }
- for (y = 0;y < height;y++) {
- int dy = y+yMin-ty;
- memset(onBuf,0,width);
- if (srcAlpha) {
- /* with alpha data */
- for (x = 0;x < width;x++) {
- if (!clip->test(x+xMin,y+yMin)) continue;
- int ox,oy;
- /* calculate original coordinate */
- int dx = x+xMin-tx;
- ox = (int)trunc((imat[0]*dx+imat[2]*dy)*w);
- oy = (int)trunc((imat[1]*dx+imat[3]*dy)*h);
- if (ox >= 0 && ox < w && oy >= 0 && oy < h) {
- /* in the image */
-
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- onBuf[x] = pixBuf[oy*linesize+ox] != 0;
- lineBuf[x] = pixBuf[oy*linesize+ox+1];
- break;
- case splashModeRGB8:
- p = pixBuf+oy*linesize+ox*4;
- onBuf[x] = (*p++) != 0;
- lineBuf[x*3] = *p++;
- lineBuf[x*3+1] = *p++;
- lineBuf[x*3+2] = *p;
- break;
- default:
- OPRS::error("Image: no supported color mode\n");
- result = splashErrOPVP;
- goto err1;
- break;
- }
- }
- }
- } else {
- for (x = 0;x < width;x++) {
- if (!clip->test(x+xMin,y+yMin)) continue;
- int ox,oy;
- /* calculate original coordinate */
- int dx = x+xMin-tx;
- ox = (int)trunc((imat[0]*dx+imat[2]*dy)*w);
- oy = (int)trunc((imat[1]*dx+imat[3]*dy)*h);
- if (ox >= 0 && ox < w && oy >= 0 && oy < h) {
- /* in the image */
-
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- lineBuf[x] = pixBuf[oy*linesize+ox];
- break;
- case splashModeRGB8:
- p = pixBuf+oy*linesize+ox*3;
- lineBuf[x*3] = *p++;
- lineBuf[x*3+1] = *p++;
- lineBuf[x*3+2] = *p;
- break;
- default:
- OPRS::error("Image: no supported color mode\n");
- result = splashErrOPVP;
- goto err1;
- break;
- }
- onBuf[x] = 1;
- }
- }
- }
- /* out pixel */
- int sx = 0;
- int ex;
- while (sx < width) {
- /* find start pixel */
- for (;onBuf[sx] == 0 && sx < width;sx++);
- if (sx >= width) break;
- /* find end pixel */
- for (ex = sx+1;onBuf[ex] != 0 && ex < width;ex++);
- int n = ex-sx;
- Guchar *bp;
- int ns;
-
- switch (colorMode) {
- case splashModeMono1:
- case splashModeMono8:
- bp = lineBuf+sx;
- ns = n;
- break;
- case splashModeRGB8:
- bp = lineBuf+sx*3;
- ns = n*3;
- break;
- default:
- OPRS::error("Image: no supported color mode\n");
- result = splashErrOPVP;
- goto err1;
- break;
- }
- ns = (ns+3)/4;
- ns *= 4;
-
- OPVP_i2Fix(xMin+sx,(opvpx));
- OPVP_i2Fix(yMin+y,(opvpy));
- if (opvp->SetCurrentPoint(opvpx,opvpy) < 0) {
- OPRS::error("SetCurrentPoint error\n");
- result = splashErrOPVP;
- goto err1;
- }
- /* canonlisp driver use CTM only, ignores currentPoint */
- /* So, set start point to CTM */
- opvpctm.e = xMin+sx;
- opvpctm.f = yMin+y;
- if (opvp->SetCTM(&opvpctm) < 0) {
- OPRS::error("SetCTM error\n");
- }
-
- if (opvp->DrawImage(n,1,ns,OPVP_IFORMAT_RAW,
- n,1,(void *)(bp)) < 0) {
- OPRS::error("DrawImage error\n");
- result = splashErrOPVP;
- goto err1;
- }
-
- /* reset CTM */
- opvpctm.e = 0.0;
- opvpctm.f = 0.0;
- if (opvp->SetCTM(&opvpctm) < 0) {
- OPRS::error("SetCTM error\n");
- }
-
- sx = ex+1;
- }
- }
-
-
-err1:
- delete clip;
- gfree(pixBuf);
- gfree(lineBuf);
- gfree(onBuf);
- return result;
-}
-
-void OPVPSplash::setColorMode(int colorModeA)
-{
- colorMode = colorModeA;
-}
-
-void OPVPSplash::drawSpan(int x0, int x1, int y, bool noClip)
-{
- int s,e;
- opvp_point_t points[1];
- opvp_fix_t opvpx, opvpy;
- SplashCoord *savedLineDash = 0;
- int savedLineDashLength;
- SplashCoord savedLineDashPhase;
- SplashCoord savedLineWidth;
- bool noSpan;
-
-
- if (opvp->NewPath() < 0) {
- OPRS::error("NewPath error\n");
- return;
- }
- if (noClip) {
- noSpan = false;
- OPVP_i2Fix(x0,opvpx);
- OPVP_i2Fix(y,opvpy);
- if (opvp->SetCurrentPoint(opvpx,opvpy) < 0) {
- OPRS::error("SetCurrentPoint error\n");
- return;
- }
- OPVP_i2Fix(x1+1,points[0].x);
- OPVP_i2Fix(y,points[0].y);
- if (opvp->LinePath(OPVP_PATHOPEN,1,points) < 0) {
- OPRS::error("LinePath error\n");
- return;
- }
- } else {
- noSpan = true;
- s = x0;
- while (s < x1) {
- /* find start point */
- for (;s < x1;s++) {
- if (state->clip->test(s, y)) break;
- }
- if (s < x1) {
- /* start point was found */
- /* then find end point */
- for (e = s+1;e < x1;e++) {
- if (!state->clip->test(e, y)) break;
- }
- /* do make span */
- noSpan = false;
- OPVP_i2Fix(s,opvpx);
- OPVP_i2Fix(y,opvpy);
- if (opvp->SetCurrentPoint(opvpx,opvpy) < 0) {
- OPRS::error("SetCurrentPoint error\n");
- return;
- }
- OPVP_i2Fix(e,points[0].x);
- OPVP_i2Fix(y,points[0].y);
- if (opvp->LinePath(OPVP_PATHOPEN,1,points) < 0) {
- OPRS::error("LinePath error\n");
- return;
- }
- s = e;
- }
- }
- }
- if (opvp->EndPath() < 0) {
- OPRS::error("EndPath error\n");
- return;
- }
- if (noSpan) return;
- /* change lins style temporarily */
- savedLineDashLength = state->lineDashLength;
- savedLineDashPhase = state->lineDashPhase;
- if (savedLineDashLength > 0 && state->lineDash != 0) {
- savedLineDash = new SplashCoord[savedLineDashLength];
- memcpy(savedLineDash, state->lineDash,
- savedLineDashLength*sizeof(SplashCoord));
- }
- setLineDash(0,0,0);
- savedLineWidth = state->lineWidth;
- setLineWidth(0.0);
-
- if (opvp->StrokePath() < 0) {
- OPRS::error("StrokePath error\n");
- return;
- }
-
- /* restore line style */
- setLineDash(savedLineDash,savedLineDashLength,
- savedLineDashPhase);
- if (savedLineDash != 0) {
- delete[] savedLineDash;
- }
- setLineWidth(savedLineWidth);
-}
-
-/*
- draw pixel with StrokePath
- color is stroke color
-*/
-void OPVPSplash::drawPixel(int x, int y, bool noClip)
-{
- opvp_point_t points[1];
- opvp_fix_t opvpx, opvpy;
-
- if (noClip || state->clip->test(x, y)) {
- if (opvp->NewPath() < 0) {
- OPRS::error("NewPath error\n");
- return;
- }
- OPVP_i2Fix(x,opvpx);
- OPVP_i2Fix(y,opvpy);
- if (opvp->SetCurrentPoint(opvpx,opvpy) < 0) {
- OPRS::error("NewPath error\n");
- return;
- }
- OPVP_i2Fix(x+1,points[0].x);
- OPVP_i2Fix(y,points[0].y);
- if (opvp->LinePath(OPVP_PATHOPEN,1,points) < 0) {
- OPRS::error("LinePath error\n");
- return;
- }
- if (opvp->EndPath() < 0) {
- OPRS::error("EndPath error\n");
- return;
- }
- if (opvp->StrokePath() < 0) {
- OPRS::error("StrokePath error\n");
- return;
- }
- }
-}
-
-const char *OPVPSplash::getOption(const char *key, int nOptions,
- const char *optionKeys[], const char *optionVals[])
-{
- int i;
-
- for (i = 0;i < nOptions;i++) {
- if (strcmp(key,optionKeys[i]) == 0) {
- return optionVals[i];
- }
- }
- return 0;
-}
-
-void OPVPSplash::endPage()
-{
- if (clipPath != 0) {
- delete clipPath;
- clipPath = 0;
- }
-}
-
-void OPVPSplash::restoreAllDriverState()
-{
- for (;saveDriverStateCount > 0;saveDriverStateCount--) {
- opvp->RestoreGS();
- }
-}
-
-SplashCoord *OPVPSplash::getMatrix()
-{
- return state->matrix;
-}
-
-OPVPClipPath *OPVPClipPath::stackTop = 0;
-
-OPVPClipPath::OPVPClipPath(OPVPSplashPath *pathA, bool eoA)
-{
- path = pathA;
- eo = eoA;
- next = 0;
- saved = false;
-}
-
-void OPVPClipPath::push()
-{
- OPVPClipPath *p;
-
- p = stackTop;
- stackTop = copy();
- stackTop->next = p;
- saved = true;
-}
-
-OPVPClipPath *OPVPClipPath::pop() {
- OPVPClipPath *p = stackTop;
- if (stackTop != 0) stackTop = stackTop->next;
- return p;
-}
-
-OPVPClipPath *OPVPClipPath::copy()
-{
- OPVPClipPath *p;
-
- p = new OPVPClipPath(path->copy(),eo);
- p->saved = saved;
- return p;
-}
diff --git a/filter/pdftoopvp/oprs/OPVPSplash.h b/filter/pdftoopvp/oprs/OPVPSplash.h
deleted file mode 100644
index 200fda375..000000000
--- a/filter/pdftoopvp/oprs/OPVPSplash.h
+++ /dev/null
@@ -1,244 +0,0 @@
-//========================================================================
-//
-// OPVPSplash.h
-//
-//========================================================================
-
-#ifndef OPVPSPLASH_H
-#define OPVPSPLASH_H
-
-#include <config.h>
-
-#ifdef USE_GCC_PRAGMAS
-#pragma interface
-#endif
-
-#include <typeinfo>
-#include "splash/SplashTypes.h"
-#include "splash/SplashPattern.h"
-#include "splash/SplashErrorCodes.h"
-#include "OPVPSplashPath.h"
-#include "OPVPWrapper.h"
-#include "CharTypes.h"
-
-/* extra error code */
-#define splashErrOPVP 100
-
-#define OPVP_MAX_CLIPPATH_LENGTH 2000
-#define OPVP_MAX_FILLPATH_LENGTH 4000
-#define OPVP_BITMAPCHAR_THRESHOLD 2000
-#define OPVP_ROP_SRCCOPY 0xCC
-#define OPVP_ROP_S 0xCC
-#define OPVP_ROP_P 0xF0
-#define OPVP_ROP_PSDPxax 0xB8
-#define OPVP_ROP_DSPDxax 0xE2
-
-class SplashBitmap;
-class SplashGlyphBitmap;
-class OPVPSplashState;
-class SplashPattern;
-class SplashScreen;
-class OPVPSplashPath;
-class OPVPSplashXPath;
-class OPVPSplashClip;
-class SplashFont;
-
-class OPVPClipPath {
-public:
- OPVPClipPath(OPVPSplashPath *pathA, bool eoA);
- void push();
- static OPVPClipPath *pop();
- ~OPVPClipPath() { delete path; }
- OPVPSplashPath *getPath() { return path; }
- bool getEo() { return eo; }
- bool getSaved() { return saved; }
-private:
- OPVPClipPath *copy();
- OPVPClipPath *next;
- OPVPSplashPath *path;
- bool eo;
- bool saved;
- static OPVPClipPath *stackTop;
-};
-
-//------------------------------------------------------------------------
-// Splash
-//------------------------------------------------------------------------
-
-class OPVPSplash {
-public:
-
- // Create a new rasterizer object.
- OPVPSplash(OPVPWrapper *opvpA,
- int nOptions, const char *optionKeys[], const char *optionVals[]);
-
- virtual ~OPVPSplash();
-
- //----- state read
-
- SplashPattern *getStrokePattern();
- SplashPattern *getFillPattern();
- SplashScreen *getScreen();
- SplashCoord getLineWidth();
- int getLineCap();
- int getLineJoin();
- SplashCoord getMiterLimit();
- SplashCoord getFlatness();
- SplashCoord *getLineDash();
- int getLineDashLength();
- SplashCoord getLineDashPhase();
- OPVPSplashClip *getClip();
-
- //----- state write
-
- void setStrokePattern(SplashPattern *strokeColor);
- void setFillPattern(SplashPattern *fillColor);
- void setScreen(SplashScreen *screen);
- void setLineWidth(SplashCoord lineWidth);
- void setLineCap(int lineCap);
- void setLineJoin(int lineJoin);
- void setMiterLimit(SplashCoord miterLimit);
- void setFlatness(SplashCoord flatness);
- // the <lineDash> array will be copied
- void setLineDash(SplashCoord *lineDash, int lineDashLength,
- SplashCoord lineDashPhase);
- void clipResetToRect(SplashCoord x0, SplashCoord y0,
- SplashCoord x1, SplashCoord y1);
- SplashError clipToPath(OPVPSplashPath *path, bool eo);
-
- //----- state save/restore
-
- void saveState();
- SplashError restoreState();
- void restoreAllDriverState();
-
- //----- drawing operations
-
- // Fill the bitmap with <color>. This is not subject to clipping.
- void clear(SplashColor color);
-
- // Stroke a path using the current stroke pattern.
- SplashError stroke(OPVPSplashPath *path);
-
- // Fill a path using the current fill pattern.
- SplashError fill(OPVPSplashPath *path, bool eo);
-
- // Draw a character, using the current fill pattern.
- SplashError fillChar(SplashCoord x, SplashCoord y, int c,
- SplashFont *font, Unicode *u, double *fontMat);
-
- // Draw a glyph, using the current fill pattern. This function does
- // not free any data, i.e., it ignores glyph->freeData.
- // not used in vector mode
- void fillGlyph(SplashCoord x, SplashCoord y,
- SplashGlyphBitmap *glyph);
-
- // Draws an image mask using the fill color. This will read <w>*<h>
- // pixels from <src>, in raster order, starting with the top line.
- // "1" pixels will be drawn with the current fill color; "0" pixels
- // are transparent. The matrix:
- // [ mat[0] mat[1] 0 ]
- // [ mat[2] mat[3] 0 ]
- // [ mat[4] mat[5] 1 ]
- // maps a unit square to the desired destination for the image, in
- // PostScript style:
- // [x' y' 1] = [x y 1] * mat
- // Note that the Splash y axis points downward, and the image source
- // is assumed to produce pixels in raster order, starting from the
- // top line.
- SplashError fillImageMask(SplashImageMaskSource src, void *srcData,
- int w, int h, SplashCoord *mat, bool glyphMode);
-
- // Draw an image. This will read <w>*<h> pixels from <src>, in
- // raster order, starting with the top line. These pixels are
- // assumed to be in the source mode, <srcMode>. The following
- // combinations of source and target modes are supported:
- // source target
- // ------ ------
- // Mono1 Mono1
- // Mono8 Mono1 -- with dithering
- // Mono8 Mono8
- // RGB8 RGB8
- // BGR8packed BGR8Packed
- // The matrix behaves as for fillImageMask.
- SplashError drawImage(SplashImageSource src, void *srcData,
- SplashColorMode srcMode, bool srcAlpha,
- int w, int h, SplashCoord *mat);
-
- //~ drawMaskedImage
-
- //----- misc
-
- // Return the associated bitmap.
- SplashBitmap *getBitmap() { return 0; }
-
- // Toggle debug mode on or off.
- void setDebugMode(bool debugModeA) { debugMode = debugModeA; }
-
- void setColorMode(int colorModeA);
- void setStateBypass(bool bypass) {stateBypass = bypass;}
- void endPage();
- SplashCoord *getMatrix();
- void drawSpan(int x0, int x1, int y, bool noClip);
-#ifdef OLD_DRAW_IMAGE
- void drawPixel(int x, int y, SplashColor *color, bool noClip);
-#endif
- void drawPixel(int x, int y, bool noClip);
- void arcToCurve(SplashCoord x0, SplashCoord y0,
- SplashCoord x3, SplashCoord y3,
- SplashCoord cx, SplashCoord cy, SplashCoord *rx1, SplashCoord *ry1,
- SplashCoord *rx2, SplashCoord *ry2);
-
-private:
- void makeBrush(SplashPattern *pattern, opvp_brush_t *brush);
- SplashError doClipPath(OPVPSplashPath *path, bool eo,
- OPVPClipPath *prevClip);
- opvp_cspace_t getOPVPColorSpace();
- bool equalPattern(SplashPattern *pt1, SplashPattern *pt2);
- SplashError makeRectanglePath(SplashCoord x0, SplashCoord y0,
- SplashCoord x1, SplashCoord y1, OPVPSplashPath **p);
- SplashError drawImageFastWithCTM(SplashImageSource src, void *srcData,
- int w, int h, int tx, int ty,
- SplashCoord *mat);
- SplashError drawImageNotShear(SplashImageSource src,
- void *srcData,
- int w, int h,
- int tx, int ty,
- int scaledWidth, int scaledHeight,
- int xSign, int ySign, bool rot);
- SplashError fillImageMaskFastWithCTM(SplashImageMaskSource src,
- void *srcData, int w, int h, int tx, int ty,SplashCoord *mat);
- SplashError strokeByMyself(OPVPSplashPath *path);
- SplashError fillByMyself(OPVPSplashPath *path, bool eo);
- OPVPSplashXPath *makeDashedPath(OPVPSplashXPath *xPath);
- void transform(SplashCoord *matrix, SplashCoord xi, SplashCoord yi,
- SplashCoord *xo, SplashCoord *yo);
-
- const char *getOption(const char *key, int nOptions, const char *optionKeys[],
- const char *optionVals[]);
-
- OPVPWrapper *opvp;
- int printerContext;
-
- OPVPSplashState *state;
- bool debugMode;
- int colorMode;
- bool stateBypass;
- OPVPClipPath *clipPath;
-
- bool oldLipsDriver;
- bool clipPathNotSaved;
- bool noShearImage;
- bool noLineStyle;
- bool noClipPath;
- bool noMiterLimit;
- bool ignoreMiterLimit;
- bool savedNoClipPath;
- bool noImageMask;
- int bitmapCharThreshold;
- int maxClipPathLength;
- int maxFillPathLength;
- int saveDriverStateCount;
-};
-
-#endif
diff --git a/filter/pdftoopvp/oprs/OPVPSplashClip.cxx b/filter/pdftoopvp/oprs/OPVPSplashClip.cxx
deleted file mode 100644
index c9d2e834c..000000000
--- a/filter/pdftoopvp/oprs/OPVPSplashClip.cxx
+++ /dev/null
@@ -1,91 +0,0 @@
-#include <config.h>
-#include "splash/SplashXPathScanner.h"
-#include "OPVPSplashClip.h"
-
-void OPVPSplashClip::getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA)
-{
- int i;
- int cxMin = splashRound(xMin), cyMin = splashRound(yMin);
- int cxMax = splashRound(xMax), cyMax = splashRound(yMax);
- int txMin, tyMin, txMax, tyMax;
-
- for (i = 0; i < length; ++i) {
- scanners[i]->getBBox(&txMin,&tyMin,&txMax,&tyMax);
- if (txMin > cxMin) cxMin = txMin;
- if (tyMin > cyMin) cyMin = tyMin;
- if (txMax < cxMax) cxMax = txMax;
- if (tyMax < cyMax) cyMax = tyMax;
- }
- *xMinA = cxMin;
- *yMinA = cyMin;
- *xMaxA = cxMax;
- *yMaxA = cyMax;
-}
-
-OPVPSplashPath *OPVPSplashClip::makePath()
-{
- int i,j;
- int y, x0, x1;
- int txMin, tyMin, txMax, tyMax;
- int tsxMin, tsyMin, tsxMax, tsyMax;
- Guchar *cbuf,*tbuf;
- int blen;
- OPVPSplashPath *p = new OPVPSplashPath();
-
- getBBox(&txMin,&tyMin,&txMax,&tyMax);
- if (txMin > txMax || tyMin > tyMax) return p;
- blen = txMax-txMin+1;
- cbuf = new Guchar[blen];
- tbuf = new Guchar[blen];
-
- /* dummy call to clear state */
- scanners[0]->getBBox(&tsxMin,&tsyMin,&tsxMax,&tsyMax);
- scanners[0]->getNextSpan(tsyMin-2,&x0,&x1);
-
- for (y = tyMin;y <= tyMax;y++) {
- /* clear buffer */
- for (i = 0;i < blen;i++) {
- cbuf[i] = 0;
- }
- while (scanners[0]->getNextSpan(y,&x0,&x1)) {
- if (x0 < txMin) x0 = txMin;
- if (x1 > txMax) x1 = txMax;
- for (i = x0;i < x1;i++) {
- cbuf[i-txMin] = 1;
- }
- }
- for (j = 1; j < length; ++j) {
- /* clear buffer */
- for (i = 0;i < blen;i++) {
- tbuf[i] = 0;
- }
- while (scanners[j]->getNextSpan(y,&x0,&x1)) {
- if (x0 < txMin) x0 = txMin;
- if (x1 > txMax) x1 = txMax;
- for (i = x0;i < x1;i++) {
- tbuf[i-txMin] = 1;
- }
- }
- /* and buffer */
- for (i = 0;i < blen;i++) {
- cbuf[i] &= tbuf[i];
- }
- }
- /* scan buffer and add path */
- for (i = 0;i < blen;i = j) {
- if (cbuf[i] != 0) {
- p->moveTo(i+txMin,y);
- for (j = i+1;j < blen && cbuf[j] != 0;j++);
- p->lineTo(j-1+txMin,y);
- p->lineTo(j-1+txMin,y+1);
- p->lineTo(i+txMin,y+1);
- p->close();
- } else {
- j = i+1;
- }
- }
- }
- delete[] cbuf;
- delete[] tbuf;
- return p;
-}
diff --git a/filter/pdftoopvp/oprs/OPVPSplashClip.h b/filter/pdftoopvp/oprs/OPVPSplashClip.h
deleted file mode 100644
index 05bd57b1b..000000000
--- a/filter/pdftoopvp/oprs/OPVPSplashClip.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef OPVPSPLASHCLIP_H
-#define OPVPSPLASHCLIP_H
-
-#include "splash/SplashClip.h"
-#include "OPVPSplashPath.h"
-
-class OPVPSplashClip : public SplashClip {
-public:
-
- OPVPSplashClip(SplashCoord x0, SplashCoord y0,
- SplashCoord x1, SplashCoord y1,
- bool antialiasA) :
- SplashClip(x0,y0,x1,y1,antialiasA) {
- }
-
- OPVPSplashClip(SplashClip *sclip) : SplashClip(sclip) {
- }
-
- OPVPSplashClip *copy() { return new OPVPSplashClip(this); }
-
- ~OPVPSplashClip() {}
-
- void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA);
- OPVPSplashPath *makePath();
-private:
- OPVPSplashClip(OPVPSplashClip *clip) : SplashClip(clip) {
- }
-};
-
-#endif
diff --git a/filter/pdftoopvp/oprs/OPVPSplashPath.cxx b/filter/pdftoopvp/oprs/OPVPSplashPath.cxx
deleted file mode 100644
index f03c128f0..000000000
--- a/filter/pdftoopvp/oprs/OPVPSplashPath.cxx
+++ /dev/null
@@ -1,185 +0,0 @@
-#include <config.h>
-#include <stdio.h>
-#include "splash/SplashMath.h"
-#include "OPVPSplashPath.h"
-#include "OPVPWrapper.h"
-#include "OPRS.h"
-
-void OPVPSplashPath::getBBox(int *xMinA, int *yMinA, int *xMaxA,
- int *yMaxA)
-{
- int i;
- SplashCoord xMin, yMin, xMax, yMax;
-
- if (length <= 0) {
- /* return far away point */
- *xMinA = *yMinA = *xMaxA = *yMaxA = 0xC0000000;
- return;
- }
- xMin = xMax = pts[0].x;
- yMin = yMax = pts[0].y;
- for (i = 1;i < length;i++) {
- if (pts[i].x > xMax) {
- xMax = pts[i].x;
- } else if (pts[i].x < xMin) {
- xMin = pts[i].x;
- }
- if (pts[i].y > yMax) {
- yMax = pts[i].y;
- } else if (pts[i].y < yMin) {
- yMin = pts[i].y;
- }
- }
- *xMinA = splashRound(xMin);
- *xMaxA = splashRound(xMax);
- *yMinA = splashRound(yMin);
- *yMaxA = splashRound(yMax);
-}
-
-bool OPVPSplashPath::isRectanglePath(
- SplashCoord *xMin, SplashCoord *yMin, SplashCoord *xMax, SplashCoord *yMax)
-{
- if (length != 5
- || pts[0].x != pts[4].x
- || pts[0].y != pts[4].y
- || flags[0] != (splashPathFirst | splashPathClosed)
- || flags[1] != 0
- || flags[2] != 0
- || flags[3] != 0
- || flags[4] != (splashPathLast | splashPathClosed)) {
- return false;
- }
- if (splashRound(pts[0].x) == splashRound(pts[1].x)) {
- if (splashRound(pts[1].y) != splashRound(pts[2].y)
- || splashRound(pts[2].x) != splashRound(pts[3].x)
- || splashRound(pts[3].y) != splashRound(pts[4].y)) {
- return false;
- }
- } else if (splashRound(pts[0].y) == splashRound(pts[1].y)) {
- if (splashRound(pts[1].x) != splashRound(pts[2].x)
- || splashRound(pts[2].y) != splashRound(pts[3].y)
- || splashRound(pts[3].x) != splashRound(pts[4].x)) {
- return false;
- }
- } else {
- return false;
- }
- *xMin = pts[0].x;
- *yMin = pts[0].y;
- *xMax = pts[2].x;
- *yMax = pts[2].y;
- if (*xMin > *xMax) {
- SplashCoord t = *xMin;
-
- *xMin = *xMax;
- *xMax = t;
- }
- if (*yMin > *yMax) {
- SplashCoord t = *yMin;
-
- *yMin = *yMax;
- *yMax = t;
- }
- return true;
-}
-
-SplashError OPVPSplashPath::makePath(OPVPWrapper *opvp)
-{
- int i,j;
- opvp_fix_t x,y;
-
- if (opvp->NewPath() < 0) {
- OPRS::error("NewPath error\n");
- return splashErrOPVP;
- }
- for (i = 0;i < length;i = j) {
- int curve = 0;
- int n;
- opvp_point_t *points;
- int k;
-
- if ((flags[i] & splashPathFirst) != 0) {
- /* first point of a subpath */
- if ((flags[i] & splashPathLast) == 0
- || (flags[i] & splashPathClosed) != 0) {
- OPVP_F2FIX((pts[i].x),(x));
- OPVP_F2FIX((pts[i].y),(y));
- if (opvp->SetCurrentPoint(x,y) < 0) {
- OPRS::error("SetCurrentPoint error\n");
- return splashErrOPVP;
- }
- }
- j = i+1;
- continue;
- }
- if (i+2 < length && flags[i] == splashPathCurve) {
- /* curve */
- curve = 1;
- for (j = i;j+2 < length
- && flags[j] == splashPathCurve;j += 3);
- } else {
- curve = 0;
- for (j = i;j < length
- && (flags[j] & splashPathCurve) == 0
- && (flags[j] & splashPathFirst) == 0;j++);
- }
-
- n = j-i;
- points = new opvp_point_t[n];
- /* copy points */
- for (k = i; k < j;k++) {
- OPVP_F2FIX((pts[k].x),(points[k-i].x));
- OPVP_F2FIX((pts[k].y),(points[k-i].y));
- }
-
- if (curve) {
- /* curve */
- if (opvp->BezierPath(n,points) < 0) {
- OPRS::error("BezierPath error\n");
- return splashErrOPVP;
- }
- } else {
- /* line */
- bool closed = (flags[j-1] & splashPathClosed) != 0;
-
- if (closed) {
- if (opvp->LinePath(OPVP_PATHCLOSE,
- n,points) < 0) {
- OPRS::error("LinePath error\n");
- return splashErrOPVP;
- }
- } else {
- if (opvp->LinePath(OPVP_PATHOPEN,
- n,points) < 0) {
- OPRS::error("LinePath error\n");
- return splashErrOPVP;
- }
- }
- }
- delete[] points;
- }
- if (opvp->EndPath() < 0) {
- OPRS::error("EndPath error\n");
- return splashErrOPVP;
- }
- return splashOk;
-}
-
-void OPVPSplashPath::closeAllSubPath()
-{
- int i;
- int f = 0;
-
- for (i = 0;i < length;i++) {
- if ((flags[i] & splashPathFirst) != 0) {
- f = i;
- }
- if ((flags[i] & splashPathLast) != 0) {
- if (pts[f].x == pts[i].x
- && pts[f].y == pts[i].y) {
- flags[f] |= splashPathClosed;
- flags[i] |= splashPathClosed;
- }
- }
- }
-}
diff --git a/filter/pdftoopvp/oprs/OPVPSplashPath.h b/filter/pdftoopvp/oprs/OPVPSplashPath.h
deleted file mode 100644
index 38bfeffb1..000000000
--- a/filter/pdftoopvp/oprs/OPVPSplashPath.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef OPVPSPLASHPATH_H
-#define OPVPSPLASHPATH_H
-
-#include "splash/SplashPath.h"
-#include "OPVPWrapper.h"
-
-class OPVPSplashPath : public SplashPath {
-public:
-
- OPVPSplashPath() {};
-
- OPVPSplashPath(SplashPath *spath) : SplashPath(spath) {
- }
-
- // Copy a path.
- OPVPSplashPath *copy() { return new OPVPSplashPath(this); }
-
- void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA);
- bool isRectanglePath(SplashCoord *xMin, SplashCoord *yMin,
- SplashCoord *xMax, SplashCoord *yMax);
- SplashError makePath(OPVPWrapper *opvp);
- void closeAllSubPath();
-private:
- OPVPSplashPath(OPVPSplashPath *path) : SplashPath(path) {
- }
-};
-
-#endif
diff --git a/filter/pdftoopvp/oprs/OPVPSplashState.cxx b/filter/pdftoopvp/oprs/OPVPSplashState.cxx
deleted file mode 100644
index 62351fa7a..000000000
--- a/filter/pdftoopvp/oprs/OPVPSplashState.cxx
+++ /dev/null
@@ -1,178 +0,0 @@
-//========================================================================
-//
-// SplashState.cc
-//
-//========================================================================
-
-#include <config.h>
-
-#ifdef USE_GCC_PRAGMAS
-#pragma implementation
-#endif
-
-#include <string.h>
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-#include "goo/gmem.h"
-#include "splash/SplashPattern.h"
-#include "splash/SplashScreen.h"
-#include "splash/SplashBitmap.h"
-#include "splash/SplashState.h"
-#include "OPVPSplashState.h"
-#include "OPVPSplashClip.h"
-
-//------------------------------------------------------------------------
-// SplashState
-//------------------------------------------------------------------------
-
-OPVPSplashState::OPVPSplashState(int width, int height, bool vectorAntialias,
- SplashScreenParams *screenParams) {
- SplashColor color;
-
- matrix[0] = 1; matrix[1] = 0;
- matrix[2] = 0; matrix[3] = 1;
- matrix[4] = 0; matrix[5] = 0;
- memset(&color, 0, sizeof(SplashColor));
- strokePattern = new SplashSolidColor(color);
- fillPattern = new SplashSolidColor(color);
- screen = new SplashScreen(screenParams);
- blendFunc = NULL;
- strokeAlpha = 1;
- fillAlpha = 1;
- lineWidth = 0;
- lineCap = splashLineCapButt;
- lineJoin = splashLineJoinMiter;
- miterLimit = 10;
- flatness = 1;
- lineDash = NULL;
- lineDashLength = 0;
- lineDashPhase = 0;
- strokeAdjust = false;
- clip = new OPVPSplashClip(0, 0, width - 0.001,
- height - 0.001, vectorAntialias);
- softMask = NULL;
- deleteSoftMask = false;
- inNonIsolatedGroup = false;
- next = NULL;
-}
-
-OPVPSplashState::OPVPSplashState(int width, int height, bool vectorAntialias,
- SplashScreen *screenA) {
- SplashColor color;
-
- matrix[0] = 1; matrix[1] = 0;
- matrix[2] = 0; matrix[3] = 1;
- matrix[4] = 0; matrix[5] = 0;
- memset(&color, 0, sizeof(SplashColor));
- strokePattern = new SplashSolidColor(color);
- fillPattern = new SplashSolidColor(color);
- screen = screenA->copy();
- blendFunc = NULL;
- strokeAlpha = 1;
- fillAlpha = 1;
- lineWidth = 0;
- lineCap = splashLineCapButt;
- lineJoin = splashLineJoinMiter;
- miterLimit = 10;
- flatness = 1;
- lineDash = NULL;
- lineDashLength = 0;
- lineDashPhase = 0;
- strokeAdjust = false;
- clip = new OPVPSplashClip(0, 0, width - 0.001,
- height - 0.001, vectorAntialias);
- softMask = NULL;
- deleteSoftMask = false;
- inNonIsolatedGroup = false;
- next = NULL;
-}
-
-OPVPSplashState::OPVPSplashState(OPVPSplashState *state) {
- memcpy(matrix, state->matrix, 6 * sizeof(SplashCoord));
- strokePattern = state->strokePattern->copy();
- fillPattern = state->fillPattern->copy();
- screen = state->screen->copy();
- blendFunc = state->blendFunc;
- strokeAlpha = state->strokeAlpha;
- fillAlpha = state->fillAlpha;
- lineWidth = state->lineWidth;
- lineCap = state->lineCap;
- lineJoin = state->lineJoin;
- miterLimit = state->miterLimit;
- flatness = state->flatness;
- if (state->lineDash) {
- lineDashLength = state->lineDashLength;
- lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord));
- memcpy(lineDash, state->lineDash, lineDashLength * sizeof(SplashCoord));
- } else {
- lineDash = NULL;
- lineDashLength = 0;
- }
- lineDashPhase = state->lineDashPhase;
- strokeAdjust = state->strokeAdjust;
- clip = state->clip->copy();
- softMask = state->softMask;
- deleteSoftMask = false;
- inNonIsolatedGroup = state->inNonIsolatedGroup;
- next = NULL;
-}
-
-OPVPSplashState::~OPVPSplashState() {
- delete strokePattern;
- delete fillPattern;
- delete screen;
- gfree(lineDash);
- delete clip;
- if (deleteSoftMask && softMask) {
- delete softMask;
- }
-}
-
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
-void OPVPSplashState::setState(Splash *osplash) {
- osplash->setMatrix(matrix);
- osplash->setFlatness(flatness);
- osplash->setLineDash(lineDash,lineDashLength,lineDashPhase);
- osplash->setLineCap(lineCap);
- osplash->setStrokeAdjust(strokeAdjust);
- osplash->setMiterLimit(miterLimit);
- osplash->setLineJoin(lineJoin);
-}
-#endif
-
-void OPVPSplashState::setStrokePattern(SplashPattern *strokePatternA) {
- delete strokePattern;
- strokePattern = strokePatternA;
-}
-
-void OPVPSplashState::setFillPattern(SplashPattern *fillPatternA) {
- delete fillPattern;
- fillPattern = fillPatternA;
-}
-
-void OPVPSplashState::setScreen(SplashScreen *screenA) {
- delete screen;
- screen = screenA;
-}
-
-void OPVPSplashState::setLineDash(SplashCoord *lineDashA, int lineDashLengthA,
- SplashCoord lineDashPhaseA) {
- gfree(lineDash);
- lineDashLength = lineDashLengthA;
- if (lineDashLength > 0) {
- lineDash = (SplashCoord *)gmallocn(lineDashLength, sizeof(SplashCoord));
- memcpy(lineDash, lineDashA, lineDashLength * sizeof(SplashCoord));
- } else {
- lineDash = NULL;
- }
- lineDashPhase = lineDashPhaseA;
-}
-
-void OPVPSplashState::setSoftMask(SplashBitmap *softMaskA) {
- if (deleteSoftMask) {
- delete softMask;
- }
- softMask = softMaskA;
- deleteSoftMask = true;
-}
diff --git a/filter/pdftoopvp/oprs/OPVPSplashState.h b/filter/pdftoopvp/oprs/OPVPSplashState.h
deleted file mode 100644
index b40aaf466..000000000
--- a/filter/pdftoopvp/oprs/OPVPSplashState.h
+++ /dev/null
@@ -1,95 +0,0 @@
-//========================================================================
-//
-// OPVPSplashState.h
-//
-//========================================================================
-
-#ifndef OPVPSPLASHSTATE_H
-#define OPVPSPLASHSTATE_H
-
-#ifdef USE_GCC_PRAGMAS
-#pragma interface
-#endif
-
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-#include "splash/SplashTypes.h"
-#include "splash/SplashState.h"
-#include "splash/Splash.h"
-
-class SplashPattern;
-class SplashScreen;
-class OPVPSplashClip;
-class SplashBitmap;
-
-//------------------------------------------------------------------------
-// SplashState
-//------------------------------------------------------------------------
-
-class OPVPSplashState {
-public:
-
- // Create a new state object, initialized with default settings.
- OPVPSplashState(int width, int height, bool vectorAntialias,
- SplashScreenParams *screenParams);
- OPVPSplashState(int width, int height, bool vectorAntialias,
- SplashScreen *screenA);
-
- // Copy a state object.
- OPVPSplashState *copy() { return new OPVPSplashState(this); }
-
- ~OPVPSplashState();
-
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- void setState(Splash *osplash);
-#endif
-
- // Set the stroke pattern. This does not copy <strokePatternA>.
- void setStrokePattern(SplashPattern *strokePatternA);
-
- // Set the fill pattern. This does not copy <fillPatternA>.
- void setFillPattern(SplashPattern *fillPatternA);
-
- // Set the screen. This does not copy <screenA>.
- void setScreen(SplashScreen *screenA);
-
- // Set the line dash pattern. This copies the <lineDashA> array.
- void setLineDash(SplashCoord *lineDashA, int lineDashLengthA,
- SplashCoord lineDashPhaseA);
-
- // Set the soft mask bitmap.
- void setSoftMask(SplashBitmap *softMaskA);
-
-private:
-
- OPVPSplashState(OPVPSplashState *state);
-
- SplashCoord matrix[6];
- SplashPattern *strokePattern;
- SplashPattern *fillPattern;
- SplashScreen *screen;
- SplashBlendFunc blendFunc;
- SplashCoord strokeAlpha;
- SplashCoord fillAlpha;
- SplashCoord lineWidth;
- int lineCap;
- int lineJoin;
- SplashCoord miterLimit;
- SplashCoord flatness;
- SplashCoord *lineDash;
- int lineDashLength;
- SplashCoord lineDashPhase;
- bool strokeAdjust;
- OPVPSplashClip *clip;
- SplashBitmap *softMask;
- bool deleteSoftMask;
- bool inNonIsolatedGroup;
-
- OPVPSplashState *next; // used by OPVPSplash class
-
- friend class OPVPSplash;
- friend class OPVPSplashXPath;
-};
-
-#endif
diff --git a/filter/pdftoopvp/oprs/OPVPSplashXPath.cxx b/filter/pdftoopvp/oprs/OPVPSplashXPath.cxx
deleted file mode 100644
index 924fe9fa6..000000000
--- a/filter/pdftoopvp/oprs/OPVPSplashXPath.cxx
+++ /dev/null
@@ -1,426 +0,0 @@
-#include <config.h>
-#include <stdio.h>
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-#include "splash/Splash.h"
-#include "splash/SplashMath.h"
-#include "OPVPSplashClip.h"
-#include "OPVPSplashXPath.h"
-#include "OPVPWrapper.h"
-#include "OPVPSplash.h"
-
-#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 19
-OPVPSplashXPath *OPVPSplashXPath::makeDashedPath(OPVPSplashState *state)
-{
- OPVPSplashXPath *dPath;
- bool lineDashStartOn, lineDashOn;
- bool atSegStart, atSegEnd, atDashStart, atDashEnd;
- int lineDashStartIdx, lineDashIdx, subpathStart;
- SplashCoord lineDashTotal, lineDashStartPhase, lineDashDist;
- int segIdx;
- SplashXPathSeg *seg;
- SplashCoord sx0, sy0, sx1, sy1, ax0, ay0, ax1, ay1, dist;
- int i;
-
- dPath = new OPVPSplashXPath();
-
- lineDashTotal = 0;
- for (i = 0; i < state->lineDashLength; ++i) {
- lineDashTotal += state->lineDash[i];
- }
- lineDashStartPhase = state->lineDashPhase;
- i = splashFloor(lineDashStartPhase / lineDashTotal);
- lineDashStartPhase -= i * lineDashTotal;
- lineDashStartOn = true;
- lineDashStartIdx = 0;
- while (lineDashStartPhase >= state->lineDash[lineDashStartIdx]) {
- lineDashStartOn = !lineDashStartOn;
- lineDashStartPhase -= state->lineDash[lineDashStartIdx];
- ++lineDashStartIdx;
- }
-
- segIdx = 0;
- seg = segs;
- sx0 = seg->x0;
- sy0 = seg->y0;
- sx1 = seg->x1;
- sy1 = seg->y1;
- dist = splashDist(sx0, sy0, sx1, sy1);
- lineDashOn = lineDashStartOn;
- lineDashIdx = lineDashStartIdx;
- lineDashDist = state->lineDash[lineDashIdx] - lineDashStartPhase;
- atSegStart = true;
- atDashStart = true;
- subpathStart = dPath->length;
-
- while (segIdx < length) {
-
- ax0 = sx0;
- ay0 = sy0;
- if (dist <= lineDashDist) {
- ax1 = sx1;
- ay1 = sy1;
- lineDashDist -= dist;
- dist = 0;
- atSegEnd = true;
- atDashEnd = lineDashDist == 0 || (seg->flags & splashXPathLast);
- } else {
- ax1 = sx0 + (lineDashDist / dist) * (sx1 - sx0);
- ay1 = sy0 + (lineDashDist / dist) * (sy1 - sy0);
- sx0 = ax1;
- sy0 = ay1;
- dist -= lineDashDist;
- lineDashDist = 0;
- atSegEnd = false;
- atDashEnd = true;
- }
-
- if (lineDashOn) {
- dPath->addSegment(ax0, ay0, ax1, ay1,
- atDashStart, atDashEnd,
- atDashStart, atDashEnd);
- // end of closed subpath
- if (atSegEnd &&
- (seg->flags & splashXPathLast) &&
- !(seg->flags & splashXPathEnd1)) {
- dPath->segs[subpathStart].flags &= ~splashXPathEnd0;
- dPath->segs[dPath->length - 1].flags &= ~splashXPathEnd1;
- }
- }
-
- if (atDashEnd) {
- lineDashOn = !lineDashOn;
- if (++lineDashIdx == state->lineDashLength) {
- lineDashIdx = 0;
- }
- lineDashDist = state->lineDash[lineDashIdx];
- atDashStart = true;
- } else {
- atDashStart = false;
- }
- if (atSegEnd) {
- if (++segIdx < length) {
- ++seg;
- sx0 = seg->x0;
- sy0 = seg->y0;
- sx1 = seg->x1;
- sy1 = seg->y1;
- dist = splashDist(sx0, sy0, sx1, sy1);
- if (seg->flags & splashXPathFirst) {
- lineDashOn = lineDashStartOn;
- lineDashIdx = lineDashStartIdx;
- lineDashDist = state->lineDash[lineDashIdx] - lineDashStartPhase;
- atDashStart = true;
- subpathStart = dPath->length;
- }
- }
- atSegStart = true;
- } else {
- atSegStart = false;
- }
- }
-
- return dPath;
-}
-
-void OPVPSplashXPath::strokeWide(OPVPSplash *splash, OPVPSplashState *state)
-{
- SplashXPathSeg *seg, *seg2;
- OPVPSplashPath *widePath;
- SplashCoord d, dx, dy, wdx, wdy, dxPrev, dyPrev, wdxPrev, wdyPrev;
- SplashCoord dotprod, miter;
- SplashCoord x0,y0,x1,y1,x2,y2,x3,y3;
- int i, j;
-
- dx = dy = wdx = wdy = 0; // make gcc happy
- dxPrev = dyPrev = wdxPrev = wdyPrev = 0; // make gcc happy
-
- for (i = 0, seg = segs; i < length; ++i, ++seg) {
-
- // save the deltas for the previous segment; if this is the first
- // segment on a subpath, compute the deltas for the last segment
- // on the subpath (which may be used to draw a line join)
- if (seg->flags & splashXPathFirst) {
- for (j = i + 1, seg2 = &segs[j];
- j < length; ++j, ++seg2) {
- if (seg2->flags & splashXPathLast) {
- d = splashDist(seg2->x0, seg2->y0, seg2->x1, seg2->y1);
- if (d == 0) {
- //~ not clear what the behavior should be for joins with d==0
- dxPrev = 0;
- dyPrev = 1;
- } else {
- d = 1 / d;
- dxPrev = d * (seg2->x1 - seg2->x0);
- dyPrev = d * (seg2->y1 - seg2->y0);
- }
- wdxPrev = 0.5 * state->lineWidth * dxPrev;
- wdyPrev = 0.5 * state->lineWidth * dyPrev;
- break;
- }
- }
- } else {
- dxPrev = dx;
- dyPrev = dy;
- wdxPrev = wdx;
- wdyPrev = wdy;
- }
-
- // compute deltas for this line segment
- d = splashDist(seg->x0, seg->y0, seg->x1, seg->y1);
- if (d == 0) {
- // we need to draw end caps on zero-length lines
- //~ not clear what the behavior should be for splashLineCapButt with d==0
- dx = 0;
- dy = 1;
- } else {
- d = 1 / d;
- dx = d * (seg->x1 - seg->x0);
- dy = d * (seg->y1 - seg->y0);
- }
- wdx = 0.5 * state->lineWidth * dx;
- wdy = 0.5 * state->lineWidth * dy;
-
- // initialize the path (which will be filled)
- widePath = new OPVPSplashPath();
- widePath->moveTo(seg->x0 - wdy, seg->y0 + wdx);
-
- // draw the start cap
- if (seg->flags & splashXPathEnd0) {
- switch (state->lineCap) {
- case splashLineCapButt:
- widePath->lineTo(seg->x0 + wdy, seg->y0 - wdx);
- break;
- case splashLineCapRound:
- x0 = seg->x0 - wdy;
- y0 = seg->y0 + wdx;
- x3 = seg->x0 - wdx;
- y3 = seg->y0 - wdy;
- splash->arcToCurve(x0, y0, x3, y3,
- seg->x0, seg->y0, &x1,&y1,&x2,&y2);
- widePath->curveTo(x2,y2,x1,y1,x3,y3);
- x0 = x3;
- y0 = y3;
- x3 = seg->x0 + wdy;
- y3 = seg->y0 - wdx;
- splash->arcToCurve(x0,y0,x3,y3,
- seg->x0, seg->y0, &x1,&y1,&x2,&y2);
- widePath->curveTo(x2,y2,x1,y1,x3,y3);
- break;
- case splashLineCapProjecting:
- widePath->lineTo(seg->x0 - wdx - wdy, seg->y0 + wdx - wdy);
- widePath->lineTo(seg->x0 - wdx + wdy, seg->y0 - wdx - wdy);
- widePath->lineTo(seg->x0 + wdy, seg->y0 - wdx);
- break;
- }
- } else {
- widePath->lineTo(seg->x0 + wdy, seg->y0 - wdx);
- }
-
- // draw the left side of the segment
- widePath->lineTo(seg->x1 + wdy, seg->y1 - wdx);
-
- // draw the end cap
- if (seg->flags & splashXPathEnd1) {
- switch (state->lineCap) {
- case splashLineCapButt:
- widePath->lineTo(seg->x1 - wdy, seg->y1 + wdx);
- break;
- case splashLineCapRound:
- x0 = seg->x1 + wdy;
- y0 = seg->y1 - wdx;
- x3 = seg->x1 + wdx;
- y3 = seg->y1 + wdy;
- splash->arcToCurve(x0, y0, x3, y3,
- seg->x1, seg->y1, &x1,&y1,&x2,&y2);
- widePath->curveTo(x2,y2,x1,y1,x3,y3);
- x0 = x3;
- y0 = y3;
- x3 = seg->x1 - wdy;
- y3 = seg->y1 + wdx;
- splash->arcToCurve(x0,y0,x3,y3,
- seg->x1, seg->y1, &x1,&y1,&x2,&y2);
- widePath->curveTo(x2,y2,x1,y1,x3,y3);
- break;
- case splashLineCapProjecting:
- widePath->lineTo(seg->x1 + wdx + wdy, seg->y1 - wdx + wdy);
- widePath->lineTo(seg->x1 + wdx - wdy, seg->y1 + wdx + wdy);
- widePath->lineTo(seg->x1 - wdy, seg->y1 + wdx);
- break;
- }
- } else {
- widePath->lineTo(seg->x1 - wdy, seg->y1 + wdx);
- }
-
- // draw the right side of the segment
- widePath->lineTo(seg->x0 - wdy, seg->y0 + wdx);
-
- // fill the segment
- splash->fill(widePath, true);
- delete widePath;
-
- // draw the line join
- if (!(seg->flags & splashXPathEnd0)) {
- widePath = NULL;
- switch (state->lineJoin) {
- case splashLineJoinMiter:
- dotprod = -(dx * dxPrev + dy * dyPrev);
- if (dotprod != 1) {
- widePath = new OPVPSplashPath();
- widePath->moveTo(seg->x0, seg->y0);
- miter = 2 / (1 - dotprod);
- if (splashSqrt(miter) <= state->miterLimit) {
- miter = splashSqrt(miter - 1);
- if (dy * dxPrev > dx * dyPrev) {
- widePath->lineTo(seg->x0 + wdyPrev, seg->y0 - wdxPrev);
- widePath->lineTo(seg->x0 + wdy - miter * wdx,
- seg->y0 - wdx - miter * wdy);
- widePath->lineTo(seg->x0 + wdy, seg->y0 - wdx);
- } else {
- widePath->lineTo(seg->x0 - wdyPrev, seg->y0 + wdxPrev);
- widePath->lineTo(seg->x0 - wdy - miter * wdx,
- seg->y0 + wdx - miter * wdy);
- widePath->lineTo(seg->x0 - wdy, seg->y0 + wdx);
- }
- } else {
- if (dy * dxPrev > dx * dyPrev) {
- widePath->lineTo(seg->x0 + wdyPrev, seg->y0 - wdxPrev);
- widePath->lineTo(seg->x0 + wdy, seg->y0 - wdx);
- } else {
- widePath->lineTo(seg->x0 - wdyPrev, seg->y0 + wdxPrev);
- widePath->lineTo(seg->x0 - wdy, seg->y0 + wdx);
- }
- }
- }
- break;
- case splashLineJoinRound:
- widePath = new OPVPSplashPath();
- /* draw circle */
- widePath->moveTo(seg->x0 + wdy, seg->y0 - wdx);
- x0 = seg->x0 + wdy;
- y0 = seg->y0 - wdx;
- x3 = seg->x0 - wdx;
- y3 = seg->y0 - wdy;
- splash->arcToCurve(x0, y0, x3, y3,
- seg->x0, seg->y0, &x1,&y1,&x2,&y2);
- widePath->curveTo(x1,y1,x2,y2,x3,y3);
- x0 = x3;
- y0 = y3;
- x3 = seg->x0 - wdy;
- y3 = seg->y0 + wdx;
- splash->arcToCurve(x0, y0, x3, y3,
- seg->x0, seg->y0, &x1,&y1,&x2,&y2);
- widePath->curveTo(x1,y1,x2,y2,x3,y3);
- x0 = x3;
- y0 = y3;
- x3 = seg->x0 + wdx;
- y3 = seg->y0 + wdy;
- splash->arcToCurve(x0, y0, x3, y3,
- seg->x0, seg->y0, &x1,&y1,&x2,&y2);
- widePath->curveTo(x1,y1,x2,y2,x3,y3);
- x0 = x3;
- y0 = y3;
- x3 = seg->x0 + wdy;
- y3 = seg->y0 - wdx;
- splash->arcToCurve(x0, y0, x3, y3,
- seg->x0, seg->y0, &x1,&y1,&x2,&y2);
- widePath->curveTo(x1,y1,x2,y2,x3,y3);
- break;
- case splashLineJoinBevel:
- widePath = new OPVPSplashPath();
- widePath->moveTo(seg->x0, seg->y0);
- if (dy * dxPrev > dx * dyPrev) {
- widePath->lineTo(seg->x0 + wdyPrev, seg->y0 - wdxPrev);
- widePath->lineTo(seg->x0 + wdy, seg->y0 - wdx);
- } else {
- widePath->lineTo(seg->x0 - wdyPrev, seg->y0 + wdxPrev);
- widePath->lineTo(seg->x0 - wdy, seg->y0 + wdx);
- }
- break;
- }
- if (widePath) {
- splash->fill(widePath, true);
- delete widePath;
- }
- }
- }
-}
-#endif
-
-void OPVPSplashXPath::strokeNarrow(OPVPSplash *splash, OPVPSplashState *state)
-{
- SplashXPathSeg *seg;
- int x0, x1, x2, x3, y0, y1, x, y, t;
- SplashCoord dx, dy, dxdy;
- SplashClipResult clipRes;
- int i;
-
- for (i = 0, seg = segs; i < length; ++i, ++seg) {
-
- x0 = splashFloor(seg->x0);
- x1 = splashFloor(seg->x1);
- y0 = splashFloor(seg->y0);
- y1 = splashFloor(seg->y1);
-
- // horizontal segment
- if (y0 == y1) {
- if (x0 > x1) {
- t = x0; x0 = x1; x1 = t;
- }
- if ((clipRes = state->clip->testSpan(x0, x1, y0))
- != splashClipAllOutside) {
- splash->drawSpan(x0, x1, y0, clipRes == splashClipAllInside);
- }
-
- // segment with |dx| > |dy|
- } else if (splashAbs(seg->dxdy) > 1) {
- dx = seg->x1 - seg->x0;
- dy = seg->y1 - seg->y0;
- dxdy = seg->dxdy;
- if (y0 > y1) {
- t = y0; y0 = y1; y1 = t;
- t = x0; x0 = x1; x1 = t;
- dx = -dx;
- dy = -dy;
- }
- if ((clipRes = state->clip->testRect(x0 <= x1 ? x0 : x1, y0,
- x0 <= x1 ? x1 : x0, y1))
- != splashClipAllOutside) {
- if (dx > 0) {
- x2 = x0;
- for (y = y0; y < y1; ++y) {
- x3 = splashFloor(seg->x0 + (y + 1 - seg->y0) * dxdy);
- splash->drawSpan(x2, x3 - 1, y, clipRes == splashClipAllInside);
- x2 = x3;
- }
- splash->drawSpan(x2, x1, y, clipRes == splashClipAllInside);
- } else {
- x2 = x0;
- for (y = y0; y < y1; ++y) {
- x3 = splashFloor(seg->x0 + (y + 1 - seg->y0) * dxdy);
- splash->drawSpan(x3 + 1, x2, y, clipRes == splashClipAllInside);
- x2 = x3;
- }
- splash->drawSpan(x1, x2, y, clipRes == splashClipAllInside);
- }
- }
-
- // segment with |dy| > |dx|
- } else {
- dxdy = seg->dxdy;
- if (y0 > y1) {
- t = y0; y0 = y1; y1 = t;
- }
- if ((clipRes = state->clip->testRect(x0 <= x1 ? x0 : x1, y0,
- x0 <= x1 ? x1 : x0, y1))
- != splashClipAllOutside) {
- for (y = y0; y <= y1; ++y) {
- x = splashFloor(seg->x0 + (y - seg->y0) * dxdy);
- splash->drawPixel(x, y, clipRes == splashClipAllInside);
- }
- }
- }
- }
-}
-
diff --git a/filter/pdftoopvp/oprs/OPVPSplashXPath.h b/filter/pdftoopvp/oprs/OPVPSplashXPath.h
deleted file mode 100644
index c80243ae4..000000000
--- a/filter/pdftoopvp/oprs/OPVPSplashXPath.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef OPVPSPLASHXPATH_H
-#define OPVPSPLASHXPATH_H
-
-#include <config.h>
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-#include "splash/SplashXPath.h"
-#include "OPVPSplashPath.h"
-#include "OPVPSplashState.h"
-
-class OPVPSplash;
-
-class OPVPSplashXPath : public SplashXPath {
-public:
- OPVPSplashXPath(OPVPSplashPath *path, SplashCoord *matrix,
- SplashCoord flatness, bool closeSubpaths) :
- SplashXPath(path,matrix,flatness,closeSubpaths) {
- }
-
- // Copy an expanded path.
- OPVPSplashXPath *copy() { return new OPVPSplashXPath(this); }
-
- OPVPSplashXPath *makeDashedPath(OPVPSplashState *state);
- void strokeNarrow(OPVPSplash *splash, OPVPSplashState *state);
-#if POPPLER_VERSION_MAJOR <= 0 && POPPLER_VERSION_MINOR < 19
- void strokeWide(OPVPSplash *splash, OPVPSplashState *state);
-#endif
-private:
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- OPVPSplashXPath() : SplashXPath(new SplashPath(), 0, 0, false) {};
-#else
- OPVPSplashXPath() {};
-#endif
- OPVPSplashXPath(OPVPSplashXPath *xPath) : SplashXPath(xPath) {
- }
-};
-
-#endif
diff --git a/filter/pdftoopvp/oprs/OPVPWrapper.cxx b/filter/pdftoopvp/oprs/OPVPWrapper.cxx
deleted file mode 100644
index 3453e0d9b..000000000
--- a/filter/pdftoopvp/oprs/OPVPWrapper.cxx
+++ /dev/null
@@ -1,910 +0,0 @@
-/*
- OPVPWrapper.cc
-*/
-
-
-#include <config.h>
-#include <stdio.h>
-#include "OPRS.h"
-#include "OPVPWrapper.h"
-#include "OPVPWrapper_0_2.h"
-#include <string.h>
-#include <dlfcn.h>
-
-OPVPWrapper::OPVPWrapper(void *opvpHandleA, opvp_int_t *opvpErrorNoA,
- opvp_api_procs_t *procsA, opvp_dc_t printerContextA)
-{
- procs = procsA;
- opvpHandle = opvpHandleA;
- opvpErrorNo = opvpErrorNoA;
- printerContext = printerContextA;
- version[0] = 1;
- version[1] = 0;
- supportClosePrinter = (procs->opvpClosePrinter != 0);
- supportStartJob = (procs->opvpStartJob != 0);
- supportEndJob = (procs->opvpEndJob != 0);
- supportAbortJob = (procs->opvpAbortJob != 0);
- supportStartDoc = (procs->opvpStartDoc != 0);
- supportEndDoc = (procs->opvpEndDoc != 0);
- supportStartPage = (procs->opvpStartPage != 0);
- supportEndPage = (procs->opvpEndPage != 0);
- supportResetCTM = (procs->opvpResetCTM != 0);
- supportSetCTM = (procs->opvpSetCTM != 0);
- supportGetCTM = (procs->opvpGetCTM != 0);
- supportInitGS = (procs->opvpInitGS != 0);
- supportSaveGS = (procs->opvpSaveGS != 0);
- supportRestoreGS = (procs->opvpRestoreGS != 0);
- supportQueryColorSpace = (procs->opvpQueryColorSpace != 0);
- supportSetColorSpace = (procs->opvpSetColorSpace != 0);
- supportGetColorSpace = (procs->opvpGetColorSpace != 0);
- supportSetFillMode = (procs->opvpSetFillMode != 0);
- supportGetFillMode = (procs->opvpGetFillMode != 0);
- supportSetAlphaConstant = (procs->opvpSetAlphaConstant != 0);
- supportGetAlphaConstant = (procs->opvpGetAlphaConstant != 0);
- supportSetLineWidth = (procs->opvpSetLineWidth != 0);
- supportGetLineWidth = (procs->opvpGetLineWidth != 0);
- supportSetLineDash = (procs->opvpSetLineDash != 0);
- supportGetLineDash = (procs->opvpGetLineDash != 0);
- supportSetLineDashOffset = (procs->opvpSetLineDashOffset != 0);
- supportGetLineDashOffset = (procs->opvpGetLineDashOffset != 0);
- supportSetLineStyle = (procs->opvpSetLineStyle != 0);
- supportGetLineStyle = (procs->opvpGetLineStyle != 0);
- supportSetLineCap = (procs->opvpSetLineCap != 0);
- supportGetLineCap = (procs->opvpGetLineCap != 0);
- supportSetLineJoin = (procs->opvpSetLineJoin != 0);
- supportGetLineJoin = (procs->opvpGetLineJoin != 0);
- supportSetMiterLimit = (procs->opvpSetMiterLimit != 0);
- supportGetMiterLimit = (procs->opvpGetMiterLimit != 0);
- supportSetPaintMode = (procs->opvpSetPaintMode != 0);
- supportGetPaintMode = (procs->opvpGetPaintMode != 0);
- supportSetStrokeColor = (procs->opvpSetStrokeColor != 0);
- supportSetFillColor = (procs->opvpSetFillColor != 0);
- supportSetBgColor = (procs->opvpSetBgColor != 0);
- supportNewPath = (procs->opvpNewPath != 0);
- supportEndPath = (procs->opvpEndPath != 0);
- supportStrokePath = (procs->opvpStrokePath != 0);
- supportFillPath = (procs->opvpFillPath != 0);
- supportStrokeFillPath = (procs->opvpStrokeFillPath != 0);
- supportSetClipPath = (procs->opvpSetClipPath != 0);
- supportSetCurrentPoint = (procs->opvpSetCurrentPoint != 0);
- supportLinePath = (procs->opvpLinePath != 0);
- supportPolygonPath = (procs->opvpPolygonPath != 0);
- supportRectanglePath = (procs->opvpRectanglePath != 0);
- supportRoundRectanglePath = (procs->opvpRoundRectanglePath != 0);
- supportBezierPath = (procs->opvpBezierPath != 0);
- supportArcPath = (procs->opvpArcPath != 0);
- supportDrawImage = (procs->opvpDrawImage != 0);
- supportStartDrawImage = (procs->opvpStartDrawImage != 0);
- supportTransferDrawImage = (procs->opvpTransferDrawImage != 0);
- supportEndDrawImage = (procs->opvpEndDrawImage != 0);
- supportStartScanline = (procs->opvpStartScanline != 0);
- supportScanline = (procs->opvpScanline != 0);
- supportEndScanline = (procs->opvpEndScanline != 0);
- supportStartRaster = (procs->opvpStartRaster != 0);
- supportTransferRasterData = (procs->opvpTransferRasterData != 0);
- supportSkipRaster = (procs->opvpSkipRaster != 0);
- supportEndRaster = (procs->opvpEndRaster != 0);
- supportStartStream = (procs->opvpStartStream != 0);
- supportTransferStreamData = (procs->opvpTransferStreamData != 0);
- supportEndStream = (procs->opvpEndStream != 0);
- supportQueryDeviceCapability = (procs->opvpQueryDeviceCapability != 0);
- supportQueryDeviceInfo = (procs->opvpQueryDeviceInfo != 0);
- supportResetClipPath = (procs->opvpResetClipPath != 0);
-}
-
-OPVPWrapper::~OPVPWrapper()
-{
- unloadDriver(opvpHandle);
- opvpHandle = 0;
-}
-
-opvp_result_t OPVPWrapper::ClosePrinter()
-{
- if (!supportClosePrinter) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpClosePrinter(printerContext);
-}
-
-opvp_result_t OPVPWrapper::StartJob(const opvp_char_t *jobInfo)
-{
- if (!supportStartJob) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpStartJob(printerContext,jobInfo);
-}
-
-opvp_result_t OPVPWrapper::EndJob()
-{
- if (!supportEndJob) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpEndJob(printerContext);
-}
-
-opvp_result_t OPVPWrapper::AbortJob()
-{
- if (!supportAbortJob) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpAbortJob(printerContext);
-}
-
-opvp_result_t OPVPWrapper::StartDoc(const opvp_char_t *docInfo)
-{
- if (!supportStartDoc) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpStartDoc(printerContext,docInfo);
-}
-
-opvp_result_t OPVPWrapper::EndDoc()
-{
- if (!supportEndDoc) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpEndDoc(printerContext);
-}
-
-opvp_result_t OPVPWrapper::StartPage(const opvp_char_t *pageInfo)
-{
- if (!supportStartPage) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpStartPage(printerContext,pageInfo);
-}
-
-opvp_result_t OPVPWrapper::EndPage()
-{
- if (!supportEndPage) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpEndPage(printerContext);
-}
-
-opvp_result_t OPVPWrapper::QueryDeviceCapability(opvp_flag_t queryflag,
- opvp_int_t *buflen, opvp_byte_t *infoBuf)
-{
- if (!supportQueryDeviceCapability) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpQueryDeviceCapability(printerContext,queryflag,
- buflen,infoBuf);
-}
-
-opvp_result_t OPVPWrapper::QueryDeviceInfo(opvp_flag_t queryflag,
- opvp_int_t *buflen, opvp_byte_t *infoBuf)
-{
- if (!supportQueryDeviceInfo) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpQueryDeviceInfo(printerContext,queryflag,
- buflen,infoBuf);
-}
-
-opvp_result_t OPVPWrapper::ResetCTM()
-{
- if (!supportResetCTM) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpResetCTM(printerContext);
-}
-
-opvp_result_t OPVPWrapper::SetCTM(const opvp_ctm_t *pCTM)
-{
- if (!supportSetCTM) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetCTM(printerContext,pCTM);
-}
-
-opvp_result_t OPVPWrapper::GetCTM(opvp_ctm_t *pCTM)
-{
- if (!supportGetCTM) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetCTM(printerContext,pCTM);
-}
-
-opvp_result_t OPVPWrapper::InitGS()
-{
- if (!supportInitGS) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpInitGS(printerContext);
-}
-
-opvp_result_t OPVPWrapper::SaveGS()
-{
- if (!supportSaveGS) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSaveGS(printerContext);
-}
-
-opvp_result_t OPVPWrapper::RestoreGS()
-{
- if (!supportRestoreGS) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpRestoreGS(printerContext);
-}
-
-opvp_result_t OPVPWrapper::QueryColorSpace(opvp_int_t *pnum,
- opvp_cspace_t *pcspace)
-{
- if (!supportQueryColorSpace) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpQueryColorSpace(printerContext,pnum,pcspace);
-}
-
-opvp_result_t OPVPWrapper::SetColorSpace(opvp_cspace_t cspace)
-{
- if (!supportSetColorSpace) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetColorSpace(printerContext,cspace);
-}
-
-opvp_result_t OPVPWrapper::GetColorSpace(opvp_cspace_t *pcspace)
-{
- if (!supportGetColorSpace) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetColorSpace(printerContext,pcspace);
-}
-
-opvp_result_t OPVPWrapper::SetFillMode(opvp_fillmode_t fillmode)
-{
- if (!supportSetFillMode) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetFillMode(printerContext,fillmode);
-}
-
-opvp_result_t OPVPWrapper::GetFillMode(opvp_fillmode_t *pfillmode)
-{
- if (!supportGetFillMode) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetFillMode(printerContext,pfillmode);
-}
-
-opvp_result_t OPVPWrapper::SetAlphaConstant(opvp_float_t alpha)
-{
- if (!supportSetAlphaConstant) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetAlphaConstant(printerContext,alpha);
-}
-
-opvp_result_t OPVPWrapper::GetAlphaConstant(opvp_float_t *palpha)
-{
- if (!supportGetAlphaConstant) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetAlphaConstant(printerContext,palpha);
-}
-
-opvp_result_t OPVPWrapper::SetLineWidth(opvp_fix_t width)
-{
- if (!supportSetLineWidth) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetLineWidth(printerContext,width);
-}
-
-opvp_result_t OPVPWrapper::GetLineWidth(opvp_fix_t *pwidth)
-{
- if (!supportGetLineWidth) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetLineWidth(printerContext,pwidth);
-}
-
-opvp_result_t OPVPWrapper::SetLineDash(opvp_int_t num,
- const opvp_fix_t *pdash)
-{
- if (!supportSetLineDash) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetLineDash(printerContext,num,pdash);
-}
-
-opvp_result_t OPVPWrapper::GetLineDash(opvp_int_t *pnum, opvp_fix_t *pdash)
-{
- if (!supportGetLineDash) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetLineDash(printerContext,pnum,pdash);
-}
-
-opvp_result_t OPVPWrapper::SetLineDashOffset(opvp_fix_t offset)
-{
- if (!supportSetLineDashOffset) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetLineDashOffset(printerContext,offset);
-}
-
-opvp_result_t OPVPWrapper::GetLineDashOffset(opvp_fix_t *poffset)
-{
- if (!supportGetLineDashOffset) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetLineDashOffset(printerContext,poffset);
-}
-
-opvp_result_t OPVPWrapper::SetLineStyle(opvp_linestyle_t linestyle)
-{
- if (!supportSetLineStyle) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetLineStyle(printerContext,linestyle);
-}
-
-opvp_result_t OPVPWrapper::GetLineStyle(opvp_linestyle_t *plinestyle)
-{
- if (!supportGetLineStyle) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetLineStyle(printerContext,plinestyle);
-}
-
-opvp_result_t OPVPWrapper::SetLineCap(opvp_linecap_t linecap)
-{
- if (!supportSetLineCap) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetLineCap(printerContext,linecap);
-}
-
-opvp_result_t OPVPWrapper::GetLineCap(opvp_linecap_t *plinecap)
-{
- if (!supportGetLineCap) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetLineCap(printerContext,plinecap);
-}
-
-opvp_result_t OPVPWrapper::SetLineJoin(opvp_linejoin_t linejoin)
-{
- if (!supportSetLineJoin) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetLineJoin(printerContext,linejoin);
-}
-
-opvp_result_t OPVPWrapper::GetLineJoin(opvp_linejoin_t *plinejoin)
-{
- if (!supportGetLineJoin) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetLineJoin(printerContext,plinejoin);
-}
-
-opvp_result_t OPVPWrapper::SetMiterLimit(opvp_fix_t miterlimit)
-{
- if (!supportSetMiterLimit) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetMiterLimit(printerContext,miterlimit);
-}
-
-opvp_result_t OPVPWrapper::GetMiterLimit(opvp_fix_t *pmiterlimit)
-{
- if (!supportGetMiterLimit) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetMiterLimit(printerContext,pmiterlimit);
-}
-
-opvp_result_t OPVPWrapper::SetPaintMode(opvp_paintmode_t paintmode)
-{
- if (!supportSetPaintMode) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetPaintMode(printerContext,paintmode);
-}
-
-opvp_result_t OPVPWrapper::GetPaintMode(opvp_paintmode_t *ppaintmode)
-{
- if (!supportGetPaintMode) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpGetPaintMode(printerContext,ppaintmode);
-}
-
-opvp_result_t OPVPWrapper::SetStrokeColor(const opvp_brush_t *brush)
-{
- if (!supportSetStrokeColor) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetStrokeColor(printerContext,brush);
-}
-
-opvp_result_t OPVPWrapper::SetFillColor(const opvp_brush_t *brush)
-{
- if (!supportSetFillColor) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetFillColor(printerContext,brush);
-}
-
-opvp_result_t OPVPWrapper::SetBgColor(const opvp_brush_t *brush)
-{
- if (!supportSetBgColor) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetBgColor(printerContext,brush);
-}
-
-opvp_result_t OPVPWrapper::NewPath()
-{
- if (!supportNewPath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpNewPath(printerContext);
-}
-
-opvp_result_t OPVPWrapper::EndPath()
-{
- if (!supportEndPath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpEndPath(printerContext);
-}
-
-opvp_result_t OPVPWrapper::StrokePath()
-{
- if (!supportStrokePath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpStrokePath(printerContext);
-}
-
-opvp_result_t OPVPWrapper::FillPath()
-{
- if (!supportFillPath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpFillPath(printerContext);
-}
-
-opvp_result_t OPVPWrapper::StrokeFillPath()
-{
- if (!supportStrokeFillPath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpStrokeFillPath(printerContext);
-}
-
-opvp_result_t OPVPWrapper::SetClipPath(opvp_cliprule_t clipRule)
-{
- if (!supportSetClipPath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetClipPath(printerContext,clipRule);
-}
-
-opvp_result_t OPVPWrapper::SetCurrentPoint(opvp_fix_t x, opvp_fix_t y)
-{
- if (!supportSetCurrentPoint) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSetCurrentPoint(printerContext,x,y);
-}
-
-opvp_result_t OPVPWrapper::LinePath(opvp_pathmode_t flag,
- opvp_int_t npoints, const opvp_point_t *points)
-{
- if (!supportLinePath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpLinePath(printerContext,flag,npoints,points);
-}
-
-opvp_result_t OPVPWrapper::PolygonPath(opvp_int_t npolygons,
- const opvp_int_t *nvertexes, const opvp_point_t *points)
-{
- if (!supportPolygonPath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpPolygonPath(printerContext,npolygons,nvertexes,points);
-}
-
-opvp_result_t OPVPWrapper::RectanglePath(opvp_int_t nrectangles,
- const opvp_rectangle_t *rectangles)
-{
- if (!supportRectanglePath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpRectanglePath(printerContext,nrectangles,rectangles);
-}
-
-opvp_result_t OPVPWrapper::RoundRectanglePath(opvp_int_t nrectangles,
- const opvp_roundrectangle_t *rectangles)
-{
- if (!supportRoundRectanglePath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpRoundRectanglePath(printerContext,nrectangles,rectangles);
-}
-
-opvp_result_t OPVPWrapper::BezierPath(opvp_int_t npoints,
- const opvp_point_t *points)
-{
- if (!supportBezierPath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpBezierPath(printerContext,npoints,points);
-}
-
-opvp_result_t OPVPWrapper::ArcPath(opvp_arcmode_t kind,
- opvp_arcdir_t dir, opvp_fix_t bbx0,
- opvp_fix_t bby0, opvp_fix_t bbx1, opvp_fix_t bby1, opvp_fix_t x0,
- opvp_fix_t y0, opvp_fix_t x1, opvp_fix_t y1)
-{
- if (!supportArcPath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpArcPath(printerContext,kind,dir,bbx0,bby0,
- bbx1,bby1,x0,y0,x1,y1);
-}
-
-opvp_result_t OPVPWrapper::DrawImage(
- opvp_int_t sourceWidth, opvp_int_t sourceHeight, opvp_int_t sourcePitch,
- opvp_imageformat_t imageFormat, opvp_int_t destinationWidth,
- opvp_int_t destinationHeight, const void *imagedata)
-{
- if (!supportDrawImage) {
- int result;
-
- if ((result = StartDrawImage(sourceWidth,sourceHeight,sourcePitch,
- imageFormat,destinationWidth,destinationHeight)) < 0) {
- return result;
- }
- if ((result = TransferDrawImage(sourcePitch*sourceHeight,
- imagedata)) < 0) {
- return result;
- }
- return EndDrawImage();
- }
- return procs->opvpDrawImage(printerContext,sourceWidth, sourceHeight,
- sourcePitch, imageFormat, destinationWidth, destinationHeight,
- imagedata);
-}
-
-opvp_result_t OPVPWrapper::StartDrawImage(
- opvp_int_t sourceWidth, opvp_int_t sourceHeight, opvp_int_t sourcePitch,
- opvp_imageformat_t imageFormat, opvp_int_t destinationWidth,
- opvp_int_t destinationHeight)
-{
- if (!supportStartDrawImage) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpStartDrawImage(printerContext,sourceWidth,
- sourceHeight,sourcePitch,imageFormat,
- destinationWidth,destinationHeight);
-}
-
-opvp_result_t OPVPWrapper::TransferDrawImage(opvp_int_t count,
- const void *imagedata)
-{
- if (!supportTransferDrawImage) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpTransferDrawImage(printerContext,count,imagedata);
-}
-
-opvp_result_t OPVPWrapper::EndDrawImage()
-{
- if (!supportEndDrawImage) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpEndDrawImage(printerContext);
-}
-
-opvp_result_t OPVPWrapper::StartScanline(opvp_int_t yposition)
-{
- if (!supportStartScanline) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpStartScanline(printerContext,yposition);
-}
-
-opvp_result_t OPVPWrapper::Scanline(opvp_int_t nscanpairs,
- const opvp_int_t *scanpairs)
-{
- if (!supportScanline) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpScanline(printerContext,nscanpairs,scanpairs);
-}
-
-opvp_result_t OPVPWrapper::EndScanline()
-{
- if (!supportEndScanline) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpEndScanline(printerContext);
-}
-
-opvp_result_t OPVPWrapper::StartRaster(
- opvp_int_t rasterWidth)
-{
- if (!supportStartRaster) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpStartRaster(printerContext,rasterWidth);
-}
-
-opvp_result_t OPVPWrapper::TransferRasterData(opvp_int_t count,
- const opvp_byte_t *data)
-{
- if (!supportTransferRasterData) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpTransferRasterData(printerContext,count,
- data);
-}
-
-opvp_result_t OPVPWrapper::SkipRaster(opvp_int_t count)
-{
- if (!supportSkipRaster) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpSkipRaster(printerContext,count);
-}
-
-opvp_result_t OPVPWrapper::EndRaster()
-{
- if (!supportEndRaster) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpEndRaster(printerContext);
-}
-
-opvp_result_t OPVPWrapper::StartStream()
-{
- if (!supportStartStream) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpStartStream(printerContext);
-}
-
-opvp_result_t OPVPWrapper::TransferStreamData(opvp_int_t count,
- const void *data)
-{
- if (!supportTransferStreamData) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpTransferStreamData(printerContext,count,data);
-}
-
-opvp_result_t OPVPWrapper::EndStream()
-{
- if (!supportEndStream) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpEndStream(printerContext);
-}
-
-opvp_result_t OPVPWrapper::ResetClipPath()
-{
- if (!supportResetClipPath) {
- *opvpErrorNo = OPVP_NOTSUPPORTED;
- return -1;
- }
- return procs->opvpResetClipPath(printerContext);
-}
-
-char *OPVPWrapper::allocString(char **destin, unsigned int size)
-{
- if (!destin) return 0;
-
- if (*destin != 0) delete[] *destin;
- if (size > 0) {
- *destin = new char[size];
- }
-
- return *destin;
-}
-
-char **OPVPWrapper::genDynamicLibName(const char *name)
-{
- static char *buff[5] = {0,0,0,0,0};
-
- allocString(&(buff[0]), strlen(name)+1);
- strcpy(buff[0], name);
- allocString(&(buff[1]), strlen(name)+3+1);
- strcpy(buff[1], name);
- strcat(buff[1], ".so");
- allocString(&(buff[2]), strlen(name)+4+1);
- strcpy(buff[2], name);
- strcat(buff[2], ".dll");
- allocString(&(buff[3]), strlen(name)+6+1);
- strcpy(buff[3], "lib");
- strcat(buff[3], name);
- strcat(buff[3], ".so");
- buff[4] = 0;
-
- return buff;
-}
-
-OPVPWrapper *OPVPWrapper::loadDriver(const char *driverName,
- int outputFD, const char *printerModel)
-{
- char **list = 0;
- int i;
- void *h;
- int nApiEntry;
- int (*opvpOpenPrinter)(opvp_int_t outputFD,
- const opvp_char_t * printerModel, const opvp_int_t version[2],
- opvp_api_procs_t **apiEntry) = 0;
- int (*opvpOpenPrinter_0_2)(int outputFD, char* printerModel,
- int *nApiEntry, OPVP_api_procs **apiEntry) = 0;
- opvp_api_procs_t *opvpProcs;
- OPVP_api_procs *opvpProcs_0_2;
- opvp_dc_t opvpContext;
- int opvpContext_0_2 = 0;
- opvp_int_t *opvpErrorNo = 0;
- int *opvpErrorNo_0_2 = 0;
- void *handle = 0;
- OPVPWrapper *opvp = 0;
-
- // remove directory part
- const char *s = strrchr(driverName,'/');
- if (s != NULL) {
- driverName = s+1;
- }
-
- list = genDynamicLibName(driverName);
-
- if (list) {
- i = 0;
- while (list[i]) {
- if ((h = dlopen(list[i],RTLD_NOW))) {
- opvpOpenPrinter = (int (*)(opvp_int_t,
- const opvp_char_t *, const opvp_int_t[2],
- opvp_api_procs_t **))dlsym(h,"opvpOpenPrinter");
- opvpErrorNo = (opvp_int_t *)dlsym(h,"opvpErrorNo");
- if (opvpOpenPrinter && opvpErrorNo) {
- handle = h;
- break;
- }
- opvpOpenPrinter = 0;
- opvpErrorNo = 0;
- /* try version 0.2 driver */
- opvpOpenPrinter_0_2 = (int (*)(int, char*, int *,
- OPVP_api_procs **))dlsym(h,"OpenPrinter");
- opvpErrorNo_0_2 = (int *)dlsym(h,"errorno");
- if (opvpOpenPrinter_0_2 && opvpErrorNo_0_2) {
- handle = h;
- break;
- }
- opvpOpenPrinter_0_2 = 0;
- opvpErrorNo_0_2 = 0;
- }
- i++;
- }
- for (i = 0;list[i] != 0;i++) {
- delete[] (list[i]);
- list[i] = 0;
- }
- }
- if (handle == 0) {
- OPRS::error("Loading vector printer driver (%s) fail\n",driverName);
- return 0;
- }
- if (opvpOpenPrinter != 0) {
- opvp_int_t apiVersion[2];
-
- /* require version 1.0 */
- apiVersion[0] = 1;
- apiVersion[1] = 0;
- if ((opvpContext = (*opvpOpenPrinter)(outputFD,
- (const opvp_char_t *)printerModel,apiVersion,&opvpProcs)) < 0) {
- OPRS::error("OpenPrinter fail\n",driverName);
- unloadDriver(handle);
- return 0;
- }
- opvp = new OPVPWrapper(handle, opvpErrorNo, opvpProcs, opvpContext);
- } else if (opvpOpenPrinter_0_2) {
- if ((opvpContext_0_2 = (*opvpOpenPrinter_0_2)(outputFD,
- (char *)printerModel,&nApiEntry,&opvpProcs_0_2)) < 0) {
- OPRS::error("OpenPrinter fail\n",driverName);
- unloadDriver(handle);
- return 0;
- }
- opvp = (OPVPWrapper *)new OPVPWrapper_0_2(handle, opvpErrorNo_0_2,
- opvpProcs_0_2, opvpContext_0_2);
- }
- return opvp;
-}
-
-/*
- * unload vector-driver
- */
-int OPVPWrapper::unloadDriver(void *opvpHandleA)
-{
- if (opvpHandleA != 0) {
- dlclose(opvpHandleA);
- }
- return 0;
-}
-
-opvp_int_t OPVPWrapper::getErrorNo()
-{
- return *opvpErrorNo;
-}
-
diff --git a/filter/pdftoopvp/oprs/OPVPWrapper.h b/filter/pdftoopvp/oprs/OPVPWrapper.h
deleted file mode 100644
index 1dfcba3c2..000000000
--- a/filter/pdftoopvp/oprs/OPVPWrapper.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- OPVPWrapper.h
-*/
-
-#ifndef OPVPWRAPPER_H
-#define OPVPWRAPPER_H
-
-#include "opvp_common.h"
-
-class OPVPWrapper {
-public:
- static OPVPWrapper *loadDriver(const char *driverName, int outputFD,
- const char *printerModel);
- static int unloadDriver(void *opvpHandleA);
-private:
- static char *allocString(char **destin, unsigned int size);
- static char **genDynamicLibName(const char *name);
-public:
- OPVPWrapper() {};
- OPVPWrapper(void *opvpHandleA, opvp_int_t *opvpErrorNoA,
- opvp_api_procs_t *procsA, opvp_dc_t printerContextA);
- virtual ~OPVPWrapper();
-
- virtual opvp_int_t getErrorNo();
-
- void getVersion(opvp_int_t versionA[2])
- {
- versionA[0] = version[0];
- versionA[1] = version[1];
- }
-
- virtual opvp_result_t ClosePrinter();
- virtual opvp_result_t StartJob(const opvp_char_t *jobInfo);
- virtual opvp_result_t EndJob();
- virtual opvp_result_t AbortJob();
- virtual opvp_result_t StartDoc(const opvp_char_t *docInfo);
- virtual opvp_result_t EndDoc();
- virtual opvp_result_t StartPage(const opvp_char_t *pageInfo);
- virtual opvp_result_t EndPage();
- virtual opvp_result_t QueryDeviceCapability(opvp_flag_t queryflag,
- opvp_int_t *buflen, opvp_byte_t *infoBuf);
- virtual opvp_result_t QueryDeviceInfo(opvp_flag_t queryflag,
- opvp_int_t *buflen, opvp_byte_t *infoBuf);
- virtual opvp_result_t ResetCTM();
- virtual opvp_result_t SetCTM(const opvp_ctm_t *pCTM);
- virtual opvp_result_t GetCTM(opvp_ctm_t *pCTM);
- virtual opvp_result_t InitGS();
- virtual opvp_result_t SaveGS();
- virtual opvp_result_t RestoreGS();
- virtual opvp_result_t QueryColorSpace(opvp_int_t *pnum,
- opvp_cspace_t *pcspace);
- virtual opvp_result_t SetColorSpace(opvp_cspace_t cspace);
- virtual opvp_result_t GetColorSpace(opvp_cspace_t *pcspace);
- virtual opvp_result_t SetFillMode(opvp_fillmode_t fillmode);
- virtual opvp_result_t GetFillMode(opvp_fillmode_t *pfillmode);
- virtual opvp_result_t SetAlphaConstant(opvp_float_t alpha);
- virtual opvp_result_t GetAlphaConstant(opvp_float_t *palpha);
- virtual opvp_result_t SetLineWidth(opvp_fix_t width);
- virtual opvp_result_t GetLineWidth(opvp_fix_t *pwidth);
- virtual opvp_result_t SetLineDash(opvp_int_t num, const opvp_fix_t *pdash);
- virtual opvp_result_t GetLineDash(opvp_int_t *pnum, opvp_fix_t *pdash);
- virtual opvp_result_t SetLineDashOffset(opvp_fix_t offset);
- virtual opvp_result_t GetLineDashOffset(opvp_fix_t *poffset);
- virtual opvp_result_t SetLineStyle(opvp_linestyle_t linestyle);
- virtual opvp_result_t GetLineStyle(opvp_linestyle_t *plinestyle);
- virtual opvp_result_t SetLineCap(opvp_linecap_t linecap);
- virtual opvp_result_t GetLineCap(opvp_linecap_t *plinecap);
- virtual opvp_result_t SetLineJoin(opvp_linejoin_t linejoin);
- virtual opvp_result_t GetLineJoin(opvp_linejoin_t *plinejoin);
- virtual opvp_result_t SetMiterLimit(opvp_fix_t miterlimit);
- virtual opvp_result_t GetMiterLimit(opvp_fix_t *pmiterlimit);
- virtual opvp_result_t SetPaintMode(opvp_paintmode_t paintmode);
- virtual opvp_result_t GetPaintMode(opvp_paintmode_t *ppaintmode);
- virtual opvp_result_t SetStrokeColor(const opvp_brush_t *brush);
- virtual opvp_result_t SetFillColor(const opvp_brush_t *brush);
- virtual opvp_result_t SetBgColor(const opvp_brush_t *brush);
- virtual opvp_result_t NewPath();
- virtual opvp_result_t EndPath();
- virtual opvp_result_t StrokePath();
- virtual opvp_result_t FillPath();
- virtual opvp_result_t StrokeFillPath();
- virtual opvp_result_t SetClipPath(opvp_cliprule_t clipRule);
- virtual opvp_result_t SetCurrentPoint(opvp_fix_t x, opvp_fix_t y);
- virtual opvp_result_t LinePath(opvp_pathmode_t flag,
- opvp_int_t npoints, const opvp_point_t *points);
- virtual opvp_result_t PolygonPath(opvp_int_t npolygons,
- const opvp_int_t *nvertexes, const opvp_point_t *points);
- virtual opvp_result_t RectanglePath(opvp_int_t nrectangles,
- const opvp_rectangle_t *reclangles);
- virtual opvp_result_t RoundRectanglePath(opvp_int_t nrectangles,
- const opvp_roundrectangle_t *reclangles);
- virtual opvp_result_t BezierPath(opvp_int_t npoints,
- const opvp_point_t *points);
- virtual opvp_result_t ArcPath(opvp_arcmode_t kind,
- opvp_arcdir_t dir, opvp_fix_t bbx0, opvp_fix_t bby0,
- opvp_fix_t bbx1, opvp_fix_t bby1, opvp_fix_t x0,
- opvp_fix_t y0, opvp_fix_t x1, opvp_fix_t y1);
- virtual opvp_result_t DrawImage(opvp_int_t sourceWidth,
- opvp_int_t sourceHeight, opvp_int_t sourcePitch,
- opvp_imageformat_t imageFormat,
- opvp_int_t destinationWidth, opvp_int_t destinationHeight,
- const void *imageData);
- virtual opvp_result_t StartDrawImage(opvp_int_t sourceWidth,
- opvp_int_t sourceHeight, opvp_int_t sourcePitch,
- opvp_imageformat_t imageFormat,
- opvp_int_t destinationWidth, opvp_int_t destinationHeight);
- virtual opvp_result_t TransferDrawImage(opvp_int_t count,
- const void *imageData);
- virtual opvp_result_t EndDrawImage();
- virtual opvp_result_t StartScanline(opvp_int_t yposition);
- virtual opvp_result_t Scanline(opvp_int_t nscanpairs,
- const opvp_int_t *scanpairs);
- virtual opvp_result_t EndScanline();
- virtual opvp_result_t StartRaster(opvp_int_t rasterWidth);
- virtual opvp_result_t TransferRasterData(opvp_int_t count,
- const opvp_byte_t *data);
- virtual opvp_result_t SkipRaster(opvp_int_t count);
- virtual opvp_result_t EndRaster();
- virtual opvp_result_t StartStream();
- virtual opvp_result_t TransferStreamData(opvp_int_t count,
- const void *data);
- virtual opvp_result_t EndStream();
- virtual opvp_result_t ResetClipPath();
-
- bool supportClosePrinter;
- bool supportStartJob;
- bool supportEndJob;
- bool supportAbortJob;
- bool supportStartDoc;
- bool supportEndDoc;
- bool supportStartPage;
- bool supportEndPage;
- bool supportResetCTM;
- bool supportSetCTM;
- bool supportGetCTM;
- bool supportInitGS;
- bool supportSaveGS;
- bool supportRestoreGS;
- bool supportQueryColorSpace;
- bool supportSetColorSpace;
- bool supportGetColorSpace;
- bool supportSetFillMode;
- bool supportGetFillMode;
- bool supportSetAlphaConstant;
- bool supportGetAlphaConstant;
- bool supportSetLineWidth;
- bool supportGetLineWidth;
- bool supportSetLineDash;
- bool supportGetLineDash;
- bool supportSetLineDashOffset;
- bool supportGetLineDashOffset;
- bool supportSetLineStyle;
- bool supportGetLineStyle;
- bool supportSetLineCap;
- bool supportGetLineCap;
- bool supportSetLineJoin;
- bool supportGetLineJoin;
- bool supportSetMiterLimit;
- bool supportGetMiterLimit;
- bool supportSetPaintMode;
- bool supportGetPaintMode;
- bool supportSetStrokeColor;
- bool supportSetFillColor;
- bool supportSetBgColor;
- bool supportNewPath;
- bool supportEndPath;
- bool supportStrokePath;
- bool supportFillPath;
- bool supportStrokeFillPath;
- bool supportSetClipPath;
- bool supportSetCurrentPoint;
- bool supportLinePath;
- bool supportPolygonPath;
- bool supportRectanglePath;
- bool supportRoundRectanglePath;
- bool supportBezierPath;
- bool supportArcPath;
- bool supportDrawImage;
- bool supportStartDrawImage;
- bool supportTransferDrawImage;
- bool supportEndDrawImage;
- bool supportStartScanline;
- bool supportScanline;
- bool supportEndScanline;
- bool supportStartRaster;
- bool supportTransferRasterData;
- bool supportSkipRaster;
- bool supportEndRaster;
- bool supportStartStream;
- bool supportTransferStreamData;
- bool supportEndStream;
- bool supportQueryDeviceCapability;
- bool supportQueryDeviceInfo;
- bool supportResetClipPath;
-
-protected:
- void *opvpHandle;
- opvp_int_t version[2];
-private:
- opvp_api_procs_t *procs;
- opvp_int_t *opvpErrorNo;
- opvp_dc_t printerContext;
-};
-
-#endif
diff --git a/filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx b/filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx
deleted file mode 100644
index 112580e84..000000000
--- a/filter/pdftoopvp/oprs/OPVPWrapper_0_2.cxx
+++ /dev/null
@@ -1,1172 +0,0 @@
-/*
- OPVPWrapper_0_2.cc
-*/
-
-
-#include <config.h>
-#include "OPVPWrapper_0_2.h"
-#include <string.h>
-
-/* color space mapping 0.2 to 1.0 */
-opvp_cspace_t OPVPWrapper_0_2::cspace_0_2_to_1_0[] = {
- OPVP_CSPACE_BW,
- OPVP_CSPACE_DEVICEGRAY,
- OPVP_CSPACE_DEVICECMY,
- OPVP_CSPACE_DEVICECMYK,
- OPVP_CSPACE_DEVICERGB,
- OPVP_CSPACE_STANDARDRGB,
- OPVP_CSPACE_STANDARDRGB64
-};
-
-/* color space mapping 1.0 to 0.2 */
-OPVP_ColorSpace OPVPWrapper_0_2::cspace_1_0_to_0_2[] = {
- OPVP_cspaceBW,
- OPVP_cspaceDeviceGray,
- OPVP_cspaceDeviceCMY,
- OPVP_cspaceDeviceCMYK,
- OPVP_cspaceDeviceRGB,
- (OPVP_ColorSpace)0, /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */
- OPVP_cspaceStandardRGB,
- OPVP_cspaceStandardRGB64,
-};
-
-/* image format mapping 1.0 to 0.2 */
-OPVP_ImageFormat OPVPWrapper_0_2::iformat_1_0_to_0_2[] = {
- OPVP_iformatRaw,
- /* OPVP_IFORMAT_MASK use iformat raw in 0.2 */
- OPVP_iformatRaw,
- OPVP_iformatRLE,
- OPVP_iformatJPEG,
- OPVP_iformatPNG,
-};
-
-/* image colorDepth needed in 0.2 */
-int OPVPWrapper_0_2::colorDepth_0_2[] = {
- 1, /* OPVP_CSPACE_BW */
- 8, /* OPVP_CSPACE_DEVICEGRAY */
- 24, /* OPVP_CSPACE_DEVICECMY */
- 32, /* OPVP_CSPACE_DEVICECMYK */
- 24, /* OPVP_CSPACE_DEVICERGB */
- 32, /* OPVP_CSPACE_DEVICEKRGB */
- 24, /* OPVP_CSPACE_STANDARDRGB */
- 64, /* OPVP_CSPACE_STANDARDRGB64 */
-};
-
-OPVPWrapper_0_2::OPVPWrapper_0_2(void *opvpHandleA, int *opvpErrorNoA,
- OPVP_api_procs *procsA, int printerContextA)
-{
- procs_0_2 = procsA;
- opvpHandle = opvpHandleA;
- opvpErrorNo_0_2 = opvpErrorNoA;
- printerContext_0_2 = printerContextA;
- version[0] = 0;
- version[1] = 2;
- supportClosePrinter = (procs_0_2->ClosePrinter != 0);
- supportStartJob = (procs_0_2->StartJob != 0);
- supportEndJob = (procs_0_2->EndJob != 0);
- supportAbortJob = false;
- supportStartDoc = (procs_0_2->StartDoc != 0);
- supportEndDoc = (procs_0_2->EndDoc != 0);
- supportStartPage = (procs_0_2->StartPage != 0);
- supportEndPage = (procs_0_2->EndPage != 0);
- supportResetCTM = (procs_0_2->ResetCTM != 0);
- supportSetCTM = (procs_0_2->SetCTM != 0);
- supportGetCTM = (procs_0_2->GetCTM != 0);
- supportInitGS = (procs_0_2->InitGS != 0);
- supportSaveGS = (procs_0_2->SaveGS != 0);
- supportRestoreGS = (procs_0_2->RestoreGS != 0);
- supportQueryColorSpace = (procs_0_2->QueryColorSpace != 0);
- supportSetColorSpace = (procs_0_2->SetColorSpace != 0);
- supportGetColorSpace = (procs_0_2->GetColorSpace != 0);
- supportSetFillMode = (procs_0_2->SetFillMode != 0);
- supportGetFillMode = (procs_0_2->GetFillMode != 0);
- supportSetAlphaConstant = (procs_0_2->SetAlphaConstant != 0);
- supportGetAlphaConstant = (procs_0_2->GetAlphaConstant != 0);
- supportSetLineWidth = (procs_0_2->SetLineWidth != 0);
- supportGetLineWidth = (procs_0_2->GetLineWidth != 0);
- supportSetLineDash = (procs_0_2->SetLineDash != 0);
- supportGetLineDash = (procs_0_2->GetLineDash != 0);
- supportSetLineDashOffset = (procs_0_2->SetLineDashOffset != 0);
- supportGetLineDashOffset = (procs_0_2->GetLineDashOffset != 0);
- supportSetLineStyle = (procs_0_2->SetLineStyle != 0);
- supportGetLineStyle = (procs_0_2->GetLineStyle != 0);
- supportSetLineCap = (procs_0_2->SetLineCap != 0);
- supportGetLineCap = (procs_0_2->GetLineCap != 0);
- supportSetLineJoin = (procs_0_2->SetLineJoin != 0);
- supportGetLineJoin = (procs_0_2->GetLineJoin != 0);
- supportSetMiterLimit = (procs_0_2->SetMiterLimit != 0);
- supportGetMiterLimit = (procs_0_2->GetMiterLimit != 0);
- supportSetPaintMode = (procs_0_2->SetPaintMode != 0);
- supportGetPaintMode = (procs_0_2->GetPaintMode != 0);
- supportSetStrokeColor = (procs_0_2->SetStrokeColor != 0);
- supportSetFillColor = (procs_0_2->SetFillColor != 0);
- supportSetBgColor = (procs_0_2->SetBgColor != 0);
- supportNewPath = (procs_0_2->NewPath != 0);
- supportEndPath = (procs_0_2->EndPath != 0);
- supportStrokePath = (procs_0_2->StrokePath != 0);
- supportFillPath = (procs_0_2->FillPath != 0);
- supportStrokeFillPath = (procs_0_2->StrokeFillPath != 0);
- supportSetClipPath = (procs_0_2->SetClipPath != 0);
- supportSetCurrentPoint = (procs_0_2->SetCurrentPoint != 0);
- supportLinePath = (procs_0_2->LinePath != 0);
- supportPolygonPath = (procs_0_2->PolygonPath != 0);
- supportRectanglePath = (procs_0_2->RectanglePath != 0);
- supportRoundRectanglePath = (procs_0_2->RoundRectanglePath != 0);
- supportBezierPath = (procs_0_2->BezierPath != 0);
- supportArcPath = (procs_0_2->ArcPath != 0);
- supportDrawImage = (procs_0_2->DrawImage != 0);
- supportStartDrawImage = (procs_0_2->StartDrawImage != 0);
- supportTransferDrawImage = (procs_0_2->TransferDrawImage != 0);
- supportEndDrawImage = (procs_0_2->EndDrawImage != 0);
- supportStartScanline = (procs_0_2->StartScanline != 0);
- supportScanline = (procs_0_2->Scanline != 0);
- supportEndScanline = (procs_0_2->EndScanline != 0);
- supportStartRaster = (procs_0_2->StartRaster != 0);
- supportTransferRasterData = (procs_0_2->TransferRasterData != 0);
- supportSkipRaster = (procs_0_2->SkipRaster != 0);
- supportEndRaster = (procs_0_2->EndRaster != 0);
- supportStartStream = (procs_0_2->StartStream != 0);
- supportTransferStreamData = (procs_0_2->TransferStreamData != 0);
- supportEndStream = (procs_0_2->EndStream != 0);
- supportQueryDeviceCapability = (procs_0_2->QueryDeviceCapability != 0);
- supportQueryDeviceInfo = (procs_0_2->QueryDeviceInfo != 0);
- supportResetClipPath = (procs_0_2->ResetClipPath != 0);
- colorSpace = OPVP_CSPACE_STANDARDRGB;
- if (supportGetColorSpace) {
- if (GetColorSpace(&colorSpace) != OPVP_OK) {
- colorSpace = OPVP_CSPACE_STANDARDRGB;
- }
- }
-}
-
-OPVPWrapper_0_2::~OPVPWrapper_0_2()
-{
-}
-
-opvp_result_t OPVPWrapper_0_2::ClosePrinter()
-{
- if (!supportClosePrinter) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->ClosePrinter(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::StartJob(
- const opvp_char_t *jobInfo)
-{
- if (!supportStartJob) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->StartJob(printerContext_0_2,
- (char *)jobInfo);
-}
-
-opvp_result_t OPVPWrapper_0_2::EndJob()
-{
- if (!supportEndJob) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->EndJob(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::AbortJob()
-{
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
-}
-
-opvp_result_t OPVPWrapper_0_2::StartDoc(
- const opvp_char_t *docInfo)
-{
- if (!supportStartDoc) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->StartDoc(printerContext_0_2,
- (char *)docInfo);
-}
-
-opvp_result_t OPVPWrapper_0_2::EndDoc()
-{
- if (!supportEndDoc) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->EndDoc(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::StartPage(
- const opvp_char_t *pageInfo)
-{
- int r;
-
- if (!supportStartPage) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if ((r = procs_0_2->StartPage(printerContext_0_2,
- /* discard const */(char *)pageInfo)) != OPVP_OK) {
- /* error */
- return (opvp_result_t)r;
- }
- /* initialize ROP */
- if (procs_0_2->SetROP != 0) {
- procs_0_2->SetROP(printerContext_0_2,
- OPVP_0_2_ROP_P);
- }
- return OPVP_OK;
-}
-
-opvp_result_t OPVPWrapper_0_2::EndPage()
-{
- if (!supportEndPage) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->EndPage(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::QueryDeviceCapability(
- opvp_flag_t queryflag, opvp_int_t *buflen, opvp_byte_t *infoBuf)
-{
- if (!supportQueryDeviceCapability) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->
- QueryDeviceCapability(printerContext_0_2,queryflag,*buflen,
- (char *)infoBuf);
-}
-
-opvp_result_t OPVPWrapper_0_2::QueryDeviceInfo(
- opvp_flag_t queryflag, opvp_int_t *buflen, opvp_byte_t *infoBuf)
-{
- if (!supportQueryDeviceInfo) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if (queryflag & OPVP_QF_MEDIACOPY) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if (queryflag & OPVP_QF_PRINTREGION) {
- queryflag &= ~OPVP_QF_PRINTREGION;
- queryflag |= 0x0020000;
- }
- return (opvp_result_t)procs_0_2->QueryDeviceInfo(printerContext_0_2,
- queryflag,*buflen,(char *)infoBuf);
-}
-
-opvp_result_t OPVPWrapper_0_2::ResetCTM()
-{
- if (!supportResetCTM) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->ResetCTM(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetCTM(const opvp_ctm_t *pCTM)
-{
- if (!supportSetCTM) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->SetCTM(printerContext_0_2,
- (OPVP_CTM *)pCTM);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetCTM(opvp_ctm_t *pCTM)
-{
- if (!supportGetCTM) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->GetCTM(printerContext_0_2,
- (OPVP_CTM *)pCTM);
-}
-
-opvp_result_t OPVPWrapper_0_2::InitGS()
-{
- int r;
-
- if (!supportInitGS) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if ((r = procs_0_2->InitGS(printerContext_0_2)) != OPVP_OK) {
- /* error */
- return (opvp_result_t)r;
- }
- /* initialize ROP */
- if (procs_0_2->SetROP != 0) {
- procs_0_2->SetROP(printerContext_0_2,
- OPVP_0_2_ROP_P);
- }
- return OPVP_OK;
-}
-
-opvp_result_t OPVPWrapper_0_2::SaveGS()
-{
- if (!supportSaveGS) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->SaveGS(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::RestoreGS()
-{
- if (!supportRestoreGS) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->RestoreGS(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::QueryColorSpace(
- opvp_int_t *pnum, opvp_cspace_t *pcspace)
-{
- int r;
- int i;
-
- if (!supportQueryColorSpace) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if ((r = procs_0_2->QueryColorSpace(printerContext_0_2,
- (OPVP_ColorSpace *)pcspace,pnum)) != OPVP_OK) {
- /* error */
- return (opvp_result_t)r;
- }
- /* translate cspaces */
- for (i = 0;i < *pnum;i++) {
- if ((unsigned int)pcspace[i]
- > sizeof(cspace_0_2_to_1_0)/sizeof(opvp_cspace_t)) {
- /* unknown color space */
- /* set DEVICERGB instead */
- pcspace[i] = OPVP_CSPACE_DEVICERGB;
- } else {
- pcspace[i] = cspace_0_2_to_1_0[pcspace[i]];
- }
- }
- return OPVP_OK;
-}
-
-opvp_result_t OPVPWrapper_0_2::SetColorSpace(
- opvp_cspace_t cspace)
-{
- int r;
-
- if (!supportSetColorSpace) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if (cspace == OPVP_CSPACE_DEVICEKRGB) {
- /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if ((unsigned int)cspace
- > sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) {
- /* unknown color space */
- *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
- return -1;
- }
- r = procs_0_2->SetColorSpace(printerContext_0_2,
- cspace_1_0_to_0_2[cspace]);
- if (r == OPVP_OK) {
- colorSpace = cspace;
- }
- return (opvp_result_t)r;
-}
-
-opvp_result_t OPVPWrapper_0_2::GetColorSpace(
- opvp_cspace_t *pcspace)
-{
- int r;
-
- if (!supportGetColorSpace) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if ((r = procs_0_2->GetColorSpace(printerContext_0_2,
- (OPVP_ColorSpace *)pcspace)) != OPVP_OK) {
- /* error */
- return (opvp_result_t)r;
- }
- if ((unsigned int)*pcspace
- > sizeof(cspace_0_2_to_1_0)/sizeof(opvp_cspace_t)) {
- /* unknown color space */
- /* set DEVICERGB instead */
- *pcspace = OPVP_CSPACE_DEVICERGB;
- } else {
- *pcspace = cspace_0_2_to_1_0[*pcspace];
- }
- return (opvp_result_t)r;
-}
-
-opvp_result_t OPVPWrapper_0_2::SetFillMode(
- opvp_fillmode_t fillmode)
-{
- if (!supportSetFillMode) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_FillMode is comaptible with opvp_fillmode_t */
- return (opvp_result_t)procs_0_2->SetFillMode(printerContext_0_2,
- (OPVP_FillMode)fillmode);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetFillMode(
- opvp_fillmode_t *pfillmode)
-{
- if (!supportGetFillMode) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_FillMode is comaptible with opvp_fillmode_t */
- return (opvp_result_t)procs_0_2->GetFillMode(printerContext_0_2,
- (OPVP_FillMode *)pfillmode);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetAlphaConstant(
- opvp_float_t alpha)
-{
- if (!supportSetAlphaConstant) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->SetAlphaConstant(printerContext_0_2,alpha);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetAlphaConstant(
- opvp_float_t *palpha)
-{
- if (!supportGetAlphaConstant) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->GetAlphaConstant(printerContext_0_2,palpha);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetLineWidth(
- opvp_fix_t width)
-{
- if (!supportSetLineWidth) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->SetLineWidth(printerContext_0_2,width);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetLineWidth(
- opvp_fix_t *pwidth)
-{
- if (!supportGetLineWidth) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->GetLineWidth(printerContext_0_2,pwidth);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetLineDash(opvp_int_t num,
- const opvp_fix_t *pdash)
-{
- if (!supportSetLineDash) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->SetLineDash(printerContext_0_2,
- /* remove const */ (OPVP_Fix *)pdash,num);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetLineDash(
- opvp_int_t *pnum, opvp_fix_t *pdash)
-{
- if (!supportGetLineDash) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->GetLineDash(printerContext_0_2,
- pdash,pnum);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetLineDashOffset(
- opvp_fix_t offset)
-{
- if (!supportSetLineDashOffset) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->SetLineDashOffset(printerContext_0_2,offset);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetLineDashOffset(
- opvp_fix_t *poffset)
-{
- if (!supportGetLineDashOffset) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->GetLineDashOffset(printerContext_0_2,poffset);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetLineStyle(
- opvp_linestyle_t linestyle)
-{
- if (!supportSetLineStyle) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_LineStyle is compatible with opvp_linestyle_t */
- return (opvp_result_t)procs_0_2->SetLineStyle(printerContext_0_2,
- (OPVP_LineStyle)linestyle);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetLineStyle(
- opvp_linestyle_t *plinestyle)
-{
- if (!supportGetLineStyle) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_LineStyle is compatible with opvp_linestyle_t */
- return (opvp_result_t)procs_0_2->GetLineStyle(printerContext_0_2,
- (OPVP_LineStyle *)plinestyle);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetLineCap(
- opvp_linecap_t linecap)
-{
- if (!supportSetLineCap) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_LineCap is compatible with opvp_cap_t */
- return (opvp_result_t)procs_0_2->SetLineCap(printerContext_0_2,
- (OPVP_LineCap)linecap);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetLineCap(
- opvp_linecap_t *plinecap)
-{
- if (!supportGetLineCap) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_LineCap is compatible with opvp_cap_t */
- return (opvp_result_t)procs_0_2->GetLineCap(printerContext_0_2,
- (OPVP_LineCap *)plinecap);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetLineJoin(
- opvp_linejoin_t linejoin)
-{
- if (!supportSetLineJoin) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_LineJoin is compatible with opvp_linejoin_t */
- return (opvp_result_t)procs_0_2->SetLineJoin(printerContext_0_2,
- (OPVP_LineJoin)linejoin);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetLineJoin(
- opvp_linejoin_t *plinejoin)
-{
- if (!supportGetLineJoin) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_LineJoin is compatible with opvp_linejoin_t */
- return (opvp_result_t)procs_0_2->GetLineJoin(printerContext_0_2,
- (OPVP_LineJoin *)plinejoin);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetMiterLimit(
- opvp_fix_t miterlimit)
-{
- if (!supportSetMiterLimit) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_Fix is compatible with opvp_fix_t */
- return (opvp_result_t)procs_0_2->SetMiterLimit(printerContext_0_2,
- (OPVP_Fix)miterlimit);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetMiterLimit(
- opvp_fix_t *pmiterlimit)
-{
- if (!supportGetMiterLimit) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_Fix is compatible with opvp_fix_t */
- return (opvp_result_t)procs_0_2->GetMiterLimit(printerContext_0_2,
- (OPVP_Fix *)pmiterlimit);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetPaintMode(
- opvp_paintmode_t paintmode)
-{
- if (!supportSetPaintMode) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_PaintMode is compatible with opvp_paintmode_t */
- return (opvp_result_t)procs_0_2->SetPaintMode(printerContext_0_2,
- (OPVP_PaintMode)paintmode);
-}
-
-opvp_result_t OPVPWrapper_0_2::GetPaintMode(
- opvp_paintmode_t *ppaintmode)
-{
- if (!supportGetPaintMode) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_PaintMode is compatible with opvp_paintmode_t */
- return (opvp_result_t)procs_0_2->GetPaintMode(printerContext_0_2,
- (OPVP_PaintMode *)ppaintmode);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetStrokeColor(
- const opvp_brush_t *brush)
-{
- OPVP_Brush brush_0_2;
-
- if (!supportSetStrokeColor) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if (brush == 0) {
- *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
- return -1;
- }
- if (brush->colorSpace == OPVP_CSPACE_DEVICEKRGB) {
- /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if ((unsigned int)brush->colorSpace
- > sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) {
- /* unknown color space */
- *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
- return -1;
- }
- brush_0_2.colorSpace = cspace_1_0_to_0_2[brush->colorSpace];
- brush_0_2.xorg = brush->xorg;
- brush_0_2.yorg = brush->yorg;
- brush_0_2.pbrush = (OPVP_BrushData *)brush->pbrush;
- memcpy(brush_0_2.color,brush->color,sizeof(brush_0_2.color));
- return (opvp_result_t)procs_0_2->SetStrokeColor(printerContext_0_2,
- &brush_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetFillColor(
- const opvp_brush_t *brush)
-{
- OPVP_Brush brush_0_2;
-
- if (!supportSetFillColor) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if (brush == 0) {
- *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
- return -1;
- }
- if (brush->colorSpace == OPVP_CSPACE_DEVICEKRGB) {
- /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if ((unsigned int)brush->colorSpace
- > sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) {
- /* unknown color space */
- *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
- return -1;
- }
- brush_0_2.colorSpace = cspace_1_0_to_0_2[brush->colorSpace];
- brush_0_2.xorg = brush->xorg;
- brush_0_2.yorg = brush->yorg;
- brush_0_2.pbrush = (OPVP_BrushData *)brush->pbrush;
- memcpy(brush_0_2.color,brush->color,sizeof(brush_0_2.color));
- return (opvp_result_t)procs_0_2->SetFillColor(printerContext_0_2,
- &brush_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetBgColor(
- const opvp_brush_t *brush)
-{
- OPVP_Brush brush_0_2;
-
- if (!supportSetBgColor) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if (brush == 0) {
- *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
- return -1;
- }
- if (brush->colorSpace == OPVP_CSPACE_DEVICEKRGB) {
- /* 0.2 doesn't have OPVP_CSPACE_DEVICEKRGB */
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if ((unsigned int)brush->colorSpace
- > sizeof(cspace_1_0_to_0_2)/sizeof(OPVP_ColorSpace)) {
- /* unknown color space */
- *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
- return -1;
- }
- brush_0_2.colorSpace = cspace_1_0_to_0_2[brush->colorSpace];
- brush_0_2.xorg = brush->xorg;
- brush_0_2.yorg = brush->yorg;
- brush_0_2.pbrush = (OPVP_BrushData *)brush->pbrush;
- memcpy(brush_0_2.color,brush->color,sizeof(brush_0_2.color));
- return (opvp_result_t)procs_0_2->SetBgColor(printerContext_0_2,
- &brush_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::NewPath()
-{
- if (!supportNewPath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->NewPath(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::EndPath()
-{
- if (!supportEndPath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->EndPath(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::StrokePath()
-{
- if (!supportStrokePath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->StrokePath(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::FillPath()
-{
- if (!supportFillPath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->FillPath(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::StrokeFillPath()
-{
- if (!supportStrokeFillPath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->StrokeFillPath(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetClipPath(
- opvp_cliprule_t clipRule)
-{
- if (!supportSetClipPath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_ClipRule is compatible with opvp_cliprule_t */
- return (opvp_result_t)procs_0_2->SetClipPath(printerContext_0_2,
- (OPVP_ClipRule)clipRule);
-}
-
-opvp_result_t OPVPWrapper_0_2::SetCurrentPoint(
- opvp_fix_t x, opvp_fix_t y)
-{
- if (!supportSetCurrentPoint) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->SetCurrentPoint(printerContext_0_2,x,y);
-}
-
-opvp_result_t OPVPWrapper_0_2::LinePath(
- opvp_pathmode_t flag, opvp_int_t npoints, const opvp_point_t *points)
-{
- if (!supportLinePath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_Point is compatible with opvp_point_t */
- return (opvp_result_t)procs_0_2->LinePath(printerContext_0_2,flag,npoints,
- (OPVP_Point *)points);
-}
-
-opvp_result_t OPVPWrapper_0_2::PolygonPath(
- opvp_int_t npolygons, const opvp_int_t *nvertexes,
- const opvp_point_t *points)
-{
- if (!supportPolygonPath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_Point is compatible with opvp_point_t */
- return (opvp_result_t)procs_0_2->PolygonPath(printerContext_0_2,
- (int)npolygons,(int *)nvertexes,(OPVP_Point *)points);
-}
-
-opvp_result_t OPVPWrapper_0_2::RectanglePath(
- opvp_int_t nrectangles, const opvp_rectangle_t *rectangles)
-{
- if (!supportRectanglePath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_Rectangle is compatible with opvp_rectangle_t */
- return (opvp_result_t)procs_0_2->RectanglePath(printerContext_0_2,
- (int)nrectangles,(OPVP_Rectangle *)rectangles);
-}
-
-opvp_result_t OPVPWrapper_0_2::RoundRectanglePath(
- opvp_int_t nrectangles, const opvp_roundrectangle_t *rectangles)
-{
- if (!supportRoundRectanglePath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_RoundRectangle is compatible with opvp_roundrectangle_t */
- return (opvp_result_t)procs_0_2->RoundRectanglePath(printerContext_0_2,
- (int)nrectangles,(OPVP_RoundRectangle *)rectangles);
-}
-
-opvp_result_t OPVPWrapper_0_2::BezierPath(opvp_int_t npoints,
- const opvp_point_t *points)
-{
- if (!supportBezierPath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* OPVP_Point is compatible with opvp_point_t */
- return (opvp_result_t)procs_0_2->BezierPath(printerContext_0_2,(int)npoints,
- (OPVP_Point *)points);
-}
-
-opvp_result_t OPVPWrapper_0_2::ArcPath(opvp_arcmode_t kind, opvp_arcdir_t dir,
- opvp_fix_t bbx0, opvp_fix_t bby0, opvp_fix_t bbx1,
- opvp_fix_t bby1, opvp_fix_t x0, opvp_fix_t y0, opvp_fix_t x1, opvp_fix_t y1)
-{
- if (!supportArcPath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- /* opvp_arcmode_t is compatible with int */
- /* opvp_arcdir_t is compatible with int */
- return (opvp_result_t)procs_0_2->ArcPath(printerContext_0_2,
- (int)kind,(int)dir,bbx0,bby0,
- bbx1,bby1,x0,y0,x1,y1);
-}
-
-opvp_result_t OPVPWrapper_0_2::DrawImage(opvp_int_t sourceWidth,
- opvp_int_t sourceHeight, opvp_int_t sourcePitch,
- opvp_imageformat_t imageFormat, opvp_int_t destinationWidth,
- opvp_int_t destinationHeight, const void *imagedata)
-{
- int r;
- OPVP_Rectangle rect;
- OPVP_ImageFormat iformat_0_2;
- OPVP_PaintMode paintmode_0_2 = OPVP_paintModeTransparent;
- int depth;
-
- if (!supportDrawImage) {
- int result;
-
- if ((result = StartDrawImage(sourceWidth,
- sourceHeight,sourcePitch,imageFormat,destinationWidth,
- destinationHeight)) < 0) {
- return result;
- }
- if ((result = TransferDrawImage(sourcePitch*sourceHeight,
- imagedata)) < 0) {
- return result;
- }
- return EndDrawImage();
- }
-
- if (imageFormat == OPVP_IFORMAT_MASK) {
- if (procs_0_2->GetPaintMode != 0) {
- procs_0_2->GetPaintMode(printerContext_0_2,
- &paintmode_0_2);
- }
- if (paintmode_0_2 != OPVP_paintModeTransparent) {
- if (procs_0_2->SetROP != 0) {
- procs_0_2->SetROP(printerContext_0_2,
- OPVP_0_2_ROP_S);
- }
- }
- else {
- if (procs_0_2->SetROP != 0) {
- procs_0_2->SetROP(printerContext_0_2,
- OPVP_0_2_ROP_OR);
- }
- }
- depth = 1;
- } else {
- if (procs_0_2->SetROP != 0) {
- procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_S);
- }
- depth = colorDepth_0_2[colorSpace];
- }
-
- OPVP_I2FIX(0,rect.p0.x);
- OPVP_I2FIX(0,rect.p0.y);
- OPVP_I2FIX(destinationWidth,rect.p1.x);
- OPVP_I2FIX(destinationHeight,rect.p1.y);
- if ((unsigned int)imageFormat
- > sizeof(iformat_1_0_to_0_2)/sizeof(OPVP_ImageFormat)) {
- /* illegal image format */
- *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
- return -1;
- }
- iformat_0_2 = iformat_1_0_to_0_2[imageFormat];
- r = procs_0_2->DrawImage(printerContext_0_2,sourceWidth,sourceHeight,
- depth,iformat_0_2,rect,
- sourcePitch*sourceHeight,
- /* remove const */ (void *)imagedata);
-
- if (procs_0_2->SetROP != 0) {
- procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_P);
- }
-
- return (opvp_result_t)r;
-}
-
-opvp_result_t OPVPWrapper_0_2::StartDrawImage(opvp_int_t sourceWidth,
- opvp_int_t sourceHeight, opvp_int_t sourcePitch,
- opvp_imageformat_t imageFormat, opvp_int_t destinationWidth,
- opvp_int_t destinationHeight)
-{
- int r;
- OPVP_Rectangle rect;
- OPVP_ImageFormat iformat_0_2;
- OPVP_PaintMode paintmode_0_2 = OPVP_paintModeTransparent;
- int depth;
-
- if (!supportStartDrawImage) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- if (imageFormat == OPVP_IFORMAT_MASK) {
- if (procs_0_2->GetPaintMode != 0) {
- procs_0_2->GetPaintMode(printerContext_0_2,
- &paintmode_0_2);
- }
- if (paintmode_0_2 != OPVP_paintModeTransparent) {
- if (procs_0_2->SetROP != 0) {
- procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_S);
- }
- }
- else {
- if (procs_0_2->SetROP != 0) {
- procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_OR);
- }
- }
- depth = 1;
- } else {
- if (procs_0_2->SetROP != 0) {
- procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_S);
- }
- depth = colorDepth_0_2[colorSpace];
- }
-
- OPVP_I2FIX(0,rect.p0.x);
- OPVP_I2FIX(0,rect.p0.y);
- OPVP_I2FIX(destinationWidth,rect.p1.x);
- OPVP_I2FIX(destinationHeight,rect.p1.y);
- if ((unsigned int)imageFormat
- > sizeof(iformat_1_0_to_0_2)/sizeof(OPVP_ImageFormat)) {
- /* illegal image format */
- *opvpErrorNo_0_2 = OPVP_PARAMERROR_0_2;
- return -1;
- }
- iformat_0_2 = iformat_1_0_to_0_2[imageFormat];
- r = procs_0_2->StartDrawImage(printerContext_0_2,
- sourceWidth,sourceHeight,
- depth,iformat_0_2,rect);
-
- return (opvp_result_t)r;
-}
-
-opvp_result_t OPVPWrapper_0_2::TransferDrawImage(opvp_int_t count,
- const void *imagedata)
-{
- if (!supportTransferDrawImage) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->TransferDrawImage(printerContext_0_2,
- count,(void *)imagedata);
-}
-
-opvp_result_t OPVPWrapper_0_2::EndDrawImage()
-{
- int r;
-
- if (!supportEndDrawImage) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- r = procs_0_2->EndDrawImage(printerContext_0_2);
-
- /* make sure rop is pattern copy */
- if (procs_0_2->SetROP != 0) {
- procs_0_2->SetROP(printerContext_0_2,OPVP_0_2_ROP_P);
- }
-
- return (opvp_result_t)r;
-}
-
-opvp_result_t OPVPWrapper_0_2::StartScanline(opvp_int_t yposition)
-{
- if (!supportStartScanline) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->StartScanline(printerContext_0_2,yposition);
-}
-
-opvp_result_t OPVPWrapper_0_2::Scanline(opvp_int_t nscanpairs,
- const opvp_int_t *scanpairs)
-{
- if (!supportScanline) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->Scanline(printerContext_0_2,
- (int)nscanpairs,(int *)scanpairs);
-}
-
-opvp_result_t OPVPWrapper_0_2::EndScanline()
-{
- if (!supportEndScanline) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->EndScanline(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::StartRaster(opvp_int_t rasterWidth)
-{
- if (!supportStartRaster) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->StartRaster(printerContext_0_2,rasterWidth);
-}
-
-opvp_result_t OPVPWrapper_0_2::TransferRasterData(opvp_int_t count,
- const opvp_byte_t *data)
-{
- if (!supportTransferRasterData) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->TransferRasterData(printerContext_0_2,
- (int)count, (unsigned char *)data);
-}
-
-opvp_result_t OPVPWrapper_0_2::SkipRaster(opvp_int_t count)
-{
- if (!supportSkipRaster) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->SkipRaster(printerContext_0_2,count);
-}
-
-opvp_result_t OPVPWrapper_0_2::EndRaster()
-{
- if (!supportEndRaster) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->EndRaster(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::StartStream()
-{
- if (!supportStartStream) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->StartStream(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::TransferStreamData(opvp_int_t count,
- const void *data)
-{
- if (!supportTransferStreamData) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->TransferStreamData(printerContext_0_2,
- count,(void *)data);
-}
-
-opvp_result_t OPVPWrapper_0_2::EndStream()
-{
- if (!supportEndStream) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->EndStream(printerContext_0_2);
-}
-
-opvp_result_t OPVPWrapper_0_2::ResetClipPath()
-{
- if (!supportResetClipPath) {
- *opvpErrorNo_0_2 = OPVP_NOTSUPPORTED_0_2;
- return -1;
- }
- return (opvp_result_t)procs_0_2->ResetClipPath(printerContext_0_2);
-}
-
-/* translate error code */
-opvp_int_t OPVPWrapper_0_2::getErrorNo()
-{
- switch(*opvpErrorNo_0_2) {
- case OPVP_FATALERROR_0_2:
- return OPVP_FATALERROR;
- break;
- case OPVP_BADREQUEST_0_2:
- return OPVP_BADREQUEST;
- break;
- case OPVP_BADCONTEXT_0_2:
- return OPVP_BADCONTEXT;
- break;
- case OPVP_NOTSUPPORTED_0_2:
- return OPVP_NOTSUPPORTED;
- break;
- case OPVP_JOBCANCELED_0_2:
- return OPVP_JOBCANCELED;
- break;
- case OPVP_PARAMERROR_0_2:
- return OPVP_PARAMERROR;
- break;
- default:
- break;
- }
- /* unknown error no */
- /* return FATALERROR instead */
- return OPVP_FATALERROR;
-}
diff --git a/filter/pdftoopvp/oprs/OPVPWrapper_0_2.h b/filter/pdftoopvp/oprs/OPVPWrapper_0_2.h
deleted file mode 100644
index f670a4526..000000000
--- a/filter/pdftoopvp/oprs/OPVPWrapper_0_2.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- OPVPWrapper_0_2.h
-*/
-
-#ifndef OPVPWRAPPER_0_2_H
-#define OPVPWRAPPER_0_2_H
-
-#include "OPVPWrapper.h"
-
-/* ROP */
-#define OPVP_0_2_ROP_S 0xCC
-#define OPVP_0_2_ROP_P 0xF0
-#define OPVP_0_2_ROP_OR 0xB8
-
-class OPVPWrapper_0_2: public OPVPWrapper {
-private:
- static opvp_cspace_t cspace_0_2_to_1_0[];
- static OPVP_ColorSpace cspace_1_0_to_0_2[];
- static OPVP_ImageFormat iformat_1_0_to_0_2[];
- static int colorDepth_0_2[];
-public:
- OPVPWrapper_0_2(void *opvpHandleA, int *opvpErrorNoA,
- OPVP_api_procs *procsA, int printerContextA);
- virtual ~OPVPWrapper_0_2();
- virtual opvp_int_t getErrorNo();
-
- virtual opvp_result_t ClosePrinter();
- virtual opvp_result_t StartJob(const opvp_char_t *jobInfo);
- virtual opvp_result_t EndJob();
- virtual opvp_result_t AbortJob();
- virtual opvp_result_t StartDoc(const opvp_char_t *docInfo);
- virtual opvp_result_t EndDoc();
- virtual opvp_result_t StartPage(const opvp_char_t *pageInfo);
- virtual opvp_result_t EndPage();
- virtual opvp_result_t QueryDeviceCapability(opvp_flag_t queryflag,
- opvp_int_t *buflen, opvp_byte_t *infoBuf);
- virtual opvp_result_t QueryDeviceInfo(opvp_flag_t queryflag,
- opvp_int_t *buflen, opvp_byte_t *infoBuf);
- virtual opvp_result_t ResetCTM();
- virtual opvp_result_t SetCTM(const opvp_ctm_t *pCTM);
- virtual opvp_result_t GetCTM(opvp_ctm_t *pCTM);
- virtual opvp_result_t InitGS();
- virtual opvp_result_t SaveGS();
- virtual opvp_result_t RestoreGS();
- virtual opvp_result_t QueryColorSpace(opvp_int_t *pnum,
- opvp_cspace_t *pcspace);
- virtual opvp_result_t SetColorSpace(opvp_cspace_t cspace);
- virtual opvp_result_t GetColorSpace(opvp_cspace_t *pcspace);
- virtual opvp_result_t SetFillMode(opvp_fillmode_t fillmode);
- virtual opvp_result_t GetFillMode(opvp_fillmode_t *pfillmode);
- virtual opvp_result_t SetAlphaConstant(opvp_float_t alpha);
- virtual opvp_result_t GetAlphaConstant(opvp_float_t *palpha);
- virtual opvp_result_t SetLineWidth(opvp_fix_t width);
- virtual opvp_result_t GetLineWidth(opvp_fix_t *pwidth);
- virtual opvp_result_t SetLineDash(opvp_int_t num, const opvp_fix_t *pdash);
- virtual opvp_result_t GetLineDash(opvp_int_t *pnum, opvp_fix_t *pdash);
- virtual opvp_result_t SetLineDashOffset(opvp_fix_t offset);
- virtual opvp_result_t GetLineDashOffset(opvp_fix_t *poffset);
- virtual opvp_result_t SetLineStyle(opvp_linestyle_t linestyle);
- virtual opvp_result_t GetLineStyle(opvp_linestyle_t *plinestyle);
- virtual opvp_result_t SetLineCap(opvp_linecap_t linecap);
- virtual opvp_result_t GetLineCap(opvp_linecap_t *plinecap);
- virtual opvp_result_t SetLineJoin(opvp_linejoin_t linejoin);
- virtual opvp_result_t GetLineJoin(opvp_linejoin_t *plinejoin);
- virtual opvp_result_t SetMiterLimit(opvp_fix_t miterlimit);
- virtual opvp_result_t GetMiterLimit(opvp_fix_t *pmiterlimit);
- virtual opvp_result_t SetPaintMode(opvp_paintmode_t paintmode);
- virtual opvp_result_t GetPaintMode(opvp_paintmode_t *ppaintmode);
- virtual opvp_result_t SetStrokeColor(const opvp_brush_t *brush);
- virtual opvp_result_t SetFillColor(const opvp_brush_t *brush);
- virtual opvp_result_t SetBgColor(const opvp_brush_t *brush);
- virtual opvp_result_t NewPath();
- virtual opvp_result_t EndPath();
- virtual opvp_result_t StrokePath();
- virtual opvp_result_t FillPath();
- virtual opvp_result_t StrokeFillPath();
- virtual opvp_result_t SetClipPath(opvp_cliprule_t clipRule);
- virtual opvp_result_t SetCurrentPoint(opvp_fix_t x, opvp_fix_t y);
- virtual opvp_result_t LinePath(opvp_pathmode_t flag,
- opvp_int_t npoints, const opvp_point_t *points);
- virtual opvp_result_t PolygonPath(opvp_int_t npolygons,
- const opvp_int_t *nvertexes, const opvp_point_t *points);
- virtual opvp_result_t RectanglePath(opvp_int_t nrectangles,
- const opvp_rectangle_t *reclangles);
- virtual opvp_result_t RoundRectanglePath(opvp_int_t nrectangles,
- const opvp_roundrectangle_t *reclangles);
- virtual opvp_result_t BezierPath(opvp_int_t npoints,
- const opvp_point_t *points);
- virtual opvp_result_t ArcPath(opvp_arcmode_t kind,
- opvp_arcdir_t dir, opvp_fix_t bbx0, opvp_fix_t bby0,
- opvp_fix_t bbx1, opvp_fix_t bby1, opvp_fix_t x0,
- opvp_fix_t y0, opvp_fix_t x1, opvp_fix_t y1);
- virtual opvp_result_t DrawImage(opvp_int_t sourceWidth,
- opvp_int_t sourceHeight, opvp_int_t sourcePitch,
- opvp_imageformat_t imageFormat,
- opvp_int_t destinationWidth, opvp_int_t destinationHeight,
- const void *imageData);
- virtual opvp_result_t StartDrawImage(opvp_int_t sourceWidth,
- opvp_int_t sourceHeight, opvp_int_t sourcePitch,
- opvp_imageformat_t imageFormat,
- opvp_int_t destinationWidth, opvp_int_t destinationHeight);
- virtual opvp_result_t TransferDrawImage(opvp_int_t count,
- const void *imageData);
- virtual opvp_result_t EndDrawImage();
- virtual opvp_result_t StartScanline(opvp_int_t yposition);
- virtual opvp_result_t Scanline(opvp_int_t nscanpairs,
- const opvp_int_t *scanpairs);
- virtual opvp_result_t EndScanline();
- virtual opvp_result_t StartRaster(opvp_int_t rasterWidth);
- virtual opvp_result_t TransferRasterData(opvp_int_t count,
- const opvp_byte_t *data);
- virtual opvp_result_t SkipRaster(opvp_int_t count);
- virtual opvp_result_t EndRaster();
- virtual opvp_result_t StartStream();
- virtual opvp_result_t TransferStreamData(opvp_int_t count,
- const void *data);
- virtual opvp_result_t EndStream();
- virtual opvp_result_t ResetClipPath();
-
-private:
- OPVP_api_procs *procs_0_2;
- int *opvpErrorNo_0_2;
- int printerContext_0_2;
- opvp_cspace_t colorSpace;
-};
-
-#endif
diff --git a/filter/pdftoopvp/opvp/opvp.h b/filter/pdftoopvp/opvp/opvp.h
deleted file mode 100644
index 41ade3aa7..000000000
--- a/filter/pdftoopvp/opvp/opvp.h
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * OpenPrinting Vector Printer Driver API Definitions [opvp.h]
- *
- * Copyright (c) 2006 Free Standards Group
- * Copyright (c) 2006 Fuji Xerox Printing Systems Co., Ltd.
- * Copyright (c) 2006 Canon Inc.
- * Copyright (c) 2003-2006 AXE Inc.
- *
- * All Rights Reserverd.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation.
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
- /*
- 2007 Modified for OPVP 1.0 by BBR Inc.
- */
-
-#ifndef _OPVP_H_
-#define _OPVP_H_
-
-/* Return Values and Error Codes */
-#define OPVP_OK 0 /* -1 for errors */
-#define OPVP_FATALERROR -1 /* error: cannot be recovered */
-#define OPVP_BADREQUEST -2 /* error: called where it should
- not be called */
-#define OPVP_BADCONTEXT -3 /* error: invalid printer context */
-#define OPVP_NOTSUPPORTED -4 /* error: combination of
- parameters are set
- which cannot be handled
- by driver or printer */
-#define OPVP_JOBCANCELED -5 /* error: job has been canceled
- by some cause */
-#define OPVP_PARAMERROR -6 /* error: invalid parameter */
-#define OPVP_VERSIONERROR -7 /* error: invalid API version */
-
-/* Basic Types */
-typedef int opvp_dc_t; /* driver/device context */
-typedef int opvp_result_t; /* return value */
-typedef unsigned char opvp_byte_t; /* BYTE */
-typedef unsigned char opvp_char_t; /* character (string) */
-typedef int opvp_int_t; /* integer */
-typedef int opvp_fix_t; /* fixed integer */
-typedef float opvp_float_t; /* float */
-typedef unsigned int opvp_flag_t; /* flags */
-typedef unsigned int opvp_rop_t; /* raster operation */
-
-/* for opvp_fix_t */
-#define OPVP_FIX_FRACT_WIDTH 8
-#define OPVP_FIX_FRACT_DENOM (1<<OPVP_FIX_FRACT_WIDTH)
-#define OPVP_FIX_FLOOR_WIDTH (sizeof(int)*8-OPVP_FIX_FRACT_WIDTH)
-
-/* convert macro */
-#define OPVP_I2FIX(i,fix) (fix=(i)<<OPVP_FIX_FRACT_WIDTH)
-#define OPVP_F2FIX(f,fix) (fix=((int)floor(f)<<OPVP_FIX_FRACT_WIDTH)\
- |((int)((f-floor(f))*OPVP_FIX_FRACT_DENOM)\
- &(OPVP_FIX_FRACT_DENOM-1)))
-
-/* graphic elements */
-typedef struct _opvp_point {
- opvp_fix_t x, y;
-} opvp_point_t;
-
-typedef struct _opvp_rectangle {
- opvp_point_t p0; /* start point */
- opvp_point_t p1; /* diagonal point */
-} opvp_rectangle_t;
-
-typedef struct _opvp_roundrectangle {
- opvp_point_t p0; /* start point */
- opvp_point_t p1; /* diagonal point */
- opvp_fix_t xellipse, yellipse;
-} opvp_roundrectangle_t;
-
-/* Image Formats */
-typedef enum _opvp_imageformat {
- OPVP_IFORMAT_RAW = 0,
- OPVP_IFORMAT_MASK = 1,
- OPVP_IFORMAT_RLE = 2,
- OPVP_IFORMAT_JPEG = 3,
- OPVP_IFORMAT_PNG = 4
-} opvp_imageformat_t;
-
-/* Color Presentation */
-typedef enum _opvp_colormapping {
- OPVP_CMAP_DIRECT = 0,
- OPVP_CMAP_INDEXED = 1
-} opvp_colormapping_t;
-
-typedef enum _opvp_cspace {
- OPVP_CSPACE_BW = 0,
- OPVP_CSPACE_DEVICEGRAY = 1,
- OPVP_CSPACE_DEVICECMY = 2,
- OPVP_CSPACE_DEVICECMYK = 3,
- OPVP_CSPACE_DEVICERGB = 4,
- OPVP_CSPACE_DEVICEKRGB = 5,
- OPVP_CSPACE_STANDARDRGB = 6,
- OPVP_CSPACE_STANDARDRGB64 = 7
-} opvp_cspace_t;
-
-/* Fill, Paint, Clip */
-typedef enum _opvp_fillmode {
- OPVP_FILLMODE_EVENODD = 0,
- OPVP_FILLMODE_WINDING = 1
-} opvp_fillmode_t;
-
-typedef enum _opvp_paintmode {
- OPVP_PAINTMODE_OPAQUE = 0,
- OPVP_PAINTMODE_TRANSPARENT = 1
-} opvp_paintmode_t;
-
-typedef enum _opvp_cliprule {
- OPVP_CLIPRULE_EVENODD = 0,
- OPVP_CLIPRULE_WINDING = 1
-} opvp_cliprule_t;
-
-/* Line */
-typedef enum _opvp_linestyle {
- OPVP_LINESTYLE_SOLID = 0,
- OPVP_LINESTYLE_DASH = 1
-} opvp_linestyle_t;
-
-typedef enum _opvp_linecap {
- OPVP_LINECAP_BUTT = 0,
- OPVP_LINECAP_ROUND = 1,
- OPVP_LINECAP_SQUARE = 2
-} opvp_linecap_t;
-
-typedef enum _opvp_linejoin {
- OPVP_LINEJOIN_MITER = 0,
- OPVP_LINEJOIN_ROUND = 1,
- OPVP_LINEJOIN_BEVEL = 2
-} opvp_linejoin_t;
-
-/* Brush */
-typedef enum _opvp_bdtype {
- OPVP_BDTYPE_NORMAL = 0
-} opvp_bdtype_t;
-
-typedef struct _opvp_brushdata {
- opvp_bdtype_t type;
- opvp_int_t width, height, pitch;
- opvp_byte_t data[1];
-
-} opvp_brushdata_t;
-
-typedef struct _opvp_brush {
- opvp_cspace_t colorSpace;
- opvp_int_t color[4]; /* aRGB quadruplet */
- opvp_int_t xorg, yorg; /* brush origin */
- /* ignored for opvpSetBgColor */
- opvp_brushdata_t *pbrush; /* pointer to brush data */
- /* solid brush used, if NULL */
-} opvp_brush_t;
-
-/* Misc. Flags */
-typedef enum _opvp_arcmode {
- OPVP_ARC = 0,
- OPVP_CHORD = 1,
- OPVP_PIE = 2
-} opvp_arcmode_t;
-
-typedef enum _opvp_arcdir {
- OPVP_CLOCKWISE = 0,
- OPVP_COUNTERCLOCKWISE = 1
-} opvp_arcdir_t;
-
-typedef enum _opvp_pathmode {
- OPVP_PATHCLOSE = 0,
- OPVP_PATHOPEN = 1
-} opvp_pathmode_t;
-
-/* CTM */
-typedef struct _opvp_ctm {
- opvp_float_t a, b, c, d, e, f;
-} opvp_ctm_t;
-
-/* Device Information and Capabilites */
-typedef enum _opvp_queryinfoflags {
- OPVP_QF_DEVICERESOLUTION = 0x00000001,
- OPVP_QF_MEDIASIZE = 0x00000002,
- OPVP_QF_PAGEROTATION = 0x00000004,
- OPVP_QF_MEDIANUP = 0x00000008,
- OPVP_QF_MEDIADUPLEX = 0x00000010,
- OPVP_QF_MEDIASOURCE = 0x00000020,
- OPVP_QF_MEDIADESTINATION = 0x00000040,
- OPVP_QF_MEDIATYPE = 0x00000080,
- OPVP_QF_MEDIACOPY = 0x00000100, /* Maximum copy number
- supported */
- OPVP_QF_PRINTREGION = 0x00010000 /* only for opvpQueryDeviceInfo */
-} opvp_queryinfoflags_t;
-
-
-/* API Procedure Entries */
-typedef struct _opvp_api_procs {
- opvp_dc_t (*opvpOpenPrinter)(opvp_int_t,const opvp_char_t*,const opvp_int_t[2],struct _opvp_api_procs**);
- opvp_result_t (*opvpClosePrinter)(opvp_dc_t);
- opvp_result_t (*opvpStartJob)(opvp_dc_t,const opvp_char_t*);
- opvp_result_t (*opvpEndJob)(opvp_dc_t);
- opvp_result_t (*opvpAbortJob)(opvp_dc_t);
- opvp_result_t (*opvpStartDoc)(opvp_dc_t,const opvp_char_t*);
- opvp_result_t (*opvpEndDoc)(opvp_dc_t);
- opvp_result_t (*opvpStartPage)(opvp_dc_t,const opvp_char_t*);
- opvp_result_t (*opvpEndPage)(opvp_dc_t);
- opvp_result_t (*opvpQueryDeviceCapability)(opvp_dc_t,opvp_flag_t,opvp_int_t*,opvp_byte_t*);
- opvp_result_t (*opvpQueryDeviceInfo)(opvp_dc_t,opvp_flag_t,opvp_int_t*,opvp_char_t*);
- opvp_result_t (*opvpResetCTM)(opvp_dc_t);
- opvp_result_t (*opvpSetCTM)(opvp_dc_t,const opvp_ctm_t*);
- opvp_result_t (*opvpGetCTM)(opvp_dc_t,opvp_ctm_t*);
- opvp_result_t (*opvpInitGS)(opvp_dc_t);
- opvp_result_t (*opvpSaveGS)(opvp_dc_t);
- opvp_result_t (*opvpRestoreGS)(opvp_dc_t);
- opvp_result_t (*opvpQueryColorSpace)(opvp_dc_t,opvp_int_t*,opvp_cspace_t*);
- opvp_result_t (*opvpSetColorSpace)(opvp_dc_t,opvp_cspace_t);
- opvp_result_t (*opvpGetColorSpace)(opvp_dc_t,opvp_cspace_t*);
- opvp_result_t (*opvpSetFillMode)(opvp_dc_t,opvp_fillmode_t);
- opvp_result_t (*opvpGetFillMode)(opvp_dc_t,opvp_fillmode_t*);
- opvp_result_t (*opvpSetAlphaConstant)(opvp_dc_t,opvp_float_t);
- opvp_result_t (*opvpGetAlphaConstant)(opvp_dc_t,opvp_float_t*);
- opvp_result_t (*opvpSetLineWidth)(opvp_dc_t,opvp_fix_t);
- opvp_result_t (*opvpGetLineWidth)(opvp_dc_t,opvp_fix_t*);
- opvp_result_t (*opvpSetLineDash)(opvp_dc_t,opvp_int_t,const opvp_fix_t*);
- opvp_result_t (*opvpGetLineDash)(opvp_dc_t,opvp_int_t*,opvp_fix_t*);
- opvp_result_t (*opvpSetLineDashOffset)(opvp_dc_t,opvp_fix_t);
- opvp_result_t (*opvpGetLineDashOffset)(opvp_dc_t,opvp_fix_t*);
- opvp_result_t (*opvpSetLineStyle)(opvp_dc_t,opvp_linestyle_t);
- opvp_result_t (*opvpGetLineStyle)(opvp_dc_t,opvp_linestyle_t*);
- opvp_result_t (*opvpSetLineCap)(opvp_dc_t,opvp_linecap_t);
- opvp_result_t (*opvpGetLineCap)(opvp_dc_t,opvp_linecap_t*);
- opvp_result_t (*opvpSetLineJoin)(opvp_dc_t,opvp_linejoin_t);
- opvp_result_t (*opvpGetLineJoin)(opvp_dc_t,opvp_linejoin_t*);
- opvp_result_t (*opvpSetMiterLimit)(opvp_dc_t,opvp_fix_t);
- opvp_result_t (*opvpGetMiterLimit)(opvp_dc_t,opvp_fix_t*);
- opvp_result_t (*opvpSetPaintMode)(opvp_dc_t,opvp_paintmode_t);
- opvp_result_t (*opvpGetPaintMode)(opvp_dc_t,opvp_paintmode_t*);
- opvp_result_t (*opvpSetStrokeColor)(opvp_dc_t,const opvp_brush_t*);
- opvp_result_t (*opvpSetFillColor)(opvp_dc_t,const opvp_brush_t*);
- opvp_result_t (*opvpSetBgColor)(opvp_dc_t,const opvp_brush_t*);
- opvp_result_t (*opvpNewPath)(opvp_dc_t);
- opvp_result_t (*opvpEndPath)(opvp_dc_t);
- opvp_result_t (*opvpStrokePath)(opvp_dc_t);
- opvp_result_t (*opvpFillPath)(opvp_dc_t);
- opvp_result_t (*opvpStrokeFillPath)(opvp_dc_t);
- opvp_result_t (*opvpSetClipPath)(opvp_dc_t,opvp_cliprule_t);
- opvp_result_t (*opvpResetClipPath)(opvp_dc_t);
- opvp_result_t (*opvpSetCurrentPoint)(opvp_dc_t,opvp_fix_t,opvp_fix_t);
- opvp_result_t (*opvpLinePath)(opvp_dc_t,opvp_pathmode_t,opvp_int_t,const opvp_point_t*);
- opvp_result_t (*opvpPolygonPath)(opvp_dc_t,opvp_int_t,const opvp_int_t*,const opvp_point_t*);
- opvp_result_t (*opvpRectanglePath)(opvp_dc_t,opvp_int_t,const opvp_rectangle_t*);
- opvp_result_t (*opvpRoundRectanglePath)(opvp_dc_t,opvp_int_t,const opvp_roundrectangle_t*);
- opvp_result_t (*opvpBezierPath)(opvp_dc_t,opvp_int_t,const opvp_point_t*);
- opvp_result_t (*opvpArcPath)(opvp_dc_t,opvp_arcmode_t,opvp_arcdir_t,opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t,opvp_fix_t);
- opvp_result_t (*opvpDrawImage)(opvp_dc_t,opvp_int_t,opvp_int_t,opvp_int_t,opvp_imageformat_t,opvp_int_t, opvp_int_t ,const void*);
- opvp_result_t (*opvpStartDrawImage)(opvp_dc_t,opvp_int_t,opvp_int_t,opvp_int_t,opvp_imageformat_t,opvp_int_t, opvp_int_t);
- opvp_result_t (*opvpTransferDrawImage)(opvp_dc_t,opvp_int_t,const void*);
- opvp_result_t (*opvpEndDrawImage)(opvp_dc_t);
- opvp_result_t (*opvpStartScanline)(opvp_dc_t,opvp_int_t);
- opvp_result_t (*opvpScanline)(opvp_dc_t,opvp_int_t,const opvp_int_t*);
- opvp_result_t (*opvpEndScanline)(opvp_dc_t);
- opvp_result_t (*opvpStartRaster)(opvp_dc_t,opvp_int_t);
- opvp_result_t (*opvpTransferRasterData)(opvp_dc_t,opvp_int_t,const opvp_byte_t*);
- opvp_result_t (*opvpSkipRaster)(opvp_dc_t,opvp_int_t);
- opvp_result_t (*opvpEndRaster)(opvp_dc_t);
- opvp_result_t (*opvpStartStream)(opvp_dc_t);
- opvp_result_t (*opvpTransferStreamData)(opvp_dc_t,opvp_int_t,const void*);
- opvp_result_t (*opvpEndStream)(opvp_dc_t);
-} opvp_api_procs_t;
-
-/* Function prototype */
-opvp_dc_t opvpOpenPrinter(
- opvp_int_t outputFD,
- const opvp_char_t *printerModel,
- const opvp_int_t apiVersion[2],
- opvp_api_procs_t **apiProcs);
-
-/* error no */
-extern opvp_int_t opvpErrorNo;
-
-#endif /* _OPVP_H_ */
diff --git a/filter/pdftoopvp/opvp/opvp_0_2_0.h b/filter/pdftoopvp/opvp/opvp_0_2_0.h
deleted file mode 100644
index 2b2c4aaf3..000000000
--- a/filter/pdftoopvp/opvp/opvp_0_2_0.h
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
-
-Copyright (c) 2003-2004, AXE, Inc. All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-/* opvp_common.h ver.1.00 rel.1.0 26 Nov 2004 */
-/* OpenPrinting Vector Printer Driver Glue Code */
-
-#ifndef _FSGPD_0_2_0_H
-#define _FSGPD_0_2_0_H
-
-#define _PDAPI_VERSION_MAJOR_ 0
-#define _PDAPI_VERSION_MINOR_ 2
-
-/* Return Values */
-#define OPVP_OK 0 /* error is -1 */
-
-/* Error Codes */
-#define OPVP_FATALERROR -101 /* unrecoverable error occurred within the */
- /* library */
-#define OPVP_BADREQUEST -102 /* invalid function parameters */
-#define OPVP_BADCONTEXT -103 /* bad parameter precontext */
-#define OPVP_NOTSUPPORTED -104 /* printer or driver request not supported */
-#define OPVP_JOBCANCELED -105 /* job cancelled */
-#define OPVP_PARAMERROR -106 /* illegal parameter combination */
-
-/* Info params */
-#define OPVP_INFO_PREFIX "updf:"
-
-/* Fix */
-#define OPVP_FIX_FRACT_WIDTH 8
-#define OPVP_FIX_FRACT_DENOM (1<<OPVP_FIX_FRACT_WIDTH)
-#define OPVP_FIX_FLOOR_WIDTH (sizeof(int)*8-OPVP_FIX_FRACT_WIDTH)
-#if 0
-typedef struct {
- unsigned int fract : OPVP_FIX_FRACT_WIDTH;
- signed int floor : OPVP_FIX_FLOOR_WIDTH;
-} OPVP_Fix;
-#define OPVP_i2Fix(i,fix) (fix.fract=0,fix.floor=i)
-#define OPVP_Fix2f(fix,f) (f=(double)fix.floor\
- +(double)(fix.fract)/OPVP_FIX_FRACT_DENOM)
-#define OPVP_f2Fix(f,fix) (fix.fract=(f-floor(f))*OPVP_FIX_FRACT_DENOM,\
- fix.floor=floor(f))
-#else
-typedef int OPVP_Fix;
-#define OPVP_i2Fix(i,fix) (fix=(i)<<8)
-#define OPVP_f2Fix(f,fix) (fix=((int)floor(f)<<8)\
- |((int)(((f)-floor(f))*OPVP_FIX_FRACT_DENOM)\
- &0x000000ff))
-#endif
-
-/* Basic Types */
-typedef struct _OPVP_Point {
- OPVP_Fix x;
- OPVP_Fix y;
-} OPVP_Point;
-
-typedef struct _OPVP_Rectangle {
- OPVP_Point p0; /* start point */
- OPVP_Point p1; /* end point */
-} OPVP_Rectangle;
-
-typedef struct _OPVP_RoundRectangle {
- OPVP_Point p0; /* start point */
- OPVP_Point p1; /* end point */
- OPVP_Fix xellipse;
- OPVP_Fix yellipse;
-} OPVP_RoundRectangle;
-
-/* Image Formats */
-typedef enum _OPVP_ImageFormat {
- OPVP_iformatRaw = 0,
- OPVP_iformatRLE = 1,
- OPVP_iformatJPEG = 2,
- OPVP_iformatPNG = 3
-} OPVP_ImageFormat;
-
-/* Color Presentation */
-typedef enum _OPVP_ColorMapping {
- OPVP_cmapDirect = 0,
- OPVP_cmapIndexed = 1
-} OPVP_ColorMapping;
-
-typedef enum _OPVP_ColorSpace {
- OPVP_cspaceBW = 0,
- OPVP_cspaceDeviceGray = 1,
- OPVP_cspaceDeviceCMY = 2,
- OPVP_cspaceDeviceCMYK = 3,
- OPVP_cspaceDeviceRGB = 4,
- OPVP_cspaceStandardRGB = 5,
- OPVP_cspaceStandardRGB64 = 6
-} OPVP_ColorSpace;
-
-/* Raster Operation modes */
-typedef enum _OPVP_ROP {
- OPVP_ropPset = 0,
- OPVP_ropPreset = 1,
- OPVP_ropOr = 2,
- OPVP_ropAnd = 3,
- OPVP_ropXor = 4
-} OPVP_ROP;
-
-/* Fill, Paint, Clip */
-typedef enum _OPVP_FillMode {
- OPVP_fillModeEvenOdd = 0,
- OPVP_fillModeWinding = 1
-} OPVP_FillMode;
-
-typedef enum _OPVP_PaintMode {
- OPVP_paintModeOpaque = 0,
- OPVP_paintModeTransparent = 1
-} OPVP_PaintMode;
-
-typedef enum _OPVP_ClipRule {
- OPVP_clipRuleEvenOdd = 0,
- OPVP_clipRuleWinding = 1
-} OPVP_ClipRule;
-
-/* Line */
-typedef enum _OPVP_LineStyle {
- OPVP_lineStyleSolid = 0,
- OPVP_lineStyleDash = 1
-} OPVP_LineStyle;
-
-typedef enum _OPVP_LineCap {
- OPVP_lineCapButt = 0,
- OPVP_lineCapRound = 1,
- OPVP_lineCapSquare = 2
-} OPVP_LineCap;
-
-typedef enum _OPVP_LineJoin {
- OPVP_lineJoinMiter = 0,
- OPVP_lineJoinRound = 1,
- OPVP_lineJoinBevel = 2
-} OPVP_LineJoin;
-
-/* Brush */
-typedef enum _OPVP_BrushDataType {
- OPVP_bdtypeNormal = 0
-} OPVP_BrushDataType;
-
-typedef struct _OPVP_BrushData {
- OPVP_BrushDataType type;
- int width;
- int height;
- int pitch;
-#if (_PDAPI_VERSION_MAJOR_ == 0 && _PDAPI_VERSION_MINOR_ < 2)
- void *data; /* pointer to actual data */
-#else
- char data[1];
-#endif
-} OPVP_BrushData;
-
-typedef struct _OPVP_Brush {
- OPVP_ColorSpace colorSpace;
- int color[4]; /* aRGB quadruplet */
-#if (_PDAPI_VERSION_MAJOR_ == 0 && _PDAPI_VERSION_MINOR_ < 2)
- OPVP_BrushData *pbrush; /* pointer to brush data */
- /* solid brush used, if null */
- int xorg; /* brush origin */
- int yorg; /* ignored for SetBgColor */
-#else
- int xorg; /* brush origin */
- int yorg; /* ignored for SetBgColor */
- OPVP_BrushData *pbrush; /* pointer to brush data */
- /* solid brush used, if null */
-#endif
-} OPVP_Brush;
-
-/* Misc. Flags */
-#define OPVP_Arc 0 /* circular arc */
-#define OPVP_Chord 1 /* arch */
-#define OPVP_Pie 2 /* pie section */
-#define OPVP_Clockwise 0 /* clockwise */
-#define OPVP_Counterclockwise 1 /* counter-clockwise */
-#define OPVP_PathClose 0 /* Close path when using LinePath */
-#define OPVP_PathOpen 1 /* Do not close path when using LinePath */
-
-/* CTM */
-typedef struct _OPVP_CTM {
- float a;
- float b;
- float c;
- float d;
- float e;
- float f;
-} OPVP_CTM;
-
-/* Vector Driver API Proc. Entries */
-typedef struct _OPVP_api_procs {
- int (*OpenPrinter)(int,char *,int *,struct _OPVP_api_procs **);
- int (*ClosePrinter)(int);
- int (*StartJob)(int,char *);
- int (*EndJob)(int);
- int (*StartDoc)(int,char *);
- int (*EndDoc)(int);
- int (*StartPage)(int,char *);
- int (*EndPage)(int);
-#if (_PDAPI_VERSION_MAJOR_ > 0 || _PDAPI_VERSION_MINOR_ >= 2)
- int (*QueryDeviceCapability)(int,int,int,char *);
- int (*QueryDeviceInfo)(int,int,int,char *);
-#endif
- int (*ResetCTM)(int);
- int (*SetCTM)(int,OPVP_CTM *);
- int (*GetCTM)(int,OPVP_CTM *);
- int (*InitGS)(int);
- int (*SaveGS)(int);
- int (*RestoreGS)(int);
- int (*QueryColorSpace)(int,OPVP_ColorSpace *,int *);
- int (*SetColorSpace)(int,OPVP_ColorSpace);
- int (*GetColorSpace)(int,OPVP_ColorSpace *);
- int (*QueryROP)(int,int *,int *);
- int (*SetROP)(int,int);
- int (*GetROP)(int,int *);
- int (*SetFillMode)(int,OPVP_FillMode);
- int (*GetFillMode)(int,OPVP_FillMode *);
- int (*SetAlphaConstant)(int,float);
- int (*GetAlphaConstant)(int,float *);
- int (*SetLineWidth)(int,OPVP_Fix);
- int (*GetLineWidth)(int,OPVP_Fix *);
- int (*SetLineDash)(int,OPVP_Fix *,int);
- int (*GetLineDash)(int,OPVP_Fix *,int *);
- int (*SetLineDashOffset)(int,OPVP_Fix);
- int (*GetLineDashOffset)(int,OPVP_Fix *);
- int (*SetLineStyle)(int,OPVP_LineStyle);
- int (*GetLineStyle)(int,OPVP_LineStyle *);
- int (*SetLineCap)(int,OPVP_LineCap);
- int (*GetLineCap)(int,OPVP_LineCap *);
- int (*SetLineJoin)(int,OPVP_LineJoin);
- int (*GetLineJoin)(int,OPVP_LineJoin *);
- int (*SetMiterLimit)(int,OPVP_Fix);
- int (*GetMiterLimit)(int,OPVP_Fix *);
- int (*SetPaintMode)(int,OPVP_PaintMode);
- int (*GetPaintMode)(int,OPVP_PaintMode *);
- int (*SetStrokeColor)(int,OPVP_Brush *);
- int (*SetFillColor)(int,OPVP_Brush *);
- int (*SetBgColor)(int,OPVP_Brush *);
- int (*NewPath)(int);
- int (*EndPath)(int);
- int (*StrokePath)(int);
- int (*FillPath)(int);
- int (*StrokeFillPath)(int);
- int (*SetClipPath)(int,OPVP_ClipRule);
-#if (_PDAPI_VERSION_MAJOR_ > 0 || _PDAPI_VERSION_MINOR_ >= 2)
- int (*ResetClipPath)(int);
-#endif
- int (*SetCurrentPoint)(int,OPVP_Fix,OPVP_Fix);
- int (*LinePath)(int,int,int,OPVP_Point *);
- int (*PolygonPath)(int,int,int *,OPVP_Point *);
- int (*RectanglePath)(int,int,OPVP_Rectangle *);
- int (*RoundRectanglePath)(int,int,OPVP_RoundRectangle *);
-#if (_PDAPI_VERSION_MAJOR_ == 0 && _PDAPI_VERSION_MINOR_ < 2)
- int (*BezierPath)(int,int *,OPVP_Point *);
-#else
- int (*BezierPath)(int,int,OPVP_Point *);
-#endif
- int (*ArcPath)(int,int,int,OPVP_Fix,OPVP_Fix,OPVP_Fix,OPVP_Fix,
- OPVP_Fix,OPVP_Fix,OPVP_Fix,OPVP_Fix);
- int (*DrawBitmapText)(int,int,int,int,void *);
- int (*DrawImage)(int,int,int,int,
- OPVP_ImageFormat,OPVP_Rectangle,int,void *);
- int (*StartDrawImage)(int,int,int,int,
- OPVP_ImageFormat,OPVP_Rectangle);
- int (*TransferDrawImage)(int,int,void *);
- int (*EndDrawImage)(int);
- int (*StartScanline)(int,int);
- int (*Scanline)(int,int,int *);
- int (*EndScanline)(int);
- int (*StartRaster)(int,int);
- int (*TransferRasterData)(int,int,unsigned char *);
- int (*SkipRaster)(int,int);
- int (*EndRaster)(int);
- int (*StartStream)(int);
- int (*TransferStreamData)(int,int,void *);
- int (*EndStream)(int);
-} OPVP_api_procs;
-
-#endif /* _OPVP_COMMON_H_ */
-
diff --git a/filter/pdftoopvp/opvp/opvp_common.h b/filter/pdftoopvp/opvp/opvp_common.h
deleted file mode 100644
index 5d65b3208..000000000
--- a/filter/pdftoopvp/opvp/opvp_common.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-
-Copyright (c) 2003-2004, AXE, Inc. All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-*/
-/* OpenPrinting Vector Printer Driver Glue Code */
-
-#ifndef _OPVP_COMMON_H_
-#define _OPVP_COMMON_H_
-
-#include "opvp_0_2_0.h"
-#undef _PDAPI_VERSION_MAJOR_
-#undef _PDAPI_VERSION_MINOR_
-/* undefine conflicted macros */
-#undef OPVP_INFO_PREFIX
-#undef OPVP_OK
-#undef OPVP_FATALERROR
-#undef OPVP_BADREQUEST
-#undef OPVP_BADCONTEXT
-#undef OPVP_NOTSUPPORTED
-#undef OPVP_JOBCANCELED
-#undef OPVP_PARAMERROR
-/* define 0_2 error no as different macros */
-#define OPVP_FATALERROR_0_2 -101
-#define OPVP_BADREQUEST_0_2 -102
-#define OPVP_BADCONTEXT_0_2 -103
-#define OPVP_NOTSUPPORTED_0_2 -104
-#define OPVP_JOBCANCELED_0_2 -105
-#define OPVP_PARAMERROR_0_2 -106
-
-#include "opvp.h"
-#define OPVP_INFO_PREFIX ""
-
-#endif /* _OPVP_COMMON_H_ */
-
diff --git a/filter/pdftoopvp/pdftoopvp.cxx b/filter/pdftoopvp/pdftoopvp.cxx
deleted file mode 100644
index 867d4070c..000000000
--- a/filter/pdftoopvp/pdftoopvp.cxx
+++ /dev/null
@@ -1,797 +0,0 @@
-//========================================================================
-//
-// pdftoopvp.cc
-//
-// Copyright 2005 AXE,Inc.
-//
-// 2007,2008,2009 Modified by BBR Inc.
-//========================================================================
-
-#include <config.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <math.h>
-#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
-#endif
-#include "goo/GooString.h"
-#define GSTRING_H // for old GooString.h
-#include "goo/gmem.h"
-#include "GlobalParams.h"
-#include "Object.h"
-#include "PDFDoc.h"
-#include "splash/SplashBitmap.h"
-#include "OPRS.h"
-#include "OPVPOutputDev.h"
-#include "Gfx.h"
-#include <cups/cups.h>
-#include <cups/ppd.h>
-#include "OPVPError.h"
-
-#define MMPERINCH (25.4)
-
-static int resolution = 300;
-static int hResolution = 0;
-static int vResolution = 0;
-static bool mono = false;
-static bool reverse = false;
-static bool gray = false;
-static char enableFreeTypeStr[16] = "";
-static bool quiet = false;
-static char outputOrderStr[256] = "";
-static bool oldLipsDriver = false;
-static bool HPDriver = false;
-static bool NECDriver = false;
-static bool clipPathNotSaved = false;
-static bool noShearImage = false;
-static bool noLineStyle = false;
-static bool noImageMask = false;
-static bool noClipPath = false;
-static bool ignoreMiterLimit = false;
-static bool noMiterLimit = false;
-static char printerDriver[1024] = "";
-static char printerModel[1024] = "";
-static char jobInfo[4096] = "";
-static char docInfo[1024] = "";
-static char pageInfo[1024] = "";
-static bool noBitmapChar = false;
-static char bitmapCharThreshold[20] = "2000";
-static char maxClipPathLength[20] = "2000";
-static char maxFillPathLength[20] = "4000";
-static int pageWidth = -1;
-static int pageHeight = -1;
-
-static int outOnePage(PDFDoc *doc, OPVPOutputDev *opvpOut, int pg)
-{
- char buf[1024];
- char *p;
- double pw = doc->getPageMediaWidth(pg);
- double ph = doc->getPageMediaHeight(pg);
- int paperWidth;
- int paperHeight;
-
- if (pw != pageWidth || ph != pageHeight) {
- if (pageInfo[0] != '\0') {
- snprintf(buf,sizeof(buf),"%s;MediaSize=%dx%dmm",pageInfo,
- (int)(pw*MMPERINCH/72),
- (int)(ph*MMPERINCH/72));
- } else {
- snprintf(buf,sizeof(buf),"MediaSize=%dx%dmm",
- (int)(pw*MMPERINCH/72),
- (int)(ph*MMPERINCH/72));
- }
- p = buf;
- } else {
- pw = pageWidth;
- ph = pageHeight;
- p = pageInfo;
- }
-
- paperWidth = (int)(pw*hResolution/72+0.5);
- paperHeight = (int)(ph*vResolution/72+0.5);
- if (opvpOut->OPVPStartPage(p,paperWidth,paperHeight) < 0) {
- opvpError(-1,"Start Page failed");
- return 2;
- }
- opvpOut->setScale(1.0,1.0,0,0,0,0,paperHeight);
- doc->displayPage(opvpOut, pg, resolution, resolution,
- 0, true, true, false);
- if (opvpOut->outSlice() < 0) {
- opvpError(-1,"OutSlice failed");
- return 2;
- }
- if (opvpOut->OPVPEndPage() < 0) {
- opvpError(-1,"End Page failed");
- return 2;
- }
- return 0;
-}
-
-#define MAX_OPVP_OPTIONS 20
-
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 23
-void CDECL myErrorFun(void *data, ErrorCategory category,
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 70
- Goffset pos, const char *msg)
-#else
- Goffset pos, char *msg)
-#endif /* MAJOR > 0 || MINOR >= 70 */
-#else
-void CDECL myErrorFun(void *data, ErrorCategory category,
- int pos, char *msg)
-#endif
-{
- if (pos >= 0) {
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 23
- fprintf(stderr, "ERROR (%lld): ", pos);
-#else
- fprintf(stderr, "ERROR (%d): ", pos);
-#endif
- } else {
- fprintf(stderr, "ERROR: ");
- }
- fprintf(stderr, "%s\n",msg);
- fflush(stderr);
-}
-#else
-void CDECL myErrorFun(int pos, char *msg, va_list args)
-{
- if (pos >= 0) {
- fprintf(stderr, "ERROR (%d): ", pos);
- } else {
- fprintf(stderr, "ERROR: ");
- }
- vfprintf(stderr, msg, args);
- fprintf(stderr, "\n");
- fflush(stderr);
-}
-#endif
-
-static bool getColorProfilePath(ppd_file_t *ppd, GooString *path)
-{
- // get color profile path
- const char *colorModel;
- const char *cupsICCQualifier2;
- const char *cupsICCQualifier2Choice;
- const char *cupsICCQualifier3;
- const char *cupsICCQualifier3Choice;
- ppd_attr_t *attr;
- ppd_choice_t *choice;
- const char *datadir;
-
- if ((attr = ppdFindAttr(ppd,"ColorModel",NULL)) != NULL) {
- colorModel = attr->value;
- } else {
- colorModel = NULL;
- }
- if ((attr = ppdFindAttr(ppd,"cupsICCQualifier2",NULL)) != NULL) {
- cupsICCQualifier2 = attr->value;
- } else {
- cupsICCQualifier2 = "MediaType";
- }
- if ((choice = ppdFindMarkedChoice(ppd,cupsICCQualifier2)) != NULL) {
- cupsICCQualifier2Choice = choice->choice;
- } else {
- cupsICCQualifier2Choice = NULL;
- }
- if ((attr = ppdFindAttr(ppd,"cupsICCQualifier3",NULL)) != NULL) {
- cupsICCQualifier3 = attr->value;
- } else {
- cupsICCQualifier3 = "Resolution";
- }
- if ((choice = ppdFindMarkedChoice(ppd,cupsICCQualifier3)) != NULL) {
- cupsICCQualifier3Choice = choice->choice;
- } else {
- cupsICCQualifier3Choice = NULL;
- }
-
- for (attr = ppdFindAttr(ppd,"cupsICCProfile",NULL);attr != NULL;
- attr = ppdFindNextAttr(ppd,"cupsICCProfile",NULL)) {
- // check color model
- char buf[PPD_MAX_NAME];
- char *p, *r;
-
- strncpy(buf,attr->spec,sizeof(buf));
- if ((p = strchr(buf,'.')) != NULL) {
- *p = '\0';
- }
- if (colorModel != NULL && buf[0] != '\0'
- && strcasecmp(buf,colorModel) != 0) continue;
- if (p == NULL) {
- break;
- } else {
- p++;
- if ((r = strchr(p,'.')) != 0) {
- *r = '\0';
- }
- }
- if (cupsICCQualifier2Choice != NULL && p[0] != '\0'
- && strcasecmp(p,cupsICCQualifier2Choice) != 0) continue;
- if (r == NULL) {
- break;
- } else {
- r++;
- if ((p = strchr(r,'.')) != 0) {
- *p = '\0';
- }
- }
- if (cupsICCQualifier3Choice == NULL || r[0] == '\0'
- || strcasecmp(r,cupsICCQualifier3Choice) == 0) break;
- }
- if (attr != NULL) {
- // matched
- path->clear();
- if (attr->value[0] != '/') {
- if ((datadir = getenv("CUPS_DATADIR")) == NULL)
- datadir = CUPS_DATADIR;
- path->append(datadir);
- path->append("/profiles/");
- }
- path->append(attr->value);
- return true;
- }
- return false;
-}
-
-int main(int argc, char *argv[]) {
-/* mtrace(); */
- int exitCode;
-{
- PDFDoc *doc;
- SplashColor paperColor;
- OPVPOutputDev *opvpOut;
- bool ok = true;
- int pg;
- const char *optionKeys[MAX_OPVP_OPTIONS];
- const char *optionVals[MAX_OPVP_OPTIONS];
- int nOptions = 0;
- int numPages;
- int i;
- GooString fileName;
- GooString colorProfilePath("opvp.icc");
-
- exitCode = 99;
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- setErrorCallback(::myErrorFun,NULL);
-#else
- setErrorFunction(::myErrorFun);
-#endif
-
- // parse args
- int num_options;
- cups_option_t *options;
- const char *val;
- char *ppdFileName;
- ppd_file_t *ppd = 0;
- ppd_attr_t *attr;
- GooString jobInfoStr;
- GooString docInfoStr;
- GooString pageInfoStr;
- bool colorProfile = false;
-
-
- if (argc < 6 || argc > 7) {
- opvpError(-1,"ERROR: %s job-id user title copies options [file]",
- argv[0]);
- return (1);
- }
-
- if ((ppdFileName = getenv("PPD")) != 0) {
- if ((ppd = ppdOpenFile(ppdFileName)) != 0) {
- /* get attributes from PPD File */
- if ((attr = ppdFindAttr(ppd,"opvpJobInfo",0)) != 0) {
- jobInfoStr.append(attr->value);
- }
- if ((attr = ppdFindAttr(ppd,"opvpDocInfo",0)) != 0) {
- docInfoStr.append(attr->value);
- }
- if ((attr = ppdFindAttr(ppd,"opvpPageInfo",0)) != 0) {
- pageInfoStr.append(attr->value);
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpOldLipsDriver",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- oldLipsDriver = true;
- } else {
- oldLipsDriver = false;
- }
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpHPDriver",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- HPDriver = true;
- } else {
- HPDriver = false;
- }
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpNECDriver",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- NECDriver = true;
- } else {
- NECDriver = false;
- }
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpClipPathNotSaved",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- clipPathNotSaved = true;
- } else {
- clipPathNotSaved = false;
- }
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpShearImage",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- noShearImage = false;
- } else {
- noShearImage = true;
- }
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpLineStyle",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- noLineStyle = false;
- } else {
- noLineStyle = true;
- }
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpImageMask",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- noImageMask = false;
- } else {
- noImageMask = true;
- }
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpClipPath",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- noClipPath = false;
- } else {
- noClipPath = true;
- }
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpMiterLimit",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- noMiterLimit = false;
- } else {
- noMiterLimit = true;
- }
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpIgnoreMiterLimit",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- ignoreMiterLimit = true;
- } else {
- ignoreMiterLimit = false;
- }
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpBitmapCharThreshold",0)) != 0) {
- strncpy(bitmapCharThreshold,attr->value,
- sizeof(bitmapCharThreshold)-1);
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpMaxClipPathLength",0)) != 0) {
- strncpy(maxClipPathLength,attr->value,
- sizeof(maxClipPathLength)-1);
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpMaxFillPathLength",0)) != 0) {
- strncpy(maxFillPathLength,attr->value,
- sizeof(maxFillPathLength)-1);
- }
- if ((attr = ppdFindAttr(ppd,"pdftoopvpBitmapChar",0)) != 0) {
- if (strcasecmp(attr->value,"true") == 0) {
- noBitmapChar = false;
- } else {
- noBitmapChar = true;
- }
- }
- if ((attr = ppdFindAttr(ppd,"opvpDriver",0)) != 0) {
- strncpy(printerDriver,attr->value,sizeof(printerDriver)-1);
- printerDriver[sizeof(printerDriver)-1] = '\0';
- }
- if ((attr = ppdFindAttr(ppd,"opvpModel",0)) != 0) {
- strncpy(printerModel,attr->value,sizeof(printerModel)-1);
- printerModel[sizeof(printerModel)-1] = '\0';
- }
- ppdMarkDefaults(ppd);
- }
- }
- /* get attributes and options from command line option */
- num_options = cupsParseOptions(argv[5],0,&options);
- cupsMarkOptions(ppd,num_options,options);
-
- for (i = 0;i < num_options;i++) {
- if (strcasecmp(options[i].name,"Resolution") == 0) {
- resolution = atoi(options[i].value);
- } else if (strcasecmp(options[i].name,"pdftoopvpOldLipsDriver") == 0) {
- oldLipsDriver = true;
- } else if (strcasecmp(options[i].name,"pdftoopvpHPDriver") == 0) {
- HPDriver = true;
- } else if (strcasecmp(options[i].name,"pdftoopvpNECDriver") == 0) {
- NECDriver = true;
- } else if (strcasecmp(options[i].name,"pdftoopvpClipPathNotSaved") == 0) {
- clipPathNotSaved = true;
- } else if (strcasecmp(options[i].name,"pdftoopvpShearImage") == 0) {
- if (strcasecmp(options[i].value,"false") == 0) {
- noShearImage = true;
- }
- } else if (strcasecmp(options[i].name,"pdftoopvpLineStyle") == 0) {
- if (strcasecmp(options[i].value,"false") == 0) {
- noLineStyle = true;
- }
- } else if (strcasecmp(options[i].name,"pdftoopvpImageMask") == 0) {
- if (strcasecmp(options[i].value,"false") == 0) {
- noImageMask = true;
- }
- } else if (strcasecmp(options[i].name,"pdftoopvpClipPath") == 0) {
- if (strcasecmp(options[i].value,"false") == 0) {
- noClipPath = true;
- }
- } else if (strcasecmp(options[i].name,"pdftoopvpMiterLimit") == 0) {
- if (strcasecmp(options[i].value,"false") == 0) {
- noMiterLimit = true;
- }
- } else if (strcasecmp(options[i].name,"pdftoopvpIgnoreMiterLimit") == 0) {
- if (strcasecmp(options[i].value,"true") == 0) {
- ignoreMiterLimit = true;
- }
- }
- else if (strcasecmp(options[i].name,"pdftoopvpBitmapChar") == 0) {
- if (strcasecmp(options[i].value,"false") == 0) {
- noBitmapChar = true;
- }
- } else if (strcasecmp(options[i].name,"pdftoopvpBitmapCharThreshold") == 0) {
- strncpy(bitmapCharThreshold,options[i].value,
- sizeof(bitmapCharThreshold)-1);
- } else if (strcasecmp(options[i].name,"pdftoopvpMaxClipPathLength") == 0) {
- strncpy(maxClipPathLength,options[i].value,
- sizeof(maxClipPathLength)-1);
- } else if (strcasecmp(options[i].name,"pdftoopvpMaxFillPathLength") == 0) {
- strncpy(maxFillPathLength,options[i].value,
- sizeof(maxFillPathLength)-1);
- } else if (strcasecmp(options[i].name,"opvpDriver") == 0) {
- strncpy(printerDriver,options[i].value,sizeof(printerDriver)-1);
- printerDriver[sizeof(printerDriver)-1] = '\0';
- } else if (strcasecmp(options[i].name,"opvpModel") == 0) {
- strncpy(printerModel,options[i].value,sizeof(printerModel)-1);
- printerModel[sizeof(printerModel)-1] = '\0';
- } else if (strcasecmp(options[i].name,"opvpJobInfo") == 0) {
- /* do nothing here */;
- } else if (strcasecmp(options[i].name,"opvpDocInfo") == 0) {
- /* do nothing here */;
- } else if (strcasecmp(options[i].name,"opvpPageInfo") == 0) {
- /* do nothing here */;
- }
- }
- if (ppd != 0) {
- int section;
- ppd_choice_t **choices;
- ppd_size_t *pagesize;
-
- if ((pagesize = ppdPageSize(ppd,0)) != 0) {
- pageWidth = (int)pagesize->width;
- pageHeight = (int)pagesize->length;
- }
- for (section = (int)PPD_ORDER_ANY;
- section <= (int)PPD_ORDER_PROLOG;section++) {
- int n;
-
- n = ppdCollect(ppd,(ppd_section_t)section,&choices);
- for (i = 0;i < n;i++) {
-
- if (strcasecmp(((ppd_option_t *)(choices[i]->option))->keyword,
- "Resolution") == 0) {
- resolution = atoi(choices[i]->choice);
- }
- }
- if (choices != 0) free(choices);
- }
-
- strncpy(jobInfo,jobInfoStr.getCString(),sizeof(jobInfo)-1);
- jobInfo[sizeof(jobInfo)-1] = '\0';
- strncpy(docInfo,docInfoStr.getCString(),sizeof(docInfo)-1);
- docInfo[sizeof(docInfo)-1] = '\0';
- strncpy(pageInfo,pageInfoStr.getCString(),sizeof(pageInfo)-1);
- pageInfo[sizeof(pageInfo)-1] = '\0';
-
- colorProfile = getColorProfilePath(ppd,&colorProfilePath);
-
- ppdClose(ppd);
- }
- if ((val = cupsGetOption("opvpJobInfo",num_options, options)) != 0) {
- /* override ppd value */
- strncpy(jobInfo,val,sizeof(jobInfo)-1);
- jobInfo[sizeof(jobInfo)-1] = '\0';
- }
- if ((val = cupsGetOption("opvpDocInfo",num_options, options)) != 0) {
- /* override ppd value */
- strncpy(docInfo,val,sizeof(docInfo)-1);
- docInfo[sizeof(docInfo)-1] = '\0';
- }
- if ((val = cupsGetOption("opvpPageInfo",num_options, options)) != 0) {
- /* override ppd value */
- strncpy(pageInfo,val,sizeof(pageInfo)-1);
- pageInfo[sizeof(pageInfo)-1] = '\0';
- }
-
- cupsFreeOptions(num_options,options);
-#if 0
- /* for debug parameters */
- fprintf(stderr,"WARNING:resolution=%d\n",resolution);
- fprintf(stderr,"WARNING:sliceHeight=%d\n",sliceHeight);
- fprintf(stderr,"WARNING:oldLipsDriver=%d\n",oldLipsDriver);
- fprintf(stderr,"WARNING:HPDriver=%d\n",HPDriver);
- fprintf(stderr,"WARNING:NECDriver=%d\n",NECDriver);
- fprintf(stderr,"WARNING:clipPathNotSaved=%d\n",clipPathNotSaved);
- fprintf(stderr,"WARNING:noShearImage=%d\n",noShearImage);
- fprintf(stderr,"WARNING:noLineStyle=%d\n",noLineStyle);
- fprintf(stderr,"WARNING:noClipPath=%d\n",noClipPath);
- fprintf(stderr,"WARNING:noMiterLimit=%d\n",noMiterLimit);
- fprintf(stderr,"WARNING:printerDriver=%s\n",printerDriver);
- fprintf(stderr,"WARNING:printerModel=%s\n",printerModel);
- fprintf(stderr,"WARNING:jobInfo=%s\n",jobInfo);
- fprintf(stderr,"WARNING:docInfo=%s\n",docInfo);
- fprintf(stderr,"WARNING:pageInfo=%s\n",pageInfo);
- fprintf(stderr,"WARNING:noBitmapChar=%d\n",noBitmapChar);
- fprintf(stderr,"WARNING:bitmapCharThreshold=%s\n",bitmapCharThreshold);
- fprintf(stderr,"WARNING:maxClipPathLength=%s\n",maxClipPathLength);
- fprintf(stderr,"WARNING:maxFillPathLength=%s\n",maxFillPathLength);
-exit(0);
-#endif
-
- if (oldLipsDriver) {
- optionKeys[nOptions] = "OPVP_OLDLIPSDRIVER";
- optionVals[nOptions] = "1";
- nOptions++;
- clipPathNotSaved = true;
- noShearImage = true;
- }
- if (HPDriver) {
- noClipPath = true;
- noLineStyle = true;
- noShearImage = true;
- }
- if (NECDriver) {
- noMiterLimit = true;
- strcpy(maxClipPathLength,"6");
- noShearImage = true;
- }
- if (clipPathNotSaved) {
- optionKeys[nOptions] = "OPVP_CLIPPATHNOTSAVED";
- optionVals[nOptions] = "1";
- nOptions++;
- }
- if (noShearImage) {
- optionKeys[nOptions] = "OPVP_NOSHEARIMAGE";
- optionVals[nOptions] = "1";
- nOptions++;
- }
- if (noLineStyle) {
- optionKeys[nOptions] = "OPVP_NOLINESTYLE";
- optionVals[nOptions] = "1";
- nOptions++;
- }
- if (noImageMask) {
- optionKeys[nOptions] = "OPVP_NOIMAGEMASK";
- optionVals[nOptions] = "1";
- nOptions++;
- }
- if (noClipPath) {
- optionKeys[nOptions] = "OPVP_NOCLIPPATH";
- optionVals[nOptions] = "1";
- nOptions++;
- }
- if (noMiterLimit) {
- optionKeys[nOptions] = "OPVP_NOMITERLIMIT";
- optionVals[nOptions] = "1";
- nOptions++;
- }
- if (noBitmapChar) {
- optionKeys[nOptions] = "OPVP_NOBITMAPCHAR";
- optionVals[nOptions] = "1";
- nOptions++;
- }
- if (ignoreMiterLimit) {
- optionKeys[nOptions] = "OPVP_IGNOREMITERLIMIT";
- optionVals[nOptions] = "1";
- nOptions++;
- }
- optionKeys[nOptions] = "OPVP_BITMAPCHARTHRESHOLD";
- optionVals[nOptions] = bitmapCharThreshold;
- nOptions++;
- optionKeys[nOptions] = "OPVP_MAXCLIPPATHLENGTH";
- optionVals[nOptions] = maxClipPathLength;
- nOptions++;
- optionKeys[nOptions] = "OPVP_MAXFILLPATHLENGTH";
- optionVals[nOptions] = maxFillPathLength;
- nOptions++;
- if (hResolution == 0) hResolution = resolution;
- if (hResolution == 0) hResolution = resolution;
- if (vResolution == 0) vResolution = resolution;
- if (strcasecmp(outputOrderStr,"reverse") == 0) {
- reverse = true;
- }
-
- if (argc > 6) {
- fileName.append(argv[6]);
- } else {
- fileName.append("-");
- }
-
- // read config file
- globalParams = new GlobalParams();
- if (enableFreeTypeStr[0]) {
- if (!globalParams->setEnableFreeType(enableFreeTypeStr)) {
- opvpError(-1,"Bad '-freetype' value on command line");
- ok = false;
- }
- }
-#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR <= 30
- globalParams->setAntialias("no");
-#endif
- if (quiet) {
- globalParams->setErrQuiet(quiet);
- }
- if (!ok) {
- exitCode = 2;
- goto err0;
- }
-
- if (fileName.cmp("-") == 0) {
- /* stdin */
- char *s;
- GooString name;
- int fd;
- char buf[4096];
- int n;
-
- /* create a tmp file */
- if ((s = getenv("TMPDIR")) != 0) {
- name.append(s);
- } else {
- name.append("/tmp");
- }
- name.append("/XXXXXX");
- fd = mkstemp(name.getCString());
- if (fd < 0) {
- opvpError(-1,"Can't create temporary file");
- exitCode = 2;
- goto err0;
- }
-
- /* check JCL */
- while (fgets(buf,sizeof(buf)-1,stdin) != NULL
- && strncmp(buf,"%PDF",4) != 0) {
- if (strncmp(buf,"pdftoopvp jobInfo:",18) == 0) {
- /* JCL jobInfo exists, override jobInfo */
- strncpy(jobInfo,buf+18,sizeof(jobInfo)-1);
- for (i = sizeof(jobInfo)-2;i >= 0
- && (jobInfo[i] == 0 || jobInfo[i] == '\n' || jobInfo[i] == ';')
- ;i--);
- jobInfo[i+1] = 0;
- }
- }
- if (strncmp(buf,"%PDF",4) != 0) {
- opvpError(-1,"Can't find PDF header");
- exitCode = 2;
- goto err0;
- }
- /* copy PDF header */
- n = strlen(buf);
- if (write(fd,buf,n) != n) {
- opvpError(-1,"Can't copy stdin to temporary file");
- close(fd);
- exitCode = 2;
- goto err0;
- }
- /* copy rest stdin to the tmp file */
- while ((n = fread(buf,1,sizeof(buf),stdin)) > 0) {
- if (write(fd,buf,n) != n) {
- opvpError(-1,"Can't copy stdin to temporary file");
- close(fd);
- exitCode = 2;
- goto err0;
- }
- }
- close(fd);
- doc = new PDFDoc(&name);
- /* remove name */
- unlink(name.getCString());
- } else {
- /* no jcl check */
- doc = new PDFDoc(fileName.copy());
- }
- if (!doc->isOk()) {
- opvpError(-1," Parsing PDF failed: error code %d",
- doc->getErrorCode());
- exitCode = 2;
- goto err05;
- }
-
- if (doc->isEncrypted() && !doc->okToPrint()) {
- opvpError(-1,"Print Permission Denied");
- exitCode = 2;
- goto err05;
- }
-
- /* paperColor is white */
- paperColor[0] = 255;
- paperColor[1] = 255;
- paperColor[2] = 255;
-#ifdef USE_CMS
- /* set color profile file name */
- GfxColorSpace::setDisplayProfileName(&colorProfilePath);
-#endif
- opvpOut = new OPVPOutputDev();
- if (opvpOut->init(mono ? splashModeMono1 :
- gray ? splashModeMono8 :
- splashModeRGB8,
- colorProfile,
- false, paperColor,
- printerDriver,1,printerModel,
- nOptions,optionKeys,optionVals) < 0) {
- opvpError(-1,"OPVPOutputDev Initialize fail");
- exitCode = 2;
- goto err1;
- }
-
- opvpOut->startDoc(doc->getXRef());
-
-#if 0
-fprintf(stderr,"JobInfo=%s\n",jobInfo);
-#endif
- if (opvpOut->OPVPStartJob(jobInfo) < 0) {
- opvpError(-1,"Start job failed");
- exitCode = 2;
- goto err1;
- }
- if (opvpOut->OPVPStartDoc(docInfo) < 0) {
- opvpError(-1,"Start Document failed");
- exitCode = 2;
- goto err2;
- }
- numPages = doc->getNumPages();
- for (pg = 1; pg <= numPages; ++pg) {
- if ((exitCode = outOnePage(doc,opvpOut,pg)) != 0) break;
- }
- if (opvpOut->OPVPEndDoc() < 0) {
- opvpError(-1,"End Document failed");
- exitCode = 2;
- }
-err2:
- if (opvpOut->OPVPEndJob() < 0) {
- opvpError(-1,"End job failed");
- exitCode = 2;
- }
-
- // clean up
- err1:
- delete opvpOut;
- err05:
- delete doc;
- err0:
- delete globalParams;
-
-#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR < 69
- // check for memory leaks
- Object::memCheck(stderr);
- gMemReport(stderr);
-#endif
-
-}
-/* muntrace(); */
- return exitCode;
-}
-
-/* for memory debug */
-/* For compatibility with g++ >= 4.7 compilers _GLIBCXX_THROW
- * should be used as a guard, otherwise use traditional definition */
-#ifndef _GLIBCXX_THROW
-#define _GLIBCXX_THROW throw
-#endif
-
-void * operator new(size_t size) _GLIBCXX_THROW (std::bad_alloc)
-{
- void *p = malloc(size);
- return p;
-}
-
-void operator delete(void *p) throw ()
-{
- free(p);
-}
diff --git a/filter/pdftopdf/pdftopdf.cc b/filter/pdftopdf/pdftopdf.cc
index 49d27c976..e9702a66d 100644
--- a/filter/pdftopdf/pdftopdf.cc
+++ b/filter/pdftopdf/pdftopdf.cc
@@ -318,6 +318,25 @@ void getParameters(ppd_file_t *ppd,int num_options,cups_option_t *options,Proces
param.numCopies=1;
}
+ if((val = cupsGetOption("ipp-attribute-fidelity",num_options,options))!=NULL) {
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes") ||
+ !strcasecmp(val,"on"))
+ param.fidelity = true;
+ }
+
+ if((val = cupsGetOption("print-scaling",num_options,options)) != NULL) {
+ if(!strcasecmp(val,"auto"))
+ param.autoprint = true;
+ else if(!strcasecmp(val,"auto-fit"))
+ param.autofit = true;
+ else if(!strcasecmp(val,"fill"))
+ param.fillprint = true;
+ else if(!strcasecmp(val,"fit"))
+ param.fitplot = true;
+ else
+ param.cropfit = true;
+ }
+ else {
if ((val=cupsGetOption("fitplot",num_options,options)) == NULL) {
if ((val=cupsGetOption("fit-to-page",num_options,options)) == NULL) {
val=cupsGetOption("ipp-attribute-fidelity",num_options,options);
@@ -326,6 +345,20 @@ void getParameters(ppd_file_t *ppd,int num_options,cups_option_t *options,Proces
// TODO? pstops checks =="true", pdftops !is_false ... pstops says: fitplot only for PS (i.e. not for PDF, cmp. cgpdftopdf)
param.fitplot=(val)&&(!is_false(val));
+ if((val = cupsGetOption("fill",num_options,options))!=0) {
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
+ {
+ param.fillprint = true;
+ }
+ }
+ if((val = cupsGetOption("crop-to-fit",num_options,options))!= NULL){
+ if(!strcasecmp(val,"true")||!strcasecmp(val,"yes"))
+ {
+ param.cropfit=1;
+ }
+ }
+ }
+
if (ppd && (ppd->landscape < 0)) { // direction the printer rotates landscape (90 or -90)
param.normal_landscape=ROT_270;
} else {
@@ -348,6 +381,8 @@ void getParameters(ppd_file_t *ppd,int num_options,cups_option_t *options,Proces
static const Rotation ipp2rot[4]={ROT_0, ROT_90, ROT_270, ROT_180};
param.orientation=ipp2rot[ipprot-3];
}
+ } else {
+ param.noOrientation = true;
}
ppd_size_t *pagesize;
@@ -834,7 +869,6 @@ void calculate(ppd_file_t *ppd,ProcessingParameters &param) // {{{
// }}}
// reads from stdin into temporary file. returns FILE * or NULL on error
-// TODO? to extra file (also used in pdftoijs, e.g.)
FILE *copy_stdin_to_temp() // {{{
{
char buf[BUFSIZ];
@@ -1023,10 +1057,11 @@ int main(int argc,char **argv)
param.nup.nupY=2;
//param.nup.yalign=TOP;
param.border=BorderType::NONE;
+ //param.fillprint = true;
//param.mirror=true;
//param.reverse=true;
//param.numCopies=3;
- if (!proc1->loadFilename("in.pdf")) return 2;
+ if (!proc1->loadFilename("in.pdf",1)) return 2;
param.dump();
if (!processPDFTOPDF(*proc1,param)) return 3;
emitComment(*proc1,param);
@@ -1063,30 +1098,61 @@ int main(int argc,char **argv)
param.dump();
#endif
+ /* Check with which method we will flatten interactive PDF forms
+ and annotations so that they get printed also after page
+ manipulations (scaling, N-up, ...). Flattening means to
+ integrate the filled in data and the printable annotations into
+ the pages themselves instead of holding them in an extra
+ layer. Default method is using QPDF, alternatives are the
+ external utilities pdftocairo or Ghostscript, but these make
+ the processing slower, especially due to extra piping of the
+ data between processes. */
+ int qpdf_flatten = 1;
+ int pdftocairo_flatten = 0;
+ int gs_flatten = 0;
+ int external_auto_flatten = 0;
+ const char *val;
+ if ((val = cupsGetOption("pdftopdf-form-flattening", num_options, options)) != NULL) {
+ if (strcasecmp(val, "qpdf") == 0 || strcasecmp(val, "internal") == 0 ||
+ strcasecmp(val, "auto") == 0) {
+ qpdf_flatten = 1;
+ } else if (strcasecmp(val, "external") == 0) {
+ qpdf_flatten = 0;
+ external_auto_flatten = 1;
+ } else if (strcasecmp(val, "pdftocairo") == 0) {
+ qpdf_flatten = 0;
+ pdftocairo_flatten = 1;
+ } else if (strcasecmp(val, "ghostscript") == 0 || strcasecmp(val, "gs") == 0) {
+ qpdf_flatten = 0;
+ gs_flatten = 1;
+ } else
+ fprintf(stderr,
+ "WARNING: Invalid value for \"pdftopdf-form-flattening\": \"%s\"\n", val);
+ }
+
cupsFreeOptions(num_options,options);
std::unique_ptr<PDFTOPDF_Processor> proc(PDFTOPDF_Factory::processor());
FILE *tmpfile = NULL;
if (argc==7) {
- if (!proc->loadFilename(argv[6])) {
+ if (!proc->loadFilename(argv[6],qpdf_flatten)) {
ppdClose(ppd);
return 1;
}
} else {
tmpfile = copy_stdin_to_temp();
if ((!tmpfile)||
- (!proc->loadFile(tmpfile,WillStayAlive))) {
+ (!proc->loadFile(tmpfile,WillStayAlive,qpdf_flatten))) {
ppdClose(ppd);
return 1;
}
}
- /* The input file contains a PDF form. To not loose the data filled
- into the form during our further manipulations we need to flatten
- the form, meaning that we integrate the filled in data into the
- pages themselves instead of holding them in an extra layer */
- if (proc->hasAcroForm()) {
+ /* If the input file contains a PDF form and we opted for not
+ using QPDF for flattening the form, we pipe the PDF through
+ pdftocairo or Ghostscript here */
+ if (!qpdf_flatten && proc->hasAcroForm()) {
/* Prepare the input file for being read by the form flattening
process */
FILE *infile = NULL;
@@ -1119,22 +1185,26 @@ int main(int argc,char **argv)
const char *command;
cups_array_t *args;
/* Choose the utility to be used and create its command line */
- /* Try pdftocairo first, the preferred utility for form-flattening */
- command = CUPS_POPPLER_PDFTOCAIRO;
- args = cupsArrayNew(NULL, NULL);
- cupsArrayAdd(args, strdup(command));
- cupsArrayAdd(args, strdup("-pdf"));
- cupsArrayAdd(args, strdup("-"));
- cupsArrayAdd(args, strdup(buf));
- /* Run the pdftocairo form flattening process */
- rewind(infile);
- int status = sub_process_spawn (command, args, infile);
- cupsArrayDelete(args);
- if (status == 0)
- flattening_done = 1;
- else {
- error("Unable to execute pdftocairo for form flattening!");
- /* Try Ghostscript, currently the only working alternative */
+ if (pdftocairo_flatten || external_auto_flatten) {
+ /* Try pdftocairo first, the preferred utility for form-flattening */
+ command = CUPS_POPPLER_PDFTOCAIRO;
+ args = cupsArrayNew(NULL, NULL);
+ cupsArrayAdd(args, strdup(command));
+ cupsArrayAdd(args, strdup("-pdf"));
+ cupsArrayAdd(args, strdup("-"));
+ cupsArrayAdd(args, strdup(buf));
+ /* Run the pdftocairo form flattening process */
+ rewind(infile);
+ int status = sub_process_spawn (command, args, infile);
+ cupsArrayDelete(args);
+ if (status == 0)
+ flattening_done = 1;
+ else
+ error("Unable to execute pdftocairo for form flattening!");
+ }
+ if (flattening_done == 0 &&
+ (gs_flatten || external_auto_flatten)) {
+ /* Try Ghostscript */
command = CUPS_GHOSTSCRIPT;
args = cupsArrayNew(NULL, NULL);
cupsArrayAdd(args, strdup(command));
@@ -1157,11 +1227,12 @@ int main(int argc,char **argv)
cupsArrayDelete(args);
if (status == 0)
flattening_done = 1;
- else {
+ else
error("Unable to execute Ghostscript for form flattening!");
- error("No suitable utility for flattening filled PDF forms available, no flattening performed. Filled in content will not be printed.");
- rewind(infile);
- }
+ }
+ if (flattening_done == 0) {
+ error("No suitable utility for flattening filled PDF forms available, no flattening performed. Filled in content will possibly not be printed.");
+ rewind(infile);
}
/* Clean up */
if (infile != tmpfile)
@@ -1170,12 +1241,13 @@ int main(int argc,char **argv)
if (flattening_done) {
rewind(outfile);
unlink(buf);
- if (!proc->loadFile(outfile,TakeOwnership)) {
+ if (!proc->loadFile(outfile,TakeOwnership,0)) {
error("Unable to create a PDF processor on the flattened form!");
return 1;
}
}
- }
+ } else if (qpdf_flatten)
+ fprintf(stderr, "DEBUG: PDF interactive form and annotation flattening done via QPDF\n");
/* TODO
// color management
diff --git a/filter/pdftopdf/pdftopdf_processor.cc b/filter/pdftopdf/pdftopdf_processor.cc
index 22ff0c5ce..6d2d32ff5 100644
--- a/filter/pdftopdf/pdftopdf_processor.cc
+++ b/filter/pdftopdf/pdftopdf_processor.cc
@@ -175,6 +175,62 @@ bool processPDFTOPDF(PDFTOPDF_Processor &proc,ProcessingParameters &param) // {{
}
const int numPages=std::max(shuffle.size(),pages.size());
+ if(param.autoprint||param.autofit){
+ bool margin_defined = true;
+ bool document_large = false;
+ int pw = param.page.right-param.page.left;
+ int ph = param.page.top-param.page.bottom;
+ int w=0,h=0;
+ Rotation tempRot=param.orientation;
+ PageRect r= pages[0]->getRect();
+ w = r.width;
+ h = r.height;
+
+ if(tempRot==ROT_90||tempRot==ROT_270)
+ {
+ std::swap(w,h);
+ }
+ if(w>=pw||h>=ph)
+ {
+ document_large = true;
+ }
+ if((param.page.width==pw)&&
+ (param.page.height==ph))
+ margin_defined = false;
+ if(param.autoprint){
+ if(param.fidelity||document_large) {
+ if(margin_defined)
+ param.fitplot = true;
+ else
+ param.fillprint = true;
+ }
+ else
+ param.cropfit = true;
+ }
+ else{
+ if(param.fidelity||document_large)
+ param.fitplot = true;
+ else
+ param.cropfit = true;
+ }
+ }
+
+ if(param.fillprint||param.cropfit){
+ fprintf(stderr,"[DEBUG]: Cropping input pdf and Enabling fitplot.\n");
+ if(param.noOrientation&&pages.size())
+ {
+ bool land = pages[0]->is_landscape(param.orientation);
+ if(land)
+ param.orientation = param.normal_landscape;
+ }
+ for(int i=0;i<(int)pages.size();i++)
+ {
+ std::shared_ptr<PDFTOPDF_PageHandle> page = pages[i];
+ page->crop(param.page,param.orientation,param.xpos,param.ypos,!param.cropfit);
+ }
+ param.fitplot = 1;
+ }
+
std::shared_ptr<PDFTOPDF_PageHandle> curpage;
int outputpage=0;
int outputno=0;
@@ -322,7 +378,20 @@ bool processPDFTOPDF(PDFTOPDF_Processor &proc,ProcessingParameters &param) // {{
if (!param.fitplot) {
curpage->add_subpage(page,pgedit.xpos+xpos,pgedit.ypos+ypos,pgedit.scale,&rect);
} else {
- curpage->add_subpage(page,pgedit.xpos+xpos,pgedit.ypos+ypos,pgedit.scale);
+ if(param.cropfit){
+ double xpos2 = (param.page.right-param.page.left-(page->getRect().width))/2;
+ double ypos2 = (param.page.top-param.page.bottom-(page->getRect().height))/2;
+ if(param.orientation==ROT_270||param.orientation==ROT_90)
+ {
+ xpos2 = (param.page.right-param.page.left-(page->getRect().height))/2;
+ ypos2 = (param.page.top-param.page.bottom-(page->getRect().width))/2;
+ curpage->add_subpage(page,ypos2+param.page.bottom,xpos2+param.page.left,1);
+ }else{
+ curpage->add_subpage(page,xpos2+param.page.left,ypos2+param.page.bottom,1);
+ }
+ }
+ else
+ curpage->add_subpage(page,pgedit.xpos+xpos,pgedit.ypos+ypos,pgedit.scale);
}
#ifdef DEBUG
diff --git a/filter/pdftopdf/pdftopdf_processor.h b/filter/pdftopdf/pdftopdf_processor.h
index b3837d9b6..ec7b2997b 100644
--- a/filter/pdftopdf/pdftopdf_processor.h
+++ b/filter/pdftopdf/pdftopdf_processor.h
@@ -14,6 +14,12 @@ ProcessingParameters()
: jobId(0),numCopies(1),
user(0),title(0),
fitplot(false),
+ fillprint(false), //print-scaling = fill
+ cropfit(false),
+ autoprint(false),
+ autofit(false),
+ fidelity(false),
+ noOrientation(false),
orientation(ROT_0),normal_landscape(ROT_270),
paper_is_landscape(false),
duplex(false),
@@ -38,7 +44,6 @@ ProcessingParameters()
deviceCollate(false),setDuplex(false),
page_logging(-1)
-
{
page.width=612.0; // letter
page.height=792.0;
@@ -55,6 +60,12 @@ ProcessingParameters()
int jobId, numCopies;
const char *user, *title; // will stay around
bool fitplot;
+ bool fillprint; //print-scaling = fill
+ bool cropfit; // -o crop-to-fit
+ bool autoprint; // print-scaling = auto
+ bool autofit; // print-scaling = auto-fit
+ bool fidelity;
+ bool noOrientation;
PageRect page;
Rotation orientation,normal_landscape; // normal_landscape (i.e. default direction) is e.g. needed for number-up=2
bool paper_is_landscape;
@@ -107,6 +118,8 @@ class PDFTOPDF_PageHandle {
// fscale: inverse_scale (from nup, fitplot)
virtual void add_border_rect(const PageRect &rect,BorderType border,float fscale) =0;
// TODO?! add standalone crop(...) method (not only for subpages)
+ virtual Rotation crop(const PageRect &cropRect,Rotation orientation,Position xpos,Position ypos,bool scale) =0;
+ virtual bool is_landscape(Rotation orientation) =0 ;
virtual void add_subpage(const std::shared_ptr<PDFTOPDF_PageHandle> &sub,float xpos,float ypos,float scale,const PageRect *crop=NULL) =0;
virtual void mirror() =0;
virtual void rotate(Rotation rot) =0;
@@ -119,8 +132,8 @@ class PDFTOPDF_Processor { // abstract interface
virtual ~PDFTOPDF_Processor() {}
// TODO: ... qpdf wants password at load time
- virtual bool loadFile(FILE *f,ArgOwnership take=WillStayAlive) =0;
- virtual bool loadFilename(const char *name) =0;
+ virtual bool loadFile(FILE *f,ArgOwnership take=WillStayAlive,int flatten_forms=1) =0;
+ virtual bool loadFilename(const char *name,int flatten_forms=1) =0;
// TODO? virtual bool may_modify/may_print/?
virtual bool check_print_permissions() =0;
diff --git a/filter/pdftopdf/qpdf_pdftopdf_processor.cc b/filter/pdftopdf/qpdf_pdftopdf_processor.cc
index 73e4f0669..7321e427c 100644
--- a/filter/pdftopdf/qpdf_pdftopdf_processor.cc
+++ b/filter/pdftopdf/qpdf_pdftopdf_processor.cc
@@ -5,6 +5,8 @@
#include <stdexcept>
#include <qpdf/QPDFWriter.hh>
#include <qpdf/QUtil.hh>
+#include <qpdf/QPDFPageDocumentHelper.hh>
+#include <qpdf/QPDFAcroFormDocumentHelper.hh>
#include "qpdf_tools.h"
#include "qpdf_xobject.h"
#include "qpdf_pdftopdf.h"
@@ -169,6 +171,89 @@ void QPDF_PDFTOPDF_PageHandle::add_border_rect(const PageRect &_rect,BorderType
#endif
}
// }}}
+/*
+ * This crop function is written for print-scaling=fill option.
+ * Trim Box is used for trimming the page in required size.
+ * scale tells if we need to scale input file.
+ */
+Rotation QPDF_PDFTOPDF_PageHandle::crop(const PageRect &cropRect,Rotation orientation,Position xpos,Position ypos,bool scale)
+{
+ page.assertInitialized();
+ if(orientation==ROT_0||orientation==ROT_180)
+ page.replaceOrRemoveKey("/Rotate",makeRotate(ROT_90));
+ else
+ page.replaceOrRemoveKey("/Rotate",makeRotate(ROT_0));
+
+ PageRect currpage= getBoxAsRect(getTrimBox(page));
+ double width = currpage.right-currpage.left;
+ double height = currpage.top-currpage.bottom;
+ double pageWidth = cropRect.right-cropRect.left;
+ double pageHeight = cropRect.top-cropRect.bottom;
+ double final_w,final_h; //Width and height of cropped image.
+
+ Rotation pageRot = getRotate(page);
+ if(pageRot==ROT_0||pageRot==ROT_180)
+ {
+ std::swap(pageHeight,pageWidth);
+ }
+ if(scale)
+ {
+ if(width*pageHeight/pageWidth<=height)
+ {
+ final_w = width;
+ final_h = width*pageHeight/pageWidth;
+ }
+ else{
+ final_w = height*pageWidth/pageHeight;
+ final_h = height;
+ }
+ }
+ else{
+ final_w = std::min(width,pageWidth);
+ final_h = std::min(height,pageHeight);
+ }
+ fprintf(stderr,"After Cropping: %lf %lf %lf %lf\n",width,height,final_w,final_h);
+ double posw = (width-final_w)/2,
+ posh = (height-final_h)/2;
+ // posw, posh : Position along width and height respectively.
+ // Calculating required position.
+ if(xpos==Position::LEFT)
+ posw =0;
+ else if(xpos==Position::RIGHT)
+ posw*=2;
+
+ if(ypos==Position::TOP)
+ posh*=2;
+ else if(ypos==Position::BOTTOM)
+ posh=0;
+
+ // making PageRect for cropping.
+ currpage.left += posw;
+ currpage.bottom += posh;
+ currpage.top =currpage.bottom+final_h;
+ currpage.right=currpage.left+final_w;
+ //Cropping.
+ // TODO: Borders are covered by the image. buffer space?
+ page.replaceKey("/TrimBox",makeBox(currpage.left,currpage.bottom,currpage.right,currpage.top));
+ page.replaceOrRemoveKey("/Rotate",makeRotate(ROT_0));
+ return getRotate(page);
+}
+
+bool QPDF_PDFTOPDF_PageHandle::is_landscape(Rotation orientation)
+{
+ page.assertInitialized();
+ if(orientation==ROT_0||orientation==ROT_180)
+ page.replaceOrRemoveKey("/Rotate",makeRotate(ROT_90));
+ else
+ page.replaceOrRemoveKey("/Rotate",makeRotate(ROT_0));
+
+ PageRect currpage= getBoxAsRect(getTrimBox(page));
+ double width = currpage.right-currpage.left;
+ double height = currpage.top-currpage.bottom;
+ if(width>height)
+ return true;
+ return false;
+}
// TODO: better cropping
// TODO: test/fix with qsub rotation
@@ -379,7 +464,7 @@ void QPDF_PDFTOPDF_Processor::error(const char *fmt,...) // {{{
// TODO? try/catch for PDF parsing errors?
-bool QPDF_PDFTOPDF_Processor::loadFile(FILE *f,ArgOwnership take) // {{{
+bool QPDF_PDFTOPDF_Processor::loadFile(FILE *f,ArgOwnership take,int flatten_forms) // {{{
{
closeFile();
if (!f) {
@@ -414,12 +499,12 @@ bool QPDF_PDFTOPDF_Processor::loadFile(FILE *f,ArgOwnership take) // {{{
error("loadFile with MustDuplicate is not supported");
return false;
}
- start();
+ start(flatten_forms);
return true;
}
// }}}
-bool QPDF_PDFTOPDF_Processor::loadFilename(const char *name) // {{{
+bool QPDF_PDFTOPDF_Processor::loadFilename(const char *name,int flatten_forms) // {{{
{
closeFile();
try {
@@ -429,15 +514,23 @@ bool QPDF_PDFTOPDF_Processor::loadFilename(const char *name) // {{{
error("loadFilename failed: %s",e.what());
return false;
}
- start();
+ start(flatten_forms);
return true;
}
// }}}
-void QPDF_PDFTOPDF_Processor::start() // {{{
+void QPDF_PDFTOPDF_Processor::start(int flatten_forms) // {{{
{
assert(pdf);
+ if (flatten_forms) {
+ QPDFAcroFormDocumentHelper afdh(*pdf);
+ afdh.generateAppearancesIfNeeded();
+
+ QPDFPageDocumentHelper dh(*pdf);
+ dh.flattenAnnotations(an_print);
+ }
+
pdf->pushInheritedAttributesToPage();
orig_pages=pdf->getAllPages();
diff --git a/filter/pdftopdf/qpdf_pdftopdf_processor.h b/filter/pdftopdf/qpdf_pdftopdf_processor.h
index 485b595ee..f721d9390 100644
--- a/filter/pdftopdf/qpdf_pdftopdf_processor.h
+++ b/filter/pdftopdf/qpdf_pdftopdf_processor.h
@@ -12,7 +12,8 @@ class QPDF_PDFTOPDF_PageHandle : public PDFTOPDF_PageHandle {
virtual void mirror();
virtual void rotate(Rotation rot);
virtual void add_label(const PageRect &rect, const std::string label);
-
+ virtual Rotation crop(const PageRect &cropRect,Rotation orientation,Position xpos,Position ypos,bool scale);
+ virtual bool is_landscape(Rotation orientation);
void debug(const PageRect &rect,float xpos,float ypos);
private:
bool isExisting() const;
@@ -34,8 +35,8 @@ class QPDF_PDFTOPDF_PageHandle : public PDFTOPDF_PageHandle {
class QPDF_PDFTOPDF_Processor : public PDFTOPDF_Processor {
public:
- virtual bool loadFile(FILE *f,ArgOwnership take=WillStayAlive);
- virtual bool loadFilename(const char *name);
+ virtual bool loadFile(FILE *f,ArgOwnership take=WillStayAlive,int flatten_forms=1);
+ virtual bool loadFilename(const char *name,int flatten_forms=1);
// TODO: virtual bool may_modify/may_print/?
virtual bool check_print_permissions();
@@ -61,7 +62,7 @@ class QPDF_PDFTOPDF_Processor : public PDFTOPDF_Processor {
private:
void closeFile();
void error(const char *fmt,...);
- void start();
+ void start(int flatten_forms);
private:
std::unique_ptr<QPDF> pdf;
std::vector<QPDFObjectHandle> orig_pages;
diff --git a/filter/pdftops.c b/filter/pdftops.c
index 57a7e4848..f50ba63da 100644
--- a/filter/pdftops.c
+++ b/filter/pdftops.c
@@ -107,17 +107,6 @@ const char *pstops_exclude_page_management[] = {
/*
- * Options which we do not pass on to the mupdftoraster and rastertops
- * filters when we render via MuPDF
- */
-
-const char *mupdf_exclude_general[] = {
- "Resolution",
- NULL
-};
-
-
-/*
* Check whether we were called after the "pdftopdf" filter and extract
* parameters passed over by "pdftopdf" in the header comments of the PDF
* file
@@ -297,25 +286,16 @@ main(int argc, /* I - Number of command-line args */
need_post_proc = 0, /* Post-processing needed? */
post_proc_pid = 0, /* Process ID of post-processing */
post_proc_pipe[2], /* Pipe to post-processing */
- need_rastertops = 0, /* rastertops (for MuPDF) needed */
- rastertops_pid = 0, /* Process ID of rastertops */
- rastertops_pipe[2], /* Pipe to rastertops */
wait_children, /* Number of child processes left */
wait_pid, /* Process ID from wait() */
wait_status, /* Status from child */
exit_status = 0; /* Exit status */
+ int gray_output = 0; /* Checking for monochrome/grayscale PostScript output */
char *pdf_argv[100], /* Arguments for pdftops/gs */
pstops_path[1024], /* Path to pstops program */
*pstops_argv[7], /* Arguments for pstops filter */
*pstops_options, /* Options for pstops filter */
*pstops_end, /* End of pstops filter option */
- rastertops_path[1024], /* Path to rastertops program */
- *rastertops_argv[7], /* Arguments for rastertops filter */
- mupdftoraster_path[1024], /* Path to mupdftoraster program */
- *mupdf_options, /* Options for mupdftoraster and
- rastertops filters */
- *mupdf_end, /* End of mupdftoraster and rastertops
- filter option */
*ptr; /* Pointer into value */
const char *cups_serverbin; /* CUPS_SERVERBIN environment
variable */
@@ -559,36 +539,43 @@ main(int argc, /* I - Number of command-line args */
log_command_line("pstops", pstops_argv);
/*
- * Build the rastertops command-line (MuPDF only)...
+ * Force monochrome/grayscale PostScript output
+ * if job is to be printed in monochrome/grayscale
*/
-
- if (renderer == MUPDF)
+ if (ppd->color_device == 0) /* Monochrome printer */
+ gray_output = 1;
+ else /*Color Printer - user option for Grayscale */
{
- if ((cups_serverbin = getenv("CUPS_SERVERBIN")) == NULL)
- cups_serverbin = CUPS_SERVERBIN;
-
- snprintf(rastertops_path, sizeof(rastertops_path), "%s/filter/rastertops",
- cups_serverbin);
-
- mupdf_options = strdup(argv[5]);
- remove_options(mupdf_options, mupdf_exclude_general);
-
- rastertops_argv[0] = argv[0]; /* Printer */
- rastertops_argv[1] = argv[1]; /* Job */
- rastertops_argv[2] = argv[2]; /* User */
- rastertops_argv[3] = argv[3]; /* Title */
- if (pdftopdfapplied)
- rastertops_argv[4] = deviceCopies; /* Copies */
- else
- rastertops_argv[4] = argv[4]; /* Copies */
- rastertops_argv[5] = mupdf_options; /* Options */
- rastertops_argv[6] = NULL;
-
- log_command_line("rastertops", rastertops_argv);
+ if ((val = cupsGetOption("pwg-raster-document-type", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("PwgRasterDocumentType", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("print-color-mode", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("PrintColorMode", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("color-space", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("ColorSpace", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("color-model", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("ColorModel", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("output-mode", num_options,
+ options)) != NULL ||
+ (val = cupsGetOption("OutputMode", num_options,
+ options)) != NULL)
+ {
+ if (strcasestr(val, "Black") ||
+ strcasestr(val, "Gray") ||
+ strcasestr(val, "Mono"))
+ gray_output = 1;
+ }
}
/*
- * Build the command-line for the pdftops, gs, pdftocairo, or
+ * Build the command-line for the pdftops, gs, mutool, pdftocairo, or
* acroread filter...
*/
@@ -612,7 +599,29 @@ main(int argc, /* I - Number of command-line args */
# endif /* HAVE_GHOSTSCRIPT_PS2WRITE */
pdf_argv[7] = (char *)"-dShowAcroForm";
pdf_argv[8] = (char *)"-sOUTPUTFILE=%stdout";
- pdf_argc = 9;
+ if (gray_output == 1) /* Checking for monochrome/grayscale PostScript
+ output */
+ {
+ pdf_argv[9] = (char *)"-sColorConversionStrategy=Gray";
+ pdf_argc = 10;
+ }
+ else
+ pdf_argc = 9;
+ }
+ else if (renderer == MUPDF)
+ {
+ pdf_argv[0] = (char *)"mutool";
+ pdf_argv[1] = (char *)"draw";
+ pdf_argv[2] = (char *)"-L";
+ pdf_argv[3] = (char *)"-smtf";
+ pdf_argv[4] = (char *)"-Fps";
+ pdf_argv[5] = (char *)"-o-";
+ if (gray_output == 1) /* Checking for monochrome/grayscale PostScript
+ output */
+ pdf_argv[6] = (char *)"-cgray";
+ else
+ pdf_argv[6] = (char *)"-crgb";
+ pdf_argc = 7;
}
else if (renderer == PDFTOCAIRO)
{
@@ -626,23 +635,6 @@ main(int argc, /* I - Number of command-line args */
pdf_argv[1] = (char *)"-toPostScript";
pdf_argc = 2;
}
- else if (renderer == MUPDF)
- {
- snprintf(mupdftoraster_path, sizeof(mupdftoraster_path),
- "%s/filter/mupdftoraster", cups_serverbin);
- pdf_argv[0] = "mupdftoraster";
- pdf_argv[1] = argv[1]; /* Job */
- pdf_argv[2] = argv[2]; /* User */
- pdf_argv[3] = argv[3]; /* Title */
- if (pdftopdfapplied)
- pdf_argv[4] = deviceCopies; /* Copies */
- else
- pdf_argv[4] = argv[4]; /* Copies */
- pdf_argv[5] = mupdf_options; /* Options */
- pdf_argv[6] = filename;
- pdf_argv[7] = NULL;
- pdf_argc = 8;
- }
/*
* Set language level and TrueType font handling...
@@ -660,11 +652,11 @@ main(int argc, /* I - Number of command-line args */
else if (renderer == GS)
pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=1";
else if (renderer == PDFTOCAIRO)
- fprintf(stderr, "WARNING: Level 1 PostScript not supported by pdftocairo.");
+ fprintf(stderr, "WARNING: Level 1 PostScript not supported by pdftocairo.\n");
else if (renderer == ACROREAD)
- fprintf(stderr, "WARNING: Level 1 PostScript not supported by acroread.");
+ fprintf(stderr, "WARNING: Level 1 PostScript not supported by acroread.\n");
else if (renderer == MUPDF)
- fprintf(stderr, "WARNING: Level 1 PostScript not supported by rastertops.");
+ fprintf(stderr, "WARNING: Level 1 PostScript not supported by mutool.\n");
}
else if (ppd->language_level == 2)
{
@@ -676,16 +668,20 @@ main(int argc, /* I - Number of command-line args */
}
else if (renderer == GS)
pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=2";
- else /* PDFTOCAIRO || ACROREAD */
+ else if (renderer != MUPDF) /* MuPDF is PS level 2 only */
+ /* PDFTOCAIRO, ACROREAD */
pdf_argv[pdf_argc++] = (char *)"-level2";
}
else
{
if (renderer == PDFTOPS)
{
- /* Do not emit PS Level 3 with Poppler on HP PostScript laser printers
- as some do not like it. See https://bugs.launchpad.net/bugs/277404.*/
+ /* Do not emit PS Level 3 with Poppler on Brother and HP PostScript
+ laser printers as some do not like it.
+ See https://bugs.launchpad.net/bugs/277404 and
+ https://bugs.launchpad.net/bugs/1306849 comment #42. */
if (!make_model[0] ||
+ !strncasecmp(make_model, "Brother", 7) ||
((!strncasecmp(make_model, "HP", 2) ||
!strncasecmp(make_model, "Hewlett-Packard", 15) ||
!strncasecmp(make_model, "Hewlett Packard", 15)) &&
@@ -695,7 +691,18 @@ main(int argc, /* I - Number of command-line args */
pdf_argv[pdf_argc++] = (char *)"-level3";
}
else if (renderer == GS)
- pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=3";
+ {
+ /* Do not emit PS Level 3 with Ghostscript on Brother PostScript
+ laser printers as some do not like it.
+ See https://bugs.launchpad.net/bugs/1306849 comment #42. */
+ if (!make_model[0] ||
+ !strncasecmp(make_model, "Brother", 7))
+ pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=2";
+ else
+ pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=3";
+ }
+ else if (renderer == MUPDF)
+ fprintf(stderr, "WARNING: Level 3 PostScript not supported by mutool.\n");
else /* PDFTOCAIRO || ACROREAD */
pdf_argv[pdf_argc++] = (char *)"-level3";
}
@@ -718,7 +725,8 @@ main(int argc, /* I - Number of command-line args */
}
else if (renderer == GS)
pdf_argv[pdf_argc++] = (char *)"-dLanguageLevel=3";
- else /* PDFTOCAIRO || ACROREAD */
+ else if (renderer != MUPDF) /* MuPDF is PS level 2 only */
+ /* PDFTOCAIRO || ACROREAD */
pdf_argv[pdf_argc++] = (char *)"-level3";
}
@@ -851,6 +859,11 @@ main(int argc, /* I - Number of command-line args */
pdf_argv[pdf_argc++] = resolution;
fprintf(stderr, "DEBUG: Using image rendering resolution %d dpi\n", res);
#endif /* HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION */
+ if (gray_output == 1) /* Checking for monochrome/grayscale PostScript output */
+ {
+ pdf_argv[1] = (char *)"-level1";
+ pdf_argv[pdf_argc++] = (char *)"-optimizecolorspace";
+ }
pdf_argv[pdf_argc++] = filename;
pdf_argv[pdf_argc++] = (char *)"-";
}
@@ -924,15 +937,12 @@ main(int argc, /* I - Number of command-line args */
* Add Resolution option to avoid slow processing by the printer when the
* resolution of embedded images does not match the printer's resolution
*/
- mupdf_options = realloc(mupdf_options, strlen(mupdf_options) + 30);
- if (!mupdf_options) {
- fprintf(stderr, "ERROR: Can't allocate mupdf_options\n");
- exit(2);
- }
- mupdf_end = mupdf_options + strlen(mupdf_options);
- snprintf(mupdf_end, 30, " Resolution=%ddpi", res);
- pdf_argv[5] = mupdf_options;
- rastertops_argv[5] = mupdf_options;
+ snprintf(resolution, 127, "-r%dx%d", res, res);
+ pdf_argv[pdf_argc++] = resolution;
+ /*
+ * Add input file name
+ */
+ pdf_argv[pdf_argc++] = filename;
}
pdf_argv[pdf_argc] = NULL;
@@ -965,16 +975,7 @@ main(int argc, /* I - Number of command-line args */
need_post_proc = 1;
/*
- * Do we need to run rastertops when we are using mupdftoraster as PDF
- * renderer
- */
-
- if (renderer == MUPDF)
- need_rastertops = 1;
-
- /*
- * Execute "pdftops/gs/mupdftoraster [ | rastertops ] [ | PS post-processing ]
- * | pstops"...
+ * Execute "pdftops/gs/mutool [ | PS post-processing ] | pstops"...
*/
@@ -991,17 +992,6 @@ main(int argc, /* I - Number of command-line args */
goto error;
}
- if (need_rastertops)
- {
- if (pipe(rastertops_pipe))
- {
- perror("DEBUG: Unable to create pipe for rastertops");
-
- exit_status = 1;
- goto error;
- }
- }
-
if (need_post_proc)
{
if (pipe(post_proc_pipe))
@@ -1019,18 +1009,7 @@ main(int argc, /* I - Number of command-line args */
* Child comes here...
*/
- if (need_rastertops)
- {
- dup2(rastertops_pipe[1], 1);
- close(rastertops_pipe[0]);
- close(rastertops_pipe[1]);
- if (need_post_proc)
- {
- close(post_proc_pipe[0]);
- close(post_proc_pipe[1]);
- }
- }
- else if (need_post_proc)
+ if (need_post_proc)
{
dup2(post_proc_pipe[1], 1);
close(post_proc_pipe[0]);
@@ -1073,8 +1052,8 @@ main(int argc, /* I - Number of command-line args */
}
else if (renderer == MUPDF)
{
- execvp(mupdftoraster_path, pdf_argv);
- perror("DEBUG: Unable to execute mupdftoraster program");
+ execvp(CUPS_MUTOOL, pdf_argv);
+ perror("DEBUG: Unable to execute mutool program");
}
exit(1);
@@ -1094,7 +1073,7 @@ main(int argc, /* I - Number of command-line args */
else if (renderer == ACROREAD)
perror("DEBUG: Unable to execute acroread program");
else if (renderer == MUPDF)
- perror("DEBUG: Unable to execute mupdftoraster program");
+ perror("DEBUG: Unable to execute mutool program");
exit_status = 1;
goto error;
@@ -1102,47 +1081,6 @@ main(int argc, /* I - Number of command-line args */
fprintf(stderr, "DEBUG: Started filter %s (PID %d)\n", pdf_argv[0], pdf_pid);
- if (need_rastertops)
- {
- if ((rastertops_pid = fork()) == 0)
- {
- /*
- * Child comes here...
- */
-
- dup2(rastertops_pipe[0], 0);
- close(rastertops_pipe[0]);
- close(rastertops_pipe[1]);
- if (need_post_proc)
- {
- dup2(post_proc_pipe[1], 1);
- close(post_proc_pipe[0]);
- close(post_proc_pipe[1]);
- }
- else
- dup2(pstops_pipe[1], 1);
- close(pstops_pipe[0]);
- close(pstops_pipe[1]);
-
- execvp(rastertops_path, rastertops_argv);
- perror("DEBUG: Unable to execute rastertops program");
- }
- else if (post_proc_pid < 0)
- {
- /*
- * Unable to fork!
- */
-
- perror("DEBUG: Unable to execute rastertops program");
-
- exit_status = 1;
- goto error;
- }
-
- fprintf(stderr, "DEBUG: Started filter rastertops (PID %d)\n",
- rastertops_pid);
- }
-
if (need_post_proc)
{
if ((post_proc_pid = fork()) == 0)
@@ -1157,11 +1095,6 @@ main(int argc, /* I - Number of command-line args */
dup2(pstops_pipe[1], 1);
close(pstops_pipe[0]);
close(pstops_pipe[1]);
- if (need_rastertops)
- {
- close(rastertops_pipe[0]);
- close(rastertops_pipe[1]);
- }
fp = cupsFileStdin();
@@ -1488,11 +1421,6 @@ main(int argc, /* I - Number of command-line args */
dup2(pstops_pipe[0], 0);
close(pstops_pipe[0]);
close(pstops_pipe[1]);
- if (need_rastertops)
- {
- close(rastertops_pipe[0]);
- close(rastertops_pipe[1]);
- }
if (need_post_proc)
{
close(post_proc_pipe[0]);
@@ -1525,17 +1453,12 @@ main(int argc, /* I - Number of command-line args */
close(post_proc_pipe[0]);
close(post_proc_pipe[1]);
}
- if (need_rastertops)
- {
- close(rastertops_pipe[0]);
- close(rastertops_pipe[1]);
- }
/*
* Wait for the child processes to exit...
*/
- wait_children = 2 + need_rastertops + need_post_proc;
+ wait_children = 2 + need_post_proc;
while (wait_children > 0)
{
@@ -1548,8 +1471,6 @@ main(int argc, /* I - Number of command-line args */
if (job_canceled)
{
kill(pdf_pid, SIGTERM);
- if (need_rastertops)
- kill(rastertops_pid, SIGTERM);
if (need_post_proc)
kill(post_proc_pid, SIGTERM);
kill(pstops_pid, SIGTERM);
@@ -1580,12 +1501,11 @@ main(int argc, /* I - Number of command-line args */
(renderer == PDFTOCAIRO ? "pdftocairo" :
(renderer == GS ? "gs" :
(renderer == ACROREAD ? "acroread" :
- (renderer == MUPDF ? "mupdftoraster" :
+ (renderer == MUPDF ? "mutool" :
"Unknown renderer"))))) :
(wait_pid == pstops_pid ? "pstops" :
- (wait_pid == rastertops_pid ? "rastertops" :
(wait_pid == post_proc_pid ? "Post-processing" :
- "Unknown process"))),
+ "Unknown process")),
exit_status);
}
else if (WTERMSIG(wait_status) == SIGTERM)
@@ -1598,12 +1518,11 @@ main(int argc, /* I - Number of command-line args */
(renderer == PDFTOCAIRO ? "pdftocairo" :
(renderer == GS ? "gs" :
(renderer == ACROREAD ? "acroread" :
- (renderer == MUPDF ? "mupdftoraster" :
+ (renderer == MUPDF ? "mutool" :
"Unknown renderer"))))) :
(wait_pid == pstops_pid ? "pstops" :
- (wait_pid == rastertops_pid ? "rastertops" :
(wait_pid == post_proc_pid ? "Post-processing" :
- "Unknown process"))),
+ "Unknown process")),
exit_status);
}
else
@@ -1617,12 +1536,11 @@ main(int argc, /* I - Number of command-line args */
(renderer == PDFTOCAIRO ? "pdftocairo" :
(renderer == GS ? "gs" :
(renderer == ACROREAD ? "acroread" :
- (renderer == MUPDF ? "mupdftoraster" :
+ (renderer == MUPDF ? "mutool" :
"Unknown renderer"))))) :
(wait_pid == pstops_pid ? "pstops" :
- (wait_pid == rastertops_pid ? "rastertops" :
(wait_pid == post_proc_pid ? "Post-processing" :
- "Unknown process"))),
+ "Unknown process")),
exit_status);
}
}
@@ -1635,12 +1553,11 @@ main(int argc, /* I - Number of command-line args */
(renderer == PDFTOCAIRO ? "pdftocairo" :
(renderer == GS ? "gs" :
(renderer == ACROREAD ? "acroread" :
- (renderer == MUPDF ? "mupdftoraster" :
+ (renderer == MUPDF ? "mutool" :
"Unknown renderer"))))) :
(wait_pid == pstops_pid ? "pstops" :
- (wait_pid == rastertops_pid ? "rastertops" :
(wait_pid == post_proc_pid ? "Post-processing" :
- "Unknown process"))));
+ "Unknown process")));
}
}
diff --git a/filter/pdftoraster.cxx b/filter/pdftoraster.cxx
index 13229e190..e553e76b8 100644
--- a/filter/pdftoraster.cxx
+++ b/filter/pdftoraster.cxx
@@ -1,5 +1,7 @@
/*
Copyright (c) 2008-2011 BBR Inc. All rights reserved.
+Copyright (c) 2012-2019 by Till Kamppeter
+Copyright (c) 2019 by Tanmay Anand.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -37,27 +39,22 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_CPP_POPPLER_VERSION_H
-#include "cpp/poppler-version.h"
+#include <poppler/cpp/poppler-version.h>
#endif
-#include "goo/GooString.h"
-#include "goo/gmem.h"
-#include "Object.h"
-#include "Stream.h"
-#include "PDFDoc.h"
-#include "SplashOutputDev.h"
-#include "GfxState.h"
#include <cups/ppd.h>
#include <stdarg.h>
-#include "PDFError.h"
-#include "GlobalParams.h"
#include <cups/raster.h>
#include <cupsfilters/image.h>
#include <cupsfilters/raster.h>
#include <cupsfilters/colormanager.h>
-#include <splash/SplashTypes.h>
-#include <splash/SplashBitmap.h>
#include <strings.h>
#include <math.h>
+#include <poppler/cpp/poppler-document.h>
+#include <poppler/cpp/poppler-page.h>
+#include <poppler/cpp/poppler-global.h>
+#include <poppler/cpp/poppler-image.h>
+#include <poppler/cpp/poppler-page-renderer.h>
+#include <poppler/cpp/poppler-rectangle.h>
#ifdef USE_LCMS1
#include <lcms.h>
#define cmsColorSpaceSignature icColorSpaceSignature
@@ -166,7 +163,7 @@ namespace {
{15,143,47,175,7,135,39,167,13,141,45,173,5,133,37,165},
{207,79,239,111,199,71,231,103,205,77,237,109,197,69,229,101},
{63,191,31,159,55,183,23,151,61,189,29,157,53,181,21,149},
- {255,127,223,95,247,119,215,87,253,125,221,93,245,117,213,85}
+ {255,127,223,95,247,119,215,87,253,125,221,93,245,117,213,85}
};
unsigned int dither2[8][8] = {
{0,32,8,40,2,34,10,42},
@@ -176,13 +173,13 @@ namespace {
{3,35,11,43,1,33,9,41},
{51,19,59,27,49,17,57,25},
{15,47,7,39,13,45,5,37},
- {63,31,55,23,61,29,53,21}
+ {63,31,55,23,61,29,53,21}
};
unsigned int dither4[4][4] = {
{0,8,2,10},
{12,4,14,6},
{3,11,1,9},
- {15,7,13,5}
+ {15,7,13,5}
};
/* for color profiles */
@@ -224,7 +221,7 @@ cmsCIExyYTRIPLE adobergb_matrix()
cmsCIExyYTRIPLE m;
double * matrix = cmMatrixAdobeRgb();
-
+
m.Red.x = matrix[0];
m.Red.y = matrix[1];
m.Red.Y = matrix[2];
@@ -251,7 +248,7 @@ cmsHPROFILE adobergb_profile()
#else
cmsToneCurve * Gamma = cmsBuildGamma(NULL, 2.2);
cmsToneCurve * Gamma3[3];
-#endif
+#endif
Gamma3[0] = Gamma3[1] = Gamma3[2] = Gamma;
// Build AdobeRGB profile
@@ -272,7 +269,7 @@ cmsHPROFILE sgray_profile()
cmsToneCurve Gamma = cmsBuildGamma(256, 2.2);
#else
cmsToneCurve * Gamma = cmsBuildGamma(NULL, 2.2);
-#endif
+#endif
// Build sGray profile
wp = sgray_wp();
sgray = cmsCreateGrayProfile(&wp, Gamma);
@@ -280,44 +277,6 @@ cmsHPROFILE sgray_profile()
return sgray;
}
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 23
-void CDECL myErrorFun(void *data, ErrorCategory category,
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 70
- Goffset pos, const char *msg)
-#else
- Goffset pos, char *msg)
-#endif /* MAJOR > 0 || MINOR >= 70 */
-#else
-void CDECL myErrorFun(void *data, ErrorCategory category,
- int pos, char *msg)
-#endif
-{
- if (pos >= 0) {
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 23
- fprintf(stderr, "ERROR (%lld): ", pos);
-#else
- fprintf(stderr, "ERROR (%d): ", pos);
-#endif
- } else {
- fprintf(stderr, "ERROR: ");
- }
- fprintf(stderr, "%s\n",msg);
- fflush(stderr);
-}
-#else
-void CDECL myErrorFun(int pos, char *msg, va_list args)
-{
- if (pos >= 0) {
- fprintf(stderr, "ERROR (%d): ", pos);
- } else {
- fprintf(stderr, "ERROR: ");
- }
- vfprintf(stderr, msg, args);
- fprintf(stderr, "\n");
- fflush(stderr);
-}
-#endif
#ifdef USE_LCMS1
static int lcmsErrorHandler(int ErrorCode, const char *ErrorText)
@@ -334,93 +293,6 @@ static void lcmsErrorHandler(cmsContext contextId, cmsUInt32Number ErrorCode,
#endif
-#if 0
-static bool getColorProfilePath(ppd_file_t *ppd, GooString *path)
-{
- // get color profile path
- const char *colorModel;
- const char *cupsICCQualifier2;
- const char *cupsICCQualifier2Choice;
- const char *cupsICCQualifier3;
- const char *cupsICCQualifier3Choice;
- ppd_attr_t *attr;
- ppd_choice_t *choice;
-
- if ((choice = ppdFindMarkedChoice(ppd,"ColorModel")) != NULL) {
- colorModel = choice->choice;
- } else {
- colorModel = NULL;
- }
- if ((attr = ppdFindAttr(ppd,"cupsICCQualifier2",NULL)) != NULL) {
- cupsICCQualifier2 = attr->value;
- } else {
- cupsICCQualifier2 = "MediaType";
- }
- if ((choice = ppdFindMarkedChoice(ppd,cupsICCQualifier2)) != NULL) {
- cupsICCQualifier2Choice = choice->choice;
- } else {
- cupsICCQualifier2Choice = NULL;
- }
- if ((attr = ppdFindAttr(ppd,"cupsICCQualifier3",NULL)) != NULL) {
- cupsICCQualifier3 = attr->value;
- } else {
- cupsICCQualifier3 = "Resolution";
- }
- if ((choice = ppdFindMarkedChoice(ppd,cupsICCQualifier3)) != NULL) {
- cupsICCQualifier3Choice = choice->choice;
- } else {
- cupsICCQualifier3Choice = NULL;
- }
-
- for (attr = ppdFindAttr(ppd,"cupsICCProfile",NULL);attr != NULL;
- attr = ppdFindNextAttr(ppd,"cupsICCProfile",NULL)) {
- // check color model
- char buf[PPD_MAX_NAME];
- char *p, *r;
- char *datadir;
-
- strncpy(buf,attr->spec,sizeof(buf));
- if ((p = strchr(buf,'.')) != NULL) {
- *p = '\0';
- }
- if (colorModel != NULL && buf[0] != '\0'
- && strcasecmp(buf,colorModel) != 0) continue;
- if (p == NULL) {
- break;
- } else {
- p++;
- if ((r = strchr(p,'.')) != 0) {
- *r = '\0';
- }
- }
- if (cupsICCQualifier2Choice != NULL && p[0] != '\0'
- && strcasecmp(p,cupsICCQualifier2Choice) != 0) continue;
- if (r == NULL) {
- break;
- } else {
- r++;
- if ((p = strchr(r,'.')) != 0) {
- *p = '\0';
- }
- }
- if (cupsICCQualifier3Choice == NULL || r[0] == '\0'
- || strcasecmp(r,cupsICCQualifier3Choice) == 0) break;
- }
- if (attr != NULL) {
- // matched
- path->clear();
- if (attr->value[0] != '/') {
- if ((datadir = getenv("CUPS_DATADIR")) == NULL)
- datadir = CUPS_DATADIR;
- path->append(datadir);
- path->append("/profiles/");
- }
- path->append(attr->value);
- return true;
- }
- return false;
-}
-#endif
static void handleRqeuiresPageRegion() {
ppd_choice_t *mf;
@@ -462,14 +334,13 @@ static void parseOpts(int argc, char **argv)
{
int num_options = 0;
cups_option_t *options = 0;
- GooString profilePath;
char *profile = 0;
const char *t = NULL;
ppd_attr_t *attr;
if (argc < 6 || argc > 7) {
- pdfError(-1,const_cast<char *>("%s job-id user title copies options [file]"),
- argv[0]);
+ fprintf(stderr, "ERROR: Usage: %s job-id user title copies options [file]\n",
+ argv[0]);
exit(1);
}
@@ -478,7 +349,7 @@ static void parseOpts(int argc, char **argv)
if (t && strcasestr(t, "pwg"))
pwgraster = 1;
#endif /* HAVE_CUPS_1_7 */
-
+
ppd = ppdOpenFile(getenv("PPD"));
if (ppd == NULL)
fprintf(stderr, "DEBUG: PPD file is not specified.\n");
@@ -556,10 +427,10 @@ static void parseOpts(int argc, char **argv)
if (cm_calibrate == CM_CALIBRATION_ENABLED)
cm_disabled = 1;
- else
+ else
cm_disabled = cmIsPrinterCmDisabled(getenv("PRINTER"));
-
- if (!cm_disabled)
+
+ if (!cm_disabled)
cmGetPrinterIccProfile(getenv("PRINTER"), &profile, ppd);
if (profile != NULL) {
@@ -587,7 +458,7 @@ static void parseOpts(int argc, char **argv)
if (strcasestr(t, "pwg"))
pwgraster = 1;
else
- pwgraster = 0;
+ pwgraster = 0;
}
cupsRasterParseIPPOptions(&header,num_options,options,pwgraster,1);
#else
@@ -1413,7 +1284,7 @@ static unsigned int getCMSColorSpaceType(cmsColorSpaceSignature cs)
/* select convertLine function */
static void selectConvertFunc(cups_raster_t *raster)
{
- if ((colorProfile == NULL || popplerColorProfile == colorProfile)
+ if ((colorProfile == NULL || popplerColorProfile == colorProfile)
&& (header.cupsColorOrder == CUPS_ORDER_CHUNKED
|| header.cupsNumColors == 1)) {
if (selectSpecialCase()) return;
@@ -1491,7 +1362,7 @@ static void selectConvertFunc(cups_raster_t *raster)
COLORSPACE_SH(dcst) |
CHANNELS_SH(header.cupsNumColors) | BYTES_SH(bytes),
renderingIntent,0)) == 0) {
- pdfError(-1,const_cast<char *>("Can't create color transform"));
+ fprintf(stderr, "ERROR: Can't create color transform");
exit(1);
}
} else {
@@ -1562,7 +1433,7 @@ static void selectConvertFunc(cups_raster_t *raster)
convertCSpace = W8toK8;
break;
default:
- pdfError(-1,const_cast<char *>("Specified ColorSpace is not supported"));
+ fprintf(stderr, "ERROR: Specified ColorSpace is not supported\n" );
exit(1);
break;
}
@@ -1637,13 +1508,103 @@ static void selectConvertFunc(cups_raster_t *raster)
}
}
-static void writePageImage(cups_raster_t *raster, SplashBitmap *bitmap,
+static unsigned char *onebitpixel(unsigned char *src, unsigned char *dst, unsigned int width, unsigned int height){
+ unsigned char *temp;
+ temp=dst;
+ int cnt=0;
+ for(unsigned int i=0;i<height;i++){
+ for(unsigned int j=0;j<width;j+=8){
+ unsigned char tem=0;
+ for(int k=0;k<8;k++){
+ cnt++;
+ tem <<=1;
+ unsigned int var=*src;
+ if(var > dither1[i & 0xf][(j+k) & 0xf]){
+ tem |= 0x1;
+ }
+ src +=1;
+ }
+ *dst=tem;
+ dst+=1;
+ }
+ }
+ return temp;
+}
+
+
+static unsigned char *removeAlpha(unsigned char *src, unsigned char *dst, unsigned int width, unsigned int height){
+ unsigned char *temp;
+ temp=dst;
+ for(unsigned int i=0;i<height;i++){
+ for(unsigned int j=0;j<width;j++){
+ dst[0]=src[2];
+ dst[1]=src[1];
+ dst[2]=src[0];
+ src+=4;
+ dst+=3;
+ }
+ }
+ return temp;
+}
+
+static void writePageImage(cups_raster_t *raster, poppler::document *doc1,
int pageNo)
{
ConvertLineFunc convertLine;
unsigned char *lineBuf = NULL;
unsigned char *dp;
- unsigned int rowsize = bitmap->getRowSize();
+ unsigned int rowsize;
+
+ poppler::page *current_page =doc1->create_page(pageNo-1);
+ poppler::page_renderer pr;
+ pr.set_render_hint(poppler::page_renderer::text_antialiasing);
+
+ unsigned char *colordata,*newdata,*graydata,*onebitdata;
+ unsigned int pixel_count;
+ poppler::image im;
+ //render the page according to the colourspace and generate the requried data
+ switch (header.cupsColorSpace) {
+ case CUPS_CSPACE_K://black
+ case CUPS_CSPACE_SW://sgray
+ if(header.cupsBitsPerColor==1){ //special case for 1-bit colorspaces
+ im = pr.render_page(current_page,header.HWResolution[0],header.HWResolution[1],0,0,bytesPerLine*8,header.cupsHeight);
+ newdata = (unsigned char *)malloc(sizeof(char)*3*im.width()*im.height());
+ newdata = removeAlpha((unsigned char *)im.const_data(),newdata,im.width(),im.height());
+ graydata=(unsigned char *)malloc(sizeof(char)*im.width()*im.height());
+ cupsImageRGBToWhite(newdata,graydata,im.width()*im.height());
+ onebitdata=(unsigned char *)malloc(sizeof(char)*bytesPerLine*im.height());
+ onebitpixel(graydata,onebitdata,im.width(),im.height());
+ colordata=onebitdata;
+ rowsize=bytesPerLine;
+ }
+ else{
+ im = pr.render_page(current_page,header.HWResolution[0],header.HWResolution[1],0,0,header.cupsWidth,header.cupsHeight);
+ newdata = (unsigned char *)malloc(sizeof(char)*3*im.width()*im.height());
+ newdata = removeAlpha((unsigned char *)im.const_data(),newdata,im.width(),im.height());
+ pixel_count=im.width()*im.height();
+ graydata=(unsigned char *)malloc(sizeof(char)*im.width()*im.height());
+ cupsImageRGBToWhite(newdata,graydata,pixel_count);
+ colordata=graydata;
+ rowsize=header.cupsWidth;
+ }
+
+ break;
+ case CUPS_CSPACE_RGB:
+ case CUPS_CSPACE_ADOBERGB:
+ case CUPS_CSPACE_CMYK:
+ case CUPS_CSPACE_SRGB:
+ case CUPS_CSPACE_CMY:
+ case CUPS_CSPACE_RGBW:
+ default:
+ im = pr.render_page(current_page,header.HWResolution[0],header.HWResolution[1],0,0,header.cupsWidth,header.cupsHeight);
+ newdata = (unsigned char *)malloc(sizeof(char)*3*im.width()*im.height());
+ newdata = removeAlpha((unsigned char *)im.const_data(),newdata,im.width(),im.height());
+ pixel_count=im.width()*im.height();
+ rowsize=header.cupsWidth*3;
+ colordata=newdata;
+ break;
+ }
+
if (allocLineBuf) lineBuf = new unsigned char [bytesPerLine];
if ((pageNo & 1) == 0) {
@@ -1653,7 +1614,7 @@ static void writePageImage(cups_raster_t *raster, SplashBitmap *bitmap,
}
if (header.Duplex && (pageNo & 1) == 0 && swap_image_y) {
for (unsigned int plane = 0;plane < nplanes;plane++) {
- unsigned char *bp = (unsigned char *)(bitmap->getDataPtr());
+ unsigned char *bp = colordata;
bp += rowsize * (bitmapoffset[1] + header.cupsHeight - 1) +
popplerBitsPerPixel * bitmapoffset[0] / 8;
@@ -1668,9 +1629,9 @@ static void writePageImage(cups_raster_t *raster, SplashBitmap *bitmap,
}
} else {
for (unsigned int plane = 0;plane < nplanes;plane++) {
- unsigned char *bp = (unsigned char *)(bitmap->getDataPtr());
+ unsigned char *bp = colordata;
- bp += rowsize * bitmapoffset[1] +
+ bp += rowsize * bitmapoffset[1] +
popplerBitsPerPixel * bitmapoffset[0] / 8;
for (unsigned int h = 0;h < header.cupsHeight;h++) {
for (unsigned int band = 0;band < nbands;band++) {
@@ -1685,29 +1646,40 @@ static void writePageImage(cups_raster_t *raster, SplashBitmap *bitmap,
if (allocLineBuf) delete[] lineBuf;
}
-static void outPage(PDFDoc *doc, Catalog *catalog, int pageNo,
- SplashOutputDev *out, cups_raster_t *raster)
+static void outPage(poppler::document *doc1, int pageNo,
+ cups_raster_t *raster)
{
- SplashBitmap *bitmap;
- Page *page = catalog->getPage(pageNo);
- PDFRectangle mediaBox = *page->getMediaBox();
- int rotate = page->getRotate();
+ // Page *page = catalog->getPage(pageNo);
+ // PDFRectangle mediaBox = *page->getMediaBox();
+ int rotate = 0;
double paperdimensions[2], /* Physical size of the paper */
margins[4]; /* Physical margins of print */
ppd_size_t *size; /* Page size */
double l, swap;
int i;
- bool landscape = 0;
+ poppler::page *current_page =doc1->create_page(pageNo-1);
+ poppler::page_box_enum box = poppler::page_box_enum::media_box;
+ poppler::rectf mediaBox = current_page->page_rect(box);
+ poppler::page::orientation_enum orient = current_page->orientation();
+ switch (orient) {
+ case poppler::page::landscape: rotate=90;
+ break;
+ case poppler::page::upside_down: rotate=180;
+ break;
+ case poppler::page::seascape: rotate=270;
+ break;
+ default:rotate=0;
+ }
fprintf(stderr, "DEBUG: mediaBox = [ %f %f %f %f ]; rotate = %d\n",
- mediaBox.x1, mediaBox.y1, mediaBox.x2, mediaBox.y2, rotate);
- l = mediaBox.x2 - mediaBox.x1;
+ mediaBox.left(), mediaBox.top(), mediaBox.right(), mediaBox.bottom(), rotate);
+ l = mediaBox.width();
if (l < 0) l = -l;
if (rotate == 90 || rotate == 270)
header.PageSize[1] = (unsigned)l;
else
header.PageSize[0] = (unsigned)l;
- l = mediaBox.y2 - mediaBox.y1;
+ l = mediaBox.height();
if (l < 0) l = -l;
if (rotate == 90 || rotate == 270)
header.PageSize[0] = (unsigned)l;
@@ -1732,7 +1704,6 @@ static void outPage(PDFDoc *doc, Catalog *catalog, int pageNo,
* Standard size...
*/
fprintf(stderr, "DEBUG: size = %s\n", size->name);
- landscape = 0;
paperdimensions[0] = size->width;
paperdimensions[1] = size->length;
if (pwgraster == 0) {
@@ -1760,7 +1731,6 @@ static void outPage(PDFDoc *doc, Catalog *catalog, int pageNo,
* Standard size in landscape orientation...
*/
fprintf(stderr, "DEBUG: landscape size = %s\n", size->name);
- landscape = 1;
paperdimensions[0] = size->width;
paperdimensions[1] = size->length;
if (pwgraster == 0) {
@@ -1775,7 +1745,6 @@ static void outPage(PDFDoc *doc, Catalog *catalog, int pageNo,
* Custom size...
*/
fprintf(stderr, "DEBUG: size = Custom\n");
- landscape = 0;
paperdimensions[1] = size->length;
for (i = 0; i < 2; i ++)
paperdimensions[i] = header.PageSize[i];
@@ -1816,10 +1785,7 @@ static void outPage(PDFDoc *doc, Catalog *catalog, int pageNo,
}
}
- doc->displayPage(out,pageNo,header.HWResolution[0],
- header.HWResolution[1],(landscape == 0 ? 0 : 90),
- true,true,true);
- bitmap = out->getBitmap();
+
bitmapoffset[0] = margins[0] / 72.0 * header.HWResolution[0];
bitmapoffset[1] = margins[3] / 72.0 * header.HWResolution[1];
@@ -1863,12 +1829,12 @@ static void outPage(PDFDoc *doc, Catalog *catalog, int pageNo,
header.cupsBytesPerLine *= header.cupsNumColors;
}
if (!cupsRasterWriteHeader2(raster,&header)) {
- pdfError(-1,const_cast<char *>("Can't write page %d header"),pageNo);
+ fprintf(stderr, "ERROR: Can't write page %d header\n",pageNo );
exit(1);
}
/* write page image */
- writePageImage(raster,bitmap,pageNo);
+ writePageImage(raster,doc1,pageNo);
}
static void setPopplerColorProfile()
@@ -1950,33 +1916,19 @@ static void setPopplerColorProfile()
popplerColorProfile = NULL;
break;
default:
- pdfError(-1,const_cast<char *>("Specified ColorSpace is not supported"));
+ fprintf(stderr, "ERROR: Specified ColorSpace is not supported\n" );
exit(1);
break;
}
- if (popplerColorProfile != NULL) {
- GfxColorSpace::setDisplayProfile(popplerColorProfile);
- }
}
int main(int argc, char *argv[]) {
- PDFDoc *doc;
- SplashOutputDev *out;
- SplashColor paperColor;
+ poppler::document *doc1;
int i;
int npages;
cups_raster_t *raster;
- enum SplashColorMode cmode;
- int rowpad;
- Catalog *catalog;
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- setErrorCallback(::myErrorFun,NULL);
-#else
- setErrorFunction(::myErrorFun);
-#endif
cmsSetLogErrorHandler(lcmsErrorHandler);
- globalParams = new GlobalParams();
parseOpts(argc, argv);
if (argc == 6) {
@@ -1988,43 +1940,41 @@ int main(int argc, char *argv[]) {
fd = cupsTempFd(name,sizeof(name));
if (fd < 0) {
- pdfError(-1,const_cast<char *>("Can't create temporary file"));
+ fprintf(stderr, "ERROR: Can't create temporary file\n");
exit(1);
}
/* copy stdin to the tmp file */
while ((n = read(0,buf,BUFSIZ)) > 0) {
if (write(fd,buf,n) != n) {
- pdfError(-1,const_cast<char *>("Can't copy stdin to temporary file"));
+ fprintf(stderr, "ERROR: Can't copy stdin to temporary file\n" );
close(fd);
exit(1);
}
}
close(fd);
- doc = new PDFDoc(new GooString(name));
+ doc1=poppler::document::load_from_file(name,"","");
/* remove name */
unlink(name);
} else {
- GooString *fileName = new GooString(argv[6]);
/* argc == 7 filenmae is specified */
FILE *fp;
if ((fp = fopen(argv[6],"rb")) == 0) {
- pdfError(-1,const_cast<char *>("Can't open input file %s"),argv[6]);
+ fprintf(stderr, "ERROR: Can't open input file %s\n",argv[6]);
exit(1);
}
parsePDFTOPDFComment(fp);
fclose(fp);
- doc = new PDFDoc(fileName,NULL,NULL);
+ doc1=poppler::document::load_from_file(argv[6],"","");
}
- if (!doc->isOk()) {
+ if (doc1==NULL) {
exitCode = 1;
goto err1;
}
- catalog = doc->getCatalog();
- npages = doc->getNumPages();
+ npages = doc1->pages();
/* fix NumCopies, Collate ccording to PDFTOPDFComments */
header.NumCopies = deviceCopies;
@@ -2038,7 +1988,7 @@ int main(int argc, char *argv[]) {
&& header.cupsBitsPerColor != 4
&& header.cupsBitsPerColor != 8
&& header.cupsBitsPerColor != 16) {
- pdfError(-1,const_cast<char *>("Specified color format is not supported"));
+ fprintf(stderr, "ERROR: Specified color format is not supported\n");
exit(1);
}
if (header.cupsColorOrder == CUPS_ORDER_PLANAR) {
@@ -2073,7 +2023,7 @@ int main(int argc, char *argv[]) {
if (header.cupsColorOrder != CUPS_ORDER_CHUNKED
|| (header.cupsBitsPerColor != 8
&& header.cupsBitsPerColor != 16)) {
- pdfError(-1,const_cast<char *>("Specified color format is not supported"));
+ fprintf(stderr, "ERROR: Specified color format is not supported\n");
exit(1);
}
case CUPS_CSPACE_RGB:
@@ -2089,12 +2039,6 @@ int main(int argc, char *argv[]) {
case CUPS_CSPACE_RGBW:
case CUPS_CSPACE_GMCK:
case CUPS_CSPACE_GMCS:
- cmode = splashModeRGB8;
- rowpad = 4;
- /* set paper color white */
- paperColor[0] = 255;
- paperColor[1] = 255;
- paperColor[2] = 255;
popplerBitsPerPixel = 24;
popplerNumColors = 3;
break;
@@ -2104,21 +2048,17 @@ int main(int argc, char *argv[]) {
case CUPS_CSPACE_WHITE:
case CUPS_CSPACE_GOLD:
case CUPS_CSPACE_SILVER:
- if (header.cupsBitsPerColor == 1
+ if (header.cupsBitsPerColor == 1
&& header.cupsBitsPerPixel == 1) {
- cmode = splashModeMono1;
popplerBitsPerPixel = 1;
} else {
- cmode = splashModeMono8;
popplerBitsPerPixel = 8;
}
/* set paper color white */
- paperColor[0] = 255;
- rowpad = 1;
popplerNumColors = 1;
break;
default:
- pdfError(-1,const_cast<char *>("Specified ColorSpace is not supported"));
+ fprintf(stderr, "ERROR: Specified ColorSpace is not supported\n");
exit(1);
break;
}
@@ -2127,32 +2067,19 @@ int main(int argc, char *argv[]) {
setPopplerColorProfile();
}
- out = new SplashOutputDev(cmode,rowpad/* row padding */,
- false,paperColor,true
-#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR <= 30
- ,false
-#endif
- );
-#if POPPLER_VERSION_MAJOR > 0 || POPPLER_VERSION_MINOR >= 19
- out->startDoc(doc);
-#else
- out->startDoc(doc->getXRef());
-#endif
-
if ((raster = cupsRasterOpen(1, pwgraster ? CUPS_RASTER_WRITE_PWG :
CUPS_RASTER_WRITE)) == 0) {
- pdfError(-1,const_cast<char *>("Can't open raster stream"));
+ fprintf(stderr, "ERROR: Can't open raster stream\n");
exit(1);
}
selectConvertFunc(raster);
for (i = 1;i <= npages;i++) {
- outPage(doc,catalog,i,out,raster);
+ outPage(doc1,i,raster);
}
cupsRasterClose(raster);
- delete out;
err1:
- delete doc;
+ delete doc1;
if (ppd != NULL) {
ppdClose(ppd);
}
@@ -2166,12 +2093,6 @@ err1:
cmsDeleteTransform(colorTransform);
}
-#if POPPLER_VERSION_MAJOR == 0 && POPPLER_VERSION_MINOR < 69
- // Check for memory leaks
- Object::memCheck(stderr);
- gMemReport(stderr);
-#endif
-
return exitCode;
}
@@ -2184,20 +2105,20 @@ err1:
void * operator new(size_t size) _GLIBCXX_THROW (std::bad_alloc)
{
- return gmalloc(size);
+ return malloc(size);
}
void operator delete(void *p) throw ()
{
- gfree(p);
+ free(p);
}
void * operator new[](size_t size) _GLIBCXX_THROW (std::bad_alloc)
{
- return gmalloc(size);
+ return malloc(size);
}
void operator delete[](void *p) throw ()
{
- gfree(p);
+ free(p);
}
diff --git a/filter/rastertops.c b/filter/rastertops.c
index 531eb7091..3d825a5da 100644
--- a/filter/rastertops.c
+++ b/filter/rastertops.c
@@ -44,14 +44,13 @@
*/
void
-writeProlog(cups_cspace_t mode, /* I - Color mode (gray or color) */
- int width, /* I - width of the image in pixels */
- int height) /* I - height of the image in pixels */
+writeProlog(int width, /* I - width of the image in points */
+ int height) /* I - height of the image in points */
{
/* Document header... */
printf("%%!PS-Adobe-3.0\n");
printf("%%%%BoundingBox: %d %d %d %d\n", 0, 0, width, height);
- printf("%%%%Creator: Cups-Filters\n");
+ printf("%%%%Creator: cups-filters\n");
printf("%%%%LanguageLevel: 2\n");
printf("%%%%DocumentData: Clean7Bit\n");
printf("%%%%Pages: (atend)\n");
@@ -100,11 +99,13 @@ find_bits(cups_cspace_t mode, /* I - Color space of data */
* 'writeImage()' - Write the information regarding the image
*/
-void /* O - Exit status */
-writeImage(int bpc, /* I - bits per color */
- int width, /* I - width of image */
- int height, /* I - height of image */
- cups_cspace_t mode) /* I - color model of image */
+void /* O - Exit status */
+writeImage(int pagewidth, /* I - width of page in points */
+ int pageheight, /* I - height of page in points */
+ int bpc, /* I - bits per color */
+ int pixwidth, /* I - width of image in pixels */
+ int pixheight, /* I - height of image in pixels */
+ cups_cspace_t mode) /* I - color model of image */
{
printf("gsave\n");
@@ -131,12 +132,12 @@ writeImage(int bpc, /* I - bits per color */
if (bpc == 16)
printf("/Input currentfile /FlateDecode filter def\n");
- printf("%d %d scale\n",width, height);
+ printf("%d %d scale\n", pagewidth, pageheight);
printf("<< \n"
"/ImageType 1\n"
"/Width %d\n"
"/Height %d\n"
- "/BitsPerComponent %d\n", width, height, find_bits(mode, bpc));
+ "/BitsPerComponent %d\n", pixwidth, pixheight, find_bits(mode, bpc));
switch (mode)
{
@@ -168,7 +169,7 @@ writeImage(int bpc, /* I - bits per color */
else
printf("/DataSource currentfile /FlateDecode filter\n");
- printf("/ImageMatrix [%d 0 0 %d 0 %d]\n", width, -1*height, height);
+ printf("/ImageMatrix [%d 0 0 %d 0 %d]\n", pixwidth, -1*pixheight, pixheight);
printf(">> image\n");
}
@@ -453,7 +454,7 @@ main(int argc, /* I - Number of command-line arguments */
if (!count)
{
count++;
- writeProlog(header.cupsColorSpace, header.cupsWidth, header.cupsHeight);
+ writeProlog(header.PageSize[0], header.PageSize[1]);
}
/*
@@ -469,12 +470,14 @@ main(int argc, /* I - Number of command-line arguments */
/*
* Write the starting of the page
*/
- writeStartPage(Page, header.cupsWidth, header.cupsHeight);
+ writeStartPage(Page, header.PageSize[0], header.PageSize[1]);
/*
* write the information regarding the image
*/
- writeImage(header.cupsBitsPerColor, header.cupsWidth, header.cupsHeight,
+ writeImage(header.PageSize[0], header.PageSize[1],
+ header.cupsBitsPerColor,
+ header.cupsWidth, header.cupsHeight,
header.cupsColorSpace);
/* Write the compressed image data*/
diff --git a/filter/urftopdf.cpp b/filter/urftopdf.cpp
index ec3f8dce3..4e7f6535a 100644
--- a/filter/urftopdf.cpp
+++ b/filter/urftopdf.cpp
@@ -12,8 +12,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * @brief Decode URF to a PDF file
- * @file urf_decode.cpp
+ * @brief Decode URF to a PDF file
+ * @file urftopdf.cpp
* @author Neil 'Superna' Armstrong <superna9999@gmail.com> (C) 2010
* @author Tobias Hoffmann <smilingthax@gmail.com> (c) 2012
*/
diff --git a/ltmain.sh b/ltmain.sh
index d3230f7c3..f402c9c17 100644
--- a/ltmain.sh
+++ b/ltmain.sh
@@ -31,7 +31,7 @@
PROGRAM=libtool
PACKAGE=libtool
-VERSION="2.4.6 Debian-2.4.6-4"
+VERSION="2.4.6 Debian-2.4.6-10"
package_revision=2.4.6
@@ -64,7 +64,7 @@ package_revision=2.4.6
# libraries, which are installed to $pkgauxdir.
# Set a version string for this script.
-scriptversion=2015-10-12.13; # UTC
+scriptversion=2015-01-20.17; # UTC
# General shell script boiler plate, and helper functions.
# Written by Gary V. Vaughan, 2004
@@ -580,16 +580,16 @@ if test yes = "$_G_HAVE_PLUSEQ_OP"; then
{
$debug_cmd
- func_quote_arg pretty "$2"
- eval "$1+=\\ \$func_quote_arg_result"
+ func_quote_for_eval "$2"
+ eval "$1+=\\ \$func_quote_for_eval_result"
}'
else
func_append_quoted ()
{
$debug_cmd
- func_quote_arg pretty "$2"
- eval "$1=\$$1\\ \$func_quote_arg_result"
+ func_quote_for_eval "$2"
+ eval "$1=\$$1\\ \$func_quote_for_eval_result"
}
fi
@@ -1091,181 +1091,85 @@ func_relative_path ()
}
-# func_quote_portable EVAL ARG
-# ----------------------------
-# Internal function to portably implement func_quote_arg. Note that we still
-# keep attention to performance here so we as much as possible try to avoid
-# calling sed binary (so far O(N) complexity as long as func_append is O(1)).
-func_quote_portable ()
+# func_quote_for_eval ARG...
+# --------------------------
+# Aesthetically quote ARGs to be evaled later.
+# This function returns two values:
+# i) func_quote_for_eval_result
+# double-quoted, suitable for a subsequent eval
+# ii) func_quote_for_eval_unquoted_result
+# has all characters that are still active within double
+# quotes backslashified.
+func_quote_for_eval ()
{
$debug_cmd
- func_quote_portable_result=$2
-
- # one-time-loop (easy break)
- while true
- do
- if $1; then
- func_quote_portable_result=`$ECHO "$2" | $SED \
- -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
- break
- fi
-
- # Quote for eval.
- case $func_quote_portable_result in
+ func_quote_for_eval_unquoted_result=
+ func_quote_for_eval_result=
+ while test 0 -lt $#; do
+ case $1 in
*[\\\`\"\$]*)
- case $func_quote_portable_result in
- *[\[\*\?]*)
- func_quote_portable_result=`$ECHO "$func_quote_portable_result" | $SED "$sed_quote_subst"`
- break
- ;;
- esac
+ _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
+ *)
+ _G_unquoted_arg=$1 ;;
+ esac
+ if test -n "$func_quote_for_eval_unquoted_result"; then
+ func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
+ else
+ func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
+ fi
- func_quote_portable_old_IFS=$IFS
- for _G_char in '\' '`' '"' '$'
- do
- # STATE($1) PREV($2) SEPARATOR($3)
- set start "" ""
- func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
- IFS=$_G_char
- for _G_part in $func_quote_portable_result
- do
- case $1 in
- quote)
- func_append func_quote_portable_result "$3$2"
- set quote "$_G_part" "\\$_G_char"
- ;;
- start)
- set first "" ""
- func_quote_portable_result=
- ;;
- first)
- set quote "$_G_part" ""
- ;;
- esac
- done
- done
- IFS=$func_quote_portable_old_IFS
+ case $_G_unquoted_arg in
+ # Double-quote args containing shell metacharacters to delay
+ # word splitting, command substitution and variable expansion
+ # for a subsequent eval.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ _G_quoted_arg=\"$_G_unquoted_arg\"
;;
- *) ;;
+ *)
+ _G_quoted_arg=$_G_unquoted_arg
+ ;;
esac
- break
- done
- func_quote_portable_unquoted_result=$func_quote_portable_result
- case $func_quote_portable_result in
- # double-quote args containing shell metacharacters to delay
- # word splitting, command substitution and variable expansion
- # for a subsequent eval.
- # many bourne shells cannot handle close brackets correctly
- # in scan sets, so we specify it separately.
- *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
- func_quote_portable_result=\"$func_quote_portable_result\"
- ;;
- esac
+ if test -n "$func_quote_for_eval_result"; then
+ func_append func_quote_for_eval_result " $_G_quoted_arg"
+ else
+ func_append func_quote_for_eval_result "$_G_quoted_arg"
+ fi
+ shift
+ done
}
-# func_quotefast_eval ARG
-# -----------------------
-# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG',
-# but optimized for speed. Result is stored in $func_quotefast_eval.
-if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
- func_quotefast_eval ()
- {
- printf -v func_quotefast_eval_result %q "$1"
- }
-else
- func_quotefast_eval ()
- {
- func_quote_portable false "$1"
- func_quotefast_eval_result=$func_quote_portable_result
- }
-fi
-
+# func_quote_for_expand ARG
+# -------------------------
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+ $debug_cmd
-# func_quote_arg MODEs ARG
-# ------------------------
-# Quote one ARG to be evaled later. MODEs argument may contain zero ore more
-# specifiers listed below separated by ',' character. This function returns two
-# values:
-# i) func_quote_arg_result
-# double-quoted (when needed), suitable for a subsequent eval
-# ii) func_quote_arg_unquoted_result
-# has all characters that are still active within double
-# quotes backslashified. Available only if 'unquoted' is specified.
-#
-# Available modes:
-# ----------------
-# 'eval' (default)
-# - escape shell special characters
-# 'expand'
-# - the same as 'eval'; but do not quote variable references
-# 'pretty'
-# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might
-# later used in func_quote to get output like: 'echo "a b"' instead of
-# 'echo a\ b'. This is slower than default on some shells.
-# 'unquoted'
-# - produce also $func_quote_arg_unquoted_result which does not contain
-# wrapping double-quotes.
-#
-# Examples for 'func_quote_arg pretty,unquoted string':
-#
-# string | *_result | *_unquoted_result
-# ------------+-----------------------+-------------------
-# " | \" | \"
-# a b | "a b" | a b
-# "a b" | "\"a b\"" | \"a b\"
-# * | "*" | *
-# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\"
-#
-# Examples for 'func_quote_arg pretty,unquoted,expand string':
-#
-# string | *_result | *_unquoted_result
-# --------------+---------------------+--------------------
-# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\"
-func_quote_arg ()
-{
- _G_quote_expand=false
- case ,$1, in
- *,expand,*)
- _G_quote_expand=:
- ;;
+ case $1 in
+ *[\\\`\"]*)
+ _G_arg=`$ECHO "$1" | $SED \
+ -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
+ *)
+ _G_arg=$1 ;;
esac
- case ,$1, in
- *,pretty,*|*,expand,*|*,unquoted,*)
- func_quote_portable $_G_quote_expand "$2"
- func_quote_arg_result=$func_quote_portable_result
- func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
- ;;
- *)
- # Faster quote-for-eval for some shells.
- func_quotefast_eval "$2"
- func_quote_arg_result=$func_quotefast_eval_result
+ case $_G_arg in
+ # Double-quote args containing shell metacharacters to delay
+ # word splitting and command substitution for a subsequent eval.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ _G_arg=\"$_G_arg\"
;;
esac
-}
-
-# func_quote MODEs ARGs...
-# ------------------------
-# Quote all ARGs to be evaled later and join them into single command. See
-# func_quote_arg's description for more info.
-func_quote ()
-{
- $debug_cmd
- _G_func_quote_mode=$1 ; shift
- func_quote_result=
- while test 0 -lt $#; do
- func_quote_arg "$_G_func_quote_mode" "$1"
- if test -n "$func_quote_result"; then
- func_append func_quote_result " $func_quote_arg_result"
- else
- func_append func_quote_result "$func_quote_arg_result"
- fi
- shift
- done
+ func_quote_for_expand_result=$_G_arg
}
@@ -1311,8 +1215,8 @@ func_show_eval ()
_G_cmd=$1
_G_fail_exp=${2-':'}
- func_quote_arg pretty,expand "$_G_cmd"
- eval "func_notquiet $func_quote_arg_result"
+ func_quote_for_expand "$_G_cmd"
+ eval "func_notquiet $func_quote_for_expand_result"
$opt_dry_run || {
eval "$_G_cmd"
@@ -1337,8 +1241,8 @@ func_show_eval_locale ()
_G_fail_exp=${2-':'}
$opt_quiet || {
- func_quote_arg expand,pretty "$_G_cmd"
- eval "func_echo $func_quote_arg_result"
+ func_quote_for_expand "$_G_cmd"
+ eval "func_echo $func_quote_for_expand_result"
}
$opt_dry_run || {
@@ -1466,7 +1370,7 @@ func_lt_ver ()
#! /bin/sh
# Set a version string for this script.
-scriptversion=2015-10-12.13; # UTC
+scriptversion=2015-10-07.11; # UTC
# A portable, pluggable option parser for Bourne shell.
# Written by Gary V. Vaughan, 2010
@@ -1676,8 +1580,8 @@ func_run_hooks ()
# '
# # No change in '$@' (ignored completely by this hook). There is
# # no need to do the equivalent (but slower) action:
-# # func_quote eval ${1+"$@"}
-# # my_options_prep_result=$func_quote_result
+# # func_quote_for_eval ${1+"$@"}
+# # my_options_prep_result=$func_quote_for_eval_result
# false
# }
# func_add_hook func_options_prep my_options_prep
@@ -1713,8 +1617,8 @@ func_run_hooks ()
# done
#
# if $args_changed; then
-# func_quote eval ${1+"$@"}
-# my_silent_option_result=$func_quote_result
+# func_quote_for_eval ${1+"$@"}
+# my_silent_option_result=$func_quote_for_eval_result
# fi
#
# $args_changed
@@ -1781,8 +1685,8 @@ func_options ()
if $_G_rc_options; then
func_options_result=$_G_res_var
else
- func_quote eval ${1+"$@"}
- func_options_result=$func_quote_result
+ func_quote_for_eval ${1+"$@"}
+ func_options_result=$func_quote_for_eval_result
fi
$_G_rc_options
@@ -1925,8 +1829,8 @@ func_parse_options ()
if $_G_rc_parse_options; then
# save modified positional parameters for caller
- func_quote eval ${1+"$@"}
- func_parse_options_result=$func_quote_result
+ func_quote_for_eval ${1+"$@"}
+ func_parse_options_result=$func_quote_for_eval_result
fi
$_G_rc_parse_options
@@ -2237,7 +2141,7 @@ include the following information:
compiler: $LTCC
compiler flags: $LTCFLAGS
linker: $LD (gnu? $with_gnu_ld)
- version: $progname $scriptversion Debian-2.4.6-4
+ version: $progname $scriptversion Debian-2.4.6-10
automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
@@ -2471,8 +2375,8 @@ libtool_options_prep ()
if $_G_rc_lt_options_prep; then
# Pass back the list of options.
- func_quote eval ${1+"$@"}
- libtool_options_prep_result=$func_quote_result
+ func_quote_for_eval ${1+"$@"}
+ libtool_options_prep_result=$func_quote_for_eval_result
fi
$_G_rc_lt_options_prep
@@ -2578,8 +2482,8 @@ libtool_parse_options ()
if $_G_rc_lt_parse_options; then
# save modified positional parameters for caller
- func_quote eval ${1+"$@"}
- libtool_parse_options_result=$func_quote_result
+ func_quote_for_eval ${1+"$@"}
+ libtool_parse_options_result=$func_quote_for_eval_result
fi
$_G_rc_lt_parse_options
@@ -2639,8 +2543,8 @@ libtool_validate_options ()
}
# Pass back the unparsed argument list
- func_quote eval ${1+"$@"}
- libtool_validate_options_result=$func_quote_result
+ func_quote_for_eval ${1+"$@"}
+ libtool_validate_options_result=$func_quote_for_eval_result
}
func_add_hook func_validate_options libtool_validate_options
@@ -3606,8 +3510,8 @@ func_mode_compile ()
esac
done
- func_quote_arg pretty "$libobj"
- test "X$libobj" != "X$func_quote_arg_result" \
+ func_quote_for_eval "$libobj"
+ test "X$libobj" != "X$func_quote_for_eval_result" \
&& $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
&& func_warning "libobj name '$libobj' may not contain shell special characters."
func_dirname_and_basename "$obj" "/" ""
@@ -3680,8 +3584,8 @@ compiler."
func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
srcfile=$func_to_tool_file_result
- func_quote_arg pretty "$srcfile"
- qsrcfile=$func_quote_arg_result
+ func_quote_for_eval "$srcfile"
+ qsrcfile=$func_quote_for_eval_result
# Only build a PIC object if we are building libtool libraries.
if test yes = "$build_libtool_libs"; then
@@ -4284,8 +4188,8 @@ func_mode_install ()
case $nonopt in *shtool*) :;; *) false;; esac
then
# Aesthetically quote it.
- func_quote_arg pretty "$nonopt"
- install_prog="$func_quote_arg_result "
+ func_quote_for_eval "$nonopt"
+ install_prog="$func_quote_for_eval_result "
arg=$1
shift
else
@@ -4295,8 +4199,8 @@ func_mode_install ()
# The real first argument should be the name of the installation program.
# Aesthetically quote it.
- func_quote_arg pretty "$arg"
- func_append install_prog "$func_quote_arg_result"
+ func_quote_for_eval "$arg"
+ func_append install_prog "$func_quote_for_eval_result"
install_shared_prog=$install_prog
case " $install_prog " in
*[\\\ /]cp\ *) install_cp=: ;;
@@ -4353,12 +4257,12 @@ func_mode_install ()
esac
# Aesthetically quote the argument.
- func_quote_arg pretty "$arg"
- func_append install_prog " $func_quote_arg_result"
+ func_quote_for_eval "$arg"
+ func_append install_prog " $func_quote_for_eval_result"
if test -n "$arg2"; then
- func_quote_arg pretty "$arg2"
+ func_quote_for_eval "$arg2"
fi
- func_append install_shared_prog " $func_quote_arg_result"
+ func_append install_shared_prog " $func_quote_for_eval_result"
done
test -z "$install_prog" && \
@@ -4369,8 +4273,8 @@ func_mode_install ()
if test -n "$install_override_mode" && $no_mode; then
if $install_cp; then :; else
- func_quote_arg pretty "$install_override_mode"
- func_append install_shared_prog " -m $func_quote_arg_result"
+ func_quote_for_eval "$install_override_mode"
+ func_append install_shared_prog " -m $func_quote_for_eval_result"
fi
fi
@@ -4666,8 +4570,8 @@ func_mode_install ()
relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
$opt_quiet || {
- func_quote_arg expand,pretty "$relink_command"
- eval "func_echo $func_quote_arg_result"
+ func_quote_for_expand "$relink_command"
+ eval "func_echo $func_quote_for_expand_result"
}
if eval "$relink_command"; then :
else
@@ -5446,8 +5350,7 @@ else
if test \"\$libtool_execute_magic\" != \"$magic\"; then
file=\"\$0\""
- func_quote_arg pretty "$ECHO"
- qECHO=$func_quote_arg_result
+ qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
$ECHO "\
# A function that is used when there is no print builtin or printf.
@@ -5457,7 +5360,7 @@ func_fallback_echo ()
\$1
_LTECHO_EOF'
}
- ECHO=$qECHO
+ ECHO=\"$qECHO\"
fi
# Very basic option parsing. These options are (a) specific to
@@ -6800,9 +6703,9 @@ func_mode_link ()
while test "$#" -gt 0; do
arg=$1
shift
- func_quote_arg pretty,unquoted "$arg"
- qarg=$func_quote_arg_unquoted_result
- func_append libtool_args " $func_quote_arg_result"
+ func_quote_for_eval "$arg"
+ qarg=$func_quote_for_eval_unquoted_result
+ func_append libtool_args " $func_quote_for_eval_result"
# If the previous option needs an argument, assign it.
if test -n "$prev"; then
@@ -7400,9 +7303,9 @@ func_mode_link ()
save_ifs=$IFS; IFS=,
for flag in $args; do
IFS=$save_ifs
- func_quote_arg pretty "$flag"
- func_append arg " $func_quote_arg_result"
- func_append compiler_flags " $func_quote_arg_result"
+ func_quote_for_eval "$flag"
+ func_append arg " $func_quote_for_eval_result"
+ func_append compiler_flags " $func_quote_for_eval_result"
done
IFS=$save_ifs
func_stripname ' ' '' "$arg"
@@ -7416,10 +7319,10 @@ func_mode_link ()
save_ifs=$IFS; IFS=,
for flag in $args; do
IFS=$save_ifs
- func_quote_arg pretty "$flag"
- func_append arg " $wl$func_quote_arg_result"
- func_append compiler_flags " $wl$func_quote_arg_result"
- func_append linker_flags " $func_quote_arg_result"
+ func_quote_for_eval "$flag"
+ func_append arg " $wl$func_quote_for_eval_result"
+ func_append compiler_flags " $wl$func_quote_for_eval_result"
+ func_append linker_flags " $func_quote_for_eval_result"
done
IFS=$save_ifs
func_stripname ' ' '' "$arg"
@@ -7443,8 +7346,8 @@ func_mode_link ()
# -msg_* for osf cc
-msg_*)
- func_quote_arg pretty "$arg"
- arg=$func_quote_arg_result
+ func_quote_for_eval "$arg"
+ arg=$func_quote_for_eval_result
;;
# Flags to be passed through unchanged, with rationale:
@@ -7464,12 +7367,13 @@ func_mode_link ()
# -specs=* GCC specs files
# -stdlib=* select c++ std lib with clang
# -fsanitize=* Clang/GCC memory and address sanitizer
+ # -fuse-ld=* Linker select flags for GCC
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
-t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
-O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
- -specs=*|-fsanitize=*)
- func_quote_arg pretty "$arg"
- arg=$func_quote_arg_result
+ -specs=*|-fsanitize=*|-fuse-ld=*)
+ func_quote_for_eval "$arg"
+ arg=$func_quote_for_eval_result
func_append compile_command " $arg"
func_append finalize_command " $arg"
func_append compiler_flags " $arg"
@@ -7490,15 +7394,15 @@ func_mode_link ()
continue
else
# Otherwise treat like 'Some other compiler flag' below
- func_quote_arg pretty "$arg"
- arg=$func_quote_arg_result
+ func_quote_for_eval "$arg"
+ arg=$func_quote_for_eval_result
fi
;;
# Some other compiler flag.
-* | +*)
- func_quote_arg pretty "$arg"
- arg=$func_quote_arg_result
+ func_quote_for_eval "$arg"
+ arg=$func_quote_for_eval_result
;;
*.$objext)
@@ -7618,8 +7522,8 @@ func_mode_link ()
*)
# Unknown arguments in both finalize_command and compile_command need
# to be aesthetically quoted because they are evaled later.
- func_quote_arg pretty "$arg"
- arg=$func_quote_arg_result
+ func_quote_for_eval "$arg"
+ arg=$func_quote_for_eval_result
;;
esac # arg
@@ -10131,8 +10035,8 @@ EOF
for cmd in $concat_cmds; do
IFS=$save_ifs
$opt_quiet || {
- func_quote_arg expand,pretty "$cmd"
- eval "func_echo $func_quote_arg_result"
+ func_quote_for_expand "$cmd"
+ eval "func_echo $func_quote_for_expand_result"
}
$opt_dry_run || eval "$cmd" || {
lt_exit=$?
@@ -10225,8 +10129,8 @@ EOF
eval cmd=\"$cmd\"
IFS=$save_ifs
$opt_quiet || {
- func_quote_arg expand,pretty "$cmd"
- eval "func_echo $func_quote_arg_result"
+ func_quote_for_expand "$cmd"
+ eval "func_echo $func_quote_for_expand_result"
}
$opt_dry_run || eval "$cmd" || {
lt_exit=$?
@@ -10700,12 +10604,12 @@ EOF
elif eval var_value=\$$var; test -z "$var_value"; then
relink_command="$var=; export $var; $relink_command"
else
- func_quote_arg pretty "$var_value"
- relink_command="$var=$func_quote_arg_result; export $var; $relink_command"
+ func_quote_for_eval "$var_value"
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
fi
done
- func_quote_arg pretty,unquoted "(cd `pwd`; $relink_command)"
- relink_command=$func_quote_arg_unquoted_result
+ relink_command="(cd `pwd`; $relink_command)"
+ relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
fi
# Only actually do things if not in dry run mode.
@@ -10945,14 +10849,13 @@ EOF
elif eval var_value=\$$var; test -z "$var_value"; then
relink_command="$var=; export $var; $relink_command"
else
- func_quote_arg pretty,unquoted "$var_value"
- relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"
+ func_quote_for_eval "$var_value"
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
fi
done
# Quote the link command for shipping.
relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
- func_quote_arg pretty,unquoted "$relink_command"
- relink_command=$func_quote_arg_unquoted_result
+ relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
if test yes = "$hardcode_automatic"; then
relink_command=
fi
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index e67ed6997..9d6dd9fce 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -4063,7 +4063,8 @@ _LT_EOF
if AC_TRY_EVAL(ac_compile); then
# Now try to grab the symbols.
nlist=conftest.nm
- if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
+ $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&AS_MESSAGE_LOG_FD
+ if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&AS_MESSAGE_LOG_FD && test -s "$nlist"; then
# Try sorting and uniquifying the output.
if sort "$nlist" | uniq > "$nlist"T; then
mv -f "$nlist"T "$nlist"
@@ -4703,6 +4704,12 @@ m4_if([$1], [CXX], [
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
;;
+ # flang / f18. f95 an alias for gfortran or flang on Debian
+ flang* | f18* | f95*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
# icc used to be incompatible with GCC.
# ICC 10 doesn't accept -KPIC any more.
icc* | ifort*)
diff --git a/ppd/HP-PhotoSmart_Pro_B8300-hpijs-pdftoijs.ppd b/ppd/HP-PhotoSmart_Pro_B8300-hpijs-pdftoijs.ppd
deleted file mode 100644
index 798181b2d..000000000
--- a/ppd/HP-PhotoSmart_Pro_B8300-hpijs-pdftoijs.ppd
+++ /dev/null
@@ -1,342 +0,0 @@
-*PPD-Adobe: "4.3"
-*%
-*FormatVersion: "4.3"
-*FileVersion: "1.1"
-*LanguageVersion: English
-*LanguageEncoding: ISOLatin1
-*PCFileName: "HPIJS.PPD"
-*Manufacturer: "HP"
-*Product: "(PhotoSmart Pro B8300)"
-*cupsVersion: 1.0
-*cupsManualCopies: True
-*cupsModelNumber: 2
-*cupsFilter: "application/vnd.cups-pdf 0 pdftoijs"
-*ModelName: "HP PhotoSmart Pro B8300"
-*ShortNickName: "HP PhotoSmart Pro B8300 hpijs"
-*NickName: "HP PhotoSmart Pro B8300 CUPS/pdftoijs/hpijs"
-*PSVersion: "(3010.000) 800"
-*LanguageLevel: "3"
-*ColorDevice: True
-*DefaultColorSpace: RGB
-*FileSystem: False
-*Throughput: "1"
-*LandscapeOrientation: Plus90
-*TTRasterizer: Type42
-*1284DeviceID: "DRV:Dhpijs,R1,M1,F1,Sv,TI,X1200,Y1200,C1,t90,l90,g100,p100,s70;"
-
-*driverName hpijs/hpijs - HP's IJS driver for most of their non-PostScript printers: ""
-*driverType I/IJS: ""
-*driverUrl: "http://hplipopensource.com/"
-*driverObsolete: False
-*driverSupplier: "Hewlett-Packard"
-*driverManufacturerSupplied: True
-*driverLicense: "BSD"
-*driverFreeSoftware: True
-*driverSupportContactVoluntary: "https://launchpad.net/hplip HPLIP support and bug tracking system"
-*driverMaxResolution: 1200 1200
-*driverColor: True
-*driverTextSupport: 90
-*driverLineartSupport: 90
-*driverGraphicsSupport: 100
-*driverPhotoSupport: 100
-*driverRenderingSpeed: 70
-
-*DefaultResolution: 1200dpi
-
-
-
-*HWMargins: 18 36 18 9
-*VariablePaperSize: True
-*MaxMediaWidth: 100000
-*MaxMediaHeight: 100000
-*NonUIOrderDependency: 105 AnySetup *CustomPageSize
-*CustomPageSize True: ""
-*ParamCustomPageSize Width: 1 points 36 100000
-*ParamCustomPageSize Height: 2 points 36 100000
-*ParamCustomPageSize Orientation: 3 int 0 0
-*ParamCustomPageSize WidthOffset: 4 points 0 0
-*ParamCustomPageSize HeightOffset: 5 points 0 0
-
-*ijsServer: "hpijs"
-*ijsManufacturer: "HP"
-*ijsModel: "deskjet 5600"
-*ijsColorSpace: "rgb"
-
-*OpenGroup: General/General
-
-*OpenUI *Quality/Resolution, Quality, Ink Type, Media Type: PickOne
-*OrderDependency: 100 AnySetup *Quality
-*DefaultQuality: 600ColorCMYK
-
-*Quality 300ColorCMYK/300 dpi, Color, Black + Color Cartr.: ""
-*ijsParams Quality=300ColorCMYK: "Quality:Quality=0,Quality:ColorMode=2,Quality:MediaType=0,Quality:PenSet=2"
-*ijsResolution Quality=300ColorCMYK: "300 300"
-
-*Quality 300ColorCMYKFullBleed/300 dpi, Color, Full Bleed, Black + Color Cartr.: ""
-*ijsParams Quality=300ColorCMYKFullbleed: "Quality:Quality=0,Quality:ColorMode=2,Quality:MediaType=0,Quality:PenSet=2,Quality:FullBleed=1"
-*ijsResolution Quality=300ColorCMYKFullbleed: "300 300"
-
-*Quality 300DraftColorCMYK/300 dpi, Draft, Color, Black + Color Cartr.: ""
-*ijsParams Quality=300DraftColorCMYK: "Quality:Quality=1,Quality:ColorMode=2,Quality:MediaType=0,Quality:PenSet=2"
-*ijsResolution Quality=300DraftColorCMYK: "300 300"
-
-*Quality 300DraftGrayscaleCMYK/300 dpi, Draft, Grayscale, Black + Color Cartr.: ""
-*ijsParams Quality=300DraftGrayscaleCMYK: "Quality:Quality=1,Quality:ColorMode=0,Quality:MediaType=0,Quality:PenSet=2"
-*ijsResolution Quality=300DraftGrayscaleCMYK: "300 300"
-
-*Quality 300FastDraftColorCMYK/300 dpi, FastDraft, Color, Black + Color Cartr.: ""
-*ijsParams Quality=300FastDraftColorCMYK: "Quality:Quality=4,Quality:ColorMode=2,Quality:MediaType=0,Quality:PenSet=2"
-*ijsResolution 300FastDraftColorCMYK: "300 300"
-
-*Quality 300FastDraftGrayscaleCMYK/300 dpi, FastDraft, Grayscale, Black + Color Cartr.: ""
-*ijsParams Quality=300FastDraftGrayscaleCMYK: "Quality:Quality=4,Quality:ColorMode=0,Quality:MediaType=0,Quality:PenSet=2"
-*ijsResolution Quality=300FastDraftGrayscaleCMYK: "300 300"
-
-*Quality 300GrayscaleCMYK/300 dpi, Grayscale, Black + Color Cartr.: ""
-*ijsParams Quality=300GrayscaleCMYK: "Quality:Quality=0,Quality:ColorMode=0,Quality:MediaType=0,Quality:PenSet=2"
-*ijsResolution Quality=300GrayscaleCMYK: "300 300"
-
-*Quality 600ColorCMYK/600 dpi, Color, Black + Color Cartr.: ""
-*ijsParams Quality=600ColorCMYK: "Quality:Quality=0,Quality:ColorMode=2,Quality:MediaType=0,Quality:PenSet=2"
-*ijsResolution Quality=600ColorCMYK: "600 600"
-
-*Quality 600ColorCMYKFullBleed/600 dpi, Color, Full Bleed, Black + Color Cartr.: ""
-*ijsParams Quality=600ColorCMYKFullbleed: "Quality:Quality=0,Quality:ColorMode=2,Quality:MediaType=0,Quality:PenSet=2,Quality:FullBleed=1"
-*ijsResolution Quality=600ColorCMYKFullbleed: "600 600"
-
-*Quality 600GrayscaleCMYK/600 dpi, Grayscale, Black + Color Cartr.: ""
-*ijsParams Quality=600GrayscaleCMYK: "Quality:Quality=0,Quality:ColorMode=0,Quality:MediaType=0,Quality:PenSet=2"
-*ijsResolution Quality=600GrayscaleCMYK: "600 600"
-
-*Quality 1200PhotoCMYK/1200 dpi, Photo, Black + Color Cartr., Photo Paper: ""
-*ijsParams Quality=1200PhotoCMYK: "Quality:Quality=3,Quality:ColorMode=2,Quality:MediaType=2,Quality:PenSet=2"
-*ijsResolution Quality=1200PhotoCMYK: "1200 1200"
-
-*Quality 1200PhotoCMYKFullBleed/1200 dpi, Photo, Full Bleed, Black + Color Cartr., Photo Paper: ""
-*ijsParams Quality=1200PhotoCMYKFullBleed: "Quality:Quality=3,Quality:ColorMode=2,Quality:MediaType=3,Quality:PenSet=2,Quality:FullBleed=1"
-*ijsResolution Quality=1200PhotoCMYKFullBleed: "1200 1200"
-
-*CloseUI: *Quality
-
-*OpenUI *InputSlot/Media Source: PickOne
-*OrderDependency: 100 AnySetup *InputSlot
-*DefaultInputSlot: Default
-
-*InputSlot Default/Printer default: ""
-*ijsParams InputSlot=Default: "PS:MediaPosition=7"
-
-*InputSlot PhotoTray/Photo Tray: ""
-*ijsParams InputSlot=PhotoTray: "PS:MediaPosition=6"
-
-*InputSlot Upper/Upper Tray: ""
-*ijsParams InputSlot=Upper: "PS:MediaPosition=1"
-
-*InputSlot Lower/Lower Tray: ""
-*ijsParams InputSlot=Lower: "PS:MediaPosition=4"
-
-*InputSlot CDDVDTray/CD or DVD Tray: ""
-*ijsParams InputSlot=CDDVDTray: "PS:MediaPosition=14"
-
-*InputSlot Envelope/Envelope Feeder: ""
-*ijsParams InputSlot=Envelope: "PS:MediaPosition=3"
-
-*InputSlot LargeCapacity/Large Capacity Tray: ""
-*ijsParams InputSlot=LargeCapacity: "PS:MediaPosition=5"
-
-*InputSlot Manual/Manual Feeder: ""
-*ijsParams InputSlot=Manual: "PS:MediaPosition=2"
-
-*InputSlot MPTray/Multi Purpose Tray: ""
-*ijsParams InputSlot=MPTray: "PS:MediaPosition=8"
-
-*CloseUI: *InputSlot
-
-*OpenUI *PageSize/Page Size: PickOne
-*OrderDependency: 105 AnySetup *PageSize
-*DefaultPageSize: Letter
-*PageSize Letter/Letter: ""
-*PageSize A4/A4: ""
-*PageSize Photo/Photo or 4x6 inch index card: ""
-*PageSize Photo5x7/Photo or 5x7 inch index card: ""
-*PageSize PhotoTearOff/Photo with tear-off tab: ""
-*PageSize 3x5/3x5 inch index card: ""
-*PageSize 5x8/5x8 inch index card: ""
-*PageSize A3/A3: ""
-*PageSize A5/A5: ""
-*PageSize A6/A6: ""
-*PageSize A6TearOff/A6 with tear-off tab: ""
-*PageSize B4JIS/B4 (JIS): ""
-*PageSize B5JIS/B5 (JIS): ""
-*PageSize CDDVD80/CD or DVD 80 mm: ""
-*PageSize CDDVD120/CD or DVD 120 mm: ""
-*PageSize Env10/Envelope #10: ""
-*PageSize EnvC5/Envelope C5: ""
-*PageSize EnvC6/Envelope C6: ""
-*PageSize EnvDL/Envelope DL: ""
-*PageSize EnvISOB5/Envelope B5: ""
-*PageSize EnvMonarch/Envelope Monarch: ""
-*PageSize Executive/Executive: ""
-*PageSize FLSA/American Foolscap: ""
-*PageSize Hagaki/Hagaki: ""
-*PageSize Ledger/Ledger: ""
-*PageSize Legal/Legal: ""
-*PageSize Oufuku/Oufuku-Hagaki: ""
-*PageSize SuperB/Super B: ""
-*PageSize w558h774/16K: ""
-*PageSize w612h935/Executive (JIS): ""
-*PageSize w774h1116/8K: ""
-*CloseUI: *PageSize
-
-*OpenUI *PageRegion: PickOne
-*OrderDependency: 105 AnySetup *PageRegion
-*DefaultPageRegion: Letter
-*PageRegion Letter/Letter: ""
-*PageRegion A4/A4: ""
-*PageRegion Photo/Photo or 4x6 inch index card: ""
-*PageRegion Photo5x7/Photo or 5x7 inch index card: ""
-*PageRegion PhotoTearOff/Photo with tear-off tab: ""
-*PageRegion 3x5/3x5 inch index card: ""
-*PageRegion 5x8/5x8 inch index card: ""
-*PageRegion A3/A3: ""
-*PageRegion A5/A5: ""
-*PageRegion A6/A6: ""
-*PageRegion A6TearOff/A6 with tear-off tab: ""
-*PageRegion B4JIS/B4 (JIS): ""
-*PageRegion B5JIS/B5 (JIS): ""
-*PageRegion CDDVD80/CD or DVD 80 mm: ""
-*PageRegion CDDVD120/CD or DVD 120 mm: ""
-*PageRegion Env10/Envelope #10: ""
-*PageRegion EnvC5/Envelope C5: ""
-*PageRegion EnvC6/Envelope C6: ""
-*PageRegion EnvDL/Envelope DL: ""
-*PageRegion EnvISOB5/Envelope B5: ""
-*PageRegion EnvMonarch/Envelope Monarch: ""
-*PageRegion Executive/Executive: ""
-*PageRegion FLSA/American Foolscap: ""
-*PageRegion Hagaki/Hagaki: ""
-*PageRegion Ledger/Ledger: ""
-*PageRegion Legal/Legal: ""
-*PageRegion Oufuku/Oufuku-Hagaki: ""
-*PageRegion SuperB/Super B: ""
-*PageRegion w558h774/16K: ""
-*PageRegion w612h935/Executive (JIS): ""
-*PageRegion w774h1116/8K: ""
-*CloseUI: *PageRegion
-
-*DefaultImageableArea: Letter
-*ImageableArea Letter/Letter: "18 36 594 783"
-*ImageableArea A4/A4: "9.72 36 585.28 833"
-*ImageableArea Photo/Photo or 4x6 inch index card: "0 36 288 432"
-*ImageableArea Photo5x7/Photo or 5x7 inch index card: "0 36 360 504"
-*ImageableArea PhotoTearOff/Photo with tear-off tab: "0 0 288 432"
-*ImageableArea 3x5/3x5 inch index card: "0 36 216 360"
-*ImageableArea 5x8/5x8 inch index card: "0 36 360 576"
-*ImageableArea A3/A3: "14.40 36.00 827.60 1181"
-*ImageableArea A5/A5: "9 36 411 586"
-*ImageableArea A6/A6: "0 36 297 420"
-*ImageableArea A6TearOff/A6 with tear-off tab: "0 0 297 420"
-*ImageableArea B4JIS/B4 (JIS): "18 36 711 1024"
-*ImageableArea B5JIS/B5 (JIS): "18 36 498 720"
-*ImageableArea CDDVD80/CD or DVD 80 mm: "0 36 237 237"
-*ImageableArea CDDVD120/CD or DVD 120 mm: "0 36 360 360"
-*ImageableArea Env10/Envelope #10: "0 36 297 684"
-*ImageableArea EnvC5/Envelope C5: "18 36 441 640"
-*ImageableArea EnvC6/Envelope C6: "0 36 323 459"
-*ImageableArea EnvDL/Envelope DL: "0 36 312 624"
-*ImageableArea EnvISOB5/Envelope B5: "18 36 481 700"
-*ImageableArea EnvMonarch/Envelope Monarch: "0 36 279 540"
-*ImageableArea Executive/Executive: "18 36 504 747"
-*ImageableArea FLSA/American Foolscap: "18 36 594 927"
-*ImageableArea Hagaki/Hagaki: "0 36 283 420"
-*ImageableArea Ledger/Ledger: "14.40 36 777.60 1215"
-*ImageableArea Legal/Legal: "18 36 594 999"
-*ImageableArea Oufuku/Oufuku-Hagaki: "0 36 420 567"
-*ImageableArea SuperB/Super B: "14.40 36 921.60 1359"
-*ImageableArea w558h774/16K: "18 36 540 765"
-*ImageableArea w612h935/Executive (JIS): "18 36 594 926"
-*ImageableArea w774h1116/8K: "18 36 756 1107"
-
-*DefaultPaperDimension: Letter
-*PaperDimension Letter/Letter: "612 792"
-*PaperDimension A4/A4: "595 842"
-*PaperDimension Photo/Photo or 4x6 inch index card: "288 432"
-*PaperDimension Photo5x7/Photo or 5x7 inch index card: "360 504"
-*PaperDimension PhotoTearOff/Photo with tear-off tab: "288 432"
-*PaperDimension 3x5/3x5 inch index card: "216 360"
-*PaperDimension 5x8/5x8 inch index card: "360 576"
-*PaperDimension A3/A3: "842 1190"
-*PaperDimension A5/A5: "420 595"
-*PaperDimension A6/A6: "297 420"
-*PaperDimension A6TearOff/A6 with tear-off tab: "297 420"
-*PaperDimension B4JIS/B4 (JIS): "729 1033"
-*PaperDimension B5JIS/B5 (JIS): "516 729"
-*PaperDimension CDDVD80/CD or DVD 80 mm: "237 237"
-*PaperDimension CDDVD120/CD or DVD 120 mm: "360 360"
-*PaperDimension Env10/Envelope #10: "297 684"
-*PaperDimension EnvC5/Envelope C5: "459 649"
-*PaperDimension EnvC6/Envelope C6: "323 459"
-*PaperDimension EnvDL/Envelope DL: "312 624"
-*PaperDimension EnvISOB5/Envelope B5: "499 709"
-*PaperDimension EnvMonarch/Envelope Monarch: "279 540"
-*PaperDimension Executive/Executive: "522 756"
-*PaperDimension FLSA/American Foolscap: "612 936"
-*PaperDimension Hagaki/Hagaki: "283 420"
-*PaperDimension Ledger/Ledger: "792 1224"
-*PaperDimension Legal/Legal: "612 1008"
-*PaperDimension Oufuku/Oufuku-Hagaki: "420 567"
-*PaperDimension SuperB/Super B: "936 1368"
-*PaperDimension w558h774/16K: "558 774"
-*PaperDimension w612h935/Executive (JIS): "612 935"
-*PaperDimension w774h1116/8K: "774 1116"
-
-*OpenUI *Duplex/Double-Sided Printing: PickOne
-*FoomaticRIPOption Duplex: enum CmdLine A
-*OrderDependency: 120 AnySetup *Duplex
-*DefaultDuplex: None
-*Duplex DuplexNoTumble/Long Edge (Standard): ""
-*Duplex DuplexTumble/Short Edge (Flip): ""
-*Duplex None/Off: ""
-*CloseUI: *Duplex
-
-*CloseGroup: General
-
-
-*% Generic boilerplate PPD stuff as standard PostScript fonts and so on
-
-*DefaultFont: Courier
-*Font AvantGarde-Book: Standard "(001.006S)" Standard ROM
-*Font AvantGarde-BookOblique: Standard "(001.006S)" Standard ROM
-*Font AvantGarde-Demi: Standard "(001.007S)" Standard ROM
-*Font AvantGarde-DemiOblique: Standard "(001.007S)" Standard ROM
-*Font Bookman-Demi: Standard "(001.004S)" Standard ROM
-*Font Bookman-DemiItalic: Standard "(001.004S)" Standard ROM
-*Font Bookman-Light: Standard "(001.004S)" Standard ROM
-*Font Bookman-LightItalic: Standard "(001.004S)" Standard ROM
-*Font Courier: Standard "(002.004S)" Standard ROM
-*Font Courier-Bold: Standard "(002.004S)" Standard ROM
-*Font Courier-BoldOblique: Standard "(002.004S)" Standard ROM
-*Font Courier-Oblique: Standard "(002.004S)" Standard ROM
-*Font Helvetica: Standard "(001.006S)" Standard ROM
-*Font Helvetica-Bold: Standard "(001.007S)" Standard ROM
-*Font Helvetica-BoldOblique: Standard "(001.007S)" Standard ROM
-*Font Helvetica-Narrow: Standard "(001.006S)" Standard ROM
-*Font Helvetica-Narrow-Bold: Standard "(001.007S)" Standard ROM
-*Font Helvetica-Narrow-BoldOblique: Standard "(001.007S)" Standard ROM
-*Font Helvetica-Narrow-Oblique: Standard "(001.006S)" Standard ROM
-*Font Helvetica-Oblique: Standard "(001.006S)" Standard ROM
-*Font NewCenturySchlbk-Bold: Standard "(001.009S)" Standard ROM
-*Font NewCenturySchlbk-BoldItalic: Standard "(001.007S)" Standard ROM
-*Font NewCenturySchlbk-Italic: Standard "(001.006S)" Standard ROM
-*Font NewCenturySchlbk-Roman: Standard "(001.007S)" Standard ROM
-*Font Palatino-Bold: Standard "(001.005S)" Standard ROM
-*Font Palatino-BoldItalic: Standard "(001.005S)" Standard ROM
-*Font Palatino-Italic: Standard "(001.005S)" Standard ROM
-*Font Palatino-Roman: Standard "(001.005S)" Standard ROM
-*Font Symbol: Special "(001.007S)" Special ROM
-*Font Times-Bold: Standard "(001.007S)" Standard ROM
-*Font Times-BoldItalic: Standard "(001.009S)" Standard ROM
-*Font Times-Italic: Standard "(001.007S)" Standard ROM
-*Font Times-Roman: Standard "(001.007S)" Standard ROM
-*Font ZapfChancery-MediumItalic: Standard "(001.007S)" Standard ROM
-*Font ZapfDingbats: Special "(001.004S)" Standard ROM
-
diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c
index c1921d6f5..db335aefa 100644
--- a/utils/cups-browsed.c
+++ b/utils/cups-browsed.c
@@ -66,54 +66,54 @@
#ifdef HAVE_LDAP
-LDAP *BrowseLDAPHandle = NULL;
- /* Handle to LDAP server */
-char *BrowseLDAPBindDN = NULL,
- /* LDAP login DN */
- *BrowseLDAPDN = NULL,
- /* LDAP search DN */
- *BrowseLDAPPassword = NULL,
- /* LDAP login password */
- *BrowseLDAPServer = NULL,
- /* LDAP server to use */
- *BrowseLDAPFilter = NULL;
- /* LDAP query filter */
-int BrowseLDAPUpdate = TRUE,
- /* enables LDAP updates */
- BrowseLDAPInitialised = FALSE;
- /* the init stuff has been done */
+LDAP *BrowseLDAPHandle = NULL;
+ /* Handle to LDAP server */
+char *BrowseLDAPBindDN = NULL,
+ /* LDAP login DN */
+ *BrowseLDAPDN = NULL,
+ /* LDAP search DN */
+ *BrowseLDAPPassword = NULL,
+ /* LDAP login password */
+ *BrowseLDAPServer = NULL,
+ /* LDAP server to use */
+ *BrowseLDAPFilter = NULL;
+ /* LDAP query filter */
+int BrowseLDAPUpdate = TRUE,
+ /* enables LDAP updates */
+ BrowseLDAPInitialised = FALSE;
+ /* the init stuff has been done */
# ifdef HAVE_LDAP_SSL
-char *BrowseLDAPCACertFile = NULL;
- /* LDAP CA CERT file to use */
+char *BrowseLDAPCACertFile = NULL;
+ /* LDAP CA CERT file to use */
# endif /* HAVE_LDAP_SSL */
#endif /* HAVE_LDAP */
#ifdef HAVE_LDAP
#define LDAP_BROWSE_FILTER "(objectclass=cupsPrinter)"
-static LDAP *ldap_connect(void);
-static LDAP *ldap_reconnect(void);
-static void ldap_disconnect(LDAP *ld);
-static int ldap_search_rec(LDAP *ld, char *base, int scope,
- char *filter, char *attrs[],
- int attrsonly, LDAPMessage **res);
-static int ldap_getval_firststring(LDAP *ld, LDAPMessage *entry,
- char *attr, char *retval,
- unsigned long maxsize);
-static void ldap_freeres(LDAPMessage *entry);
+static LDAP *ldap_connect(void);
+static LDAP *ldap_reconnect(void);
+static void ldap_disconnect(LDAP *ld);
+static int ldap_search_rec(LDAP *ld, char *base, int scope,
+ char *filter, char *attrs[],
+ int attrsonly, LDAPMessage **res);
+static int ldap_getval_firststring(LDAP *ld, LDAPMessage *entry,
+ char *attr, char *retval,
+ unsigned long maxsize);
+static void ldap_freeres(LDAPMessage *entry);
# ifdef HAVE_LDAP_REBIND_PROC
# if defined(LDAP_API_FEATURE_X_OPENLDAP) && (LDAP_API_VERSION > 2000)
-static int ldap_rebind_proc(LDAP *RebindLDAPHandle,
- LDAP_CONST char *refsp,
- ber_tag_t request,
- ber_int_t msgid,
- void *params);
+static int ldap_rebind_proc(LDAP *RebindLDAPHandle,
+ LDAP_CONST char *refsp,
+ ber_tag_t request,
+ ber_int_t msgid,
+ void *params);
# else
-static int ldap_rebind_proc(LDAP *RebindLDAPHandle,
- char **dnp,
- char **passwdp,
- int *authmethodp,
- int freeit,
+static int ldap_rebind_proc(LDAP *RebindLDAPHandle,
+ char **dnp,
+ char **passwdp,
+ int *authmethodp,
+ int freeit,
void *arg);
# endif /* defined(LDAP_API_FEATURE_X_OPENLDAP) && (LDAP_API_VERSION > 2000) */
# endif /* HAVE_LDAP_REBIND_PROC */
@@ -128,6 +128,7 @@ static int ldap_rebind_proc(LDAP *RebindLDAPHandle,
/* Attribute to mark a CUPS queue as created by us */
#define CUPS_BROWSED_MARK "cups-browsed"
+#define AUTO_OPTION "auto"
/* Attribute to tell the implicitclass backend the destination queue for
the current job */
@@ -154,11 +155,11 @@ static int ldap_rebind_proc(LDAP *RebindLDAPHandle,
/* Status of remote printer */
typedef enum printer_status_e {
- STATUS_UNCONFIRMED = 0, /* Generated in a previous session */
- STATUS_CONFIRMED, /* Avahi confirms UNCONFIRMED printer */
- STATUS_TO_BE_CREATED, /* Scheduled for creation */
- STATUS_DISAPPEARED, /* Scheduled for removal */
- STATUS_TO_BE_RELEASED /* Scheduled for release from cups-browsed */
+ STATUS_UNCONFIRMED = 0, /* Generated in a previous session */
+ STATUS_CONFIRMED, /* Avahi confirms UNCONFIRMED printer */
+ STATUS_TO_BE_CREATED, /* Scheduled for creation */
+ STATUS_DISAPPEARED, /* Scheduled for removal */
+ STATUS_TO_BE_RELEASED /* Scheduled for release from cups-browsed */
} printer_status_t;
/* Data structure for remote printers */
@@ -329,6 +330,44 @@ typedef enum autoshutdown_inactivity_type_e {
NO_JOBS
} autoshutdown_inactivity_type_t;
+typedef struct media_size_s{
+ int x;
+ int y;
+}media_size_t;
+
+typedef struct pagesize_range_s{
+ int x_dim_min;
+ int x_dim_max;
+ int y_dim_min;
+ int y_dim_max;
+}pagesize_range_t;
+
+typedef struct media_col_s{
+ int x,y,top_margin,bottom_margin,left_margin,right_margin;
+ char *media_source,*media_type;
+}media_col_t;
+
+typedef struct default_str_attribute_s{
+ char* value;
+ int count;
+}default_str_attribute_t;
+
+typedef struct resolution_count_s{
+ res_t *res;
+ int count;
+}resolution_count_t;
+
+typedef struct mediacol_count_s{
+ media_col_t *data;
+ int count;
+}mediacol_count_t;
+
+typedef struct pagesize_count_s{
+ char* pagesize;
+ int count;
+}pagesize_count_t;
+
+
cups_array_t *remote_printers;
static char *alt_config_file = NULL;
static cups_array_t *command_line_config;
@@ -359,14 +398,14 @@ static int avahi_present = 0;
#endif /* HAVE_AVAHI */
#ifdef HAVE_LDAP
static const char * const ldap_attrs[] =/* CUPS LDAP attributes */
- {
- "printerDescription",
- "printerLocation",
- "printerMakeAndModel",
- "printerType",
- "printerURI",
- NULL
- };
+ {
+ "printerDescription",
+ "printerLocation",
+ "printerMakeAndModel",
+ "printerType",
+ "printerURI",
+ NULL
+ };
#endif /* HAVE_LDAP */
static guint queues_timer_id = 0;
static int browsesocket = -1;
@@ -406,7 +445,7 @@ static cups_array_t *clusters;
static load_balancing_type_t LoadBalancingType = QUEUE_ON_CLIENT;
static char *DefaultOptions = NULL;
static int terminating = 0; /* received SIGTERM, ignore callbacks,
- break loops */
+ break loops */
static int in_shutdown = 0;
static int autoshutdown = 0;
static int autoshutdown_avahi = 0;
@@ -426,6 +465,27 @@ static char remote_default_printer_file[1024];
static char save_options_file[1024];
static char debug_log_file[1024];
+/*Contains ppd keywords which are written by ppdgenerator.c in the ppd file.*/
+static char* ppd_keywords[] =
+ {
+ "PageSize",
+ "PageRegion",
+ "InputSlot",
+ "MediaType",
+ "ColorModel",
+ "Duplex",
+ "OutputBin",
+ "StapleLocation",
+ "FoldType",
+ "PunchMedia",
+ "Booklet",
+ "cupsFinishingTemplate",
+ "cupsPrintQuality",
+ "print-content-optimize",
+ "print-rendering-intent",
+ "print-scaling",
+ };
+
/* Static global variable for indicating we have reached the HTTP timeout */
static int timeout_reached = 0;
@@ -451,6 +511,19 @@ static remote_printer_t
#endif
/*
+ * Option 'printer-is-shared' cannot be set on remote CUPS
+ * queue and requests for setting it ends with error since
+ * 2.1.1. Define HAVE_CUPS_2_2 to do not send IPP request
+ * for setting 'printer-is-shared' option on remote CUPS queues
+ * for newer versions of CUPS.
+ */
+#if (CUPS_VERSION_MAJOR > 2) || (CUPS_VERSION_MINOR > 1)
+#define HAVE_CUPS_2_2 1
+#else
+#define HAVE_CUPS_2_2 0
+#endif
+
+/*
* CUPS 1.6 makes various structures private and
* introduces these ippGet and ippSet functions
* for all of the fields in these structures.
@@ -516,7 +589,7 @@ ippGetString(ipp_attribute_t *attr,
return (attr->values[element].string.text);
}
-ipp_attribute_t *
+ipp_attribute_t *
ippFirstAttribute(ipp_t *ipp)
{
if (!ipp)
@@ -583,7 +656,7 @@ start_debug_logging()
lfp = fopen(debug_log_file, "a+");
if (lfp == NULL) {
fprintf(stderr, "cups-browsed: ERROR: Failed creating debug log file %s\n",
- debug_log_file);
+ debug_log_file);
exit(1);
}
}
@@ -621,6 +694,449 @@ debug_printf(const char *format, ...) {
}
}
}
+/*
+ * 'create_media_size()' - Create a media-size value.
+ */
+
+static ipp_t * /* O - media-col collection */
+create_media_size(int width, /* I - x-dimension in 2540ths */
+ int length) /* I - y-dimension in 2540ths */
+{
+ ipp_t *media_size = ippNew(); /* media-size value */
+
+ ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "x-dimension",
+ width);
+ ippAddInteger(media_size, IPP_TAG_PRINTER, IPP_TAG_INTEGER, "y-dimension",
+ length);
+
+ return (media_size);
+}
+
+/*
+ * 'create_media_range()' - Create a pagesize-range value.
+ */
+
+static ipp_t *
+create_media_range(int x_dim_min_width,
+ int x_dim_max_width,
+ int y_dim_min_height,
+ int y_dim_max_height)
+{
+ ipp_t *media_size = ippNew();
+ ippAddRange(media_size, IPP_TAG_PRINTER, "x-dimension",
+ x_dim_min_width, x_dim_max_width);
+ ippAddRange(media_size, IPP_TAG_PRINTER, "y-dimension",
+ y_dim_min_height, y_dim_max_height);
+ return (media_size);
+}
+
+void *
+copy_media_size(void *size, void *user_data)
+{
+ media_size_t *data = (media_size_t *)size;
+ media_size_t *copy;
+
+ copy = (media_size_t *)calloc(1, sizeof(media_size_t));
+ if (copy) {
+ copy->x = data->x;
+ copy->y = data->y;
+ }
+ return copy;
+}
+
+void*
+copy_range_size(void *range, void* user_data)
+{
+ pagesize_range_t *data = (pagesize_range_t *)range;
+ pagesize_range_t *copy;
+
+ copy = (pagesize_range_t *)calloc(1,sizeof(pagesize_range_t));
+ if (copy) {
+ copy->x_dim_min = data->x_dim_min;
+ copy->x_dim_max = data->x_dim_max;
+ copy->y_dim_min = data->y_dim_min;
+ copy->y_dim_max = data->y_dim_max;
+ }
+ return copy;
+}
+
+void *
+copy_media(void *media, void *user_data)
+{
+ media_col_t *data = (media_col_t *)media;
+ media_col_t *copy;
+
+ copy = (media_col_t *)calloc(1, sizeof(media_col_t));
+ if (copy) {
+ copy->x = data->x;
+ copy->y = data->y;
+ copy->left_margin=data->left_margin;
+ copy->right_margin=data->right_margin;
+ copy->top_margin=data->top_margin;
+ copy->bottom_margin=data->bottom_margin;
+ copy->media_source = NULL;
+ copy->media_type = NULL;
+ if (data->media_source != NULL) {
+ copy->media_source = (char *)malloc(sizeof(char)*32);
+ strcpy(copy->media_source,data->media_source);
+ }
+ if (data->media_type != NULL) {
+ copy->media_type = (char *)malloc(sizeof(char)*32);;
+ strcpy(copy->media_type,data->media_type);
+ }
+ }
+ return copy;
+}
+
+void* copy_media_count(void *media, void* user_data)
+{
+ mediacol_count_t *prev = (mediacol_count_t *)media;
+ mediacol_count_t *copy;
+
+ copy = (mediacol_count_t*)calloc(1,sizeof(mediacol_count_t));
+ if (copy) {
+ copy->data = copy_media(prev->data,NULL);
+ copy->count = prev->count;
+ }
+ return copy;
+}
+
+void* copy_pagesize_count(void *pagesize_count, void* user_data)
+{
+ pagesize_count_t *prev = (pagesize_count_t *)pagesize_count;
+ pagesize_count_t *copy;
+
+ copy = (pagesize_count_t*)calloc(1,sizeof(pagesize_count_t));
+ copy->pagesize = malloc(sizeof(char)*32);
+ if (copy) {
+ strcpy(copy->pagesize,prev->pagesize);
+ copy->count = prev->count;
+ }
+ return copy;
+}
+
+int compare_pagesize_count(void* pagesize_a, void* pagesize_b,void* user_data)
+{
+ pagesize_count_t *a = (pagesize_count_t *) pagesize_a;
+ pagesize_count_t *b = (pagesize_count_t *) pagesize_b;
+
+ if (!strcmp(a->pagesize,b->pagesize))
+ return 0;
+ return 1;
+}
+
+/*
+ * 'create_media_col()' - Create a media-col value.
+ */
+
+static ipp_t *
+create_media_col(int width,
+ int length,
+ int left_margin,
+ int right_margin,
+ int top_margin,
+ int bottom_margin,
+ char *media_source,
+ char *media_type)
+{
+ ipp_t *media_col = ippNew(), /* media-col value */
+ *media_size = create_media_size(width, length);
+
+ ippAddCollection(media_col, IPP_TAG_PRINTER, "media-size", media_size);
+ ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-bottom-margin",bottom_margin);
+ ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-left-margin", left_margin);
+ ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-right-margin",right_margin);
+ ippAddInteger(media_col, IPP_TAG_PRINTER, IPP_TAG_INTEGER,
+ "media-top-margin", top_margin);
+ if (media_source != NULL)
+ ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "media-source", NULL,media_source);
+ if (media_type != NULL)
+ ippAddString(media_col, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "media-type", NULL,media_type);
+ ippDelete(media_size);
+
+ return (media_col);
+}
+
+int
+compare_mediasize(void *media_a, void *media_b,
+ void *user_data)
+{
+ media_size_t *a=(media_size_t *)media_a;
+ media_size_t *b=(media_size_t *)media_b;
+
+ if (a->x < b->x)
+ return -1;
+ else if (a->x > b->x)
+ return 1;
+ else{
+ if (a->y == b->y)
+ return 0;
+ else if (a->y < b->y)
+ return -1;
+ return 1;
+ }
+}
+
+int compare_int(int a, int b)
+{
+ if (a < b)
+ return -1;
+ else if (a > b)
+ return 1;
+ return 0;
+}
+
+int compare_rangesize(void *range_a,void *range_b,
+ void *user_data)
+{
+ pagesize_range_t *a = (pagesize_range_t *)range_a;
+ pagesize_range_t *b = (pagesize_range_t *)range_b;
+ int value;
+
+ if ((value = compare_int(a->x_dim_min, b->x_dim_min)) == 0) {
+ if ((value = compare_int(a->x_dim_max, b->x_dim_max)) == 0) {
+ if ((value = compare_int(a->y_dim_min, b->y_dim_min)) == 0) {
+ if ((value = compare_int(a->y_dim_max, b->y_dim_max)) == 0) {
+ return 0;
+ }
+ }
+ }
+ }
+ return value;
+}
+
+int compare_media(void *media_a, void *media_b,
+ void *user_data)
+{
+ media_col_t *a=(media_col_t *)media_a;
+ media_col_t *b=(media_col_t *)media_b;
+ int value;
+
+ if ((value = compare_int(a->x, b->x)) == 0) {
+ if ((value = compare_int(a->y, b->y)) == 0) {
+ if ((value = compare_int(a->top_margin, b->top_margin)) == 0) {
+ if ((value = compare_int(a->bottom_margin, b->bottom_margin)) == 0) {
+ if ((value = compare_int(a->right_margin, b->right_margin)) == 0) {
+ if ((value = compare_int(a->left_margin, b->left_margin)) == 0) {
+ if (a->media_source == NULL && b->media_source == NULL) {
+ if (a->media_type == NULL && b->media_type == NULL)
+ return 0;
+ if (a->media_type == NULL)
+ return -1;
+ if (b->media_type == NULL)
+ return 1;
+ return strcmp(a->media_type, b->media_type);
+ }
+ if (a->media_source == NULL)
+ return -1;
+ if (b->media_source == NULL)
+ return 1;
+ if (!strcmp(a->media_source, b->media_source)) {
+ if (a->media_type==NULL && b->media_type == NULL)
+ return 0;
+ if (a->media_type==NULL)
+ return -1;
+ if (b->media_type==NULL)
+ return 1;
+ return strcmp(a->media_type, b->media_type);
+ }
+ else
+ return strcmp(a->media_source, b->media_source);
+ }
+ }
+ }
+ }
+ }
+ }
+ return value;
+}
+
+int compare_media_count(void* media_a, void* media_b,void* user_data)
+{
+ mediacol_count_t *a = (mediacol_count_t*) media_a;
+ mediacol_count_t *b = (mediacol_count_t*) media_b;
+
+ return (compare_media(a->data, b->data, NULL));
+}
+
+void *
+copy_default_str(void *data, void *user_data)
+{
+ default_str_attribute_t *prev = (default_str_attribute_t *)data;
+ default_str_attribute_t *copy;
+
+ copy = (default_str_attribute_t *)calloc(1, sizeof(default_str_attribute_t));
+ if (copy) {
+ copy->value = (char *)malloc(sizeof(char)*100);
+ copy->value = strdup(prev->value);
+ copy->count = prev->count;
+ }
+ return copy;
+}
+
+
+int
+compare_default_str(void *defstr_a, void *defstr_b,
+ void *user_data)
+{
+ default_str_attribute_t *a=(default_str_attribute_t *)defstr_a;
+ default_str_attribute_t *b=(default_str_attribute_t *)defstr_b;
+
+ return strcmp(a->value, b->value);
+}
+
+void *
+copy_counted_res(void *data, void *user_data)
+{
+ resolution_count_t *prev = (resolution_count_t *)data;
+ resolution_count_t *copy;
+
+ copy = (resolution_count_t *)calloc(1, sizeof(resolution_count_t));
+ if (copy) {
+ copy->res = (res_t *)malloc(sizeof(res_t));
+ copy->res->x = prev->res->x;
+ copy->res->y = prev->res->y;
+ copy->count = prev->count;
+ }
+ return copy;
+}
+
+
+int
+compare_counted_res(void *defres_a, void *defres_b,
+ void *user_data)
+{
+ resolution_count_t *a=(resolution_count_t *)defres_a;
+ resolution_count_t *b=(resolution_count_t *)defres_b;
+
+ return compare_resolutions(a->res, b->res, NULL);
+}
+
+/*
+ * 'pwg_compare_sizes()' - Compare two media sizes...
+ */
+
+static int /* O - Result of comparison */
+pwg_compare_sizes(cups_size_t *a, /* I - First media size */
+ cups_size_t *b) /* I - Second media size */
+{
+ return (strcmp(a->media, b->media));
+}
+
+
+/*
+ * 'pwg_copy_size()' - Copy a media size.
+ */
+
+static cups_size_t * /* O - New media size */
+pwg_copy_size(cups_size_t *size) /* I - Media size to copy */
+{
+ cups_size_t *newsize = (cups_size_t *)calloc(1, sizeof(cups_size_t));
+ /* New media size */
+
+ if (newsize)
+ memcpy(newsize, size, sizeof(cups_size_t));
+
+ return (newsize);
+}
+
+/* Function returns number of jobs queued on printer*/
+int /* O - Number of jobs */
+get_number_of_jobs(http_t *http, /* I - Connection to server */
+ const char *uri, /* I - uri of printer */
+ int myjobs, /* I - 0 = all users, 1 = mine */
+ int whichjobs) /* I - @code CUPS_WHICHJOBS_ALL@, @code CUPS_WHICHJOBS_ACTIVE@, or @code CUPS_WHICHJOBS_COMPLETED@ */
+{
+ int n; /* Number of jobs */
+ ipp_t *request, /* IPP Request */
+ *response; /* IPP Response */
+ ipp_attribute_t *attr; /* Current attribute */
+ int id; /* job-id */
+ static const char * const attrs[] = /* Requested attributes */
+ {
+ "job-id"
+ };
+
+ httpReconnect2(http, 30000, NULL);
+
+ /*
+ * Build an IPP_GET_JOBS request, which requires the following
+ * attributes:
+ *
+ * attributes-charset
+ * attributes-natural-language
+ * printer-uri
+ * requesting-user-name
+ * which-jobs
+ * my-jobs
+ * requested-attributes
+ */
+
+
+ /* Generating IPP Request */
+ request = ippNewRequest(IPP_OP_GET_JOBS);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
+ "printer-uri", NULL, uri);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+ "requesting-user-name", NULL, cupsUser());
+ if (myjobs)
+ ippAddBoolean(request, IPP_TAG_OPERATION, "my-jobs", 1);
+ if (whichjobs == CUPS_WHICHJOBS_COMPLETED)
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "which-jobs", NULL, "completed");
+ else if (whichjobs == CUPS_WHICHJOBS_ALL)
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "which-jobs", NULL, "all");
+ ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "requested-attributes", sizeof(attrs) / sizeof(attrs[0]),
+ NULL, attrs);
+
+ /* Do the request and get back a response... */
+ n = 0;
+ if ((response = cupsDoRequest(http, request, "/")) != NULL) {
+ for (attr = ippFirstAttribute(response); attr;
+ attr = ippNextAttribute(response)){
+ /* Skip leading attributes until we hit a job... */
+ while (attr && ippGetGroupTag(attr) != IPP_TAG_JOB)
+ attr = ippNextAttribute(response);
+
+ if (!attr)
+ break;
+ /* Pull the needed attributes from this job */
+ id = 0;
+ while (attr && ippGetGroupTag(attr) == IPP_TAG_JOB) {
+ if (!strcmp(ippGetName(attr), "job-id") &&
+ ippGetValueTag(attr) == IPP_TAG_INTEGER)
+ id = ippGetInteger(attr,0);
+ attr = ippNextAttribute(response);
+ }
+
+ /* See if we have everything needed */
+ if (!id){
+ if (!attr)
+ break;
+ else
+ continue;
+ }
+ /* Incrementing number of jobs*/
+ n ++;
+ if (!attr)
+ break;
+ }
+
+ ippDelete(response);
+ }
+
+ if (n == 0)
+ return (-1);
+ else
+ return (n);
+}
static const char *
password_callback (const char *prompt,
@@ -673,6 +1189,2069 @@ http_close_local (void)
}
}
+int /* O - 1 on match, 0 otherwise */
+_cups_isalpha(int ch) /* I - Character to test */
+{
+ return ((ch >= 'A' && ch <= 'Z') ||
+ (ch >= 'a' && ch <= 'z'));
+}
+
+int /* O - 1 on match, 0 otherwise */
+_cups_islower(int ch) /* I - Character to test */
+{
+ return (ch >= 'a' && ch <= 'z');
+}
+
+int /* O - Converted character */
+_cups_toupper(int ch) /* I - Character to convert */
+{
+ return (_cups_islower(ch) ? ch - 'a' + 'A' : ch);
+}
+
+static void
+pwg_ppdize_name(const char *ipp, /* I - IPP keyword */
+ char *name, /* I - Name buffer */
+ size_t namesize) /* I - Size of name buffer */
+{
+ char *ptr, /* Pointer into name buffer */
+ *end; /* End of name buffer */
+ *name = (char)toupper(*ipp++);
+
+ for (ptr = name + 1, end = name + namesize - 1; *ipp && ptr < end;)
+ {
+ if (*ipp == '-' && _cups_isalpha(ipp[1]))
+ {
+ ipp ++;
+ *ptr++ = (char)toupper(*ipp++ & 255);
+ }
+ else
+ *ptr++ = *ipp++;
+ }
+
+ *ptr = '\0';
+}
+
+void add_mimetype_attributes(char* cluster_name, ipp_t **merged_attributes)
+{
+ int count,i;
+ remote_printer_t *p;
+ const char *str;
+ char *q;
+ cups_array_t *list;
+ ipp_attribute_t *attr;
+ int num_value,attr_no;
+ char* attributes[] = {
+ "document-format-supported"
+ };
+
+ for (attr_no = 0; attr_no < 1; attr_no++) {
+ if ((list = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return ;
+
+ num_value=0;
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute(p->prattrs,attributes[attr_no], IPP_TAG_MIMETYPE)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i ++) {
+ str = ippGetString(attr, i, NULL);
+ if (!cupsArrayFind(list, (void *)str)){
+ cupsArrayAdd(list, (void *)str);
+ num_value++;
+ }
+ }
+ }
+ }
+ if (num_value != 0){
+ char *values[num_value];
+ for (q = (char *)cupsArrayFirst(list),i=0;
+ q;
+ q = (char *)cupsArrayNext(list),i++) {
+ values[i]=malloc(sizeof(char)*strlen(q)+1);
+ strncpy(values[i],q,strlen(q)+1);
+ }
+ ippAddStrings(*merged_attributes, IPP_TAG_PRINTER,IPP_TAG_MIMETYPE,
+ attributes[attr_no], num_value, NULL,
+ (const char * const *)values);
+ }
+ }
+ cupsArrayDelete(list);
+}
+
+/*add_tagzero_attributes - Adds attribute to the merged_attribute variable for the cluster.
+ This function adds attribute with value tag IPP_TAG_ZERO */
+void add_tagzero_attributes(char* cluster_name,ipp_t **merged_attributes)
+{
+ int count,i;
+ remote_printer_t *p;
+ const char *str;
+ char *q;
+ cups_array_t *list;
+ ipp_attribute_t *attr;
+ int num_value,attr_no;
+ char* attributes[] = {
+ "media-supported",
+ "output-bin-supported",
+ "print-content-optimize-supported",
+ "print-rendering-intent-supported",
+ "print-scaling-supported"
+ };
+
+ for (attr_no = 0; attr_no < 5; attr_no++) {
+ /* Cups Array to store the values for the attribute*/
+ if ((list = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return ;
+
+ num_value=0;
+ /* Iterating over all the printers in the cluster*/
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute(p->prattrs,attributes[attr_no], IPP_TAG_ZERO)) != NULL) {
+ count = ippGetCount(attr);
+ for(i = 0; i < count; i ++) {
+ /* Pick next format from attribute */
+ str = ippGetString(attr, i, NULL);
+ /* Add format to list, skip duplicates */
+ if (!cupsArrayFind(list, (void *)str)){
+ cupsArrayAdd(list, (void *)str);
+ num_value++;
+ }
+ }
+ }
+ }
+ if (num_value != 0){
+ char *values[num_value];
+ /* Transferring attributes value from cups Array to char* array*/
+ for (q = (char *)cupsArrayFirst(list), i = 0; q;
+ q = (char *)cupsArrayNext(list), i++) {
+ values[i]=malloc(sizeof(char)*strlen(q)+1);
+ strncpy(values[i],q,strlen(q)+1);
+ }
+ ippAddStrings(*merged_attributes, IPP_TAG_PRINTER, IPP_CONST_TAG(IPP_TAG_KEYWORD),
+ attributes[attr_no], num_value, NULL,
+ (const char * const *)values);
+ }
+ }
+ cupsArrayDelete(list);
+}
+
+/*add_keyword_attributes - Adds attributes to the merged_attribute variable for the cluster.
+ This function adds attributes with value tag IPP_TAG_KEYWORD*/
+void add_keyword_attributes(char* cluster_name,ipp_t **merged_attributes)
+{
+ int count,i;
+ remote_printer_t *p;
+ const char *str;
+ char *q;
+ cups_array_t *list;
+ ipp_attribute_t *attr;
+ int num_value,attr_no;
+ char* attributes[] = {
+ "output-mode-supported",
+ "urf-supported",
+ "pwg-raster-document-type-supported",
+ "media-source-supported",
+ "media-type-supported",
+ "print-color-mode-supported",
+ "sides-supported"
+ };
+
+ for (attr_no = 0; attr_no < 7; attr_no ++) {
+ if ((list = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return;
+
+ num_value=0;
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute(p->prattrs,attributes[attr_no], IPP_TAG_KEYWORD)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i++) {
+ str = ippGetString(attr, i, NULL);
+ if (!cupsArrayFind(list, (void *)str)){
+ cupsArrayAdd(list, (void *)str);
+ num_value++;
+ }
+ }
+ }
+ }
+ if (num_value!=0) {
+ char *values[num_value];
+ for (q = (char *)cupsArrayFirst(list), i=0;
+ q;
+ q = (char *)cupsArrayNext(list), i++) {
+ values[i]=malloc(sizeof(char)*strlen(q)+1);
+ strncpy(values[i],q,strlen(q)+1);
+ }
+ ippAddStrings(*merged_attributes, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ attributes[attr_no], num_value, NULL,
+ (const char * const *)values);
+ }
+ }
+ cupsArrayDelete(list);
+}
+
+/*add_enum_attributes - Adds attributes to the merged_attribute variable for the cluster.
+ This function adds attributes with value tag IPP_TAG_BEGIN_ENUM*/
+void add_enum_attributes(char* cluster_name,ipp_t **merged_attributes)
+{
+ int count,i,value;
+ remote_printer_t *p;
+ char *str;
+ char *q;
+ cups_array_t *list;
+ ipp_attribute_t *attr;
+ int num_value,attr_no;
+ char* attributes[] = {
+ "finishings-supported",
+ "print-quality-supported",
+ "finishing-template",
+ "finishings-col-database"
+ };
+
+ for (attr_no = 0; attr_no < 4; attr_no ++) {
+ if ((list = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return ;
+ str = malloc(sizeof(char)*10);
+ num_value=0;
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute(p->prattrs,attributes[attr_no], IPP_TAG_ENUM)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i ++) {
+ value = ippGetInteger(attr, i);
+ sprintf(str,"%d",value);
+ if (!cupsArrayFind(list, (void *)str)){
+ cupsArrayAdd(list, (void *)str);
+ num_value++;
+ }
+ }
+ }
+ }
+
+ if (num_value != 0){
+ int values[num_value];
+ for (q = (char *)cupsArrayFirst(list), i = 0;q;
+ q = (char *)cupsArrayNext(list), i++) {
+ values[i] = atoi(q);
+ }
+ ippAddIntegers(*merged_attributes, IPP_TAG_PRINTER,IPP_TAG_ENUM,
+ attributes[attr_no], num_value,values);
+ }
+ }
+ cupsArrayDelete(list);
+}
+
+/*add_margin_attribute - Adds margin attributes to the merged_attribute variable for the cluster.*/
+void add_margin_attributes(char* cluster_name,ipp_t **merged_attributes)
+{
+ int count,i,value;
+ remote_printer_t *p;
+ char *str;
+ char *q;
+ cups_array_t *list;
+ ipp_attribute_t *attr;
+ int num_value,attr_no;
+ char* attributes[] = {
+ "media-bottom-margin-supported",
+ "media-left-margin-supported",
+ "media-top-margin-supported",
+ "media-right-margin-supported"
+ };
+
+ for (attr_no = 0; attr_no < 4; attr_no++) {
+ if ((list = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return ;
+ str = malloc(sizeof(char)*10);
+ num_value=0;
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute(p->prattrs,attributes[attr_no], IPP_TAG_INTEGER)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i++) {
+ value = ippGetInteger(attr, i);
+ sprintf(str,"%d",value);
+ if (!cupsArrayFind(list, (void *)str)){
+ cupsArrayAdd(list, (void *)str);
+ num_value++;
+ }
+ }
+ }
+ }
+
+ if (num_value != 0){
+ int values[num_value];
+ for (q = (char *)cupsArrayFirst(list),i=0;q;
+ q = (char *)cupsArrayNext(list),i++) {
+ values[i] = atoi(q);
+ }
+ ippAddIntegers(*merged_attributes, IPP_TAG_PRINTER,IPP_TAG_INTEGER,
+ attributes[attr_no], num_value,values);
+ }
+ }
+ cupsArrayDelete(list);
+}
+
+/*add_resolution_attributes - Adds resolution attributes to the merged_attribute
+ for the cluster*/
+void add_resolution_attributes(char* cluster_name, ipp_t **merged_attributes)
+{
+ int count,i;
+ remote_printer_t *p;
+ ipp_attribute_t *attr;
+ int num_resolution,attr_no;
+ cups_array_t *res_array;
+ res_t *res,*resolution;
+ char* attributes[] = {
+ "printer-resolution-supported",
+ "pwg-raster-document-resolution-supported",
+ "pclm-source-resolution-supported"
+ };
+
+ for (attr_no = 0; attr_no < 3; attr_no++) {
+ res_array = NULL;
+ res_array = resolutionArrayNew();
+ num_resolution = 0;
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute(p->prattrs,attributes[attr_no], IPP_TAG_RESOLUTION)) != NULL){
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ if ((res = ippResolutionToRes(attr, i)) != NULL &&
+ cupsArrayFind(res_array, res) == NULL) {
+ cupsArrayAdd(res_array, res);
+ num_resolution++;
+ }
+ }
+ }
+ }
+ if (num_resolution) {
+ int xres[num_resolution],yres[num_resolution];
+ for (i = 0, resolution=cupsArrayFirst(res_array); resolution;
+ i ++, resolution = cupsArrayNext(res_array)) {
+ xres[i]=resolution->x;
+ yres[i]=resolution->y;
+ }
+ ippAddResolutions(*merged_attributes, IPP_TAG_PRINTER,attributes[attr_no],
+ num_resolution,IPP_RES_PER_INCH,xres,yres);
+ }
+ }
+ cupsArrayDelete(res_array);
+}
+
+/*add_mediasize_attribute - Adds media sizes to the merged_attribute for the printer*/
+void add_mediasize_attributes(char* cluster_name, ipp_t **merged_attributes)
+{
+ int count,i=0;
+ remote_printer_t *p;
+ ipp_attribute_t *attr,*media_size_supported,*x_dim,*y_dim;
+ int num_sizes,attr_no,num_ranges;
+ ipp_t *media_size;
+ cups_array_t *sizes,*size_ranges;
+ media_size_t *temp,*media_s;
+ pagesize_range_t *temp_range;
+ char* attributes[] = {
+ "media-size-supported",
+ };
+
+ sizes = cupsArrayNew3((cups_array_func_t)compare_mediasize, NULL, NULL, 0,
+ (cups_acopy_func_t)copy_media_size,
+ (cups_afree_func_t)free);
+ size_ranges = cupsArrayNew3((cups_array_func_t)compare_rangesize, NULL, NULL,
+ 0,
+ (cups_acopy_func_t)copy_range_size,
+ (cups_afree_func_t)free);
+ temp = (media_size_t *)malloc(sizeof(media_size_t));
+ temp_range = (pagesize_range_t *)malloc(sizeof(pagesize_range_t));
+ for (attr_no = 0; attr_no < 1; attr_no ++) {
+ num_sizes = 0;
+ num_ranges = 0;
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute(p->prattrs, attributes[attr_no],
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ media_size = ippGetCollection(attr, i);
+ x_dim = ippFindAttribute(media_size, "x-dimension", IPP_TAG_ZERO);
+ y_dim = ippFindAttribute(media_size, "y-dimension", IPP_TAG_ZERO);
+ if (ippGetValueTag(x_dim) == IPP_TAG_RANGE ||
+ ippGetValueTag(y_dim) == IPP_TAG_RANGE) {
+ if (ippGetValueTag(x_dim) == IPP_TAG_RANGE)
+ temp_range->x_dim_min = ippGetRange(x_dim, 0,
+ &temp_range->x_dim_max);
+ else
+ temp_range->x_dim_min = temp_range->x_dim_max =
+ ippGetInteger(x_dim, 0);
+
+ if (ippGetValueTag(y_dim) == IPP_TAG_RANGE)
+ temp_range->y_dim_min = ippGetRange(y_dim, 0,
+ &temp_range->y_dim_max);
+ else
+ temp_range->y_dim_min = temp_range->y_dim_max =
+ ippGetInteger(y_dim, 0);
+ if (!cupsArrayFind(size_ranges,temp_range)) {
+ cupsArrayAdd(size_ranges, temp_range);
+ num_ranges++;
+ }
+ } else {
+ temp->x = ippGetInteger(x_dim,0);
+ temp->y = ippGetInteger(y_dim,0);
+ if (!cupsArrayFind(sizes, temp)){
+ cupsArrayAdd(sizes, temp);
+ num_sizes++;
+ }
+ }
+ }
+ }
+ }
+ media_size_supported =
+ ippAddCollections(*merged_attributes,
+ IPP_TAG_PRINTER,attributes[attr_no],
+ num_sizes+num_ranges, NULL);
+ if (num_sizes){
+ for (i = 0, media_s = cupsArrayFirst(sizes);
+ media_s; i ++, media_s = cupsArrayNext(sizes)) {
+ ipp_t *size = create_media_size(media_s->x,media_s->y);
+ ippSetCollection(*merged_attributes, &media_size_supported, i, size);
+ ippDelete(size);
+ }
+ }
+ if (num_ranges) {
+ for (temp_range = cupsArrayFirst(size_ranges); temp_range;
+ i++, temp_range = cupsArrayNext(size_ranges)) {
+ ipp_t *size_range = create_media_range(temp_range->x_dim_min,
+ temp_range->x_dim_max,
+ temp_range->y_dim_min,
+ temp_range->y_dim_max);
+ ippSetCollection(*merged_attributes, &media_size_supported, i,
+ size_range);
+ ippDelete(size_range);
+ }
+ }
+ }
+ cupsArrayDelete(sizes);
+}
+
+/*add_mediadatabase_attribute - Adds media-col-database attributes for the cluster*/
+void
+add_mediadatabase_attributes(char* cluster_name, ipp_t **merged_attributes)
+{
+ int count, i;
+ remote_printer_t *p;
+ ipp_attribute_t *attr, *media_attr;
+ int num_database, attr_no;
+ cups_array_t *media_database;
+ media_col_t *temp, *media_data;
+ ipp_t *media_col,
+ *media_size, *current_media;
+ ipp_attribute_t *media_col_database;
+ char media_source[32], media_type[32];
+ char* attributes[] = {
+ "media-col-database",
+ };
+ temp = (media_col_t *)malloc(sizeof(media_col_t));
+ media_database = cupsArrayNew3((cups_array_func_t)compare_media,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)copy_media,
+ (cups_afree_func_t)free);
+ for (attr_no = 0; attr_no < 1; attr_no++) {
+ num_database = 0;
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute(p->prattrs,attributes[attr_no],
+ IPP_TAG_BEGIN_COLLECTION)) != NULL){
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ media_col = ippGetCollection(attr, i);
+ media_size =
+ ippGetCollection(ippFindAttribute(media_col,
+ "media-size",
+ IPP_TAG_BEGIN_COLLECTION), 0);
+ temp->x = ippGetInteger(ippFindAttribute(media_size, "x-dimension",
+ IPP_TAG_ZERO),0);
+ temp->y = ippGetInteger(ippFindAttribute(media_size, "y-dimension",
+ IPP_TAG_ZERO),0);
+ temp->top_margin =
+ ippGetInteger(ippFindAttribute(media_col,
+ "media-top-margin",
+ IPP_TAG_INTEGER),
+ 0);
+ temp->bottom_margin =
+ ippGetInteger(ippFindAttribute(media_col,
+ "media-bottom-margin",
+ IPP_TAG_INTEGER),
+ 0);
+ temp->left_margin =
+ ippGetInteger(ippFindAttribute(media_col,
+ "media-left-margin",
+ IPP_TAG_INTEGER),
+ 0);
+ temp->right_margin =
+ ippGetInteger(ippFindAttribute(media_col,
+ "media-right-margin",
+ IPP_TAG_INTEGER),
+ 0);
+ media_type[0]='\0';
+ media_source[0]='\0';
+ temp->media_source = NULL;
+ temp->media_type = NULL;
+ if ((media_attr = ippFindAttribute(media_col,
+ "media-type",
+ IPP_TAG_KEYWORD)) != NULL)
+ pwg_ppdize_name(ippGetString(media_attr, 0, NULL), media_type,
+ sizeof(media_type));
+ if (strlen(media_type) > 1) {
+ temp->media_type = (char*)malloc(sizeof(char)*32);
+ strcpy(temp->media_type, media_type);
+ }
+ if ((media_attr = ippFindAttribute(media_col, "media-source",
+ IPP_TAG_KEYWORD)) != NULL) {
+ pwg_ppdize_name(ippGetString(media_attr, 0, NULL), media_source,
+ sizeof(media_source));
+ }
+ if(strlen(media_source) > 1) {
+ temp->media_source = (char*)malloc(sizeof(char)*32);
+ strcpy(temp->media_source, media_source);
+ }
+
+ if (!cupsArrayFind(media_database, temp)) {
+ cupsArrayAdd(media_database, temp);
+ num_database++;
+ }
+ }
+ }
+ }
+
+ if (num_database !=0 ) {
+ media_col_database = ippAddCollections(*merged_attributes,
+ IPP_TAG_PRINTER,
+ attributes[attr_no],
+ num_database, NULL);
+ for (i = 0, media_data = cupsArrayFirst(media_database); media_data;
+ i ++, media_data = cupsArrayNext(media_database)) {
+ current_media = create_media_col(media_data->x, media_data->y,
+ media_data->left_margin,
+ media_data->right_margin,
+ media_data->top_margin,
+ media_data->bottom_margin,
+ media_data->media_source,
+ media_data->media_type);
+ ippSetCollection(*merged_attributes, &media_col_database, i,
+ current_media);
+ ippDelete(current_media);
+ }
+ }
+ }
+ cupsArrayDelete(media_database);
+}
+
+/*add_jobpresets_attribute - Adds presets attributes for the cluster*/
+void add_jobpresets_attribute(char* cluster_name, ipp_t ** merged_attributes)
+{
+ int count,i,num_preset=0,preset_no=0;
+ remote_printer_t *p;
+ cups_array_t *list,*added_presets;
+ ipp_t *preset;
+ ipp_attribute_t *attr;
+ const char *preset_name;
+ ipp_attribute_t *preset_attribute;
+
+ if ((list = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return;
+
+ if ((added_presets = cupsArrayNew3((cups_array_func_t)strcasecmp,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return;
+
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute(p->prattrs, "job-presets-supported",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ preset = ippGetCollection(attr, i);
+ preset_name = ippGetString(ippFindAttribute(preset, "preset-name",
+ IPP_TAG_ZERO), 0, NULL);
+ if (!cupsArrayFind(list, (void *)preset_name)) {
+ cupsArrayAdd(list, (void *)preset_name);
+ num_preset++;
+ }
+ }
+ }
+ }
+
+ if (num_preset == 0)
+ return;
+
+ preset_attribute = ippAddCollections(*merged_attributes, IPP_TAG_PRINTER,
+ "job-presets-supported",num_preset,
+ NULL);
+
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if ((attr = ippFindAttribute(p->prattrs, "job-presets-supported",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ preset = ippGetCollection(attr, i);
+ preset_name = ippGetString(ippFindAttribute(preset, "preset-name",
+ IPP_TAG_ZERO), 0, NULL);
+ if (!cupsArrayFind(added_presets, (void *)preset_name)) {
+ cupsArrayAdd(added_presets, (void *)preset_name);
+ ippSetCollection(*merged_attributes, &preset_attribute, i, preset);
+ preset_no++;
+ } else
+ continue;
+ }
+ }
+ }
+}
+
+/* get_pagesize: Function returns the standard/custom page size using
+ generate_sizes function from ppdgenerator.c*/
+static cups_array_t* get_pagesize(ipp_t *printer_attributes) {
+ cups_array_t *sizes,*page_media;
+ cups_size_t *size;
+ ipp_attribute_t *defattr;
+ char *ppdsizename,*temp;
+ int min_length=INT_MAX, min_width=INT_MAX,
+ max_length=0,max_width=0,
+ bottom,left,right,top;
+ char ppdname[41];
+
+ ppdsizename = (char *)malloc(sizeof(char)*128);
+ sizes = generate_sizes(printer_attributes, &defattr, &min_length, &min_width,
+ &max_length,&max_width,
+ &bottom,&left,&right,&top,ppdname);
+ if ((page_media = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ for (size = (cups_size_t *)cupsArrayFirst(sizes); size;
+ size = (cups_size_t *)cupsArrayNext(sizes)) {
+ strcpy(ppdsizename, size->media);
+ if (( temp = strchr(ppdsizename, ' ')) != NULL)
+ *temp = '\0';
+ cupsArrayAdd(page_media, ppdsizename);
+ }
+ free(ppdsizename);
+ return page_media;
+}
+
+/*get_mediadata - This function extracts the MediaType, InputSlot and OutputBin
+ supported, using IPP Response message of the printer*/
+cups_array_t* get_mediadata(ipp_t *printer_attributes,char* requested_attr){
+ ipp_attribute_t *attr;
+ int count,i;
+ cups_array_t *media_data;
+ const char *keyword; /* Keyword value */
+ char ppdname[41];
+ char requested_option[30];
+
+ if (!strcmp(requested_attr,"MediaType"))
+ strcpy(requested_option,"media-type-supported");
+ else if (!strcmp(requested_attr,"InputSlot"))
+ strcpy(requested_option,"media-source-supported");
+ else if (!strcmp(requested_attr,"OutputBin"))
+ strcpy(requested_option,"output-bin-supported");
+ else
+ return NULL;
+
+ if ((media_data = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, requested_option,
+ IPP_TAG_ZERO)) != NULL
+ && (count = ippGetCount(attr)) > 1) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ keyword = ippGetString(attr, i, NULL);
+ pwg_ppdize_name(keyword, ppdname, sizeof(ppdname));
+ cupsArrayAdd(media_data, ppdname);
+ }
+ }
+ return media_data;
+}
+
+/*get_mimetype_attribute - Adds attributes to the merged_attribute variable for
+ the cluster. This function adds attribute with value
+ tag IPP_TAG_MIMETYPE*/
+cups_array_t* get_mimetype_attributes(ipp_t *printer_attributes)
+{
+ int count,i;
+ const char *str;
+ cups_array_t *document_formats;
+ ipp_attribute_t *attr;
+
+ if ((document_formats = cupsArrayNew3((cups_array_func_t)strcasecmp,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+
+ if ((attr = ippFindAttribute(printer_attributes, "document-format-supported",
+ IPP_TAG_MIMETYPE)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i ++) {
+ str = ippGetString(attr, i, NULL);
+ if (!cupsArrayFind(document_formats, (void *)str))
+ cupsArrayAdd(document_formats, (void *)str);
+ }
+ }
+ return document_formats;
+}
+
+/*get_staplelocation: This function returns the supported staple locations of
+ the printer */
+cups_array_t* get_staplelocation(ipp_t *printer_attributes)
+{
+ ipp_attribute_t *attr;
+ int count,value,i;
+ const char *name;
+ cups_array_t *staplelocation;
+
+ if ((staplelocation = cupsArrayNew3((cups_array_func_t)strcasecmp,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, "finishings-supported",
+ IPP_TAG_ENUM)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i ++) {
+ value = ippGetInteger(attr, i);
+ name = ippEnumString("finishings", value);
+ if (!strncmp(name, "staple-", 7) || !strncmp(name, "bind-", 5) ||
+ !strncmp(name, "edge-stitch-", 12) || !strcmp(name, "saddle-stitch"))
+ if (!cupsArrayFind(staplelocation,(void*)name))
+ cupsArrayAdd(staplelocation,(void*)name);
+ }
+ }
+ return staplelocation;
+}
+
+/*get_foldtype - Function returns the supported foldtype for the printer*/
+cups_array_t* get_foldtype(ipp_t *printer_attributes)
+{
+ ipp_attribute_t *attr;
+ int count,value,i;
+ const char *name;
+ cups_array_t *foldtype;
+
+ if ((foldtype = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, "finishings-supported",
+ IPP_TAG_ENUM)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i ++) {
+ value = ippGetInteger(attr, i);
+ name = ippEnumString("finishings", value);
+ if (!strncmp(name, "fold-", 5))
+ if (!cupsArrayFind(foldtype,(void*)name))
+ cupsArrayAdd(foldtype,(void*)name);
+ }
+ }
+ return foldtype;
+}
+
+/*get_finishings - Function returns the supported finishings for the printer*/
+cups_array_t* get_finishings(ipp_t *printer_attributes)
+{
+ ipp_attribute_t *attr;
+ int count,value,i;
+ const char *name;
+ cups_array_t *finishings;
+
+ if ((finishings = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, "finishings-supported",
+ IPP_TAG_ENUM)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i ++) {
+ value = ippGetInteger(attr, i);
+ name = ippEnumString("finishings", value);
+ if (!cupsArrayFind(finishings,(void*)name))
+ cupsArrayAdd(finishings,(void*)name);
+ }
+ }
+ return finishings;
+}
+
+
+/*get_punchmedia - Returns the puchmedia supported by the printer*/
+cups_array_t* get_punchmedia(ipp_t *printer_attributes){
+ ipp_attribute_t *attr;
+ int count,value,i;
+ const char *name;
+ cups_array_t *punchmedia;
+
+ if ((punchmedia = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, "finishings-supported",
+ IPP_TAG_ENUM)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i ++) {
+ value = ippGetInteger(attr, i);
+ name = ippEnumString("finishings", value);
+ if (!strncmp(name, "punch-", 6))
+ if (!cupsArrayFind(punchmedia,(void*)name))
+ cupsArrayAdd(punchmedia,(void*)name);
+ }
+ }
+ return punchmedia;
+}
+
+/*get_duplex - Function returns whether the printer support Duplex,
+ DuplexTumble, DuplexNoTumble using attributes returned by the
+ IPP Request*/
+cups_array_t* get_duplex(ipp_t *printer_attributes)
+{
+ ipp_attribute_t *attr;
+ int count,i;
+ cups_array_t *duplex_options;
+ const char *str;
+
+ if ((duplex_options = cupsArrayNew3((cups_array_func_t)strcasecmp,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, "sides-supported",
+ IPP_TAG_KEYWORD)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i ++) {
+ str = ippGetString(attr, i, NULL);
+ if (!strcmp(str,"one-sided"))
+ cupsArrayAdd(duplex_options,"None");
+ else if (!strcmp(str,"two-sided-long-edge"))
+ cupsArrayAdd(duplex_options,"DuplexNoTumble");
+ else if (!strcmp(str,"two-sided-short-edge"))
+ cupsArrayAdd(duplex_options,"DuplexTumble");
+ }
+ }
+ return duplex_options;
+}
+
+/* get_colormodel - Returns the colormodel supported by the printer*/
+cups_array_t* get_colormodel(ipp_t *printer_attributes)
+{
+ ipp_attribute_t *attr;
+ int count, i;
+ cups_array_t *colormodel;
+ const char *keyword;
+ int have_bi_level = 0,
+ have_mono = 0;
+
+ if ((colormodel = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, "urf-supported",
+ IPP_TAG_KEYWORD)) == NULL)
+ if ((attr = ippFindAttribute(printer_attributes,
+ "pwg-raster-document-type-supported",
+ IPP_TAG_KEYWORD)) == NULL)
+ if ((attr = ippFindAttribute(printer_attributes,
+ "print-color-mode-supported",
+ IPP_TAG_KEYWORD)) == NULL)
+ attr = ippFindAttribute(printer_attributes, "output-mode-supported",
+ IPP_TAG_KEYWORD);
+
+ if (attr && ippGetCount(attr) > 0) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ keyword = ippGetString(attr, i, NULL);
+ if (!have_bi_level && (!strcasecmp(keyword, "black_1") ||
+ !strcmp(keyword, "bi-level") ||
+ !strcmp(keyword, "process-bi-level"))) {
+ cupsArrayAdd(colormodel,"FastGray");
+ have_bi_level = 1;
+ } else if (!have_mono &&(!strcasecmp(keyword, "sgray_8") ||
+ !strncmp(keyword, "W8", 2) ||
+ !strcmp(keyword, "monochrome") ||
+ !strcmp(keyword, "process-monochrome"))) {
+ have_mono = 1;
+ cupsArrayAdd(colormodel,"Gray");
+ } else if (!strcasecmp(keyword, "sgray_16") ||
+ !strncmp(keyword, "W8-16", 5) || !strncmp(keyword, "W16", 3))
+ cupsArrayAdd(colormodel,"Gray16");
+ else if (!strcasecmp(keyword, "srgb_8") ||
+ !strncmp(keyword, "SRGB24", 6) || !strcmp(keyword, "color"))
+ cupsArrayAdd(colormodel,"RGB");
+ else if ((!strcasecmp(keyword, "srgb_16") ||
+ !strncmp(keyword, "SRGB48", 6)) &&
+ !ippContainsString(attr, "srgb_8"))
+ cupsArrayAdd(colormodel,"RGB");
+ else if (!strcasecmp(keyword, "adobe-rgb_16") ||
+ !strncmp(keyword, "ADOBERGB48", 10) ||
+ !strncmp(keyword, "ADOBERGB24-48", 13))
+ cupsArrayAdd(colormodel,"AdobeRGB");
+ else if ((!strcasecmp(keyword, "adobe-rgb_8") ||
+ !strcmp(keyword, "ADOBERGB24")) &&
+ !ippContainsString(attr, "adobe-rgb_16"))
+ cupsArrayAdd(colormodel,"AdobeRGB");
+ else if ((!strcasecmp(keyword, "black_8") &&
+ !ippContainsString(attr, "black_16")) ||
+ !strcmp(keyword, "DEVW8"))
+ cupsArrayAdd(colormodel,"DeviceGray");
+ else if (!strcasecmp(keyword, "black_16") ||
+ !strcmp(keyword, "DEVW16") || !strcmp(keyword, "DEVW8-16"))
+ cupsArrayAdd(colormodel,"DeviceGray");
+ else if ((!strcasecmp(keyword, "cmyk_8") &&
+ !ippContainsString(attr, "cmyk_16")) ||
+ !strcmp(keyword, "DEVCMYK32"))
+ cupsArrayAdd(colormodel,"CMYK");
+ else if (!strcasecmp(keyword, "cmyk_16") ||
+ !strcmp(keyword, "DEVCMYK32-64") ||
+ !strcmp(keyword, "DEVCMYK64"))
+ cupsArrayAdd(colormodel,"CMYK");
+ else if ((!strcasecmp(keyword, "rgb_8") &&
+ !ippContainsString(attr, "rgb_16")) ||
+ !strcmp(keyword, "DEVRGB24"))
+ cupsArrayAdd(colormodel,"DeviceRGB");
+ else if (!strcasecmp(keyword, "rgb_16") ||
+ !strcmp(keyword, "DEVRGB24-48") ||
+ !strcmp(keyword, "DEVRGB48"))
+ cupsArrayAdd(colormodel,"DeviceRGB");
+ }
+ }
+ return colormodel;
+}
+
+/* get_printquality - Returns the print qualities supported by the printer*/
+cups_array_t* get_printquality(ipp_t *printer_attributes)
+{
+ ipp_attribute_t *quality;
+ cups_array_t *print_qualities;
+
+ if ((print_qualities = cupsArrayNew3((cups_array_func_t)strcasecmp,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((quality=ippFindAttribute(printer_attributes, "print-quality-supported",
+ IPP_TAG_ENUM)) != NULL) {
+ if (ippContainsInteger(quality, IPP_QUALITY_DRAFT))
+ cupsArrayAdd(print_qualities,"3");
+ if (ippContainsInteger(quality, IPP_QUALITY_HIGH))
+ cupsArrayAdd(print_qualities,"5");
+ cupsArrayAdd(print_qualities,"4");
+ }
+ return print_qualities;
+}
+
+/* get_job_data - Returns the job_sheets,multiple-document-handling supported
+ by the printer*/
+cups_array_t* get_job_data(ipp_t *printer_attributes,char* requested_attr)
+{
+ ipp_attribute_t *attr;
+ cups_array_t *job_data;
+ int i, count;
+ const char* str;
+
+ if ((job_data = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr=ippFindAttribute(printer_attributes, requested_attr,
+ IPP_TAG_KEYWORD)) != NULL) {
+ for(i = 0, count = ippGetCount(attr); i < count; i ++) {
+ str = ippGetString(attr, i, NULL);
+ if (!cupsArrayFind(job_data, (void *)str))
+ cupsArrayAdd(job_data, (void*)str);
+ }
+ }
+ return job_data;
+}
+
+/* get_finishingtemplate - Returns the Finishing Templates supported by the
+ printer*/
+cups_array_t* get_finishingtemplate(ipp_t *printer_attributes)
+{
+ ipp_attribute_t *attr;
+ cups_array_t *finishing_templates;
+ ipp_t *finishing_col; /* Current finishing collection */
+ int count,i;
+ const char *keyword;
+
+ if ((finishing_templates = cupsArrayNew3((cups_array_func_t)strcasecmp,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, "finishings-col-database",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
+ count = ippGetCount(attr);
+ for (i = 0; i < count; i ++) {
+ finishing_col = ippGetCollection(attr, i);
+ keyword = ippGetString(ippFindAttribute(finishing_col,
+ "finishing-template",
+ IPP_TAG_ZERO), 0, NULL);
+ if (!keyword || cupsArrayFind(finishing_templates, (void *)keyword))
+ continue;
+ if (strncmp(keyword, "fold-", 5) && (strstr(keyword, "-bottom") ||
+ strstr(keyword, "-left") ||
+ strstr(keyword, "-right") ||
+ strstr(keyword, "-top")))
+ continue;
+ cupsArrayAdd(finishing_templates, (void*)keyword);
+ }
+ }
+ return finishing_templates;
+}
+
+/* get_printing_data - Returns the print-content-optimize,print-rendering-intent
+ and print-scaling attributes for the printer*/
+cups_array_t* get_printing_data(ipp_t *printer_attributes,char* requested_attr){
+ ipp_attribute_t *attr;
+ int count,i;
+ cups_array_t *printing_support;
+ const char *keyword;
+ char requested_option[40];
+
+ if(!strcmp(requested_attr,"print-content-optimize"))
+ strcpy(requested_option,"print-content-optimize-supported");
+ else if (!strcmp(requested_attr,"print-rendering-intent"))
+ strcpy(requested_option,"print-rendering-intent-supported");
+ else if(!strcmp(requested_attr,"print-scaling"))
+ strcpy(requested_option,"print-scaling-supported");
+ else if (!strcmp(requested_attr,"job-sheets-supported"))
+ strcpy(requested_option,"job-sheets-supported");
+ else
+ return NULL;
+
+ if ((printing_support = cupsArrayNew3((cups_array_func_t)strcasecmp,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, requested_option,
+ IPP_TAG_ZERO)) != NULL &&
+ (count = ippGetCount(attr)) > 1) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ keyword = ippGetString(attr, i, NULL);
+ cupsArrayAdd(printing_support, (void *)keyword);
+ }
+ }
+ return printing_support;
+}
+
+/*get_presets - Returns a list of presets name supported by the printer*/
+cups_array_t* get_presets(ipp_t *printer_attributes)
+{
+ ipp_attribute_t *attr;
+ int count,i;
+ cups_array_t *presets;
+ ipp_t *preset ;
+ const char *preset_name;
+
+ if ((presets = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, "job-presets-supported",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL
+ && (count = ippGetCount(attr)) > 1) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ preset = ippGetCollection(attr, i);
+ preset_name = ippGetString(ippFindAttribute(preset, "preset-name",
+ IPP_TAG_ZERO), 0, NULL);
+ if(!cupsArrayFind(presets,(void*)preset_name))
+ cupsArrayAdd(presets,(void *)preset_name);
+ }
+ }
+ return presets;
+}
+
+/* get_booklet - Returns True if booklet is supported */
+cups_array_t* get_booklet(ipp_t *printer_attributes)
+{
+ ipp_attribute_t *attr;
+ cups_array_t *booklet;
+
+ if ((booklet = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ if ((attr = ippFindAttribute(printer_attributes, "finishings-supported",
+ IPP_TAG_ENUM)) != NULL) {
+ if (ippContainsInteger(attr, IPP_FINISHINGS_BOOKLET_MAKER)) {
+ /* Assuming that the printer which supports Booklet also supports
+ printing without Booklet, so for this printer we will return
+ both "True" and "False" */
+ cupsArrayAdd(booklet,"True");
+ }
+ }
+ cupsArrayAdd(booklet,"False");
+ return booklet;
+}
+
+/* get_supported_options - Function returns various attributes supported by the
+ printer, such as PageSize,ColorModel etc.*/
+cups_array_t* get_supported_options(ipp_t *printer_attributes, char* option)
+{
+ if(!strcmp(option,"PageSize") || !strcmp(option,"PageRegion"))
+ return get_pagesize(printer_attributes);
+ else if(!strcmp(option,"MediaType") || !strcmp(option,"InputSlot") ||
+ !strcmp(option,"OutputBin"))
+ return get_mediadata(printer_attributes,option);
+ else if (!strcmp(option,"StapleLocation"))
+ return get_staplelocation(printer_attributes);
+ else if (!strcmp(option,"FoldType"))
+ return get_foldtype(printer_attributes);
+ else if (!strcmp(option,"PunchMedia"))
+ return get_punchmedia(printer_attributes);
+ else if (!strcmp(option,"cupsFinishingTemplate"))
+ return get_finishingtemplate(printer_attributes);
+ else if (!strcmp(option,"cupsPrintQuality"))
+ return get_printquality(printer_attributes);
+ else if (!strcmp(option,"job-sheets-supported") ||
+ !strcmp(option,"print-content-optimize") ||
+ !strcmp(option,"print-rendering-intent") ||
+ !strcmp(option,"print-scaling"))
+ return get_printing_data(printer_attributes,option);
+ else if (!strcmp(option,"APPrinterPreset"))
+ return get_presets(printer_attributes);
+ else if(!strcmp(option,"Booklet"))
+ return get_booklet(printer_attributes);
+ else if(!strcmp(option,"ColorModel"))
+ return get_colormodel(printer_attributes);
+ else if (!strcmp(option,"Duplex"))
+ return get_duplex(printer_attributes);
+ else if (!strcmp(option,"multiple-document-handling-supported") ||
+ !strcmp(option,"cover-back-supported") ||
+ !strcmp(option,"cover-front-supported") ||
+ !strcmp(option,"cover-type-supported") ||
+ !strcmp(option,"media-type-supported"))
+ return get_job_data(printer_attributes,option);
+ else if (!strcmp(option,"finishings-supported"))
+ return get_finishings(printer_attributes);
+ return NULL;
+}
+
+/*check_printer_with_options - Checks whether a printer in an cluster supports
+ option1 for keyword at value idx_option1 in
+ ppd_keywords[] and option2 for keyword at value
+ idx_option2*/
+int check_printer_with_options(char* cluster_name,int idx_option1,char* option1,
+ int idx_option2,char* option2)
+{
+ remote_printer_t *p;
+ cups_array_t *first_attributes_value;
+ cups_array_t *second_attributes_value;
+ char *borderless_pagesize;
+ int option1_is_size=0, option2_is_size=0;
+ char t[] = ".Borderless";
+
+ borderless_pagesize = malloc(sizeof(char)*32);
+ if (!strcmp(ppd_keywords[idx_option1],"PageSize") ||
+ !strcmp(ppd_keywords[idx_option1],"PageRegion")) {
+ /* Check that we are generating .Borderless for the correct size, i.e We
+ are generating 4x5.Borderless for 4x5 and not generating
+ 4x5.Borderless.Borderless for 4x5.Borderless */
+ if (strlen(option1) >= 11 && !strcmp(&option1[strlen(option1)-strlen(t)], t))
+ ;
+ else {
+ strcat(borderless_pagesize,option1);
+ strcat(borderless_pagesize,t);
+ option1_is_size = 1;
+ }
+ }
+ if (!strcmp(ppd_keywords[idx_option2],"PageSize") ||
+ !strcmp(ppd_keywords[idx_option2],"PageRegion")) {
+ if(strlen(option2) >=11 && !strcmp(&option2[strlen(option2)-strlen(t)], t))
+ ;
+ else {
+ strcat(borderless_pagesize,option2);
+ strcat(borderless_pagesize,t);
+ option2_is_size = 1;
+ }
+ }
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if(strcmp(cluster_name, p->queue_name))
+ continue;
+ first_attributes_value = get_supported_options(p->prattrs,
+ ppd_keywords[idx_option1]);
+ if(cupsArrayFind(first_attributes_value, (void*)option1) ||
+ (option1_is_size && cupsArrayFind(first_attributes_value,
+ (void*)borderless_pagesize))) {
+ second_attributes_value =
+ get_supported_options(p->prattrs,
+ ppd_keywords[idx_option2]);
+ if (cupsArrayFind(second_attributes_value,(void*)option2) ||
+ (option2_is_size && cupsArrayFind(second_attributes_value,
+ (void*)borderless_pagesize)))
+ return 1;
+ }
+ }
+ free(borderless_pagesize);
+ return 0;
+}
+
+/* The function returns a array containint the sizes supported by the cluster*/
+cups_array_t* get_cluster_sizes(char* cluster_name)
+{
+ cups_array_t *sizes=NULL;
+ cups_array_t *cluster_sizes=NULL,
+ *sizes_ppdname;
+ cups_size_t *size;
+ pagesize_count_t *temp;
+ remote_printer_t *p;
+ ipp_attribute_t *defattr;
+ char ppdname[41],pagesize[128];
+ char* first_space;
+ int min_length,min_width,max_length,max_width,
+ bottom,left,right,top;
+
+ temp = (pagesize_count_t *)malloc(sizeof(pagesize_count_t));
+ cluster_sizes = cupsArrayNew3((cups_array_func_t)pwg_compare_sizes,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)pwg_copy_size,
+ (cups_afree_func_t)free);
+ sizes_ppdname = cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free);
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (!strcmp(p->queue_name,cluster_name)) {
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ defattr = NULL;
+ min_length = INT_MAX;
+ min_width = INT_MAX;
+ max_length = 0;
+ max_width = 0;
+ bottom = 0;
+ left = 0;
+ right = 0;
+ top = 0;
+ sizes = generate_sizes(p->prattrs, &defattr, &min_length, &min_width,
+ &max_length, &max_width,
+ &bottom, &left, &right, &top, ppdname);
+ temp->pagesize = ppdname;
+ temp->count = 1;
+ for (size = (cups_size_t *)cupsArrayFirst(sizes);
+ size; size = (cups_size_t *)cupsArrayNext(sizes)) {
+ if (!cupsArrayFind(cluster_sizes, size)) {
+ strcpy(pagesize, size->media);
+ if ((first_space = strchr(pagesize, ' ')) != NULL) {
+ *first_space = '\0';
+ }
+ if (!cupsArrayFind(sizes_ppdname,pagesize)) {
+ cupsArrayAdd(cluster_sizes, size);
+ cupsArrayAdd(sizes_ppdname,pagesize);
+ }
+ }
+ }
+ }
+ }
+ return cluster_sizes;
+}
+
+/* generate_cluster_conflicts - Function generates conflicts for the cluster*/
+cups_array_t* generate_cluster_conflicts(char* cluster_name,
+ ipp_t *merged_attributes)
+{
+ remote_printer_t *p;
+ cups_array_t *conflict_pairs=NULL;
+ int i,k,j,no_of_printers=0,no_of_ppd_keywords;
+ cups_array_t *printer_first_options=NULL,*printer_second_options=NULL;
+ char *opt1,*opt2,constraint[100],*ppdsizename,*temp;
+ cups_array_t *sizes = NULL,*pagesizes;
+ cups_size_t *size;
+
+ /* Cups Array to store the conflicts*/
+ ppdsizename = (char *)malloc(sizeof(char)*128);
+ if ((conflict_pairs = cupsArrayNew3((cups_array_func_t)strcasecmp,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+
+ /* Storing all the values supported by the cluster in cluster_options*/
+ no_of_ppd_keywords = sizeof(ppd_keywords)/sizeof(ppd_keywords[0]);
+ cups_array_t *cluster_options[no_of_ppd_keywords];
+ for(i = 0; i < no_of_ppd_keywords; i ++) {
+ if (strcmp(ppd_keywords[i],"PageSize") &&
+ strcmp(ppd_keywords[i],"PageRegion"))
+ cluster_options[i] =
+ get_supported_options(merged_attributes,ppd_keywords[i]);
+ else {
+ sizes = get_cluster_sizes(cluster_name);
+ if ((pagesizes =
+ cupsArrayNew3((cups_array_func_t)strcasecmp, NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL)
+ return NULL;
+ for (size = (cups_size_t *)cupsArrayFirst(sizes); size;
+ size = (cups_size_t *)cupsArrayNext(sizes)) {
+ strcpy(ppdsizename, size->media);
+ if ((temp = strchr(ppdsizename, ' ')) != NULL)
+ *temp = '\0';
+ cupsArrayAdd(pagesizes, ppdsizename);
+ }
+ cluster_options[i]=pagesizes;
+ }
+ }
+
+ /* Algorithm to find constriants: We iterate over printer, if we
+ find a value for a keyword which is supported by the cluster but
+ not by the printer, that value can be part of the conflict. With
+ this value v and a new value (for an different keyword, at index
+ more than the index of first keyword), we generate a pair (v,u)
+ and then we check whether some printer satisfy this pair, if no
+ such printer exists then the pair is a conflict, we add it to
+ conflict_pairs array */
+
+ no_of_printers = cupsArrayCount(remote_printers);
+ for (j = 0; j < no_of_printers; j ++) {
+ p = (remote_printer_t *)cupsArrayIndex(remote_printers, j);
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ for (i = 0; i < no_of_ppd_keywords; i ++) {
+ printer_first_options =
+ get_supported_options(p->prattrs, ppd_keywords[i]);
+ if (i == 0)
+ for (opt1 = cupsArrayFirst(cluster_options[i]); opt1;
+ opt1 = cupsArrayNext(cluster_options[i])) {
+ if (cupsArrayFind(printer_first_options, opt1))
+ continue;
+ for (k = i + 1; k < no_of_ppd_keywords; k++) {
+ if (!strcmp(ppd_keywords[i],"PageSize") &&
+ !strcmp(ppd_keywords[k],"PageRegion"))
+ continue;
+ printer_second_options = get_supported_options(p->prattrs,
+ ppd_keywords[k]);
+ for(opt2 = cupsArrayFirst(printer_second_options); opt2;
+ opt2 = cupsArrayNext(printer_second_options)) {
+ if (check_printer_with_options(cluster_name, i, opt1, k, opt2))
+ continue;
+ if (!strcasecmp(opt1, AUTO_OPTION) || !strcasecmp(opt2, AUTO_OPTION))
+ continue;
+ if (!strcmp(opt1, "Gray") || !strcmp(opt2,"Gray"))
+ continue;
+ sprintf(constraint, "*UIConstraints: *%s %s *%s %s\n",
+ ppd_keywords[i],
+ opt1,ppd_keywords[k],opt2);
+ if (!cupsArrayFind(conflict_pairs, constraint)) {
+ cupsArrayAdd(conflict_pairs,constraint);
+ }
+ sprintf(constraint, "*UIConstraints: *%s %s *%s %s\n",
+ ppd_keywords[k],
+ opt2,ppd_keywords[i],opt1);
+ if (!cupsArrayFind(conflict_pairs, constraint)) {
+ cupsArrayAdd(conflict_pairs, constraint);
+ }
+ }
+ }
+ }
+ }
+ }
+ free(ppdsizename);
+ return conflict_pairs;
+}
+
+/*get_cluster_attributes - Returns ipp_t* containing the options supplied by
+ all the printers in the cluster, which can be sent
+ to ppdCreateFromIPP2() to generate the ppd file */
+ipp_t* get_cluster_attributes(char* cluster_name)
+{
+ remote_printer_t *p;
+ ipp_t *merged_attributes = NULL;
+ char printer_make_and_model[256];
+ ipp_attribute_t *attr;
+ int color_supported=0,make_model_done = 0,i;
+ char valuebuffer[65536];
+ merged_attributes = ippNew();
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name,p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if (!make_model_done) {
+ strcpy(printer_make_and_model, "Cluster ");
+ strcat(printer_make_and_model, cluster_name);
+ make_model_done = 1;
+ }
+ if (((attr = ippFindAttribute(p->prattrs, "color-supported",
+ IPP_TAG_BOOLEAN)) != NULL &&
+ ippGetBoolean(attr, 0)))
+ color_supported = 1;
+ }
+
+ ippAddString(merged_attributes, IPP_TAG_PRINTER,IPP_TAG_TEXT,
+ "printer-make-and-model",
+ NULL, printer_make_and_model);
+ ippAddBoolean(merged_attributes, IPP_TAG_PRINTER, "color-supported",
+ color_supported);
+
+ add_keyword_attributes(cluster_name, &merged_attributes);
+ add_mimetype_attributes(cluster_name, &merged_attributes);
+ add_tagzero_attributes(cluster_name, &merged_attributes);
+ add_enum_attributes(cluster_name, &merged_attributes);
+ add_resolution_attributes(cluster_name, &merged_attributes);
+ add_margin_attributes(cluster_name, &merged_attributes);
+ add_mediasize_attributes(cluster_name, &merged_attributes);
+ add_mediadatabase_attributes(cluster_name, &merged_attributes);
+ add_jobpresets_attribute(cluster_name, &merged_attributes);
+ attr = ippFirstAttribute(merged_attributes);
+ /* Printing merged attributes*/
+ debug_printf("Merged attributes for the cluster %s : \n", cluster_name);
+ while (attr) {
+ debug_printf(" Attr: %s\n",
+ ippGetName(attr));
+ ippAttributeString(attr, valuebuffer, sizeof(valuebuffer));
+ debug_printf(" Value: %s\n", valuebuffer);
+ const char *kw;
+ for (i = 0; i < ippGetCount(attr); i ++)
+ if ((kw = ippGetString(attr, i, NULL)) != NULL)
+ debug_printf(" Keyword: %s\n", kw);
+ attr = ippNextAttribute(merged_attributes);
+ }
+ return merged_attributes;
+}
+
+int cluster_supports_given_attribute(char* cluster_name,ipp_tag_t tag,
+ const char* attribute)
+{
+ remote_printer_t *p;
+ ipp_attribute_t *attr;
+ int count;
+
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(cluster_name, p->queue_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute(p->prattrs, attribute, tag)) != NULL &&
+ (count = ippGetCount(attr)) > 1)
+ return 1;
+ }
+ return 0;
+}
+
+/* Generating the default values for the cluster*/
+void get_cluster_default_attributes(ipp_t** merged_attributes,
+ char* cluster_name,
+ char* default_pagesize,
+ const char **default_color)
+{
+ int max_pages_per_min = 0,pages_per_min;
+ remote_printer_t *p,*def_printer=NULL;
+ int i,count;
+ ipp_attribute_t *attr,*media_attr,*media_col_default,*defattr;
+ ipp_t *media_col,
+ *media_size,*current_media=NULL;
+ char media_source[32],media_type[32];
+ const char *str;
+ media_col_t *temp;
+ const char *keyword;
+ res_t *res;
+ int xres,yres;
+ int min_length=INT_MAX,min_width=INT_MAX,
+ max_length=0,max_width=0,
+ bottom,left,right,top;
+ char ppdname[41];
+ cups_array_t *sizes;
+
+ /*The printer with the maximum Throughtput(pages_per_min) is selected as
+ the default printer*/
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(p->queue_name, cluster_name))
+ continue;
+ if(p->status == STATUS_DISAPPEARED || p->status == STATUS_UNCONFIRMED ||
+ p->status == STATUS_TO_BE_RELEASED )
+ continue;
+ if ((attr = ippFindAttribute (p->prattrs, "pages-per-minute",
+ IPP_TAG_INTEGER)) != NULL) {
+ pages_per_min = ippGetInteger (attr, 0);
+ if (pages_per_min > max_pages_per_min) {
+ max_pages_per_min = pages_per_min;
+ def_printer = p;
+ }
+ }
+ }
+
+ /* If none of the printer in the cluster has "pages-per-minute" in the ipp
+ response message, then select the first printer in the cluster */
+ if (!def_printer) {
+ for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ p; p = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (strcmp(p->queue_name,cluster_name))
+ continue;
+ else {
+ def_printer = p;
+ break;
+ }
+ }
+ }
+
+ debug_printf("Selecting printer (%s) as the default for the cluster %s\n",
+ def_printer->uri, cluster_name);
+ debug_printf("Default Attributes of the cluster %s are : \n",cluster_name);
+
+ /* Generating the default pagesize for the cluster*/
+ sizes = generate_sizes(def_printer->prattrs, &defattr, &min_length,
+ &min_width, &max_length, &max_width,
+ &bottom, &left, &right, &top, ppdname);
+ strcpy(default_pagesize,ppdname);
+ debug_printf("Default PageSize : %s\n", default_pagesize);
+
+ /* Generating the default media-col for the cluster*/
+ if ((attr = ippFindAttribute(def_printer->prattrs, "media-col-default",
+ IPP_TAG_BEGIN_COLLECTION)) != NULL) {
+ media_col = ippGetCollection(attr, 0);
+ media_size = ippGetCollection(ippFindAttribute(media_col, "media-size",
+ IPP_TAG_BEGIN_COLLECTION),
+ 0);
+ temp = (media_col_t *)malloc(sizeof(media_col_t));
+ temp->x = ippGetInteger(ippFindAttribute(media_size, "x-dimension",
+ IPP_TAG_ZERO), 0);
+ temp->y = ippGetInteger(ippFindAttribute(media_size, "y-dimension",
+ IPP_TAG_ZERO), 0);
+ temp->top_margin = ippGetInteger(ippFindAttribute(media_col,
+ "media-top-margin",
+ IPP_TAG_INTEGER), 0);
+ temp->bottom_margin = ippGetInteger(ippFindAttribute(media_col,
+ "media-bottom-margin",
+ IPP_TAG_INTEGER), 0);
+ temp->left_margin = ippGetInteger(ippFindAttribute(media_col,
+ "media-left-margin",
+ IPP_TAG_INTEGER), 0);
+ temp->right_margin = ippGetInteger(ippFindAttribute(media_col,
+ "media-right-margin",
+ IPP_TAG_INTEGER), 0);
+ media_type[0]='\0';
+ media_source[0]='\0';
+ temp->media_source = NULL;
+ temp->media_type = NULL;
+
+ if ((media_attr = ippFindAttribute(media_col, "media-type",
+ IPP_TAG_KEYWORD)) != NULL)
+ pwg_ppdize_name(ippGetString(media_attr, 0, NULL), media_type,
+ sizeof(media_type));
+
+ if (strlen(media_type) > 1) {
+ temp->media_type = (char*)malloc(sizeof(char)*32);
+ strcpy(temp->media_type, media_type);
+ debug_printf("Default MediaType: %s\n", media_type);
+ }
+
+ if ((media_attr = ippFindAttribute(media_col, "media-source",
+ IPP_TAG_KEYWORD)) != NULL) {
+ pwg_ppdize_name(ippGetString(media_attr, 0, NULL), media_source,
+ sizeof(media_source));
+ }
+
+ if (strlen(media_source) > 1) {
+ temp->media_source = (char*)malloc(sizeof(char)*32);
+ strcpy(temp->media_source,media_source);
+ debug_printf("Default MediaSource: %s\n", media_source);
+ }
+
+ if (temp->media_source == NULL) {
+ if (cluster_supports_given_attribute(cluster_name, IPP_TAG_KEYWORD,
+ "media-source-supported")) {
+ strcpy(temp->media_source,AUTO_OPTION);
+ debug_printf("Default MediaSource: %s\n", media_source);
+ }
+ }
+
+ if (temp->media_type == NULL) {
+ if (cluster_supports_given_attribute(cluster_name, IPP_TAG_KEYWORD,
+ "media-type-supported")) {
+ strcpy(temp->media_type, AUTO_OPTION);
+ debug_printf("Default MediaType: %s\n", media_type);
+ }
+ }
+ media_col_default = ippAddCollection(*merged_attributes, IPP_TAG_PRINTER,
+ "media-col-default", NULL);
+ current_media = create_media_col(temp->x, temp->y, temp->left_margin,
+ temp->right_margin, temp->top_margin,
+ temp->bottom_margin,
+ temp->media_source, temp->media_type);
+ ippSetCollection(*merged_attributes, &media_col_default, 0, current_media);
+ }
+
+ /*Finding the default colormodel for the cluster*/
+ if ((attr = ippFindAttribute(def_printer->prattrs, "urf-supported",
+ IPP_TAG_KEYWORD)) == NULL)
+ if ((attr = ippFindAttribute(def_printer->prattrs,
+ "pwg-raster-document-type-supported",
+ IPP_TAG_KEYWORD)) == NULL)
+ if ((attr = ippFindAttribute(def_printer->prattrs,
+ "print-color-mode-supported",
+ IPP_TAG_KEYWORD)) == NULL)
+ attr = ippFindAttribute(def_printer->prattrs, "output-mode-supported",
+ IPP_TAG_KEYWORD);
+
+ if (attr && ippGetCount(attr) > 0) {
+ *default_color = NULL;
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ keyword = ippGetString(attr, i, NULL);
+ if ((!strcasecmp(keyword, "black_1") ||
+ !strcmp(keyword, "bi-level") ||
+ !strcmp(keyword, "process-bi-level"))) {
+ if (!*default_color)
+ *default_color = "FastGray";
+ } else if ((!strcasecmp(keyword, "sgray_8") ||
+ !strncmp(keyword, "W8", 2) ||
+ !strcmp(keyword, "monochrome") ||
+ !strcmp(keyword, "process-monochrome"))) {
+ if (!*default_color || !strcmp(*default_color, "FastGray"))
+ *default_color = "Gray";
+ } else if (!strcasecmp(keyword, "sgray_16") ||
+ !strncmp(keyword, "W8-16", 5) ||
+ !strncmp(keyword, "W16", 3)) {
+ if (!*default_color || !strcmp(*default_color, "FastGray"))
+ *default_color = "Gray16";
+ } else if (!strcasecmp(keyword, "srgb_8") ||
+ !strncmp(keyword, "SRGB24", 6) ||
+ !strcmp(keyword, "color")) {
+ *default_color = "RGB";
+ } else if ((!strcasecmp(keyword, "srgb_16") ||
+ !strncmp(keyword, "SRGB48", 6)) &&
+ !ippContainsString(attr, "srgb_8")) {
+ *default_color = "RGB";
+ } else if (!strcasecmp(keyword, "adobe-rgb_16") ||
+ !strncmp(keyword, "ADOBERGB48", 10) ||
+ !strncmp(keyword, "ADOBERGB24-48", 13)) {
+ if (!*default_color)
+ *default_color = "AdobeRGB";
+ } else if ((!strcasecmp(keyword, "adobe-rgb_8") ||
+ !strcmp(keyword, "ADOBERGB24")) &&
+ !ippContainsString(attr, "adobe-rgb_16")) {
+ if (!*default_color)
+ *default_color = "AdobeRGB";
+ }
+ }
+ if (*default_color)
+ debug_printf("Default ColorModel : %s\n", *default_color);
+ }
+
+ if ((attr = ippFindAttribute(def_printer->prattrs, "output-bin-default",
+ IPP_TAG_ZERO)) != NULL) {
+ str = ippGetString(attr,0,NULL);
+ ippAddString(*merged_attributes, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-default", NULL, str);
+ debug_printf("Default OutputBin: %s\n", str);
+ } else {
+ if (cluster_supports_given_attribute(cluster_name,IPP_TAG_ZERO,
+ "output-bin-supported")) {
+ ippAddString(*merged_attributes, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "output-bin-default", NULL, AUTO_OPTION);
+ debug_printf("Default OutputBin: %s\n", AUTO_OPTION);
+ }
+ }
+
+ if ((attr = ippFindAttribute(def_printer->prattrs,
+ "print-content-optimize-default",
+ IPP_TAG_ZERO)) != NULL) {
+ str = ippGetString(attr, 0, NULL);
+ ippAddString(*merged_attributes, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-content-optimize-default", NULL, str);
+ debug_printf("Default print-content-optimize: %s\n", str);
+ } else {
+ if (cluster_supports_given_attribute(cluster_name, IPP_TAG_ZERO,
+ "print-content-optimize-default")) {
+ ippAddString(*merged_attributes, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-content-optimize-default", NULL, AUTO_OPTION);
+ debug_printf("Default print-content-optimize: %s\n", AUTO_OPTION);
+ }
+ }
+
+ if ((attr = ippFindAttribute(def_printer->prattrs,
+ "print-rendering-intent-default",
+ IPP_TAG_ZERO)) != NULL) {
+ str = ippGetString(attr, 0, NULL);
+ ippAddString(*merged_attributes, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-rendering-intent-default", NULL, str);
+ debug_printf("Default print-rendering-intent: %s\n", str);
+ } else {
+ if (cluster_supports_given_attribute(cluster_name, IPP_TAG_ZERO,
+ "print-rendering-intent-default")) {
+ ippAddString(*merged_attributes, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-rendering-intent-default", NULL, AUTO_OPTION);
+ debug_printf("Default print-rendering-intent: %s\n", AUTO_OPTION);
+ }
+ }
+
+ if ((attr = ippFindAttribute(def_printer->prattrs, "print-scaling-default",
+ IPP_TAG_ZERO)) != NULL) {
+ str = ippGetString(attr, 0, NULL);
+ ippAddString(*merged_attributes, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-scaling-default", NULL, str);
+ debug_printf("Default print-scaling: %s\n",str);
+ } else {
+ if (cluster_supports_given_attribute(cluster_name, IPP_TAG_ZERO,
+ "print-scaling-default")) {
+ ippAddString(*merged_attributes, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+ "print-scaling-default", NULL, AUTO_OPTION);
+ debug_printf("Default print-scaling: %s\n", AUTO_OPTION);
+ }
+ }
+
+ if ((attr = ippFindAttribute(def_printer->prattrs,
+ "printer-resolution-default",
+ IPP_TAG_ZERO)) != NULL) {
+ if ((res = ippResolutionToRes(attr, 0)) != NULL) {
+ xres = res->x;
+ yres = res->y;
+ ippAddResolution(*merged_attributes, IPP_TAG_PRINTER,
+ "printer-resolution-default",
+ IPP_RES_PER_INCH, xres, yres);
+ debug_printf("Default Resolution : %dx%d\n", xres, yres);
+ }
+ }
+
+ cupsArrayDelete(sizes);
+}
+
+/* Function to see which printer in the cluster supports the
+ requested job attributes*/
+int supports_job_attributes_requested(const gchar* printer, int printer_index,
+ int job_id, int *print_quality)
+{
+ char uri[1024];
+ http_t *http = NULL;
+ ipp_attribute_t *attr,*attr1;
+ ipp_t *request, *response = NULL;
+ const char *str,*side,*resource;
+ cups_array_t *job_sheet_supported,
+ *multiple_doc_supported,*print_qualities,
+ *media_type_supported,*staplelocation_supported,
+ *foldtype_supported,*punchmedia_supported,
+ *color_supported;
+ remote_printer_t *p;
+ int i,count,side_found,orien_req,orien,
+ orien_found;
+ cups_array_t *sizes;
+
+ p = (remote_printer_t *)cupsArrayIndex(remote_printers, printer_index);
+ static const char * const jattrs[] = /* Job attributes we want */
+ {
+ "all"
+ };
+
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ "localhost", ippPort(), "/printers/%s", printer);
+
+ /* Getting the resource */
+ resource = uri + (strlen(uri) - strlen(printer) - 10);
+
+ http = http_connect_local();
+ request = ippNewRequest(IPP_OP_GET_JOB_ATTRIBUTES);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
+ uri);
+ ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id",job_id);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
+ "requesting-user-name", NULL, cupsUser());
+ ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "requested-attributes",
+ (int)(sizeof(jattrs) / sizeof(jattrs[0])), NULL, jattrs);
+
+ response = cupsDoRequest(http, request,resource);
+ attr = ippFirstAttribute(response);
+
+ /* Document Format */
+/* if ((attr = ippFindAttribute(response, "document-format-detected",
+ IPP_TAG_MIMETYPE)) != NULL &&
+ ippGetCount(attr) > 0) {
+ str = ippGetString(attr,0, NULL);
+ debug_printf("The job-document is of the format %s\n.",str);
+ formats_supported = get_mimetype_attributes(p->prattrs);
+ if(!cupsArrayFind(formats_supported, (void *)str)){
+ debug_printf("Printer %s doesn't support the document format %s\n",
+ printer, str);
+ return 0;
+ }
+ }*/
+
+ /* Job Sheets*/
+ if ((attr = ippFindAttribute(response, "job-sheets",
+ IPP_TAG_ZERO)) != NULL &&
+ ippGetCount(attr) > 0) {
+ str = ippGetString(attr, 0, NULL);
+ debug_printf("The job-sheets %s is requested for the job\n", str);
+ job_sheet_supported = get_supported_options(p->prattrs,
+ "job-sheets-supported");
+ if (str) {
+ if (!cupsArrayFind(job_sheet_supported, (void *)str) &&
+ strcasecmp(str,"none")) {
+ debug_printf("Printer %s doesn't support the job-sheet %s\n", printer,
+ str);
+ return 0;
+ }
+ }
+ }
+
+ /*Multiple document handling*/
+ /* Can't get multiple-document-handling data from job templates*/
+ if ((attr = ippFindAttribute(response, "multiple-document-handling",
+ IPP_TAG_ZERO)) != NULL && ippGetCount(attr)>0) {
+ str = ippGetString(attr, 0, NULL);
+ debug_printf("The multiple-document-handling type %s is requested\n", str);
+ if (str) {
+ multiple_doc_supported =
+ get_supported_options(p->prattrs,
+ "multiple-document-handling-supported");
+ if (!cupsArrayFind(multiple_doc_supported, (void *)str)) {
+ debug_printf("Printer %s doesn't support the multiple document handling option %s\n",
+ printer, str);
+ return 0;
+ }
+ }
+ }
+
+ /* Media Type */
+ if ((attr = ippFindAttribute(response, "MediaType",
+ IPP_TAG_ZERO)) != NULL &&
+ ippGetCount(attr) > 0) {
+ str = ippGetString(attr,0, NULL);
+ debug_printf("The mediatype %s is requested for the job\n",str);
+ if (str != NULL) {
+ media_type_supported = get_supported_options(p->prattrs,
+ "media-type-supported");
+ if (!cupsArrayFind(media_type_supported, (void *)str) &&
+ strcasecmp(str,AUTO_OPTION)) {
+ debug_printf("Printer %s doesn't support the media-type %s\n",
+ printer, str);
+ return 0;
+ }
+ }
+ }
+
+ /* Staple Location*/
+ if ((attr = ippFindAttribute(response, "StapleLocation",
+ IPP_TAG_ZERO)) != NULL &&
+ ippGetCount(attr) > 0) {
+ str = ippGetString(attr, 0, NULL);
+ debug_printf("The staplelocation %s is requested for the job\n", str);
+ if (str != NULL) {
+ staplelocation_supported =
+ get_supported_options(p->prattrs, "StapleLocation");
+ if (!cupsArrayFind(staplelocation_supported, (void *)str) &&
+ strcasecmp(str,"None")) {
+ debug_printf("Printer %s doesn't support the staple location %s\n",
+ printer, str);
+ return 0;
+ }
+ }
+ }
+
+ /*FoldType*/
+ if ((attr = ippFindAttribute(response, "FoldType",
+ IPP_TAG_ZERO)) != NULL &&
+ ippGetCount(attr) > 0) {
+ str = ippGetString(attr, 0, NULL);
+ debug_printf("The FoldType %s is requested for the job\n", str);
+ if (str != NULL) {
+ foldtype_supported = get_supported_options(p->prattrs,"FoldType");
+ if (!cupsArrayFind(foldtype_supported, (void *)str) &&
+ strcasecmp(str,"None")) {
+ debug_printf("Printer %s doesn't support the FoldType %s\n",
+ printer, str);
+ return 0;
+ }
+ }
+ }
+
+ /*PunchMedia*/
+ if ((attr = ippFindAttribute(response, "PunchMedia",
+ IPP_TAG_ZERO)) != NULL &&
+ ippGetCount(attr) > 0) {
+ str = ippGetString(attr,0, NULL);
+ debug_printf("The PunchMedia %s is requested for the job\n", str);
+ if (str != NULL) {
+ punchmedia_supported = get_supported_options(p->prattrs,"PunchMedia");
+ if (!cupsArrayFind(punchmedia_supported, (void *)str) &&
+ strcasecmp(str,"none")) {
+ debug_printf("Printer %s doesn't support the PunchMedia %s\n",
+ printer, str);
+ return 0;
+ }
+ }
+ }
+
+ /*ColorModel*/
+ if ((attr = ippFindAttribute(response, "ColorModel",
+ IPP_TAG_ZERO)) != NULL &&
+ ippGetCount(attr) > 0) {
+ str = ippGetString(attr, 0, NULL);
+ debug_printf("The ColorModel %s is requested for the job\n", str);
+ if (str != NULL) {
+ color_supported = get_supported_options(p->prattrs, "ColorModel");
+ if (!cupsArrayFind(color_supported, (void *)str) &&
+ strcasecmp(str,"Gray")) {
+ debug_printf("Printer %s doesn't support the ColorModel %s\n",
+ printer, str);
+ return 0;
+ }
+ }
+ }
+
+ /* Sides supported*/
+ if ((attr = ippFindAttribute(response, "Duplex",
+ IPP_TAG_ZERO)) != NULL) {
+ side_found = 0;
+ str = ippGetString(attr, 0, NULL);
+ if (str) {
+ if ((attr1 = ippFindAttribute(p->prattrs, "sides-supported",
+ IPP_TAG_KEYWORD)) != NULL) {
+ for (i = 0, count = ippGetCount(attr1); i < count; i++) {
+ side = ippGetString(attr1, i, NULL);
+ debug_printf("The duplex option %s is requested\n", side);
+ if (!strcasecmp(str, "None") && !strcmp(side, "one-sided")) {
+ side_found = 1;
+ break;
+ } else if (!strcmp(str, "DuplexNoTumble") &&
+ !strcmp(side, "two-sided-long-edge")) {
+ side_found = 1;
+ break;
+ } else if (!strcmp(str, "DuplexTumble") &&
+ !strcmp(side, "two-sided-short-edge")) {
+ side_found = 1;
+ break;
+ }
+ }
+ if (!side_found) {
+ debug_printf("Printer %s doesn't support the required duplex options\n",
+ printer);
+ return 0;
+ }
+ }
+ }
+ }
+
+ /* Orientation Requested */
+ if ((attr = ippFindAttribute(response, "orientation-requested",
+ IPP_TAG_ENUM)) != NULL) {
+ orien_found = 0;
+ orien_req = ippGetInteger(attr, 0);
+ if ((attr1 = ippFindAttribute(p->prattrs,
+ "orientation-requested-supported",
+ IPP_TAG_ENUM)) != NULL) {
+ for (i = 0, count = ippGetCount(attr1); i < count; i ++) {
+ orien = ippGetInteger(attr1, i);
+ if (orien == orien_req) {
+ orien_found = 1;
+ break;
+ }
+ }
+ if (!orien_found) {
+ debug_printf("Printer %s doesn't support the requested orientation\n",
+ printer);
+ return 0;
+ }
+ }
+ }
+
+ /*Page Size*/
+ if ((attr = ippFindAttribute(response, "PageSize",
+ IPP_TAG_ZERO)) != NULL &&
+ ippGetCount(attr) > 0) {
+ str = ippGetString(attr, 0, NULL);
+ if (str) {
+ sizes = get_pagesize(p->prattrs);
+ if (!cupsArrayFind(sizes, (void*)str)) {
+ debug_printf("Printer %s doesn't support %s PageSize\n", p->uri, str);
+ return 0;
+ }
+ }
+ }
+
+ /*Print Quality*/
+ *print_quality = 4;
+ if ((attr = ippFindAttribute(response, "cupsPrintQuality",
+ IPP_TAG_ZERO)) != NULL &&
+ ippGetCount(attr) > 0) {
+ print_qualities = get_supported_options(p->prattrs, "cupsPrintQuality");
+ str = ippGetString(attr, 0, NULL);
+ debug_printf("%s\n", str);
+ if (str && !cupsArrayFind(print_qualities, (void*)str)) {
+ debug_printf("In\n");
+ if(!strcmp(str, "5"))
+ *print_quality = 5;
+ else if (!strcmp(str, "3"))
+ *print_quality = 3;
+ debug_printf("Printer doesn't support %s print quality\n",
+ !strcmp(str, "5") ? "HIGH": "DRAFT");
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
/*
* Remove all illegal characters and replace each group of such characters
@@ -794,17 +3373,17 @@ local_printer_has_uri (gpointer key,
gpointer user_data)
{
local_printer_t *printer = value;
- char *device_uri = user_data;
- char lhost[HTTP_MAX_URI], /* Local printer: Hostname */
- lresource[HTTP_MAX_URI],/* Local printer: Resource path */
- lscheme[32], /* Local printer: URI's scheme */
- lusername[64], /* Local printer: URI's username */
- dhost[HTTP_MAX_URI], /* Discovered printer: Hostname */
- dresource[HTTP_MAX_URI],/* Discovered printer: Resource path */
- dscheme[32], /* Discovered printer: URI's scheme */
- dusername[64]; /* Discovered printer: URI's username */
- int lport = 0, /* Local printer: URI's port number */
- dport = 0; /* Discovered printer: URI's port number */
+ char *device_uri = user_data;
+ char lhost[HTTP_MAX_URI], /* Local printer: Hostname */
+ lresource[HTTP_MAX_URI], /* Local printer: Resource path */
+ lscheme[32], /* Local printer: URI's scheme */
+ lusername[64], /* Local printer: URI's username */
+ dhost[HTTP_MAX_URI], /* Discovered printer: Hostname */
+ dresource[HTTP_MAX_URI], /* Discovered printer: Resource path */
+ dscheme[32], /* Discovered printer: URI's scheme */
+ dusername[64]; /* Discovered printer: URI's username */
+ int lport = 0, /* Local printer: URI's port number */
+ dport = 0; /* Discovered printer: URI's port number */
debug_printf("local_printer_has_uri() in THREAD %ld\n", pthread_self());
/* Separate the two URIs to be compared into their components */
@@ -1081,7 +3660,7 @@ prepare_browse_data (void)
break;
}
} else if (!strcasecmp(attrname, "printer-state") &&
- value_tag == IPP_TAG_ENUM)
+ value_tag == IPP_TAG_ENUM)
state = ippGetInteger(attr, 0);
else if (!strcasecmp(attrname, "printer-uri-supported") &&
value_tag == IPP_TAG_URI)
@@ -1302,7 +3881,7 @@ color_space_score(const char *color_space)
} else if (!strncasecmp(p, "rgb", 3)) {
p += 3;
score += 5000;
- }
+ }
if (!strncasecmp(p, "-", 1) || !strncasecmp(p, "_", 1)) {
p += 1;
}
@@ -1318,20 +3897,17 @@ color_space_score(const char *color_space)
* 'ldap_rebind_proc()' - Callback function for LDAP rebind
*/
-static int /* O - Result code */
-ldap_rebind_proc(
- LDAP *RebindLDAPHandle, /* I - LDAP handle */
- LDAP_CONST char *refsp, /* I - ??? */
- ber_tag_t request, /* I - ??? */
- ber_int_t msgid, /* I - ??? */
- void *params) /* I - ??? */
+static int /* O - Result code */
+ldap_rebind_proc(LDAP *RebindLDAPHandle, /* I - LDAP handle */
+ LDAP_CONST char *refsp, /* I - ??? */
+ ber_tag_t request, /* I - ??? */
+ ber_int_t msgid, /* I - ??? */
+ void *params) /* I - ??? */
{
- int rc; /* Result code */
+ int rc; /* Result code */
# if LDAP_API_VERSION > 3000
- struct berval bval; /* Bind value */
+ struct berval bval; /* Bind value */
# endif /* LDAP_API_VERSION > 3000 */
-
-
(void)request;
(void)msgid;
(void)params;
@@ -1362,50 +3938,48 @@ ldap_rebind_proc(
* 'ldap_rebind_proc()' - Callback function for LDAP rebind
*/
-static int /* O - Result code */
-ldap_rebind_proc(
- LDAP *RebindLDAPHandle, /* I - LDAP handle */
- char **dnp, /* I - ??? */
- char **passwdp, /* I - ??? */
- int *authmethodp, /* I - ??? */
- int freeit, /* I - ??? */
- void *arg) /* I - ??? */
+static int /* O - Result code */
+ldap_rebind_proc(LDAP *RebindLDAPHandle, /* I - LDAP handle */
+ char **dnp, /* I - ??? */
+ char **passwdp, /* I - ??? */
+ int *authmethodp, /* I - ??? */
+ int freeit, /* I - ??? */
+ void *arg) /* I - ??? */
{
- switch (freeit)
- {
- case 1:
- /*
- * Free current values...
- */
+ switch (freeit) {
+ case 1:
+ /*
+ * Free current values...
+ */
- debug_printf("ldap_rebind_proc: Free values...\n");
+ debug_printf("ldap_rebind_proc: Free values...\n");
- if (dnp && *dnp)
- free(*dnp);
+ if (dnp && *dnp)
+ free(*dnp);
- if (passwdp && *passwdp)
- free(*passwdp);
- break;
+ if (passwdp && *passwdp)
+ free(*passwdp);
+ break;
- case 0:
- /*
- * Return credentials for LDAP referal...
- */
+ case 0:
+ /*
+ * Return credentials for LDAP referal...
+ */
- debug_printf("ldap_rebind_proc: Return necessary values...\n");
+ debug_printf("ldap_rebind_proc: Return necessary values...\n");
- *dnp = strdup(BrowseLDAPBindDN);
- *passwdp = strdup(BrowseLDAPPassword);
- *authmethodp = LDAP_AUTH_SIMPLE;
- break;
+ *dnp = strdup(BrowseLDAPBindDN);
+ *passwdp = strdup(BrowseLDAPPassword);
+ *authmethodp = LDAP_AUTH_SIMPLE;
+ break;
- default:
- /*
- * Should never happen...
- */
+ default:
+ /*
+ * Should never happen...
+ */
- debug_printf("LDAP rebind has been called with wrong freeit value!\n");
- break;
+ debug_printf("LDAP rebind has been called with wrong freeit value!\n");
+ break;
}
return (LDAP_SUCCESS);
@@ -1419,17 +3993,17 @@ ldap_rebind_proc(
* 'ldap_connect()' - Start new LDAP connection
*/
-static LDAP * /* O - LDAP handle */
+static LDAP * /* O - LDAP handle */
ldap_connect(void)
{
- int rc; /* LDAP API status */
- int version = 3; /* LDAP version */
- struct berval bv = {0, ""}; /* SASL bind value */
- LDAP *TempBrowseLDAPHandle=NULL;
- /* Temporary LDAP Handle */
+ int rc; /* LDAP API status */
+ int version = 3; /* LDAP version */
+ struct berval bv = {0, ""}; /* SASL bind value */
+ LDAP *TempBrowseLDAPHandle=NULL;
+ /* Temporary LDAP Handle */
# if defined(HAVE_LDAP_SSL) && defined (HAVE_MOZILLA_LDAP)
- int ldap_ssl = 0; /* LDAP SSL indicator */
- int ssl_err = 0; /* LDAP SSL error value */
+ int ldap_ssl = 0; /* LDAP SSL indicator */
+ int ssl_err = 0; /* LDAP SSL error value */
# endif /* defined(HAVE_LDAP_SSL) && defined (HAVE_MOZILLA_LDAP) */
@@ -1439,13 +4013,12 @@ ldap_connect(void)
* Set the certificate file to use for encrypted LDAP sessions...
*/
- if (BrowseLDAPCACertFile)
- {
+ if (BrowseLDAPCACertFile) {
debug_printf("ldap_connect: Setting CA certificate file \"%s\"\n",
- BrowseLDAPCACertFile);
+ BrowseLDAPCACertFile);
if ((rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE,
- (void *)BrowseLDAPCACertFile)) != LDAP_SUCCESS)
+ (void *)BrowseLDAPCACertFile)) != LDAP_SUCCESS)
debug_printf("Unable to set CA certificate file for LDAP "
"connections: %d - %s\n", rc, ldap_err2string(rc));
}
@@ -1463,16 +4036,15 @@ ldap_connect(void)
# else /* HAVE_OPENLDAP */
- int ldap_port = 0; /* LDAP port */
- char ldap_protocol[11], /* LDAP protocol */
- ldap_host[255]; /* LDAP host */
+ int ldap_port = 0; /* LDAP port */
+ char ldap_protocol[11], /* LDAP protocol */
+ ldap_host[255]; /* LDAP host */
/*
* Split LDAP URI into its components...
*/
- if (!BrowseLDAPServer)
- {
+ if (!BrowseLDAPServer) {
debug_printf("BrowseLDAPServer not configured!\n");
debug_printf("Disabling LDAP browsing!\n");
/*BrowseLocalProtocols &= ~BROWSE_LDAP;*/
@@ -1487,8 +4059,7 @@ ldap_connect(void)
ldap_ssl = 0;
else if (!strcmp(ldap_protocol, "ldaps"))
ldap_ssl = 1;
- else
- {
+ else {
debug_printf("Unrecognized LDAP protocol (%s)!\n",
ldap_protocol);
debug_printf("Disabling LDAP browsing!\n");
@@ -1497,8 +4068,7 @@ ldap_connect(void)
return (NULL);
}
- if (ldap_port == 0)
- {
+ if (ldap_port == 0) {
if (ldap_ssl)
ldap_port = LDAPS_PORT;
else
@@ -1506,46 +4076,37 @@ ldap_connect(void)
}
debug_printf("ldap_connect: PROT:%s HOST:%s PORT:%d\n",
- ldap_protocol, ldap_host, ldap_port);
+ ldap_protocol, ldap_host, ldap_port);
/*
* Initialize LDAP connection...
*/
- if (!ldap_ssl)
- {
+ if (!ldap_ssl) {
if ((TempBrowseLDAPHandle = ldap_init(ldap_host, ldap_port)) == NULL)
rc = LDAP_OPERATIONS_ERROR;
else
rc = LDAP_SUCCESS;
# ifdef HAVE_LDAP_SSL
- }
- else
- {
+ } else {
/*
* Initialize SSL LDAP connection...
*/
- if (BrowseLDAPCACertFile)
- {
+ if (BrowseLDAPCACertFile) {
rc = ldapssl_client_init(BrowseLDAPCACertFile, (void *)NULL);
- if (rc != LDAP_SUCCESS)
- {
+ if (rc != LDAP_SUCCESS) {
debug_printf("Failed to initialize LDAP SSL client!\n");
rc = LDAP_OPERATIONS_ERROR;
- }
- else
- {
+ } else {
if ((TempBrowseLDAPHandle = ldapssl_init(ldap_host, ldap_port,
1)) == NULL)
rc = LDAP_OPERATIONS_ERROR;
else
rc = LDAP_SUCCESS;
}
- }
- else
- {
+ } else {
debug_printf("LDAP SSL certificate file/database not configured!\n");
rc = LDAP_OPERATIONS_ERROR;
}
@@ -1567,14 +4128,12 @@ ldap_connect(void)
* Check return code from LDAP initialize...
*/
- if (rc != LDAP_SUCCESS)
- {
+ if (rc != LDAP_SUCCESS) {
debug_printf("Unable to initialize LDAP!\n");
if (rc == LDAP_SERVER_DOWN || rc == LDAP_CONNECT_ERROR)
debug_printf("Temporarily disabling LDAP browsing...\n");
- else
- {
+ else {
debug_printf("Disabling LDAP browsing!\n");
/*BrowseLocalProtocols &= ~BROWSE_LDAP;*/
@@ -1591,8 +4150,7 @@ ldap_connect(void)
*/
if (ldap_set_option(TempBrowseLDAPHandle, LDAP_OPT_PROTOCOL_VERSION,
- (const void *)&version) != LDAP_SUCCESS)
- {
+ (const void *)&version) != LDAP_SUCCESS) {
debug_printf("Unable to set LDAP protocol version %d!\n",
version);
debug_printf("Disabling LDAP browsing!\n");
@@ -1637,21 +4195,20 @@ ldap_connect(void)
rc = ldap_sasl_bind_s(TempBrowseLDAPHandle, NULL, "EXTERNAL", &bv, NULL,
NULL, NULL);
else
- rc = ldap_sasl_bind_s(TempBrowseLDAPHandle, BrowseLDAPBindDN, LDAP_SASL_SIMPLE, &bval, NULL, NULL, NULL);
+ rc = ldap_sasl_bind_s(TempBrowseLDAPHandle, BrowseLDAPBindDN,
+ LDAP_SASL_SIMPLE, &bval, NULL, NULL, NULL);
# else
- rc = ldap_bind_s(TempBrowseLDAPHandle, BrowseLDAPBindDN,
- BrowseLDAPPassword, LDAP_AUTH_SIMPLE);
+ rc = ldap_bind_s(TempBrowseLDAPHandle, BrowseLDAPBindDN,
+ BrowseLDAPPassword, LDAP_AUTH_SIMPLE);
# endif /* LDAP_API_VERSION > 3000 */
- if (rc != LDAP_SUCCESS)
- {
+ if (rc != LDAP_SUCCESS) {
debug_printf("LDAP bind failed with error %d: %s\n",
rc, ldap_err2string(rc));
# if defined(HAVE_LDAP_SSL) && defined (HAVE_MOZILLA_LDAP)
- if (ldap_ssl && (rc == LDAP_SERVER_DOWN || rc == LDAP_CONNECT_ERROR))
- {
+ if (ldap_ssl && (rc == LDAP_SERVER_DOWN || rc == LDAP_CONNECT_ERROR)) {
ssl_err = PORT_GetError();
if (ssl_err != 0)
debug_printf("LDAP SSL error %d: %s\n", ssl_err,
@@ -1674,11 +4231,10 @@ ldap_connect(void)
* 'ldap_reconnect()' - Reconnect to LDAP Server
*/
-static LDAP * /* O - New LDAP handle */
+static LDAP * /* O - New LDAP handle */
ldap_reconnect(void)
{
- LDAP *TempBrowseLDAPHandle = NULL; /* Temp Handle to LDAP server */
-
+ LDAP *TempBrowseLDAPHandle = NULL; /* Temp Handle to LDAP server */
/*
* Get a new LDAP Handle and replace the global Handle
@@ -1689,8 +4245,7 @@ ldap_reconnect(void)
TempBrowseLDAPHandle = ldap_connect();
- if (TempBrowseLDAPHandle != NULL)
- {
+ if (TempBrowseLDAPHandle != NULL) {
if (BrowseLDAPHandle != NULL)
ldap_disconnect(BrowseLDAPHandle);
@@ -1706,10 +4261,9 @@ ldap_reconnect(void)
*/
static void
-ldap_disconnect(LDAP *ld) /* I - LDAP handle */
+ldap_disconnect(LDAP *ld) /* I - LDAP handle */
{
- int rc; /* Return code */
-
+ int rc; /* Return code */
/*
* Close LDAP handle...
@@ -1733,24 +4287,24 @@ ldap_disconnect(LDAP *ld) /* I - LDAP handle */
void
cupsdUpdateLDAPBrowse(void)
{
- char uri[HTTP_MAX_URI], /* Printer URI */
- host[HTTP_MAX_URI], /* Hostname */
- resource[HTTP_MAX_URI], /* Resource path */
- local_resource[HTTP_MAX_URI], /* Resource path */
- service_name[2048],
- location[1024], /* Printer location */
- info[1024], /* Printer information */
- make_model[1024], /* Printer make and model */
- type_num[30], /* Printer type number */
- scheme[32], /* URI's scheme */
- username[64]; /* URI's username */
- int port; /* URI's port number */
- char *c;
- int hl;
- int rc; /* LDAP status */
- int limit; /* Size limit */
- LDAPMessage *res, /* LDAP search results */
- *e; /* Current entry from search */
+ char uri[HTTP_MAX_URI], /* Printer URI */
+ host[HTTP_MAX_URI], /* Hostname */
+ resource[HTTP_MAX_URI], /* Resource path */
+ local_resource[HTTP_MAX_URI], /* Resource path */
+ service_name[2048],
+ location[1024], /* Printer location */
+ info[1024], /* Printer information */
+ make_model[1024], /* Printer make and model */
+ type_num[30], /* Printer type number */
+ scheme[32], /* URI's scheme */
+ username[64]; /* URI's username */
+ int port; /* URI's port number */
+ char *c;
+ int hl;
+ int rc; /* LDAP status */
+ int limit; /* Size limit */
+ LDAPMessage *res, /* LDAP search results */
+ *e; /* Current entry from search */
debug_printf("UpdateLDAPBrowse\n");
@@ -1758,8 +4312,7 @@ cupsdUpdateLDAPBrowse(void)
* Reconnect if LDAP Handle is invalid...
*/
- if (! BrowseLDAPHandle)
- {
+ if (! BrowseLDAPHandle) {
ldap_reconnect();
return;
}
@@ -1776,10 +4329,9 @@ cupsdUpdateLDAPBrowse(void)
* and temporary disable LDAP updates...
*/
- if (rc != LDAP_SUCCESS)
- {
- if (BrowseLDAPUpdate && ((rc == LDAP_SERVER_DOWN) || (rc == LDAP_CONNECT_ERROR)))
- {
+ if (rc != LDAP_SUCCESS) {
+ if (BrowseLDAPUpdate && ((rc == LDAP_SERVER_DOWN) ||
+ (rc == LDAP_CONNECT_ERROR))) {
BrowseLDAPUpdate = FALSE;
debug_printf("LDAP update temporary disabled\n");
}
@@ -1790,8 +4342,7 @@ cupsdUpdateLDAPBrowse(void)
* If LDAP updates were disabled, we will reenable them...
*/
- if (! BrowseLDAPUpdate)
- {
+ if (!BrowseLDAPUpdate) {
BrowseLDAPUpdate = TRUE;
debug_printf("LDAP update enabled\n");
}
@@ -1802,8 +4353,7 @@ cupsdUpdateLDAPBrowse(void)
limit = ldap_count_entries(BrowseLDAPHandle, res);
debug_printf("LDAP search returned %d entries\n", limit);
- if (limit < 1)
- {
+ if (limit < 1) {
ldap_freeres(res);
return;
}
@@ -1814,8 +4364,7 @@ cupsdUpdateLDAPBrowse(void)
for (e = ldap_first_entry(BrowseLDAPHandle, res);
e;
- e = ldap_next_entry(BrowseLDAPHandle, e))
- {
+ e = ldap_next_entry(BrowseLDAPHandle, e)) {
/*
* Get the required values from this entry...
*/
@@ -1825,15 +4374,18 @@ cupsdUpdateLDAPBrowse(void)
continue;
if (ldap_getval_firststring(BrowseLDAPHandle, e,
- "printerLocation", location, sizeof(location)) == -1)
+ "printerLocation", location,
+ sizeof(location)) == -1)
continue;
if (ldap_getval_firststring(BrowseLDAPHandle, e,
- "printerMakeAndModel", make_model, sizeof(make_model)) == -1)
+ "printerMakeAndModel", make_model,
+ sizeof(make_model)) == -1)
continue;
if (ldap_getval_firststring(BrowseLDAPHandle, e,
- "printerType", type_num, sizeof(type_num)) == -1)
+ "printerType", type_num,
+ sizeof(type_num)) == -1)
continue;
if (ldap_getval_firststring(BrowseLDAPHandle, e,
@@ -1898,17 +4450,17 @@ cupsdUpdateLDAPBrowse(void)
* 'ldap_search_rec()' - LDAP Search with reconnect
*/
-static int /* O - Return code */
-ldap_search_rec(LDAP *ld, /* I - LDAP handler */
- char *base, /* I - Base dn */
- int scope, /* I - LDAP search scope */
- char *filter, /* I - Filter string */
- char *attrs[], /* I - Requested attributes */
- int attrsonly, /* I - Return only attributes? */
- LDAPMessage **res) /* I - LDAP handler */
+static int /* O - Return code */
+ldap_search_rec(LDAP *ld, /* I - LDAP handler */
+ char *base, /* I - Base dn */
+ int scope, /* I - LDAP search scope */
+ char *filter, /* I - Filter string */
+ char *attrs[], /* I - Requested attributes */
+ int attrsonly, /* I - Return only attributes? */
+ LDAPMessage **res) /* I - LDAP handler */
{
- int rc; /* Return code */
- LDAP *ldr; /* LDAP handler after reconnect */
+ int rc; /* Return code */
+ LDAP *ldr; /* LDAP handler after reconnect */
# if defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000
@@ -1922,8 +4474,7 @@ ldap_search_rec(LDAP *ld, /* I - LDAP handler */
* If we have a connection problem try again...
*/
- if (rc == LDAP_SERVER_DOWN || rc == LDAP_CONNECT_ERROR)
- {
+ if (rc == LDAP_SERVER_DOWN || rc == LDAP_CONNECT_ERROR) {
debug_printf("LDAP search failed with status %d: %s\n",
rc, ldap_err2string(rc));
debug_printf("We try the LDAP search once again after reconnecting to "
@@ -1957,10 +4508,9 @@ ldap_search_rec(LDAP *ld, /* I - LDAP handler */
*/
static void
-ldap_freeres(LDAPMessage *entry) /* I - LDAP handler */
+ldap_freeres(LDAPMessage *entry) /* I - LDAP handler */
{
- int rc; /* Return value */
-
+ int rc; /* Return value */
rc = ldap_msgfree(entry);
if (rc == -1)
@@ -1974,76 +4524,68 @@ ldap_freeres(LDAPMessage *entry) /* I - LDAP handler */
* 'ldap_getval_char()' - Get first LDAP value and convert to string
*/
-static int /* O - Return code */
-ldap_getval_firststring(
- LDAP *ld, /* I - LDAP handler */
- LDAPMessage *entry, /* I - LDAP message or search result */
- char *attr, /* I - the wanted attribute */
- char *retval, /* O - String to return */
- unsigned long maxsize) /* I - Max string size */
+static int /* O - Return code */
+ldap_getval_firststring(LDAP *ld, /* I - LDAP handler */
+ LDAPMessage *entry, /* I - LDAP message or search
+ result */
+ char *attr, /* I - the wanted attribute */
+ char *retval, /* O - String to return */
+ unsigned long maxsize) /* I - Max string size */
{
- char *dn; /* LDAP DN */
- int rc = 0; /* Return code */
+ char *dn; /* LDAP DN */
+ int rc = 0; /* Return code */
# if defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000
- struct berval **bval; /* LDAP value array */
- unsigned long size; /* String size */
+ struct berval **bval; /* LDAP value array */
+ unsigned long size; /* String size */
/*
* Get value from LDAPMessage...
*/
- if ((bval = ldap_get_values_len(ld, entry, attr)) == NULL)
- {
+ if ((bval = ldap_get_values_len(ld, entry, attr)) == NULL) {
rc = -1;
dn = ldap_get_dn(ld, entry);
debug_printf("Failed to get LDAP value %s for %s!\n",
attr, dn);
ldap_memfree(dn);
- }
- else
- {
+ } else {
/*
* Check size and copy value into our string...
*/
size = maxsize;
- if (size < (bval[0]->bv_len + 1))
- {
+ if (size < (bval[0]->bv_len + 1)) {
rc = -1;
dn = ldap_get_dn(ld, entry);
debug_printf("Attribute %s is too big! (dn: %s)\n",
attr, dn);
ldap_memfree(dn);
- }
- else
+ } else
size = bval[0]->bv_len + 1;
strncpy(retval, bval[0]->bv_val, size);
if (size > 0)
- retval[size - 1] = '\0';
+ retval[size - 1] = '\0';
ldap_value_free_len(bval);
}
# else
- char **value; /* LDAP value */
+ char **value; /* LDAP value */
/*
* Get value from LDAPMessage...
*/
- if ((value = (char **)ldap_get_values(ld, entry, attr)) == NULL)
- {
+ if ((value = (char **)ldap_get_values(ld, entry, attr)) == NULL) {
rc = -1;
dn = ldap_get_dn(ld, entry);
debug_printf("Failed to get LDAP value %s for %s!\n",
attr, dn);
ldap_memfree(dn);
- }
- else
- {
+ } else {
strncpy(retval, *value, maxsize);
if (maxsize > 0)
- retval[maxsize - 1] = '\0';
+ retval[maxsize - 1] = '\0';
ldap_value_free(value);
}
# endif /* defined(HAVE_OPENLDAP) && LDAP_API_VERSION > 3000 */
@@ -2214,11 +4756,11 @@ log_cluster(remote_printer_t *p) {
int i;
if (p == NULL || (!debug_stderr && !debug_logfile))
return;
- if (p->netprinter) {
- debug_printf("Printer %s is not a remote CUPS printer, load-balanced clustering not supported.\n",
- p->queue_name);
- return;
- }
+ /* if (p->netprinter) {
+ debug_printf("Printer %s is not a remote CUPS printer, load-balanced clustering not supported.\n",
+ p->queue_name);
+ return;
+ }*/
if (p->slave_of)
q = p->slave_of;
else
@@ -2242,13 +4784,15 @@ log_all_printers() {
debug_printf("=== Remote printer overview ===\n");
for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
p; p = (remote_printer_t *)cupsArrayNext(remote_printers))
- debug_printf("Printer %s (%s, %s): Local queue %s, %s, Slave of %s%s\n", p->uri,
+ debug_printf("Printer %s (%s, %s): Local queue %s, %s, Slave of %s%s\n",
+ p->uri,
p->host, (p->ip ? p->ip : "IP not determined"), p->queue_name,
(p->netprinter ? "IPP Printer" : "Remote CUPS Printer"),
((q = p->slave_of) != NULL ? q->uri : "None"),
(p->status == STATUS_UNCONFIRMED ? " (Unconfirmed)" :
(p->status == STATUS_DISAPPEARED ? " (Disappeared)" :
- (p->status == STATUS_TO_BE_RELEASED ? " (To be released from cups-browsed)" :
+ (p->status == STATUS_TO_BE_RELEASED ?
+ " (To be released from cups-browsed)" :
(p->status == STATUS_TO_BE_CREATED ?
" (To be created/updated)" : "")))));
debug_printf("===============================\n");
@@ -2341,8 +4885,8 @@ is_disabled(const char *printer, const char *reason) {
return pstatemsg;
else {
if (pstatemsg != NULL) {
- free(pstatemsg);
- pstatemsg = NULL;
+ free(pstatemsg);
+ pstatemsg = NULL;
}
return NULL;
}
@@ -2429,7 +4973,7 @@ disable_printer (const char *printer, const char *reason) {
int
set_cups_default_printer(const char *printer) {
- ipp_t *request;
+ ipp_t *request;
char uri[HTTP_MAX_URI];
http_t *conn = NULL;
@@ -2498,7 +5042,7 @@ get_cups_default_printer() {
}
}
if (default_printer_name)
- break;
+ break;
}
}
@@ -2611,30 +5155,30 @@ record_printer_options(const char *printer) {
int i;
/* List of IPP attributes to get recorded */
static const char *attrs_to_record[] =
- {
- "*-default",
- "auth-info-required",
- /*"device-uri",*/
- "job-quota-period",
- "job-k-limit",
- "job-page-limit",
- /*"port-monitor",*/
- "printer-error-policy",
- "printer-info",
- "printer-is-accepting-jobs",
- "printer-is-shared",
- "printer-geo-location",
- "printer-location",
- "printer-op-policy",
- "printer-organization",
- "printer-organizational-unit",
- /*"printer-state",
- "printer-state-message",
- "printer-state-reasons",*/
- "requesting-user-name-allowed",
- "requesting-user-name-denied",
- NULL
- };
+ {
+ "*-default",
+ "auth-info-required",
+ /*"device-uri",*/
+ "job-quota-period",
+ "job-k-limit",
+ "job-page-limit",
+ /*"port-monitor",*/
+ "printer-error-policy",
+ "printer-info",
+ "printer-is-accepting-jobs",
+ "printer-is-shared",
+ "printer-geo-location",
+ "printer-location",
+ "printer-op-policy",
+ "printer-organization",
+ "printer-organizational-unit",
+ /*"printer-state",
+ "printer-state-message",
+ "printer-state-reasons",*/
+ "requesting-user-name-allowed",
+ "requesting-user-name-denied",
+ NULL
+ };
const char **ptr;
http_t *conn = NULL;
@@ -2844,7 +5388,7 @@ queue_removal_handle_default(const char *printer) {
return 0;
/* Record the fact that this printer was default */
if (record_default_printer(default_printer, 0) < 0) {
- /* Delete record file if recording failed */
+ /* Delete record file if recording failed */
debug_printf("ERROR: Failed recording remote default printer (%s). Removing the file with possible old recording.\n",
printer);
invalidate_default_printer(0);
@@ -2875,7 +5419,7 @@ get_local_queue_name(const char *service_name,
int *is_cups_queue,
const char *exclude) {
char *queue_name = NULL, *backup_queue_name = NULL,
- *local_queue_name = NULL, *local_queue_name_lower = NULL;
+ *local_queue_name = NULL, *local_queue_name_lower = NULL;
local_printer_t *local_printer = NULL;
cluster_t *cluster = NULL;
char *member = NULL, *str = NULL;
@@ -2982,67 +5526,66 @@ get_local_queue_name(const char *service_name,
return NULL;
}
- if (*is_cups_queue) {
- /* Check whether our new printer matches one of the user-defined
- printer clusters */
+ /* Check whether our new printer matches one of the user-defined
+ printer clusters */
+ for (cluster = cupsArrayFirst(clusters);
+ cluster;
+ cluster = cupsArrayNext(clusters)) {
+ if (exclude && !strcasecmp(cluster->local_queue_name, exclude))
+ continue;
+ local_queue_name_lower = g_ascii_strdown(cluster->local_queue_name, -1);
+ local_printer = g_hash_table_lookup (local_printers,
+ local_queue_name_lower);
+ free(local_queue_name_lower);
+ if (local_printer && !local_printer->cups_browsed_controlled)
+ continue;
+ for (member = cupsArrayFirst(cluster->members);
+ member;
+ member = cupsArrayNext(cluster->members)) {
+ /* Match remote CUPS queue name */
+ if ((str = strrchr(resource, '/')) != NULL && strlen(str) > 1) {
+ str = remove_bad_chars(str + 1, 2);
+ if (strcasecmp(member, str) == 0) /* Match */
+ break;
+ free(str);
+ }
+ /* Match make and model */
+ if (make_model) {
+ str = remove_bad_chars(make_model, 2);
+ if (strcasecmp(member, str) == 0) /* Match */
+ break;
+ free(str);
+ }
+ /* Match DNS-SD service name */
+ if (service_name) {
+ str = remove_bad_chars(service_name, 2);
+ if (strcasecmp(member, str) == 0) /* Match */
+ break;
+ free(str);
+ }
+ }
+ if (member)
+ break;
+ }
+ if (cluster) {
+ local_queue_name = strdup(cluster->local_queue_name);
+ *is_cups_queue = 2;
+ free(str);
+ } else if (AutoClustering) {
+ /* If we do automatic clustering by matching queue names, do not
+ add a queue to a manually defined cluster because it matches
+ the cluster's local queue name. Manually defined clusters can
+ only be joined by printers which match one of the cluster's
+ member names */
for (cluster = cupsArrayFirst(clusters);
cluster;
cluster = cupsArrayNext(clusters)) {
- if (exclude && !strcasecmp(cluster->local_queue_name, exclude))
- continue;
- local_queue_name_lower = g_ascii_strdown(cluster->local_queue_name, -1);
- local_printer = g_hash_table_lookup (local_printers,
- local_queue_name_lower);
- free(local_queue_name_lower);
- if (local_printer && !local_printer->cups_browsed_controlled)
- continue;
- for (member = cupsArrayFirst(cluster->members);
- member;
- member = cupsArrayNext(cluster->members)) {
- /* Match remote CUPS queue name */
- if ((str = strrchr(resource, '/')) != NULL && strlen(str) > 1) {
- str = remove_bad_chars(str + 1, 2);
- if (strcasecmp(member, str) == 0) /* Match */
- break;
- free(str);
- }
- /* Match make and model */
- if (make_model) {
- str = remove_bad_chars(make_model, 2);
- if (strcasecmp(member, str) == 0) /* Match */
- break;
- free(str);
- }
- /* Match DNS-SD service name */
- if (service_name) {
- str = remove_bad_chars(service_name, 2);
- if (strcasecmp(member, str) == 0) /* Match */
- break;
- free(str);
- }
- }
- if (member)
- break;
- }
- if (cluster) {
- local_queue_name = strdup(cluster->local_queue_name);
- *is_cups_queue = 2;
- free(str);
- } else if (AutoClustering) {
- /* If we do automatic clustering by matching queue names, do not
- add a queue to a manually defined cluster because it matches
- the cluster's local queue name. Manually defined clusters can
- only be joined by printers which match one of the cluster's
- member names */
- for (cluster = cupsArrayFirst(clusters);
- cluster;
- cluster = cupsArrayNext(clusters)) {
- if (strcasecmp(local_queue_name, cluster->local_queue_name) == 0) {
- debug_printf("We have already a manually defined printer cluster with the name %s. Automatic clustering does not add this printer to this cluster as it does not match any of the cluster's member names. Skipping this printer.\n", local_queue_name);
- debug_printf("In cups-browsed.conf try \"LocalQueueNamingRemoteCUPS DNS-SD\" or give another name to your manually defined cluster (\"Cluster\" directive) to avoid name clashes.\n");
- free(local_queue_name);
- return NULL;
- }
+ if (strcasecmp(local_queue_name, cluster->local_queue_name) == 0) {
+ debug_printf("We have already a manually defined printer cluster with the name %s. Automatic clustering does not add this printer to this cluster as it does not match any of the cluster's member names. Skipping this printer.\n",
+ local_queue_name);
+ debug_printf("In cups-browsed.conf try \"LocalQueueNamingRemoteCUPS DNS-SD\" or give another name to your manually defined cluster (\"Cluster\" directive) to avoid name clashes.\n");
+ free(local_queue_name);
+ return NULL;
}
}
}
@@ -3067,16 +5610,12 @@ join_cluster_if_needed(remote_printer_t *p,
!q->slave_of) /* Find the master of the queues with this name,
to avoid "daisy chaining" */
break;
- if (q && AutoClustering == 0 && is_cups_queue == 1) {
+ if (q && AutoClustering == 0 && (is_cups_queue == 1 ||is_cups_queue == 0) ) {
debug_printf("We have already created a queue with the name %s for another remote CUPS printer but automatic clustering of equally named printers is turned off nor did we find a manually defined cluster this printer belongs to. Skipping this printer.\n", p->queue_name);
debug_printf("In cups-browsed.conf try setting \"AutoClustering On\" to cluster equally-named remote CUPS printers, \"LocalQueueNamingRemoteCUPS DNS-SD\" to avoid queue name clashes, or define clusters with the \"Cluster\" directive.\n");
return -1;
}
- if (q && q->netprinter == 1) {
- debug_printf("We have already created a queue with the name %s for another printer which is not a remote CUPS printer. Skipping this printer.\n", p->queue_name);
- debug_printf("Try setting \"LocalQueueNamingRemoteCUPS DNS-SD\" or \"LocalQueueNamingRemoteCUPS RemoteName\" in cups-browsed.conf.\n");
- return -1;
- }
+
p->slave_of = (q && q->status != STATUS_DISAPPEARED &&
q->status != STATUS_UNCONFIRMED &&
q->status != STATUS_TO_BE_RELEASED) ? q : NULL;
@@ -3106,39 +5645,7 @@ on_printer_state_changed (CupsNotifier *object,
gboolean printer_is_accepting_jobs,
gpointer user_data)
{
- int i;
char *ptr, buf[2048];
- remote_printer_t *p, *q;
- http_t *http = NULL;
- ipp_t *request, *response;
- ipp_attribute_t *attr;
- const char *pname = NULL;
- char *remote_cups_queue;
- ipp_pstate_t pstate = IPP_PRINTER_IDLE;
- int paccept = 0;
- int num_jobs, min_jobs = 99999999;
- cups_job_t *jobs = NULL;
- const char *dest_host = NULL;
- int dest_port = 0;
- char dest_name[1024];
- int dest_index = 0;
- int valid_dest_found = 0;
- char uri[HTTP_MAX_URI];
- int job_id = 0;
- int num_options;
- cups_option_t *options;
- static const char *pattrs[] =
- {
- "printer-name",
- "printer-state",
- "printer-is-accepting-jobs"
- };
- static const char *jattrs[] =
- {
- "job-id",
- "job-state"
- };
- http_t *conn = NULL;
debug_printf("on_printer_state_changed() in THREAD %ld\n", pthread_self());
@@ -3157,7 +5664,8 @@ on_printer_state_changed (CupsNotifier *object,
/* If auto shutdown is active for triggering on no jobs being left, we
schedule the shutdown in autoshutdown_timeout seconds */
if (!autoshutdown_exec_id) {
- debug_printf ("No jobs there any more on printers made available by us, shutting down in %d sec...\n", autoshutdown_timeout);
+ debug_printf ("No jobs there any more on printers made available by us, shutting down in %d sec...\n",
+ autoshutdown_timeout);
autoshutdown_exec_id =
g_timeout_add_seconds (autoshutdown_timeout, autoshutdown_execute,
NULL);
@@ -3217,7 +5725,101 @@ on_printer_state_changed (CupsNotifier *object,
strncpy(buf, text, ptr - text);
buf[ptr - text] = '\0';
debug_printf("[CUPS Notification] %s not default printer any more.\n", buf);
- } else if ((ptr = strstr(text, " state changed to processing")) != NULL) {
+ }
+}
+
+static void
+on_job_state (CupsNotifier *object,
+ const gchar *text,
+ const gchar *printer_uri,
+ const gchar *printer,
+ guint printer_state,
+ const gchar *printer_state_reasons,
+ gboolean printer_is_accepting_jobs,
+ guint job_id,
+ guint job_state,
+ const gchar *job_state_reasons,
+ const gchar *job_name,
+ guint job_impressions_completed,
+ gpointer user_data)
+{
+ int i, count;
+ char buf[2048];
+ remote_printer_t *p, *q, *r, *s=NULL;
+ http_t *http = NULL;
+ ipp_t *request, *response, *printer_attributes = NULL;
+ ipp_attribute_t *attr;
+ const char *pname = NULL;
+ char *remote_cups_queue;
+ ipp_pstate_t pstate = IPP_PRINTER_IDLE;
+ int paccept = 0;
+ int num_jobs, min_jobs = 99999999;
+ char destination_uri[1024];
+ const char *dest_host = NULL;
+ int dest_port = 0;
+ char dest_name[1024];
+ int dest_index = 0;
+ int valid_dest_found = 0;
+ char uri[HTTP_MAX_URI];
+ int num_options;
+ cups_option_t *options;
+ int num_of_printers;
+ char* document_format;
+ int print_quality;
+ const char *pdl=NULL;
+ cups_array_t *pdl_list;
+ char resolution[32];
+ res_t *max_res=NULL,*min_res=NULL,*res;
+ int xres,yres;
+ static const char *pattrs[] =
+ {
+ "printer-name",
+ "printer-state",
+ "printer-is-accepting-jobs"
+ };
+ http_t *conn = NULL;
+
+ debug_printf("on_job_state() in THREAD %ld\n", pthread_self());
+
+ debug_printf("[CUPS Notification] Job state changed on printer %s: %s\n",
+ printer, text);
+ debug_printf("[CUPS Notification] Printer state reasons: %s\n",
+ printer_state_reasons);
+ debug_printf("[CUPS Notification] Job ID: %d\n",
+ job_id);
+ debug_printf("[CUPS Notification] Job State: %s\n",
+ job_state_reasons);
+ debug_printf("[CUPS Notification] Job is processing: %s\n",
+ job_state == IPP_JOB_PROCESSING ? "Yes" : "No");
+
+ if (terminating) {
+ debug_printf("[CUPS Notification]: Ignoring because cups-browsed is terminating.\n");
+ return;
+ }
+
+ if (autoshutdown && autoshutdown_on == NO_JOBS) {
+ if (check_jobs() == 0) {
+ /* If auto shutdown is active for triggering on no jobs being left, we
+ schedule the shutdown in autoshutdown_timeout seconds */
+ if (!autoshutdown_exec_id) {
+ debug_printf ("No jobs there any more on printers made available by us, shutting down in %d sec...\n", autoshutdown_timeout);
+ autoshutdown_exec_id =
+ g_timeout_add_seconds (autoshutdown_timeout, autoshutdown_execute,
+ NULL);
+ }
+ } else {
+ /* If auto shutdown is active for triggering on no jobs being left, we
+ cancel a shutdown in autoshutdown_timeout seconds as there are jobs
+ again. */
+ if (autoshutdown_exec_id) {
+ debug_printf ("New jobs there on the printers made available by us, killing auto shutdown timer.\n");
+ g_source_remove(autoshutdown_exec_id);
+ autoshutdown_exec_id = 0;
+ }
+ }
+ }
+
+ if (job_id != 0 && job_state == IPP_JOB_PROCESSING) {
/* Printer started processing a job, check if it uses the implicitclass
backend and if so, we select the remote queue to which to send the job
in a way so that we get load balancing between all remote queues
@@ -3271,15 +5873,17 @@ on_printer_state_changed (CupsNotifier *object,
/* If we hit a slave and not the master, switch to the master */
if (q && q->slave_of)
q = q->slave_of;
- if (q && q->netprinter == 0) {
+ if (q) {
/* We have remote CUPS queue(s) and so are using the implicitclass
backend */
debug_printf("[CUPS Notification] %s is using the \"implicitclass\" CUPS backend, so let us search for a destination for this job.\n", printer);
+
/* We keep track of the printer which we used last time and start
checking with the next printer this time, to get a "round robin"
type of printer usage instead of having most jobs going to the first
printer in the list. Method taken from the cupsdFindAvailablePrinter()
function of the scheduler/classes.c file of CUPS. */
+
if (q->last_printer < 0 ||
q->last_printer >= cupsArrayCount(remote_printers))
q->last_printer = 0;
@@ -3291,7 +5895,32 @@ on_printer_state_changed (CupsNotifier *object,
if (!strcasecmp(p->queue_name, printer) &&
p->status == STATUS_CONFIRMED) {
remote_cups_queue = strrchr(p->uri, '/') + 1;
- debug_printf("Checking state of remote printer %s on host %s, IP %s, port %d.\n", remote_cups_queue, p->host, p->ip, p->port);
+ num_of_printers = 0;
+ for (r = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ r; r = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if(!strcmp(r->queue_name, q->queue_name)){
+ if(r->status == STATUS_DISAPPEARED || r->status == STATUS_UNCONFIRMED ||
+ r->status == STATUS_TO_BE_RELEASED )
+ continue;
+ num_of_printers++;
+ }
+ }
+
+ /* If we are in a cluster, see whether the printer supports the
+ requested job attributes*/
+ if (num_of_printers > 1) {
+ if (!supports_job_attributes_requested(printer, i, job_id,
+ &print_quality)) {
+ debug_printf("Printer with uri %s in cluster %s doesn't support the requested job attributes\n",
+ p->uri, p->queue_name);
+ if (i == q->last_printer)
+ break;
+ else
+ continue;
+ }
+ }
+ debug_printf("Checking state of remote printer %s on host %s, IP %s, port %d.\n",
+ remote_cups_queue, p->host, p->ip, p->port);
http = httpConnectEncryptShortTimeout (p->ip ? p->ip : p->host,
p->port,
HTTP_ENCRYPT_IF_REQUESTED);
@@ -3300,7 +5929,9 @@ on_printer_state_changed (CupsNotifier *object,
if (http) {
/* Check whether the printer is idle, processing, or disabled */
httpSetTimeout(http, HttpRemoteTimeout, http_timeout_cb, NULL);
- request = ippNewRequest(CUPS_GET_PRINTERS);
+ request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
+ NULL,p->uri);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes",
sizeof(pattrs) / sizeof(pattrs[0]),
@@ -3344,53 +5975,61 @@ on_printer_state_changed (CupsNotifier *object,
else
continue;
}
- if (!strcasecmp(pname, remote_cups_queue)) {
- if (paccept) {
- debug_printf("Printer %s on host %s, port %d is accepting jobs.\n", remote_cups_queue, p->host, p->port);
- switch (pstate) {
- case IPP_PRINTER_IDLE:
- valid_dest_found = 1;
- dest_host = p->ip ? p->ip : p->host;
- dest_port = p->port;
- strncpy(dest_name, remote_cups_queue, sizeof(dest_name));
- if (strlen(remote_cups_queue) > 1023)
- dest_name[1023] = '\0';
- dest_index = i;
- debug_printf("Printer %s on host %s, port %d is idle, take this as destination and stop searching.\n",
- remote_cups_queue, p->host, p->port);
- break;
- case IPP_PRINTER_PROCESSING:
- valid_dest_found = 1;
- if (LoadBalancingType == QUEUE_ON_SERVERS) {
- num_jobs = 0;
- jobs = NULL;
- num_jobs =
- cupsGetJobs2(http, &jobs, remote_cups_queue, 0,
- CUPS_WHICHJOBS_ACTIVE);
- if (num_jobs >= 0 && num_jobs < min_jobs) {
- min_jobs = num_jobs;
- dest_host = p->ip ? p->ip : p->host;
- dest_port = p->port;
- strncpy(dest_name, remote_cups_queue, sizeof(dest_name));
- if (strlen(remote_cups_queue) > 1023)
- dest_name[1023] = '\0';
- dest_index = i;
- }
- debug_printf("Printer %s on host %s, port %d is printing and it has %d jobs.\n",
- remote_cups_queue, p->host, p->port,
- num_jobs);
- } else
- debug_printf("Printer %s on host %s, port %d is printing.\n", remote_cups_queue, p->host, p->port);
- break;
- case IPP_PRINTER_STOPPED:
- debug_printf("Printer %s on host %s, port %d is disabled, skip it.\n", remote_cups_queue, p->host, p->port);
- break;
- }
- } else {
- debug_printf("Printer %s on host %s, port %d is not accepting jobs, skip it.\n", remote_cups_queue, p->host, p->port);
+ if (paccept) {
+ debug_printf("Printer %s on host %s, port %d is accepting jobs.\n",
+ remote_cups_queue, p->host, p->port);
+ switch (pstate) {
+ case IPP_PRINTER_IDLE:
+ valid_dest_found = 1;
+ dest_host = p->ip ? p->ip : p->host;
+ dest_port = p->port;
+ strncpy(destination_uri,p->uri,sizeof(destination_uri));
+ printer_attributes = p->prattrs;
+ pdl = p->pdl;
+ s = p;
+ strncpy(dest_name, remote_cups_queue, sizeof(dest_name));
+ if (strlen(remote_cups_queue) > 1023)
+ dest_name[1023] = '\0';
+ dest_index = i;
+ debug_printf("Printer %s on host %s, port %d is idle, take this as destination and stop searching.\n",
+ remote_cups_queue, p->host, p->port);
+ break;
+ case IPP_PRINTER_PROCESSING:
+ valid_dest_found = 1;
+ if (LoadBalancingType == QUEUE_ON_SERVERS) {
+ num_jobs = 0;
+ num_jobs = get_number_of_jobs(http, p->uri, 0,
+ CUPS_WHICHJOBS_ACTIVE);
+ if (num_jobs >= 0 && num_jobs < min_jobs) {
+ min_jobs = num_jobs;
+ dest_host = p->ip ? p->ip : p->host;
+ dest_port = p->port;
+ strncpy(destination_uri,p->uri,sizeof(destination_uri));
+ printer_attributes = p->prattrs;
+ pdl = p->pdl;
+ s = p;
+ strncpy(dest_name, remote_cups_queue,
+ sizeof(dest_name));
+ if (strlen(remote_cups_queue) > 1023)
+ dest_name[1023] = '\0';
+ dest_index = i;
+ }
+ debug_printf("Printer %s on host %s, port %d is printing and it has %d jobs.\n",
+ remote_cups_queue, p->host, p->port,
+ num_jobs);
+ } else
+ debug_printf("Printer %s on host %s, port %d is printing.\n", remote_cups_queue, p->host, p->port);
+ break;
+ case IPP_PRINTER_STOPPED:
+ debug_printf("Printer %s on host %s, port %d is disabled, skip it.\n",
+ remote_cups_queue, p->host, p->port);
+ break;
}
- break;
+ } else {
+ debug_printf("Printer %s on host %s, port %d is not accepting jobs, skip it.\n",
+ remote_cups_queue, p->host, p->port);
}
+ break;
}
if (pstate == IPP_PRINTER_IDLE && paccept) {
q->last_printer = i;
@@ -3406,54 +6045,142 @@ on_printer_state_changed (CupsNotifier *object,
if (i == q->last_printer)
break;
}
- /* Find the ID of the current job */
- request = ippNewRequest(IPP_GET_JOBS);
- httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
- "localhost", ippPort(), "/printers/%s", printer);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
- "printer-uri", NULL, uri);
- ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
- "requested-attributes",
- sizeof(jattrs) / sizeof(jattrs[0]), NULL, jattrs);
- job_id = 0;
- if ((response = cupsDoRequest(conn, request, "/")) != NULL) {
- /* Get the current active job on this queue... */
- ipp_jstate_t jobstate = IPP_JOB_PENDING;
- for (attr = ippFirstAttribute(response); attr != NULL;
- attr = ippNextAttribute(response)) {
- if (!ippGetName(attr)) {
- if (jobstate == IPP_JOB_PROCESSING)
- break;
+
+ /* Write the selected destination host into an option of our implicit
+ class queue (cups-browsed-dest-printer="<dest>") so that the
+ implicitclass backend will pick it up */
+
+ if ((pdl_list = cupsArrayNew3((cups_array_func_t)strcasecmp,
+ NULL, NULL, 0,
+ (cups_acopy_func_t)strdup,
+ (cups_afree_func_t)free)) == NULL){
+ debug_printf("Could Not allocate memory for cups Array \n");
+ return;
+ }
+
+ /* Finding the best pdl supported by the printer, we need to send the
+ document format to the implictclass backend */
+ if (((attr = ippFindAttribute(printer_attributes,
+ "document-format-supported",
+ IPP_TAG_MIMETYPE)) != NULL) ||
+ (pdl && pdl[0] != '\0')) {
+ const char *format = pdl;
+ i = 0;
+ count = ippGetCount(attr);
+ while ((attr && i < count) || /* Go through formats in attribute */
+ (!attr && pdl && pdl[0] != '\0' && format[0] != '\0')) {
+ /* Go through formats in pdl string (from DNS-SD record) */
+ /* Pick next format from attribute */
+ if (attr) format = ippGetString(attr, i, NULL);
+ /* Add format to list of supported PDLs, skip duplicates */
+ if (!cupsArrayFind(pdl_list, (void *)format))
+ cupsArrayAdd(pdl_list, (void *)format);
+ if (attr)
+ /* Next format in attribute */
+ i ++;
+ else {
+ /* Find the next format in the string pdl, if there is none left,
+ go to the terminating zero */
+ while (!isspace(*format) && *format != ',' && *format != '\0')
+ format ++;
+ while ((isspace(*format) || *format == ',') && *format != '\0')
+ format++;
+ }
+ }
+ }
+
+ document_format = (char *)malloc(sizeof(char) * 32);
+ if (cupsArrayFind(pdl_list, "application/vnd.cups-pdf") ||
+ cupsArrayFind(pdl_list, "application/pdf"))
+ strcpy(document_format,"pdf");
+ else if(cupsArrayFind(pdl_list, "image/pwg-raster"))
+ strcpy(document_format,"raster");
+ else {
+#ifdef CUPS_RASTER_HAVE_APPLERASTER
+ if (cupsArrayFind(pdl_list, "image/urf"))
+ strcpy(document_format,"apple-raster");
+#else
+#ifdef QPDF_HAVE_PCLM
+ if (cupsArrayFind(pdl_list, "application/PCLm"))
+ strcpy(document_format,"pclm");
+#else
+ if(cupsArrayFind(pdl_list, "application/vnd.hp-pclxl"))
+ stcpy(document_format,"pclxl");
+ else(cupsArrayFind(pdl_list, "application/vnd.hp-pcl")||cupsArrayFind(pdl_list, "application/pcl")||
+ cupsArrayFind(pdl_list, "application/x-pcl"))
+ strcpy(document_format,"pcl");
+#endif
+#endif
+ }
+
+ /* Deciding the resolution to be sent with the job */
+ /* Finding the minimum and maximum resolution supported by the printer */
+ if (s &&
+ ((attr = ippFindAttribute(s->prattrs, "printer-resolution-supported",
+ IPP_TAG_RESOLUTION)) != NULL)) {
+ for (i = 0, count = ippGetCount(attr); i < count; i ++) {
+ if ((res = ippResolutionToRes(attr, i)) != NULL) {
+ debug_printf("%d %d\n",res->x,res->y);
+ if (i == 0) {
+ max_res = res;
+ min_res = res;
+ } else {
+ if(compare_resolutions((void *)res,(void *)max_res,NULL) > 0)
+ max_res = res;
+ if(compare_resolutions((void *)res,(void *)min_res,NULL) < 0)
+ min_res = res;
+ }
+ }
+ }
+ }
+
+ /* If we are requesting normal print quality then send default
+ resolution, for draft send minimum resolution and for high,
+ send the maximum resolution */
+ /* If none of the below dpi is selected then default dpi will be
+ sent as 600 */
+ snprintf(resolution,sizeof(resolution), "600dpi");
+ if (s && print_quality == 3) {
+ if (min_res != NULL){
+ if (min_res->x == min_res->y)
+ snprintf(resolution,sizeof(resolution), "%ddpi", min_res->x);
+ else
+ snprintf(resolution,sizeof(resolution), "%dx%ddpi", min_res->x,
+ min_res->y);
+ }
+ } else if (s && print_quality == 5) {
+ if (max_res != NULL) {
+ if (max_res->x == max_res->y)
+ snprintf(resolution, sizeof(resolution), "%ddpi", max_res->x);
+ else
+ snprintf(resolution, sizeof(resolution), "%dx%ddpi", max_res->x,
+ max_res->y);
+ }
+ } else if (s) {
+ if ((attr = ippFindAttribute(s->prattrs, "printer-resolution-default",
+ IPP_TAG_ZERO)) != NULL) {
+ if ((res = ippResolutionToRes(attr, 0)) != NULL) {
+ xres = res->x;
+ yres = res->y;
+ if(xres == yres)
+ snprintf(resolution, sizeof(resolution), "%ddpi", xres);
else
- continue;
+ snprintf(resolution, sizeof(resolution), "%dx%ddpi", xres, yres);
}
- if (!strcmp(ippGetName(attr), "job-id") &&
- ippGetValueTag(attr) == IPP_TAG_INTEGER)
- job_id = ippGetInteger(attr, 0);
- else if (!strcmp(ippGetName(attr), "job-state") &&
- ippGetValueTag(attr) == IPP_TAG_ENUM)
- jobstate = (ipp_jstate_t)ippGetInteger(attr, 0);
}
- if (jobstate != IPP_JOB_PROCESSING)
- job_id = 0;
- ippDelete(response);
}
- if (job_id == 0)
- debug_printf("ERROR: could not determine ID of curremt job on %s\n",
- printer);
- /* Write the selected destination host into an option of our implicit
- class queue (cups-browsed-dest-printer="<dest>") so that the
- implicitclass backend will pick it up */
request = ippNewRequest(CUPS_ADD_MODIFY_PRINTER);
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ "localhost", ippPort(), "/printers/%s", printer);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, cupsUser());
if (dest_host) {
q->last_printer = dest_index;
- snprintf(buf, sizeof(buf), "\"%d %s:%d/%s\"", job_id, dest_host,
- dest_port, dest_name);
+ snprintf(buf, sizeof(buf), "\"%d %s %s %s\"", job_id, destination_uri,
+ document_format, resolution);
debug_printf("Destination for job %d to %s: %s:%d, queue %s\n",
job_id, printer, dest_host, dest_port, dest_name);
} else if (valid_dest_found == 1) {
@@ -3557,17 +6284,9 @@ on_printer_deleted (CupsNotifier *object,
}
}
-static void
-on_printer_modified (CupsNotifier *object,
- const gchar *text,
- const gchar *printer_uri,
- const gchar *printer,
- guint printer_state,
- const gchar *printer_state_reasons,
- gboolean printer_is_accepting_jobs,
- gpointer user_data)
+static int
+queue_overwritten (remote_printer_t *p)
{
- remote_printer_t *p;
http_t *conn = NULL;
ipp_t *request, /* IPP Request */
*response = NULL; /* IPP Response */
@@ -3583,6 +6302,142 @@ on_printer_modified (CupsNotifier *object,
};
const char *loadedppd = NULL;
ppd_file_t *ppd;
+ int overwritten = 0;
+
+ if (p->overwritten)
+ /* We already have discovered that this queue got overwritten
+ so we do not repeat the tests and exit positively */
+ return 1;
+
+ /* Get the URI which our CUPS queue actually has now, a change of the
+ URI means a modification or replacement of the print queue by
+ something user-defined. So we schedule this queue for release from
+ handling by cups-browsed */
+ conn = http_connect_local ();
+ if (conn == NULL) {
+ debug_printf("Cannot connect to local CUPS to find the actual device URI and other properties of the printer %s.\n",
+ p->queue_name);
+ return 0;
+ } else {
+ request = ippNewRequest(CUPS_GET_PRINTERS);
+ ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
+ NULL, pattrs);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
+ NULL, cupsUser());
+ response = cupsDoRequest(conn, request, "/");
+ }
+ if (!response || cupsLastError() > IPP_STATUS_OK_CONFLICTING) {
+ debug_printf("lpstat: %s\n", cupsLastErrorString());
+ } else {
+ for (attr = ippFirstAttribute(response); attr != NULL;
+ attr = ippNextAttribute(response)) {
+ while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_PRINTER)
+ attr = ippNextAttribute(response);
+ if (attr == NULL)
+ break;
+ printername = NULL;
+ device = NULL;
+ uri = NULL;
+ while (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_PRINTER) {
+ if (!strcmp(ippGetName(attr), "printer-name") &&
+ ippGetValueTag(attr) == IPP_TAG_NAME)
+ printername = ippGetString(attr, 0, NULL);
+ if (!strcmp(ippGetName(attr), "printer-uri-supported") &&
+ ippGetValueTag(attr) == IPP_TAG_URI)
+ uri = ippGetString(attr, 0, NULL);
+ if (!strcmp(ippGetName(attr), "device-uri") &&
+ ippGetValueTag(attr) == IPP_TAG_URI)
+ device = ippGetString(attr, 0, NULL);
+ attr = ippNextAttribute(response);
+ }
+ if (printername == NULL) {
+ if (attr == NULL)
+ break;
+ else
+ continue;
+ }
+ if (strcasecmp(p->queue_name, printername) == 0) {
+ /* Found our printer in the response */
+ if (device == NULL)
+ device = uri;
+ if (device != NULL &&
+ (p->uri == NULL ||
+ (strlen(device) < 16 || strncmp(device, "implicitclass://", 16)))) {
+ /* The printer's device URI is different to what we have
+ assigned, so we got notified because the queue was
+ externally modified and so we will release this printer
+ from the control of cups-browsed */
+ debug_printf("Printer %s got modified externally, discovered by a change of its device URI from %s to %s.\n",
+ p->queue_name,
+ (p->uri ? (p->netprinter ? p->uri :
+ "implicitclass://...") :
+ "(not yet determined)"),
+ device);
+ overwritten = 1;
+ }
+ break;
+ }
+ }
+ }
+ if (response) ippDelete(response);
+
+ /* Get the NickName of the PPD which our CUPS queue actually uses
+ now, a change of the NickName means a replacement of the PPD of
+ the print queue by a user-selected one. So we schedule this
+ queue for release from handling by cups-browsed */
+ if ((loadedppd = cupsGetPPD2(conn, p->queue_name))
+ == NULL) {
+ debug_printf("Unable to load PPD from local queue %s, queue seems to be raw.\n",
+ p->queue_name);
+ if (p->nickname && p->nickname[0] != '\0') {
+ /* We have set up this printer with a PPD file but the queue
+ does not have a PPD file any more, so we were notified
+ because the queue was externally modified and so we will
+ release this printer from the control of cups-browsed */
+ debug_printf("Printer %s got modified externally, discovered by the removal of its PPD file.\n",
+ p->queue_name);
+ overwritten = 1;
+ }
+ } else {
+ if ((ppd = ppdOpenFile(loadedppd)) == NULL)
+ debug_printf("Unable to open downloaded PPD from local queue %s.\n",
+ p->queue_name);
+ else {
+ if (p->nickname == NULL || ppd->nickname == NULL ||
+ strcasecmp(p->nickname, ppd->nickname)) {
+ /* The PPD file of the queue got replaced which we
+ discovered by comparing the NickName of the PPD with the
+ NickName which the PPD we have used has. So we were
+ notified because the queue was externally modified and so
+ we will release this printer from the control of
+ cups-browsed */
+ debug_printf("Printer %s got modified externally, discovered by the NickName of its PPD file having changed from \"%s\" to \"%s\".\n",
+ p->queue_name, (p->nickname ? p->nickname : "(no PPD)"),
+ (ppd->nickname ? ppd->nickname :
+ "(NickName not readable)"));
+ overwritten = 1;
+ }
+ }
+ unlink(loadedppd);
+ }
+
+ return overwritten;
+}
+
+static void
+on_printer_modified (CupsNotifier *object,
+ const gchar *text,
+ const gchar *printer_uri,
+ const gchar *printer,
+ guint printer_state,
+ const gchar *printer_state_reasons,
+ gboolean printer_is_accepting_jobs,
+ gpointer user_data)
+{
+ remote_printer_t *p;
+ http_t *conn = NULL;
+ ipp_t *request; /* IPP Request */
int re_create, is_cups_queue;
char *new_queue_name;
cups_array_t *to_be_renamed;
@@ -3600,118 +6455,8 @@ on_printer_modified (CupsNotifier *object,
and are treating the process appropriately, so return now to
avoid an infinite recursion */
return;
- /* Get the URI which our CUPS queue actually has now, a change of the
- URI means a modification or replacement of the print queue by
- something user-defined. So we schedule this queue for release from
- handling by cups-browsed */
- conn = http_connect_local ();
- if (conn == NULL) {
- debug_printf("Cannot connect to local CUPS to find the actual device URI of the printer %s.\n",
- printer);
- } else {
- request = ippNewRequest(CUPS_GET_PRINTERS);
- ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
- "requested-attributes", sizeof(pattrs) / sizeof(pattrs[0]),
- NULL, pattrs);
- ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name",
- NULL, cupsUser());
- response = cupsDoRequest(conn, request, "/");
- }
- if (cupsLastError() > IPP_STATUS_OK_CONFLICTING) {
- debug_printf("lpstat: %s\n", cupsLastErrorString());
- ippDelete(response);
- } else {
- for (attr = ippFirstAttribute(response); attr != NULL;
- attr = ippNextAttribute(response)) {
- while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_PRINTER)
- attr = ippNextAttribute(response);
- if (attr == NULL)
- break;
- printername = NULL;
- device = NULL;
- uri = NULL;
- while (attr != NULL && ippGetGroupTag(attr) == IPP_TAG_PRINTER) {
- if (!strcmp(ippGetName(attr), "printer-name") &&
- ippGetValueTag(attr) == IPP_TAG_NAME)
- printername = ippGetString(attr, 0, NULL);
- if (!strcmp(ippGetName(attr), "printer-uri-supported") &&
- ippGetValueTag(attr) == IPP_TAG_URI)
- uri = ippGetString(attr, 0, NULL);
- if (!strcmp(ippGetName(attr), "device-uri") &&
- ippGetValueTag(attr) == IPP_TAG_URI)
- device = ippGetString(attr, 0, NULL);
- attr = ippNextAttribute(response);
- }
- if (printername == NULL) {
- if (attr == NULL)
- break;
- else
- continue;
- }
- if (strcasecmp(printer, printername) == 0) {
- /* Found our printer in the response */
- if (device == NULL)
- device = uri;
- if (device != NULL &&
- (p->uri == NULL ||
- (p->netprinter != 0 && strcasecmp(device, p->uri)) ||
- (p->netprinter == 0 &&
- (strlen(device) < 16 || strncmp(device, "implicitclass://", 16))))) {
- /* The printer's device URI is different to what we have
- assigned, so we got notified because the queue was
- externally modified and so we will release this printer
- from the control of cups-browsed */
- debug_printf("Printer %s got modified externally, discovered by a change of its device URI from %s to %s.\n",
- printer,
- (p->uri ? (p->netprinter ? p->uri : "implicitclass://...") : "(not yet determined)"),
- device);
- p->overwritten = 1;
- }
- break;
- }
- }
- }
-
- /* Get the NickName of the PPD which our CUPS queue actually uses
- now, a change of the NickName means a replacement of the PPD of
- the print queue by a user-selected one. So we schedule this
- queue for release from handling by cups-browsed */
- if ((loadedppd = cupsGetPPD2(conn, printer))
- == NULL) {
- debug_printf("Unable to load PPD from local queue %s, queue seems to be raw.\n",
- printer);
- if (p->nickname && p->nickname[0] != '\0') {
- /* We have set up this printer with a PPD file but the queue
- does not have a PPD file any more, so we were notified
- because the queue was externally modified and so we will
- release this printer from the control of cups-browsed */
- debug_printf("Printer %s got modified externally, discovered by the removal of its PPD file.\n",
- printer);
- p->overwritten = 1;
- }
- } else {
- if ((ppd = ppdOpenFile(loadedppd)) == NULL)
- debug_printf("Unable to open downloaded PPD from local queue %s.\n",
- printer);
- else {
- if (p->nickname == NULL || ppd->nickname == NULL ||
- strcasecmp(p->nickname, ppd->nickname)) {
- /* The PPD file of the queue got replaced which we
- discovered by comparing the NickName of the PPD with the
- NickName which the PPD we have used has. So we were
- notified because the queue was externally modified and so
- we will release this printer from the control of
- cups-browsed */
- debug_printf("Printer %s got modified externally, discovered by the NickName of its PPD file having changed from \"%s\" to \"%s\".\n",
- printer, (p->nickname ? p->nickname : "(no PPD)"),
- (ppd->nickname ? ppd->nickname : "(NickName not readable)"));
- p->overwritten = 1;
- }
- }
- unlink(loadedppd);
- }
- if (p->overwritten) {
+ if (queue_overwritten(p)) {
/* Our generated local queue pointing to a remote printer got
overwritten by an externally created queue with the same
name.
@@ -3720,13 +6465,14 @@ on_printer_modified (CupsNotifier *object,
<old_name>@<remote_host>.
If we have slaves, we have to do this for them, too. */
+ p->overwritten = 1;
+
/* First, remove the "cups-browsed=true" from the queue's
options, so that cups-browsed considers this queue as created
manually */
debug_printf("Removing \"cups-browsed=true\" from CUPS queue %s (%s).\n",
p->queue_name, p->uri);
- if (conn == NULL)
- conn = http_connect_local ();
+ conn = http_connect_local ();
if (conn == NULL)
debug_printf("Browse send failed to connect to localhost\n");
else {
@@ -3786,11 +6532,11 @@ on_printer_modified (CupsNotifier *object,
} else {
free(p->queue_name);
p->queue_name = new_queue_name;
- /* Check whether the queue under its new name will be stand-alone or part of
- a cluster */
+ /* Check whether the queue under its new name will be stand-alone or
+ part of a cluster */
if (join_cluster_if_needed(p, is_cups_queue) < 0) {
- /* There are other cups-browsed-generated queues with the new name, not able to
- cluster this queue with them */
+ /* There are other cups-browsed-generated queues with the new
+ name, not able to cluster this queue with them */
debug_printf("Not able to cluster this queue with equally-named ones.\n");
re_create = 0;
}
@@ -3837,7 +6583,8 @@ on_printer_modified (CupsNotifier *object,
#ifdef HAVE_CUPS_1_6
static ipp_t *
-get_printer_attributes(const char* uri) {
+get_printer_attributes(const char* uri)
+{
int uri_status, host_port, i;
http_t *http_printer = NULL;
char scheme[10], userpass[1024], host_name[1024], resource[1024];
@@ -3845,10 +6592,11 @@ get_printer_attributes(const char* uri) {
ipp_attribute_t *attr;
char valuebuffer[65536];
static const char * const pattrs[] =
- {
- "all",
- "media-col-database"
- };
+ {
+ "all",
+ "media-col-database"
+ };
+
/* Request printer properties via IPP to generate a PPD file for the
printer (mainly driverless-capable printers)
If we work with Systen V interface scripts use this info to set
@@ -3861,8 +6609,9 @@ get_printer_attributes(const char* uri) {
resource, sizeof(resource));
if (uri_status != HTTP_URI_OK)
return NULL;
- if ((http_printer = httpConnect(host_name, host_port)) ==
- NULL) {
+ if ((http_printer =
+ httpConnectEncryptShortTimeout (host_name, host_port,
+ HTTP_ENCRYPT_IF_REQUESTED)) == NULL) {
debug_printf("Cannot connect to remote printer with URI %s, ignoring this printer.\n",
uri);
return NULL;
@@ -3979,10 +6728,10 @@ create_remote_printer_entry (const char *queue_name,
p->slave_of = NULL;
p->last_printer = -1;
-
+
p->num_options = 0;
p->options = NULL;
-
+
p->host = strdup (host);
if (!p->host)
goto fail;
@@ -4041,13 +6790,13 @@ create_remote_printer_entry (const char *queue_name,
remote CUPS server gets used. So we will not generate a PPD file
or interface script at this point. */
p->netprinter = 0;
- p->prattrs = NULL;
+ p->prattrs = get_printer_attributes(p->uri);
p->nickname = NULL;
-
- /* Check whether we have an equally named queue already from another
- server and join a cluster if needed */
- if (join_cluster_if_needed(p, is_cups_queue) < 0)
+ if (p->prattrs == NULL) {
+ debug_printf("get-printer-attributes IPP call failed on printer %s (%s).\n",
+ p->queue_name, p->uri);
goto fail;
+ }
} else {
#ifndef HAVE_CUPS_1_6
/* The following code uses a lot of CUPS >= 1.6 specific stuff.
@@ -4143,7 +6892,8 @@ create_remote_printer_entry (const char *queue_name,
IPP_TAG_KEYWORD)) != NULL) {
debug_printf(" Attr: %s\n", ippGetName(attr));
for (i = 0; i < ippGetCount(attr); i ++) {
- strncpy(valuebuffer, ippGetString(attr, i, NULL), sizeof(valuebuffer));
+ strncpy(valuebuffer, ippGetString(attr, i, NULL),
+ sizeof(valuebuffer));
if (strlen(ippGetString(attr, i, NULL)) > 65535)
valuebuffer[65535] = '\0';
debug_printf(" Keyword: %s\n", valuebuffer);
@@ -4176,7 +6926,8 @@ create_remote_printer_entry (const char *queue_name,
debug_printf(" Value: %s\n", valuebuffer);
if (valuebuffer[0] == '\0') {
for (i = 0; i < ippGetCount(attr); i ++) {
- strncpy(valuebuffer, ippGetString(attr, i, NULL), sizeof(valuebuffer));
+ strncpy(valuebuffer, ippGetString(attr, i, NULL),
+ sizeof(valuebuffer));
if (strlen(ippGetString(attr, i, NULL)) > 65535)
valuebuffer[65535] = '\0';
debug_printf(" Keyword: %s\n", valuebuffer);
@@ -4208,7 +6959,8 @@ create_remote_printer_entry (const char *queue_name,
debug_printf(" Value: %s\n", valuebuffer);
if (valuebuffer[0] == '\0') {
for (i = 0; i < ippGetCount(attr); i ++) {
- strncpy(valuebuffer, ippGetString(attr, i, NULL), sizeof(valuebuffer));
+ strncpy(valuebuffer, ippGetString(attr, i, NULL),
+ sizeof(valuebuffer));
if (strlen(ippGetString(attr, i, NULL)) > 65535)
valuebuffer[65535] = '\0';
debug_printf(" Keyword: %s\n", valuebuffer);
@@ -4243,7 +6995,8 @@ create_remote_printer_entry (const char *queue_name,
debug_printf(" Value: %s\n", p->queue_name, valuebuffer);
if (valuebuffer[0] == '\0') {
for (i = 0; i < ippGetCount(attr); i ++) {
- strncpy(valuebuffer, ippGetString(attr, i, NULL), sizeof(valuebuffer));
+ strncpy(valuebuffer, ippGetString(attr, i, NULL),
+ sizeof(valuebuffer));
if (strlen(ippGetString(attr, i, NULL)) > 65535)
valuebuffer[65535] = '\0';
debug_printf(" Keyword: %s\n", valuebuffer);
@@ -4265,8 +7018,8 @@ create_remote_printer_entry (const char *queue_name,
"application/pdf" under its PDLs. */
if (CreateIPPPrinterQueues == IPP_PRINTERS_PDF ||
CreateIPPPrinterQueues == IPP_PRINTERS_DRIVERLESS) {
- debug_printf("Checking whether printer %s understands PDF: PDLs: %s\n",
- p->queue_name, pdl);
+ debug_printf("Checking whether printer %s understands PDF: PDLs: %s\n",
+ p->queue_name, pdl);
if(strcasestr(pdl, "application/pdf"))
is_pdf = 1;
debug_printf(" --> Printer %s PDF.\n",
@@ -4329,7 +7082,10 @@ create_remote_printer_entry (const char *queue_name,
#endif /* HAVE_CUPS_1_6 */
}
-
+ /* Check whether we have an equally named queue already from another
+ server and join a cluster if needed */
+ if (join_cluster_if_needed(p, is_cups_queue) < 0)
+ goto fail;
/* Add the new remote printer entry */
log_all_printers();
cupsArrayAdd(remote_printers, p);
@@ -4416,7 +7172,7 @@ remove_printer_entry(remote_printer_t *p) {
} else
debug_printf("Printer %s (Host: %s, Port: %d, URI: %s) disappeared and no slave available (or it is a slave of another printer), removing entry.\n",
p->queue_name, p->host, p->port, p->uri);
-
+
/* Schedule entry and its CUPS queue for removal */
if (p->status != STATUS_TO_BE_RELEASED)
p->status = STATUS_DISAPPEARED;
@@ -4424,42 +7180,50 @@ remove_printer_entry(remote_printer_t *p) {
}
gboolean update_cups_queues(gpointer unused) {
- remote_printer_t *p, *q, *r;
- http_t *http, *remote_http;
- char uri[HTTP_MAX_URI], device_uri[HTTP_MAX_URI], buf[1024], line[1024];
- char *remote_cups_queue;
- int num_options;
+ remote_printer_t *p, *q, *r, *s, *master;
+ http_t *http;
+ char uri[HTTP_MAX_URI], device_uri[HTTP_MAX_URI], buf[1024],
+ line[1024];
+ int num_options;
cups_option_t *options;
- int num_jobs;
- cups_job_t *jobs;
- ipp_t *request;
- time_t current_time;
- int i, new_cupsfilter_line_inserted, ap_remote_queue_id_line_inserted,
- cont_line_read, want_raw;
- char *disabled_str, *ptr, *prefix;
- char *ppdfile, *ifscript;
- int fd = 0; /* Script file descriptor */
- char tempfile[1024]; /* Temporary file */
- char buffer[8192]; /* Buffer for creating script */
+ int num_jobs;
+ cups_job_t *jobs;
+ ipp_t *request;
+ time_t current_time;
+ int i, ap_remote_queue_id_line_inserted,
+ want_raw, num_cluster_printers = 0;
+ char *disabled_str, *ptr;
+ char *ppdfile, *ifscript;
+ int fd = 0; /* Script file descriptor */
+ char tempfile[1024]; /* Temporary file */
+ char buffer[8192]; /* Buffer for creating script */
int bytes;
- const char *cups_serverbin; /* CUPS_SERVERBIN environment variable */
+ const char *cups_serverbin; /* CUPS_SERVERBIN environment variable */
#ifdef HAVE_CUPS_1_6
ipp_attribute_t *attr;
- int count, left, right, bottom, top;
- const char *default_page_size = NULL, *best_color_space = NULL, *color_space;
+ int count, left, right, bottom, top;
+ const char *default_page_size = NULL, *best_color_space = NULL,
+ *color_space;
#endif
- const char *loadedppd = NULL;
- int pass_through_ppd;
- ppd_file_t *ppd;
- ppd_choice_t *choice;
- cups_file_t *in, *out;
- char keyword[1024], *keyptr;
- const char *customval;
- const char *val = NULL;
- cups_dest_t *dest = NULL;
- int is_shared;
-
- debug_printf("update_cups_queues() in THREAD %ld\n", pthread_self());
+ const char *loadedppd = NULL;
+ ppd_file_t *ppd;
+ ppd_choice_t *choice;
+ cups_file_t *in, *out;
+ char keyword[1024], *keyptr;
+ const char *customval;
+ const char *val = NULL;
+ cups_dest_t *dest = NULL;
+ int is_shared;
+ cups_array_t *conflicts = NULL;
+ ipp_t *printer_attributes = NULL;
+ cups_array_t *sizes=NULL;
+ ipp_t *printer_ipp_response;
+ char *make_model;
+ const char *pdl=NULL;
+ int color;
+ int duplex;
+ char *default_pagesize;
+ const char *default_color = NULL;
/* Create dummy entry to point slaves at when their master is about to
get removed now (if we point them to NULL, we would try to remove
@@ -4477,7 +7241,8 @@ gboolean update_cups_queues(gpointer unused) {
to this dummy entry */
for (p = (remote_printer_t *)cupsArrayFirst(remote_printers);
p; p = (remote_printer_t *)cupsArrayNext(remote_printers))
- if ((p->status == STATUS_DISAPPEARED || p->status == STATUS_TO_BE_RELEASED) &&
+ if ((p->status == STATUS_DISAPPEARED ||
+ p->status == STATUS_TO_BE_RELEASED) &&
(q = p->slave_of) != NULL &&
(q->status == STATUS_DISAPPEARED || q->status == STATUS_TO_BE_RELEASED))
p->slave_of = r;
@@ -4524,10 +7289,12 @@ gboolean update_cups_queues(gpointer unused) {
if (p->timeout > current_time)
break;
- cannot_create:
+ cannot_create:
debug_printf("Removing entry %s (%s)%s.\n", p->queue_name, p->uri,
- (p->slave_of || p->status == STATUS_TO_BE_RELEASED ? "" : " and its CUPS queue"));
+ (p->slave_of ||
+ p->status == STATUS_TO_BE_RELEASED ? "" :
+ " and its CUPS queue"));
/* Slaves do not have a CUPS queue */
if ((q = p->slave_of) == NULL) {
@@ -4548,14 +7315,16 @@ gboolean update_cups_queues(gpointer unused) {
queue re-appears later or when cups-browsed gets started again */
record_printer_options(p->queue_name);
- if (p->status != STATUS_TO_BE_RELEASED) {
+ if (p->status != STATUS_TO_BE_RELEASED &&
+ !queue_overwritten(p)) {
/* Remove the CUPS queue */
/* Check whether there are still jobs and do not remove the queue
then */
num_jobs = 0;
jobs = NULL;
- num_jobs = cupsGetJobs2(http, &jobs, p->queue_name, 0, CUPS_WHICHJOBS_ACTIVE);
+ num_jobs = cupsGetJobs2(http, &jobs, p->queue_name, 0,
+ CUPS_WHICHJOBS_ACTIVE);
if (num_jobs != 0) { /* error or jobs */
debug_printf("Queue has still jobs or CUPS error!\n");
cupsFreeJobs(num_jobs, jobs);
@@ -4607,7 +7376,8 @@ gboolean update_cups_queues(gpointer unused) {
request = ippNewRequest(CUPS_DELETE_PRINTER);
/* Printer URI: ipp://localhost:631/printers/<queue name> */
httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
- "localhost", ippPort(), "/printers/%s", p->queue_name);
+ "localhost", ippPort(), "/printers/%s",
+ p->queue_name);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
/* Default user */
@@ -4657,7 +7427,7 @@ gboolean update_cups_queues(gpointer unused) {
p = NULL;
/* If auto shutdown is active and all printers we have set up got removed
- again, schedule the shutdown in autoshutdown_timeout seconds
+ again, schedule the shutdown in autoshutdown_timeout seconds
Note that in this case we also do not have jobs any more so if we
auto shutdown on running out of jobs, trigger it here, too. */
if (in_shutdown == 0 && autoshutdown && !autoshutdown_exec_id &&
@@ -4666,7 +7436,7 @@ gboolean update_cups_queues(gpointer unused) {
debug_printf ("No printers there any more to make available or no jobs, shutting down in %d sec...\n", autoshutdown_timeout);
autoshutdown_exec_id =
g_timeout_add_seconds (autoshutdown_timeout, autoshutdown_execute,
- NULL);
+ NULL);
}
break;
@@ -4674,12 +7444,15 @@ gboolean update_cups_queues(gpointer unused) {
/* DNS-SD has reported a new remote printer, create a CUPS queue for it,
or upgrade an existing queue, or update a queue to use a backup host
when it has disappeared on the currently used host */
- /* (...or, we've just received a CUPS Browsing packet for this queue) */
+ /* (...or, we've just received a CUPS Browsing packet for this queue) */
case STATUS_TO_BE_CREATED:
/* Do not create a queue for slaves */
if (p->slave_of) {
p->status = STATUS_CONFIRMED;
+ master = p->slave_of;
+ master->status = STATUS_TO_BE_CREATED;
+ master->timeout = time(NULL) + TIMEOUT_IMMEDIATELY;
if (p->is_legacy) {
p->timeout = time(NULL) + BrowseTimeout;
debug_printf("starting BrowseTimeout timer for %s (%ds)\n",
@@ -4733,9 +7506,11 @@ gboolean update_cups_queues(gpointer unused) {
Either CUPS generates a temporary queue here or we have already
made this queue permanent. In any case, load the PPD from this
queue to conserve the PPD which CUPS has originally generated. */
- if (p->netprinter == 1 && IPPPrinterQueueType == PPD_YES && UseCUPSGeneratedPPDs) {
+ if (p->netprinter == 1 && IPPPrinterQueueType == PPD_YES &&
+ UseCUPSGeneratedPPDs) {
if (LocalQueueNamingIPPPrinter != LOCAL_QUEUE_NAMING_DNSSD) {
- debug_printf("Local queue %s: We can replace temporary CUPS queues and keep their PPD file only when we name our queues like them, to avoid duplicate queues to the same printer.\n", p->queue_name);
+ debug_printf("Local queue %s: We can replace temporary CUPS queues and keep their PPD file only when we name our queues like them, to avoid duplicate queues to the same printer.\n",
+ p->queue_name);
debug_printf("Not loading PPD from temporary CUPS queue for this printer.\n");
debug_printf("Try setting \"LocalQueueNamingIPPPrinter DNS-SD\" in cups-browsed.conf.\n");
} else {
@@ -4780,7 +7555,7 @@ gboolean update_cups_queues(gpointer unused) {
we cannot modify its printer-is-shared option as CUPS prevents
this. In this case we remove the temporary queue so that we
create a fresh one which will always be permanent.
- If the temporary queue has still jobs we will not remove it to
+ If the temporary queue has still jobs we will not remove it to
not loose the jobs and wait with creating our new queue until
the jobs are done. */
val = cupsGetOption ("printer-is-shared",
@@ -4810,7 +7585,8 @@ gboolean update_cups_queues(gpointer unused) {
num_options = cupsAddOption("printer-is-shared",
(i == 0 ? "true" : "false"),
num_options, &options);
- cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
+ cupsEncodeOptions2(request, num_options, options,
+ IPP_TAG_OPERATION);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_PRINTER);
ippDelete(cupsDoRequest(http, request, "/admin/"));
cupsFreeOptions(num_options, options);
@@ -4821,8 +7597,8 @@ gboolean update_cups_queues(gpointer unused) {
break;
}
}
- /* Error on modifying printer-is-shared bit, removing possibly temporary
- queue */
+ /* Error on modifying printer-is-shared bit, removing possibly
+ temporary queue */
if (i <= 1) {
debug_printf("Removing the possibly temporary CUPS queue.\n");
/* Check whether there are still jobs and do not remove the queue
@@ -4881,18 +7657,77 @@ gboolean update_cups_queues(gpointer unused) {
goto cannot_create;
}
if (IPPPrinterQueueType == PPD_YES) {
+ num_cluster_printers = 0;
+ for (s = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ s; s = (remote_printer_t *)cupsArrayNext(remote_printers)){
+ if(!strcmp(s->queue_name,p->queue_name)) {
+ if(s->status == STATUS_DISAPPEARED || s->status == STATUS_UNCONFIRMED ||
+ s->status == STATUS_TO_BE_RELEASED )
+ continue;
+ num_cluster_printers++;
+ }
+ }
+
+ if (num_cluster_printers == 1) {
+ printer_attributes = p->prattrs;
+ conflicts = NULL;
+ default_pagesize = NULL;
+ default_color = NULL;
+ make_model = p->make_model;
+ pdl = p->pdl;
+ color = p->color;
+ duplex = p->duplex;
+ sizes = NULL;
+ } else {
+ make_model = (char*)malloc(sizeof(char) * 256);
+ if ((attr = ippFindAttribute(printer_attributes,
+ "printer-make-and-model",
+ IPP_TAG_TEXT)) != NULL)
+ strncpy(make_model, ippGetString(attr, 0, NULL), 256);
+ color = 0;
+ duplex = 0;
+ for (r = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ r; r = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if (!strcmp(p->queue_name, r->queue_name)) {
+ if (r->color == 1)
+ color = 1;
+ if (r->duplex == 1)
+ duplex = 1;
+ }
+ }
+ default_pagesize = (char *)malloc(sizeof(char)*32);
+ printer_attributes = get_cluster_attributes(p->queue_name);
+ debug_printf("Generated Merged Attributes for local queue %s\n",
+ p->queue_name);
+ conflicts = generate_cluster_conflicts(p->queue_name,
+ printer_attributes);
+ debug_printf("Generated Constraints for queue %s\n",
+ p->queue_name);
+ sizes = get_cluster_sizes(p->queue_name);
+ get_cluster_default_attributes(&printer_attributes,
+ p->queue_name, default_pagesize,
+ &default_color);
+ debug_printf("Generated Default Attributes for local queue %s\n",
+ p->queue_name);
+ }
p->nickname = NULL;
if (ppdfile == NULL) {
/* If we do not want CUPS-generated PPDs or we cannot obtain a
CUPS-generated PPD, for example if CUPS does not create a
temporary queue for this printer, we generate a PPD by
ourselves */
- if (!ppdCreateFromIPP(buffer, sizeof(buffer), p->prattrs, p->make_model,
- p->pdl, p->color, p->duplex)) {
+ printer_ipp_response = (num_cluster_printers == 1) ? p->prattrs :
+ printer_attributes;
+ if (!ppdCreateFromIPP2(buffer, sizeof(buffer), printer_ipp_response,
+ make_model,
+ pdl, color, duplex, conflicts, sizes,
+ default_pagesize, default_color)) {
if (errno != 0)
- debug_printf("Unable to create PPD file: %s\n", strerror(errno));
+ debug_printf("Unable to create PPD file: %s\n",
+ strerror(errno));
else
- debug_printf("Unable to create PPD file: %s\n", ppdgenerator_msg);
+ debug_printf("Unable to create PPD file: %s\n",
+ ppdgenerator_msg);
p->status = STATUS_DISAPPEARED;
current_time = time(NULL);
p->timeout = current_time + TIMEOUT_IMMEDIATELY;
@@ -4928,13 +7763,18 @@ gboolean update_cups_queues(gpointer unused) {
p->num_options = cupsAddOption("media-default",
strdup(default_page_size),
p->num_options, &(p->options));
- } else
+ } else
debug_printf("No default page size found!\n");
}
/* Find maximum unprintable margins of the printer */
- if ((attr = ippFindAttribute(p->prattrs, "media-bottom-margin-supported", IPP_TAG_INTEGER)) != NULL) {
- for (i = 1, bottom = ippGetInteger(attr, 0), count = ippGetCount(attr); i < count; i ++)
+ if ((attr = ippFindAttribute(p->prattrs,
+ "media-bottom-margin-supported",
+ IPP_TAG_INTEGER)) != NULL) {
+ for (i = 1, bottom = ippGetInteger(attr, 0),
+ count = ippGetCount(attr);
+ i < count;
+ i ++)
if (ippGetInteger(attr, i) > bottom)
bottom = ippGetInteger(attr, i);
} else
@@ -4944,8 +7784,13 @@ gboolean update_cups_queues(gpointer unused) {
strdup(buffer),
p->num_options, &(p->options));
- if ((attr = ippFindAttribute(p->prattrs, "media-left-margin-supported", IPP_TAG_INTEGER)) != NULL) {
- for (i = 1, left = ippGetInteger(attr, 0), count = ippGetCount(attr); i < count; i ++)
+ if ((attr = ippFindAttribute(p->prattrs,
+ "media-left-margin-supported",
+ IPP_TAG_INTEGER)) != NULL) {
+ for (i = 1, left = ippGetInteger(attr, 0),
+ count = ippGetCount(attr);
+ i < count;
+ i ++)
if (ippGetInteger(attr, i) > left)
left = ippGetInteger(attr, i);
} else
@@ -4955,8 +7800,13 @@ gboolean update_cups_queues(gpointer unused) {
strdup(buffer),
p->num_options, &(p->options));
- if ((attr = ippFindAttribute(p->prattrs, "media-right-margin-supported", IPP_TAG_INTEGER)) != NULL) {
- for (i = 1, right = ippGetInteger(attr, 0), count = ippGetCount(attr); i < count; i ++)
+ if ((attr = ippFindAttribute(p->prattrs,
+ "media-right-margin-supported",
+ IPP_TAG_INTEGER)) != NULL) {
+ for (i = 1, right = ippGetInteger(attr, 0),
+ count = ippGetCount(attr);
+ i < count;
+ i ++)
if (ippGetInteger(attr, i) > right)
right = ippGetInteger(attr, i);
} else
@@ -4966,8 +7816,13 @@ gboolean update_cups_queues(gpointer unused) {
strdup(buffer),
p->num_options, &(p->options));
- if ((attr = ippFindAttribute(p->prattrs, "media-top-margin-supported", IPP_TAG_INTEGER)) != NULL) {
- for (i = 1, top = ippGetInteger(attr, 0), count = ippGetCount(attr); i < count; i ++)
+ if ((attr = ippFindAttribute(p->prattrs,
+ "media-top-margin-supported",
+ IPP_TAG_INTEGER)) != NULL) {
+ for (i = 1, top = ippGetInteger(attr, 0),
+ count = ippGetCount(attr);
+ i < count;
+ i ++)
if (ippGetInteger(attr, i) > top)
top = ippGetInteger(attr, i);
} else
@@ -5005,10 +7860,12 @@ gboolean update_cups_queues(gpointer unused) {
}
if (p->duplex)
- p->num_options = cupsAddOption("sides-default", "two-sided-long-edge",
+ p->num_options = cupsAddOption("sides-default",
+ "two-sided-long-edge",
p->num_options, &(p->options));
- p->num_options = cupsAddOption("output-format-default", strdup(p->pdl),
+ p->num_options = cupsAddOption("output-format-default",
+ strdup(p->pdl),
p->num_options, &(p->options));
p->num_options = cupsAddOption("make-and-model-default",
remove_bad_chars(p->make_model, 0),
@@ -5057,8 +7914,6 @@ gboolean update_cups_queues(gpointer unused) {
ifscript = strdup(tempfile);
}
- ippDelete(p->prattrs);
- p->prattrs = NULL;
}
#endif /* HAVE_CUPS_1_6 */
@@ -5074,18 +7929,12 @@ gboolean update_cups_queues(gpointer unused) {
p->num_options = load_printer_options(p->queue_name, p->num_options,
&p->options);
- /* If we create a queue to a remote CUPS printer we need the queue
- name on the remote server */
- if (p->netprinter == 0)
- remote_cups_queue = strrchr(p->uri, '/') + 1;
-
/* Determine whether we have an IPP network printer. If not we
have remote CUPS queue(s) and so we use an implicit class for
load balancing. In this case we will assign an
implicitclass://... device URI, which makes cups-browsed find
the best destination for each job. */
loadedppd = NULL;
- pass_through_ppd = 0;
if (cups_notifier != NULL && p->netprinter == 0) {
/* We are not an IPP network printer, so we use the device URI
implicitclass://<queue name>/
@@ -5115,45 +7964,98 @@ gboolean update_cups_queues(gpointer unused) {
the PPD's NickName, so that automatic PPD updating by the
distribution's package installation/update infrastructure
is suppressed. */
- /* Load the PPD file from one of the servers */
- if ((remote_http =
- httpConnectEncryptShortTimeout(p->ip ? p->ip : p->host,
- p->port ? p->port :
- ippPort(),
- cupsEncryption()))
- == NULL) {
- debug_printf("Could not connect to the server %s:%d for %s!\n",
- p->host, p->port, p->queue_name);
- current_time = time(NULL);
- p->timeout = current_time + TIMEOUT_RETRY;
- p->no_autosave = 0;
- break;
+ /* Generating the ppd file for the remote cups queue */
+ if (p->prattrs == NULL)
+ p->prattrs = get_printer_attributes(p->uri);
+ if (p->prattrs == NULL) {
+ debug_printf("get-printer-attributes IPP call failed on printer %s (%s).\n",
+ p->queue_name, p->uri);
+ goto cannot_create;
}
- httpSetTimeout(remote_http, HttpRemoteTimeout, http_timeout_cb, NULL);
- if ((loadedppd = cupsGetPPD2(remote_http, remote_cups_queue))
- == NULL &&
- CreateRemoteRawPrinterQueues == 0) {
- debug_printf("Unable to load PPD file for %s from the server %s:%d!\n",
- p->queue_name, p->host, p->port);
- current_time = time(NULL);
- p->timeout = current_time + TIMEOUT_RETRY;
- p->no_autosave = 0;
- httpClose(remote_http);
- break;
- } else if (loadedppd) {
- debug_printf("Loaded PPD file %s for printer %s from server %s:%d!\n",
- loadedppd, p->queue_name, p->host, p->port);
- /* Modify PPD to not filter the job */
- pass_through_ppd = 1;
+ p->nickname = NULL;
+ num_cluster_printers = 0;
+ for (s = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ s; s = (remote_printer_t *)cupsArrayNext(remote_printers)) {
+ if(!strcmp(s->queue_name,p->queue_name)) {
+ if(s->status == STATUS_DISAPPEARED || s->status == STATUS_UNCONFIRMED ||
+ s->status == STATUS_TO_BE_RELEASED )
+ continue;
+ num_cluster_printers++;
+ }
+ }
+ if (num_cluster_printers == 1) {
+ printer_attributes = p->prattrs;
+ conflicts = NULL;
+ default_pagesize = NULL;
+ default_color = NULL;
+ make_model = p->make_model;
+ pdl = p->pdl;
+ color = p->color;
+ duplex = p->duplex;
+ sizes = NULL;
+ } else {
+ make_model = (char*)malloc(sizeof(char)*256);
+ if((attr = ippFindAttribute(printer_attributes,
+ "printer-make-and-model",
+ IPP_TAG_TEXT)) != NULL)
+ strncpy(make_model, ippGetString(attr, 0, NULL), 256);
+ color = 0;
+ duplex = 0;
+ for(r = (remote_printer_t *)cupsArrayFirst(remote_printers);
+ r; r = (remote_printer_t *)cupsArrayNext(remote_printers)){
+ if(!strcmp(p->queue_name,r->queue_name)){
+ if(r->color==1)
+ color = 1;
+ if(r->duplex==1)
+ duplex = 1;
+ }
+ }
+ default_pagesize = (char *)malloc(sizeof(char)*32);
+ printer_attributes = get_cluster_attributes(p->queue_name);
+ debug_printf("Generated Merged Attributes for local queue %s\n",
+ p->queue_name);
+ conflicts = generate_cluster_conflicts(p->queue_name,
+ printer_attributes);
+ debug_printf("Generated Constraints for queue %s\n",p->queue_name);
+ sizes = get_cluster_sizes(p->queue_name);
+ get_cluster_default_attributes(&printer_attributes, p->queue_name,
+ default_pagesize,&default_color);
+ debug_printf("Generated Default Attributes for local queue %s\n",
+ p->queue_name);
+ }
+ if (ppdfile == NULL) {
+ /* If we do not want CUPS-generated PPDs or we cannot obtain a
+ CUPS-generated PPD, for example if CUPS does not create a
+ temporary queue for this printer, we generate a PPD by
+ ourselves */
+ printer_ipp_response = (num_cluster_printers == 1) ? p->prattrs :
+ printer_attributes;
+ if (!ppdCreateFromIPP2(buffer, sizeof(buffer), printer_ipp_response,
+ make_model,
+ pdl, color, duplex, conflicts, sizes,
+ default_pagesize, default_color)) {
+ if (errno != 0)
+ debug_printf("Unable to create PPD file: %s\n", strerror(errno));
+ else
+ debug_printf("Unable to create PPD file: %s\n", ppdgenerator_msg);
+ p->status = STATUS_DISAPPEARED;
+ current_time = time(NULL);
+ p->timeout = current_time + TIMEOUT_IMMEDIATELY;
+ goto cannot_create;
+ } else {
+ debug_printf("PPD generation successful: %s\n", ppdgenerator_msg);
+ debug_printf("Created temporary PPD file: %s\n", buffer);
+ ppdfile = strdup(buffer);
+ }
}
- httpClose(remote_http);
}
} else {
- /* Device URI: ipp(s)://<remote host>:631/printers/<remote queue> */
- strncpy(device_uri, p->uri, sizeof(device_uri));
+ /* Device URI: using implicitclass backend for IPP network printer */
+ httpAssembleURI(HTTP_URI_CODING_ALL, device_uri, sizeof(device_uri),
+ "implicitclass", NULL, p->queue_name, 0, NULL);
if (strlen(p->uri) > HTTP_MAX_URI-1)
device_uri[HTTP_MAX_URI-1] = '\0';
- debug_printf("Print queue %s is for an IPP network printer, or we do not get notifications from CUPS, using direct device URI %s\n",
+ debug_printf("Print queue %s is for an IPP network printer, using implicitclass backend for the printer. %s\n",
p->queue_name, device_uri);
}
@@ -5198,66 +8100,11 @@ gboolean update_cups_queues(gpointer unused) {
}
debug_printf("Editing PPD file %s for printer %s, setting the option defaults of the previous cups-browsed session%s, saving the resulting PPD in %s.\n",
loadedppd, p->queue_name,
- (pass_through_ppd == 1 ?
- " and inhibiting client-side filtering of the job" : ""),
+ " and doing client-side filtering of the job" ,
buf);
- new_cupsfilter_line_inserted = 0;
ap_remote_queue_id_line_inserted = 0;
- cont_line_read = 0;
while (cupsFileGets(in, line, sizeof(line))) {
- if (pass_through_ppd == 1 &&
- (!strncmp(line, "*cupsFilter:", 12) ||
- !strncmp(line, "*cupsFilter2:", 13))) {
- cont_line_read = 0;
- /* "*cupfFilter(2): ..." line: Remove it and replace the
- first one by a line which passes through the data
- unfiltered */
- if (new_cupsfilter_line_inserted == 0) {
- cupsFilePrintf(out, "*cupsFilter: \"*/* 0 -\"\n");
- new_cupsfilter_line_inserted = 1;
- }
- /* Find the end of the "*cupsFilter(2): ..." entry in the
- case it spans more than one line */
- do {
- if (strlen(line) != 0) {
- ptr = line + strlen(line) - 1;
- while(isspace(*ptr) && ptr > line)
- ptr --;
- if (*ptr == '"')
- break;
- }
- cont_line_read = 1;
- } while (cupsFileGets(in, line, sizeof(line)));
- } else if (pass_through_ppd == 1 &&
- !strncmp(line, "*NickName:", 10)) {
- cont_line_read = 0;
- /* Prefix the "NickName" of the printer so that automatic
- PPD updaters skip this PPD */
- ptr = strchr(line, '"');
- if (ptr) {
- ptr ++;
- prefix = "Remote printer: ";
- line[sizeof(line) - strlen(prefix) - 1] = '\0';
- memmove(ptr + strlen(prefix), ptr, strlen(ptr) + 1);
- memmove(ptr, prefix, strlen(prefix));
- ptr = line + strlen(line) - 1;
- while(isspace(*ptr) && ptr > line) {
- ptr --;
- *ptr = '\0';
- }
- if (*ptr != '"') {
- if (ptr < line + sizeof(line) - 2) {
- *(ptr + 1) = '"';
- *(ptr + 2) = '\0';
- } else {
- line[sizeof(line) - 2] = '"';
- line[sizeof(line) - 1] = '\0';
- }
- }
- }
- cupsFilePrintf(out, "%s\n", line);
- } else if (!strncmp(line, "*Default", 8)) {
- cont_line_read = 0;
+ if (!strncmp(line, "*Default", 8)) {
strncpy(keyword, line + 8, sizeof(keyword));
if ((strlen(line) + 8) > 1023)
keyword[1023] = '\0';
@@ -5286,8 +8133,7 @@ gboolean update_cups_queues(gpointer unused) {
cupsFilePrintf(out, "%s\n", line);
} else
cupsFilePrintf(out, "%s\n", line);
- } else if (cont_line_read == 0 || strncmp(line, "*End", 4)) {
- cont_line_read = 0;
+ } else if (strncmp(line, "*End", 4)) {
/* Write an "APRemoteQueueID" line to make this queue marked
as remote printer by CUPS */
if (p->netprinter == 0 &&
@@ -5313,8 +8159,8 @@ gboolean update_cups_queues(gpointer unused) {
}
}
}
- if (pass_through_ppd == 1 && new_cupsfilter_line_inserted == 0)
- cupsFilePrintf(out, "*cupsFilter: \"*/* 0 -\"\n");
+ cupsFilePrintf(out,"*cupsFilter2: \"application/vnd.cups-pdf application/pdf 0 -\"\n");
+
cupsFileClose(in);
cupsFileClose(out);
ppdClose(ppd);
@@ -5328,7 +8174,7 @@ gboolean update_cups_queues(gpointer unused) {
/* Create a new CUPS queue or modify the existing queue */
request = ippNewRequest(CUPS_ADD_MODIFY_PRINTER);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
- "printer-uri", NULL, uri);
+ "printer-uri", NULL, uri);
/* Default user */
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
"requesting-user-name", NULL, cupsUser());
@@ -5384,7 +8230,7 @@ gboolean update_cups_queues(gpointer unused) {
} else {
debug_printf("Queue %s keeping its current PPD file/interface script\n", p->queue_name);
want_raw = 0;
- }
+ }
ippDelete(cupsDoRequest(http, request, "/admin/"));
}
cupsFreeOptions(num_options, options);
@@ -5418,7 +8264,7 @@ gboolean update_cups_queues(gpointer unused) {
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI,
"printer-uri", NULL, uri);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
- "requesting-user-name", NULL, cupsUser());
+ "requesting-user-name", NULL, cupsUser());
num_options = 0;
options = NULL;
if (p->netprinter == 1 &&
@@ -5438,7 +8284,15 @@ gboolean update_cups_queues(gpointer unused) {
}
cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);
cupsEncodeOptions2(request, num_options, options, IPP_TAG_PRINTER);
- ippDelete(cupsDoRequest(http, request, "/admin/"));
+ /*
+ * Do IPP request for printer-is-shared option only when we have
+ * network printer or if we have remote CUPS queue, do IPP request
+ * only if we have CUPS older than 2.2.
+ */
+ if (p->netprinter != 0 || !HAVE_CUPS_2_2)
+ ippDelete(cupsDoRequest(http, request, "/admin/"));
+ else
+ ippDelete(request);
cupsFreeOptions(num_options, options);
if (cupsLastError() > IPP_STATUS_OK_EVENTS_COMPLETE)
debug_printf("Unable to modify the printer-is-shared bit (%s)!\n",
@@ -5479,7 +8333,10 @@ gboolean update_cups_queues(gpointer unused) {
if ((disabled_str = is_disabled(p->queue_name, "cups-browsed")) != NULL) {
enable_printer(p->queue_name);
free(disabled_str);
- } else if ((disabled_str = is_disabled(p->queue_name, "Printer stopped due to backend errors")) != NULL) {
+ } else if ((disabled_str =
+ is_disabled(p->queue_name,
+ "Printer stopped due to backend errors")) !=
+ NULL) {
enable_printer(p->queue_name);
free(disabled_str);
}
@@ -5494,8 +8351,8 @@ gboolean update_cups_queues(gpointer unused) {
/* Check if an HTTP timeout happened during the print queue creation
If it does - increment p->timeouted and set status to TO_BE_CREATED
- because the creation can fall through the process, have state changed to
- STATUS_CONFIRMED and experience the timeout */
+ because the creation can fall through the process, have state changed
+ to STATUS_CONFIRMED and experience the timeout */
/* If no timeout has happened, clear p->timeouted */
if (timeout_reached == 1) {
fprintf(stderr, "Timeout happened during creation of the queue %s, turn on DebugLogging for more info.\n", p->queue_name);
@@ -5627,17 +8484,17 @@ matched_filters (const char *queue_name,
avahi_free(value);
goto filter_failed;
}
- }
+ }
} else {
/* match boolean value */
if (filter->sense == FILTER_MATCH) {
- if (!value || strcasecmp(value, "T")) {
+ if (!value || strcasecmp(value, "T")) {
avahi_free(key);
avahi_free(value);
goto filter_failed;
}
} else {
- if (value && !strcasecmp(value, "T")) {
+ if (value && !strcasecmp(value, "T")) {
avahi_free(key);
avahi_free(value);
goto filter_failed;
@@ -5730,7 +8587,7 @@ examine_discovered_printer_record(const char *host,
char uri[HTTP_MAX_URI];
char *remote_host = NULL, *pdl = NULL,
- *make_model = NULL;
+ *make_model = NULL;
int color = 1, duplex = 1;
#ifdef HAVE_AVAHI
char *fields[] = { "product", "usb_MDL", "ty", NULL }, **f;
@@ -5749,7 +8606,6 @@ examine_discovered_printer_record(const char *host,
return NULL;
}
-
is_cups_queue = 0;
memset(uri, 0, sizeof(uri));
@@ -5758,9 +8614,8 @@ examine_discovered_printer_record(const char *host,
(strcasestr(type, "_ipps") ? "ipps" : "ipp"), NULL,
(ip != NULL ? ip : host), port, "/%s", resource);
/* Find the remote host name.
- * Used in constructing backup queue name, so need to sanitize.
- * strdup() is called inside remove_bad_chars() and result is free()-able.
- */
+ Used in constructing backup queue name, so need to sanitize.
+ strdup() is called inside remove_bad_chars() and result is free()-able. */
remote_host = remove_bad_chars(host, 1);
/* If we only want to create queues for printers for which CUPS does
@@ -5770,8 +8625,8 @@ examine_discovered_printer_record(const char *host,
if (g_hash_table_find (cups_supported_remote_printers,
local_printer_service_name_matches,
(gpointer *)service_name)) {
- /* Found a DNS-SD-discovered CUPS-supported printer whose service name matches
- our discovered printer */
+ /* Found a DNS-SD-discovered CUPS-supported printer whose service name
+ matches our discovered printer */
debug_printf("Printer with DNS-SD service name \"%s\" and URI \"%s\" does not need to be covered by us as it is already supported by CUPS, skipping.\n",
service_name, uri);
goto fail;
@@ -5799,11 +8654,13 @@ examine_discovered_printer_record(const char *host,
avahi_free(value);
}
}
- /* Check by the printer-type TXT field whether the discovered printer is a CUPS queue */
+ /* Check by the printer-type TXT field whether the discovered printer is a
+ CUPS queue */
entry = avahi_string_list_find((AvahiStringList *)txt, "printer-type");
if (entry) {
avahi_string_list_get_pair(entry, &key, &value, NULL);
- if (key && value && strlen(value) > 1 && !strcasecmp(key, "printer-type") && value[0] == '0' &&
+ if (key && value && strlen(value) > 1 &&
+ !strcasecmp(key, "printer-type") && value[0] == '0' &&
value[1] == 'x') {
is_cups_queue = 1;
}
@@ -5897,7 +8754,8 @@ examine_discovered_printer_record(const char *host,
if (entry) {
avahi_string_list_get_pair(entry, &key, &note_value, NULL);
if (key && note_value && !strcasecmp(key, "note")) {
- debug_printf("examine_discovered_printer_record: TXT.note: |%s|\n", note_value); /* !! */
+ debug_printf("examine_discovered_printer_record: TXT.note: |%s|\n",
+ note_value); /* !! */
location = note_value;
}
avahi_free(key);
@@ -5907,7 +8765,8 @@ examine_discovered_printer_record(const char *host,
if (!location)
location = "";
}
- /* A NULL location is only passed in from resolve_callback(), which is HAVE_AVAHI */
+ /* A NULL location is only passed in from resolve_callback(), which is
+ HAVE_AVAHI */
#endif /* HAVE_AVAHI */
/* Determine the queue name */
@@ -5916,8 +8775,8 @@ examine_discovered_printer_record(const char *host,
if (local_queue_name == NULL)
goto fail;
- if (!matched_filters (local_queue_name, remote_host, port, service_name, domain,
- txt)) {
+ if (!matched_filters (local_queue_name, remote_host, port, service_name,
+ domain, txt)) {
debug_printf("Printer %s does not match BrowseFilter lines in cups-browsed.conf, printer ignored.\n",
local_queue_name);
goto fail;
@@ -6272,7 +9131,7 @@ update_netifs (gpointer data)
addr_size = 0;
if (addr_size)
for (i = 0; i <= 1; i ++)
- if (getnameinfo (ifa->ifa_addr, addr_size,
+ if (getnameinfo (ifa->ifa_addr, addr_size,
buf, HTTP_MAX_HOST, NULL, 0,
i == 0 ? NI_NUMERICHOST : NI_NAMEREQD) == 0)
if (buf[0]) {
@@ -6319,13 +9178,14 @@ update_netifs (gpointer data)
memcpy (&iface->broadcast, ifa->ifa_broadaddr,
sizeof (struct sockaddr_in));
iface->broadcast.ipv4.sin_port = htons (BrowsePort);
- /* discard if we already have an interface sharing the broadcast address */
+ /* discard if we already have an interface sharing the broadcast
+ address */
dupe = 0;
for (iface2 = (netif_t *)cupsArrayFirst (netifs);
iface2 != NULL;
iface2 = (netif_t *)cupsArrayNext (netifs)) {
if (memcmp(&iface2->broadcast, &iface->broadcast,
- sizeof(struct sockaddr_in)) == 0) {
+ sizeof(struct sockaddr_in)) == 0) {
dupe = 1;
break;
}
@@ -6351,7 +9211,7 @@ update_netifs (gpointer data)
iface2 != NULL;
iface2 = (netif_t *)cupsArrayNext (netifs)) {
if (memcmp(&iface2->broadcast, ifa->ifa_broadaddr,
- sizeof(struct sockaddr_in6)) == 0) {
+ sizeof(struct sockaddr_in6)) == 0) {
dupe = 1;
break;
}
@@ -6379,20 +9239,19 @@ update_netifs (gpointer data)
}
#ifdef HAVE_AVAHI
-static void resolve_callback(
- AvahiServiceResolver *r,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- AvahiResolverEvent event,
- const char *name,
- const char *type,
- const char *domain,
- const char *host_name,
- const AvahiAddress *address,
- uint16_t port,
- AvahiStringList *txt,
- AvahiLookupResultFlags flags,
- AVAHI_GCC_UNUSED void* userdata) {
+static void resolve_callback(AvahiServiceResolver *r,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiResolverEvent event,
+ const char *name,
+ const char *type,
+ const char *domain,
+ const char *host_name,
+ const AvahiAddress *address,
+ uint16_t port,
+ AvahiStringList *txt,
+ AvahiLookupResultFlags flags,
+ AVAHI_GCC_UNUSED void* userdata) {
char ifname[IF_NAMESIZE];
debug_printf("resolve_callback() in THREAD %ld\n", pthread_self());
@@ -6632,16 +9491,15 @@ static void resolve_callback(
recheck_timer ();
}
-static void browse_callback(
- AvahiServiceBrowser *b,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- AvahiBrowserEvent event,
- const char *name,
- const char *type,
- const char *domain,
- AvahiLookupResultFlags flags,
- void* userdata) {
+static void browse_callback(AvahiServiceBrowser *b,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiBrowserEvent event,
+ const char *name,
+ const char *type,
+ const char *domain,
+ AvahiLookupResultFlags flags,
+ void* userdata) {
AvahiClient *c = userdata;
char ifname[IF_NAMESIZE];
@@ -7063,7 +9921,7 @@ process_browse_data (GIOChannel *source,
end = packet + sizeof(packet);
c = strchr (packet, '\"');
if (c >= end)
- return TRUE;
+ return TRUE;
if (c) {
/* Extract location field */
@@ -7081,7 +9939,7 @@ process_browse_data (GIOChannel *source,
;
if (c >= end)
- return TRUE;
+ return TRUE;
if (*c == '\"') {
for (c++; c < end && isspace(*c); c++)
@@ -7277,7 +10135,6 @@ browse_poll_get_printers (browsepoll_t *context, http_t *conn)
info = NULL;
location = NULL;
while (attr && ippGetGroupTag(attr) == IPP_TAG_PRINTER) {
-
if (!strcasecmp (ippGetName(attr), "printer-uri-supported") &&
ippGetValueTag(attr) == IPP_TAG_URI)
uri = ippGetString(attr, 0, NULL);
@@ -7287,7 +10144,6 @@ browse_poll_get_printers (browsepoll_t *context, http_t *conn)
else if (!strcasecmp (ippGetName(attr), "printer-info") &&
ippGetValueTag(attr) == IPP_TAG_TEXT)
info = ippGetString(attr, 0, NULL);
-
attr = ippNextAttribute(response);
}
@@ -7513,7 +10369,8 @@ browsepoll_printer_keepalive (gpointer data, gpointer user_data)
{
browsepoll_printer_t *printer = data;
const char *server = user_data;
- debug_printf("browsepoll_printer_keepalive() in THREAD %ld\n", pthread_self());
+ debug_printf("browsepoll_printer_keepalive() in THREAD %ld\n",
+ pthread_self());
found_cups_printer (server, printer->uri_supported, printer->location,
printer->info);
}
@@ -7591,44 +10448,38 @@ browse_ldap_poll (gpointer data)
debug_printf("browse_ldap_poll() in THREAD %ld\n", pthread_self());
/* do real stuff here */
- if (!BrowseLDAPDN)
- {
+ if (!BrowseLDAPDN) {
debug_printf("Need to set BrowseLDAPDN to use LDAP browsing!\n");
BrowseLocalProtocols &= ~BROWSE_LDAP;
BrowseRemoteProtocols &= ~BROWSE_LDAP;
return FALSE;
- }
- else
- {
- if (!BrowseLDAPInitialised)
- {
+ } else {
+ if (!BrowseLDAPInitialised) {
BrowseLDAPInitialised = TRUE;
/*
* Query filter string
*/
if (BrowseLDAPFilter)
- filterLen = snprintf(NULL, 0, "(&%s%s)", LDAP_BROWSE_FILTER, BrowseLDAPFilter);
+ filterLen = snprintf(NULL, 0, "(&%s%s)", LDAP_BROWSE_FILTER,
+ BrowseLDAPFilter);
else
filterLen = strlen(LDAP_BROWSE_FILTER);
tmpFilter = (char *)malloc(filterLen + 1);
- if (!tmpFilter)
- {
- debug_printf("Could not allocate memory for LDAP browse query filter!\n");
- BrowseLocalProtocols &= ~BROWSE_LDAP;
- BrowseRemoteProtocols &= ~BROWSE_LDAP;
-
- return FALSE;
- }
+ if (!tmpFilter) {
+ debug_printf("Could not allocate memory for LDAP browse query filter!\n");
+ BrowseLocalProtocols &= ~BROWSE_LDAP;
+ BrowseRemoteProtocols &= ~BROWSE_LDAP;
+ return FALSE;
+ }
- if (BrowseLDAPFilter)
- {
- snprintf(tmpFilter, filterLen + 1, "(&%s%s)", LDAP_BROWSE_FILTER, BrowseLDAPFilter);
- free(BrowseLDAPFilter);
- BrowseLDAPFilter = NULL;
- }
- else
+ if (BrowseLDAPFilter) {
+ snprintf(tmpFilter, filterLen + 1, "(&%s%s)", LDAP_BROWSE_FILTER,
+ BrowseLDAPFilter);
+ free(BrowseLDAPFilter);
+ BrowseLDAPFilter = NULL;
+ } else
strcpy(tmpFilter, LDAP_BROWSE_FILTER);
BrowseLDAPFilter = tmpFilter;
@@ -7698,7 +10549,7 @@ sigusr2_handler(int sig) {
debug_printf ("We entered auto shutdown mode and no printers are there to make available or no jobs on them, shutting down in %d sec...\n", autoshutdown_timeout);
autoshutdown_exec_id =
g_timeout_add_seconds (autoshutdown_timeout, autoshutdown_execute,
- NULL);
+ NULL);
}
}
@@ -7777,7 +10628,7 @@ read_configuration (const char *filename)
cups_file_t *fp;
int i, linenum = 0;
char line[HTTP_MAX_BUFFER];
- char *value = NULL, *ptr, *start = NULL;
+ char *value = NULL, *ptr, *ptr2, *start;
const char *delim = " \t,";
int browse_allow_line_found = 0;
int browse_deny_line_found = 0;
@@ -7806,7 +10657,9 @@ read_configuration (const char *filename)
in the configuration file is used. */
while ((i < cupsArrayCount(command_line_config) &&
(value = cupsArrayIndex(command_line_config, i++)) &&
- strncpy(line, value, sizeof(line)) && ((strlen(value) > HTTP_MAX_BUFFER-1)? line[HTTP_MAX_BUFFER-1] = '\0': 1)) ||
+ strncpy(line, value, sizeof(line)) &&
+ ((strlen(value) > HTTP_MAX_BUFFER-1) ?
+ line[HTTP_MAX_BUFFER-1] = '\0': 1)) ||
cupsFileGetConf(fp, line, sizeof(line), &value, &linenum)) {
if (linenum < 0) {
/* We are still reading options from the command line ("-o ..."),
@@ -7847,8 +10700,8 @@ read_configuration (const char *filename)
if (value[0] != '\0')
strncpy(logdir, value, sizeof(logdir) - 1);
} else if ((!strcasecmp(line, "BrowseProtocols") ||
- !strcasecmp(line, "BrowseLocalProtocols") ||
- !strcasecmp(line, "BrowseRemoteProtocols")) && value) {
+ !strcasecmp(line, "BrowseLocalProtocols") ||
+ !strcasecmp(line, "BrowseRemoteProtocols")) && value) {
int protocols = 0;
char *p, *saveptr;
p = strtok_r (value, delim, &saveptr);
@@ -8107,28 +10960,28 @@ read_configuration (const char *filename)
!strcasecmp(value, "on") || !strcasecmp(value, "1"))
OnlyUnsupportedByCUPS = 1;
else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
- !strcasecmp(value, "off") || !strcasecmp(value, "0"))
+ !strcasecmp(value, "off") || !strcasecmp(value, "0"))
OnlyUnsupportedByCUPS = 0;
} else if (!strcasecmp(line, "UseCUPSGeneratedPPDs") && value) {
if (!strcasecmp(value, "yes") || !strcasecmp(value, "true") ||
!strcasecmp(value, "on") || !strcasecmp(value, "1"))
UseCUPSGeneratedPPDs = 1;
else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
- !strcasecmp(value, "off") || !strcasecmp(value, "0"))
+ !strcasecmp(value, "off") || !strcasecmp(value, "0"))
UseCUPSGeneratedPPDs = 0;
} else if (!strcasecmp(line, "CreateRemoteRawPrinterQueues") && value) {
if (!strcasecmp(value, "yes") || !strcasecmp(value, "true") ||
!strcasecmp(value, "on") || !strcasecmp(value, "1"))
CreateRemoteRawPrinterQueues = 1;
else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
- !strcasecmp(value, "off") || !strcasecmp(value, "0"))
+ !strcasecmp(value, "off") || !strcasecmp(value, "0"))
CreateRemoteRawPrinterQueues = 0;
} else if (!strcasecmp(line, "CreateRemoteCUPSPrinterQueues") && value) {
if (!strcasecmp(value, "yes") || !strcasecmp(value, "true") ||
!strcasecmp(value, "on") || !strcasecmp(value, "1"))
CreateRemoteCUPSPrinterQueues = 1;
else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
- !strcasecmp(value, "off") || !strcasecmp(value, "0"))
+ !strcasecmp(value, "off") || !strcasecmp(value, "0"))
CreateRemoteCUPSPrinterQueues = 0;
} else if (!strcasecmp(line, "CreateIPPPrinterQueues") && value) {
if (!strcasecmp(value, "all") ||
@@ -8136,7 +10989,7 @@ read_configuration (const char *filename)
!strcasecmp(value, "on") || !strcasecmp(value, "1"))
CreateIPPPrinterQueues = IPP_PRINTERS_ALL;
else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
- !strcasecmp(value, "off") || !strcasecmp(value, "0"))
+ !strcasecmp(value, "off") || !strcasecmp(value, "0"))
CreateIPPPrinterQueues = IPP_PRINTERS_NO;
else if (strcasestr(value, "local") || strcasestr(value, "usb"))
CreateIPPPrinterQueues = IPP_PRINTERS_LOCAL_ONLY;
@@ -8164,17 +11017,18 @@ read_configuration (const char *filename)
!strcasecmp(value, "on") || !strcasecmp(value, "1"))
NewIPPPrinterQueuesShared = 1;
else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
- !strcasecmp(value, "off") || !strcasecmp(value, "0"))
+ !strcasecmp(value, "off") || !strcasecmp(value, "0"))
NewIPPPrinterQueuesShared = 0;
} else if (!strcasecmp(line, "AutoClustering") && value) {
if (!strcasecmp(value, "yes") || !strcasecmp(value, "true") ||
!strcasecmp(value, "on") || !strcasecmp(value, "1"))
AutoClustering = 1;
else if (!strcasecmp(value, "no") || !strcasecmp(value, "false") ||
- !strcasecmp(value, "off") || !strcasecmp(value, "0"))
+ !strcasecmp(value, "off") || !strcasecmp(value, "0"))
AutoClustering = 0;
} else if (!strcasecmp(line, "Cluster") && value) {
ptr = value;
+ ptr2 = NULL;
/* Skip white space */
while (*ptr && isspace(*ptr)) ptr ++;
/* Premature line end */
@@ -8193,26 +11047,27 @@ read_configuration (const char *filename)
if (strlen(start) <= 0)
goto cluster_fail;
/* Clean queue name */
- start = remove_bad_chars(start, 0);
+ ptr2 = remove_bad_chars(start, 0);
/* Check whether we have already a cluster with this name */
for (cluster = cupsArrayFirst(clusters);
cluster;
cluster = cupsArrayNext(clusters))
- if (!strcasecmp(start, cluster->local_queue_name)) {
+ if (!strcasecmp(ptr2, cluster->local_queue_name)) {
debug_printf("Duplicate cluster with queue name \"%s\".\n",
- start);
+ ptr2);
cluster = NULL;
goto cluster_fail;
}
/* Create the new cluster definition */
cluster = calloc (1, sizeof (cluster_t));
if (!cluster) goto cluster_fail;
- cluster->local_queue_name = start;
+ cluster->local_queue_name = ptr2;
cluster->members = cupsArrayNew(NULL, NULL);
+ ptr2 = NULL;
if (!*ptr) {
/* Only local queue name given, so assume this name as the only
member name (only remote queues with this name match) */
- cupsArrayAdd(cluster->members, remove_bad_chars(start, 2));
+ cupsArrayAdd(cluster->members, remove_bad_chars(ptr2, 2));
} else {
/* The rest of the line lists one or more member queue names */
while (*ptr) {
@@ -8231,9 +11086,9 @@ read_configuration (const char *filename)
}
}
cupsArrayAdd (clusters, cluster);
- if (start != NULL) {
- free(start);
- start = NULL;
+ if (ptr2 != NULL) {
+ free(ptr2);
+ ptr2 = NULL;
}
continue;
cluster_fail:
@@ -8250,9 +11105,9 @@ read_configuration (const char *filename)
free(cluster);
cluster = NULL;
}
- if (start != NULL) {
- free(start);
- start = NULL;
+ if (ptr2 != NULL) {
+ free(ptr2);
+ ptr2 = NULL;
}
} else if (!strcasecmp(line, "LoadBalancing") && value) {
if (!strncasecmp(value, "QueueOnClient", 13))
@@ -8271,7 +11126,7 @@ read_configuration (const char *filename)
autoshutdown = 1;
debug_printf("Turning on auto shutdown mode.\n");
} else if (!strcasecmp(p, "Off") || !strcasecmp(p, "No") ||
- !strcasecmp(p, "False") || !strcasecmp(p, "0")) {
+ !strcasecmp(p, "False") || !strcasecmp(p, "0")) {
autoshutdown = 0;
debug_printf("Turning off auto shutdown mode (permanent mode).\n");
} else if (!strcasecmp(p, "avahi")) {
@@ -8482,7 +11337,7 @@ int main(int argc, char*argv[]) {
fprintf(stderr,
"Reading command line option -c, no alternative configuration file name supplied.\n\n");
goto help;
- }
+ }
} else if (!strncasecmp(argv[i], "-o", 2)) {
/* Configuration option via command line */
val = argv[i] + 2;
@@ -8496,12 +11351,12 @@ int main(int argc, char*argv[]) {
if (val) {
cupsArrayAdd (command_line_config, strdup(val));
debug_printf("Reading command line option -o %s, applying extra configuration option.\n",
- val);
+ val);
} else {
fprintf(stderr,
"Reading command line option -o, no extra configuration option supplied.\n\n");
goto help;
- }
+ }
} else if (!strncasecmp(argv[i], "--autoshutdown-timeout", 22)) {
debug_printf("Reading command line: %s\n", argv[i]);
if (argv[i][22] == '=' && argv[i][23])
@@ -8569,7 +11424,7 @@ int main(int argc, char*argv[]) {
autoshutdown = 1;
debug_printf("Turning on auto shutdown mode.\n");
} else if (!strcasecmp(val, "Off") || !strcasecmp(val, "No") ||
- !strcasecmp(val, "False") || !strcasecmp(val, "0")) {
+ !strcasecmp(val, "False") || !strcasecmp(val, "0")) {
autoshutdown = 0;
debug_printf("Turning off auto shutdown mode (permanent mode).\n");
} else if (!strcasecmp(val, "avahi")) {
@@ -8841,16 +11696,16 @@ int main(int argc, char*argv[]) {
}
if (BrowseLocalProtocols & BROWSE_CUPS) {
- debug_printf ("will send browse data every %ds\n",
- BrowseInterval);
- g_idle_add (send_browse_data, NULL);
+ debug_printf ("will send browse data every %ds\n",
+ BrowseInterval);
+ g_idle_add (send_browse_data, NULL);
}
#ifdef HAVE_LDAP
if (BrowseRemoteProtocols & BROWSE_LDAP) {
- debug_printf ("will browse poll LDAP every %ds\n",
- BrowseInterval);
- g_idle_add (browse_ldap_poll, NULL);
+ debug_printf ("will browse poll LDAP every %ds\n",
+ BrowseInterval);
+ g_idle_add (browse_ldap_poll, NULL);
}
#endif /* HAVE_LDAP */
@@ -8885,6 +11740,8 @@ int main(int argc, char*argv[]) {
if (cups_notifier != NULL) {
g_signal_connect (cups_notifier, "printer-state-changed",
G_CALLBACK (on_printer_state_changed), NULL);
+ g_signal_connect (cups_notifier, "job-state",
+ G_CALLBACK (on_job_state), NULL);
g_signal_connect (cups_notifier, "printer-deleted",
G_CALLBACK (on_printer_deleted), NULL);
g_signal_connect (cups_notifier, "printer-modified",
@@ -8895,7 +11752,8 @@ int main(int argc, char*argv[]) {
schedule the shutdown in autoshutdown_timeout seconds */
if (autoshutdown && !autoshutdown_exec_id &&
cupsArrayCount(remote_printers) == 0) {
- debug_printf ("No printers found to make available, shutting down in %d sec...\n", autoshutdown_timeout);
+ debug_printf ("No printers found to make available, shutting down in %d sec...\n",
+ autoshutdown_timeout);
autoshutdown_exec_id =
g_timeout_add_seconds (autoshutdown_timeout, autoshutdown_execute, NULL);
}
@@ -8962,8 +11820,7 @@ fail:
#ifdef HAVE_LDAP
if (((BrowseLocalProtocols | BrowseRemoteProtocols) & BROWSE_LDAP) &&
- BrowseLDAPHandle)
- {
+ BrowseLDAPHandle) {
ldap_disconnect(BrowseLDAPHandle);
BrowseLDAPHandle = NULL;
}
@@ -9025,4 +11882,3 @@ fail:
return 1;
}
-
diff --git a/utils/cups-browsed.conf.5 b/utils/cups-browsed.conf.5
index c629d1490..745a3d2a5 100644
--- a/utils/cups-browsed.conf.5
+++ b/utils/cups-browsed.conf.5
@@ -33,6 +33,11 @@ The "DebugLogging" directive determines how should debug logging be done.
Into the file /var/log/cups/cups-browsed_log ("file"), to stderr ("stderr"), or
not at all ("none").
.PP
+Note that if cups-browsed is running as a system service (for example
+via systemd) logging to stderr makes the log output going to the
+journal or syslog. Only if you run cups-browsed from the command line
+(for development or debugging) it will actually appear on stderr.
+.PP
.nf
.fam C
DebugLogging file
diff --git a/utils/cups-browsed.conf.in b/utils/cups-browsed.conf.in
index c54ab7e82..de3b06218 100644
--- a/utils/cups-browsed.conf.in
+++ b/utils/cups-browsed.conf.in
@@ -23,6 +23,12 @@
# /var/log/cups/cups-browsed_log ('file'), to stderr ('stderr'), or
# not at all ('none')?
+# Note that if cups-browsed is running as a system service (for
+# example via systemd) logging to stderr makes the log output going to
+# the journal or syslog. Only if you run cups-browsed from the command
+# line (for development or debugging) it will actually appear on
+# stderr.
+
# DebugLogging file
# DebugLogging stderr
# DebugLogging file stderr
diff --git a/utils/driverless.1 b/utils/driverless.1
index 7dfa11bd5..189a612f5 100644
--- a/utils/driverless.1
+++ b/utils/driverless.1
@@ -13,13 +13,14 @@
.fi
.SH DESCRIPTION
\fBdriverless\fP generates PPD files for printers which are designed
-for driverless printing (currently IPP Everywhere and AirPrint
-printers) by polling capability information from the printers via
-IPP. it can be either called for listing suitable printers in the
-network and for actually generating the PPD. It can also be called by
-CUPS when CUPS is listing available PPDs/drivers or creating print
-queues, making the setup of driverless printers with printer setup
-tools transparently working.
+for driverless IPP printing (currently IPP Everywhere, AirPrint,
+Mopria, and Wi-Fi-Direct printers, network printers and also
+IPP-over-USB printers with the help of ippusbxd(8)) by polling
+capability information from the printers via IPP. it can be either
+called for listing suitable printers in the network and for actually
+generating the PPD. It can also be called by CUPS when CUPS is listing
+available PPDs/drivers or creating print queues, making the setup of
+driverless printers with printer setup tools transparently working.
.P
driverless is placed in /usr/lib/cups/driver/ for listing available
driverless-capable printers and generating PPDs for them. It should
@@ -58,12 +59,13 @@ Generate the PPD file for the supplied \fIdriver URI\fP from the output of "list
.B
\fIIPP printer URI\fB
Generate the PPD file for the supplied \fIIPP printer URI\fP (suitable URIs are listed when calling driverless without options).
-.TP
-When called without options, the IPP printer URIs of all available IPP printers will be listed.
+.P
+When called without options, the IPP printer URIs of all available
+driverless-capable IPP printers will be listed.
.P
.SH SEE ALSO
-\fBcups-browsed\fP(8), \fBippfind\fP(1)
+\fBcups-browsed\fP(8), \fBippfind\fP(1), \fBippusbxd\fP(8)
.PP
.SH AUTHOR
The authors of \fBdriverless\fP are listed in /usr/share/doc/\fBcups-filters\fP/AUTHORS.
diff --git a/utils/driverless.c b/utils/driverless.c
index 6371bdbcd..6a464c307 100644
--- a/utils/driverless.c
+++ b/utils/driverless.c
@@ -497,7 +497,8 @@ generate_ppd (const char *uri)
fprintf(stderr, "ERROR: Invalid URI: %s\n", uri);
goto fail;
}
- if ((http = httpConnect(host_name, host_port)) ==
+ if ((http = httpConnect2(host_name, host_port, NULL, AF_UNSPEC,
+ HTTP_ENCRYPT_IF_REQUESTED, 1, 5000, NULL)) ==
NULL) {
fprintf(stderr, "ERROR: Cannot connect to remote printer %s (%s:%d)\n",
uri, host_name, host_port);