From 3514df18b289ec827cb6e4c446419feab1813231 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Thu, 21 Jun 2012 23:30:20 +0100 Subject: Imported Upstream version 5.2.8 --- src/cups/Makefile.am | 18 +- src/cups/Makefile.in | 21 +- src/cups/commandtocanon.c | 1 + src/cups/commandtoepson.c | 5 +- src/cups/cups-genppdupdate.in | 49 +++- src/cups/genppd.c | 45 ++-- src/cups/rastertoprinter.c | 491 +++++++++++++++++++++++++++--------- src/cups/test-ppds | 2 +- src/cups/test-rastertogutenprint.in | 15 +- 9 files changed, 478 insertions(+), 169 deletions(-) (limited to 'src/cups') diff --git a/src/cups/Makefile.am b/src/cups/Makefile.am index f395aa0..1e27ae0 100644 --- a/src/cups/Makefile.am +++ b/src/cups/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.120 2011/01/17 23:20:51 rlk Exp $ +## $Id: Makefile.am,v 1.122 2012/03/25 17:54:32 rlk Exp $ ## Copyright (C) 2000 Roger Leigh ## ## This program is free software; you can redistribute it and/or modify @@ -27,6 +27,8 @@ include $(top_srcdir)/scripts/global.mk empty= PACKAGE = cups +BASE_VERSION = \"@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@.@GUTENPRINT_MICRO_VERSION@\" + bindir = @cups_bindir@ sbindir = @cups_sbindir@ @@ -43,7 +45,7 @@ else cups_modeldir = $(pkgdatadir)/model/gutenprint/@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@/ endif -LOCAL_CPPFLAGS = $(GUTENPRINT_CFLAGS) $(CUPS_CFLAGS) +LOCAL_CPPFLAGS = $(GUTENPRINT_CFLAGS) $(CUPS_CFLAGS) -DBASE_VERSION=$(BASE_VERSION) STP_NONLS_ENV= STP_MODULE_PATH=$(top_builddir)/src/main/.libs:$(top_builddir)/src/main STP_DATA_PATH=$(top_srcdir)/src/xml @@ -95,12 +97,12 @@ commandtoepson_SOURCES = commandtoepson.c commandtoepson_LDADD = $(CUPS_LIBS) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c i18n.c i18n.h -cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DALL_LINGUAS='"@ALL_LINGUAS@"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) +cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DALL_LINGUAS='"$(ALL_LINGUAS)"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GENPPD_LIBS) $(GUTENPRINT_LIBS) @LIBICONV@ cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c i18n.c i18n.h -gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DCUPS_DRIVER_INTERFACE -DALL_LINGUAS='"@ALL_LINGUAS@"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DCUPS_DRIVER_INTERFACE -DALL_LINGUAS='"$(ALL_LINGUAS)"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) @LIBICONV@ gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) @@ -209,20 +211,20 @@ ppd-catalog: ppd-catalog-clean ppd-nonls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(mkdir_p) ppd/C $(MAKE) ppd-catalog-clean - LC_ALL= LANG= LANGUAGE= $(STP_NONLS_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -l C -p ppd/C + LC_ALL= LANG= LANGUAGE= $(STP_NONLS_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ $(EXTRA_GENPPD_OPTS) -l C -p ppd/C ppd-global: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @echo "Global PPDs:" $(mkdir_p) ppd/Global $(MAKE) ppd-catalog - LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/Global + LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(EXTRA_GENPPD_OPTS) @WHICH_PPDS@ -p ppd/Global $(MAKE) ppd-catalog-clean ppd-global-ln: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @echo "Global PPDs (localized numbers for testing):" $(mkdir_p) ppd/Global $(MAKE) ppd-catalog - LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/Global -N + LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(EXTRA_GENPPD_OPTS) @WHICH_PPDS@ -p ppd/Global -N $(MAKE) ppd-catalog-clean ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ ppd-nonls @@ -231,7 +233,7 @@ ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ ppd-n for language in `$(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ -L` ; do \ mkdir ppd/$$language ; \ echo "$$language:" ; \ - LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -l $$language -p ppd/$$language; \ + LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(EXTRA_GENPPD_OPTS) @WHICH_PPDS@ -l $$language -p ppd/$$language; \ done $(MAKE) ppd-catalog-clean diff --git a/src/cups/Makefile.in b/src/cups/Makefile.in index 50a1c36..8f5418c 100644 --- a/src/cups/Makefile.in +++ b/src/cups/Makefile.in @@ -199,6 +199,7 @@ DB2PS = @DB2PS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DIALOG = @DIALOG@ +DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ @@ -275,6 +276,7 @@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAINTAINER_CFLAGS = @MAINTAINER_CFLAGS@ MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ @@ -295,6 +297,8 @@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PERL = @PERL@ PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PLUG_IN_PATH = @PLUG_IN_PATH@ POSUB = @POSUB@ RANLIB = @RANLIB@ @@ -318,6 +322,7 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -364,7 +369,6 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -383,13 +387,14 @@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include $(LOCAL_CPPFLAGS) $(GNUCFLAGS) GUTENPRINTUI_LIBS = $(top_builddir)/src/gutenprintui/libgutenprintui.la empty = +BASE_VERSION = \"@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@.@GUTENPRINT_MICRO_VERSION@\" pkgsysconfdir = $(cups_conf_serverroot) cupsexec_driverdir = $(pkglibdir)/driver cupsexec_filterdir = $(pkglibdir)/filter @CUPS_PPDS_AT_TOP_LEVEL_FALSE@cups_modeldir = $(pkgdatadir)/model/gutenprint/@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@/ @CUPS_PPDS_AT_TOP_LEVEL_TRUE@cups_modeldir = $(pkgdatadir)/model/ @CUPS_PPDS_AT_TOP_LEVEL_TRUE@DONT_UNINSTALL_PPDS = true -LOCAL_CPPFLAGS = $(GUTENPRINT_CFLAGS) $(CUPS_CFLAGS) +LOCAL_CPPFLAGS = $(GUTENPRINT_CFLAGS) $(CUPS_CFLAGS) -DBASE_VERSION=$(BASE_VERSION) STP_NONLS_ENV = STP_MODULE_PATH=$(top_builddir)/src/main/.libs:$(top_builddir)/src/main STP_DATA_PATH=$(top_srcdir)/src/xml STP_ENV = $(STP_NONLS_ENV) STP_LOCALEDIR=$(top_srcdir)/src/cups/catalog @BUILD_GLOBALIZED_CUPS_PPDS_FALSE@@BUILD_TRANSLATED_CUPS_PPDS_TRUE@PPD = $(PPD_NLS_1) @@ -409,11 +414,11 @@ commandtocanon_LDADD = $(CUPS_LIBS) commandtoepson_SOURCES = commandtoepson.c commandtoepson_LDADD = $(CUPS_LIBS) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c i18n.c i18n.h -cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DALL_LINGUAS='"@ALL_LINGUAS@"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) +cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DALL_LINGUAS='"$(ALL_LINGUAS)"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GENPPD_LIBS) $(GUTENPRINT_LIBS) @LIBICONV@ cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c i18n.c i18n.h -gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DCUPS_DRIVER_INTERFACE -DALL_LINGUAS='"@ALL_LINGUAS@"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DCUPS_DRIVER_INTERFACE -DALL_LINGUAS='"$(ALL_LINGUAS)"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) @LIBICONV@ gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = rastertoprinter.c i18n.c i18n.h @@ -1255,20 +1260,20 @@ ppd-catalog: ppd-catalog-clean ppd-nonls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(mkdir_p) ppd/C $(MAKE) ppd-catalog-clean - LC_ALL= LANG= LANGUAGE= $(STP_NONLS_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -l C -p ppd/C + LC_ALL= LANG= LANGUAGE= $(STP_NONLS_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ $(EXTRA_GENPPD_OPTS) -l C -p ppd/C ppd-global: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @echo "Global PPDs:" $(mkdir_p) ppd/Global $(MAKE) ppd-catalog - LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/Global + LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(EXTRA_GENPPD_OPTS) @WHICH_PPDS@ -p ppd/Global $(MAKE) ppd-catalog-clean ppd-global-ln: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @echo "Global PPDs (localized numbers for testing):" $(mkdir_p) ppd/Global $(MAKE) ppd-catalog - LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/Global -N + LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(EXTRA_GENPPD_OPTS) @WHICH_PPDS@ -p ppd/Global -N $(MAKE) ppd-catalog-clean ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ ppd-nonls @@ -1277,7 +1282,7 @@ ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ ppd-n for language in `$(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ -L` ; do \ mkdir ppd/$$language ; \ echo "$$language:" ; \ - LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -l $$language -p ppd/$$language; \ + LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(EXTRA_GENPPD_OPTS) @WHICH_PPDS@ -l $$language -p ppd/$$language; \ done $(MAKE) ppd-catalog-clean diff --git a/src/cups/commandtocanon.c b/src/cups/commandtocanon.c index db5bc92..b7b7ef2 100644 --- a/src/cups/commandtocanon.c +++ b/src/cups/commandtocanon.c @@ -14,6 +14,7 @@ #include #include #include +#include /* diff --git a/src/cups/commandtoepson.c b/src/cups/commandtoepson.c index b907a2d..e2d03b2 100644 --- a/src/cups/commandtoepson.c +++ b/src/cups/commandtoepson.c @@ -1,5 +1,5 @@ /* - * "$Id: commandtoepson.c,v 1.3 2007/12/23 17:31:51 easysw Exp $" + * "$Id: commandtoepson.c,v 1.4 2011/08/13 16:24:17 rlk Exp $" * * EPSON ESC/P2 command filter for the Common UNIX Printing System. * @@ -32,6 +32,7 @@ #include #include #include +#include /* * Macros... @@ -229,5 +230,5 @@ main(int argc, /* I - Number of command-line arguments */ /* - * End of "$Id: commandtoepson.c,v 1.3 2007/12/23 17:31:51 easysw Exp $". + * End of "$Id: commandtoepson.c,v 1.4 2011/08/13 16:24:17 rlk Exp $". */ diff --git a/src/cups/cups-genppdupdate.in b/src/cups/cups-genppdupdate.in index adf27e9..66d0a46 100644 --- a/src/cups/cups-genppdupdate.in +++ b/src/cups/cups-genppdupdate.in @@ -1,5 +1,5 @@ #! @PERL@ -w -# $Id: cups-genppdupdate.in,v 1.58 2010/01/01 19:22:18 rlk Exp $ +# $Id: cups-genppdupdate.in,v 1.60 2012/02/14 23:11:41 tillkamppeter Exp $ # Update CUPS PPDs for Gutenprint queues. # Copyright (C) 2002-2003 Roger Leigh (rleigh@debian.org) # @@ -18,7 +18,7 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. use strict; -use Getopt::Std; +use Getopt::Long; use Fcntl qw(:mode); use FileHandle; use IPC::Open2; @@ -78,8 +78,6 @@ if (-x $driver_bin) { get_driver_version(); } -$Getopt::Std::STANDARD_HELP_VERSION = 1; - my @ppd_files; # A list of in-use Gutenprint PPD files # Used to convert a language name to its two letter code @@ -175,7 +173,14 @@ if (!$quiet || $verbose) { print STDOUT "No Gutenprint PPD files to update.\n"; } elsif ($updated_ppd_count > 0) { my $plural = $updated_ppd_count == 1 ? "" : "s"; - print STDOUT "Updated $updated_ppd_count PPD file${plural}."; + print STDOUT "Updated $updated_ppd_count PPD file${plural}"; + if ($failed_ppd_count > 0) { + print STDOUT ", $failed_ppd_count failed"; + } + if ($skipped_ppd_count > 0) { + print STDOUT ", $skipped_ppd_count skipped"; + } + print STDOUT "."; if (!defined $opt_o || $opt_o ne "") { print STDOUT " Restart cupsd for the changes to take effect."; } @@ -247,7 +252,23 @@ sub get_driver_version() { } sub parse_options () { - if (!getopts('d:hnqs:vNo:p:P:r:ifl:')) { + Getopt::Long::Configure("bundling"); + if (!GetOptions("d=i" => \$opt_d, + "h" => \$opt_h, + "n" => \$opt_n, + "q" => \$opt_q, + "s=s" => \$opt_s, + "p=s" => \$opt_p, + "P=s" => \$opt_P, + "v" => \$opt_v, + "N" => \$opt_N, + "o=s" => \$opt_o, + "r=s" => \$opt_r, + "f" => \$opt_f, + "i" => \$opt_i, + "l=s" => \$opt_l, + "version" => sub { VERSION_MESSAGE(\*STDOUT) }, + "help" => sub { VERSION_MESSAGE(\*STDOUT); HELP_MESSAGE(\*STDOUT) })) { help(); } if ($opt_n) { @@ -514,7 +535,15 @@ sub update_ppd ($) { get_ppd_fh($ppd_source_filename, $filename, $driver, $locale, $region); if (! defined $source_fd) { - print "Unable to retrieve PPD file!\n"; + print "Unable to retrieve PPD file for $ppd_source_filename!\n"; + close ORIG; + return 0; + } + + my ($ndt, $nopt, $nres, $ndef, $source_data) = get_ppd_data($source_fd, 1, 1, 1, 1, 1); + if (! defined $ndt) { + print "Unable to retrieve PPD file for $ppd_source_filename!\n"; + close ORIG; return 0; } @@ -537,14 +566,13 @@ sub update_ppd ($) { seek(ORIG, 0, 0); my ($odt, $oopt, $ores, $odef) = get_ppd_data(ORIG, 1, 0, 1, 1, 0); - my ($ndt, $nopt, $nres, $ndef, $source_data) = get_ppd_data($source_fd, 1, 1, 1, 1, 1); # Close original and temporary files... close ORIG; if (! $server_multicat && ! close $source_fd) { print "Unable to retrieve new PPD file: $!\n"; - return 0; + return -1; } my %orig_default_types = %$odt; @@ -827,6 +855,7 @@ sub find_ppd ($$$$) { sub get_ppd_data(*$$$$$) { my ($fh, $types, $opts, $resolutions, $defaults, $data) = @_; my (%options, %defaults, %resolution_map, %default_types); + my ($fileversion_found) = 0; my $cur_opt = ""; my (@optionlist); my ($source_data) = ""; @@ -840,6 +869,7 @@ sub get_ppd_data(*$$$$$) { if ($resolutions || $types || $opts || $defaults || $data) { while (<$fh>) { last if $_ eq "*%*%EOFEOF\n"; + $fileversion_found = 1 if (/^\*FileVersion:/); $source_data .= $_ if ($data); chomp; if (($types || $opts) && m/^\*OpenUI/) { @@ -870,5 +900,6 @@ sub get_ppd_data(*$$$$$) { } } } + return (undef, undef, undef, undef, undef) if (! $fileversion_found); return (\%default_types, \%options, \%resolution_map, \%defaults, $source_data); } diff --git a/src/cups/genppd.c b/src/cups/genppd.c index 4e85388..f2dded8 100644 --- a/src/cups/genppd.c +++ b/src/cups/genppd.c @@ -1,5 +1,5 @@ /* - * "$Id: genppd.c,v 1.186 2011/03/13 19:28:50 rlk Exp $" + * "$Id: genppd.c,v 1.192 2012/03/25 17:54:32 rlk Exp $" * * PPD file generation program for the CUPS drivers. * @@ -81,6 +81,8 @@ static const char *gzext = ""; #include "i18n.h" +static int use_base_version = 0; + /* * Some applications use the XxYdpi tags rather than the actual * hardware resolutions to decide what resolution to print at. Some @@ -249,18 +251,17 @@ main(int argc, /* I - Number of command-line arguments */ { char buf[1024]; int status = 0; - while (status == 0 && fgets(buf, sizeof(buf) - 1, stdin)) + while (fgets(buf, sizeof(buf) - 1, stdin)) { size_t len = strlen(buf); if (len == 0) continue; if (buf[len - 1] == '\n') buf[len - 1] = '\0'; - status = cat_ppd(buf); + status |= cat_ppd(buf); fputs("*%*%EOFEOF\n", stdout); (void) fflush(stdout); } - return status; } else if (argc == 2 && !strcmp(argv[1], "VERSION")) { @@ -273,11 +274,12 @@ main(int argc, /* I - Number of command-line arguments */ return (0); } else - { - fprintf(stderr, "Usage: %s list\n", argv[0]); - fprintf(stderr, " %s cat URI\n", argv[0]); - return (1); - } + { + fprintf(stderr, "Usage: %s list\n", argv[0]); + fprintf(stderr, " %s cat URI\n", argv[0]); + return (1); + } + return (0); } @@ -457,7 +459,7 @@ main(int argc, /* I - Number of command-line arguments */ for (;;) { - if ((i = getopt(argc, argv, "23hvqc:p:l:LMVd:saNC")) == -1) + if ((i = getopt(argc, argv, "23hvqc:p:l:LMVd:saNCb")) == -1) break; switch (i) @@ -528,6 +530,9 @@ main(int argc, /* I - Number of command-line arguments */ "GNU General Public License for more details.\n"); exit(EXIT_SUCCESS); break; + case 'b': + use_base_version = 1; + break; default: usage(); exit(EXIT_FAILURE); @@ -944,7 +949,10 @@ print_ppd_header(gzFile fp, ppd_type_t ppd_type, int model, const char *driver, gzputs(fp, "*% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"); gzputs(fp, "*%\n"); gzputs(fp, "*FormatVersion: \"4.3\"\n"); - gzputs(fp, "*FileVersion: \"" VERSION "\"\n"); + if (use_base_version) + gzputs(fp, "*FileVersion: \"" BASE_VERSION "\"\n"); + else + gzputs(fp, "*FileVersion: \"" VERSION "\"\n"); /* Specify language of PPD translation */ /* TRANSLATORS: Specify the language of the PPD translation. * Use the English name of your language here, e.g. "Swedish" instead of @@ -987,11 +995,6 @@ print_ppd_header(gzFile fp, ppd_type_t ppd_type, int model, const char *driver, short_long_name[PPD_MAX_SHORT_NICKNAME] = '\0'; gzprintf(fp, "*ShortNickName: \"%s\"\n", short_long_name); - /* - * The Windows driver download stuff has problems with NickName fields - * with commas. Now use a dash instead... - */ - /* * NOTE - code in rastertoprinter looks for this version string. * If this is changed, the corresponding change must be made in @@ -1245,7 +1248,7 @@ print_color_setup(gzFile fp, int simplified, int printer_is_color, gzputs(fp, "*ColorKeyWords: \"ColorModel\"\n"); gzprintf(fp, "*OpenUI *ColorModel/%s: PickOne\n", _("Color Model")); gzputs(fp, "*OPOptionHints ColorModel: \"radiobuttons\"\n"); - gzputs(fp, "*OrderDependency: 10 AnySetup *ColorModel\n"); + gzputs(fp, "*OrderDependency: 2 AnySetup *ColorModel\n"); if (printer_is_color) { @@ -1314,7 +1317,7 @@ print_color_setup(gzFile fp, int simplified, int printer_is_color, gzputs(fp, "*ColorKeyWords: \"StpColorPrecision\"\n"); gzprintf(fp, "*OpenUI *StpColorPrecision/%s: PickOne\n", _("Color Precision")); gzputs(fp, "*OPOptionHints StpColorPrecision: \"radiobuttons\"\n"); - gzputs(fp, "*OrderDependency: 10 AnySetup *StpColorPrecision\n"); + gzputs(fp, "*OrderDependency: 1 AnySetup *StpColorPrecision\n"); gzputs(fp, "*DefaultStpColorPrecision: Normal\n"); gzputs(fp, "*StpDefaultStpColorPrecision: Normal\n"); gzprintf(fp, "*StpColorPrecision Normal/%s:\t\"<<" @@ -1874,12 +1877,15 @@ write_ppd( all_langs); /* Macintosh color management */ + +#ifdef __APPLE__ gzputs(fp, "*cupsICCProfile Gray../Grayscale: \"/System/Library/ColorSync/Profiles/sRGB Profile.icc\"\n"); gzputs(fp, "*cupsICCProfile RGB../Color: \"/System/Library/ColorSync/Profiles/sRGB Profile.icc\"\n"); gzputs(fp, "*cupsICCProfile CMYK../Color: \"/System/Library/ColorSync/Profiles/Generic CMYK Profile.icc\"\n"); gzputs(fp, "*APSupportsCustomColorMatching: true\n"); gzputs(fp, "*APDefaultCustomColorMatchingProfile: sRGB\n"); gzputs(fp, "*APCustomColorMatchingProfile: sRGB\n"); +#endif gzputs(fp, "\n"); @@ -2157,6 +2163,7 @@ write_ppd( } stp_string_list_destroy(res_list); + stp_clear_string_parameter(v, "Resolution"); gzputs(fp, "*CloseUI: *Resolution\n\n"); } @@ -2563,5 +2570,5 @@ write_ppd( /* - * End of "$Id: genppd.c,v 1.186 2011/03/13 19:28:50 rlk Exp $". + * End of "$Id: genppd.c,v 1.192 2012/03/25 17:54:32 rlk Exp $". */ diff --git a/src/cups/rastertoprinter.c b/src/cups/rastertoprinter.c index 38b685e..065aa9b 100644 --- a/src/cups/rastertoprinter.c +++ b/src/cups/rastertoprinter.c @@ -1,5 +1,5 @@ /* - * "$Id: rastertoprinter.c,v 1.137 2011/04/09 00:19:59 rlk Exp $" + * "$Id: rastertoprinter.c,v 1.139 2011/12/18 16:20:31 rlk Exp $" * * Gutenprint based raster filter for the Common UNIX Printing System. * @@ -36,6 +36,10 @@ * Include necessary headers... */ +#if 0 +#define ENABLE_CUPS_LOAD_SAVE_OPTIONS +#endif + #ifdef HAVE_CONFIG_H #include #endif @@ -53,6 +57,7 @@ #include #endif #include "i18n.h" +#include /* Solaris with gcc has problems because gcc's limits.h doesn't #define */ /* this */ @@ -64,6 +69,14 @@ * Structure for page raster data... */ +#if (CUPS_VERSION_MAJOR > 1 || (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR > 1)) +#define CUPS_HEADER_T cups_page_header2_t +#define CUPS_READ_HEADER cupsRasterReadHeader2 +#else +#define CUPS_HEADER_T cups_page_header_t +#define CUPS_READ_HEADER cupsRasterReadHeader +#endif + typedef struct { cups_raster_t *ras; /* Raster stream to read from */ @@ -83,7 +96,7 @@ typedef struct int adjusted_height; int last_percent; int shrink_to_fit; - cups_page_header_t header; /* Page header from file */ + CUPS_HEADER_T header; /* Page header from file */ } cups_image_t; static void cups_writefunc(void *file, const char *buf, size_t bytes); @@ -114,7 +127,14 @@ static volatile stp_image_status_t Image_status = STP_IMAGE_STATUS_OK; static double total_bytes_printed = 0; static int print_messages_as_errors = 0; static int suppress_messages = 0; -static stp_string_list_t *po = NULL; +static int suppress_verbose_messages = 0; +static const stp_string_list_t *po = NULL; +#ifdef ENABLE_CUPS_LOAD_SAVE_OPTIONS +static const char *save_file_name = NULL; +static const char *load_file_name = NULL; +#endif /* ENABLE_CUPS_LOAD_SAVE_OPTIONS */ + +extern void stpi_vars_print_error(const stp_vars_t *v, const char *prefix); static void set_string_parameter(stp_vars_t *v, const char *name, const char *val) @@ -132,7 +152,16 @@ set_special_parameter(stp_vars_t *v, const char *name, int choice) stp_describe_parameter(v, name, &desc); if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST) { - if (choice < 0) +#if 0 + if (stp_check_string_parameter(v, name, STP_PARAMETER_ACTIVE)) + { + if (! suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: Not overriding special parameter %s (%s)\n", + name, stp_get_string_parameter(v, name)); + } + else +#endif + if (choice < 0) { stp_clear_string_parameter(v, name); if (! suppress_messages) @@ -168,9 +197,6 @@ set_special_parameter(stp_vars_t *v, const char *name, int choice) static void print_debug_block(const stp_vars_t *v, const cups_image_t *cups) { - stp_parameter_list_t params; - int nparams; - int i; fprintf(stderr, "DEBUG: Gutenprint: Page data:\n"); fprintf(stderr, "DEBUG: Gutenprint: MediaClass = \"%s\"\n", cups->header.MediaClass); fprintf(stderr, "DEBUG: Gutenprint: MediaColor = \"%s\"\n", cups->header.MediaColor); @@ -221,54 +247,9 @@ print_debug_block(const stp_vars_t *v, const cups_image_t *cups) fprintf(stderr, "DEBUG: Gutenprint: cupsRowCount = %d\n", cups->header.cupsRowCount); fprintf(stderr, "DEBUG: Gutenprint: cupsRowFeed = %d\n", cups->header.cupsRowFeed); fprintf(stderr, "DEBUG: Gutenprint: cupsRowStep = %d\n", cups->header.cupsRowStep); - fprintf(stderr, "DEBUG: Gutenprint: stp_get_driver(v) |%s|\n", stp_get_driver(v)); - fprintf(stderr, "DEBUG: Gutenprint: stp_get_left(v) %d\n", stp_get_left(v)); - fprintf(stderr, "DEBUG: Gutenprint: stp_get_top(v) %d\n", stp_get_top(v)); - fprintf(stderr, "DEBUG: Gutenprint: stp_get_page_width(v) %d\n", stp_get_page_width(v)); - fprintf(stderr, "DEBUG: Gutenprint: stp_get_page_height(v) %d\n", stp_get_page_height(v)); fprintf(stderr, "DEBUG: Gutenprint: shrink page to fit %d\n", cups->shrink_to_fit); - params = stp_get_parameter_list(v); - nparams = stp_parameter_list_count(params); - for (i = 0; i < nparams; i++) - { - const stp_parameter_t *p = stp_parameter_list_param(params, i); - switch (p->p_type) - { - case STP_PARAMETER_TYPE_STRING_LIST: - fprintf(stderr, "DEBUG: Gutenprint: stp_get_string %s(v) |%s| %d\n", - p->name, stp_get_string_parameter(v, p->name) ? - stp_get_string_parameter(v, p->name) : "NULL", - stp_get_string_parameter_active(v, p->name)); - break; - case STP_PARAMETER_TYPE_DOUBLE: - fprintf(stderr, "DEBUG: Gutenprint: stp_get_float %s(v) |%.3f| %d\n", - p->name, stp_get_float_parameter(v, p->name), - stp_get_float_parameter_active(v, p->name)); - break; - case STP_PARAMETER_TYPE_DIMENSION: - fprintf(stderr, "DEBUG: Gutenprint: stp_get_dimension %s(v) |%d| %d\n", - p->name, stp_get_dimension_parameter(v, p->name), - stp_get_dimension_parameter_active(v, p->name)); - break; - case STP_PARAMETER_TYPE_INT: - fprintf(stderr, "DEBUG: Gutenprint: stp_get_int %s(v) |%d| %d\n", - p->name, stp_get_int_parameter(v, p->name), - stp_get_int_parameter_active(v, p->name)); - break; - case STP_PARAMETER_TYPE_BOOLEAN: - fprintf(stderr, "DEBUG: Gutenprint: stp_get_boolean %s(v) |%d| %d\n", - p->name, stp_get_boolean_parameter(v, p->name), - stp_get_boolean_parameter_active(v, p->name)); - break; - /* - * We don't handle raw, curve, or filename arguments. - */ - default: - break; - } - } + stpi_vars_print_error(v, "DEBUG"); fprintf(stderr, "DEBUG: Gutenprint: End page data\n"); - stp_parameter_list_destroy(params); } static int @@ -290,7 +271,7 @@ validate_options(stp_vars_t *v, cups_image_t *cups) int nparams = stp_parameter_list_count(params); int i; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: Validating options\n"); + fprintf(stderr, "DEBUG: Gutenprint: Validating options\n"); for (i = 0; i < nparams; i++) { const stp_parameter_t *param = stp_parameter_list_param(params, i); @@ -304,14 +285,14 @@ validate_options(stp_vars_t *v, cups_image_t *cups) if (! suppress_messages) { const char *val = stp_get_string_parameter(v, desc.name); - fprintf(stderr, "DEBUG: Gutenprint: Clearing string %s (%s)\n", + fprintf(stderr, "DEBUG: Gutenprint: Clearing string %s (%s)\n", desc.name, val ? val : "(null)"); } stp_clear_string_parameter(v, desc.name); if (!desc.read_only && desc.is_mandatory && desc.is_active) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: Setting default string %s to %s\n", + fprintf(stderr, "DEBUG: Gutenprint: Setting default string %s to %s\n", desc.name, desc.deflt.str ? desc.deflt.str : "(null)"); stp_set_string_parameter(v, desc.name, desc.deflt.str); if (strcmp(desc.name, "PageSize") == 0) @@ -321,7 +302,7 @@ validate_options(stp_vars_t *v, cups_image_t *cups) if (ps->width > 0) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: Setting page width to %d\n", + fprintf(stderr, "DEBUG: Gutenprint: Setting page width to %d\n", ps->width); if (ps->width < stp_get_page_width(v)) stp_set_page_width(v, ps->width); @@ -329,7 +310,7 @@ validate_options(stp_vars_t *v, cups_image_t *cups) if (ps->height > 0) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: Setting page height to %d\n", + fprintf(stderr, "DEBUG: Gutenprint: Setting page height to %d\n", ps->height); if (ps->height < stp_get_page_height(v)) stp_set_page_height(v, ps->height); @@ -341,7 +322,7 @@ validate_options(stp_vars_t *v, cups_image_t *cups) stp_parameter_description_destroy(&desc); } if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: Done validating options\n"); + fprintf(stderr, "DEBUG: Gutenprint: Done validating options\n"); stp_parameter_list_destroy(params); } @@ -472,7 +453,9 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings, set_string_parameter(v, "Duplex", "DuplexNoTumble"); } - cups->shrink_to_fit = stp_get_int_parameter(v, "CUPSShrinkPage"); + cups->shrink_to_fit = + (stp_check_int_parameter(v, "CUPSShrinkPage", STP_PARAMETER_ACTIVE) ? + stp_get_int_parameter(v, "CUPSShrinkPage") : 0); set_string_parameter(v, "JobMode", "Job"); validate_options(v, cups); @@ -483,9 +466,9 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings, &(cups->bottom), &(cups->top)); if (! suppress_messages) { - fprintf(stderr, "DEBUG: Gutenprint: limits w %d l %d r %d h %d t %d b %d\n", + fprintf(stderr, "DEBUG: Gutenprint: limits w %d l %d r %d h %d t %d b %d\n", cups->width, cups->left, cups->right, cups->height, cups->top, cups->bottom); - fprintf(stderr, "DEBUG: Gutenprint: max limits l %d r %d t %d b %d\n", + fprintf(stderr, "DEBUG: Gutenprint: max limits l %d r %d t %d b %d\n", tmp_left, tmp_right, tmp_top, tmp_bottom); } @@ -509,7 +492,7 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings, else cups->left_trim = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: left margin %d\n", cups->left_trim); + fprintf(stderr, "DEBUG: Gutenprint: left margin %d\n", cups->left_trim); } else { @@ -625,9 +608,14 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings, if (cups->adjusted_height > cups->header.cupsHeight) cups->adjusted_height = cups->header.cupsHeight; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: CUPS settings w %d (%d) l %d r %d h %d (%d) t %d b %d\n", - cups->width, cups->adjusted_width, cups->left, cups->right, - cups->height, cups->adjusted_height, cups->top, cups->bottom); + { + fprintf(stderr, "DEBUG: Gutenprint: CUPS settings w %d l %d r %d h %d t %d b %d\n", + cups->width, cups->left, cups->right, + cups->height, cups->top, cups->bottom); + fprintf(stderr, "DEBUG: Gutenprint: adjusted w %d h %d\n", + cups->adjusted_width, cups->adjusted_height); + + } if (! suppress_messages) fprintf(stderr, "DEBUG: Gutenprint: End initialize page\n"); @@ -641,8 +629,9 @@ purge_excess_data(cups_image_t *cups) if (buffer) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: Purging %d rows\n", - cups->header.cupsHeight - cups->row); + fprintf(stderr, "DEBUG: Gutenprint: Purging %d row%s\n", + cups->header.cupsHeight - cups->row, + ((cups->header.cupsHeight - cups->row) == 1 ? "" : "s")); while (cups->row < cups->header.cupsHeight) { cupsRasterReadPixels(cups->ras, (unsigned char *)buffer, @@ -758,6 +747,8 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, if (val && ((strlen(val) > 0 && strcmp(val, "None") != 0) || (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST))) { + stp_curve_t *curve; + stp_raw_t *raw; switch (desc.p_type) { case STP_PARAMETER_TYPE_STRING_LIST: @@ -792,9 +783,30 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, stp_set_boolean_parameter (v, desc.name, strcasecmp(val, "true") == 0 ? 1 : 0); break; - case STP_PARAMETER_TYPE_CURVE: /* figure this out later... */ - case STP_PARAMETER_TYPE_FILE: /* Probably not, security hole */ + case STP_PARAMETER_TYPE_CURVE: + curve = stp_curve_create_from_string(val); + if (! suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: Set curve %s to %s\n", + desc.name, curve ? val : "(NULL)"); + if (curve) + { + stp_set_curve_parameter(v, desc.name, curve); + stp_curve_destroy(curve); + } + break; case STP_PARAMETER_TYPE_RAW: /* figure this out later, too */ + raw = stp_xmlstrtoraw(val); + if (! suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: Set raw %s to %s\n", + desc.name, raw ? val : "(NULL)"); + if (raw) + { + stp_set_raw_parameter(v, desc.name, raw->data, raw->bytes); + stp_free((void *)raw->data); + stp_free(raw); + } + break; + case STP_PARAMETER_TYPE_FILE: /* Probably not, security hole */ if (! suppress_messages) fprintf(stderr, "DEBUG: Gutenprint: Ignoring option %s %s type %d\n", desc.name, val, desc.p_type); @@ -806,13 +818,13 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, else if (val) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: Not setting %s to '%s'\n", + fprintf(stderr, "DEBUG: Gutenprint: Not setting %s to '%s'\n", desc.name, val); } else { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: Not setting %s to (null)\n", + fprintf(stderr, "DEBUG: Gutenprint: Not setting %s to (null)\n", desc.name); } } @@ -824,6 +836,233 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, stp_parameter_list_destroy(params); } +#ifdef ENABLE_CUPS_LOAD_SAVE_OPTIONS +static void +save_options(const char *save_name, const stp_vars_t *v) +{ + FILE *f_options; + int i; + stp_vars_t *c = stp_vars_create(); + stp_parameter_list_t params = stp_get_parameter_list(v); + stp_parameter_t desc; + stp_mxml_node_t *mxml = NULL; + int param_count; + + if (!params) + { + stp_vars_destroy(c); + return; + } + f_options = fopen(save_name, "w"); + if (!f_options) + { + stp_parameter_list_destroy(params); + stp_vars_destroy(c); + return; + } + param_count = stp_parameter_list_count(params); + stp_set_driver(c, stp_get_driver(v)); + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: Saving parameters to %s\n", save_name); + for (i = 0; i < param_count; i++) + { + const stp_parameter_t *lparam = + stp_parameter_list_param(params, i); + stp_describe_parameter(v, lparam->name, &desc); + if (desc.read_only || !strcmp(desc.name, "ChannelBitDepth") || + !stp_parameter_has_category_value(v, &desc, "Color", "Yes")) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: skipping non-color %s\n", + desc.name); + stp_parameter_description_destroy(&desc); + continue; + } + switch (desc.p_type) + { + case STP_PARAMETER_TYPE_STRING_LIST: + if (stp_check_string_parameter(v, desc.name, + STP_PARAMETER_DEFAULTED)) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING string %s %s\n", + desc.name, stp_get_string_parameter(v, desc.name)); + stp_set_string_parameter(c, desc.name, + stp_get_string_parameter(v, desc.name)); + } + else if (desc.is_mandatory) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING defaulted string %s %s\n", + desc.name, desc.deflt.str); + stp_set_string_parameter(c, desc.name, desc.deflt.str); + } + else if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: skipping string %s\n", desc.name); + break; + case STP_PARAMETER_TYPE_RAW: + if (stp_check_raw_parameter(v, desc.name, + STP_PARAMETER_DEFAULTED)) + { + const stp_raw_t *raw = stp_get_raw_parameter(v, desc.name); + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING raw %s\n", desc.name); + stp_set_raw_parameter(c, desc.name, raw->data, raw->bytes); + } + else if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: skipping raw %s\n", + desc.name); + break; + case STP_PARAMETER_TYPE_BOOLEAN: + if (stp_check_boolean_parameter(v, desc.name, STP_PARAMETER_DEFAULTED)) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING bool %s %d\n", + desc.name, stp_get_boolean_parameter(v, desc.name)); + stp_set_boolean_parameter(c, desc.name, + stp_get_boolean_parameter(v, desc.name)); + } + else if (desc.is_mandatory) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING defaulted bool %s %d\n", + desc.name, desc.deflt.boolean); + stp_set_boolean_parameter(c, desc.name, desc.deflt.boolean); + } + else if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: skipping bool %s\n", desc.name); + break; + case STP_PARAMETER_TYPE_INT: + if (stp_check_int_parameter(v, desc.name, STP_PARAMETER_DEFAULTED)) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING int %s %d\n", + desc.name, stp_get_int_parameter(v, desc.name)); + stp_set_int_parameter(c, desc.name, stp_get_int_parameter(v, desc.name)); + } + else if (desc.is_mandatory) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING defaulted int %s %d\n", + desc.name, desc.deflt.integer); + stp_set_int_parameter(c, desc.name, desc.deflt.integer); + } + else if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: skipping int %s\n", desc.name); + break; + case STP_PARAMETER_TYPE_DOUBLE: + if (stp_check_float_parameter(v, desc.name, STP_PARAMETER_DEFAULTED)) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING float %s %f\n", + desc.name, stp_get_float_parameter(v, desc.name)); + stp_set_float_parameter(c, desc.name, + stp_get_float_parameter(v, desc.name)); + } + else if (desc.is_mandatory) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING defaulted float %s %f\n", + desc.name, desc.deflt.dbl); + stp_set_float_parameter(c, desc.name, desc.deflt.dbl); + } + else if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: skipping float %s\n", desc.name); + break; + case STP_PARAMETER_TYPE_DIMENSION: + if (stp_check_dimension_parameter(v, desc.name, STP_PARAMETER_DEFAULTED)) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING dimension %s %d\n", + desc.name, stp_get_dimension_parameter(v, desc.name)); + stp_set_dimension_parameter(c, desc.name, + stp_get_dimension_parameter(v, desc.name)); + } + else if (desc.is_mandatory) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING defaulted dimension %s %d\n", + desc.name, desc.deflt.dimension); + stp_set_dimension_parameter(c, desc.name, desc.deflt.dimension); + } + else if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: skipping dimension %s\n", desc.name); + break; + case STP_PARAMETER_TYPE_CURVE: + if (stp_check_curve_parameter(v, desc.name, STP_PARAMETER_DEFAULTED)) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING curve %s\n", desc.name); + stp_set_curve_parameter(c, desc.name, + stp_get_curve_parameter(v, desc.name)); + } + else if (desc.is_mandatory) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: SAVING defaulted curve %s\n", desc.name); + stp_set_curve_parameter(c, desc.name, desc.deflt.curve); + } + else if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: skipping curve %s\n", + desc.name); + break; + default: + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: Ignoring unknown type parameter %s (%d)\n", + desc.name, desc.p_type); + break; + } + stp_parameter_description_destroy(&desc); + } + stp_parameter_list_destroy(params); + mxml = stp_xmltree_create_from_vars(c); + if (mxml) + { + fputs("\n\n", f_options); + stp_mxmlSaveFile(mxml, f_options, STP_MXML_NO_CALLBACK); + stp_mxmlDelete(mxml); + } + (void) fclose(f_options); + stp_vars_destroy(c); + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: Done saving parameters to %s\n", save_name); +} + +static stp_vars_t * +load_options(const char *load_name) +{ + FILE *f_options = fopen(load_name, "r"); + if (f_options) + { + stp_vars_t *settings = NULL; + stp_mxml_node_t *mxml; + mxml = stp_mxmlLoadFile(NULL, f_options, STP_MXML_NO_CALLBACK); + if (mxml) + { + stp_mxml_node_t *nxml = + stp_mxmlFindElement(mxml, mxml, "vars", NULL, NULL, + STP_MXML_DESCEND); + if (nxml) + { + settings = stp_vars_create_from_xmltree_ref(nxml->child, mxml); + if (! suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: loading options from %s\n", + load_file_name); + if (! suppress_messages) + stpi_vars_print_error(settings, "DEBUG"); + } + } + else + fprintf(stderr, "DEBUG: Unable to load options from %s\n", + load_file_name); + fclose(f_options); + return settings; + } + return NULL; +} + +#endif /* ENABLE_CUPS_LOAD_SAVE_OPTIONS */ + /* * 'main()' - Main entry and processing of driver. */ @@ -851,6 +1090,10 @@ main(int argc, /* I - Number of command-line arguments */ struct timeval t1, t2; struct timezone tz; char *page_size_name = NULL; + int aborted = 0; +#ifdef ENABLE_CUPS_LOAD_SAVE_OPTIONS + stp_vars_t *loaded_settings = NULL; +#endif /* ENABLE_CUPS_LOAD_SAVE_OPTIONS */ /* @@ -862,6 +1105,9 @@ main(int argc, /* I - Number of command-line arguments */ if (getenv("STP_SUPPRESS_MESSAGES")) suppress_messages = 1; + if (getenv("STP_SUPPRESS_VERBOSE_MESSAGES")) + suppress_verbose_messages = 1; + /* * Initialize libgutenprint */ @@ -893,8 +1139,10 @@ main(int argc, /* I - Number of command-line arguments */ if (! suppress_messages) { - fprintf(stderr, "DEBUG: Gutenprint %s Starting\n", version_id); - fprintf(stderr, "DEBUG: Gutenprint command line: %s '%s' '%s' '%s' '%s' %s%s%s%s\n", + fprintf(stderr, "DEBUG: Gutenprint: ============================================================\n"); + fprintf(stderr, "DEBUG: Gutenprint: VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n"); + fprintf(stderr, "DEBUG: Gutenprint: %s Starting\n", version_id); + fprintf(stderr, "DEBUG: Gutenprint: command line: %s '%s' '%s' '%s' '%s' %s%s%s%s\n", argv[0], argv[1], argv[2], argv[3], argv[4], "", argc >= 7 ? " '" : "", argc >= 7 ? argv[6] : "", @@ -911,7 +1159,7 @@ main(int argc, /* I - Number of command-line arguments */ return (1); } if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint using PPD file %s\n", ppdfile); + fprintf(stderr, "DEBUG: Gutenprint: using PPD file %s\n", ppdfile); if ((ppd = ppdOpenFile(ppdfile)) == NULL) { @@ -960,7 +1208,7 @@ main(int argc, /* I - Number of command-line arguments */ fprintf(stderr, "DEBUG: Gutenprint: If you have upgraded your version of Gutenprint\n"); fprintf(stderr, "DEBUG: Gutenprint: recently, you must reinstall all printer queues.\n"); fprintf(stderr, "DEBUG: Gutenprint: If the previous installed version of Gutenprint\n"); - fprintf(stderr, "DEBUG: Gutenprint: was 4.3.19 or higher, you can use the `cups-genppdupdate.%s'\n", release_version_id); + fprintf(stderr, "DEBUG: Gutenprint: was 5.0.0 or higher, you can use the `cups-genppdupdate.%s'\n", release_version_id); fprintf(stderr, "DEBUG: Gutenprint: program to do this; if the previous installed version\n"); fprintf(stderr, "DEBUG: Gutenprint: was older, you can use the Modify Printer command via\n"); fprintf(stderr, "DEBUG: Gutenprint: the CUPS web interface: http://localhost:631/printers.\n"); @@ -988,9 +1236,17 @@ main(int argc, /* I - Number of command-line arguments */ { int i; for (i = 0; i < num_options; i++) - if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: CUPS option %d %s = %s\n", - i, options[i].name, options[i].value); + { + if (! suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: CUPS option %d %s = %s\n", + i, options[i].name, options[i].value); +#ifdef ENABLE_CUPS_LOAD_SAVE_OPTIONS + if (!strcmp(options[i].name, "SaveFileName")) + save_file_name = options[i].value; + if (!strcmp(options[i].name, "LoadFileName")) + load_file_name = options[i].value; +#endif /* ENABLE_CUPS_LOAD_SAVE_OPTIONS */ + } } /* @@ -1031,9 +1287,13 @@ main(int argc, /* I - Number of command-line arguments */ fprintf(stderr, "DEBUG: Gutenprint: Using fd %d\n", fd); stp_set_printer_defaults(default_settings, printer); +#ifdef ENABLE_CUPS_LOAD_SAVE_OPTIONS + if (load_file_name) + loaded_settings = load_options(load_file_name); +#endif /* ENABLE_CUPS_LOAD_SAVE_OPTIONS */ stp_set_float_parameter(default_settings, "AppGamma", 1.0); set_all_options(default_settings, options, num_options, ppd); - stp_merge_printvars(default_settings, stp_printer_get_defaults(printer)); + ppdClose(ppd); cups.ras = cupsRasterOpen(fd, CUPS_RASTER_READ); @@ -1052,7 +1312,7 @@ main(int argc, /* I - Number of command-line arguments */ * the page. */ signal(SIGTERM, cancel_job); - while (cupsRasterReadHeader(cups.ras, &cups.header)) + while (CUPS_READ_HEADER(cups.ras, &cups.header)) { /* * We don't know how many pages we're going to print, and @@ -1070,10 +1330,25 @@ main(int argc, /* I - Number of command-line arguments */ */ if (! suppress_messages) { - fprintf(stderr, "DEBUG: Gutenprint: Printing page %d\n", cups.page + 1); + fprintf(stderr, "DEBUG: Gutenprint: ================ Printing page %d ================\n", cups.page + 1); fprintf(stderr, "PAGE: %d 1\n", cups.page + 1); } v = initialize_page(&cups, default_settings, page_size_name); +#ifdef ENABLE_CUPS_LOAD_SAVE_OPTIONS + if (loaded_settings) + stp_copy_vars_from(v, loaded_settings); + if (save_file_name) + { + save_options(save_file_name, v); + save_file_name = NULL; + } +#endif /* ENABLE_CUPS_LOAD_SAVE_OPTIONS */ + if (! suppress_messages) + { + fprintf(stderr, "DEBUG: Gutenprint: Interim page settings:\n"); + stpi_vars_print_error(v, "DEBUG"); + } + stp_merge_printvars(v, stp_printer_get_defaults(printer)); stp_set_int_parameter(v, "PageNumber", cups.page); cups.row = 0; if (! suppress_messages) @@ -1085,7 +1360,8 @@ main(int argc, /* I - Number of command-line arguments */ fprintf(stderr, "DEBUG: Gutenprint: Make sure that you are using ESP Ghostscript rather\n"); fprintf(stderr, "DEBUG: Gutenprint: than GNU or AFPL Ghostscript with CUPS.\n"); fprintf(stderr, "DEBUG: Gutenprint: If this is not the cause, set LogLevel to debug to identify the problem.\n"); - goto cups_abort; + aborted = 1; + break; } if (!initialized_job) @@ -1095,7 +1371,10 @@ main(int argc, /* I - Number of command-line arguments */ } if (!stp_print(v, &theImage)) - goto cups_abort; + { + aborted = 1; + break; + } print_messages_as_errors = 0; fflush(stdout); @@ -1106,13 +1385,14 @@ main(int argc, /* I - Number of command-line arguments */ if (cups.row < cups.header.cupsHeight) purge_excess_data(&cups); if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: Done printing page %d\n", cups.page + 1); + fprintf(stderr, "DEBUG: Gutenprint: ================ Done printing page %d ================\n", cups.page + 1); cups.page ++; } if (v) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint: Ending job\n"); + fprintf(stderr, "DEBUG: Gutenprint: %s job\n", + aborted ? "Aborted" : "Ending"); stp_end_job(v, &theImage); fflush(stdout); stp_vars_destroy(v); @@ -1123,43 +1403,22 @@ main(int argc, /* I - Number of command-line arguments */ clocks_per_sec = sysconf(_SC_CLK_TCK); fprintf(stderr, "DEBUG: Gutenprint: Printed total %.0f bytes\n", total_bytes_printed); - fprintf(stderr, "DEBUG: Gutenprint: Used %.3f seconds user, %.3f seconds system, %.3f seconds elapsed\n", + fprintf(stderr, "DEBUG: Gutenprint: Time %.3f user, %.3f sys, %.3f elapsed\n", (double) tms.tms_utime / clocks_per_sec, (double) tms.tms_stime / clocks_per_sec, (double) (t2.tv_sec - t1.tv_sec) + ((double) (t2.tv_usec - t1.tv_usec)) / 1000000.0); - stp_vars_destroy(default_settings); - if (page_size_name) - stp_free(page_size_name); - if (fd != 0) - close(fd); - return 0; - -cups_abort: - if (v) + if (!suppress_messages) { - stp_end_job(v, &theImage); - fflush(stdout); - stp_vars_destroy(v); + fprintf(stderr, "DEBUG: Gutenprint: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); + fprintf(stderr, "DEBUG: Gutenprint: ============================================================\n"); } - cupsRasterClose(cups.ras); - clk = times(&tms); - (void) gettimeofday(&t2, &tz); - clocks_per_sec = sysconf(_SC_CLK_TCK); - fprintf(stderr, "DEBUG: Gutenprint: Printed total %.0f bytes\n", - total_bytes_printed); - fprintf(stderr, "DEBUG: Gutenprint: Used %.3f seconds user, %.3f seconds system, %.3f seconds elapsed\n", - (double) tms.tms_utime / clocks_per_sec, - (double) tms.tms_stime / clocks_per_sec, - (double) (t2.tv_sec - t1.tv_sec) + - ((double) (t2.tv_usec - t1.tv_usec)) / 1000000.0); - stp_i18n_printf(po, _("ERROR: Invalid Gutenprint driver settings!\n")); stp_vars_destroy(default_settings); if (page_size_name) stp_free(page_size_name); if (fd != 0) close(fd); - return 1; + return aborted ? 1 : 0; } @@ -1282,14 +1541,14 @@ Image_get_row(stp_image_t *image, /* I - Image */ if (cups->row < cups->header.cupsHeight) { - if (! suppress_messages) + if (! suppress_messages && ! suppress_verbose_messages) fprintf(stderr, "DEBUG2: Gutenprint: Reading %d %d\n", bytes_per_line, cups->row); while (cups->row <= row && cups->row < cups->header.cupsHeight) { if (left_margin > 0) { - if (! suppress_messages) + if (! suppress_messages && ! suppress_verbose_messages) fprintf(stderr, "DEBUG2: Gutenprint: Tossing left %d (%d)\n", left_margin, cups->left_trim); throwaway_data(left_margin, cups); @@ -1298,7 +1557,7 @@ Image_get_row(stp_image_t *image, /* I - Image */ cups->row ++; if (margin + right_margin > 0) { - if (!suppress_messages) + if (! suppress_messages && ! suppress_verbose_messages) fprintf(stderr, "DEBUG2: Gutenprint: Tossing right %d (%d) + %d\n", right_margin, cups->right_trim, margin); throwaway_data(margin + right_margin, cups); @@ -1445,5 +1704,5 @@ Image_width(stp_image_t *image) /* I - Image */ /* - * End of "$Id: rastertoprinter.c,v 1.137 2011/04/09 00:19:59 rlk Exp $". + * End of "$Id: rastertoprinter.c,v 1.139 2011/12/18 16:20:31 rlk Exp $". */ diff --git a/src/cups/test-ppds b/src/cups/test-ppds index 4e60d2b..4044b02 100755 --- a/src/cups/test-ppds +++ b/src/cups/test-ppds @@ -1,6 +1,6 @@ #!/bin/sh -make ppd-clean ppd-global ppd-nls ppd-nonls +make EXTRA_GENPPD_OPTS=-b ppd-clean ppd-global ppd-nls ppd-nonls # Most non-Macintosh systems won't have the Macintosh-specific profiles # installed in Macintosh-specific locations. diff --git a/src/cups/test-rastertogutenprint.in b/src/cups/test-rastertogutenprint.in index 97ae27d..9e4f07d 100755 --- a/src/cups/test-rastertogutenprint.in +++ b/src/cups/test-rastertogutenprint.in @@ -27,6 +27,7 @@ make_ppds=1 md5dir='' outdir='' cupsargs='' +npages=3 usage() { echo "Usage: test-rastertogutenprint [-s] [-v|--valgrind]" @@ -46,6 +47,7 @@ set_args() { -O|--output) shift; outdir="$1" ;; -o|--option) shift; cupsargs="$cupsargs $1" ;; -m|--md5dir) shift; md5dir="$1" ;; + -p|--pages) shift; npages="$1" ;; --) shift; args="$@"; return ;; *) return ;; esac @@ -53,7 +55,7 @@ set_args() { done } -set_args `getopt vcgsVnO:m:o: "$@"` +set_args `getopt hvcgsVnO:m:o:p: "$@"` if [ -n "$outdir" -a ! -d "$outdir" ] ; then mkdir -p "$outdir" @@ -65,7 +67,7 @@ fi version="@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@"; cupsdir="@cups_conf_serverbin@/filter" if [ -x "$cupsdir/pstoraster" -o -x "$cupsdir/cgpdftoraster" ] ; then - pages='page-ranges=24-26 ' + pages="page-ranges=24-`expr 24 + $npages - 1` " else pages='' fi @@ -91,7 +93,7 @@ fi if [ -n "$pdftops" -a ! -x "$cupsdir/cgpdftoraster" ] ; then tfile=`mktemp` trap cleanup 1 2 3 6 14 15 30 - $pdftops -f 24 -l 26 "$sdir/../../doc/gutenprint-users-manual.pdf" $tfile + $pdftops -f 24 -l `expr 24 + $npages - 1` "$sdir/../../doc/gutenprint-users-manual.pdf" $tfile fi if [ -z "$verbose" ] ; then @@ -118,10 +120,11 @@ is_duplicate() { run_rastertogp() { case "$valgrind" in - 1) valgrind $valopts -q --num-callers=100 --leak-check=yes --error-limit=no ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; - 2) valgrind $valopts --num-callers=100 --leak-resolution=high --leak-check=yes --error-limit=no ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; - 3) valgrind $valopts --error-limit=no --num-callers=100 --show-reachable=yes --leak-resolution=high --leak-check=yes ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; + 1) valgrind $valopts -q --num-callers=50 --leak-check=yes --error-limit=no ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; + 2) valgrind $valopts --num-callers=50 --leak-resolution=high --leak-check=yes --error-limit=no ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; + 3) valgrind $valopts --error-limit=no --num-callers=50 --show-reachable=yes --leak-resolution=high --leak-check=yes ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; 4) valgrind $valopts ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; + 5) cat ;; *) ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; esac if [ $? -ne 0 ] ; then -- cgit v1.2.3