diff options
author | Roger Leigh <rleigh@debian.org> | 2008-10-26 16:17:32 +0000 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2008-10-26 16:17:32 +0000 |
commit | cda0fb3b8a7cb56045b24fd0af0ed36591b5d7eb (patch) | |
tree | 31ef197ec5c98ac9ac08714a2440a787c065d8c7 /src/cups | |
parent | 92b02ddce00dec2787514568fa9d644d4f0350e9 (diff) |
Imported Upstream version 5.0.1
Diffstat (limited to 'src/cups')
-rw-r--r-- | src/cups/Makefile.am | 38 | ||||
-rw-r--r-- | src/cups/Makefile.in | 205 | ||||
-rw-r--r-- | src/cups/canon.c | 155 | ||||
-rw-r--r-- | src/cups/cups-genppdconfig.in | 4 | ||||
-rw-r--r-- | src/cups/cups-genppdupdate.in | 253 | ||||
-rw-r--r-- | src/cups/epson.c | 159 | ||||
-rw-r--r-- | src/cups/genppd.c | 1207 | ||||
-rw-r--r-- | src/cups/rastertoprinter.c | 125 |
8 files changed, 1491 insertions, 655 deletions
diff --git a/src/cups/Makefile.am b/src/cups/Makefile.am index 011bd07..8b99888 100644 --- a/src/cups/Makefile.am +++ b/src/cups/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.87 2006/05/14 16:46:03 rlk Exp $ +## $Id: Makefile.am,v 1.87.8.2 2007/05/29 01:47:26 rlk Exp $ ## Copyright (C) 2000 Roger Leigh ## ## This program is free software; you can redistribute it and/or modify @@ -35,6 +35,7 @@ pkglibdir = $(cups_conf_serverbin) pkgsysconfdir = $(cups_conf_serverroot) cupsexec_backenddir = $(pkglibdir)/backend +cupsexec_driverdir = $(pkglibdir)/driver cupsexec_filterdir = $(pkglibdir)/filter if CUPS_PPDS_AT_TOP_LEVEL cups_modeldir = $(pkgdatadir)/model/ @@ -51,6 +52,20 @@ TESTS= test-ppds ## Programs +if BUILD_TRANSLATED_CUPS_PPDS +PPD_NLS = $(PPD_NLS_1) +LINGUAS = $(ALL_LINGUAS) +TRANSLATE_PPDS = -DCUPS_TRANSLATED_PPDS +endif + +if BUILD_SIMPLIFIED_CUPS_PPDS +BUILD_SIMPLE_PPDS=-DGENERATE_SIMPLIFIED_PPDS +endif + +if BUILD_CUPS_1_2 +cupsexec_driver_PROGRAMS = gutenprint.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ +endif + if BUILD_CUPS bin_PROGRAMS = cups-calibrate sbin_PROGRAMS = cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @@ -66,6 +81,9 @@ endif cups_calibrate_SOURCES = cups-calibrate.c cups_calibrate_LDADD = -lm +commandtocanon_SOURCES = commandtocanon.c +commandtocanon_LDADD = $(CUPS_LIBS) + commandtoepson_SOURCES = commandtoepson.c commandtoepson_LDADD = $(CUPS_LIBS) @@ -76,9 +94,15 @@ epson_SOURCES = epson.c epson_LDADD = $(CUPS_LIBS) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c +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) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c +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) +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) + rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = rastertoprinter.c rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) @@ -104,11 +128,6 @@ if BUILD_CUPS_PPDS INSTALL_DATA_LOCAL_DEPS = ppd-stamp endif -if BUILD_TRANSLATED_CUPS_PPDS -PPD_NLS = $(PPD_NLS_1) -LINGUAS = $(ALL_LINGUAS) -endif - if USE_NLS PPD_NLS_1 = ppd-nls endif @@ -117,7 +136,7 @@ endif ## Rules install-data-local: $(INSTALL_DATA_LOCAL_DEPS) - if test -n "$(INSTALL_DATA_LOCAL_DEPS)" ; then \ + if test -n "$(CUPS_PKG)" -a -n "$(INSTALL_DATA_LOCAL_DEPS)" ; then \ $(mkdir_p) $(DESTDIR)$(cups_modeldir); \ cd ppd ; \ for language in * ; do \ @@ -146,6 +165,7 @@ install-data-hook: -rmdir $(DESTDIR)$(cups_modeldir) -rmdir $(DESTDIR)$(pkgdatadir) -rmdir $(DESTDIR)$(cupsexec_backenddir) + -rmdir $(DESTDIR)$(cupsexec_driverdir) -rmdir $(DESTDIR)$(cupsexec_filterdir) -rmdir $(DESTDIR)$(bindir) -rmdir $(DESTDIR)$(pkglibdir) @@ -174,7 +194,7 @@ ppd-nonls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ for language in C ; do \ mkdir ppd/$$language ; \ echo "$$language:" ; \ - LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/$$language ; \ + LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/$$language ; \ done ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @@ -185,7 +205,7 @@ ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ for language in `$(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ -L -c \`pwd\`/catalog/share/locale` ; do \ mkdir ppd/$$language ; \ echo "$$language:" ; \ - LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/$$language -c `pwd`/catalog/share/locale ; \ + LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -l $$language -p ppd/$$language -c `pwd`/catalog/share/locale ; \ done $(RM) -r catalog diff --git a/src/cups/Makefile.in b/src/cups/Makefile.in index 848dee5..e1f7f29 100644 --- a/src/cups/Makefile.in +++ b/src/cups/Makefile.in @@ -44,6 +44,7 @@ host_triplet = @host@ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/cups-genppdconfig.in $(srcdir)/cups-genppdupdate.in \ $(top_srcdir)/scripts/global.mk COPYING +@BUILD_CUPS_1_2_TRUE@cupsexec_driver_PROGRAMS = gutenprint.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@$(EXEEXT) @BUILD_CUPS_TRUE@bin_PROGRAMS = cups-calibrate$(EXEEXT) @BUILD_CUPS_TRUE@sbin_PROGRAMS = cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@$(EXEEXT) @BUILD_CUPS_TRUE@cupsexec_backend_PROGRAMS = epson$(EXEEXT) \ @@ -55,11 +56,12 @@ subdir = src/cups ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/gimp.m4 $(top_srcdir)/m4/iconv.m4 \ - $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ - $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/progtest.m4 \ - $(top_srcdir)/m4/stp.m4 $(top_srcdir)/m4/stp_cups.m4 \ - $(top_srcdir)/m4/stp_gimp.m4 $(top_srcdir)/m4/stp_option.m4 \ - $(top_srcdir)/m4/stp_release.m4 $(top_srcdir)/configure.ac + $(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/progtest.m4 $(top_srcdir)/m4/stp.m4 \ + $(top_srcdir)/m4/stp_cups.m4 $(top_srcdir)/m4/stp_gimp.m4 \ + $(top_srcdir)/m4/stp_option.m4 $(top_srcdir)/m4/stp_release.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs @@ -67,30 +69,32 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = cups-genppdconfig cups-genppdupdate am__installdirs = "$(DESTDIR)$(bindir)" \ "$(DESTDIR)$(cupsexec_backenddir)" \ + "$(DESTDIR)$(cupsexec_driverdir)" \ "$(DESTDIR)$(cupsexec_filterdir)" "$(DESTDIR)$(sbindir)" \ "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(pkgdatadir)" \ "$(DESTDIR)$(pkgsysconfdir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) cupsexec_backendPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +cupsexec_driverPROGRAMS_INSTALL = $(INSTALL_PROGRAM) cupsexec_filterPROGRAMS_INSTALL = $(INSTALL_PROGRAM) sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) $(cupsexec_backend_PROGRAMS) \ - $(cupsexec_filter_PROGRAMS) $(sbin_PROGRAMS) + $(cupsexec_driver_PROGRAMS) $(cupsexec_filter_PROGRAMS) \ + $(sbin_PROGRAMS) am_canon_OBJECTS = canon.$(OBJEXT) canon_OBJECTS = $(am_canon_OBJECTS) am__DEPENDENCIES_1 = canon_DEPENDENCIES = $(am__DEPENDENCIES_1) -commandtocanon_SOURCES = commandtocanon.c -commandtocanon_OBJECTS = commandtocanon.$(OBJEXT) -commandtocanon_LDADD = $(LDADD) +am_commandtocanon_OBJECTS = commandtocanon.$(OBJEXT) +commandtocanon_OBJECTS = $(am_commandtocanon_OBJECTS) +commandtocanon_DEPENDENCIES = $(am__DEPENDENCIES_1) am_commandtoepson_OBJECTS = commandtoepson.$(OBJEXT) commandtoepson_OBJECTS = $(am_commandtoepson_OBJECTS) commandtoepson_DEPENDENCIES = $(am__DEPENDENCIES_1) am_cups_calibrate_OBJECTS = cups-calibrate.$(OBJEXT) cups_calibrate_OBJECTS = $(am_cups_calibrate_OBJECTS) cups_calibrate_DEPENDENCIES = -am_cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = \ - genppd.$(OBJEXT) +am_cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.$(OBJEXT) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = $(am_cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS) am__DEPENDENCIES_2 = $(top_builddir)/src/main/libgutenprint.la cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_DEPENDENCIES = \ @@ -99,6 +103,10 @@ cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_DEPENDENCIES = am_epson_OBJECTS = epson.$(OBJEXT) epson_OBJECTS = $(am_epson_OBJECTS) epson_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.$(OBJEXT) +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = $(am_gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS) +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_DEPENDENCIES = \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) am_rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = \ rastertoprinter.$(OBJEXT) rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = $(am_rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS) @@ -107,8 +115,8 @@ rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_DEPENDE sbinSCRIPT_INSTALL = $(INSTALL_SCRIPT) SCRIPTS = $(sbin_SCRIPTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -depcomp = -am__depfiles_maybe = +depcomp = $(SHELL) $(top_srcdir)/scripts/depcomp +am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ @@ -117,15 +125,17 @@ LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(canon_SOURCES) commandtocanon.c $(commandtoepson_SOURCES) \ - $(cups_calibrate_SOURCES) \ +SOURCES = $(canon_SOURCES) $(commandtocanon_SOURCES) \ + $(commandtoepson_SOURCES) $(cups_calibrate_SOURCES) \ $(cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES) \ $(epson_SOURCES) \ + $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES) \ $(rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES) -DIST_SOURCES = $(canon_SOURCES) commandtocanon.c \ +DIST_SOURCES = $(canon_SOURCES) $(commandtocanon_SOURCES) \ $(commandtoepson_SOURCES) $(cups_calibrate_SOURCES) \ $(cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES) \ $(epson_SOURCES) \ + $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES) \ $(rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ @@ -143,13 +153,18 @@ pkgdatadir = $(cups_conf_datadir) pkglibdir = $(cups_conf_serverbin) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_CUPS_1_2_FALSE = @BUILD_CUPS_1_2_FALSE@ +BUILD_CUPS_1_2_TRUE = @BUILD_CUPS_1_2_TRUE@ BUILD_CUPS_FALSE = @BUILD_CUPS_FALSE@ +BUILD_CUPS_PPDS = @BUILD_CUPS_PPDS@ BUILD_CUPS_PPDS_FALSE = @BUILD_CUPS_PPDS_FALSE@ BUILD_CUPS_PPDS_TRUE = @BUILD_CUPS_PPDS_TRUE@ BUILD_CUPS_TRUE = @BUILD_CUPS_TRUE@ @@ -175,6 +190,8 @@ BUILD_LIBGUTENPRINTUI_FALSE = @BUILD_LIBGUTENPRINTUI_FALSE@ BUILD_LIBGUTENPRINTUI_TRUE = @BUILD_LIBGUTENPRINTUI_TRUE@ BUILD_MODULES_FALSE = @BUILD_MODULES_FALSE@ BUILD_MODULES_TRUE = @BUILD_MODULES_TRUE@ +BUILD_SIMPLIFIED_CUPS_PPDS_FALSE = @BUILD_SIMPLIFIED_CUPS_PPDS_FALSE@ +BUILD_SIMPLIFIED_CUPS_PPDS_TRUE = @BUILD_SIMPLIFIED_CUPS_PPDS_TRUE@ BUILD_TESTPATTERN_FALSE = @BUILD_TESTPATTERN_FALSE@ BUILD_TESTPATTERN_TRUE = @BUILD_TESTPATTERN_TRUE@ BUILD_TEST_FALSE = @BUILD_TEST_FALSE@ @@ -182,6 +199,7 @@ BUILD_TEST_TRUE = @BUILD_TEST_TRUE@ BUILD_TRANSLATED_CUPS_PPDS_FALSE = @BUILD_TRANSLATED_CUPS_PPDS_FALSE@ BUILD_TRANSLATED_CUPS_PPDS_TRUE = @BUILD_TRANSLATED_CUPS_PPDS_TRUE@ CC = @CC@ +CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONVERT = @CONVERT@ CPP = @CPP@ @@ -194,12 +212,14 @@ CUPS_PPDS_AT_TOP_LEVEL_TRUE = @CUPS_PPDS_AT_TOP_LEVEL_TRUE@ CUPS_PPD_PS_LEVEL = @CUPS_PPD_PS_LEVEL@ CXX = @CXX@ CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DB2HTML = @DB2HTML@ DB2PDF = @DB2PDF@ DB2PS = @DB2PS@ DEFS = @DEFS@ +DEPDIR = @DEPDIR@ DIALOG = @DIALOG@ DOXYGEN = @DOXYGEN@ DVIPDF = @DVIPDF@ @@ -234,6 +254,7 @@ GLIB_LIBS = @GLIB_LIBS@ GLIB_MKENUMS = @GLIB_MKENUMS@ GMSGFMT = @GMSGFMT@ GNUCFLAGS = @GNUCFLAGS@ +GREP = @GREP@ GTK2_CFLAGS = @GTK2_CFLAGS@ GTK2_LIBS = @GTK2_LIBS@ GTK_CFLAGS = @GTK_CFLAGS@ @@ -329,14 +350,17 @@ VERSION = @VERSION@ WHICH_PPDS = @WHICH_PPDS@ XGETTEXT = @XGETTEXT@ YACC = @YACC@ -ac_ct_AR = @ac_ct_AR@ +YFLAGS = @YFLAGS@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_F77 = @ac_ct_F77@ -ac_ct_RANLIB = @ac_ct_RANLIB@ -ac_ct_STRIP = @ac_ct_STRIP@ -ac_pt_PKG_CONFIG = @ac_pt_PKG_CONFIG@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @cups_bindir@ @@ -353,6 +377,9 @@ cups_exec_prefix = @cups_exec_prefix@ cups_prefix = @cups_prefix@ cups_sbindir = @cups_sbindir@ datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ exec_prefix = @exec_prefix@ gimp2_plug_indir = @gimp2_plug_indir@ gimp_plug_indir = @gimp_plug_indir@ @@ -370,17 +397,21 @@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ +htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ +localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ +psdir = @psdir@ sbindir = @cups_sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ @@ -389,6 +420,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/include $(LOCAL_CPPFLAGS empty = pkgsysconfdir = $(cups_conf_serverroot) cupsexec_backenddir = $(pkglibdir)/backend +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/ @@ -396,10 +428,16 @@ cupsexec_filterdir = $(pkglibdir)/filter LOCAL_CPPFLAGS = $(GUTENPRINT_CFLAGS) $(CUPS_CFLAGS) STP_ENV = STP_MODULE_PATH=$(top_builddir)/src/main/.libs:$(top_builddir)/src/main STP_DATA_PATH=$(top_srcdir)/src/main TESTS = test-ppds +@BUILD_TRANSLATED_CUPS_PPDS_TRUE@PPD_NLS = $(PPD_NLS_1) +@BUILD_TRANSLATED_CUPS_PPDS_TRUE@LINGUAS = $(ALL_LINGUAS) +@BUILD_TRANSLATED_CUPS_PPDS_TRUE@TRANSLATE_PPDS = -DCUPS_TRANSLATED_PPDS +@BUILD_SIMPLIFIED_CUPS_PPDS_TRUE@BUILD_SIMPLE_PPDS = -DGENERATE_SIMPLIFIED_PPDS @BUILD_CUPS_TRUE@sbin_SCRIPTS = cups-genppdconfig.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ cups-genppdupdate.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @BUILD_GENPPD_STATIC_TRUE@STATIC_LDOPTS = -static -export-dynamic cups_calibrate_SOURCES = cups-calibrate.c cups_calibrate_LDADD = -lm +commandtocanon_SOURCES = commandtocanon.c +commandtocanon_LDADD = $(CUPS_LIBS) commandtoepson_SOURCES = commandtoepson.c commandtoepson_LDADD = $(CUPS_LIBS) canon_SOURCES = canon.c @@ -407,8 +445,13 @@ canon_LDADD = $(CUPS_LIBS) epson_SOURCES = epson.c epson_LDADD = $(CUPS_LIBS) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c +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) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c +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) +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = rastertoprinter.c rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) @@ -417,8 +460,6 @@ rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS pkgdata_DATA = $(CUPS_PKG) pkgsysconf_DATA = $(CUPS_CONF) @BUILD_CUPS_PPDS_TRUE@INSTALL_DATA_LOCAL_DEPS = ppd-stamp -@BUILD_TRANSLATED_CUPS_PPDS_TRUE@PPD_NLS = $(PPD_NLS_1) -@BUILD_TRANSLATED_CUPS_PPDS_TRUE@LINGUAS = $(ALL_LINGUAS) @USE_NLS_TRUE@PPD_NLS_1 = ppd-nls CLEANFILES = ppd-stamp DISTCLEANFILES = cups-genppdconfig.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ cups-genppdupdate.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @@ -444,9 +485,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir exit 1;; \ esac; \ done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps src/cups/Makefile'; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/cups/Makefile'; \ cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu --ignore-deps src/cups/Makefile + $(AUTOMAKE) --gnu src/cups/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ @@ -524,6 +565,34 @@ clean-cupsexec_backendPROGRAMS: echo " rm -f $$p $$f"; \ rm -f $$p $$f ; \ done +install-cupsexec_driverPROGRAMS: $(cupsexec_driver_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(cupsexec_driverdir)" || $(mkdir_p) "$(DESTDIR)$(cupsexec_driverdir)" + @list='$(cupsexec_driver_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(cupsexec_driverPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(cupsexec_driverdir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(cupsexec_driverPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(cupsexec_driverdir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-cupsexec_driverPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(cupsexec_driver_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(cupsexec_driverdir)/$$f'"; \ + rm -f "$(DESTDIR)$(cupsexec_driverdir)/$$f"; \ + done + +clean-cupsexec_driverPROGRAMS: + @list='$(cupsexec_driver_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done install-cupsexec_filterPROGRAMS: $(cupsexec_filter_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(cupsexec_filterdir)" || $(mkdir_p) "$(DESTDIR)$(cupsexec_filterdir)" @@ -598,6 +667,9 @@ cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@$(EXEEXT): $(cu epson$(EXEEXT): $(epson_OBJECTS) $(epson_DEPENDENCIES) @rm -f epson$(EXEEXT) $(LINK) $(epson_LDFLAGS) $(epson_OBJECTS) $(epson_LDADD) $(LIBS) +gutenprint.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@$(EXEEXT): $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS) $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_DEPENDENCIES) + @rm -f gutenprint.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@$(EXEEXT) + $(LINK) $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS) $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS) $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD) $(LIBS) rastertogutenprint.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@$(EXEEXT): $(rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS) $(rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_DEPENDENCIES) @rm -f rastertogutenprint.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@$(EXEEXT) $(LINK) $(rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS) $(rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS) $(rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD) $(LIBS) @@ -627,14 +699,63 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/canon.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commandtocanon.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commandtoepson.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cups-calibrate.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epson.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rastertoprinter.Po@am__quote@ + .c.o: - $(COMPILE) -c $< +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: - $(COMPILE) -c `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: - $(LTCOMPILE) -c -o $@ $< +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o: genppd.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS) $(CFLAGS) -MT cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o -MD -MP -MF "$(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo" -c -o cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o `test -f 'genppd.c' || echo '$(srcdir)/'`genppd.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo" "$(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Po"; else rm -f "$(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='genppd.c' object='cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS) $(CFLAGS) -c -o cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o `test -f 'genppd.c' || echo '$(srcdir)/'`genppd.c + +cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj: genppd.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS) $(CFLAGS) -MT cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj -MD -MP -MF "$(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo" -c -o cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj `if test -f 'genppd.c'; then $(CYGPATH_W) 'genppd.c'; else $(CYGPATH_W) '$(srcdir)/genppd.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo" "$(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Po"; else rm -f "$(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='genppd.c' object='cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS) $(CFLAGS) -c -o cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj `if test -f 'genppd.c'; then $(CYGPATH_W) 'genppd.c'; else $(CYGPATH_W) '$(srcdir)/genppd.c'; fi` + +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o: genppd.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS) $(CFLAGS) -MT gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o -MD -MP -MF "$(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo" -c -o gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o `test -f 'genppd.c' || echo '$(srcdir)/'`genppd.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo" "$(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Po"; else rm -f "$(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='genppd.c' object='gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS) $(CFLAGS) -c -o gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o `test -f 'genppd.c' || echo '$(srcdir)/'`genppd.c + +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj: genppd.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS) $(CFLAGS) -MT gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj -MD -MP -MF "$(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo" -c -o gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj `if test -f 'genppd.c'; then $(CYGPATH_W) 'genppd.c'; else $(CYGPATH_W) '$(srcdir)/genppd.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo" "$(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Po"; else rm -f "$(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='genppd.c' object='gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS) $(CFLAGS) -c -o gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj `if test -f 'genppd.c'; then $(CYGPATH_W) 'genppd.c'; else $(CYGPATH_W) '$(srcdir)/genppd.c'; fi` mostlyclean-libtool: -rm -f *.lo @@ -837,7 +958,7 @@ check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(DATA) all-local installdirs: - for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(cupsexec_backenddir)" "$(DESTDIR)$(cupsexec_filterdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(pkgsysconfdir)"; do \ + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(cupsexec_backenddir)" "$(DESTDIR)$(cupsexec_driverdir)" "$(DESTDIR)$(cupsexec_filterdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(pkgdatadir)" "$(DESTDIR)$(pkgsysconfdir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-am @@ -870,10 +991,12 @@ maintainer-clean-generic: clean: clean-am clean-am: clean-binPROGRAMS clean-cupsexec_backendPROGRAMS \ - clean-cupsexec_filterPROGRAMS clean-generic clean-libtool \ - clean-local clean-sbinPROGRAMS mostlyclean-am + clean-cupsexec_driverPROGRAMS clean-cupsexec_filterPROGRAMS \ + clean-generic clean-libtool clean-local clean-sbinPROGRAMS \ + mostlyclean-am distclean: distclean-am + -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-libtool distclean-tags @@ -894,6 +1017,7 @@ install-data-am: install-data-local install-pkgdataDATA \ $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-exec-am: install-binPROGRAMS install-cupsexec_backendPROGRAMS \ + install-cupsexec_driverPROGRAMS \ install-cupsexec_filterPROGRAMS install-sbinPROGRAMS \ install-sbinSCRIPTS @@ -904,6 +1028,7 @@ install-man: installcheck-am: maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -921,18 +1046,20 @@ ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-cupsexec_backendPROGRAMS \ + uninstall-cupsexec_driverPROGRAMS \ uninstall-cupsexec_filterPROGRAMS uninstall-info-am \ uninstall-local uninstall-pkgdataDATA uninstall-pkgsysconfDATA \ uninstall-sbinPROGRAMS uninstall-sbinSCRIPTS .PHONY: CTAGS GTAGS all all-am all-local check check-TESTS check-am \ clean clean-binPROGRAMS clean-cupsexec_backendPROGRAMS \ - clean-cupsexec_filterPROGRAMS clean-generic clean-libtool \ - clean-local clean-sbinPROGRAMS ctags dist-hook distclean \ - distclean-compile distclean-generic distclean-libtool \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-binPROGRAMS \ + clean-cupsexec_driverPROGRAMS clean-cupsexec_filterPROGRAMS \ + clean-generic clean-libtool clean-local clean-sbinPROGRAMS \ + ctags dist-hook distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ install-cupsexec_backendPROGRAMS \ + install-cupsexec_driverPROGRAMS \ install-cupsexec_filterPROGRAMS install-data install-data-am \ install-data-hook install-data-local install-exec \ install-exec-am install-info install-info-am install-man \ @@ -943,6 +1070,7 @@ uninstall-am: uninstall-binPROGRAMS uninstall-cupsexec_backendPROGRAMS \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-cupsexec_backendPROGRAMS \ + uninstall-cupsexec_driverPROGRAMS \ uninstall-cupsexec_filterPROGRAMS uninstall-info-am \ uninstall-local uninstall-pkgdataDATA uninstall-pkgsysconfDATA \ uninstall-sbinPROGRAMS uninstall-sbinSCRIPTS @@ -970,7 +1098,7 @@ cups-genppdupdate.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@: $(top_b cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/cups-genppdupdate install-data-local: $(INSTALL_DATA_LOCAL_DEPS) - if test -n "$(INSTALL_DATA_LOCAL_DEPS)" ; then \ + if test -n "$(CUPS_PKG)" -a -n "$(INSTALL_DATA_LOCAL_DEPS)" ; then \ $(mkdir_p) $(DESTDIR)$(cups_modeldir); \ cd ppd ; \ for language in * ; do \ @@ -999,6 +1127,7 @@ install-data-hook: -rmdir $(DESTDIR)$(cups_modeldir) -rmdir $(DESTDIR)$(pkgdatadir) -rmdir $(DESTDIR)$(cupsexec_backenddir) + -rmdir $(DESTDIR)$(cupsexec_driverdir) -rmdir $(DESTDIR)$(cupsexec_filterdir) -rmdir $(DESTDIR)$(bindir) -rmdir $(DESTDIR)$(pkglibdir) @@ -1027,7 +1156,7 @@ ppd-nonls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ for language in C ; do \ mkdir ppd/$$language ; \ echo "$$language:" ; \ - LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/$$language ; \ + LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/$$language ; \ done ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @@ -1038,7 +1167,7 @@ ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ for language in `$(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ -L -c \`pwd\`/catalog/share/locale` ; do \ mkdir ppd/$$language ; \ echo "$$language:" ; \ - LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/$$language -c `pwd`/catalog/share/locale ; \ + LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -l $$language -p ppd/$$language -c `pwd`/catalog/share/locale ; \ done $(RM) -r catalog diff --git a/src/cups/canon.c b/src/cups/canon.c index 963d446..25c235e 100644 --- a/src/cups/canon.c +++ b/src/cups/canon.c @@ -35,6 +35,14 @@ # include <netdb.h> #endif /* WIN32 || __EMX__ */ +#ifdef __linux +# include <sys/param.h> +# include <sys/types.h> +# include <sys/stat.h> +# include <dirent.h> +# include <unistd.h> +#endif /* __linux */ + #ifdef __sgi # include <invent.h> # ifndef INV_EPP_ECP_PLP @@ -439,6 +447,7 @@ list_devices(void) int fd; /* File descriptor */ char device[255]; /* Device filename */ FILE *probe; /* /proc/parport/n/autoprobe file */ + DIR *dirprobe; /* scan /sys/bus/usb/drivers/usblp */ char line[1024], /* Line from file */ *delim, /* Delimiter in file */ make[IPP_MAX_NAME], /* Make from file */ @@ -451,12 +460,17 @@ list_devices(void) for (i = 0; i < 4; i ++) { - sprintf(device, "/proc/parport/%d/autoprobe", i); - if ((probe = fopen(device, "r")) != NULL) + sprintf(device, "/proc/sys/dev/parport/parport%d/autoprobe", i); + probe = fopen(device, "r"); + if ( probe == NULL ) /* older kernel versions */ + { + sprintf(device, "/proc/parport/%d/autoprobe", i); + probe = fopen(device, "r"); + } + if ( probe != NULL ) { memset(make, 0, sizeof(make)); memset(model, 0, sizeof(model)); - strcpy(model, "CANON"); while (fgets(line, sizeof(line), probe) != NULL) { @@ -474,17 +488,17 @@ list_devices(void) */ if (strncmp(line, "MODEL:", 6) == 0 && - strncmp(line, "MODEL:CANON", 13) != 0) + strncmp(line, "MODEL:Unknown", 13) != 0) strncpy(model, line + 6, sizeof(model) - 1); else if (strncmp(line, "MANUFACTURER:", 13) == 0 && - strncmp(line, "MANUFACTURER:CANON", 20) != 0) + strncmp(line, "MANUFACTURER:Unknown", 20) != 0) strncpy(make, line + 13, sizeof(make) - 1); } fclose(probe); - if (strcmp(make, "CANON") == 0) - printf("direct canon:/dev/lp%d \"%s %s\" \"Parallel Port #%d\"\n", + if (strcasecmp(make, "CANON") == 0) + printf("direct canon:/dev/lp%d \"%s %s\" \"Gutenprint Parallel Port #%d\"\n", i, make, model, i + 1); } else @@ -493,7 +507,7 @@ list_devices(void) if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct canon:%s \"CANON\" \"Parallel Port #%d\"\n", device, i + 1); + printf("direct canon:%s \"CANON\" \"Gutenprint Parallel Port #%d\"\n", device, i + 1); } } } @@ -502,7 +516,110 @@ list_devices(void) * Probe for USB devices... */ - if ((probe = fopen("/proc/bus/usb/devices", "r")) != NULL) + if ((dirprobe = opendir("/sys/class/usb")) != NULL) /* SYSFS in kernel 2.6 */ + { + struct dirent *dirent; /* directory entries */ + struct stat statbuf; /* file stat */ + char entry[MAXPATHLEN]; /* pathname to usb entries */ + char link[MAXPATHLEN]; /* linkname of usb entries */ + char *cptr; /* multi used character pointer */ + FILE *file; /* read printer specific info from */ + + i = 0; + /* scan the directory entries */ + while((dirent = readdir(dirprobe)) != 0) + { + /* skip "." and ".." */ + if (dirent->d_name[0] != 'l' || dirent->d_name[1] != 'p') + continue; + + /* generate path to work with */ + snprintf(entry, MAXPATHLEN, "/sys/class/usb/%s/device", dirent->d_name); + + /* look, if we have a pointer */ + if(lstat(entry, &statbuf) < 0) + { + perror(entry); + continue; + } + + if (S_ISLNK(statbuf.st_mode)) + { + /* get the path to the link */ + if (readlink(entry, link, MAXPATHLEN) < 0) + continue; + + /* find right occurance of '/' */ + if ((cptr = strrchr(link, '/')) == NULL) + { + continue; + } + + /* + * and truncate path: cut away everything after the '/', + * because parallel directory contains the information we need + */ + *cptr = '\0'; + + memset(make, 0, sizeof(make)); + memset(model, 0, sizeof(model)); + /* read manufacturer */ + snprintf(entry, MAXPATHLEN, "/sys/class/usb/%s/%s/manufacturer", + dirent->d_name, link); + + if ((file = fopen(entry, "r")) == NULL) + { + /* skip this entry, there is no file "manufacturer" */ + continue; + } + /* read data in */ + fread(make, sizeof(make)-1, sizeof(char), file); + fclose(file); + + /* beautify "make" - strip newline away */ + if ((cptr = strrchr(make, '\n')) != NULL) + { + *cptr = '\0'; + } + + /* next entry, if manufacturer is not CANON */ + if (strcasecmp(make, "CANON") != 0) + continue; + + /* read product name */ + snprintf(entry, MAXPATHLEN, "/sys/class/usb/%s/%s/product", + dirent->d_name, link); + + if ((file = fopen(entry, "r")) == NULL) + { + /* skip this entry, there is no file "product" */ + continue; + } + /* read data in */ + fread(model, sizeof(model)-1, sizeof(char), file); + fclose(file); + + /* beautify "model" - strip away newline */ + if ((cptr = strrchr(model, '\n')) != NULL) + { + *cptr = '\0'; + } + sprintf(device, "/dev/usb/%s", dirent->d_name); + if (access(device, 0)) + { + sprintf(device, "/dev/usb/usb%s", dirent->d_name); + + if (access(device, 0)) + sprintf(device, "/dev/usb%s", dirent->d_name); + } + + printf("direct canon:%s \"%s %s\" \"Gutenprint USB Printer #%d\"\n", + device, make, model, ++i); + } + } + closedir(dirprobe); + } + else if ((probe = fopen("/proc/bus/usb/devices", "r")) != NULL) { i = 0; @@ -556,7 +673,7 @@ list_devices(void) sprintf(device, "/dev/usblp%d", i); } - printf("direct canon:%s \"%s %s\" \"USB Printer #%d\"\n", + printf("direct canon:%s \"%s %s\" \"Gutenprint USB Printer #%d\"\n", device, make, model, i + 1); } @@ -577,21 +694,21 @@ list_devices(void) if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct canon:%s \"CANON\" \"USB Printer #%d\"\n", device, i + 1); + printf("direct canon:%s \"CANON\" \"Gutenprint USB Printer #%d\"\n", device, i + 1); } sprintf(device, "/dev/usb/usblp%d", i); if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct canon:%s \"CANON\" \"USB Printer #%d\"\n", device, i + 1); + printf("direct canon:%s \"CANON\" \"Gutenprint USB Printer #%d\"\n", device, i + 1); } sprintf(device, "/dev/usblp%d", i); if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct canon:%s \"CANON\" \"USB Printer #%d\"\n", device, i + 1); + printf("direct canon:%s \"CANON\" \"Gutenprint USB Printer #%d\"\n", device, i + 1); } } } @@ -615,7 +732,7 @@ list_devices(void) * Standard parallel port... */ - puts("direct canon:/dev/plpbi \"CANON\" \"Onboard Parallel Port\""); + puts("direct canon:/dev/plpbi \"CANON\" \"Gutenprint Onboard Parallel Port\""); } } @@ -633,7 +750,7 @@ list_devices(void) { sprintf(device, "/dev/ecpp%d", i); if (access(device, 0) == 0) - printf("direct canon:%s \"CANON\" \"Sun IEEE-1284 Parallel Port #%d\"\n", + printf("direct canon:%s \"CANON\" \"Gutenprint Sun IEEE-1284 Parallel Port #%d\"\n", device, i + 1); } @@ -642,7 +759,7 @@ list_devices(void) sprintf(device, "/dev/lp%d", i); if (access(device, 0) == 0) - printf("direct canon:%s \"CANON\" \"PC Parallel Port #%d\"\n", + printf("direct canon:%s \"CANON\" \"Gutenprint PC Parallel Port #%d\"\n", device, i + 1); } #elif defined(FreeBSD) || defined(OpenBSD) || defined(NetBSD) @@ -661,14 +778,14 @@ list_devices(void) if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct canon:%s \"CANON\" \"Parallel Port #%d (interrupt-driven)\"\n", device, i + 1); + printf("direct canon:%s \"CANON\" \"Gutenprint Parallel Port #%d (interrupt-driven)\"\n", device, i + 1); } sprintf(device, "/dev/lpa%d", i); if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct canon:%s \"CANON\" \"Parallel Port #%d (polled)\"\n", device, i + 1); + printf("direct canon:%s \"CANON\" \"Gutenprint Parallel Port #%d (polled)\"\n", device, i + 1); } } @@ -682,7 +799,7 @@ list_devices(void) if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct canon:%s \"CANON\" \"USB Port #%d\"\n", device, i + 1); + printf("direct canon:%s \"CANON\" \"Gutenprint USB Port #%d\"\n", device, i + 1); } } #endif diff --git a/src/cups/cups-genppdconfig.in b/src/cups/cups-genppdconfig.in index 26ae5e7..aa80920 100644 --- a/src/cups/cups-genppdconfig.in +++ b/src/cups/cups-genppdconfig.in @@ -1,5 +1,5 @@ #! @PERL@ -w -# $Id: cups-genppdconfig.in,v 1.13 2006/05/30 19:25:36 rleigh Exp $ +# $Id: cups-genppdconfig.in,v 1.13.8.1 2007/05/29 01:47:26 rlk Exp $ # A user-friendly dialog-based wrapper for cups-genppd(8). # Copyright (C) 2002 Roger Leigh <rleigh@debian.org> # @@ -396,7 +396,7 @@ sub create_ppds { $count = 0; foreach $language (@chosen_languages) { # loop through languages open GENPPD, - "LANGUAGE=$language cups-genppd.$version -v -p $chosen_location/$language $printers 2>&1 |" + "LC_ALL=$language LANG=$language LANGUAGE=$language cups-genppd.$version -v -p $chosen_location/$language $printers 2>&1 |" or die "can't fork cups-genppd: $!"; $file = ""; while ( defined($file = <GENPPD>)) { # dump genppd stats into guage diff --git a/src/cups/cups-genppdupdate.in b/src/cups/cups-genppdupdate.in index 1a1a8f4..ee49a0b 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.25 2006/05/22 20:25:51 rleigh Exp $ +# $Id: cups-genppdupdate.in,v 1.25.8.2 2007/05/29 01:47:26 rlk Exp $ # Update CUPS PPDs for Gutenprint queues. # Copyright (C) 2002-2003 Roger Leigh (rleigh@debian.org) # @@ -25,6 +25,7 @@ use File::Copy qw(mv); sub parse_options (); sub update_ppd ($); # Original PPD filename +sub get_ppd_contents ($$$$$); # Return contents of desired PPD sub find_ppd ($$$$); # Gutenprint Filename, driver, language (e.g. en, sv), # region (e.g. GB, DE) sub get_default_types (*); # Source PPD FH @@ -49,6 +50,8 @@ my $quiet = 0; # No output my $no_action = 0; # Don't output files my $reset_defaults = 0; # Reset options to default settings my $version = "@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@"; +my $micro_version = "@GUTENPRINT_VERSION@"; +my $use_static_ppd = "@BUILD_CUPS_PPDS@"; my $ppd_dir = "@cups_conf_serverroot@/ppd"; # Location of in-use CUPS PPDs my $ppd_root_dir = "@cups_conf_datadir@/model"; @@ -56,6 +59,11 @@ my $ppd_base_dir = "$ppd_root_dir/gutenprint/$version"; # Available PPDs my $ppd_out_dir = ""; # By default output into source directory my $gzext = ".gz"; my $updated_ppd_count = 0; +my $exit_after_parse_args = 0; + +my $serverdir = "@cups_conf_serverbin@"; + +$Getopt::Std::STANDARD_HELP_VERSION = 1; my @ppd_files; # A list of in-use Gutenprint PPD files @@ -166,21 +174,53 @@ if (!$quiet || $verbose) { print STDOUT "Updated $updated_ppd_count PPD file${plural}. Restart cupsd for the changes to take effect.\n"; exit (0); } else { - print STDOUT "Failed to update any PPD files\n"; + if ($no_action) { + print STDOUT "Did not update any PPD files\n"; + } else { + print STDOUT "Failed to update any PPD files\n"; + } exit (0); } } +sub HELP_MESSAGE($;$$$) { + my ($fh) = @_; + print $fh "Usage: $0 [OPTION]... [PPD_FILE]...\n"; + print $fh "Update CUPS+Gutenprint PPD files.\n\n"; + print $fh " -d flags Enable debugging\n"; + print $fh " -h Display this help text\n"; + print $fh " -n No-action. Don't overwrite any PPD files.\n"; + print $fh " -q Quiet mode. No messages except errors.\n"; + print $fh " -s ppd_dir Use ppd_dir as the source PPD directory.\n"; + print $fh " -v Verbose messages.\n"; + print $fh " -N Reset options to defaults.\n"; + print $fh " -o out_dir Output PPD files to out_dir.\n"; + exit(0); +} +# Getopt::Std calls VERSION_MESSAGE followed by HELP_MESSAGE if --help +# is passed. If --version is passed, it calls only VERSION_MESSAGE. +# So we have to make sure to exit, but we want to allow --help to +# print out the help message. +sub VERSION_MESSAGE($;$$$) { + my ($fh) = @_; + print "cups-genppdupdate from Gutenprint $micro_version\n"; + $exit_after_parse_args = 1; +} -sub parse_options () { - getopts("dhnqs:vNo:"); +sub help() { + HELP_MESSAGE(\*STDOUT); +} +sub parse_options () { + if (!getopts('d:hnqs:vNo:')) { + help(); + } if ($opt_n) { $no_action = 1; } if ($opt_d) { - $debug = 1; + $debug = $opt_d; } if ($opt_s) { if (-d $opt_s) { @@ -210,20 +250,81 @@ sub parse_options () { } } if ($opt_h) { - print "Usage: $0 [OPTION]... [PPD_FILE]...\n"; - print "Update CUPS+Gutenprint PPD files.\n\n"; - print " -d Enable debugging\n"; - print " -h Display this help text\n"; - print " -n No-action. Don't overwrite any PPD files.\n"; - print " -q Quiet mode. No messages except errors.\n"; - print " -s ppd_dir Use ppd_dir as the source PPD directory.\n"; - print " -v Verbose messages.\n"; - print " -N Reset options to defaults.\n"; - print " -o out_dir Output PPD files to out_dir.\n"; - exit (0); + help(); + } + if ($exit_after_parse_args) { + exit(0); } } +sub get_ppd_contents($$$$$) { + my ($ppd_source_filename, $filename, $driver, $locale, $region) = @_; + + my $source_data; + my ($new_ppd_filename); + + if ($use_static_ppd eq "no") { + my ($driver_bin) = "$serverdir/driver/gutenprint.$version"; + my ($driver_version) = `$driver_bin VERSION`; + chomp $driver_version; + if ($driver_version eq "@VERSION@") { + my ($simplified); + if ($filename =~ m,.*/([^/]*)(.sim)(.ppd)?(.gz)?$,) { + $simplified = "simple"; + } else { + $simplified = "expert"; + } + my ($url); + foreach $url ("gutenprint.$version://$driver/$simplified/${locale}_${region}", + "gutenprint.$version://$driver/$simplified/${locale}", + "gutenprint.$version://$driver/$simplified") { + $new_ppd_filename = $url; + if (open PPD, "$driver_bin cat $url 2>/dev/null |") { + while (<PPD>) { + $source_data .= $_; + } + close PPD; + if ($source_data) { + return ( $new_ppd_filename, $source_data ); + } + } + } + } + # Otherwise fall through and try to find a static PPD + } + + # Search for a PPD matching our criteria... + + $new_ppd_filename = find_ppd($filename, $driver, $locale, $region); + if (!defined($new_ppd_filename)) { + # There wasn't a valid source PPD file, so give up. + print STDERR "$ppd_source_filename: no valid candidate for replacement. Skipping\n"; + print STDERR "$ppd_source_filename: please upgrade this PPD manually\n"; + return ("", 0); + } + if ($debug & 1) { + print "Candidate PPD: $new_ppd_filename\n"; + } + + my $suffix = "\\" . $gzext; # Add '\', so m// matches the '.'. + if ($new_ppd_filename =~ m/.gz$/) { # Decompress input buffer + open GZIN, "gunzip -c $new_ppd_filename |" + or die "$_: can't open for decompression: $!"; + while (<GZIN>) { + $source_data .= $_; + } + close GZIN; + } else { + open SOURCE, $new_ppd_filename + or die "$new_ppd_filename: can't open source file: $!"; + binmode SOURCE; + my $source_size = (stat(SOURCE))[7]; + read (SOURCE, $source_data, $source_size) + or die "$new_ppd_filename: error reading source: $!"; + close SOURCE or die "$new_ppd_filename: can't close file: $!"; + } + return ( $new_ppd_filename, $source_data ); +} # Update the named PPD file. sub update_ppd ($) { @@ -237,7 +338,7 @@ sub update_ppd ($) { open ORIG, $_ or die "$_: can't open PPD file: $!"; seek (ORIG, 0, 0) or die "can't seek to start of PPD file"; my @orig_metadata = stat(ORIG); - if ($debug) { + if ($debug & 1) { print "Source Filename: $ppd_source_filename\n"; } my ($filename) = ""; @@ -274,7 +375,7 @@ sub update_ppd ($) { print STDERR "$ppd_source_filename: this PPD file cannot be upgraded automatically (only files based on Gutenprint 4.3.21 and newer can be)\n"; return 0; } - if ($debug) { + if ($debug & 2) { print "Gutenprint Filename: $filename\n"; print "Locale: $locale\n"; print "Language: $lingo\n"; @@ -295,46 +396,19 @@ sub update_ppd ($) { if (! defined($region)) { $region = ""; } - if ($debug) { - print "Locale: $locale\n"; + if ($debug & 2) { + print "Base Locale: $locale\n"; print "Region: $region\n"; } - # Search for a PPD matching our criteria... - - my $source = find_ppd($filename, $driver, $locale, $region); - if (!defined($source)) { - # There wasn't a valid source PPD file, so give up. - print STDERR "$ppd_source_filename: no valid candidate for replacement. Skipping\n"; - print STDERR "$ppd_source_filename: please upgrade this PPD manually\n"; - return 0; - } - if ($debug) { - print "Candidate PPD: $source\n"; - } - - # Read in the new PPD, decompressing it if needed... - my $source_data; + my ($new_ppd_filename, $source_data) = + get_ppd_contents($ppd_source_filename, $filename, + $driver, $locale, $region); - my $suffix = "\\" . $gzext; # Add '\', so m// matches the '.'. - if ($source =~ m/.gz$/) { # Decompress input buffer - open GZIN, "gunzip -c $source |" - or die "$_: can't open for decompression: $!"; - while (<GZIN>) { - $source_data .= $_; - } - close GZIN; - } - else { - open SOURCE, $source - or die "$source: can't open source file: $!"; - binmode SOURCE; - my $source_size = (stat(SOURCE))[7]; - read (SOURCE, $source_data, $source_size) - or die "$source: error reading source: $!"; - close SOURCE or die "$source: can't close file: $!"; + if (! $source_data) { + die "Unable to retrieve PPD file!\n"; } # Save new PPD in a temporary file, for processing... @@ -360,30 +434,55 @@ sub update_ppd ($) { close $tmpfile or die "can't close temporary file $tmpfile: $!"; - if ($debug) { - print "Original Default Types:\n"; - foreach (sort keys %orig_default_types) { - print " $_: $orig_default_types{$_}\n"; - } - print "New Default Types:\n"; - foreach (sort keys %new_default_types) { - print " $_: $new_default_types{$_}\n"; - } - print "Defaults:\n"; - foreach (sort keys %defaults) { - print " $_: $defaults{$_}\n"; - } - print "Options:\n"; + if ($debug & 4) { + print "Options (Old->New Default Type):\n"; foreach (sort keys %options) { - print " $_: "; + my ($old_type) = $orig_default_types{$_}; + my ($new_type) = $new_default_types{$_}; + if (! defined($old_type)) { + $old_type = '(New)'; + } + if ($old_type ne $new_type) { + print " $_ ($old_type -> $new_type) : "; + } else { + print " $_ ($new_type) : "; + } + my ($def) = $defaults{"Default$_"}; foreach my $opt (@{$options{$_}}) { + if (defined $def && $def eq $opt) { + print "*"; + } print "$opt "; } print "\n"; } - + print "Non-UI Defaults:\n"; + foreach (sort keys %defaults) { + my ($xkey) = $_; + $xkey =~ s/^Default//; + if (! defined ($options{$xkey})) { + print " $_: $defaults{$_}\n"; + } + } + print "Default Types of dropped options:\n"; + foreach (sort keys %orig_default_types) { + if (! defined($options{$_})) { + print " $_: $orig_default_types{$_}\n"; + } + } } + if ($no_action) { + if (!$quiet || $verbose) { + if ($ppd_dest_filename eq $ppd_source_filename) { + print STDOUT "Would update $ppd_source_filename using $new_ppd_filename\n"; + } else { + print STDOUT "Would update $ppd_source_filename to $ppd_dest_filename using $new_ppd_filename\n"; + } + } + return 0; + } + if (! $reset_defaults) { # Update source buffer with old defaults... @@ -412,12 +511,10 @@ default_loop: next default_loop; } } - printf STDERR - "$ppd_source_filename: Invalid option: *$default_option: $defaults{$default_option}. Skipped.\n"; + warn "Warning: $ppd_source_filename: Invalid option: *$default_option: $defaults{$default_option}. Using default setting.\n"; next; } - print STDERR - "$ppd_source_filename: PPD OpenUI method $new_default_types{$_} not understood. Skipped\n"; + warn "Warning: $ppd_source_filename: PPD OpenUI method $new_default_types{$_} not understood.\n"; } } @@ -445,9 +542,9 @@ default_loop: if (!$quiet || $verbose) { if ($ppd_dest_filename eq $ppd_source_filename) { - print STDOUT "Updated $ppd_source_filename using $source\n"; + print STDOUT "Updated $ppd_source_filename using $new_ppd_filename\n"; } else { - print STDOUT "Updated $ppd_source_filename to $ppd_dest_filename using $source\n"; + print STDOUT "Updated $ppd_source_filename to $ppd_dest_filename using $new_ppd_filename\n"; } } return 1; @@ -492,7 +589,7 @@ sub find_ppd ($$$$) { $ppd_root_dir) { if (! $basedir || ! $base) { next; } my ($fn) = "$basedir/$lingo$base$suffix"; - if ($debug) { + if ($debug & 8) { print "Trying $fn for $gutenprintfilename, $lang, $region\n"; } # Check that it is a regular file, owned by root.root, not writable @@ -508,17 +605,17 @@ sub find_ppd ($$$$) { $file_version = `cat $fn | grep '$key'`; } if ($file_version ne "") { - if ($debug) { + if ($debug & 8) { print " Format valid: time $sb[9] best $current_best_time prev $current_best_file cur $fn!\n"; } if ($sb[9] > $current_best_time) { $current_best_time = $sb[9]; $current_best_file = $fn; - if ($debug) { + if ($debug & 8) { print STDERR "***current_best_file is $fn\n"; } } - } elsif ($debug) { + } elsif ($debug & 8) { print " Format invalid\n"; } } diff --git a/src/cups/epson.c b/src/cups/epson.c index 38fec8c..e1e14c4 100644 --- a/src/cups/epson.c +++ b/src/cups/epson.c @@ -1,5 +1,5 @@ /* - * "$Id: epson.c,v 1.7 2006/03/18 23:54:49 rlk Exp $" + * "$Id: epson.c,v 1.7.8.1 2007/05/12 19:32:08 faust3 Exp $" * * EPSON backend for the Common UNIX Printing System. * @@ -66,6 +66,14 @@ # include <netdb.h> #endif /* WIN32 || __EMX__ */ +#ifdef __linux +# include <sys/param.h> +# include <sys/types.h> +# include <sys/stat.h> +# include <dirent.h> +# include <unistd.h> +#endif /* __linux */ + #ifdef __sgi # include <invent.h> # ifndef INV_EPP_ECP_PLP @@ -515,6 +523,7 @@ list_devices(void) int fd; /* File descriptor */ char device[255]; /* Device filename */ FILE *probe; /* /proc/parport/n/autoprobe file */ + DIR *dirprobe; /* scan /sys/bus/usb/drivers/usblp */ char line[1024], /* Line from file */ *delim, /* Delimiter in file */ make[IPP_MAX_NAME], /* Make from file */ @@ -527,12 +536,17 @@ list_devices(void) for (i = 0; i < 4; i ++) { - sprintf(device, "/proc/parport/%d/autoprobe", i); - if ((probe = fopen(device, "r")) != NULL) + sprintf(device, "/proc/sys/dev/parport/parport%d/autoprobe", i); + probe = fopen(device, "r"); + if ( probe == NULL ) /* older kernel versions */ + { + sprintf(device, "/proc/parport/%d/autoprobe", i); + probe = fopen(device, "r"); + } + if ( probe != NULL ) { memset(make, 0, sizeof(make)); memset(model, 0, sizeof(model)); - strcpy(model, "EPSON"); while (fgets(line, sizeof(line), probe) != NULL) { @@ -550,17 +564,17 @@ list_devices(void) */ if (strncmp(line, "MODEL:", 6) == 0 && - strncmp(line, "MODEL:EPSON", 13) != 0) + strncmp(line, "MODEL:Unknown", 13) != 0) strncpy(model, line + 6, sizeof(model) - 1); else if (strncmp(line, "MANUFACTURER:", 13) == 0 && - strncmp(line, "MANUFACTURER:EPSON", 20) != 0) + strncmp(line, "MANUFACTURER:Unknown", 20) != 0) strncpy(make, line + 13, sizeof(make) - 1); } fclose(probe); - if (strcmp(make, "EPSON") == 0) - printf("direct epson:/dev/lp%d \"%s %s\" \"Parallel Port #%d\"\n", + if (strcasecmp(make, "EPSON") == 0) + printf("direct epson:/dev/lp%d \"%s %s\" \"Gutenprint Parallel Port #%d\"\n", i, make, model, i + 1); } else @@ -569,7 +583,7 @@ list_devices(void) if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct epson:%s \"EPSON\" \"Parallel Port #%d\"\n", device, i + 1); + printf("direct epson:%s \"EPSON\" \"Gutenprint Parallel Port #%d\"\n", device, i + 1); } } } @@ -578,7 +592,110 @@ list_devices(void) * Probe for USB devices... */ - if ((probe = fopen("/proc/bus/usb/devices", "r")) != NULL) + if ((dirprobe = opendir("/sys/class/usb")) != NULL) /* SYSFS in kernel 2.6 */ + { + struct dirent *dirent; /* directory entries */ + struct stat statbuf; /* file stat */ + char entry[MAXPATHLEN]; /* pathname to usb entries */ + char link[MAXPATHLEN]; /* linkname of usb entries */ + char *cptr; /* multi used character pointer */ + FILE *file; /* read printer specific info from */ + + i = 0; + /* scan the directory entries */ + while((dirent = readdir(dirprobe)) != 0) + { + /* skip "." and ".." */ + if (dirent->d_name[0] != 'l' || dirent->d_name[1] != 'p') + continue; + + /* generate path to work with */ + snprintf(entry, MAXPATHLEN, "/sys/class/usb/%s/device", dirent->d_name); + + /* look, if we have a pointer */ + if(lstat(entry, &statbuf) < 0) + { + perror(entry); + continue; + } + + if (S_ISLNK(statbuf.st_mode)) + { + /* get the path to the link */ + if (readlink(entry, link, MAXPATHLEN) < 0) + continue; + + /* find right occurance of '/' */ + if ((cptr = strrchr(link, '/')) == NULL) + { + continue; + } + + /* + * and truncate path: cut away everything after the '/', + * because parallel directory contains the information we need + */ + *cptr = '\0'; + + memset(make, 0, sizeof(make)); + memset(model, 0, sizeof(model)); + /* read manufacturer */ + snprintf(entry, MAXPATHLEN, "/sys/class/usb/%s/%s/manufacturer", + dirent->d_name, link); + + if ((file = fopen(entry, "r")) == NULL) + { + /* skip this entry, there is no file "manufacturer" */ + continue; + } + /* read data in */ + fread(make, sizeof(make)-1, sizeof(char), file); + fclose(file); + + /* beautify "make" - strip newline away */ + if ((cptr = strrchr(make, '\n')) != NULL) + { + *cptr = '\0'; + } + + /* next entry, if manufacturer is not EPSON */ + if (strcasecmp(make, "EPSON") != 0) + continue; + + /* read product name */ + snprintf(entry, MAXPATHLEN, "/sys/class/usb/%s/%s/product", + dirent->d_name, link); + + if ((file = fopen(entry, "r")) == NULL) + { + /* skip this entry, there is no file "product" */ + continue; + } + /* read data in */ + fread(model, sizeof(model)-1, sizeof(char), file); + fclose(file); + + /* beautify "model" - strip away newline */ + if ((cptr = strrchr(model, '\n')) != NULL) + { + *cptr = '\0'; + } + sprintf(device, "/dev/usb/%s", dirent->d_name); + if (access(device, 0)) + { + sprintf(device, "/dev/usb/usb%s", dirent->d_name); + + if (access(device, 0)) + sprintf(device, "/dev/usb%s", dirent->d_name); + } + + printf("direct epson:%s \"%s %s\" \"Gutenprint USB Printer #%d\"\n", + device, make, model, ++i); + } + } + closedir(dirprobe); + } + else if ((probe = fopen("/proc/bus/usb/devices", "r")) != NULL) { i = 0; @@ -632,7 +749,7 @@ list_devices(void) sprintf(device, "/dev/usblp%d", i); } - printf("direct epson:%s \"%s %s\" \"USB Printer #%d\"\n", + printf("direct epson:%s \"%s %s\" \"Gutenprint USB Printer #%d\"\n", device, make, model, i + 1); } @@ -653,21 +770,21 @@ list_devices(void) if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct epson:%s \"EPSON\" \"USB Printer #%d\"\n", device, i + 1); + printf("direct epson:%s \"EPSON\" \"Gutenprint USB Printer #%d\"\n", device, i + 1); } sprintf(device, "/dev/usb/usblp%d", i); if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct epson:%s \"EPSON\" \"USB Printer #%d\"\n", device, i + 1); + printf("direct epson:%s \"EPSON\" \"Gutenprint USB Printer #%d\"\n", device, i + 1); } sprintf(device, "/dev/usblp%d", i); if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct epson:%s \"EPSON\" \"USB Printer #%d\"\n", device, i + 1); + printf("direct epson:%s \"EPSON\" \"Gutenprint USB Printer #%d\"\n", device, i + 1); } } } @@ -691,7 +808,7 @@ list_devices(void) * Standard parallel port... */ - puts("direct epson:/dev/plpbi \"EPSON\" \"Onboard Parallel Port\""); + puts("direct epson:/dev/plpbi \"EPSON\" \"Gutenprint Onboard Parallel Port\""); } } @@ -709,7 +826,7 @@ list_devices(void) { sprintf(device, "/dev/ecpp%d", i); if (access(device, 0) == 0) - printf("direct epson:%s \"EPSON\" \"Sun IEEE-1284 Parallel Port #%d\"\n", + printf("direct epson:%s \"EPSON\" \"Gutenprint Sun IEEE-1284 Parallel Port #%d\"\n", device, i + 1); } @@ -718,7 +835,7 @@ list_devices(void) sprintf(device, "/dev/lp%d", i); if (access(device, 0) == 0) - printf("direct epson:%s \"EPSON\" \"PC Parallel Port #%d\"\n", + printf("direct epson:%s \"EPSON\" \"Gutenprint PC Parallel Port #%d\"\n", device, i + 1); } #elif defined(FreeBSD) || defined(OpenBSD) || defined(NetBSD) @@ -737,14 +854,14 @@ list_devices(void) if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct epson:%s \"EPSON\" \"Parallel Port #%d (interrupt-driven)\"\n", device, i + 1); + printf("direct epson:%s \"EPSON\" \"Gutenprint Parallel Port #%d (interrupt-driven)\"\n", device, i + 1); } sprintf(device, "/dev/lpa%d", i); if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct epson:%s \"EPSON\" \"Parallel Port #%d (polled)\"\n", device, i + 1); + printf("direct epson:%s \"EPSON\" \"Gutenprint Parallel Port #%d (polled)\"\n", device, i + 1); } } @@ -758,7 +875,7 @@ list_devices(void) if ((fd = open(device, O_RDWR)) >= 0) { close(fd); - printf("direct epson:%s \"EPSON\" \"USB Port #%d\"\n", device, i + 1); + printf("direct epson:%s \"EPSON\" \"Gutenprint USB Port #%d\"\n", device, i + 1); } } #endif @@ -766,5 +883,5 @@ list_devices(void) /* - * End of "$Id: epson.c,v 1.7 2006/03/18 23:54:49 rlk Exp $". + * End of "$Id: epson.c,v 1.7.8.1 2007/05/12 19:32:08 faust3 Exp $". */ diff --git a/src/cups/genppd.c b/src/cups/genppd.c index 6f77c62..4b49ba6 100644 --- a/src/cups/genppd.c +++ b/src/cups/genppd.c @@ -1,9 +1,9 @@ /* - * "$Id: genppd.c,v 1.118 2006/05/28 16:59:03 rlk Exp $" + * "$Id: genppd.c,v 1.119.2.3 2007/05/29 01:47:26 rlk Exp $" * * PPD file generation program for the CUPS drivers. * - * Copyright 1993-2005 by Easy Software Products and Robert Krawitz. + * Copyright 1993-2007 by Easy Software Products and Robert Krawitz. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License, @@ -21,7 +21,7 @@ * Attn: CUPS Licensing Information * Easy Software Products * 44141 Airport View Drive, Suite 204 - * Hollywood, Maryland 20636-3111 USA + * Hollywood, Maryland 20636 USA * * Voice: (301) 373-9603 * EMail: cups-info@cups.org @@ -29,14 +29,20 @@ * * Contents: * - * main() - Process files on the command-line... - * usage() - Show program usage. - * help() - Show detailed program usage. - * getlangs() - Get available translations. - * printlangs() - Show available translations. - * printmodels() - Show available printer models. - * checkcat() - Check message catalogue exists. - * write_ppd() - Write a PPD file. + * main() - Process files on the command-line... + * cat_ppd() - Copy the named PPD to stdout. + * generate_ppd() - Generate a PPD file. + * getlangs() - Get a list of available translations. + * help() - Show detailed help. + * is_special_option() - Determine if an option should be grouped. + * list_ppds() - List the available drivers. + * print_group_close() - Close a UI group. + * print_group_open() - Open a new UI group. + * printlangs() - Print list of available translations. + * printmodels() - Print a list of available models. + * set_language() - Set the current translation language. + * usage() - Show program usage. + * write_ppd() - Write a PPD file. */ /* @@ -57,8 +63,26 @@ #include <string.h> #include <ctype.h> #include <errno.h> +#include <libgen.h> + +#ifdef CUPS_DRIVER_INTERFACE +# ifdef HAVE_LIBZ +# undef HAVE_LIBZ +# endif /* HAVE_LIBZ */ +#endif /* CUPS_DRIVER_INTERFACE */ + +static const char *cups_modeldir = CUPS_MODELDIR; + #ifdef HAVE_LIBZ #include <zlib.h> +static const char *gzext = ".gz"; +#else +static const char *gzext = ""; +# define gzopen fopen +# define gzclose fclose +# define gzFile FILE * +# define gzprintf fprintf +# define gzputs(f,s) fputs((s),(f)) #endif #include <cups/cups.h> @@ -68,6 +92,17 @@ #include <gutenprint/gutenprint-intl.h> /* + * Some of the Gutenprint resolution names are not PPD-compliant. + * In Gutenprint 5.0, use the legacy names with the CUPS 1.1 interface + * for back compatibility. With CUPS 1.2, or Gutenprint 5.1 or above, + * generate compliant names. + */ + +#if defined(CUPS_DRIVER_INTERFACE) || (STP_MAJOR_VERSION > 5) || (STP_MAJOR_VERSION == 5 && STP_MINOR_VERSION > 0) +#define USE_COMPLIANT_RESOLUTIONS 1 +#endif + +/* * Note: * * The current release of ESP Ghostscript is fully Level 3 compliant, @@ -76,33 +111,11 @@ int cups_ppd_ps_level = CUPS_PPD_PS_LEVEL; -static const char *cups_modeldir = CUPS_MODELDIR; - /* * File handling stuff... */ static const char *ppdext = ".ppd"; -#ifdef HAVE_LIBZ -static const char *gzext = ".gz"; -#else -static const char *gzext = ""; -# define gzFile FILE * -# define gzopen fopen -# define gzclose fclose -# define gzprintf fprintf -# define gzputs(f,s) fputs((s),(f)) -# define gzputc(f,c) putc((c),(f)) -#endif /* HAVE_LIBZ */ - - -/* - * Size data... - */ - -#define DEFAULT_SIZE "Letter" -/*#define DEFAULT_SIZE "A4"*/ -#define CATALOG "LC_MESSAGES/gutenprint.mo" typedef struct /**** Media size values ****/ { @@ -149,55 +162,271 @@ const char *parameter_level_names[] = * Local functions... */ -void usage(void); -void help(void); -char ** getlangs(void); -static int stpi_scandir (const char *dir, - struct dirent ***namelist, - int (*sel) (const struct dirent *), - int (*cmp) (const void *, const void *)); -int checkcat (const struct dirent *localedir); -void printlangs(char** langs); -void printmodels(int verbose); -int write_ppd(const stp_printer_t *p, const char *prefix, - const char *language, int verbose, int simplified); +#ifdef CUPS_DRIVER_INTERFACE +static int cat_ppd(int argc, char **argv); +static int list_ppds(const char *argv0); +#else /* !CUPS_DRIVER_INTERFACE */ +static int generate_ppd(const char *prefix, int verbose, + const stp_printer_t *p, const char *language, + int simplified); +static void help(void); +static void printlangs(char** langs); +static void printmodels(int verbose); +static void usage(void); +#endif /* !CUPS_DRIVER_INTERFACE */ +#ifdef ENABLE_NLS +static char **getlangs(void); +static void set_language(const char *lang); +#endif /* ENABLE_NLS */ +static int is_special_option(const char *name); +static void print_group_close(gzFile fp, stp_parameter_class_t p_class, + stp_parameter_level_t p_level); +static void print_group_open(gzFile fp, stp_parameter_class_t p_class, + stp_parameter_level_t p_level); +static int write_ppd(gzFile fp, const stp_printer_t *p, + const char *language, const char *ppd_location, + int simplified); + +#ifdef ENABLE_NLS +typedef struct { + const char *lang; + const char *mapping; +} locale_map; + +static const locale_map lang_mappings[] = + { + { "cs", "CS_CZ" }, + { "da", "da_DK" }, + { "de", "de_DE" }, + { "el", "el_GR" }, + { "es", "es_ES" }, + { "fr", "fr_FR" }, + { "hu", "hu_HU" }, + { "ja", "ja_JP" }, + { "nb", "nb_NO" }, + { "nl", "nl_NL" }, + { "pl", "pl_PL" }, + { "pt", "pt_PT" }, + { "sk", "sk_SK" }, + { "sv", "sv_SE" }, + }; +static int lang_map_count = sizeof(lang_mappings) / sizeof(locale_map); + +static const char *baselocaledir = PACKAGE_LOCALE_DIR; +#endif /* * Global variables... */ -const char *baselocaledir = PACKAGE_LOCALE_DIR; -static int -is_special_option(const char *name) + +#ifdef CUPS_DRIVER_INTERFACE + +/* + * 'main()' - Process files on the command-line... + */ + +int /* O - Exit status */ +main(int argc, /* I - Number of command-line arguments */ + char *argv[]) /* I - Command-line arguments */ { - int i = 0; - while (special_options[i]) + + /* + * Initialise libgutenprint + */ + + stp_init(); + + /* + * Process command-line... + */ + + if (argc == 2 && !strcmp(argv[1], "list")) + return (list_ppds(argv[0])); + else if (argc == 3 && !strcmp(argv[1], "cat")) + return (cat_ppd(argc, argv)); + else if (argc == 2 && !strcmp(argv[1], "VERSION")) { - if (strcmp(name, special_options[i]) == 0) - return 1; - i++; + printf("%s\n", VERSION); + return (0); } - return 0; + else + { + fprintf(stderr, "Usage: %s list\n", argv[0]); + fprintf(stderr, " %s cat URI\n", argv[0]); + return (1); + } } -static void -print_group_open(FILE *fp, stp_parameter_class_t p_class, - stp_parameter_level_t p_level) + +/* + * 'cat_ppd()' - Copy the named PPD to stdout. + */ + +static int /* O - Exit status */ +cat_ppd(int argc, char **argv) /* I - Driver URI */ { - gzprintf(fp, "*OpenGroup: %s %s\n\n", - gettext(parameter_class_names[p_class]), - gettext(parameter_level_names[p_level])); + const char *uri = argv[2]; + char scheme[64], /* URI scheme */ + userpass[32], /* URI user/pass (unused) */ + hostname[32], /* URI hostname */ + resource[1024]; /* URI resource */ + int port; /* URI port (unused) */ + http_uri_status_t status; /* URI decode status */ + const stp_printer_t *p; /* Printer driver */ + const char *lang = "C"; + char *s; +#ifdef ENABLE_NLS + char **all_langs = getlangs(); +#endif + char filename[1024], /* Filename */ + ppd_location[1024]; /* Installed location */ + + if ((status = httpSeparateURI(HTTP_URI_CODING_ALL, uri, + scheme, sizeof(scheme), + userpass, sizeof(userpass), + hostname, sizeof(hostname), + &port, resource, sizeof(resource))) + < HTTP_URI_OK) + { + fprintf(stderr, "ERROR: Bad ppd-name \"%s\" (%d)!\n", uri, status); + return (1); + } + + s = strchr(resource + 1, '/'); + if (s) + { + lang = s + 1; + *s = '\0'; + } + +#ifdef ENABLE_NLS + if (!lang || strcmp(lang, "C") != 0) + { + while (*all_langs) + { + if (!strcmp(lang, *all_langs)) + break; + all_langs++; + } + if (! *all_langs) + { + fprintf(stderr, "ERROR: Unable to find language \"%s\"!\n", lang); + return (1); + } + } + set_language(lang); +#endif + + if ((p = stp_get_printer_by_driver(hostname)) == NULL) + { + fprintf(stderr, "ERROR: Unable to find driver \"%s\"!\n", hostname); + return (1); + } + + /* + * This isn't really the right thing to do. We really shouldn't + * be embedding filenames in automatically generated PPD files, but + * if the user ever decides to go back from generated PPD files to + * static PPD files we'll need to have this for genppdupdate to work. + */ + snprintf(filename, sizeof(filename) - 1, "%s/stp-%s.%s%s%s%s", + "ppd", hostname, GUTENPRINT_RELEASE_VERSION, + strcmp(resource + 1, "simple") ? "" : ".sim", ppdext, gzext); + snprintf(ppd_location, sizeof(ppd_location) - 1, "%s%s%s/%s", + cups_modeldir, + cups_modeldir[strlen(cups_modeldir) - 1] == '/' ? "" : "/", + lang ? lang : "C", + filename); + + return (write_ppd(stdout, p, lang, ppd_location, + !strcmp(resource + 1, "simple"))); } -static void -print_group_close(FILE *fp, stp_parameter_class_t p_class, - stp_parameter_level_t p_level) +/* + * 'list_ppds()' - List the available drivers. + */ + +static int /* O - Exit status */ +list_ppds(const char *argv0) /* I - Name of program */ { - gzprintf(fp, "*CloseGroup: %s %s\n\n", - gettext(parameter_class_names[p_class]), - gettext(parameter_level_names[p_level])); + const char *scheme; /* URI scheme */ + int i; /* Looping var */ + const stp_printer_t *printer; /* Pointer to printer driver */ +#if defined(ENABLE_NLS) && defined(CUPS_TRANSLATED_PPDS) + char **langs = getlangs(); + char **langptr; +#endif + + if ((scheme = strrchr(argv0, '/')) != NULL) + scheme ++; + else + scheme = argv0; + + for (i = 0; i < stp_printer_model_count(); i++) + if ((printer = stp_get_printer_by_index(i)) != NULL) + { + if (!strcmp(stp_printer_get_family(printer), "ps") || + !strcmp(stp_printer_get_family(printer), "raw")) + continue; + + printf("\"%s://%s/expert/%s\" " + "%s " + "\"%s\" " + "\"%s" CUPS_PPD_NICKNAME_STRING VERSION "\" " + "\"\"\n", /* No IEEE-1284 Device ID yet */ + scheme, stp_printer_get_driver(printer), "C", + "en", + stp_printer_get_manufacturer(printer), + stp_printer_get_long_name(printer)); + +#ifdef GENERATE_SIMPLIFIED_PPDS + printf("\"%s://%s/simple/%s\" " + "%s " + "\"%s\" " + "\"%s" CUPS_PPD_NICKNAME_STRING VERSION " Simplified\" " + "\"\"\n", /* No IEEE-1284 Device ID yet */ + scheme, stp_printer_get_driver(printer), "C", + "en", + stp_printer_get_manufacturer(printer), + stp_printer_get_long_name(printer)); +#endif +#if defined(ENABLE_NLS) && defined(CUPS_TRANSLATED_PPDS) + langptr = langs; + while (*langptr != 0 && strcmp(*langptr, "") != 0) + { + printf("\"%s://%s/expert/%s\" " + "%s " + "\"%s\" " + "\"%s" CUPS_PPD_NICKNAME_STRING VERSION "\" " + "\"\"\n", /* No IEEE-1284 Device ID yet */ + scheme, stp_printer_get_driver(printer), *langptr, + *langptr, + stp_printer_get_manufacturer(printer), + stp_printer_get_long_name(printer)); + +#ifdef GENERATE_SIMPLIFIED_PPDS + printf("\"%s://%s/simple/%s\" " + "%s " + "\"%s\" " + "\"%s" CUPS_PPD_NICKNAME_STRING VERSION " Simplified\" " + "\"\"\n", /* No IEEE-1284 Device ID yet */ + scheme, stp_printer_get_driver(printer), *langptr, + *langptr, + stp_printer_get_manufacturer(printer), + stp_printer_get_long_name(printer)); +#endif + langptr++; + } +#endif + } + + return (0); } +#endif /* CUPS_DRIVER_INTERFACE */ + +#ifndef CUPS_DRIVER_INTERFACE /* * 'main()' - Process files on the command-line... @@ -239,6 +468,7 @@ main(int argc, /* I - Number of command-line arguments */ break; case 'h': help(); + exit(EXIT_SUCCESS); break; case 'v': verbose = 1; @@ -247,16 +477,18 @@ main(int argc, /* I - Number of command-line arguments */ verbose = 0; break; case 'c': +# ifdef ENABLE_NLS baselocaledir = optarg; -#ifdef DEBUG - fprintf (stderr, "DEBUG: baselocaledir: %s\n", baselocaledir); -#endif +# ifdef DEBUG + fprintf(stderr, "DEBUG: baselocaledir: %s\n", baselocaledir); +# endif +# endif break; case 'p': prefix = optarg; -#ifdef DEBUG - fprintf (stderr, "DEBUG: prefix: %s\n", prefix); -#endif +# ifdef DEBUG + fprintf(stderr, "DEBUG: prefix: %s\n", prefix); +# endif break; case 'l': language = optarg; @@ -278,7 +510,7 @@ main(int argc, /* I - Number of command-line arguments */ break; case 'V': printf("cups-genppd version %s, " - "Copyright (c) 1993-2005 by Easy Software Products and Robert Krawitz.\n\n", + "Copyright 1993-2006 by Easy Software Products and Robert Krawitz.\n\n", VERSION); printf("Default CUPS PPD PostScript Level: %d\n", cups_ppd_ps_level); printf("Default PPD location (prefix): %s\n", CUPS_MODELDIR); @@ -291,8 +523,8 @@ main(int argc, /* I - Number of command-line arguments */ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n" - "\n" - "You should have received a copy of the GNU General Public License\n" + "\n"); + puts("You should have received a copy of the GNU General Public License\n" "along with this program; if not, please contact Easy Software\n" "Products at:\n" "\n" @@ -304,11 +536,11 @@ main(int argc, /* I - Number of command-line arguments */ " Voice: (301) 373-9603\n" " EMail: cups-info@cups.org\n" " WWW: http://www.cups.org\n"); - exit (EXIT_SUCCESS); + exit(EXIT_SUCCESS); break; default: usage(); - exit (EXIT_FAILURE); + exit(EXIT_FAILURE); break; } } @@ -320,15 +552,11 @@ main(int argc, /* I - Number of command-line arguments */ { models[n] = argv[optind+n]; } - models[numargs] = (char*) NULL; + models[numargs] = (char*)NULL; n=0; } -#ifdef ENABLE_NLS - langs = getlangs(); -#endif - /* * Initialise libgutenprint */ @@ -339,68 +567,27 @@ main(int argc, /* I - Number of command-line arguments */ * Set the language... */ - if (language) - { - unsetenv("LC_CTYPE"); - unsetenv("LC_COLLATE"); - unsetenv("LC_TIME"); - unsetenv("LC_NUMERIC"); - unsetenv("LC_MONETARY"); - unsetenv("LC_MESSAGES"); - unsetenv("LC_ALL"); - unsetenv("LANG"); - setenv("LC_ALL", language, 1); - setenv("LANG", language, 1); - } - setlocale(LC_ALL, ""); +# ifdef ENABLE_NLS + langs = getlangs(); -#ifdef LC_NUMERIC - setlocale(LC_NUMERIC, "C"); -#endif /* LC_NUMERIC */ + if (language) + set_language(language); +# endif /* ENABLE_NLS */ /* - * Set up the catalog + * Print lists */ -#ifdef ENABLE_NLS - if (baselocaledir) - { - if ((bindtextdomain(PACKAGE, baselocaledir)) == NULL) - { - fprintf(stderr, "cups-genppd: cannot load message catalog %s under %s: %s\n", - PACKAGE, baselocaledir, strerror(errno)); - exit(EXIT_FAILURE); - } -#ifdef DEBUG - fprintf (stderr, "DEBUG: bound textdomain: %s under %s\n", - PACKAGE, baselocaledir); -#endif - if ((textdomain(PACKAGE)) == NULL) - { - fprintf(stderr, "cups-genppd: cannot select message catalog %s under %s: %s\n", - PACKAGE, baselocaledir, strerror(errno)); - exit(EXIT_FAILURE); - } -#ifdef DEBUG - fprintf (stderr, "DEBUG: textdomain set: %s\n", PACKAGE); -#endif - } -#endif - - /* - * Print lists - */ - if (opt_printlangs) { printlangs(langs); - exit (EXIT_SUCCESS); + exit(EXIT_SUCCESS); } if (opt_printmodels) { printmodels(verbose); - exit (EXIT_SUCCESS); + exit(EXIT_SUCCESS); } /* @@ -419,11 +606,11 @@ main(int argc, /* I - Number of command-line arguments */ if (printer) { if ((which_ppds & 1) && - write_ppd(printer, prefix, language, verbose, 1)) - return 1; + generate_ppd(prefix, verbose, printer, language, 1)) + return (1); if ((which_ppds & 2) && - write_ppd(printer, prefix, language, verbose, 0)) - return 1; + generate_ppd(prefix, verbose, printer, language, 0)) + return (1); } else { @@ -442,45 +629,109 @@ main(int argc, /* I - Number of command-line arguments */ if (printer) { if ((which_ppds & 1) && - write_ppd(printer, prefix, language, verbose, 1)) + generate_ppd(prefix, verbose, printer, language, 1)) return (1); if ((which_ppds & 2) && - write_ppd(printer, prefix, language, verbose, 0)) + generate_ppd(prefix, verbose, printer, language, 0)) return (1); } } } if (!verbose) fprintf(stderr, " done.\n"); - if (langs) - { - char **langs_tmp = langs; - while (*langs_tmp) - { - stp_free(*langs_tmp); - langs_tmp++; - } - stp_free(langs); - } return (0); } /* - * 'usage()' - Show program usage... + * 'generate_ppd()' - Generate a PPD file. */ -void -usage(void) +static int /* O - Exit status */ +generate_ppd( + const char *prefix, /* I - PPD directory prefix */ + int verbose, /* I - Verbosity level */ + const stp_printer_t *p, /* I - Driver */ + const char *language, /* I - Primary language */ + int simplified) /* I - 1 = simplified options */ { - puts("Usage: cups-genppd [-c localedir] " - "[-l locale] [-p prefix] [-s | -a] [-q] [-v] models...\n" - " cups-genppd -L [-c localedir]\n" - " cups-genppd -M [-v]\n" - " cups-genppd -h\n" - " cups-genppd -V\n"); + int status; /* Exit status */ + gzFile fp; /* File to write to */ + char filename[1024], /* Filename */ + ppd_location[1024]; /* Installed location */ + struct stat dir; /* Prefix dir status */ + + + /* + * Skip the PostScript drivers... + */ + + if (!strcmp(stp_printer_get_family(p), "ps") || + !strcmp(stp_printer_get_family(p), "raw")) + return (0); + + /* + * Make sure the destination directory exists... + */ + + if (stat(prefix, &dir) && !S_ISDIR(dir.st_mode)) + { + if (mkdir(prefix, 0777)) + { + printf("cups-genppd: Cannot create directory %s: %s\n", + prefix, strerror(errno)); + exit(EXIT_FAILURE); + } + } + + /* + * The files will be named stp-<driver>.<major>.<minor>.ppd, for + * example: + * + * stp-escp2-ex.5.0.ppd + * + * or + * + * stp-escp2-ex.5.0.ppd.gz + */ + + snprintf(filename, sizeof(filename) - 1, "%s/stp-%s.%s%s%s%s", + prefix, stp_printer_get_driver(p), GUTENPRINT_RELEASE_VERSION, + simplified ? ".sim" : "", ppdext, gzext); + + /* + * Open the PPD file... + */ + + if ((fp = gzopen(filename, "wb")) == NULL) + { + fprintf(stderr, "cups-genppd: Unable to create file \"%s\" - %s.\n", + filename, strerror(errno)); + return (2); + } + + if (verbose) + fprintf(stderr, "Writing %s...\n", filename); + else + fprintf(stderr, "."); + + snprintf(ppd_location, sizeof(ppd_location), "%s%s%s/%s", + cups_modeldir, + cups_modeldir[strlen(cups_modeldir) - 1] == '/' ? "" : "/", + language ? language : "C", + basename(filename)); + + status = write_ppd(fp, p, language, ppd_location, simplified); + + gzclose(fp); + + return (status); } +/* + * 'help()' - Show detailed help. + */ + void help(void) { @@ -494,8 +745,8 @@ help(void) " -L List available translations (message catalogs).\n" " -M List available printer models.\n" " -V Show version information and defaults.\n" - " The default is to output PPDs.\n" - "Options:\n" + " The default is to output PPDs.\n"); + puts("Options:\n" " -c localedir Use localedir as the base directory for locale data.\n" " -l locale Output PPDs translated with messages for locale.\n" " -p prefix Output PPDs in directory prefix.\n" @@ -509,72 +760,46 @@ help(void) } /* - * 'dirent_sort()' - sort directory entries + * 'usage()' - Show program usage. */ -static int -dirent_sort(const void *a, - const void *b) -{ - return strcoll ((*(const struct dirent *const *) a)->d_name, - (*(const struct dirent *const *) b)->d_name); -} -/* - * 'getlangs()' - Get a list of available translations - */ - -char ** -getlangs(void) +void +usage(void) { - struct dirent** langdirs = NULL; - int n; - char **langs; - - n = stpi_scandir (baselocaledir, &langdirs, checkcat, dirent_sort); - if (n >= 0) - { - int idx; - langs = stp_malloc((n+1) * sizeof(char*)); - for (idx = 0; idx < n; ++idx) - { - langs[idx] = (char*) stp_malloc((strlen(langdirs[idx]->d_name)+1) * sizeof(char)); - strcpy(langs[idx], langdirs[idx]->d_name); - free (langdirs[idx]); /* Must use plain free() */ - } - langs[n] = NULL; - free (langdirs); /* Must use plain free() */ - } - else - return NULL; - - return langs; + puts("Usage: cups-genppd [-c localedir] " + "[-l locale] [-p prefix] [-s | -a] [-q] [-v] models...\n" + " cups-genppd -L [-c localedir]\n" + " cups-genppd -M [-v]\n" + " cups-genppd -h\n" + " cups-genppd -V\n"); } - /* - * 'printlangs()' - Print list of available translations + * 'printlangs()' - Print list of available translations. */ -void printlangs(char **langs) +void +printlangs(char **langs) /* I - Languages */ { if (langs) { int n = 0; while (langs && langs[n]) { - printf("%s\n", langs[n]); + puts(langs[n]); n++; } } - exit (EXIT_SUCCESS); + exit(EXIT_SUCCESS); } /* - * 'printmodels' - Print a list of available models + * 'printmodels()' - Print a list of available models. */ -void printmodels(int verbose) +void +printmodels(int verbose) /* I - Verbosity level */ { const stp_printer_t *p; int i; @@ -593,182 +818,177 @@ void printmodels(int verbose) printf("%s\n", stp_printer_get_driver(p)); } } - exit (EXIT_SUCCESS); + exit(EXIT_SUCCESS); } -/* Adapted from GNU libc <dirent.h> - These macros extract size information from a `struct dirent *'. - They may evaluate their argument multiple times, so it must not - have side effects. Each of these may involve a relatively costly - call to `strlen' on some systems, so these values should be cached. - - _D_EXACT_NAMLEN (DP) returns the length of DP->d_name, not including - its terminating null character. +#endif /* !CUPS_DRIVER_INTERFACE */ - _D_ALLOC_NAMLEN (DP) returns a size at least (_D_EXACT_NAMLEN (DP) + 1); - that is, the allocation size needed to hold the DP->d_name string. - Use this macro when you don't need the exact length, just an upper bound. - This macro is less likely to require calling `strlen' than _D_EXACT_NAMLEN. - */ - -#ifdef _DIRENT_HAVE_D_NAMLEN -# ifndef _D_EXACT_NAMLEN -# define _D_EXACT_NAMLEN(d) ((d)->d_namlen) -# endif -# ifndef _D_ALLOC_NAMLEN -# define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1) -# endif -#else -# ifndef _D_EXACT_NAMLEN -# define _D_EXACT_NAMLEN(d) (strlen ((d)->d_name)) -# endif -# ifndef _D_ALLOC_NAMLEN -# ifdef _DIRENT_HAVE_D_RECLEN -# define _D_ALLOC_NAMLEN(d) (((char *) (d) + (d)->d_reclen) - &(d)->d_name[0]) -# else -# define _D_ALLOC_NAMLEN(d) (sizeof (d)->d_name > 1 ? sizeof (d)->d_name : \ - _D_EXACT_NAMLEN (d) + 1) -# endif -# endif -#endif /* - * 'stpi_scandir()' - BSD scandir() replacement. + * 'getlangs()' - Get a list of available translations. */ -static int -stpi_scandir (const char *dir, - struct dirent ***namelist, - int (*sel) (const struct dirent *), - int (*cmp) (const void *, const void *)) +#ifdef ENABLE_NLS +char ** /* O - Array of languages */ +getlangs(void) { - DIR *dp = opendir (dir); - struct dirent **v = NULL; - size_t vsize = 0, i; - struct dirent *d; - int save; + int i; /* Looping var */ + char *ptr; /* Pointer into string */ + static char all_linguas[] = ALL_LINGUAS; + /* List of languages from configure.ac */ + static char **langs = NULL; /* Array of languages */ - if (dp == NULL) - return -1; - save = errno; - errno = 0; + if (!langs) + { + /* + * Create the langs array... + */ - i = 0; - while ((d = readdir (dp)) != NULL) - if (sel == NULL || (*sel) (d)) - { - struct dirent *vnew; - size_t dsize; - - /* Ignore errors from sel or readdir */ - errno = 0; - - if (i == vsize) - { - struct dirent **new; - if (vsize == 0) - vsize = 10; - else - vsize *= 2; - new = (struct dirent **) realloc (v, vsize * sizeof (*v)); - if (new == NULL) - break; - v = new; - } - - dsize = &d->d_name[_D_ALLOC_NAMLEN (d)] - (char *) d; - vnew = (struct dirent *) malloc (dsize); - if (vnew == NULL) - break; - - v[i++] = (struct dirent *) memcpy (vnew, d, dsize); - } + for (i = 1, ptr = strchr(all_linguas, ' '); ptr; ptr = strchr(ptr + 1, ' ')) + i ++; + + langs = calloc(i + 1, sizeof(char *)); - if (errno != 0) + langs[0] = all_linguas; + for (i = 1, ptr = strchr(all_linguas, ' '); ptr; ptr = strchr(ptr + 1, ' ')) { - save = errno; + *ptr = '\0'; + langs[i] = ptr + 1; + i ++; + } + } - while (i > 0) - free (v[--i]); - free (v); + return (langs); +} - i = -1; - } - else +/* + * 'set_language()' - Set the current translation language. + */ + +static void +set_language(const char *lang) /* I - Locale name */ +{ + char *l = setlocale(LC_ALL, lang ? lang : ""); + + /* Make sure the locale we tried to set was accepted! */ + if (lang && !l) { - /* Sort the list if we have a comparison function to sort with. */ - if (cmp != NULL) - qsort (v, i, sizeof (*v), cmp); + int i; + for (i = 0; i < lang_map_count; i++) + { + const locale_map *lm = &(lang_mappings[i]); + if (!strcmp(lang, lm->lang)) + { + l = setlocale(LC_ALL, lm->mapping); + if (l) + break; + } + } + } - *namelist = v; +# ifdef LC_CTYPE + setlocale(LC_CTYPE, l ? l : ""); +# endif /* LC_CTYPE */ +# ifdef LC_NUMERIC + setlocale(LC_NUMERIC, "C"); +# endif /* LC_NUMERIC */ + + /* + * Set up the catalog + */ + + if (baselocaledir) + { + if ((bindtextdomain(PACKAGE, baselocaledir)) == NULL) + { + fprintf(stderr, "cups-genppd: cannot load message catalog %s under %s: %s\n", + PACKAGE, baselocaledir, strerror(errno)); + exit(EXIT_FAILURE); } - (void) closedir (dp); - errno = save; +# ifdef DEBUG + fprintf(stderr, "DEBUG: bound textdomain: %s under %s\n", + PACKAGE, baselocaledir); +# endif /* DEBUG */ - return i; + if ((textdomain(PACKAGE)) == NULL) + { + fprintf(stderr, + "cups-genppd: cannot select message catalog %s under %s: %s\n", + PACKAGE, baselocaledir, strerror(errno)); + exit(EXIT_FAILURE); + } +# ifdef DEBUG + fprintf(stderr, "DEBUG: textdomain set: %s\n", PACKAGE); +# endif /* DEBUG */ + } } +#endif /* ENABLE_NLS */ /* - * 'checkcat()' - A callback for stpi_scandir() to check - * if a message catalogue exists + * 'is_special_option()' - Determine if an option should be grouped. */ -int -checkcat (const struct dirent *localedir) +static int /* O - 1 if non-grouped, 0 otherwise */ +is_special_option(const char *name) /* I - Option name */ { - char* catpath; - int catlen, status = 0, savederr; - struct stat catstat; - - savederr = errno; /* since we are a callback, preserve stpi_scandir() state */ - - /* LOCALEDIR / LANG / LC_MESSAGES/CATALOG */ - /* Add 3, for two '/' separators and '\0' */ - catlen = strlen(baselocaledir) + strlen(localedir->d_name) + strlen(CATALOG) + 3; - catpath = (char*) stp_malloc(catlen * sizeof(char)); - - strncpy (catpath, baselocaledir, strlen(baselocaledir)); - catlen = strlen(baselocaledir); - *(catpath+catlen) = '/'; - catlen++; - strncpy (catpath+catlen, localedir->d_name, strlen(localedir->d_name)); - catlen += strlen(localedir->d_name); - *(catpath+catlen) = '/'; - catlen++; - strncpy (catpath+catlen, CATALOG, strlen(CATALOG)); - catlen += strlen(CATALOG); - *(catpath+catlen) = '\0'; - - if (!stat (catpath, &catstat)) + int i = 0; + while (special_options[i]) { - if (S_ISREG(catstat.st_mode)) - { - status = 1; - } - } + if (strcmp(name, special_options[i]) == 0) + return 1; + i++; + } + return 0; +} + + +/* + * 'print_group_close()' - Close a UI group. + */ + +static void +print_group_close( + gzFile fp, /* I - File to write to */ + stp_parameter_class_t p_class, /* I - Option class */ + stp_parameter_level_t p_level) /* I - Option level */ +{ + gzprintf(fp, "*CloseGroup: %s %s\n\n", + gettext(parameter_class_names[p_class]), + gettext(parameter_level_names[p_level])); +} - stp_free (catpath); - errno = savederr; - return status; +/* + * 'print_group_open()' - Open a new UI group. + */ + +static void +print_group_open( + gzFile fp, /* I - File to write to */ + stp_parameter_class_t p_class, /* I - Option class */ + stp_parameter_level_t p_level) /* I - Option level */ +{ + gzprintf(fp, "*OpenGroup: %s %s\n\n", + gettext(parameter_class_names[p_class]), + gettext(parameter_level_names[p_level])); } + /* * 'write_ppd()' - Write a PPD file. */ int /* O - Exit status */ -write_ppd(const stp_printer_t *p, /* I - Printer driver */ - const char *prefix, /* I - Prefix (directory) for PPD files */ - const char *language, - int verbose, - int simplified) +write_ppd( + gzFile fp, /* I - File to write to */ + const stp_printer_t *p, /* I - Printer driver */ + const char *language, /* I - Primary language */ + const char *ppd_location, /* I - Location of PPD file */ + int simplified) /* I - 1 = simplified options */ { int i, j, k, l; /* Looping vars */ - gzFile fp; /* File to write to */ - char filename[1024]; /* Filename */ int num_opts; /* Number of printer options */ int xdpi, ydpi; /* Resolution info */ stp_vars_t *v; /* Variable info */ @@ -778,10 +998,9 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ const char *driver; /* Driver name */ const char *long_name; /* Driver long name */ const char *manufacturer; /* Manufacturer of printer */ - const stp_vars_t *printvars; /* Printer option names */ + const stp_vars_t *printvars; /* Printer option names */ paper_t *the_papers; /* Media sizes */ int cur_opt; /* Current option */ - struct stat dir; /* prefix dir status */ int variable_sizes; /* Does the driver support variable sizes? */ int min_width, /* Min/max custom size */ min_height, @@ -795,6 +1014,7 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ int maximum_level = simplified ? STP_PARAMETER_LEVEL_BASIC : STP_PARAMETER_LEVEL_ADVANCED4; + /* * Initialize driver-specific variables... */ @@ -807,77 +1027,24 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ cur_opt = 0; /* - * Skip the PostScript drivers... - */ - - if (strcmp(stp_printer_get_family(p), "ps") == 0 || - strcmp(stp_printer_get_family(p), "raw") == 0) - return (0); - - /* - * Make sure the destination directory exists... - */ - - - if (stat(prefix, &dir) && !S_ISDIR(dir.st_mode)) - { - if (mkdir(prefix, 0777)) - { - printf("cups-genppd: Cannot create directory %s: %s\n", - prefix, strerror(errno)); - exit (EXIT_FAILURE); - } - } - - /* - * The files will be named stp-<driver>.<major>.<minor>.ppd, for - * example: - * - * stp-escp2-ex.5.0.ppd - * - * or - * - * stp-escp2-ex.5.0.ppd.gz - */ - snprintf(filename, sizeof(filename) - 1, "%s/stp-%s.%s%s%s%s", - prefix, driver, GUTENPRINT_RELEASE_VERSION, - simplified ? ".sim" : "", ppdext, gzext); - - /* - * Open the PPD file... - */ - - if ((fp = gzopen(filename, "wb")) == NULL) - { - fprintf(stderr, "cups-genppd: Unable to create file \"%s\" - %s.\n", - filename, strerror(errno)); - return (2); - } - - /* * Write a standard header... */ - if (verbose) - fprintf(stderr, "Writing %s...\n", filename); - else - fprintf(stderr, "."); - gzputs(fp, "*PPD-Adobe: \"4.3\"\n"); - gzputs(fp, "*%PPD file for CUPS/Gutenprint.\n"); - gzputs(fp, "*%Copyright 1993-2005 by Easy Software Products and Robert Krawitz.\n"); - gzputs(fp, "*%This program is free software; you can redistribute it and/or\n"); - gzputs(fp, "*%modify it under the terms of the GNU General Public License,\n"); - gzputs(fp, "*%version 2, as published by the Free Software Foundation.\n"); + gzputs(fp, "*% PPD file for CUPS/Gutenprint.\n"); + gzputs(fp, "*% Copyright 1993-2006 by Easy Software Products and Robert Krawitz.\n"); + gzputs(fp, "*% This program is free software; you can redistribute it and/or\n"); + gzputs(fp, "*% modify it under the terms of the GNU General Public License,\n"); + gzputs(fp, "*% version 2, as published by the Free Software Foundation.\n"); gzputs(fp, "*%\n"); - gzputs(fp, "*%This program is distributed in the hope that it will be useful, but\n"); - gzputs(fp, "*%WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n"); - gzputs(fp, "*%or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n"); - gzputs(fp, "*%for more details.\n"); + gzputs(fp, "*% This program is distributed in the hope that it will be useful, but\n"); + gzputs(fp, "*% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n"); + gzputs(fp, "*% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n"); + gzputs(fp, "*% for more details.\n"); gzputs(fp, "*%\n"); - gzputs(fp, "*%You should have received a copy of the GNU General Public License\n"); - gzputs(fp, "*%along with this program; if not, write to the Free Software\n"); - gzputs(fp, "*%Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"); + gzputs(fp, "*% You should have received a copy of the GNU General Public License\n"); + gzputs(fp, "*% along with this program; if not, write to the Free Software\n"); + 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"); @@ -925,11 +1092,11 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ * 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 - * rastertoprinter.c. Look for "ppd->nickname" - */ + /* + * NOTE - code in rastertoprinter looks for this version string. + * If this is changed, the corresponding change must be made in + * rastertoprinter.c. Look for "ppd->nickname" + */ gzprintf(fp, "*NickName: \"%s%s%s%s\"\n", long_name, CUPS_PPD_NICKNAME_STRING, VERSION, simplified ? " Simplified" : ""); @@ -987,16 +1154,8 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzputs(fp, "*cupsFilter: \"application/vnd.cups-command 33 commandtoepson\"\n"); gzputs(fp, "\n"); gzprintf(fp, "*StpDriverName: \"%s\"\n", driver); - gzprintf(fp, "*StpPPDLocation: \"%s%s%s/stp-%s.%s%s%s%s\"\n", - cups_modeldir, - cups_modeldir[strlen(cups_modeldir) - 1] == '/' ? "" : "/", - language ? language : "C", - driver, - GUTENPRINT_RELEASE_VERSION, - simplified ? ".sim" : "", - ppdext, - gzext); - gzprintf(fp, "*StpLocale: \"%s\"\n", language ? language : "C"); + gzprintf(fp, "*StpPPDLocation: \"%s\"\n", ppd_location); + gzprintf(fp, "*StpLocale: \"%s\"\n", language ? language : "C"); /* * Get the page sizes from the driver... @@ -1064,6 +1223,7 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ the_papers[cur_opt].top = height - top; cur_opt++; + stp_clear_string_parameter(v, "PageSize"); } /* @@ -1076,6 +1236,7 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzputs(fp, "*OpenUI *PageSize: PickOne\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *PageSize\n"); gzprintf(fp, "*DefaultPageSize: %s\n", desc.deflt.str); + gzprintf(fp, "*StpDefaultPageSize: %s\n", desc.deflt.str); for (i = 0; i < cur_opt; i ++) { gzprintf(fp, "*PageSize %s", the_papers[i].name); @@ -1087,6 +1248,7 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzputs(fp, "*OpenUI *PageRegion: PickOne\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *PageRegion\n"); gzprintf(fp, "*DefaultPageRegion: %s\n", desc.deflt.str); + gzprintf(fp, "*StpDefaultPageRegion: %s\n", desc.deflt.str); for (i = 0; i < cur_opt; i ++) { gzprintf(fp, "*PageRegion %s", the_papers[i].name); @@ -1096,6 +1258,7 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzputs(fp, "*CloseUI: *PageRegion\n\n"); gzprintf(fp, "*DefaultImageableArea: %s\n", desc.deflt.str); + gzprintf(fp, "*StpDefaultImageableArea: %s\n", desc.deflt.str); for (i = 0; i < cur_opt; i ++) { gzprintf(fp, "*ImageableArea %s", the_papers[i].name); @@ -1106,6 +1269,7 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzputs(fp, "\n"); gzprintf(fp, "*DefaultPaperDimension: %s\n", desc.deflt.str); + gzprintf(fp, "*StpDefaultPaperDimension: %s\n", desc.deflt.str); for (i = 0; i < cur_opt; i ++) { @@ -1143,6 +1307,7 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzputs(fp, "*ParamCustomPageSize WidthOffset: 3 points 0 0\n"); gzputs(fp, "*ParamCustomPageSize HeightOffset: 4 points 0 0\n"); gzputs(fp, "*ParamCustomPageSize Orientation: 5 int 0 0\n\n"); + stp_clear_string_parameter(v, "PageSize"); } stp_parameter_description_destroy(&desc); @@ -1157,9 +1322,15 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzputs(fp, "*OrderDependency: 10 AnySetup *ColorModel\n"); if (printer_is_color) - gzputs(fp, "*DefaultColorModel: RGB\n"); + { + gzputs(fp, "*DefaultColorModel: RGB\n"); + gzputs(fp, "*StpDefaultColorModel: RGB\n"); + } else - gzputs(fp, "*DefaultColorModel: Gray\n"); + { + gzputs(fp, "*DefaultColorModel: Gray\n"); + gzputs(fp, "*StpDefaultColorModel: Gray\n"); + } gzprintf(fp, "*ColorModel Gray/Grayscale:\t\"<<" "/cupsColorSpace %d" @@ -1218,6 +1389,7 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzputs(fp, "*OpenUI *StpColorPrecision/Color Precision: PickOne\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *StpColorPrecision\n"); gzputs(fp, "*DefaultStpColorPrecision: Normal\n"); + gzputs(fp, "*StpDefaultStpColorPrecision: Normal\n"); gzputs(fp, "*StpColorPrecision Normal/Normal:\t\"<<" "/cupsBitsPerColor 8>>setpagedevice\"\n"); gzputs(fp, "*StpColorPrecision Best/Best:\t\"<<" @@ -1238,6 +1410,7 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzprintf(fp, "*OpenUI *MediaType/%s: PickOne\n", _("Media Type")); gzputs(fp, "*OrderDependency: 10 AnySetup *MediaType\n"); gzprintf(fp, "*DefaultMediaType: %s\n", desc.deflt.str); + gzprintf(fp, "*StpDefaultMediaType: %s\n", desc.deflt.str); for (i = 0; i < num_opts; i ++) { @@ -1262,6 +1435,7 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzprintf(fp, "*OpenUI *InputSlot/%s: PickOne\n", _("Media Source")); gzputs(fp, "*OrderDependency: 10 AnySetup *InputSlot\n"); gzprintf(fp, "*DefaultInputSlot: %s\n", desc.deflt.str); + gzprintf(fp, "*StpDefaultInputSlot: %s\n", desc.deflt.str); for (i = 0; i < num_opts; i ++) { @@ -1284,8 +1458,9 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ stp_clear_string_parameter(v, "Resolution"); has_quality_parameter = 1; gzprintf(fp, "*OpenUI *StpQuality/%s: PickOne\n", gettext(desc.text)); - gzputs(fp, "*OrderDependency: 5 AnySetup *StpQuality\n"); + gzputs(fp, "*OrderDependency: 10 AnySetup *StpQuality\n"); gzprintf(fp, "*DefaultStpQuality: %s\n", desc.deflt.str); + gzprintf(fp, "*StpDefaultStpQuality: %s\n", desc.deflt.str); num_opts = stp_string_list_count(desc.bounds.str); for (i = 0; i < num_opts; i++) { @@ -1319,12 +1494,43 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ if (!simplified || desc.p_level == STP_PARAMETER_LEVEL_BASIC) { +#ifdef USE_COMPLIANT_RESOLUTIONS + stp_string_list_t *res_list = stp_string_list_create(); + char res_name[64]; /* Plenty long enough for XXXxYYYdpi */ + int resolution_ok; + int tmp_xdpi, tmp_ydpi; +#endif + gzprintf(fp, "*OpenUI *Resolution/%s: PickOne\n", _("Resolution")); - gzputs(fp, "*OrderDependency: 20 AnySetup *Resolution\n"); + gzputs(fp, "*OrderDependency: 10 AnySetup *Resolution\n"); if (has_quality_parameter) - gzprintf(fp, "*DefaultResolution: None\n"); + { + gzprintf(fp, "*DefaultResolution: None\n"); + gzprintf(fp, "*StpDefaultResolution: None\n"); + } else + { +#ifdef USE_COMPLIANT_RESOLUTIONS + stp_set_string_parameter(v, "Resolution", desc.deflt.str); + stp_describe_resolution(v, &xdpi, &ydpi); + + if (xdpi == ydpi) + (void) snprintf(res_name, 63, "%ddpi", xdpi); + else + (void) snprintf(res_name, 63, "%dx%ddpi", xdpi, ydpi); + gzprintf(fp, "*DefaultResolution: %s\n", res_name); + gzprintf(fp, "*StpDefaultResolution: %s\n", res_name); + /* + * We need to add this to the resolution list here so that + * some non-default resolution won't wind up with the + * default resolution name + */ + stp_string_list_add_string(res_list, res_name, res_name); +#else /* !USE_COMPLIANT_RESOLUTIONS */ gzprintf(fp, "*DefaultResolution: %s\n", desc.deflt.str); + gzprintf(fp, "*StpDefaultResolution: %s\n", desc.deflt.str); +#endif /* USE_COMPLIANT_RESOLUTIONS */ + } stp_clear_string_parameter(v, "Quality"); if (has_quality_parameter) @@ -1342,14 +1548,38 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ if (xdpi == -1 || ydpi == -1) continue; - /* - * Write the resolution option... - */ - +#ifdef USE_COMPLIANT_RESOLUTIONS + resolution_ok = 0; + tmp_xdpi = xdpi; + tmp_ydpi = ydpi; + do + { + if (tmp_xdpi == tmp_ydpi) + (void) snprintf(res_name, 63, "%ddpi", tmp_xdpi); + else + (void) snprintf(res_name, 63, "%dx%ddpi", tmp_xdpi, tmp_ydpi); + if (strcmp(opt->name, desc.deflt.str) == 0 || + !stp_string_list_is_present(res_list, res_name)) + { + resolution_ok = 1; + stp_string_list_add_string(res_list, res_name, res_name); + } + else if (tmp_ydpi > tmp_xdpi) + tmp_ydpi++; + else + tmp_xdpi++; + } while (!resolution_ok); + gzprintf(fp, "*Resolution %s/%s:\t\"<</HWResolution[%d %d]/cupsCompression %d>>setpagedevice\"\n", + res_name, opt->text, xdpi, ydpi, i + 1); +#else /* !USE_COMPLIANT_RESOLUTIONS */ gzprintf(fp, "*Resolution %s/%s:\t\"<</HWResolution[%d %d]/cupsCompression %d>>setpagedevice\"\n", opt->name, opt->text, xdpi, ydpi, i + 1); +#endif /* USE_COMPLIANT_RESOLUTIONS */ } +#ifdef USE_COMPLIANT_RESOLUTIONS + stp_string_list_destroy(res_list); +#endif gzputs(fp, "*CloseUI: *Resolution\n\n"); } @@ -1361,13 +1591,14 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzputs(fp, "*OpenUI *OutputOrder: PickOne\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *OutputOrder\n"); gzprintf(fp, "*DefaultOutputOrder: %s\n", desc.deflt.str); + gzprintf(fp, "*StpDefaultOutputOrder: %s\n", desc.deflt.str); gzputs(fp, "*OutputOrder Normal/Normal: \"\"\n"); gzputs(fp, "*OutputOrder Reverse/Reverse: \"\"\n"); gzputs(fp, "*CloseUI: *OutputOrder\n\n"); } stp_parameter_description_destroy(&desc); - /* + /* * Duplex * Note that the opt->name strings MUST match those in the printer driver(s) * else the PPD files will not be generated correctly @@ -1379,9 +1610,10 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ num_opts = stp_string_list_count(desc.bounds.str); if (num_opts > 0) { - gzputs(fp, "*OpenUI *Duplex/Double-Sided Printing: PickOne\n"); - gzputs(fp, "*OrderDependency: 20 AnySetup *Duplex\n"); + gzprintf(fp, "*OpenUI *Duplex/%s: PickOne\n", _("2-Sided Printing")); + gzputs(fp, "*OrderDependency: 10 AnySetup *Duplex\n"); gzprintf(fp, "*DefaultDuplex: %s\n", desc.deflt.str); + gzprintf(fp, "*StpDefaultDuplex: %s\n", desc.deflt.str); for (i = 0; i < num_opts; i++) { @@ -1398,6 +1630,16 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ } stp_parameter_description_destroy(&desc); + gzprintf(fp, "*OpenUI *StpiShrinkOutput/%s: PickOne\n", + _("Shrink Page If Necessary to Fit Borders")); + gzputs(fp, "*OrderDependency: 10 AnySetup *StpiShrinkOutput\n"); + gzputs(fp, "*DefaultStpiShrinkOutput: Shrink\n"); + gzputs(fp, "*StpDefaultStpiShrinkOutput: Shrink\n"); + gzprintf(fp, "*StpiShrinkOutput %s/%s: \"\"\n", "Shrink", _("Shrink (print the whole page)")); + gzprintf(fp, "*StpiShrinkOutput %s/%s: \"\"\n", "Crop", _("Crop (preserve dimensions)")); + gzprintf(fp, "*StpiShrinkOutput %s/%s: \"\"\n", "Expand", _("Expand (use maximum page area)")); + gzputs(fp, "*CloseUI: *StpiShrinkOutput\n\n"); + param_list = stp_get_parameter_list(v); for (j = 0; j <= STP_PARAMETER_CLASS_OUTPUT; j++) @@ -1429,23 +1671,25 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ } gzprintf(fp, "*OpenUI *Stp%s/%s: PickOne\n", desc.name, gettext(desc.text)); -#if 0 - gzprintf(fp, "*OrderDependency: %d AnySetup *Stp%s\n", - (100 + l + (j * param_count) + - (k * STP_PARAMETER_LEVEL_INTERNAL * param_count)), + gzprintf(fp, "*OrderDependency: 10 AnySetup *Stp%s\n", desc.name); -#endif - if (!desc.is_mandatory) - gzprintf(fp, "*DefaultStp%s: None\n", desc.name); switch (desc.p_type) { case STP_PARAMETER_TYPE_STRING_LIST: if (desc.is_mandatory) - gzprintf(fp, "*DefaultStp%s: %s\n", - desc.name, desc.deflt.str); + { + gzprintf(fp, "*DefaultStp%s: %s\n", + desc.name, desc.deflt.str); + gzprintf(fp, "*StpDefaultStp%s: %s\n", + desc.name, desc.deflt.str); + } else - gzprintf(fp, "*Stp%s %s/%s: \"\"\n", desc.name, - "None", _("None")); + { + gzprintf(fp, "*DefaultStp%s: None\n", desc.name); + gzprintf(fp, "*StpDefaultStp%s: None\n", desc.name); + gzprintf(fp, "*Stp%s %s/%s: \"\"\n", desc.name, + "None", _("None")); + } num_opts = stp_string_list_count(desc.bounds.str); for (i = 0; i < num_opts; i++) { @@ -1456,21 +1700,27 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ break; case STP_PARAMETER_TYPE_BOOLEAN: if (desc.is_mandatory) - gzprintf(fp, "*DefaultStp%s: %s\n", desc.name, - desc.deflt.boolean ? "True" : "False"); + { + gzprintf(fp, "*DefaultStp%s: %s\n", desc.name, + desc.deflt.boolean ? "True" : "False"); + gzprintf(fp, "*StpDefaultStp%s: %s\n", desc.name, + desc.deflt.boolean ? "True" : "False"); + } else - gzprintf(fp, "*Stp%s %s/%s: \"\"\n", desc.name, - "None", _("None")); + { + gzprintf(fp, "*DefaultStp%s: None\n", desc.name); + gzprintf(fp, "*StpDefaultStp%s: None\n", desc.name); + gzprintf(fp, "*Stp%s %s/%s: \"\"\n", desc.name, + "None", _("None")); + } gzprintf(fp, "*Stp%s %s/%s: \"\"\n", desc.name, "False", _("No")); gzprintf(fp, "*Stp%s %s/%s: \"\"\n", desc.name, "True", _("Yes")); break; case STP_PARAMETER_TYPE_DOUBLE: - if (desc.is_mandatory) - { - gzprintf(fp, "*DefaultStp%s: None\n", desc.name); - } + gzprintf(fp, "*DefaultStp%s: None\n", desc.name); + gzprintf(fp, "*StpDefaultStp%s: None\n", desc.name); for (i = desc.bounds.dbl.lower * 1000; i <= desc.bounds.dbl.upper * 1000 ; i += 100) { @@ -1491,11 +1741,21 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzprintf(fp, "*Stp%s None/%.3f: \"\"\n", desc.name, desc.deflt.dbl); gzprintf(fp, "*CloseUI: *Stp%s\n\n", desc.name); + + /* + * Add custom option code and value parameter... + */ + + gzprintf(fp, "*CustomStp%s True: \"pop\"\n", desc.name); + gzprintf(fp, "*ParamCustomStp%s Value/%s: 1 real %.3f %.3f\n\n", + desc.name, _("Value"), desc.bounds.dbl.lower, + desc.bounds.dbl.upper); if (!simplified) { gzprintf(fp, "*OpenUI *StpFine%s/%s %s: PickOne\n", desc.name, gettext(desc.text), _("Fine Adjustment")); gzprintf(fp, "*DefaultStpFine%s:None\n", desc.name); + gzprintf(fp, "*StpDefaultStpFine%s:None\n", desc.name); gzprintf(fp, "*StpFine%s None/0.000: \"\"\n", desc.name); for (i = 0; i < 100; i += 5) gzprintf(fp, "*StpFine%s %d/%.3f: \"\"\n", @@ -1503,15 +1763,23 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzprintf(fp, "*CloseUI: *StpFine%s\n\n", desc.name); } print_close_ui = 0; - + break; case STP_PARAMETER_TYPE_DIMENSION: if (desc.is_mandatory) - gzprintf(fp, "*DefaultStp%s: %d\n", - desc.name, desc.deflt.dimension); + { + gzprintf(fp, "*DefaultStp%s: %d\n", + desc.name, desc.deflt.dimension); + gzprintf(fp, "*StpDefaultStp%s: %d\n", + desc.name, desc.deflt.dimension); + } else - gzprintf(fp, "*Stp%s %s/%s: \"\"\n", desc.name, - "None", _("None")); + { + gzprintf(fp, "*DefaultStp%s: None\n", desc.name); + gzprintf(fp, "*StpDefaultStp%s: None\n", desc.name); + gzprintf(fp, "*Stp%s %s/%s: \"\"\n", desc.name, + "None", _("None")); + } for (i = desc.bounds.dimension.lower; i <= desc.bounds.dimension.upper; i++) { @@ -1523,6 +1791,20 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzprintf(fp, "*Stp%s %d/%.1f mm: \"\"\n", desc.name, i, ((double) i) * 25.4 / 72); } + + print_close_ui = 0; + gzprintf(fp, "*CloseUI: *Stp%s\n\n", desc.name); + + /* + * Add custom option code and value parameter... + */ + + gzprintf(fp, "*CustomStp%s True: \"pop\"\n", desc.name); + gzprintf(fp, "*ParamCustomStp%s Value/%s: 1 points %d %d\n\n", + desc.name, _("Value"), + desc.bounds.dimension.lower, + desc.bounds.dimension.upper); + break; default: break; @@ -1579,12 +1861,9 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ gzputs(fp, "*Font ZapfChancery-MediumItalic: Standard \"(001.007S)\" Standard ROM\n"); gzputs(fp, "*Font ZapfDingbats: Special \"(001.004S)\" Standard ROM\n"); - gzprintf(fp, "\n*%%End of stp-%s.%s%s\n", - driver, - GUTENPRINT_RELEASE_VERSION, - ppdext); - - gzclose(fp); + gzprintf(fp, "\n*%% End of stp-%s.%s%s%s\n", + driver, GUTENPRINT_RELEASE_VERSION, simplified ? ".sim" : "", + ppdext); stp_vars_destroy(v); return (0); @@ -1592,5 +1871,5 @@ write_ppd(const stp_printer_t *p, /* I - Printer driver */ /* - * End of "$Id: genppd.c,v 1.118 2006/05/28 16:59:03 rlk Exp $". + * End of "$Id: genppd.c,v 1.119.2.3 2007/05/29 01:47:26 rlk Exp $". */ diff --git a/src/cups/rastertoprinter.c b/src/cups/rastertoprinter.c index 626fcf9..52d3592 100644 --- a/src/cups/rastertoprinter.c +++ b/src/cups/rastertoprinter.c @@ -1,9 +1,9 @@ /* - * "$Id: rastertoprinter.c,v 1.104 2006/07/04 02:19:14 rlk Exp $" + * "$Id: rastertoprinter.c,v 1.105.2.1 2007/03/02 12:01:16 rlk Exp $" * * Gutenprint based raster filter for the Common UNIX Printing System. * - * Copyright 1993-2003 by Easy Software Products. + * Copyright 1993-2007 by Easy Software Products. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License, @@ -89,6 +89,7 @@ typedef struct int adjusted_width; int adjusted_height; int last_percent; + int shrink_to_fit; cups_page_header_t header; /* Page header from file */ } cups_image_t; @@ -219,6 +220,7 @@ print_debug_block(const stp_vars_t *v, const cups_image_t *cups) 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++) @@ -347,13 +349,13 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) switch (cups->header.cupsColorSpace) { case CUPS_CSPACE_W : - /* Olympus photo printers don't support black & white ink! */ + /* DyeSub photo printers don't support black & white ink! */ if (printer_supports_bw(v)) set_string_parameter(v, "PrintingMode", "BW"); set_string_parameter(v, "InputImageType", "Whitescale"); break; case CUPS_CSPACE_K : - /* Olympus photo printers don't support black & white ink! */ + /* DyeSub photo printers don't support black & white ink! */ if (printer_supports_bw(v)) set_string_parameter(v, "PrintingMode", "BW"); set_string_parameter(v, "InputImageType", "Grayscale"); @@ -413,6 +415,8 @@ 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"); + set_string_parameter(v, "JobMode", "Job"); validate_options(v, cups); stp_get_media_size(v, &(cups->width), &(cups->height)); @@ -437,9 +441,14 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) tmp_height = cups->bottom - cups->top; if (tmp_left < cups->left) { - cups->left_trim = cups->left - tmp_left; + if (cups->shrink_to_fit != 1) + { + cups->left_trim = cups->left - tmp_left; + tmp_left = cups->left; + } + else + cups->left_trim = 0; fprintf(stderr, "DEBUG: Gutenprint left margin %d\n", cups->left_trim); - tmp_left = cups->left; } else { @@ -450,9 +459,14 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) } if (tmp_right > cups->right) { - cups->right_trim = tmp_right - cups->right; + if (cups->shrink_to_fit != 1) + { + cups->right_trim = tmp_right - cups->right; + tmp_right = cups->right; + } + else + cups->right_trim = 0; fprintf(stderr, "DEBUG: Gutenprint right margin %d\n", cups->right_trim); - tmp_right = cups->right; } else { @@ -463,9 +477,14 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) } if (tmp_top < cups->top) { - cups->top_trim = cups->top - tmp_top; + if (cups->shrink_to_fit != 1) + { + cups->top_trim = cups->top - tmp_top; + tmp_top = cups->top; + } + else + cups->top_trim = 0; fprintf(stderr, "DEBUG: Gutenprint top margin %d\n", cups->top_trim); - tmp_top = cups->top; } else { @@ -476,9 +495,14 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) } if (tmp_bottom > cups->bottom) { - cups->bottom_trim = tmp_bottom - cups->bottom; + if (cups->shrink_to_fit != 1) + { + cups->bottom_trim = tmp_bottom - cups->bottom; + tmp_bottom = cups->bottom; + } + else + cups->bottom_trim = 0; fprintf(stderr, "DEBUG: Gutenprint bottom margin %d\n", cups->bottom_trim); - tmp_bottom = cups->bottom; } else { @@ -488,13 +512,28 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) cups->bottom = tmp_bottom; } - stp_set_width(v, cups->right - cups->left); - stp_set_height(v, cups->bottom - cups->top); - stp_set_left(v, cups->left); - stp_set_top(v, cups->top); + if (cups->shrink_to_fit == 2) + { + int t_left, t_right, t_bottom, t_top; + stp_get_imageable_area(v, &(t_left), &(t_right), &(t_bottom), &(t_top)); + stp_set_width(v, t_right - t_left); + stp_set_height(v, t_bottom - t_top); + stp_set_left(v, t_left); + stp_set_top(v, t_top); + } + else + { + stp_set_width(v, cups->right - cups->left); + stp_set_height(v, cups->bottom - cups->top); + stp_set_left(v, cups->left); + stp_set_top(v, cups->top); + } cups->right = cups->width - cups->right; - cups->width = cups->width - cups->left - cups->right; + if (cups->shrink_to_fit == 1) + cups->width = tmp_right - tmp_left; + else + cups->width = cups->width - cups->left - cups->right; cups->width = cups->header.HWResolution[0] * cups->width / 72; cups->left = cups->header.HWResolution[0] * cups->left / 72; cups->right = cups->header.HWResolution[0] * cups->right / 72; @@ -505,7 +544,10 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) cups->adjusted_width = cups->header.cupsWidth; cups->bottom = cups->height - cups->bottom; - cups->height = cups->height - cups->top - cups->bottom; + if (cups->shrink_to_fit == 1) + cups->height = tmp_bottom - tmp_top; + else + cups->height = cups->height - cups->top - cups->bottom; cups->height = cups->header.HWResolution[1] * cups->height / 72; cups->top = cups->header.HWResolution[1] * cups->top / 72; cups->bottom = cups->header.HWResolution[1] * cups->bottom / 72; @@ -546,14 +588,32 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, stp_parameter_list_t params = stp_get_parameter_list(v); int nparams = stp_parameter_list_count(params); int i; + const char *val; /* CUPS option value */ + ppd_option_t *ppd_option; + val = cupsGetOption("StpiShrinkOutput", num_options, options); + if (!val) + { + ppd_option = ppdFindOption(ppd, "StpiShrinkOutput"); + if (ppd_option) + val = ppd_option->defchoice; + } + if (val) + { + if (!strcasecmp(val, "crop")) + stp_set_int_parameter(v, "CUPSShrinkPage", 0); + else if (!strcasecmp(val, "expand")) + stp_set_int_parameter(v, "CUPSShrinkPage", 2); + else + stp_set_int_parameter(v, "CUPSShrinkPage", 1); + } + else + stp_set_int_parameter(v, "CUPSShrinkPage", 1); for (i = 0; i < nparams; i++) { const stp_parameter_t *param = stp_parameter_list_param(params, i); stp_parameter_t desc; char *ppd_option_name = stp_malloc(strlen(param->name) + 8); /* StpFineFOO\0 */ - const char *val; /* CUPS option value */ - ppd_option_t *ppd_option; stp_describe_parameter(v, param->name, &desc); if (desc.p_type == STP_PARAMETER_TYPE_DOUBLE) { @@ -565,7 +625,17 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, if (ppd_option) val = ppd_option->defchoice; } - if (val && strlen(val) > 0 && strcmp(val, "None") != 0) + if (val && !strncasecmp(val, "Custom.", 7)) + { + double dval = atof(val + 7); + + fprintf(stderr, "DEBUG: Gutenprint set float %s to %f\n", + desc.name, dval); + if (dval > desc.bounds.dbl.upper) + dval = desc.bounds.dbl.upper; + stp_set_float_parameter(v, desc.name, dval); + } + else if (val && strlen(val) > 0 && strcmp(val, "None") != 0) { double coarse_val = atof(val) * 0.001; double fine_val = 0; @@ -608,13 +678,20 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, set_string_parameter(v, desc.name, val); break; case STP_PARAMETER_TYPE_INT: + if (!strncasecmp(val, "Custom.", 7)) + val += 7; + fprintf(stderr, "DEBUG: Gutenprint set int %s to %s\n", desc.name, val); stp_set_int_parameter(v, desc.name, atoi(val)); break; case STP_PARAMETER_TYPE_DIMENSION: + if (!strncasecmp(val, "Custom.", 7)) + val += 7; + fprintf(stderr, "DEBUG: Gutenprint set dimension %s to %s\n", desc.name, val); + stp_set_dimension_parameter(v, desc.name, atoi(val)); break; case STP_PARAMETER_TYPE_BOOLEAN: @@ -979,7 +1056,7 @@ cups_errfunc(void *file, const char *buf, size_t bytes) * 'cancel_job()' - Cancel the current job... */ -void +static void cancel_job(int sig) /* I - Signal */ { (void)sig; @@ -1018,7 +1095,7 @@ throwaway_data(int amount, cups_image_t *cups) cupsRasterReadPixels(cups->ras, trash, leftover); } -stp_image_status_t +static stp_image_status_t Image_get_row(stp_image_t *image, /* I - Image */ unsigned char *data, /* O - Row */ size_t byte_limit, /* I - how many bytes in data */ @@ -1201,5 +1278,5 @@ Image_width(stp_image_t *image) /* I - Image */ /* - * End of "$Id: rastertoprinter.c,v 1.104 2006/07/04 02:19:14 rlk Exp $". + * End of "$Id: rastertoprinter.c,v 1.105.2.1 2007/03/02 12:01:16 rlk Exp $". */ |