diff options
author | Roger Leigh <rleigh@debian.org> | 2008-10-26 17:28:54 +0000 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2008-10-26 17:28:54 +0000 |
commit | 33a17feb28af2d2aeabc8c7ab5ef509ea3de15a7 (patch) | |
tree | d444cf1a245694bd049a9e6722c41b8f280ad429 /src/cups | |
parent | 9d82a443d65ea3e4e015ba6988208231fa8fdc77 (diff) |
Imported Upstream version 5.2.1
Diffstat (limited to 'src/cups')
-rw-r--r-- | src/cups/Info.plist.in | 28 | ||||
-rw-r--r-- | src/cups/Makefile.am | 84 | ||||
-rw-r--r-- | src/cups/Makefile.in | 170 | ||||
-rw-r--r-- | src/cups/cups-genppdupdate.in | 104 | ||||
-rw-r--r-- | src/cups/genppd.c | 1010 | ||||
-rw-r--r-- | src/cups/i18n.c | 481 | ||||
-rw-r--r-- | src/cups/i18n.h | 47 | ||||
-rw-r--r-- | src/cups/rastertoprinter.c | 436 | ||||
-rwxr-xr-x | src/cups/test-ppds | 17 | ||||
-rwxr-xr-x | src/cups/test-rastertogutenprint.in | 158 |
10 files changed, 1915 insertions, 620 deletions
diff --git a/src/cups/Info.plist.in b/src/cups/Info.plist.in new file mode 100644 index 0000000..c89a5dd --- /dev/null +++ b/src/cups/Info.plist.in @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleDisplayName</key> + <string>Gutenprint</string> + <key>CFBundleExecutable</key> + <string>rastertogutenprint.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@</string> + <key>CFBundleGetInfoString</key> + <string>@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@.@GUTENPRINT_MICRO_VERSION@, Copyright 1993-2008 Mike Sweet and Robert Krawitz</string> + <key>CFBundleIdentifier</key> + <string>org.cups.gutenprint</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>Gutenprint</string> + <key>CFBundlePackageType</key> + <string>BNDL</string> + <key>CFBundleShortVersionString</key> + <string>@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@.@GUTENPRINT_MICRO_VERSION@</string> + <key>CFBundleSignature</key> + <string>????</string> + <key>CFBundleVersion</key> + <string>@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@.@GUTENPRINT_MICRO_VERSION@</string> +</dict> +</plist> diff --git a/src/cups/Makefile.am b/src/cups/Makefile.am index 0331e80..c093bde 100644 --- a/src/cups/Makefile.am +++ b/src/cups/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.96 2008/04/06 01:10:52 rlk Exp $ +## $Id: Makefile.am,v 1.118 2008/09/22 03:10:45 easysw Exp $ ## Copyright (C) 2000 Roger Leigh ## ## This program is free software; you can redistribute it and/or modify @@ -45,14 +45,20 @@ endif 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 +STP_ENV= STP_MODULE_PATH=$(top_builddir)/src/main/.libs:$(top_builddir)/src/main STP_DATA_PATH=$(top_srcdir)/src/xml STP_LOCALEDIR=$(top_srcdir)/src/cups/catalog ## Programs if BUILD_TRANSLATED_CUPS_PPDS -PPD_NLS = $(PPD_NLS_1) +if BUILD_GLOBALIZED_CUPS_PPDS +PPD = ppd-global +else +PPD = $(PPD_NLS_1) +endif LINGUAS = $(ALL_LINGUAS) TRANSLATE_PPDS = -DCUPS_TRANSLATED_PPDS +else +PPD = ppd-nonls endif if BUILD_SIMPLIFIED_CUPS_PPDS @@ -86,18 +92,18 @@ commandtocanon_LDADD = $(CUPS_LIBS) commandtoepson_SOURCES = commandtoepson.c commandtoepson_LDADD = $(CUPS_LIBS) -cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c +cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c i18n.c i18n.h cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DALL_LINGUAS='"@ALL_LINGUAS@"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) -cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GENPPD_LIBS) $(GUTENPRINT_LIBS) +cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GENPPD_LIBS) $(GUTENPRINT_LIBS) @LIBICONV@ cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) -gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c i18n.c i18n.h gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DCUPS_DRIVER_INTERFACE -DALL_LINGUAS='"@ALL_LINGUAS@"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) -gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) @LIBICONV@ gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) -rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = rastertoprinter.c -rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) +rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = rastertoprinter.c i18n.c i18n.h +rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) @LIBICONV@ rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) ## Data @@ -121,8 +127,6 @@ PPD_NLS_1 = ppd-nls endif -## Rules - install-data-local: $(INSTALL_DATA_LOCAL_DEPS) if test -n "$(CUPS_PKG)" -a -n "$(INSTALL_DATA_LOCAL_DEPS)" ; then \ $(mkdir_p) $(DESTDIR)$(cups_modeldir); \ @@ -137,14 +141,24 @@ install-data-local: $(INSTALL_DATA_LOCAL_DEPS) cd ..; \ done \ fi + $(mkdir_p) "$(DESTDIR)$(localedir)" + for file in $(srcdir)/../../po/*.po; do \ + lang=`basename $$file .po`; \ + $(mkdir_p) "$(DESTDIR)$(localedir)/$$lang"; \ + $(INSTALL_DATA) $$file "$(DESTDIR)$(localedir)/$$lang/gutenprint_$$lang.po"; \ + done uninstall-local: $(INSTALL_DATA_LOCAL_DEPS) # Remove PPDs installed in new PPD location if test -z "DONT_UNINSTALL_PPDS" ; then \ if test -n "$(INSTALL_DATA_LOCAL_DEPS)" ; then \ $(RM) -fr $(DESTDIR)$(cups_modeldir)/* ; \ - fi \ + fi ; \ fi + for file in $(srcdir)/../../po/*.po; do \ + lang=`basename $$file .po`; \ + $(RM) "$(DESTDIR)$(localedir)/$$lang/gutenprint_$$lang.po"; \ + done install-data-hook: # Remove unused directories in install tree @@ -167,34 +181,47 @@ all-local: $(INSTALL_DATA_LOCAL_DEPS) ppd: ppd-stamp -ppd-stamp: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(top_srcdir)/src/main/printers.xml $(top_srcdir)/src/main/papers.xml +ppd-stamp: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(top_srcdir)/src/xml/xml-stamp $(MAKE) ppd-stamp-phony touch ppd-stamp -ppd-stamp-phony: ppd-stamp-pre ppd-nonls $(PPD_NLS) +ppd-stamp-phony: ppd-stamp-pre $(PPD) ppd-stamp-pre: -$(RM) -r ppd - -mkdir ppd -ppd-nonls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ - for language in C ; do \ - mkdir ppd/$$language ; \ - echo "$$language:" ; \ - LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/$$language ; \ +ppd-catalog: + $(mkdir_p) catalog + for file in $(srcdir)/../../po/*.po; do \ + lang=`basename $$file .po`; \ + $(mkdir_p) "catalog/$$lang"; \ + $(INSTALL_DATA) $$file "catalog/$$lang/gutenprint_$$lang.po"; \ done -ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ - wdir=`pwd` ; \ - cd $(top_builddir)/po ; \ - $(MAKE) ; \ - $(MAKE) DESTDIR= prefix=$${wdir}/catalog datadir=$${wdir}/catalog/share install - for language in `$(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ -L -c \`pwd\`/catalog/share/locale` ; do \ +ppd-nonls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ + $(mkdir_p) ppd/C + LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -l C -p ppd/C + +ppd-global: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ ppd-catalog + $(mkdir_p) ppd/Global + @echo "Global PPDs:" + LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/Global + -$(RM) -r catalog + +ppd-global-ln: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ ppd-catalog + $(mkdir_p) ppd/Global + @echo "Global PPDs (localized numbers for testing):" + LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/Global -N + -$(RM) -r catalog + +ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ ppd-catalog ppd-nonls + $(mkdir_p) ppd + for language in `$(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ -L` ; do \ mkdir ppd/$$language ; \ echo "$$language:" ; \ - LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -l $$language -p ppd/$$language -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; \ done - $(RM) -r catalog + -$(RM) -r catalog dist-hook: for dir in commands ; do \ @@ -227,3 +254,4 @@ EXTRA_DIST = \ test-ppds + diff --git a/src/cups/Makefile.in b/src/cups/Makefile.in index fd5895c..4bbd121 100644 --- a/src/cups/Makefile.in +++ b/src/cups/Makefile.in @@ -1,8 +1,8 @@ -# Makefile.in generated by automake 1.10 from Makefile.am. +# Makefile.in generated by automake 1.10.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -17,7 +17,7 @@ # Variables #export STP_MODULE_PATH = $(top_builddir)/src/main/.libs:$(top_builddir)/src/main -#export STP_DATA_PATH = $(top_srcdir)/src/main +#export STP_DATA_PATH = $(top_srcdir)/src/xml @@ -37,8 +37,8 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ - $(srcdir)/cups-genppdupdate.in \ +DIST_COMMON = README $(srcdir)/Info.plist.in $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/cups-genppdupdate.in \ $(srcdir)/test-rastertogutenprint.in \ $(top_srcdir)/scripts/global.mk COPYING @BUILD_CUPS_1_2_TRUE@cupsexec_driver_PROGRAMS = gutenprint.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@$(EXEEXT) @@ -52,7 +52,8 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ $(top_srcdir)/m4/iconv.m4 $(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/lib-prefix.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.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 @@ -60,7 +61,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/scripts/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = cups-genppdupdate test-rastertogutenprint +CONFIG_CLEAN_FILES = Info.plist cups-genppdupdate \ + test-rastertogutenprint am__installdirs = "$(DESTDIR)$(bindir)" \ "$(DESTDIR)$(cupsexec_driverdir)" \ "$(DESTDIR)$(cupsexec_filterdir)" "$(DESTDIR)$(sbindir)" \ @@ -82,7 +84,8 @@ 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 = cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-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@-i18n.$(OBJEXT) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = $(am_cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS) cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_DEPENDENCIES = \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(GUTENPRINT_LIBS) @@ -93,7 +96,8 @@ cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LINK = \ $(CFLAGS) \ $(cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS) \ $(LDFLAGS) -o $@ -am_gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.$(OBJEXT) +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@-i18n.$(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) $(GUTENPRINT_LIBS) @@ -105,7 +109,7 @@ gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LINK = \ $(gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS) \ $(LDFLAGS) -o $@ am_rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = \ - rastertoprinter.$(OBJEXT) + rastertoprinter.$(OBJEXT) i18n.$(OBJEXT) rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS = $(am_rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_OBJECTS) rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_DEPENDENCIES = \ $(am__DEPENDENCIES_1) $(GUTENPRINT_LIBS) @@ -116,7 +120,7 @@ rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LINK = $(LDFLAGS) -o $@ sbinSCRIPT_INSTALL = $(INSTALL_SCRIPT) SCRIPTS = $(noinst_SCRIPTS) $(sbin_SCRIPTS) -DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/scripts/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ @@ -183,6 +187,7 @@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DIALOG = @DIALOG@ DOXYGEN = @DOXYGEN@ +DSYMUTIL = @DSYMUTIL@ DVIPDF = @DVIPDF@ DVIPS = @DVIPS@ ECHO = @ECHO@ @@ -203,6 +208,7 @@ GIMP2_LIBS = @GIMP2_LIBS@ GIMPTOOL2_CHECK = @GIMPTOOL2_CHECK@ GLIB_MKENUMS = @GLIB_MKENUMS@ GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ GNUCFLAGS = @GNUCFLAGS@ GREP = @GREP@ GTK2_CFLAGS = @GTK2_CFLAGS@ @@ -235,6 +241,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ @@ -255,9 +262,10 @@ MAINT = @MAINT@ MAINTAINER_CFLAGS = @MAINTAINER_CFLAGS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ -MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ +NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = cups PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ @@ -284,6 +292,7 @@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ WHICH_PPDS = @WHICH_PPDS@ XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ @@ -361,8 +370,10 @@ cupsexec_filterdir = $(pkglibdir)/filter @CUPS_PPDS_AT_TOP_LEVEL_TRUE@cups_modeldir = $(pkgdatadir)/model/ @CUPS_PPDS_AT_TOP_LEVEL_TRUE@DONT_UNINSTALL_PPDS = true LOCAL_CPPFLAGS = $(GUTENPRINT_CFLAGS) $(CUPS_CFLAGS) -STP_ENV = STP_MODULE_PATH=$(top_builddir)/src/main/.libs:$(top_builddir)/src/main STP_DATA_PATH=$(top_srcdir)/src/main -@BUILD_TRANSLATED_CUPS_PPDS_TRUE@PPD_NLS = $(PPD_NLS_1) +STP_ENV = STP_MODULE_PATH=$(top_builddir)/src/main/.libs:$(top_builddir)/src/main STP_DATA_PATH=$(top_srcdir)/src/xml STP_LOCALEDIR=$(top_srcdir)/src/cups/catalog +@BUILD_GLOBALIZED_CUPS_PPDS_FALSE@@BUILD_TRANSLATED_CUPS_PPDS_TRUE@PPD = $(PPD_NLS_1) +@BUILD_GLOBALIZED_CUPS_PPDS_TRUE@@BUILD_TRANSLATED_CUPS_PPDS_TRUE@PPD = ppd-global +@BUILD_TRANSLATED_CUPS_PPDS_FALSE@PPD = ppd-nonls @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 @@ -376,16 +387,16 @@ commandtocanon_SOURCES = commandtocanon.c commandtocanon_LDADD = $(CUPS_LIBS) commandtoepson_SOURCES = commandtoepson.c commandtoepson_LDADD = $(CUPS_LIBS) -cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c +cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c i18n.c i18n.h cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DALL_LINGUAS='"@ALL_LINGUAS@"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) -cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GENPPD_LIBS) $(GUTENPRINT_LIBS) +cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GENPPD_LIBS) $(GUTENPRINT_LIBS) @LIBICONV@ cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) -gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = genppd.c i18n.c i18n.h gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_CFLAGS = -DCUPS_DRIVER_INTERFACE -DALL_LINGUAS='"@ALL_LINGUAS@"' $(BUILD_SIMPLE_PPDS) $(TRANSLATE_PPDS) -gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) @LIBICONV@ gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) -rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = rastertoprinter.c -rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) +rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_SOURCES = rastertoprinter.c i18n.c i18n.h +rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDADD = $(CUPS_LIBS) $(GUTENPRINT_LIBS) @LIBICONV@ rastertogutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@_LDFLAGS = $(STATIC_LDOPTS) @BUILD_CUPS_TRUE@CUPS_PKG = calibrate.ppm @BUILD_CUPS_TRUE@CUPS_CONF = command.types @@ -437,6 +448,8 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +Info.plist: $(top_builddir)/config.status $(srcdir)/Info.plist.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ cups-genppdupdate: $(top_builddir)/config.status $(srcdir)/cups-genppdupdate.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ test-rastertogutenprint: $(top_builddir)/config.status $(srcdir)/test-rastertogutenprint.in @@ -450,8 +463,8 @@ install-binPROGRAMS: $(bin_PROGRAMS) || test -f $$p1 \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done @@ -478,8 +491,8 @@ install-cupsexec_driverPROGRAMS: $(cupsexec_driver_PROGRAMS) || 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; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(cupsexec_driverPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(cupsexec_driverdir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(cupsexec_driverPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(cupsexec_driverdir)/$$f" || exit 1; \ else :; fi; \ done @@ -506,8 +519,8 @@ install-cupsexec_filterPROGRAMS: $(cupsexec_filter_PROGRAMS) || test -f $$p1 \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(cupsexec_filterPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(cupsexec_filterdir)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(cupsexec_filterPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(cupsexec_filterdir)/$$f" || exit 1; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(cupsexec_filterPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(cupsexec_filterdir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(cupsexec_filterPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(cupsexec_filterdir)/$$f" || exit 1; \ else :; fi; \ done @@ -534,8 +547,8 @@ install-sbinPROGRAMS: $(sbin_PROGRAMS) || test -f $$p1 \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(sbindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(sbinPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(sbindir)/$$f" || exit 1; \ else :; fi; \ done @@ -601,7 +614,10 @@ distclean-compile: @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)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.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)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i18n.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rastertoprinter.Po@am__quote@ .c.o: @@ -639,6 +655,20 @@ cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj: ge @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` +cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.o: i18n.c +@am__fastdepCC_TRUE@ $(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@-i18n.o -MD -MP -MF $(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Tpo -c -o cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.o `test -f 'i18n.c' || echo '$(srcdir)/'`i18n.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Tpo $(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i18n.c' object='cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.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@-i18n.o `test -f 'i18n.c' || echo '$(srcdir)/'`i18n.c + +cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.obj: i18n.c +@am__fastdepCC_TRUE@ $(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@-i18n.obj -MD -MP -MF $(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Tpo -c -o cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.obj `if test -f 'i18n.c'; then $(CYGPATH_W) 'i18n.c'; else $(CYGPATH_W) '$(srcdir)/i18n.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Tpo $(DEPDIR)/cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i18n.c' object='cups_genppd_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.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@-i18n.obj `if test -f 'i18n.c'; then $(CYGPATH_W) 'i18n.c'; else $(CYGPATH_W) '$(srcdir)/i18n.c'; fi` + gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.o: genppd.c @am__fastdepCC_TRUE@ $(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@ mv -f $(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Tpo $(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.Po @@ -653,6 +683,20 @@ gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-genppd.obj: gen @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` +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.o: i18n.c +@am__fastdepCC_TRUE@ $(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@-i18n.o -MD -MP -MF $(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Tpo -c -o gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.o `test -f 'i18n.c' || echo '$(srcdir)/'`i18n.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Tpo $(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i18n.c' object='gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.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@-i18n.o `test -f 'i18n.c' || echo '$(srcdir)/'`i18n.c + +gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.obj: i18n.c +@am__fastdepCC_TRUE@ $(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@-i18n.obj -MD -MP -MF $(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Tpo -c -o gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.obj `if test -f 'i18n.c'; then $(CYGPATH_W) 'i18n.c'; else $(CYGPATH_W) '$(srcdir)/i18n.c'; fi` +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Tpo $(DEPDIR)/gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='i18n.c' object='gutenprint_@GUTENPRINT_MAJOR_VERSION@_@GUTENPRINT_MINOR_VERSION@-i18n.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@-i18n.obj `if test -f 'i18n.c'; then $(CYGPATH_W) 'i18n.c'; else $(CYGPATH_W) '$(srcdir)/i18n.c'; fi` + mostlyclean-libtool: -rm -f *.lo @@ -698,8 +742,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS @@ -711,8 +755,8 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ @@ -722,13 +766,12 @@ ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ - here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique @@ -1003,14 +1046,24 @@ install-data-local: $(INSTALL_DATA_LOCAL_DEPS) cd ..; \ done \ fi + $(mkdir_p) "$(DESTDIR)$(localedir)" + for file in $(srcdir)/../../po/*.po; do \ + lang=`basename $$file .po`; \ + $(mkdir_p) "$(DESTDIR)$(localedir)/$$lang"; \ + $(INSTALL_DATA) $$file "$(DESTDIR)$(localedir)/$$lang/gutenprint_$$lang.po"; \ + done uninstall-local: $(INSTALL_DATA_LOCAL_DEPS) # Remove PPDs installed in new PPD location if test -z "DONT_UNINSTALL_PPDS" ; then \ if test -n "$(INSTALL_DATA_LOCAL_DEPS)" ; then \ $(RM) -fr $(DESTDIR)$(cups_modeldir)/* ; \ - fi \ + fi ; \ fi + for file in $(srcdir)/../../po/*.po; do \ + lang=`basename $$file .po`; \ + $(RM) "$(DESTDIR)$(localedir)/$$lang/gutenprint_$$lang.po"; \ + done install-data-hook: # Remove unused directories in install tree @@ -1033,34 +1086,47 @@ all-local: $(INSTALL_DATA_LOCAL_DEPS) ppd: ppd-stamp -ppd-stamp: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(top_srcdir)/src/main/printers.xml $(top_srcdir)/src/main/papers.xml +ppd-stamp: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ $(top_srcdir)/src/xml/xml-stamp $(MAKE) ppd-stamp-phony touch ppd-stamp -ppd-stamp-phony: ppd-stamp-pre ppd-nonls $(PPD_NLS) +ppd-stamp-phony: ppd-stamp-pre $(PPD) ppd-stamp-pre: -$(RM) -r ppd - -mkdir ppd -ppd-nonls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ - for language in C ; do \ - mkdir ppd/$$language ; \ - echo "$$language:" ; \ - LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/$$language ; \ +ppd-catalog: + $(mkdir_p) catalog + for file in $(srcdir)/../../po/*.po; do \ + lang=`basename $$file .po`; \ + $(mkdir_p) "catalog/$$lang"; \ + $(INSTALL_DATA) $$file "catalog/$$lang/gutenprint_$$lang.po"; \ done -ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ - wdir=`pwd` ; \ - cd $(top_builddir)/po ; \ - $(MAKE) ; \ - $(MAKE) DESTDIR= prefix=$${wdir}/catalog datadir=$${wdir}/catalog/share install - for language in `$(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ -L -c \`pwd\`/catalog/share/locale` ; do \ +ppd-nonls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ + $(mkdir_p) ppd/C + LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -l C -p ppd/C + +ppd-global: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ ppd-catalog + $(mkdir_p) ppd/Global + @echo "Global PPDs:" + LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/Global + -$(RM) -r catalog + +ppd-global-ln: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ ppd-catalog + $(mkdir_p) ppd/Global + @echo "Global PPDs (localized numbers for testing):" + LC_ALL= LANG= LANGUAGE= $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -p ppd/Global -N + -$(RM) -r catalog + +ppd-nls: cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ ppd-catalog ppd-nonls + $(mkdir_p) ppd + for language in `$(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ -L` ; do \ mkdir ppd/$$language ; \ echo "$$language:" ; \ - LC_ALL=$$language LANG=$$language LANGUAGE=$$language $(STP_ENV) ./cups-genppd.@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@ @WHICH_PPDS@ -l $$language -p ppd/$$language -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; \ done - $(RM) -r catalog + -$(RM) -r catalog dist-hook: for dir in commands ; do \ diff --git a/src/cups/cups-genppdupdate.in b/src/cups/cups-genppdupdate.in index 9892ce0..48324ee 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.42 2008/04/12 01:20:33 rlk Exp $ +# $Id: cups-genppdupdate.in,v 1.53 2008/09/22 11:04:24 rlk Exp $ # Update CUPS PPDs for Gutenprint queues. # Copyright (C) 2002-2003 Roger Leigh (rleigh@debian.org) # @@ -20,8 +20,6 @@ use strict; use Getopt::Std; use Fcntl qw(:mode); -use File::Temp qw(:POSIX); -use File::Copy qw(mv); sub parse_options (); sub update_ppd ($); # Original PPD filename @@ -43,6 +41,7 @@ our $opt_o; # Output directory our $opt_r; # Gutenprint version our $opt_i; # Interactive our $opt_f; # Force upgrade +our $opt_l; # Language my $debug = 0; my $verbose = 0; # Verbose output @@ -64,6 +63,7 @@ my $updated_ppd_count = 0; my $skipped_ppd_count = 0; my $failed_ppd_count = 0; my $exit_after_parse_args = 0; +my @languages = qw(Global C @ALL_LINGUAS@); my $serverdir = "@cups_conf_serverbin@"; my $driver_bin = "$serverdir/driver/gutenprint.$version"; @@ -170,7 +170,11 @@ if (!$quiet || $verbose) { print STDOUT "No Gutenprint PPD files to update.\n"; } elsif ($updated_ppd_count > 0) { my $plural = $updated_ppd_count == 1 ? "" : "s"; - print STDOUT "Updated $updated_ppd_count PPD file${plural}. Restart cupsd for the changes to take effect.\n"; + print STDOUT "Updated $updated_ppd_count PPD file${plural}."; + if (!defined $opt_o || $opt_o ne "") { + print STDOUT "Restart cupsd for the changes to take effect."; + } + print STDOUT "\n"; } else { if ($failed_ppd_count > 0) { print STDOUT "Failed to update any PPD files\n"; @@ -198,6 +202,10 @@ sub HELP_MESSAGE($;$$$) { print $fh " -r version Use PPD files for Gutenprint major.minor version.\n"; print $fh " -f Ignore new PPD file safety checks.\n"; print $fh " -i Prompt (interactively) for each PPD file.\n"; + print $fh " -l language Language choice (Gutenprint 5.1 or below).\n"; + print $fh " Choices: " . join(" ", @languages) . "\n"; + print $fh " Or -loriginal to preserve original language\n"; + print $fh " with Gutenprint 5.2 or above\n"; exit(0); } @@ -216,7 +224,7 @@ sub help() { } sub parse_options () { - if (!getopts('d:hnqs:vNo:p:P:r:if')) { + if (!getopts('d:hnqs:vNo:p:P:r:ifl:')) { help(); } if ($opt_n) { @@ -251,6 +259,7 @@ sub parse_options () { if (-d $opt_s) { $ppd_base_dir = "$opt_s"; $driver_bin = ""; + $use_static_ppd = "yes"; } else { die "$opt_s: invalid directory: $!\n"; } @@ -264,6 +273,7 @@ sub parse_options () { $file_version = "\"$version"; if (-x $driver_bin) { $driver_version = `$driver_bin VERSION`; + $use_static_ppd = "no"; chomp $driver_version; $file_version = "\"$driver_version\"\$"; } elsif (! -d $ppd_base_dir && ! -l $ppd_base_dir) { @@ -276,6 +286,7 @@ sub parse_options () { $ppd_base_dir = "$opt_s"; $driver_bin = ""; $driver_version = ""; + $use_static_ppd = "yes"; } else { die "$opt_s: invalid directory: $!\n"; @@ -292,6 +303,9 @@ sub parse_options () { if ($opt_P) { if (-x $opt_P) { $driver_bin = "$opt_P"; + $driver_version = `$driver_bin VERSION`; + chomp $driver_version; + $use_static_ppd = "no"; } else { die "$opt_P: invalid executable: $!\n"; @@ -300,6 +314,10 @@ sub parse_options () { if ($opt_h) { help(); } + if ($opt_l && lc $opt_l ne "original" && ! grep { $_ eq $opt_l } @languages) { + print STDERR "Unknown language '$opt_l'\n"; + help(); + } if ($opt_i) { $interactive = 1; } @@ -326,7 +344,9 @@ sub get_ppd_fh($$$$$) { } my ($url); my (@url_list); - if ($locale) { + if (((defined $opt_r && $opt_r < 5.2) || + (defined $opt_l && $opt_l ne "")) && + $locale ne "") { if ($region) { push @url_list, "gutenprint.$version://$driver/$simplified/${locale}_${region}"; } @@ -393,11 +413,13 @@ sub update_ppd ($) { my ($lingo) = ""; my ($region) = ""; my ($valid) = 0; + my ($orig_locale) = ""; while (<ORIG>) { if (/\*StpLocale:/) { - ($locale) = m/^\*StpLocale:\s\"*(.*)\"$/; + ($locale) = m/^\*StpLocale:\s*\"(.*)\"$/; + $orig_locale = $locale; $valid = 1; - } elsif (/\*LanguageVersion/) { + } elsif (/^\*LanguageVersion/) { ($lingo) = m/^\*LanguageVersion:\s*(.*)$/; } elsif (/^\*StpDriverName:/ ) { ($driver) = m/^\*StpDriverName:\s*\"(.*)\"$/; @@ -421,18 +443,26 @@ sub update_ppd ($) { # print STDERR "Skipping $ppd_source_filename: not a Gutenprint PPD file\n"; return -1; } + if (defined $opt_l && $opt_l ne "" && lc $opt_l ne "original") { + $locale = $opt_l; + $orig_locale = $locale; + } if ($debug & 2) { print "Gutenprint Filename: $filename\n"; - print "Locale: $locale\n"; + if ($opt_l) { + print "Locale: $locale (from -l)\n"; + } else { + print "Locale: $locale\n"; + } print "Language: $lingo\n"; print "Driver: $driver\n"; } if ($locale) { # Split into the language and territory. - ($locale, $region) = split(/-/, $locale); + ($locale, $region) = split(/_/, $locale); } else { # Split into the language and territory. - ($locale, $region) = split(/-/, $lingo); + ($locale, $region) = split(/_/, $lingo); # Convert language into language code. $locale = $languagemappings{"\L$lingo"}; if (!defined($locale)) { @@ -475,7 +505,7 @@ sub update_ppd ($) { seek(ORIG, 0, 0); - my ($odt, $oopt, $ores, $odef) = get_ppd_data(ORIG, 1, 0, 0, 1, 0); + my ($odt, $oopt, $ores, $odef) = get_ppd_data(ORIG, 1, 0, 1, 1, 0); my ($ndt, $nopt, $nres, $ndef, $source_data) = get_ppd_data($source_fd, 1, 1, 1, 1, 1); # Close original and temporary files... @@ -492,6 +522,14 @@ sub update_ppd ($) { my %new_defaults = %$ndef; my %options = %$nopt; my %resolution_map = %$nres; + my %old_resolution_map = reverse %$ores; + + # Store previous language in the PPD file so that -l original works + # correctly. + + if ($orig_locale ne "") { + $source_data =~ s/(\*StpLocale:\s*\")(.*)(\")/$1$orig_locale$3/; + } if ($debug & 4) { print "Options (Old->New Default Type):\n"; @@ -518,7 +556,13 @@ sub update_ppd ($) { if (keys %resolution_map) { print "Resolution Map:\n"; foreach (sort keys %resolution_map) { - print "$_: $resolution_map{$_}\n"; + print " $_: $resolution_map{$_}\n"; + } + } + if (keys %old_resolution_map) { + print "Old Resolution Map:\n"; + foreach (sort keys %old_resolution_map) { + print " $_: $old_resolution_map{$_}\n"; } } print "Non-UI Defaults:\n"; @@ -576,16 +620,31 @@ default_loop: # Check the old setting is valid foreach my $opt (@{$options{$option}}) { my $def_option = $default_option_value; - if (($def_option eq $opt) || - ($option eq "Resolution" && - (defined $resolution_map{$default_option_value}) && - ($def_option = $resolution_map{$default_option_value}) eq $opt)) { # Valid option - # Set the option in the new PPD - $source_data =~ s/\*($default_option).*/*$1:$def_option/m; - if ($verbose) { - print "$ppd_source_filename: Set *$default_option to $def_option\n"; + my $odef_option = $def_option; + if ($option eq "Resolution" && + defined $old_resolution_map{$def_option}) { + if ($debug & 4) { + print "Intermapping old resolution $def_option to $old_resolution_map{$def_option}\n"; + } + $def_option = $old_resolution_map{$def_option}; + } + my @dopts = ($def_option); + if ($def_option ne $odef_option) { + push @dopts, $odef_option; + } + + foreach my $dopt (@dopts) { + if (($dopt eq $opt) || + ($option eq "Resolution" && + (defined $resolution_map{$dopt}) && + ($dopt = $resolution_map{$dopt}) eq $opt)) { # Valid option + # Set the option in the new PPD + $source_data =~ s/^\*($default_option).*/*$1:$dopt/m; + if ($verbose) { + print "$ppd_source_filename: Set *$default_option to $dopt\n"; + } + next default_loop; } - next default_loop; } } warn "Warning: $ppd_source_filename: Invalid option: *$default_option: $defaults{$default_option}. Using default setting $new_defaults{$default_option}.\n"; @@ -664,6 +723,7 @@ sub find_ppd ($$$$) { push @lingos, "C/"; } push @lingos, "en/", ""; + push @lingos, "Global/"; my (@bases); push @bases, "stp-${drivername}.$version${simplified}"; push @bases, "${drivername}.$version${simplified}"; diff --git a/src/cups/genppd.c b/src/cups/genppd.c index 8df934f..2325fbd 100644 --- a/src/cups/genppd.c +++ b/src/cups/genppd.c @@ -1,9 +1,9 @@ /* - * "$Id: genppd.c,v 1.142 2008/04/06 21:16:08 rlk Exp $" + * "$Id: genppd.c,v 1.170 2008/09/25 23:41:00 rlk Exp $" * * PPD file generation program for the CUPS drivers. * - * Copyright 1993-2007 by Easy Software Products and Robert Krawitz. + * Copyright 1993-2008 by Mike Sweet 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 as published by the Free @@ -32,7 +32,6 @@ * 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. */ @@ -80,26 +79,18 @@ static const char *gzext = ""; #include <cups/cups.h> #include <cups/raster.h> -#include <gutenprint/gutenprint.h> -#include <gutenprint/gutenprint-intl.h> +#include "i18n.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. - * - * As of Gutenprint 5.0.2 and 5.1.4, *always* use the compliant names. - * OS X Leopard seems to be very unhappy if there are invalid resolution - * names. We've added a mapping between the invalid names and the - * valid names so that genppdupdate knows how to translate the names. + * Some applications use the XxYdpi tags rather than the actual + * hardware resolutions to decide what resolution to print at. Some + * applications get very unhappy if the vertical resolution exceeds + * a certain amount. Some of those applications even get very happy if + * the PPD file even contains a resolution that exceeds that limit. + * Feh. */ - -#if 0 -#if defined(CUPS_DRIVER_INTERFACE) || (STP_MAJOR_VERSION > 5) || (STP_MAJOR_VERSION == 5 && STP_MINOR_VERSION > 0) -#define USE_COMPLIANT_RESOLUTIONS 1 -#endif -#endif +#define MAXIMUM_SAFE_PPD_Y_RESOLUTION (720) +#define MAXIMUM_SAFE_PPD_X_RESOLUTION (1500) /* * Note: @@ -109,6 +100,7 @@ static const char *gzext = ""; */ int cups_ppd_ps_level = CUPS_PPD_PS_LEVEL; +int localize_numbers = 0; /* * File handling stuff... @@ -140,20 +132,27 @@ const char *special_options[] = NULL }; +/* + * TRANSLATORS: + * Please keep these translated names SHORT. The number of bytes in + * the parameter class name plus the number of bytes in the parameter + * name must not exceed 38 BYTES (not characters!) + */ + const char *parameter_class_names[] = { - N_("Printer Features"), - N_("Output Control") + _("Printer Features"), + _("Output Control") }; const char *parameter_level_names[] = { - N_("Common"), - N_("Extra 1"), - N_("Extra 2"), - N_("Extra 3"), - N_("Extra 4"), - N_("Extra 5") + _("Common"), + _("Extra 1"), + _("Extra 2"), + _("Extra 3"), + _("Extra 4"), + _("Extra 5") }; @@ -173,47 +172,18 @@ 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); + stp_parameter_level_t p_level, + const char *language, stp_string_list_t *po); static void print_group_open(gzFile fp, stp_parameter_class_t p_class, - stp_parameter_level_t p_level); + stp_parameter_level_t p_level, + const char *language, stp_string_list_t *po); 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... @@ -274,14 +244,12 @@ cat_ppd(int argc, char **argv) /* I - Driver URI */ int port; /* URI port (unused) */ http_uri_status_t status; /* URI decode status */ const stp_printer_t *p; /* Printer driver */ - const char *lang = "C"; + const char *lang = NULL; 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), @@ -306,24 +274,6 @@ cat_ppd(int argc, char **argv) /* I - Driver URI */ *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); @@ -359,10 +309,6 @@ list_ppds(const char *argv0) /* I - Name of program */ 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 ++; @@ -376,55 +322,27 @@ list_ppds(const char *argv0) /* I - Name of program */ !strcmp(stp_printer_get_family(printer), "raw")) continue; - printf("\"%s://%s/expert/%s\" " + printf("\"%s://%s/expert\" " "%s " "\"%s\" " "\"%s" CUPS_PPD_NICKNAME_STRING VERSION "\" " "\"\"\n", /* No IEEE-1284 Device ID yet */ - scheme, stp_printer_get_driver(printer), "C", + scheme, stp_printer_get_driver(printer), "en", stp_printer_get_manufacturer(printer), stp_printer_get_long_name(printer)); #ifdef GENERATE_SIMPLIFIED_PPDS - printf("\"%s://%s/simple/%s\" " + printf("\"%s://%s/simple\" " "%s " "\"%s\" " "\"%s" CUPS_PPD_NICKNAME_STRING VERSION " Simplified\" " "\"\"\n", /* No IEEE-1284 Device ID yet */ - scheme, stp_printer_get_driver(printer), "C", + scheme, stp_printer_get_driver(printer), "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); @@ -460,7 +378,7 @@ main(int argc, /* I - Number of command-line arguments */ for (;;) { - if ((i = getopt(argc, argv, "23hvqc:p:l:LMVd:sa")) == -1) + if ((i = getopt(argc, argv, "23hvqc:p:l:LMVd:saN")) == -1) break; switch (i) @@ -482,12 +400,7 @@ 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 -# endif + fputs("ERROR: -c option no longer supported!\n", stderr); break; case 'p': prefix = optarg; @@ -513,9 +426,12 @@ main(int argc, /* I - Number of command-line arguments */ case 'a': which_ppds = 3; break; + case 'N': + localize_numbers = !localize_numbers; + break; case 'V': printf("cups-genppd version %s, " - "Copyright 1993-2006 by Easy Software Products and Robert Krawitz.\n\n", + "Copyright 1993-2008 by Michael R Sweet 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); @@ -527,20 +443,7 @@ main(int argc, /* I - Number of command-line arguments */ "This program is distributed in the hope that it will be useful,\n" "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"); - 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" - " Attn: CUPS Licensing Information\n" - " Easy Software Products\n" - " 44141 Airport View Drive, Suite 204\n" - " Hollywood, Maryland 20636-3111 USA\n" - "\n" - " Voice: (301) 373-9603\n" - " EMail: cups-info@cups.org\n" - " WWW: http://www.cups.org\n"); + "GNU General Public License for more details.\n"); exit(EXIT_SUCCESS); break; default: @@ -568,17 +471,8 @@ main(int argc, /* I - Number of command-line arguments */ stp_init(); - /* - * Set the language... - */ - -# ifdef ENABLE_NLS langs = getlangs(); - if (language) - set_language(language); -# endif /* ENABLE_NLS */ - /* * Print lists */ @@ -752,7 +646,6 @@ help(void) " -V Show version information and defaults.\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" " -d prefix Embed directory prefix in PPD file.\n" @@ -771,9 +664,9 @@ help(void) void usage(void) { - puts("Usage: cups-genppd [-c localedir] " + puts("Usage: cups-genppd " "[-l locale] [-p prefix] [-s | -a] [-q] [-v] models...\n" - " cups-genppd -L [-c localedir]\n" + " cups-genppd -L\n" " cups-genppd -M [-v]\n" " cups-genppd -h\n" " cups-genppd -V\n"); @@ -833,7 +726,6 @@ printmodels(int verbose) /* I - Verbosity level */ * 'getlangs()' - Get a list of available translations. */ -#ifdef ENABLE_NLS char ** /* O - Array of languages */ getlangs(void) { @@ -867,69 +759,6 @@ getlangs(void) return (langs); } -/* - * '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) - { - 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; - } - } - } - -# 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); - } - -# ifdef DEBUG - fprintf(stderr, "DEBUG: bound textdomain: %s under %s\n", - PACKAGE, baselocaledir); -# endif /* DEBUG */ - - 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 */ /* * 'is_special_option()' - Determine if an option should be grouped. @@ -948,6 +777,57 @@ is_special_option(const char *name) /* I - Option name */ return 0; } +static size_t +bytelen(const char *buffer) +{ + size_t answer = 0; + while (*buffer++ != '\0') + answer++; + return answer; +} + +static void +print_group( + gzFile fp, /* I - File to write to */ + const char *what, + stp_parameter_class_t p_class, /* I - Option class */ + stp_parameter_level_t p_level, /* I - Option level */ + const char *language, /* I - Language */ + stp_string_list_t *po) /* I - Message catalog */ +{ + char buf[64]; + const char *class = stp_i18n_lookup(po, parameter_class_names[p_class]); + const char *level = stp_i18n_lookup(po, parameter_level_names[p_level]); + size_t bytes = bytelen(class) + bytelen(level); + snprintf(buf, 40, "%s%s%s", class, bytes < 39 ? " " : "", level); + gzprintf(fp, "*%sGroup: C%dL%d/%s\n", what, p_class, p_level, buf); + if (language && !strcmp(language, "C") && !strcmp(what, "Open")) + { + char **all_langs = getlangs();/* All languages */ + const char *lang; + int langnum; + + for (langnum = 0; all_langs[langnum]; langnum ++) + { + stp_string_list_t *altpo; + + lang = all_langs[langnum]; + + if (!strcmp(lang, "C") || !strcmp(lang, "en")) + continue; + if ((altpo = stp_i18n_load(lang)) != NULL) + { + class = stp_i18n_lookup(altpo, parameter_class_names[p_class]); + level = stp_i18n_lookup(altpo, parameter_level_names[p_level]); + bytes = bytelen(class) + bytelen(level); + snprintf(buf, 40, "%s%s%s", class, bytes < 39 ? " " : "", level); + gzprintf(fp, "*%s.Translation C%dL%d/%s: \"\"\n", + lang, p_class, p_level, buf); + } + } + } + gzputs(fp, "\n"); +} /* * 'print_group_close()' - Close a UI group. @@ -957,11 +837,11 @@ 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 */ + stp_parameter_level_t p_level, /* I - Option level */ + const char *language, /* I - language */ + stp_string_list_t *po) /* I - Message catalog */ { - gzprintf(fp, "*CloseGroup: %s %s\n\n", - gettext(parameter_class_names[p_class]), - gettext(parameter_level_names[p_level])); + print_group(fp, "Close", p_class, p_level, NULL, NULL); } @@ -973,11 +853,11 @@ 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 */ + stp_parameter_level_t p_level, /* I - Option level */ + const char *language, /* I - language */ + stp_string_list_t *po) /* I - Message catalog */ { - gzprintf(fp, "*OpenGroup: %s %s\n\n", - gettext(parameter_class_names[p_class]), - gettext(parameter_level_names[p_level])); + print_group(fp, "Open", p_class, p_level, language ? language : "C", po); } @@ -1020,6 +900,11 @@ write_ppd( int printer_is_color = 0; int maximum_level = simplified ? STP_PARAMETER_LEVEL_BASIC : STP_PARAMETER_LEVEL_ADVANCED4; + char *default_resolution = NULL; /* Default resolution mapped name */ + stp_string_list_t *resolutions = stp_string_list_create(); + char **all_langs = getlangs();/* All languages */ + stp_string_list_t *po = stp_i18n_load(language); + /* Message catalog */ /* @@ -1039,9 +924,12 @@ write_ppd( * Write a standard header... */ +#undef _ +#define _(x) stp_i18n_lookup(po, x) + gzputs(fp, "*PPD-Adobe: \"4.3\"\n"); gzputs(fp, "*% PPD file for CUPS/Gutenprint.\n"); - gzputs(fp, "*% Copyright 1993-2006 by Easy Software Products and Robert Krawitz.\n"); + gzputs(fp, "*% Copyright 1993-2008 by Mike Sweet 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"); @@ -1062,8 +950,10 @@ write_ppd( * Use the English name of your language here, e.g. "Swedish" instead of * "Svenska". */ gzprintf(fp, "*LanguageVersion: %s\n", _("English")); - /* TRANSLATORS: Specify PPD translation encoding e.g. ISOLatin1 */ - gzprintf(fp, "*LanguageEncoding: %s\n", _("ISOLatin1")); + if (language) + gzputs(fp, "*LanguageEncoding: UTF-8\n"); + else + gzputs(fp, "*LanguageEncoding: ISOLatin1\n"); /* * Strictly speaking, the PCFileName attribute should be a 12 character @@ -1080,13 +970,13 @@ write_ppd( /* * The Product attribute specifies the string returned by the PostScript * interpreter. The last one will appear in the CUPS "product" field, - * while all instances are available as attributes. + * while all instances are available as attributes. Rather than listing + * the PostScript interpreters we might encounter, we instead just list + * a single product line with the "long name" to be compatible with other + * CUPS-based drivers. (This is a change from Gutenprint 5.0 and earlier) */ - gzputs(fp, "*Product: \"(AFPL Ghostscript)\"\n"); - gzputs(fp, "*Product: \"(GNU Ghostscript)\"\n"); - gzputs(fp, "*Product: \"(ESP Ghostscript)\"\n"); - gzputs(fp, "*Product: \"(GPL Ghostscript)\"\n"); + gzprintf(fp, "*Product: \"(%s)\"\n", long_name); /* * The ModelName attribute now provides the long name rather than the @@ -1112,18 +1002,7 @@ write_ppd( if (cups_ppd_ps_level == 2) gzputs(fp, "*PSVersion: \"(2017.000) 550\"\n"); else - { - gzputs(fp, "*PSVersion: \"(3010.000) 651\"\n"); - gzputs(fp, "*PSVersion: \"(3010.000) 652\"\n"); - gzputs(fp, "*PSVersion: \"(3010.000) 653\"\n"); - gzputs(fp, "*PSVersion: \"(3010.000) 704\"\n"); - gzputs(fp, "*PSVersion: \"(3010.000) 705\"\n"); - gzputs(fp, "*PSVersion: \"(3010.000) 707\"\n"); - gzputs(fp, "*PSVersion: \"(3010.000) 800\"\n"); - gzputs(fp, "*PSVersion: \"(3010.000) 815\"\n"); - gzputs(fp, "*PSVersion: \"(3010.000) 850\"\n"); - gzputs(fp, "*PSVersion: \"(3010.000) 81501\"\n"); - } + gzputs(fp, "*PSVersion: \"(3010.000) 0\"\n"); gzprintf(fp, "*LanguageLevel: \"%d\"\n", cups_ppd_ps_level); /* Set Job Mode to "Job" as this enables the Duplex option */ @@ -1154,12 +1033,39 @@ write_ppd( gzputs(fp, "*LandscapeOrientation: Plus90\n"); gzputs(fp, "*TTRasterizer: Type42\n"); - gzputs(fp, "*cupsVersion: 1.1\n"); - gzprintf(fp, "*cupsModelNumber: \"0\"\n"); + gzputs(fp, "*cupsVersion: 1.2\n"); gzputs(fp, "*cupsManualCopies: True\n"); gzprintf(fp, "*cupsFilter: \"application/vnd.cups-raster 100 rastertogutenprint.%s\"\n", GUTENPRINT_RELEASE_VERSION); if (strcasecmp(manufacturer, "EPSON") == 0) gzputs(fp, "*cupsFilter: \"application/vnd.cups-command 33 commandtoepson\"\n"); + if (!language) + { + /* + * Generate globalized PPDs when POSIX language is requested... + */ + + const char *prefix = "*cupsLanguages: \""; + + for (i = 0; all_langs[i]; i ++) + { + if (!strcmp(all_langs[i], "C") || !strcmp(all_langs[i], "en")) + continue; + + gzprintf(fp, "%s%s", prefix, all_langs[i]); + prefix = " "; + } + + if (!strcmp(prefix, " ")) + gzputs(fp, "\"\n"); + } + + /* Macintosh color management */ + gzputs(fp, "*cupsICCProfile Gray../Grayscale: \"/System/Library/ColorSync/Profiles/sRGB Profile.icc\"\n"); + gzputs(fp, "*cupsICCProfile RGB../Color: \"/System/Library/ColorSync/Profiles/sRGB Profile.icc\"\n"); + gzputs(fp, "*cupsICCProfile CMYK../Color: \"/System/Library/ColorSync/Profiles/Generic CMYK Profile.icc\"\n"); + gzputs(fp, "*APSupportsCustomColorMatching: true\n"); + gzputs(fp, "*APCustomColorMatchingProfile: sRGB\n"); + gzputs(fp, "\n"); gzprintf(fp, "*StpDriverName: \"%s\"\n", driver); gzprintf(fp, "*StpDriverModelFamily: \"%d_%s\"\n", model, family); @@ -1223,7 +1129,7 @@ write_ppd( top = 0; the_papers[cur_opt].name = opt->name; - the_papers[cur_opt].text = opt->text; + the_papers[cur_opt].text = stp_i18n_lookup(po, opt->text); the_papers[cur_opt].width = width; the_papers[cur_opt].height = height; the_papers[cur_opt].left = left; @@ -1242,7 +1148,8 @@ write_ppd( gzprintf(fp, "*VariablePaperSize: %s\n\n", variable_sizes ? "true" : "false"); - gzputs(fp, "*OpenUI *PageSize: PickOne\n"); + gzprintf(fp, "*OpenUI *PageSize/%s: PickOne\n", _("Media Size")); + gzputs(fp, "*OPOptionHints PageSize: \"dropdown\"\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *PageSize\n"); gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, desc.p_type, desc.is_mandatory, @@ -1257,7 +1164,8 @@ write_ppd( } gzputs(fp, "*CloseUI: *PageSize\n\n"); - gzputs(fp, "*OpenUI *PageRegion: PickOne\n"); + gzprintf(fp, "*OpenUI *PageRegion/%s: PickOne\n", _("Media Size")); + gzputs(fp, "*OPOptionHints PageRegion: \"dropdown\"\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *PageRegion\n"); gzprintf(fp, "*DefaultPageRegion: %s\n", desc.deflt.str); gzprintf(fp, "*StpDefaultPageRegion: %s\n", desc.deflt.str); @@ -1293,8 +1201,7 @@ write_ppd( if (variable_sizes) { - stp_get_size_limit(v, &max_width, &max_height, - &min_width, &min_height); + stp_get_size_limit(v, &max_width, &max_height, &min_width, &min_height); stp_set_string_parameter(v, "PageSize", "Custom"); stp_get_media_size(v, &width, &height); stp_get_maximum_imageable_area(v, &left, &right, &bottom, &top); @@ -1330,7 +1237,8 @@ write_ppd( * Do we support color? */ - gzputs(fp, "*OpenUI *ColorModel/Color Model: PickOne\n"); + gzprintf(fp, "*OpenUI *ColorModel/%s: PickOne\n", _("Color Model")); + gzputs(fp, "*OPOptionHints ColorModel: \"radiobuttons\"\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *ColorModel\n"); if (printer_is_color) @@ -1344,51 +1252,51 @@ write_ppd( gzputs(fp, "*StpDefaultColorModel: Gray\n"); } - gzprintf(fp, "*ColorModel Gray/Grayscale:\t\"<<" + gzprintf(fp, "*ColorModel Gray/%s:\t\"<<" "/cupsColorSpace %d" "/cupsColorOrder %d" "%s" ">>setpagedevice\"\n", - CUPS_CSPACE_W, CUPS_ORDER_CHUNKED, - simplified ? "/cupsBitsPerColor 8" : ""); - gzprintf(fp, "*ColorModel Black/Inverted Grayscale:\t\"<<" + _("Grayscale"), CUPS_CSPACE_W, CUPS_ORDER_CHUNKED, + simplified ? "/cupsBitsPerColor 8/cupsPreferredBitsPerColor 16" : ""); + gzprintf(fp, "*ColorModel Black/%s:\t\"<<" "/cupsColorSpace %d" "/cupsColorOrder %d" "%s" ">>setpagedevice\"\n", - CUPS_CSPACE_K, CUPS_ORDER_CHUNKED, - simplified ? "/cupsBitsPerColor 8" : ""); + _("Inverted Grayscale"), CUPS_CSPACE_K, CUPS_ORDER_CHUNKED, + simplified ? "/cupsBitsPerColor 8/cupsPreferredBitsPerColor 16" : ""); if (printer_is_color) { - gzprintf(fp, "*ColorModel RGB/RGB Color:\t\"<<" + gzprintf(fp, "*ColorModel RGB/%s:\t\"<<" "/cupsColorSpace %d" "/cupsColorOrder %d" "%s" ">>setpagedevice\"\n", - CUPS_CSPACE_RGB, CUPS_ORDER_CHUNKED, - simplified ? "/cupsBitsPerColor 8" : ""); - gzprintf(fp, "*ColorModel CMY/CMY Color:\t\"<<" + _("RGB Color"), CUPS_CSPACE_RGB, CUPS_ORDER_CHUNKED, + simplified ? "/cupsBitsPerColor 8/cupsPreferredBitsPerColor 16" : ""); + gzprintf(fp, "*ColorModel CMY/%s:\t\"<<" "/cupsColorSpace %d" "/cupsColorOrder %d" "%s" ">>setpagedevice\"\n", - CUPS_CSPACE_CMY, CUPS_ORDER_CHUNKED, - simplified ? "/cupsBitsPerColor 8" : ""); - gzprintf(fp, "*ColorModel CMYK/CMYK:\t\"<<" + _("CMY Color"), CUPS_CSPACE_CMY, CUPS_ORDER_CHUNKED, + simplified ? "/cupsBitsPerColor 8/cupsPreferredBitsPerColor 16" : ""); + gzprintf(fp, "*ColorModel CMYK/%s:\t\"<<" "/cupsColorSpace %d" "/cupsColorOrder %d" "%s" ">>setpagedevice\"\n", - CUPS_CSPACE_CMYK, CUPS_ORDER_CHUNKED, - simplified ? "/cupsBitsPerColor 8" : ""); - gzprintf(fp, "*ColorModel KCMY/KCMY:\t\"<<" + _("CMYK"), CUPS_CSPACE_CMYK, CUPS_ORDER_CHUNKED, + simplified ? "/cupsBitsPerColor 8/cupsPreferredBitsPerColor 16" : ""); + gzprintf(fp, "*ColorModel KCMY/%s:\t\"<<" "/cupsColorSpace %d" "/cupsColorOrder %d" "%s" ">>setpagedevice\"\n", - CUPS_CSPACE_KCMY, CUPS_ORDER_CHUNKED, - simplified ? "/cupsBitsPerColor 8" : ""); + _("KCMY"), CUPS_CSPACE_KCMY, CUPS_ORDER_CHUNKED, + simplified ? "/cupsBitsPerColor 8/cupsPreferredBitsPerColor 16" : ""); } gzputs(fp, "*CloseUI: *ColorModel\n\n"); @@ -1398,15 +1306,16 @@ write_ppd( /* * 8 or 16 bit color (16 bit is slower) */ - gzputs(fp, "*OpenUI *StpColorPrecision/Color Precision: PickOne\n"); + gzprintf(fp, "*OpenUI *StpColorPrecision/%s: PickOne\n", _("Color Precision")); + gzputs(fp, "*OPOptionHints StpColorPrecision: \"radiobuttons\"\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *StpColorPrecision\n"); gzputs(fp, "*DefaultStpColorPrecision: Normal\n"); gzputs(fp, "*StpDefaultStpColorPrecision: Normal\n"); - gzputs(fp, "*StpColorPrecision Normal/Normal:\t\"<<" - "/cupsBitsPerColor 8>>setpagedevice\"\n"); - gzputs(fp, "*StpColorPrecision Best/Best:\t\"<<" - "/cupsBitsPerColor 8" - "/cupsPreferredBitsPerColor 16>>setpagedevice\"\n"); + gzprintf(fp, "*StpColorPrecision Normal/%s:\t\"<<" + "/cupsBitsPerColor 8>>setpagedevice\"\n", _("Normal")); + gzprintf(fp, "*StpColorPrecision Best/%s:\t\"<<" + "/cupsBitsPerColor 8" + "/cupsPreferredBitsPerColor 16>>setpagedevice\"\n", _("Best")); gzputs(fp, "*CloseUI: *StpColorPrecision\n\n"); } @@ -1420,6 +1329,7 @@ write_ppd( if (num_opts > 0) { gzprintf(fp, "*OpenUI *MediaType/%s: PickOne\n", _("Media Type")); + gzputs(fp, "*OPOptionHints MediaType: \"dropdown\"\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *MediaType\n"); gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, desc.p_type, desc.is_mandatory, @@ -1431,7 +1341,7 @@ write_ppd( { opt = stp_string_list_param(desc.bounds.str, i); gzprintf(fp, "*MediaType %s/%s:\t\"<</MediaType(%s)>>setpagedevice\"\n", - opt->name, opt->text, opt->name); + opt->name, stp_i18n_lookup(po, opt->text), opt->name); } gzputs(fp, "*CloseUI: *MediaType\n\n"); @@ -1448,6 +1358,7 @@ write_ppd( if (num_opts > 0) { gzprintf(fp, "*OpenUI *InputSlot/%s: PickOne\n", _("Media Source")); + gzputs(fp, "*OPOptionHints InputSlot: \"dropdown\"\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *InputSlot\n"); gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, desc.p_type, desc.is_mandatory, @@ -1459,7 +1370,7 @@ write_ppd( { opt = stp_string_list_param(desc.bounds.str, i); gzprintf(fp, "*InputSlot %s/%s:\t\"<</MediaClass(%s)>>setpagedevice\"\n", - opt->name, opt->text, opt->name); + opt->name, stp_i18n_lookup(po, opt->text), opt->name); } gzputs(fp, "*CloseUI: *InputSlot\n\n"); @@ -1475,14 +1386,18 @@ write_ppd( { stp_clear_string_parameter(v, "Resolution"); has_quality_parameter = 1; - gzprintf(fp, "*OpenUI *StpQuality/%s: PickOne\n", gettext(desc.text)); + num_opts = stp_string_list_count(desc.bounds.str); + gzprintf(fp, "*OpenUI *StpQuality/%s: PickOne\n", stp_i18n_lookup(po, desc.text)); + if (num_opts > 3) + gzputs(fp, "*OPOptionHints Quality: \"radiobuttons\"\n"); + else + gzputs(fp, "*OPOptionHints Quality: \"dropdown\"\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *StpQuality\n"); gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, desc.p_type, desc.is_mandatory, desc.p_type, desc.p_level, desc.channel, 0.0, 0.0, 0.0); 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++) { opt = stp_string_list_param(desc.bounds.str, i); @@ -1499,7 +1414,7 @@ write_ppd( stp_parameter_description_destroy(&res_desc); } gzprintf(fp, "*StpQuality %s/%s:\t\"<</HWResolution[%d %d]/cupsRowFeed %d>>setpagedevice\"\n", - opt->name, opt->text, xdpi, ydpi, i + 1); + opt->name, stp_i18n_lookup(po, opt->text), xdpi, ydpi, i + 1); } gzputs(fp, "*CloseUI: *StpQuality\n\n"); } @@ -1521,6 +1436,10 @@ write_ppd( int tmp_xdpi, tmp_ydpi; gzprintf(fp, "*OpenUI *Resolution/%s: PickOne\n", _("Resolution")); + if (num_opts > 3) + gzputs(fp, "*OPOptionHints Resolution: \"resolution radiobuttons\"\n"); + else + gzputs(fp, "*OPOptionHints Resolution: \"resolution dropdown\"\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *Resolution\n"); gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, desc.p_type, desc.is_mandatory, @@ -1535,10 +1454,12 @@ write_ppd( stp_describe_resolution(v, &xdpi, &ydpi); stp_clear_string_parameter(v, "Quality"); tmp_xdpi = xdpi; + while (tmp_xdpi > MAXIMUM_SAFE_PPD_X_RESOLUTION) + tmp_xdpi /= 2; tmp_ydpi = ydpi; - if (tmp_ydpi > tmp_xdpi) - tmp_ydpi = tmp_xdpi; - else + while (tmp_ydpi > MAXIMUM_SAFE_PPD_Y_RESOLUTION) + tmp_ydpi /= 2; + if (tmp_ydpi < tmp_xdpi) tmp_xdpi = tmp_ydpi; /* Make the default resolution look like an almost square resolution @@ -1546,12 +1467,13 @@ write_ppd( excess resolution. However, make the hardware resolution match the printer default. */ - (void) snprintf(res_name, 63, "%dx%ddpi", tmp_xdpi, tmp_xdpi + 1); + (void) snprintf(res_name, 63, "%dx%ddpi", tmp_xdpi + 1, tmp_xdpi); + default_resolution = stp_strdup(res_name); stp_string_list_add_string(res_list, res_name, res_name); gzprintf(fp, "*DefaultResolution: %s\n", res_name); gzprintf(fp, "*StpDefaultResolution: %s\n", res_name); - gzprintf(fp, "*Resolution %s/Automatic:\t\"<</HWResolution[%d %d]>>setpagedevice\"\n", - res_name, xdpi, ydpi); + gzprintf(fp, "*Resolution %s/%s:\t\"<</HWResolution[%d %d]>>setpagedevice\"\n", + res_name, _("Automatic"), xdpi, ydpi); gzprintf(fp, "*StpResolutionMap: %s %s\n", res_name, "None"); } else @@ -1583,32 +1505,44 @@ write_ppd( stp_set_string_parameter(v, "Resolution", opt->name); stp_describe_resolution(v, &xdpi, &ydpi); - /* This should not happen! */ + /* This should only happen with a "None" resolution */ if (xdpi == -1 || ydpi == -1) continue; resolution_ok = 0; tmp_xdpi = xdpi; + while (tmp_xdpi > MAXIMUM_SAFE_PPD_X_RESOLUTION) + tmp_xdpi /= 2; tmp_ydpi = ydpi; + while (tmp_ydpi > MAXIMUM_SAFE_PPD_Y_RESOLUTION) + tmp_ydpi /= 2; 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 || + if ((!has_quality_parameter && + 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) + else if (tmp_ydpi > tmp_xdpi && + tmp_ydpi < MAXIMUM_SAFE_PPD_Y_RESOLUTION) + /* Note that we're incrementing the *higher* resolution. + This will generate less aliasing, and apps that convert + down to a square resolution will do the right thing. */ tmp_ydpi++; - else + else if (tmp_xdpi < MAXIMUM_SAFE_PPD_X_RESOLUTION) tmp_xdpi++; + else + tmp_xdpi /= 2; } while (!resolution_ok); + stp_string_list_add_string(resolutions, res_name, res_name); gzprintf(fp, "*Resolution %s/%s:\t\"<</HWResolution[%d %d]/cupsCompression %d>>setpagedevice\"\n", - res_name, opt->text, xdpi, ydpi, i + 1); + res_name, stp_i18n_lookup(po, opt->text), xdpi, ydpi, i + 1); if (strcmp(res_name, opt->name) != 0) gzprintf(fp, "*StpResolutionMap: %s %s\n", res_name, opt->name); } @@ -1622,12 +1556,13 @@ write_ppd( stp_describe_parameter(v, "OutputOrder", &desc); if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST) { - gzputs(fp, "*OpenUI *OutputOrder: PickOne\n"); + gzprintf(fp, "*OpenUI *OutputOrder/%s: PickOne\n", _("Output Order")); + gzputs(fp, "*OPOptionHints OutputOrder: \"radiobuttons\"\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"); + gzprintf(fp, "*OutputOrder Normal/%s: \"\"\n", _("Normal")); + gzprintf(fp, "*OutputOrder Reverse/%s: \"\"\n", _("Reverse")); gzputs(fp, "*CloseUI: *OutputOrder\n\n"); } stp_parameter_description_destroy(&desc); @@ -1639,12 +1574,13 @@ write_ppd( */ stp_describe_parameter(v, "Duplex", &desc); - if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST) + if (desc.is_active && desc.p_type == STP_PARAMETER_TYPE_STRING_LIST) { num_opts = stp_string_list_count(desc.bounds.str); if (num_opts > 0) { gzprintf(fp, "*OpenUI *Duplex/%s: PickOne\n", _("2-Sided Printing")); + gzputs(fp, "*OPOptionHints Duplex: \"radiobuttons\"\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *Duplex\n"); gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, desc.p_type, desc.is_mandatory, @@ -1656,11 +1592,11 @@ write_ppd( { opt = stp_string_list_param(desc.bounds.str, i); if (strcmp(opt->name, "None") == 0) - gzprintf(fp, "*Duplex %s/%s: \"<</Duplex false>>setpagedevice\"\n", opt->name, opt->text); + gzprintf(fp, "*Duplex %s/%s: \"<</Duplex false>>setpagedevice\"\n", opt->name, stp_i18n_lookup(po, opt->text)); else if (strcmp(opt->name, "DuplexNoTumble") == 0) - gzprintf(fp, "*Duplex %s/%s: \"<</Duplex true/Tumble false>>setpagedevice\"\n", opt->name, opt->text); + gzprintf(fp, "*Duplex %s/%s: \"<</Duplex true/Tumble false>>setpagedevice\"\n", opt->name, stp_i18n_lookup(po, opt->text)); else if (strcmp(opt->name, "DuplexTumble") == 0) - gzprintf(fp, "*Duplex %s/%s: \"<</Duplex true/Tumble true>>setpagedevice\"\n", opt->name, opt->text); + gzprintf(fp, "*Duplex %s/%s: \"<</Duplex true/Tumble true>>setpagedevice\"\n", opt->name, stp_i18n_lookup(po, opt->text)); } gzputs(fp, "*CloseUI: *Duplex\n\n"); } @@ -1669,6 +1605,7 @@ write_ppd( gzprintf(fp, "*OpenUI *StpiShrinkOutput/%s: PickOne\n", _("Shrink Page If Necessary to Fit Borders")); + gzputs(fp, "*OPOptionHints StpiShrinkOutput: \"radiobuttons\"\n"); gzputs(fp, "*OrderDependency: 10 AnySetup *StpiShrinkOutput\n"); gzputs(fp, "*DefaultStpiShrinkOutput: Shrink\n"); gzputs(fp, "*StpDefaultStpiShrinkOutput: Shrink\n"); @@ -1695,6 +1632,7 @@ write_ppd( (lparam->p_type != STP_PARAMETER_TYPE_STRING_LIST && lparam->p_type != STP_PARAMETER_TYPE_BOOLEAN && lparam->p_type != STP_PARAMETER_TYPE_DIMENSION && + lparam->p_type != STP_PARAMETER_TYPE_INT && lparam->p_type != STP_PARAMETER_TYPE_DOUBLE)) continue; stp_describe_parameter(v, lparam->name, &desc); @@ -1703,16 +1641,23 @@ write_ppd( int printed_default_value = 0; if (!printed_open_group) { - print_group_open(fp, j, k); + print_group_open(fp, j, k, language, po); printed_open_group = 1; } gzprintf(fp, "*OpenUI *Stp%s/%s: PickOne\n", - desc.name, gettext(desc.text)); + desc.name, stp_i18n_lookup(po, desc.text)); gzprintf(fp, "*OrderDependency: 10 AnySetup *Stp%s\n", desc.name); switch (desc.p_type) { case STP_PARAMETER_TYPE_STRING_LIST: + num_opts = stp_string_list_count(desc.bounds.str); + if (num_opts > 3) + gzprintf(fp, "*OPOptionHints Stp%s: \"dropdown\"\n", + lparam->name); + else + gzprintf(fp, "*OPOptionHints Stp%s: \"radiobuttons\"\n", + lparam->name); gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, desc.p_type, desc.is_mandatory, desc.p_class, desc.p_level, desc.channel, @@ -1731,15 +1676,16 @@ write_ppd( 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++) { opt = stp_string_list_param(desc.bounds.str, i); gzprintf(fp, "*Stp%s %s/%s: \"\"\n", - desc.name, opt->name, opt->text); + desc.name, opt->name, stp_i18n_lookup(po, opt->text)); } break; case STP_PARAMETER_TYPE_BOOLEAN: + gzprintf(fp, "*OPOptionHints Stp%s: \"checkbox\"\n", + lparam->name); gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, desc.p_type, desc.is_mandatory, desc.p_class, desc.p_level, desc.channel, @@ -1764,6 +1710,8 @@ write_ppd( desc.name, "True", _("Yes")); break; case STP_PARAMETER_TYPE_DOUBLE: + gzprintf(fp, "*OPOptionHints Stp%s: \"slider input spinbox\"\n", + lparam->name); gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, desc.p_type, desc.is_mandatory, desc.p_class, desc.p_level, desc.channel, @@ -1785,8 +1733,8 @@ write_ppd( desc.name, i, ((double) i) * .001); } if (!desc.is_mandatory) - gzprintf(fp, "*Stp%s None/None: \"\"\n", - desc.name); + gzprintf(fp, "*Stp%s None/%s: \"\"\n", + desc.name, _("None")); else if (! printed_default_value) gzprintf(fp, "*Stp%s None/%.3f: \"\"\n", desc.name, desc.deflt.dbl); @@ -1803,7 +1751,9 @@ write_ppd( if (!simplified) { gzprintf(fp, "*OpenUI *StpFine%s/%s %s: PickOne\n", - desc.name, gettext(desc.text), _("Fine Adjustment")); + desc.name, stp_i18n_lookup(po, desc.text), _("Fine Adjustment")); + gzprintf(fp, "*OPOptionHints Stp%s: \"hide\"\n", + lparam->name); gzprintf(fp, "*StpStpFine%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, STP_PARAMETER_TYPE_INVALID, 0, 0, 0, -1, 0.0, 0.0, 0.0); @@ -1819,6 +1769,8 @@ write_ppd( break; case STP_PARAMETER_TYPE_DIMENSION: + gzprintf(fp, "*OPOptionHints Stp%s: \"length slider input spinbox\"\n", + lparam->name); gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", desc.name, desc.p_type, desc.is_mandatory, desc.p_class, desc.p_level, desc.channel, @@ -1865,6 +1817,50 @@ write_ppd( desc.bounds.dimension.upper); break; + case STP_PARAMETER_TYPE_INT: + gzprintf(fp, "*OPOptionHints Stp%s: \"input spinbox\"\n", + lparam->name); + gzprintf(fp, "*StpStp%s: %d %d %d %d %d %.3f %.3f %.3f\n", + desc.name, desc.p_type, desc.is_mandatory, + desc.p_class, desc.p_level, desc.channel, + (double) desc.bounds.integer.lower, + (double) desc.bounds.integer.upper, + (double) desc.deflt.integer); + if (desc.is_mandatory) + { + gzprintf(fp, "*DefaultStp%s: %d\n", + desc.name, desc.deflt.integer); + gzprintf(fp, "*StpDefaultStp%s: %d\n", + desc.name, desc.deflt.integer); + } + else + { + 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.integer.lower; + i <= desc.bounds.integer.upper; i++) + { + gzprintf(fp, "*Stp%s %d/%d: \"\"\n", + desc.name, i, i); + } + + 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; } @@ -1874,16 +1870,409 @@ write_ppd( stp_parameter_description_destroy(&desc); } if (printed_open_group) - print_group_close(fp, j, k); + print_group_close(fp, j, k, language, po); + } + } + stp_describe_parameter(v, "ImageType", &desc); + if (desc.is_active && desc.p_type == STP_PARAMETER_TYPE_STRING_LIST) + { + num_opts = stp_string_list_count(desc.bounds.str); + if (num_opts > 0) + { + for (i = 0; i < num_opts; i++) + { + opt = stp_string_list_param(desc.bounds.str, i); + if (strcmp(opt->name, "None") != 0) + gzprintf(fp, "*APPrinterPreset %s/%s: \"*StpImageType %s\"\n", + opt->name, stp_i18n_lookup(po, opt->text), opt->name); + } + gzputs(fp, "\n"); + } + } + stp_parameter_description_destroy(&desc); + +#undef _ +#define _(x) stp_i18n_lookup(altpo, x) + + if (!language) + { + /* + * Generate globalized PPDs when POSIX language is requested... + */ + + const char *lang; + stp_string_list_t *altpo; + int langnum; + + for (langnum = 0; all_langs[langnum]; langnum ++) + { + lang = all_langs[langnum]; + + if (!strcmp(lang, "C") || !strcmp(lang, "en")) + continue; + + if ((altpo = stp_i18n_load(lang)) == NULL) + continue; + + /* + * Get the page sizes from the driver... + */ + + if (printer_is_color) + stp_set_string_parameter(v, "PrintingMode", "Color"); + else + stp_set_string_parameter(v, "PrintingMode", "BW"); + stp_set_string_parameter(v, "ChannelBitDepth", "8"); + stp_describe_parameter(v, "PageSize", &desc); + num_opts = stp_string_list_count(desc.bounds.str); + + gzprintf(fp, "*%s.Translation PageSize/%s: \"\"\n", lang, _("Media Size")); + gzprintf(fp, "*%s.Translation PageRegion/%s: \"\"\n", lang, _("Media Size")); + + for (i = 0; i < num_opts; i++) + { + const stp_papersize_t *papersize; + opt = stp_string_list_param(desc.bounds.str, i); + papersize = stp_get_papersize_by_name(opt->name); + + if (!papersize) + continue; + +/* + if (strcmp(opt->name, "Custom") == 0) + continue; +*/ + + if (simplified && num_opts >= 10 && + (papersize->paper_unit == PAPERSIZE_ENGLISH_EXTENDED || + papersize->paper_unit == PAPERSIZE_METRIC_EXTENDED)) + continue; + + if ((papersize->width <= 0 || papersize->height <= 0) && + strcmp(opt->name, "Custom") != 0) + continue; + + gzprintf(fp, "*%s.PageSize %s/%s: \"\"\n", lang, opt->name, stp_i18n_lookup(altpo, opt->text)); + gzprintf(fp, "*%s.PageRegion %s/%s: \"\"\n", lang, opt->name, stp_i18n_lookup(altpo, opt->text)); + } + + stp_parameter_description_destroy(&desc); + + /* + * Do we support color? + */ + + gzprintf(fp, "*%s.Translation ColorModel/%s: \"\"\n", lang, _("Color Model")); + gzprintf(fp, "*%s.ColorModel Gray/%s: \"\"\n", lang, _("Grayscale")); + gzprintf(fp, "*%s.ColorModel Black/%s: \"\"\n", lang, _("Inverted Grayscale")); + + if (printer_is_color) + { + gzprintf(fp, "*%s.ColorModel RGB/%s: \"\"\n", lang, _("RGB Color")); + gzprintf(fp, "*%s.ColorModel CMY/%s: \"\"\n", lang, _("CMY Color")); + gzprintf(fp, "*%s.ColorModel CMYK/%s: \"\"\n", lang, _("CMYK")); + gzprintf(fp, "*%s.ColorModel KCMY/%s: \"\"\n", lang, _("KCMY")); + } + + if (!simplified) + { + /* + * 8 or 16 bit color (16 bit is slower) + */ + gzprintf(fp, "*%s.Translation StpColorPrecision/%s: \"\"\n", lang, _("Color Precision")); + gzprintf(fp, "*%s.StpColorPrecision Normal/%s: \"\"\n", lang, _("Normal")); + gzprintf(fp, "*%s.StpColorPrecision Best/%s: \"\"\n", lang, _("Best")); + } + + /* + * Media types... + */ + + stp_describe_parameter(v, "MediaType", &desc); + num_opts = stp_string_list_count(desc.bounds.str); + + if (num_opts > 0) + { + gzprintf(fp, "*%s.Translation MediaType/%s: \"\"\n", lang, _("Media Type")); + + for (i = 0; i < num_opts; i ++) + { + opt = stp_string_list_param(desc.bounds.str, i); + gzprintf(fp, "*%s.MediaType %s/%s: \"\"\n", lang, opt->name, stp_i18n_lookup(altpo, opt->text)); + } + } + stp_parameter_description_destroy(&desc); + + /* + * Input slots... + */ + + stp_describe_parameter(v, "InputSlot", &desc); + num_opts = stp_string_list_count(desc.bounds.str); + + if (num_opts > 0) + { + gzprintf(fp, "*%s.Translation InputSlot/%s: \"\"\n", lang, _("Media Source")); + + for (i = 0; i < num_opts; i ++) + { + opt = stp_string_list_param(desc.bounds.str, i); + gzprintf(fp, "*%s.InputSlot %s/%s: \"\"\n", lang, opt->name, stp_i18n_lookup(altpo, opt->text)); } + } + stp_parameter_description_destroy(&desc); + + /* + * Quality settings + */ + + stp_describe_parameter(v, "Quality", &desc); + if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST && desc.is_active) + { + gzprintf(fp, "*%s.Translation StpQuality/%s: \"\"\n", lang, stp_i18n_lookup(altpo, desc.text)); + num_opts = stp_string_list_count(desc.bounds.str); + for (i = 0; i < num_opts; i++) + { + opt = stp_string_list_param(desc.bounds.str, i); + gzprintf(fp, "*%s.StpQuality %s/%s: \"\"\n", lang, opt->name, stp_i18n_lookup(altpo, opt->text)); + } + } + stp_parameter_description_destroy(&desc); + + /* + * Resolution + */ + + stp_describe_parameter(v, "Resolution", &desc); + num_opts = stp_string_list_count(resolutions); + + if (!simplified || desc.p_level == STP_PARAMETER_LEVEL_BASIC) + { + gzprintf(fp, "*%s.Translation Resolution/%s: \"\"\n", lang, _("Resolution")); + if (has_quality_parameter) + gzprintf(fp, "*%s.Resolution %s/%s: \"\"\n", lang, + default_resolution, _("Automatic")); + + for (i = 0; i < num_opts; i ++) + { + opt = stp_string_list_param(resolutions, i); + gzprintf(fp, "*%s.Resolution %s/%s: \"\"\n", lang, + opt->name, stp_i18n_lookup(altpo, opt->text)); + } + } + + stp_parameter_description_destroy(&desc); + + /* + * OutputOrder + */ + + stp_describe_parameter(v, "OutputOrder", &desc); + if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST) + { + gzprintf(fp, "*%s.Translation OutputOrder/%s: \"\"\n", lang, _("Output Order")); + gzprintf(fp, "*%s.OutputOrder Normal/%s: \"\"\n", lang, _("Normal")); + gzprintf(fp, "*%s.OutputOrder Reverse/%s: \"\"\n", lang, _("Reverse")); + } + 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 + */ + + stp_describe_parameter(v, "Duplex", &desc); + if (desc.is_active && desc.p_type == STP_PARAMETER_TYPE_STRING_LIST) + { + num_opts = stp_string_list_count(desc.bounds.str); + if (num_opts > 0) + { + gzprintf(fp, "*%s.Translation Duplex/%s: \"\"\n", lang, _("2-Sided Printing")); + + for (i = 0; i < num_opts; i++) + { + opt = stp_string_list_param(desc.bounds.str, i); + if (strcmp(opt->name, "None") == 0) + gzprintf(fp, "*%s.Duplex %s/%s: \"\"\n", lang, opt->name, stp_i18n_lookup(altpo, opt->text)); + else if (strcmp(opt->name, "DuplexNoTumble") == 0) + gzprintf(fp, "*%s.Duplex %s/%s: \"\"\n", lang, opt->name, stp_i18n_lookup(altpo, opt->text)); + else if (strcmp(opt->name, "DuplexTumble") == 0) + gzprintf(fp, "*%s.Duplex %s/%s: \"\"\n", lang, opt->name, stp_i18n_lookup(altpo, opt->text)); + } + } + } + stp_parameter_description_destroy(&desc); + + gzprintf(fp, "*%s.Translation StpiShrinkOutput/%s: \"\"\n", lang, + _("Shrink Page If Necessary to Fit Borders")); + gzprintf(fp, "*%s.StpiShrinkOutput %s/%s: \"\"\n", lang, "Shrink", _("Shrink (print the whole page)")); + gzprintf(fp, "*%s.StpiShrinkOutput %s/%s: \"\"\n", lang, "Crop", _("Crop (preserve dimensions)")); + gzprintf(fp, "*%s.StpiShrinkOutput %s/%s: \"\"\n", lang, "Expand", _("Expand (use maximum page area)")); + + param_list = stp_get_parameter_list(v); + + for (j = 0; j <= STP_PARAMETER_CLASS_OUTPUT; j++) + { + for (k = 0; k <= maximum_level; k++) + { + size_t param_count = stp_parameter_list_count(param_list); + for (l = 0; l < param_count; l++) + { + const stp_parameter_t *lparam = + stp_parameter_list_param(param_list, l); + if (lparam->p_class != j || lparam->p_level != k || + is_special_option(lparam->name) || lparam->read_only || + (lparam->p_type != STP_PARAMETER_TYPE_STRING_LIST && + lparam->p_type != STP_PARAMETER_TYPE_BOOLEAN && + lparam->p_type != STP_PARAMETER_TYPE_DIMENSION && + lparam->p_type != STP_PARAMETER_TYPE_INT && + lparam->p_type != STP_PARAMETER_TYPE_DOUBLE)) + continue; + stp_describe_parameter(v, lparam->name, &desc); + if (desc.is_active) + { + gzprintf(fp, "*%s.Translation Stp%s/%s: \"\"\n", lang, + desc.name, stp_i18n_lookup(altpo, desc.text)); + switch (desc.p_type) + { + case STP_PARAMETER_TYPE_STRING_LIST: + if (!desc.is_mandatory) + gzprintf(fp, "*%s.Stp%s %s/%s: \"\"\n", lang, desc.name, + "None", _("None")); + num_opts = stp_string_list_count(desc.bounds.str); + for (i = 0; i < num_opts; i++) + { + opt = stp_string_list_param(desc.bounds.str, i); + gzprintf(fp, "*%s.Stp%s %s/%s: \"\"\n", lang, + desc.name, opt->name, stp_i18n_lookup(altpo, opt->text)); + } + break; + + case STP_PARAMETER_TYPE_BOOLEAN: + if (!desc.is_mandatory) + gzprintf(fp, "*%s.Stp%s %s/%s: \"\"\n", lang, desc.name, + "None", _("None")); + gzprintf(fp, "*%s.Stp%s %s/%s: \"\"\n", lang, + desc.name, "False", _("No")); + gzprintf(fp, "*%s.Stp%s %s/%s: \"\"\n", lang, + desc.name, "True", _("Yes")); + break; + + case STP_PARAMETER_TYPE_DOUBLE: + if (localize_numbers) + { + for (i = desc.bounds.dbl.lower * 1000; + i <= desc.bounds.dbl.upper * 1000 ; i += 100) + { + if (desc.deflt.dbl * 1000 == i && desc.is_mandatory) + gzprintf(fp, "*%s.Stp%s None/%.3f: \"\"\n", lang, + desc.name, ((double) i) * .001); + else + gzprintf(fp, "*%s.Stp%s %d/%.3f: \"\"\n", lang, + desc.name, i, ((double) i) * .001); + } + } + if (!desc.is_mandatory) + gzprintf(fp, "*%s.Stp%s None/%s: \"\"\n", lang, + desc.name, _("None")); + gzprintf(fp, "*%s.ParamCustomStp%s Value/%s: \"\"\n", lang, + desc.name, _("Value")); + if (!simplified) + { + gzprintf(fp, "*%s.Translation StpFine%s/%s %s: \"\"\n", lang, + desc.name, stp_i18n_lookup(altpo, desc.text), _("Fine Adjustment")); + gzprintf(fp, "*%s.StpFine%s None/%.3f: \"\"\n", lang, + desc.name, 0.0); + if (localize_numbers) + { + for (i = 0; i < 100; i += 5) + gzprintf(fp, "*%s.StpFine%s %d/%.3f: \"\"\n", lang, + desc.name, i, ((double) i) * .001); + } + } + break; + + case STP_PARAMETER_TYPE_DIMENSION: + if (!desc.is_mandatory) + gzprintf(fp, "*%s.Stp%s %s/%s: \"\"\n", lang, desc.name, + "None", _("None")); + if (localize_numbers) + { + for (i = desc.bounds.dimension.lower; + i <= desc.bounds.dimension.upper; i++) + { + /* FIXME + * For now, just use mm; we'll fix it later + * for the locale-appropriate setting. + * --rlk 20040818 + */ + gzprintf(fp, "*%s.Stp%s %d/%.1f mm: \"\"\n", lang, + desc.name, i, ((double) i) * 25.4 / 72); + } + } + gzprintf(fp, "*%s.ParamCustomStp%s Value/%s: \"\"\n", lang, + desc.name, _("Value")); + break; + + case STP_PARAMETER_TYPE_INT: + if (!desc.is_mandatory) + gzprintf(fp, "*%s.Stp%s %s/%s: \"\"\n", lang, desc.name, + "None", _("None")); + if (localize_numbers) + { + for (i = desc.bounds.integer.lower; + i <= desc.bounds.integer.upper; i++) + { + gzprintf(fp, "*%s.Stp%s %d/%d: \"\"\n", lang, + desc.name, i, i); + } + } + gzprintf(fp, "*%s.ParamCustomStp%s Value/%s: \"\"\n", lang, + desc.name, _("Value")); + break; + + default: + break; + } + } + stp_parameter_description_destroy(&desc); + } + } + } + stp_describe_parameter(v, "ImageType", &desc); + if (desc.is_active && desc.p_type == STP_PARAMETER_TYPE_STRING_LIST) + { + num_opts = stp_string_list_count(desc.bounds.str); + if (num_opts > 0) + { + for (i = 0; i < num_opts; i++) + { + opt = stp_string_list_param(desc.bounds.str, i); + if (strcmp(opt->name, "None") != 0) + gzprintf(fp, "*%s.APPrinterPreset %s/%s: \"*StpImageType %s\"\n", + lang, opt->name, opt->text, opt->name); + } + } + } + stp_parameter_description_destroy(&desc); } + } + if (has_quality_parameter) + stp_free(default_resolution); + stp_string_list_destroy(resolutions); + stp_parameter_list_destroy(param_list); +#undef _ +#define _(x) x + + /* * Fonts... */ - gzputs(fp, "*DefaultFont: Courier\n"); + gzputs(fp, "\n*DefaultFont: Courier\n"); gzputs(fp, "*Font AvantGarde-Book: Standard \"(001.006S)\" Standard ROM\n"); gzputs(fp, "*Font AvantGarde-BookOblique: Standard \"(001.006S)\" Standard ROM\n"); gzputs(fp, "*Font AvantGarde-Demi: Standard \"(001.007S)\" Standard ROM\n"); @@ -1925,10 +2314,11 @@ write_ppd( ppdext); stp_vars_destroy(v); + return (0); } /* - * End of "$Id: genppd.c,v 1.142 2008/04/06 21:16:08 rlk Exp $". + * End of "$Id: genppd.c,v 1.170 2008/09/25 23:41:00 rlk Exp $". */ diff --git a/src/cups/i18n.c b/src/cups/i18n.c new file mode 100644 index 0000000..59406ec --- /dev/null +++ b/src/cups/i18n.c @@ -0,0 +1,481 @@ +/* + * "$Id: i18n.c,v 1.6 2008/08/16 16:56:06 rlk Exp $" + * + * Internationalization functions for CUPS drivers. + * + * Copyright 2008 Michael Sweet (mike@easysw.com) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Contents: + * + * stp_i18n_load() - Load a message catalog for a locale. + * stp_i18n_lookup() - Lookup a string in the message catalog... + * stp_i18n_printf() - Send a formatted string to stderr. + * stpi_unquote() - Unquote characters in strings. + */ + +/* + * Include necessary files... + */ + +#include "i18n.h" +#include <config.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <ctype.h> +#include <unistd.h> +#include <errno.h> +#include <iconv.h> + + +/* + * GNU gettext uses a simple .po file format: + * + * # comment + * msgid "id" + * "optional continuation" + * msgstr "str" + * "optional continuation" + * + * Both the id and str strings use standard C quoting for special characters + * like newline and the double quote character. + */ + + +/* + * Cache structure... + */ + +typedef struct stpi_i18n_s +{ + struct stpi_i18n_s *next; /* Next catalog */ + char locale[6]; /* Locale */ + stp_string_list_t *po; /* Message catalog */ +} stpi_i18n_t; + + +/* + * Local functions... + */ + +static void stpi_unquote(char *s); + + +/* + * Local globals... + */ + +static stpi_i18n_t *stpi_pocache = NULL; + + +/* + * 'stp_i18n_load()' - Load a message catalog for a locale. + */ + +stp_string_list_t * /* O - Message catalog */ +stp_i18n_load(const char *locale) /* I - Locale name */ +{ + stp_string_list_t *po; /* Message catalog */ + char ll_CC[6], /* Locale ID */ + poname[1024]; /* .po filename */ + stpi_i18n_t *pocache; /* Current cache entry */ + FILE *pofile; /* .po file */ + const char *stp_localedir; /* STP_LOCALEDIR environment variable */ + char line[4096], /* Line buffer */ + *ptr, /* Pointer into buffer */ + id[4096], /* Translation ID */ + str[4096], /* Translation string */ + utf8str[4096]; /* UTF-8 translation string */ + int in_id, /* Processing "id" string? */ + in_str, /* Processing "str" string? */ + linenum; /* Line number in .po file */ + iconv_t ic; /* Transcoder to UTF-8 */ + size_t inbytes, /* Number of input buffer bytes */ + outbytes; /* Number of output buffer bytes */ + char *inptr, /* Pointer into input buffer */ + *outptr; /* Pointer into output buffer */ + int fuzzy = 0; /* Fuzzy translation? */ + + + if (!locale) + return (NULL); + + /* + * See if the locale is already loaded... + */ + + for (pocache = stpi_pocache; pocache; pocache = pocache->next) + if (!strcmp(locale, pocache->locale)) + return (pocache->po); + + /* + * Find the message catalog for the given locale... + */ + + if ((stp_localedir = getenv("STP_LOCALEDIR")) == NULL) + stp_localedir = PACKAGE_LOCALE_DIR; + + strncpy(ll_CC, locale, sizeof(ll_CC) - 1); + ll_CC[sizeof(ll_CC) - 1] = '\0'; + + if ((ptr = strchr(ll_CC, '.')) != NULL) + *ptr = '\0'; + + snprintf(poname, sizeof(poname), "%s/%s/gutenprint_%s.po", stp_localedir, + ll_CC, ll_CC); + if (access(poname, 0) && strlen(ll_CC) > 2) + { + ll_CC[2] = '\0'; + + snprintf(poname, sizeof(poname), "%s/%s/gutenprint_%s.po", stp_localedir, + ll_CC, ll_CC); + } + + if ((pofile = fopen(poname, "rb")) == NULL) + return (NULL); + + /* + * Read the messages and add them to a string list... + */ + + if ((po = stp_string_list_create()) == NULL) + { + fclose(pofile); + return (NULL); + } + + linenum = 0; + id[0] = '\0'; + str[0] = '\0'; + in_id = 0; + in_str = 0; + ic = 0; + + while (fgets(line, sizeof(line), pofile)) + { + linenum ++; + + /* + * Skip blank and comment lines... + */ + + if (line[0] == '#') + { + if (line[1] == ':') + fuzzy = 0; + + if (strstr(line, "fuzzy")) + fuzzy = 1; + } + + if (fuzzy || line[0] == '#' || line[0] == '\n') + continue; + + /* + * Strip the trailing quote... + */ + + if ((ptr = (char *)strrchr(line, '\"')) == NULL) + { + fprintf(stderr, "DEBUG: Expected quoted string on line %d of %s!\n", + linenum, poname); + break; + } + + *ptr = '\0'; + + /* + * Find start of value... + */ + + if ((ptr = strchr(line, '\"')) == NULL) + { + fprintf(stderr, "DEBUG: Expected quoted string on line %d of %s!\n", + linenum, poname); + break; + } + + ptr ++; + + /* + * Create or add to a message... + */ + + if (!strncmp(line, "msgid", 5)) + { + in_id = 1; + in_str = 0; + + if (id[0] && str[0]) + { + stpi_unquote(id); + + if (ic) + { + /* + * Convert string to UTF-8... + */ + + inbytes = strlen(str); + inptr = str; + outbytes = sizeof(utf8str); + outptr = utf8str; + + iconv(ic, &inptr, &inbytes, &outptr, &outbytes); + *outptr = '\0'; + + /* + * Add it to the string list... + */ + + stpi_unquote(utf8str); + stp_string_list_add_string(po, id, utf8str); + } + else + { + stpi_unquote(str); + stp_string_list_add_string(po, id, str); + } + } + else if (!id[0] && str[0] && !ic) + { + /* + * Look for the character set... + */ + + const char *charset = strstr(str, "charset="); + /* Source character set definition */ + char fromcode[255], /* Source character set */ + *fromptr; /* Pointer into fromcode */ + + if (charset) + { + /* + * Extract character set and setup a transcode context... + */ + + strncpy(fromcode, charset + 8, sizeof(fromcode) - 1); + fromcode[sizeof(fromcode) - 1] = '\0'; + for (fromptr = fromcode; *fromptr; fromptr ++) + if (!isalnum(*fromptr & 255) && *fromptr != '-') + break; + *fromptr = '\0'; + + if (strcasecmp(fromcode, "utf-8")) + { + if ((ic = iconv_open("UTF-8", fromcode)) == (iconv_t)-1) + { + fprintf(stderr, + "DEBUG: Unable to convert character set \"%s\": %s\n", + fromcode, strerror(errno)); + ic = 0; + } + } + } + } + + strncpy(id, ptr, sizeof(id) - 1); + id[sizeof(id) - 1] = '\0'; + str[0] = '\0'; + } + else if (!strncmp(line, "msgstr", 6)) + { + in_id = 0; + in_str = 1; + + strncpy(str, ptr, sizeof(str) - 1); + str[sizeof(str) - 1] = '\0'; + } + else if (line[0] == '\"' && in_str) + { + int str_len = strlen(str), + ptr_len = strlen(ptr); + + + if ((str_len + ptr_len + 1) > sizeof(str)) + ptr_len = sizeof(str) - str_len - 1; + + if (ptr_len > 0) + { + memcpy(str + str_len, ptr, ptr_len); + str[str_len + ptr_len] = '\0'; + } + } + else if (line[0] == '\"' && in_id) + { + int id_len = strlen(id), + ptr_len = strlen(ptr); + + + if ((id_len + ptr_len + 1) > sizeof(id)) + ptr_len = sizeof(id) - id_len - 1; + + if (ptr_len > 0) + { + memcpy(id + id_len, ptr, ptr_len); + id[id_len + ptr_len] = '\0'; + } + } + else + { + fprintf(stderr, "DEBUG: Unexpected text on line %d of %s!\n", + linenum, poname); + break; + } + } + + if (id[0] && str[0]) + { + stpi_unquote(id); + + if (ic) + { + /* + * Convert string to UTF-8... + */ + + inbytes = strlen(str); + inptr = str; + outbytes = sizeof(utf8str); + outptr = utf8str; + + iconv(ic, &inptr, &inbytes, &outptr, &outbytes); + *outptr = '\0'; + + /* + * Add it to the string list... + */ + + stpi_unquote(utf8str); + stp_string_list_add_string(po, id, utf8str); + } + else + { + stpi_unquote(str); + stp_string_list_add_string(po, id, str); + } + } + + fclose(pofile); + + /* + * Add this to the cache... + */ + + if ((pocache = calloc(1, sizeof(stpi_i18n_t))) != NULL) + { + strncpy(pocache->locale, locale, sizeof(pocache->locale) - 1); + pocache->po = po; + pocache->next = stpi_pocache; + stpi_pocache = pocache; + } + + return (po); +} + + +/* + * 'stp_i18n_lookup()' - Lookup a string in the message catalog... + */ + +const char * /* O - Localized message */ +stp_i18n_lookup( + stp_string_list_t *po, /* I - Message catalog */ + const char *message) /* I - Message */ +{ + stp_param_string_t *param; /* Matching message */ + + + if (po && (param = stp_string_list_find(po, message)) != NULL && param->text) + return (param->text); + else + return (message); +} + + +/* + * 'stp_i18n_printf()' - Send a formatted string to stderr. + */ + +void +stp_i18n_printf( + stp_string_list_t *po, /* I - Message catalog */ + const char *message, /* I - Printf-style message */ + ...) /* I - Additional arguments as needed */ +{ + va_list ap; /* Argument pointer */ + + + va_start(ap, message); + vfprintf(stderr, stp_i18n_lookup(po, message), ap); + va_end(ap); +} + + +/* + * 'stpi_unquote()' - Unquote characters in strings. + */ + +static void +stpi_unquote(char *s) /* IO - Original string */ +{ + char *d = s; /* Destination pointer */ + + + while (*s) + { + if (*s == '\\') + { + s ++; + if (isdigit(*s)) + { + *d = 0; + + while (isdigit(*s)) + { + *d = *d * 8 + *s - '0'; + s ++; + } + + d ++; + } + else + { + if (*s == 'n') + *d ++ = '\n'; + else if (*s == 'r') + *d ++ = '\r'; + else if (*s == 't') + *d ++ = '\t'; + else + *d++ = *s; + + s ++; + } + } + else + *d++ = *s++; + } + + *d = '\0'; +} + + +/* + * End of "$Id: i18n.c,v 1.6 2008/08/16 16:56:06 rlk Exp $". + */ diff --git a/src/cups/i18n.h b/src/cups/i18n.h new file mode 100644 index 0000000..f5ae7af --- /dev/null +++ b/src/cups/i18n.h @@ -0,0 +1,47 @@ +/* + * "$Id: i18n.h,v 1.1 2008/08/13 07:35:52 easysw Exp $" + * + * Internationalization definitions for CUPS drivers. + * + * Copyright 2008 Michael Sweet (mike@easysw.com) + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include <gutenprint/gutenprint.h> +#include <gutenprint/string-list.h> + + +/* + * Macro for localizing driver messages... + */ + +#define _(x) x + + +/* + * Prototypes... + */ + +extern stp_string_list_t *stp_i18n_load(const char *locale); +extern const char *stp_i18n_lookup(stp_string_list_t *po, + const char *message); +extern void stp_i18n_printf(stp_string_list_t *po, + const char *message, ...); + + +/* + * End of "$Id: i18n.h,v 1.1 2008/08/13 07:35:52 easysw Exp $". + */ diff --git a/src/cups/rastertoprinter.c b/src/cups/rastertoprinter.c index 9c25137..cf7cc38 100644 --- a/src/cups/rastertoprinter.c +++ b/src/cups/rastertoprinter.c @@ -1,9 +1,9 @@ /* - * "$Id: rastertoprinter.c,v 1.120 2008/01/02 01:39:06 rlk Exp $" + * "$Id: rastertoprinter.c,v 1.136 2008/10/04 17:47:50 rlk Exp $" * * Gutenprint based raster filter for the Common UNIX Printing System. * - * Copyright 1993-2007 by Easy Software Products. + * Copyright 1993-2008 by Mike Sweet. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -47,11 +47,12 @@ #include <stdlib.h> #include <unistd.h> #include <fcntl.h> +#include <errno.h> #include <sys/times.h> #ifdef HAVE_LIMITS_H #include <limits.h> #endif -#include <gutenprint/gutenprint.h> +#include "i18n.h" /* Solaris with gcc has problems because gcc's limits.h doesn't #define */ /* this */ @@ -113,15 +114,16 @@ static volatile stp_image_status_t Image_status = STP_IMAGE_STATUS_OK; static double total_bytes_printed = 0; static int print_messages_as_errors = 0; static int suppress_messages = 0; +static stp_string_list_t *po = NULL; static void set_string_parameter(stp_vars_t *v, const char *name, const char *val) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint set special string %s to %s\n", name, val); + fprintf(stderr, "DEBUG: Gutenprint: Set special string %s to %s\n", name, val); stp_set_string_parameter(v, name, val); } - + static void set_special_parameter(stp_vars_t *v, const char *name, int choice) @@ -134,21 +136,22 @@ set_special_parameter(stp_vars_t *v, const char *name, int choice) { stp_clear_string_parameter(v, name); if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint clear special parameter %s\n", + fprintf(stderr, "DEBUG: Gutenprint: Clear special parameter %s\n", name); } else if (choice >= stp_string_list_count(desc.bounds.str)) { if (! suppress_messages) - fprintf(stderr, "ERROR: Gutenprint UNABLE to set %s (%d > %d)!\n", - name, choice, stp_string_list_count(desc.bounds.str)); + stp_i18n_printf(po, _("ERROR: Unable to set Gutenprint option %s " + "(%d > %d)!\n"), name, choice, + stp_string_list_count(desc.bounds.str)); } else { stp_set_string_parameter (v, name, stp_string_list_param(desc.bounds.str, choice)->name); if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint set special parameter %s to choice %d (%s)\n", + fprintf(stderr, "DEBUG: Gutenprint: Set special parameter %s to choice %d (%s)\n", name, choice, stp_string_list_param(desc.bounds.str, choice)->name); } @@ -156,7 +159,7 @@ set_special_parameter(stp_vars_t *v, const char *name, int choice) else { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint UNABLE to set special %s: not a string\n", + fprintf(stderr, "DEBUG: Gutenprint: Unable to set special %s: not a string\n", name); } stp_parameter_description_destroy(&desc); @@ -168,62 +171,62 @@ print_debug_block(const stp_vars_t *v, const cups_image_t *cups) stp_parameter_list_t params; int nparams; int i; - fprintf(stderr, "DEBUG: Gutenprint Page data:\n"); - fprintf(stderr, "DEBUG: Gutenprint MediaClass = \"%s\"\n", cups->header.MediaClass); - fprintf(stderr, "DEBUG: Gutenprint MediaColor = \"%s\"\n", cups->header.MediaColor); - fprintf(stderr, "DEBUG: Gutenprint MediaType = \"%s\"\n", cups->header.MediaType); - fprintf(stderr, "DEBUG: Gutenprint OutputType = \"%s\"\n", cups->header.OutputType); - - fprintf(stderr, "DEBUG: Gutenprint AdvanceDistance = %d\n", cups->header.AdvanceDistance); - fprintf(stderr, "DEBUG: Gutenprint AdvanceMedia = %d\n", cups->header.AdvanceMedia); - fprintf(stderr, "DEBUG: Gutenprint Collate = %d\n", cups->header.Collate); - fprintf(stderr, "DEBUG: Gutenprint CutMedia = %d\n", cups->header.CutMedia); - fprintf(stderr, "DEBUG: Gutenprint Duplex = %d\n", cups->header.Duplex); - fprintf(stderr, "DEBUG: Gutenprint HWResolution = [ %d %d ]\n", cups->header.HWResolution[0], + fprintf(stderr, "DEBUG: Gutenprint: Page data:\n"); + fprintf(stderr, "DEBUG: Gutenprint: MediaClass = \"%s\"\n", cups->header.MediaClass); + fprintf(stderr, "DEBUG: Gutenprint: MediaColor = \"%s\"\n", cups->header.MediaColor); + fprintf(stderr, "DEBUG: Gutenprint: MediaType = \"%s\"\n", cups->header.MediaType); + fprintf(stderr, "DEBUG: Gutenprint: OutputType = \"%s\"\n", cups->header.OutputType); + + fprintf(stderr, "DEBUG: Gutenprint: AdvanceDistance = %d\n", cups->header.AdvanceDistance); + fprintf(stderr, "DEBUG: Gutenprint: AdvanceMedia = %d\n", cups->header.AdvanceMedia); + fprintf(stderr, "DEBUG: Gutenprint: Collate = %d\n", cups->header.Collate); + fprintf(stderr, "DEBUG: Gutenprint: CutMedia = %d\n", cups->header.CutMedia); + fprintf(stderr, "DEBUG: Gutenprint: Duplex = %d\n", cups->header.Duplex); + fprintf(stderr, "DEBUG: Gutenprint: HWResolution = [ %d %d ]\n", cups->header.HWResolution[0], cups->header.HWResolution[1]); - fprintf(stderr, "DEBUG: Gutenprint ImagingBoundingBox = [ %d %d %d %d ]\n", + fprintf(stderr, "DEBUG: Gutenprint: ImagingBoundingBox = [ %d %d %d %d ]\n", cups->header.ImagingBoundingBox[0], cups->header.ImagingBoundingBox[1], cups->header.ImagingBoundingBox[2], cups->header.ImagingBoundingBox[3]); - fprintf(stderr, "DEBUG: Gutenprint InsertSheet = %d\n", cups->header.InsertSheet); - fprintf(stderr, "DEBUG: Gutenprint Jog = %d\n", cups->header.Jog); - fprintf(stderr, "DEBUG: Gutenprint LeadingEdge = %d\n", cups->header.LeadingEdge); - fprintf(stderr, "DEBUG: Gutenprint Margins = [ %d %d ]\n", cups->header.Margins[0], + fprintf(stderr, "DEBUG: Gutenprint: InsertSheet = %d\n", cups->header.InsertSheet); + fprintf(stderr, "DEBUG: Gutenprint: Jog = %d\n", cups->header.Jog); + fprintf(stderr, "DEBUG: Gutenprint: LeadingEdge = %d\n", cups->header.LeadingEdge); + fprintf(stderr, "DEBUG: Gutenprint: Margins = [ %d %d ]\n", cups->header.Margins[0], cups->header.Margins[1]); - fprintf(stderr, "DEBUG: Gutenprint ManualFeed = %d\n", cups->header.ManualFeed); - fprintf(stderr, "DEBUG: Gutenprint MediaPosition = %d\n", cups->header.MediaPosition); - fprintf(stderr, "DEBUG: Gutenprint MediaWeight = %d\n", cups->header.MediaWeight); - fprintf(stderr, "DEBUG: Gutenprint MirrorPrint = %d\n", cups->header.MirrorPrint); - fprintf(stderr, "DEBUG: Gutenprint NegativePrint = %d\n", cups->header.NegativePrint); - fprintf(stderr, "DEBUG: Gutenprint NumCopies = %d\n", cups->header.NumCopies); - fprintf(stderr, "DEBUG: Gutenprint Orientation = %d\n", cups->header.Orientation); - fprintf(stderr, "DEBUG: Gutenprint OutputFaceUp = %d\n", cups->header.OutputFaceUp); - fprintf(stderr, "DEBUG: Gutenprint PageSize = [ %d %d ]\n", cups->header.PageSize[0], + fprintf(stderr, "DEBUG: Gutenprint: ManualFeed = %d\n", cups->header.ManualFeed); + fprintf(stderr, "DEBUG: Gutenprint: MediaPosition = %d\n", cups->header.MediaPosition); + fprintf(stderr, "DEBUG: Gutenprint: MediaWeight = %d\n", cups->header.MediaWeight); + fprintf(stderr, "DEBUG: Gutenprint: MirrorPrint = %d\n", cups->header.MirrorPrint); + fprintf(stderr, "DEBUG: Gutenprint: NegativePrint = %d\n", cups->header.NegativePrint); + fprintf(stderr, "DEBUG: Gutenprint: NumCopies = %d\n", cups->header.NumCopies); + fprintf(stderr, "DEBUG: Gutenprint: Orientation = %d\n", cups->header.Orientation); + fprintf(stderr, "DEBUG: Gutenprint: OutputFaceUp = %d\n", cups->header.OutputFaceUp); + fprintf(stderr, "DEBUG: Gutenprint: PageSize = [ %d %d ]\n", cups->header.PageSize[0], cups->header.PageSize[1]); - fprintf(stderr, "DEBUG: Gutenprint Separations = %d\n", cups->header.Separations); - fprintf(stderr, "DEBUG: Gutenprint TraySwitch = %d\n", cups->header.TraySwitch); - fprintf(stderr, "DEBUG: Gutenprint Tumble = %d\n", cups->header.Tumble); - fprintf(stderr, "DEBUG: Gutenprint cupsWidth = %d\n", cups->header.cupsWidth); - fprintf(stderr, "DEBUG: Gutenprint cupsHeight = %d\n", cups->header.cupsHeight); - fprintf(stderr, "DEBUG: Gutenprint cups->width = %d\n", cups->width); - fprintf(stderr, "DEBUG: Gutenprint cups->height = %d\n", cups->height); - fprintf(stderr, "DEBUG: Gutenprint cups->adjusted_width = %d\n", cups->adjusted_width); - fprintf(stderr, "DEBUG: Gutenprint cups->adjusted_height = %d\n", cups->adjusted_height); - fprintf(stderr, "DEBUG: Gutenprint cupsMediaType = %d\n", cups->header.cupsMediaType); - fprintf(stderr, "DEBUG: Gutenprint cupsBitsPerColor = %d\n", cups->header.cupsBitsPerColor); - fprintf(stderr, "DEBUG: Gutenprint cupsBitsPerPixel = %d\n", cups->header.cupsBitsPerPixel); - fprintf(stderr, "DEBUG: Gutenprint cupsBytesPerLine = %d\n", cups->header.cupsBytesPerLine); - fprintf(stderr, "DEBUG: Gutenprint cupsColorOrder = %d\n", cups->header.cupsColorOrder); - fprintf(stderr, "DEBUG: Gutenprint cupsColorSpace = %d\n", cups->header.cupsColorSpace); - fprintf(stderr, "DEBUG: Gutenprint cupsCompression = %d\n", cups->header.cupsCompression); - fprintf(stderr, "DEBUG: Gutenprint cupsRowCount = %d\n", cups->header.cupsRowCount); - fprintf(stderr, "DEBUG: Gutenprint cupsRowFeed = %d\n", cups->header.cupsRowFeed); - fprintf(stderr, "DEBUG: Gutenprint cupsRowStep = %d\n", cups->header.cupsRowStep); - fprintf(stderr, "DEBUG: Gutenprint stp_get_driver(v) |%s|\n", stp_get_driver(v)); - fprintf(stderr, "DEBUG: Gutenprint stp_get_left(v) %d\n", stp_get_left(v)); - fprintf(stderr, "DEBUG: Gutenprint stp_get_top(v) %d\n", stp_get_top(v)); - fprintf(stderr, "DEBUG: Gutenprint stp_get_page_width(v) %d\n", stp_get_page_width(v)); - fprintf(stderr, "DEBUG: Gutenprint stp_get_page_height(v) %d\n", stp_get_page_height(v)); - fprintf(stderr, "DEBUG: Gutenprint shrink page to fit %d\n", cups->shrink_to_fit); + fprintf(stderr, "DEBUG: Gutenprint: Separations = %d\n", cups->header.Separations); + fprintf(stderr, "DEBUG: Gutenprint: TraySwitch = %d\n", cups->header.TraySwitch); + fprintf(stderr, "DEBUG: Gutenprint: Tumble = %d\n", cups->header.Tumble); + fprintf(stderr, "DEBUG: Gutenprint: cupsWidth = %d\n", cups->header.cupsWidth); + fprintf(stderr, "DEBUG: Gutenprint: cupsHeight = %d\n", cups->header.cupsHeight); + fprintf(stderr, "DEBUG: Gutenprint: cups->width = %d\n", cups->width); + fprintf(stderr, "DEBUG: Gutenprint: cups->height = %d\n", cups->height); + fprintf(stderr, "DEBUG: Gutenprint: cups->adjusted_width = %d\n", cups->adjusted_width); + fprintf(stderr, "DEBUG: Gutenprint: cups->adjusted_height = %d\n", cups->adjusted_height); + fprintf(stderr, "DEBUG: Gutenprint: cupsMediaType = %d\n", cups->header.cupsMediaType); + fprintf(stderr, "DEBUG: Gutenprint: cupsBitsPerColor = %d\n", cups->header.cupsBitsPerColor); + fprintf(stderr, "DEBUG: Gutenprint: cupsBitsPerPixel = %d\n", cups->header.cupsBitsPerPixel); + fprintf(stderr, "DEBUG: Gutenprint: cupsBytesPerLine = %d\n", cups->header.cupsBytesPerLine); + fprintf(stderr, "DEBUG: Gutenprint: cupsColorOrder = %d\n", cups->header.cupsColorOrder); + fprintf(stderr, "DEBUG: Gutenprint: cupsColorSpace = %d\n", cups->header.cupsColorSpace); + fprintf(stderr, "DEBUG: Gutenprint: cupsCompression = %d\n", cups->header.cupsCompression); + fprintf(stderr, "DEBUG: Gutenprint: cupsRowCount = %d\n", cups->header.cupsRowCount); + fprintf(stderr, "DEBUG: Gutenprint: cupsRowFeed = %d\n", cups->header.cupsRowFeed); + fprintf(stderr, "DEBUG: Gutenprint: cupsRowStep = %d\n", cups->header.cupsRowStep); + fprintf(stderr, "DEBUG: Gutenprint: stp_get_driver(v) |%s|\n", stp_get_driver(v)); + fprintf(stderr, "DEBUG: Gutenprint: stp_get_left(v) %d\n", stp_get_left(v)); + fprintf(stderr, "DEBUG: Gutenprint: stp_get_top(v) %d\n", stp_get_top(v)); + fprintf(stderr, "DEBUG: Gutenprint: stp_get_page_width(v) %d\n", stp_get_page_width(v)); + fprintf(stderr, "DEBUG: Gutenprint: stp_get_page_height(v) %d\n", stp_get_page_height(v)); + fprintf(stderr, "DEBUG: Gutenprint: shrink page to fit %d\n", cups->shrink_to_fit); params = stp_get_parameter_list(v); nparams = stp_parameter_list_count(params); for (i = 0; i < nparams; i++) @@ -232,28 +235,28 @@ print_debug_block(const stp_vars_t *v, const cups_image_t *cups) switch (p->p_type) { case STP_PARAMETER_TYPE_STRING_LIST: - fprintf(stderr, "DEBUG: Gutenprint stp_get_string %s(v) |%s| %d\n", + fprintf(stderr, "DEBUG: Gutenprint: stp_get_string %s(v) |%s| %d\n", p->name, stp_get_string_parameter(v, p->name) ? stp_get_string_parameter(v, p->name) : "NULL", stp_get_string_parameter_active(v, p->name)); break; case STP_PARAMETER_TYPE_DOUBLE: - fprintf(stderr, "DEBUG: Gutenprint stp_get_float %s(v) |%.3f| %d\n", + fprintf(stderr, "DEBUG: Gutenprint: stp_get_float %s(v) |%.3f| %d\n", p->name, stp_get_float_parameter(v, p->name), stp_get_float_parameter_active(v, p->name)); break; case STP_PARAMETER_TYPE_DIMENSION: - fprintf(stderr, "DEBUG: Gutenprint stp_get_dimension %s(v) |%d| %d\n", + fprintf(stderr, "DEBUG: Gutenprint: stp_get_dimension %s(v) |%d| %d\n", p->name, stp_get_dimension_parameter(v, p->name), stp_get_dimension_parameter_active(v, p->name)); break; case STP_PARAMETER_TYPE_INT: - fprintf(stderr, "DEBUG: Gutenprint stp_get_int %s(v) |%d| %d\n", + fprintf(stderr, "DEBUG: Gutenprint: stp_get_int %s(v) |%d| %d\n", p->name, stp_get_int_parameter(v, p->name), stp_get_int_parameter_active(v, p->name)); break; case STP_PARAMETER_TYPE_BOOLEAN: - fprintf(stderr, "DEBUG: Gutenprint stp_get_boolean %s(v) |%d| %d\n", + fprintf(stderr, "DEBUG: Gutenprint: stp_get_boolean %s(v) |%d| %d\n", p->name, stp_get_boolean_parameter(v, p->name), stp_get_boolean_parameter_active(v, p->name)); break; @@ -264,7 +267,7 @@ print_debug_block(const stp_vars_t *v, const cups_image_t *cups) break; } } - fprintf(stderr, "DEBUG: Gutenprint End page data\n"); + fprintf(stderr, "DEBUG: Gutenprint: End page data\n"); stp_parameter_list_destroy(params); } @@ -287,7 +290,7 @@ validate_options(stp_vars_t *v, cups_image_t *cups) int nparams = stp_parameter_list_count(params); int i; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint validating options\n"); + fprintf(stderr, "DEBUG: Gutenprint: Validating options\n"); for (i = 0; i < nparams; i++) { const stp_parameter_t *param = stp_parameter_list_param(params, i); @@ -301,14 +304,14 @@ validate_options(stp_vars_t *v, cups_image_t *cups) if (! suppress_messages) { const char *val = stp_get_string_parameter(v, desc.name); - fprintf(stderr, "DEBUG: Gutenprint clearing string %s (%s)\n", + fprintf(stderr, "DEBUG: Gutenprint: Clearing string %s (%s)\n", desc.name, val ? val : "(null)"); } stp_clear_string_parameter(v, desc.name); if (!desc.read_only && desc.is_mandatory && desc.is_active) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint setting default string %s to %s\n", + fprintf(stderr, "DEBUG: Gutenprint: Setting default string %s to %s\n", desc.name, desc.deflt.str ? desc.deflt.str : "(null)"); stp_set_string_parameter(v, desc.name, desc.deflt.str); if (strcmp(desc.name, "PageSize") == 0) @@ -318,7 +321,7 @@ validate_options(stp_vars_t *v, cups_image_t *cups) if (ps->width > 0) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint setting page width to %d\n", + fprintf(stderr, "DEBUG: Gutenprint: Setting page width to %d\n", ps->width); if (ps->width < stp_get_page_width(v)) stp_set_page_width(v, ps->width); @@ -326,7 +329,7 @@ validate_options(stp_vars_t *v, cups_image_t *cups) if (ps->height > 0) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint setting page height to %d\n", + fprintf(stderr, "DEBUG: Gutenprint: Setting page height to %d\n", ps->height); if (ps->height < stp_get_page_height(v)) stp_set_page_height(v, ps->height); @@ -338,22 +341,20 @@ validate_options(stp_vars_t *v, cups_image_t *cups) stp_parameter_description_destroy(&desc); } if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint done validating options\n"); + fprintf(stderr, "DEBUG: Gutenprint: Done validating options\n"); stp_parameter_list_destroy(params); -} +} static stp_vars_t * -initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) +initialize_page(cups_image_t *cups, const stp_vars_t *default_settings, + const char *page_size_name) { - const stp_papersize_t *size; /* Paper size */ int tmp_left, tmp_right, tmp_top, tmp_bottom, tmp_width, tmp_height; stp_vars_t *v = stp_vars_create_copy(default_settings); if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint Initialize page\n"); + fprintf(stderr, "DEBUG: Gutenprint: Initialize page\n"); - stp_set_page_width(v, cups->header.PageSize[0]); - stp_set_page_height(v, cups->header.PageSize[1]); stp_set_outfunc(v, cups_writefunc); stp_set_errfunc(v, cups_errfunc); stp_set_outdata(v, stdout); @@ -394,8 +395,8 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) set_string_parameter(v, "InputImageType", "KCMY"); break; default : - fprintf(stderr, "ERROR: Gutenprint Bad colorspace %d!\n", - cups->header.cupsColorSpace); + stp_i18n_printf(po, _("ERROR: Gutenprint detected a bad colorspace " + "(%d)!\n"), cups->header.cupsColorSpace); break; } @@ -410,17 +411,52 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) set_string_parameter(v, "MediaType", cups->header.MediaType); if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint PageSize = %dx%d\n", cups->header.PageSize[0], + fprintf(stderr, "DEBUG: Gutenprint: PageSize = %dx%d\n", cups->header.PageSize[0], cups->header.PageSize[1]); - if ((size = stp_get_papersize_by_size(cups->header.PageSize[1], - cups->header.PageSize[0])) != NULL) - set_string_parameter(v, "PageSize", size->name); + if (page_size_name) + { + if (strcmp(page_size_name, "Custom") == 0) + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: Using custom page size for (%d, %d)\n", + cups->header.PageSize[1], cups->header.PageSize[0]); + stp_set_page_width(v, cups->header.PageSize[0]); + stp_set_page_height(v, cups->header.PageSize[1]); + } + else if (stp_get_papersize_by_name(page_size_name)) + { + int width, height; + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: Using page size %s with (%d, %d)\n", + page_size_name, cups->header.PageSize[1], cups->header.PageSize[0]); + set_string_parameter(v, "PageSize", page_size_name); + stp_get_media_size(v, &width, &height); + if (width > 0) + stp_set_page_width(v, width); + else + stp_set_page_width(v, cups->header.PageSize[0]); + if (height > 0) + stp_set_page_height(v, height); + else + stp_set_page_height(v, cups->header.PageSize[1]); + } + else + { + if (!suppress_messages) + fprintf(stderr, "DEBUG: Gutenprint: Can't find page size %s with (%d, %d), using custom page size\n", + page_size_name, cups->header.PageSize[1], cups->header.PageSize[0]); + stp_set_page_width(v, cups->header.PageSize[0]); + stp_set_page_height(v, cups->header.PageSize[1]); + } + } else { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint UNABLE to get media size for (%d, %d)\n", + fprintf(stderr, "DEBUG: Gutenprint: No named media size for (%d, %d)\n", cups->header.PageSize[1], cups->header.PageSize[0]); + stp_set_page_width(v, cups->header.PageSize[0]); + stp_set_page_height(v, cups->header.PageSize[1]); } /* @@ -447,9 +483,9 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) &(cups->bottom), &(cups->top)); if (! suppress_messages) { - fprintf(stderr, "DEBUG: Gutenprint limits w %d l %d r %d h %d t %d b %d\n", + fprintf(stderr, "DEBUG: Gutenprint: limits w %d l %d r %d h %d t %d b %d\n", cups->width, cups->left, cups->right, cups->height, cups->top, cups->bottom); - fprintf(stderr, "DEBUG: Gutenprint max limits l %d r %d t %d b %d\n", + fprintf(stderr, "DEBUG: Gutenprint: max limits l %d r %d t %d b %d\n", tmp_left, tmp_right, tmp_top, tmp_bottom); } @@ -473,13 +509,13 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) else cups->left_trim = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint left margin %d\n", cups->left_trim); + fprintf(stderr, "DEBUG: Gutenprint: left margin %d\n", cups->left_trim); } else { cups->left_trim = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint adjusting left margin from %d to %d\n", + fprintf(stderr, "DEBUG: Gutenprint: Adjusting left margin from %d to %d\n", cups->left, tmp_left); cups->left = tmp_left; } @@ -493,13 +529,13 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) else cups->right_trim = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint right margin %d\n", cups->right_trim); + fprintf(stderr, "DEBUG: Gutenprint: right margin %d\n", cups->right_trim); } else { cups->right_trim = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint adjusting right margin from %d to %d\n", + fprintf(stderr, "DEBUG: Gutenprint: Adjusting right margin from %d to %d\n", cups->right, tmp_right); cups->right = tmp_right; } @@ -513,13 +549,13 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) else cups->top_trim = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint top margin %d\n", cups->top_trim); + fprintf(stderr, "DEBUG: Gutenprint: top margin %d\n", cups->top_trim); } else { cups->top_trim = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint adjusting top margin from %d to %d\n", + fprintf(stderr, "DEBUG: Gutenprint: Adjusting top margin from %d to %d\n", cups->top, tmp_top); cups->top = tmp_top; } @@ -533,13 +569,13 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) else cups->bottom_trim = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint bottom margin %d\n", cups->bottom_trim); + fprintf(stderr, "DEBUG: Gutenprint: bottom margin %d\n", cups->bottom_trim); } else { cups->bottom_trim = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint adjusting bottom margin from %d to %d\n", + fprintf(stderr, "DEBUG: Gutenprint: Adjusting bottom margin from %d to %d\n", cups->bottom, tmp_bottom); cups->bottom = tmp_bottom; } @@ -589,12 +625,12 @@ initialize_page(cups_image_t *cups, const stp_vars_t *default_settings) if (cups->adjusted_height > cups->header.cupsHeight) cups->adjusted_height = cups->header.cupsHeight; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint CUPS settings w %d (%d) l %d r %d h %d (%d) t %d b %d\n", + fprintf(stderr, "DEBUG: Gutenprint: CUPS settings w %d (%d) l %d r %d h %d (%d) t %d b %d\n", cups->width, cups->adjusted_width, cups->left, cups->right, cups->height, cups->adjusted_height, cups->top, cups->bottom); if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint End initialize page\n"); + fprintf(stderr, "DEBUG: Gutenprint: End initialize page\n"); return v; } @@ -605,7 +641,7 @@ purge_excess_data(cups_image_t *cups) if (buffer) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint purging %d rows\n", + fprintf(stderr, "DEBUG: Gutenprint: Purging %d rows\n", cups->header.cupsHeight - cups->row); while (cups->row < cups->header.cupsHeight) { @@ -627,7 +663,7 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, const char *val; /* CUPS option value */ ppd_option_t *ppd_option; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint set options:\n"); + fprintf(stderr, "DEBUG: Gutenprint: Set options:\n"); val = cupsGetOption("StpiShrinkOutput", num_options, options); if (!val) { @@ -668,7 +704,7 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, double dval = atof(val + 7); if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint set float %s to %f\n", + fprintf(stderr, "DEBUG: Gutenprint: Set float %s to %f\n", desc.name, dval); if (dval > desc.bounds.dbl.upper) dval = desc.bounds.dbl.upper; @@ -681,7 +717,7 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, { fine_val = atof(val); if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint set float %s to %f (%s)\n", + fprintf(stderr, "DEBUG: Gutenprint: Set float %s to %f (%s)\n", desc.name, fine_val, val); } else @@ -698,7 +734,7 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, if (val && strlen(val) > 0 && strcmp(val, "None") != 0) fine_val = atof(val) * 0.001; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint set float %s to %f + %f\n", + fprintf(stderr, "DEBUG: Gutenprint: Set float %s to %f + %f\n", desc.name, coarse_val, fine_val); fine_val += coarse_val; } @@ -726,7 +762,7 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, { case STP_PARAMETER_TYPE_STRING_LIST: if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint set string %s to %s\n", + fprintf(stderr, "DEBUG: Gutenprint: Set string %s to %s\n", desc.name, val); set_string_parameter(v, desc.name, val); break; @@ -735,7 +771,7 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, val += 7; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint set int %s to %s (%d)\n", + fprintf(stderr, "DEBUG: Gutenprint: Set int %s to %s (%d)\n", desc.name, val, atoi(val)); stp_set_int_parameter(v, desc.name, atoi(val)); break; @@ -744,14 +780,14 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, val += 7; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint set dimension %s to %s (%d)\n", + fprintf(stderr, "DEBUG: Gutenprint: Set dimension %s to %s (%d)\n", desc.name, val, atoi(val)); stp_set_dimension_parameter(v, desc.name, atoi(val)); break; case STP_PARAMETER_TYPE_BOOLEAN: if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint set bool %s to %s (%d)\n", + fprintf(stderr, "DEBUG: Gutenprint: Set bool %s to %s (%d)\n", desc.name, val, strcasecmp(val, "true") == 0 ? 1 : 0); stp_set_boolean_parameter (v, desc.name, strcasecmp(val, "true") == 0 ? 1 : 0); @@ -760,7 +796,7 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, case STP_PARAMETER_TYPE_FILE: /* Probably not, security hole */ case STP_PARAMETER_TYPE_RAW: /* figure this out later, too */ if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint ignoring option %s %s type %d\n", + fprintf(stderr, "DEBUG: Gutenprint: Ignoring option %s %s type %d\n", desc.name, val, desc.p_type); break; default: @@ -770,13 +806,13 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, else if (val) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint NOT setting %s to '%s'\n", + fprintf(stderr, "DEBUG: Gutenprint: Not setting %s to '%s'\n", desc.name, val); } else { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint NOT setting %s to (null)\n", + fprintf(stderr, "DEBUG: Gutenprint: Not setting %s to (null)\n", desc.name); } } @@ -784,7 +820,7 @@ set_all_options(stp_vars_t *v, cups_option_t *options, int num_options, stp_free(ppd_option_name); } if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint end options\n"); + fprintf(stderr, "DEBUG: Gutenprint: End options\n"); stp_parameter_list_destroy(params); } @@ -800,6 +836,7 @@ main(int argc, /* I - Number of command-line arguments */ cups_image_t cups; /* CUPS image */ const char *ppdfile; /* PPD environment variable */ ppd_file_t *ppd; /* PPD file */ + ppd_size_t *size; const stp_printer_t *printer; /* Printer driver */ int num_options; /* Number of CUPS options */ cups_option_t *options; /* CUPS options */ @@ -813,14 +850,24 @@ main(int argc, /* I - Number of command-line arguments */ long clocks_per_sec; struct timeval t1, t2; struct timezone tz; + char *page_size_name = NULL; + + + /* + * Don't buffer error/status messages... + */ + + setbuf(stderr, NULL); if (getenv("STP_SUPPRESS_MESSAGES")) suppress_messages = 1; /* - * Initialise libgutenprint + * Initialize libgutenprint */ + po = stp_i18n_load(getenv("LANG")); + theImage.rep = ∪︀ (void) gettimeofday(&t1, &tz); @@ -828,12 +875,10 @@ main(int argc, /* I - Number of command-line arguments */ version_id = stp_get_version(); release_version_id = stp_get_release_version(); default_settings = stp_vars_create(); + /* * Check for valid arguments... */ - if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint %s Starting\n", version_id); - if (argc < 6 || argc > 7) { /* @@ -841,7 +886,8 @@ main(int argc, /* I - Number of command-line arguments */ * and return. */ - fputs("ERROR: Gutenprint rastertoprinter job-id user title copies options [file]\n", stderr); + stp_i18n_printf(po, _("Usage: rastertoprinter job-id user title copies " + "options [file]\n")); return (1); } @@ -861,7 +907,7 @@ main(int argc, /* I - Number of command-line arguments */ if ((ppdfile = getenv("PPD")) == NULL) { - fputs("ERROR: Gutenprint Fatal error: PPD environment variable not set!\n", stderr); + stp_i18n_printf(po, _("ERROR: No PPD file, unable to continue!\n")); return (1); } if (! suppress_messages) @@ -869,31 +915,31 @@ main(int argc, /* I - Number of command-line arguments */ if ((ppd = ppdOpenFile(ppdfile)) == NULL) { - fprintf(stderr, "ERROR: Gutenprint Fatal error: Unable to load PPD file \"%s\"!\n", - ppdfile); + stp_i18n_printf(po, _("ERROR: Gutenprint was unable to load PPD file " + "\"%s\"!\n"), ppdfile); return (1); } if (ppd->modelname == NULL) { - fprintf(stderr, "ERROR: Gutenprint Fatal error: No ModelName attribute in PPD file \"%s\"!\n", - ppdfile); + stp_i18n_printf(po, _("ERROR: Gutenprint did not find a ModelName " + "attribute in PPD file \"%s\"!\n"), ppdfile); ppdClose(ppd); return (1); } if (ppd->nickname == NULL) { - fprintf(stderr, "ERROR: Gutenprint Fatal error: No NickName attribute in PPD file \"%s\"!\n", - ppdfile); + stp_i18n_printf(po, _("ERROR: Gutenprint did not find a NickName attribute " + "in PPD file \"%s\"!\n"), ppdfile); ppdClose(ppd); return (1); } else if (strlen(ppd->nickname) < strlen(ppd->modelname) + strlen(CUPS_PPD_NICKNAME_STRING) + 3) { - fprintf(stderr, "ERROR: Gutenprint Fatal error: Corrupted NickName attribute in PPD file \"%s\"!\n", - ppdfile); + stp_i18n_printf(po, _("ERROR: Gutenprint found a corrupted NickName " + "attribute in PPD file \"%s\"!\n"), ppdfile); ppdClose(ppd); return (1); } @@ -907,22 +953,17 @@ main(int argc, /* I - Number of command-line arguments */ *(ppd->nickname + strlen(ppd->modelname) + strlen(CUPS_PPD_NICKNAME_STRING)) != ' '))) { - fprintf(stderr, "ERROR: Gutenprint: The version of Gutenprint software installed (%s) does not match the PPD file (%s).\n", - version_id, - ppd->nickname+strlen(ppd->modelname)+strlen(CUPS_PPD_NICKNAME_STRING)); - fprintf(stderr, "ERROR: Gutenprint: If you have upgraded your version of Gutenprint\n"); - fprintf(stderr, "ERROR: Gutenprint: recently, you must reinstall all printer queues.\n"); - fprintf(stderr, "ERROR: Gutenprint: If the previous installed version of Gutenprint\n"); - fprintf(stderr, "ERROR: Gutenprint: was 4.3.19 or higher, you can use the `cups-genppdupdate.%s'\n", release_version_id); - fprintf(stderr, "ERROR: Gutenprint: program to do this; if the previous installed version\n"); - fprintf(stderr, "ERROR: Gutenprint: was older, you can use the Modify Printer command via\n"); - fprintf(stderr, "ERROR: Gutenprint: the CUPS web interface: http://localhost:631/printers.\n"); - /* - * Repeat the first line of the message so that CUPS will display it - */ - fprintf(stderr, "ERROR: Gutenprint: The version of Gutenprint software installed (%s) does not match the PPD file (%s).\n", - version_id, - ppd->nickname+strlen(ppd->modelname)+strlen(CUPS_PPD_NICKNAME_STRING)); + stp_i18n_printf(po, _("ERROR: The PPD version (%d) is not compatible with " + "Gutenprint %s.\n"), + ppd->nickname+strlen(ppd->modelname)+strlen(CUPS_PPD_NICKNAME_STRING), + version_id); + fprintf(stderr, "DEBUG: Gutenprint: If you have upgraded your version of Gutenprint\n"); + fprintf(stderr, "DEBUG: Gutenprint: recently, you must reinstall all printer queues.\n"); + fprintf(stderr, "DEBUG: Gutenprint: If the previous installed version of Gutenprint\n"); + fprintf(stderr, "DEBUG: Gutenprint: was 4.3.19 or higher, you can use the `cups-genppdupdate.%s'\n", release_version_id); + fprintf(stderr, "DEBUG: Gutenprint: program to do this; if the previous installed version\n"); + fprintf(stderr, "DEBUG: Gutenprint: was older, you can use the Modify Printer command via\n"); + fprintf(stderr, "DEBUG: Gutenprint: the CUPS web interface: http://localhost:631/printers.\n"); ppdClose(ppd); return 1; } @@ -932,17 +973,23 @@ main(int argc, /* I - Number of command-line arguments */ */ num_options = cupsParseOptions(argv[5], 0, &options); + ppdMarkDefaults(ppd); + cupsMarkOptions(ppd, num_options, options); + size = ppdPageSize(ppd, NULL); + + if (size->name) + page_size_name = stp_strdup(size->name); if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint CUPS option count is %d (%d bytes)\n", - num_options, strlen(argv[5])); + fprintf(stderr, "DEBUG: Gutenprint: CUPS option count is %d (%d bytes)\n", + num_options, (int)strlen(argv[5])); if (num_options > 0) { int i; for (i = 0; i < num_options; i++) if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint CUPS option %d %s = %s\n", + fprintf(stderr, "DEBUG: Gutenprint: CUPS option %d %s = %s\n", i, options[i].name, options[i].value); } @@ -956,13 +1003,13 @@ main(int argc, /* I - Number of command-line arguments */ if (printer == NULL) { - fprintf(stderr, "ERROR: Gutenprint Fatal error: Unable to find driver named \"%s\"!\n", - ppd->modelname); + stp_i18n_printf(po, _("ERROR: Unable to find Gutenprint driver named " + "\"%s\"!\n"), ppd->modelname); ppdClose(ppd); return (1); } if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint driver %s\n", ppd->modelname); + fprintf(stderr, "DEBUG: Gutenprint: Driver %s\n", ppd->modelname); /* * Open the page stream... @@ -972,7 +1019,8 @@ main(int argc, /* I - Number of command-line arguments */ { if ((fd = open(argv[6], O_RDONLY)) == -1) { - perror("ERROR: Gutenprint Unable to open raster file - "); + stp_i18n_printf(po, _("ERROR: Gutenprint was unable to open raster file " + "\"%s\" - %s"), argv[6], strerror(errno)); sleep(1); return (1); } @@ -980,7 +1028,7 @@ main(int argc, /* I - Number of command-line arguments */ else fd = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint using fd %d\n", fd); + fprintf(stderr, "DEBUG: Gutenprint: Using fd %d\n", fd); stp_set_printer_defaults(default_settings, printer); stp_set_float_parameter(default_settings, "AppGamma", 1.0); @@ -997,7 +1045,7 @@ main(int argc, /* I - Number of command-line arguments */ cups.page = 0; if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint about to start printing loop.\n"); + fprintf(stderr, "DEBUG: Gutenprint: About to start printing loop.\n"); /* * Read the first page header, which we need in order to set up @@ -1022,10 +1070,10 @@ main(int argc, /* I - Number of command-line arguments */ */ if (! suppress_messages) { - fprintf(stderr, "DEBUG: Gutenprint printing page %d\n", cups.page + 1); + fprintf(stderr, "DEBUG: Gutenprint: Printing page %d\n", cups.page + 1); fprintf(stderr, "PAGE: %d 1\n", cups.page + 1); } - v = initialize_page(&cups, default_settings); + v = initialize_page(&cups, default_settings, page_size_name); stp_set_int_parameter(v, "PageNumber", cups.page); cups.row = 0; if (! suppress_messages) @@ -1033,10 +1081,10 @@ main(int argc, /* I - Number of command-line arguments */ print_messages_as_errors = 1; if (!stp_verify(v)) { - fprintf(stderr, "ERROR: Gutenprint: options failed to verify.\n"); - fprintf(stderr, "ERROR: Gutenprint: Make sure that you are using ESP Ghostscript rather\n"); - fprintf(stderr, "ERROR: Gutenprint: than GNU or AFPL Ghostscript with CUPS.\n"); - fprintf(stderr, "ERROR: Gutenprint: If this is not the cause, set LogLevel to debug2 to identify the problem.\n"); + fprintf(stderr, "DEBUG: Gutenprint: Options failed to verify.\n"); + fprintf(stderr, "DEBUG: Gutenprint: Make sure that you are using ESP Ghostscript rather\n"); + fprintf(stderr, "DEBUG: Gutenprint: than GNU or AFPL Ghostscript with CUPS.\n"); + fprintf(stderr, "DEBUG: Gutenprint: If this is not the cause, set LogLevel to debug to identify the problem.\n"); goto cups_abort; } @@ -1047,10 +1095,7 @@ main(int argc, /* I - Number of command-line arguments */ } if (!stp_print(v, &theImage)) - { - fprintf(stderr, "ERROR: Gutenprint failed to print, set LogLevel to debug2 to identify why\n"); goto cups_abort; - } print_messages_as_errors = 0; fflush(stdout); @@ -1061,13 +1106,13 @@ main(int argc, /* I - Number of command-line arguments */ if (cups.row < cups.header.cupsHeight) purge_excess_data(&cups); if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint done printing page %d\n", cups.page + 1); + fprintf(stderr, "DEBUG: Gutenprint: Done printing page %d\n", cups.page + 1); cups.page ++; } if (v) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint ending job\n"); + fprintf(stderr, "DEBUG: Gutenprint: Ending job\n"); stp_end_job(v, &theImage); fflush(stdout); stp_vars_destroy(v); @@ -1076,18 +1121,18 @@ main(int argc, /* I - Number of command-line arguments */ clk = times(&tms); (void) gettimeofday(&t2, &tz); clocks_per_sec = sysconf(_SC_CLK_TCK); - fprintf(stderr, "DEBUG: Gutenprint printed total %.0f bytes\n", + fprintf(stderr, "DEBUG: Gutenprint: Printed total %.0f bytes\n", total_bytes_printed); - fprintf(stderr, "DEBUG: Gutenprint used %.3f seconds user, %.3f seconds system, %.3f seconds elapsed\n", + fprintf(stderr, "DEBUG: Gutenprint: Used %.3f seconds user, %.3f seconds system, %.3f seconds elapsed\n", (double) tms.tms_utime / clocks_per_sec, (double) tms.tms_stime / clocks_per_sec, (double) (t2.tv_sec - t1.tv_sec) + ((double) (t2.tv_usec - t1.tv_usec)) / 1000000.0); - if (! suppress_messages) - fputs("INFO: Gutenprint Ready to print.\n", stderr); + stp_vars_destroy(default_settings); + if (page_size_name) + stp_free(page_size_name); if (fd != 0) close(fd); - stp_vars_destroy(default_settings); return 0; cups_abort: @@ -1101,16 +1146,17 @@ cups_abort: clk = times(&tms); (void) gettimeofday(&t2, &tz); clocks_per_sec = sysconf(_SC_CLK_TCK); - fprintf(stderr, "DEBUG: Gutenprint printed total %.0f bytes\n", + fprintf(stderr, "DEBUG: Gutenprint: Printed total %.0f bytes\n", total_bytes_printed); - fprintf(stderr, "DEBUG: Gutenprint used %.3f seconds user, %.3f seconds system, %.3f seconds elapsed\n", + fprintf(stderr, "DEBUG: Gutenprint: Used %.3f seconds user, %.3f seconds system, %.3f seconds elapsed\n", (double) tms.tms_utime / clocks_per_sec, (double) tms.tms_stime / clocks_per_sec, (double) (t2.tv_sec - t1.tv_sec) + ((double) (t2.tv_usec - t1.tv_usec)) / 1000000.0); - fputs("ERROR: Gutenprint No pages found!\n", stderr); - fputs("ERROR: Gutenprint Invalid printer settings!\n", stderr); + stp_i18n_printf(po, _("ERROR: Invalid Gutenprint driver settings!\n")); stp_vars_destroy(default_settings); + if (page_size_name) + stp_free(page_size_name); if (fd != 0) close(fd); return 1; @@ -1137,8 +1183,13 @@ cups_errfunc(void *file, const char *buf, size_t bytes) FILE *prn = (FILE *)file; while (where < bytes) { - if (print_messages_as_errors) - fputs("ERROR: Gutenprint: ", prn); + if (bytes - where > 6 && strncmp(buf, "ERROR:", 6) == 0) + { + fputs("ERROR: Gutenprint error:", prn); + buf += 6; + } + else if (print_messages_as_errors) + fputs("ERROR: Gutenprint error: ", prn); else fputs("DEBUG: Gutenprint internal: ", prn); while (next_nl < bytes) @@ -1172,7 +1223,7 @@ Image_get_appname(stp_image_t *image) /* I - Image */ { (void)image; - return ("CUPS 1.1.x driver based on Gutenprint"); + return ("CUPS driver based on Gutenprint"); } @@ -1213,7 +1264,9 @@ Image_get_row(stp_image_t *image, /* I - Image */ if ((cups = (cups_image_t *)(image->rep)) == NULL) { - fprintf(stderr, "ERROR: Gutenprint image is null! Please report this bug to gimp-print-devel@lists.sourceforge.net\n"); + stp_i18n_printf(po, _("ERROR: Gutenprint image is not initialized! " + "Please report this bug to " + "gimp-print-devel@lists.sourceforge.net\n")); return STP_IMAGE_STATUS_ABORT; } bytes_per_line = @@ -1221,23 +1274,23 @@ Image_get_row(stp_image_t *image, /* I - Image */ CHAR_BIT; left_margin = ((cups->left_trim * cups->header.cupsBitsPerPixel) + CHAR_BIT - 1) / - CHAR_BIT; + CHAR_BIT; right_margin = ((cups->right_trim * cups->header.cupsBitsPerPixel) + CHAR_BIT - 1) / - CHAR_BIT; + CHAR_BIT; margin = cups->header.cupsBytesPerLine - left_margin - bytes_per_line - right_margin; if (cups->row < cups->header.cupsHeight) { if (! suppress_messages) - fprintf(stderr, "DEBUG2: Gutenprint reading %d %d\n", + fprintf(stderr, "DEBUG2: Gutenprint: Reading %d %d\n", bytes_per_line, cups->row); while (cups->row <= row && cups->row < cups->header.cupsHeight) { if (left_margin > 0) { if (! suppress_messages) - fprintf(stderr, "DEBUG2: Gutenprint tossing left %d (%d)\n", + fprintf(stderr, "DEBUG2: Gutenprint: Tossing left %d (%d)\n", left_margin, cups->left_trim); throwaway_data(left_margin, cups); } @@ -1246,7 +1299,7 @@ Image_get_row(stp_image_t *image, /* I - Image */ if (margin + right_margin > 0) { if (!suppress_messages) - fprintf(stderr, "DEBUG2: Gutenprint tossing right %d (%d) + %d\n", + fprintf(stderr, "DEBUG2: Gutenprint: Tossing right %d (%d) + %d\n", right_margin, cups->right_trim, margin); throwaway_data(margin + right_margin, cups); } @@ -1267,8 +1320,8 @@ Image_get_row(stp_image_t *image, /* I - Image */ memset(data, ((1 << CHAR_BIT) - 1), bytes_per_line); break; default: - fprintf(stderr, "ERROR: Gutenprint Unknown colorspace %d!\n", - cups->header.cupsColorSpace); + stp_i18n_printf(po, _("ERROR: Gutenprint detected a bad colorspace " + "(%d)!\n"), cups->header.cupsColorSpace); return STP_IMAGE_STATUS_ABORT; } } @@ -1283,9 +1336,9 @@ Image_get_row(stp_image_t *image, /* I - Image */ { if (warned == 0) { - fprintf(stderr, - "WARNING: Gutenprint detected bad CUPS bit depth (1). " - "Output quality is degraded. Are you using psnup or non-ADSC PostScript?\n"); + fputs(_("WARNING: Gutenprint detected a bad color depth (1). " + "Output quality is degraded. Are you using psnup or " + "non-ADSC PostScript?\n"), stderr); warned = 1; } for (i = cups->adjusted_width - 1; i >= 0; i--) @@ -1301,15 +1354,18 @@ Image_get_row(stp_image_t *image, /* I - Image */ if (new_percent > cups->last_percent) { if (! suppress_messages) - fprintf(stderr, "INFO: Gutenprint Printing page %d, %d%%\n", - cups->page + 1, new_percent); + { + stp_i18n_printf(po, _("INFO: Printing page %d, %d%%\n"), + cups->page + 1, new_percent); + fprintf(stderr, "ATTR: job-media-progress=%d\n", new_percent); + } cups->last_percent = new_percent; } if (tmp_image_status != STP_IMAGE_STATUS_OK) { if (! suppress_messages) - fprintf(stderr, "DEBUG: Gutenprint image status %d\n", tmp_image_status); + fprintf(stderr, "DEBUG: Gutenprint: Image status %d\n", tmp_image_status); } return tmp_image_status; } @@ -1348,7 +1404,7 @@ Image_init(stp_image_t *image) /* I - Image */ cups->last_percent = 0; if (! suppress_messages) - fprintf(stderr, "INFO: Starting page %d...\n", cups->page + 1); + stp_i18n_printf(po, _("INFO: Starting page %d...\n"), cups->page + 1); /* cups->page + 1 because users expect 1-based counting */ } @@ -1366,7 +1422,7 @@ Image_conclude(stp_image_t *image) /* I - Image */ return; if (! suppress_messages) - fprintf(stderr, "INFO: Gutenprint Finished page %d...\n", cups->page + 1); + stp_i18n_printf(po, _("INFO: Finished page %d...\n"), cups->page + 1); } /* @@ -1389,5 +1445,5 @@ Image_width(stp_image_t *image) /* I - Image */ /* - * End of "$Id: rastertoprinter.c,v 1.120 2008/01/02 01:39:06 rlk Exp $". + * End of "$Id: rastertoprinter.c,v 1.136 2008/10/04 17:47:50 rlk Exp $". */ diff --git a/src/cups/test-ppds b/src/cups/test-ppds index 868b072..a5fa5a7 100755 --- a/src/cups/test-ppds +++ b/src/cups/test-ppds @@ -1,8 +1,11 @@ #!/bin/sh -rm -rf ppd ppd-stamp - -make ppd +if [ "$#" = 0 ] ; then + echo "Bypassing test-ppds for now due to bugs in cupstestppd!" + exit 0 + rm -rf ppd ppd-stamp + make ppd +fi ppd_count=`find ppd \( -name '*.ppd.gz' -o -name '*.ppd' \) -print | wc -l` @@ -13,7 +16,13 @@ if [ -z "$failures" ] ; then exit 0 fi -echo $failures | xargs cupstestppd +# Use this with "normal" PPD files without translated numbers. +echo $failures | xargs cupstestppd 2>&1 | egrep -v 'Missing "[a-z][a-z](_[A-Z][A-Z])?" translation string for option Stp((Brightness|Contrast|Saturation), choice None|([a-zA-Z0-9]+, choice (-?[0-9]+)))!$' |egrep -v 'Missing cupsICCProfile file' + +# Use this with PPD files with translated numbers (genppd -N) +# With normal globalized PPD files this will yield hundreds of megabytes +# of errors. +#echo $failures | xargs cupstestppd 2>&1 |egrep -v 'Missing cupsICCProfile file' fail_count=`echo "$failures" | wc -l` echo "$fail_count/$ppd_count fail" diff --git a/src/cups/test-rastertogutenprint.in b/src/cups/test-rastertogutenprint.in index afa38d7..8582037 100755 --- a/src/cups/test-rastertogutenprint.in +++ b/src/cups/test-rastertogutenprint.in @@ -1,9 +1,9 @@ -#!/bin/sh +#!@SHELL@ retval=0 if [ -z "$STP_DATA_PATH" ] ; then - STP_DATA_PATH=`pwd`/../main + STP_DATA_PATH=`pwd`/../xml export STP_DATA_PATH fi @@ -14,6 +14,11 @@ fi single='' all_models='' +verbose='' +make_ppds=1 +md5dir='' +outdir='' +cupsargs='' usage() { echo "Usage: test-rastertogutenprint [-s] [-v|--valgrind]" @@ -28,6 +33,11 @@ set_args() { -v|--valgrind) valopts='--tool=memcheck' ; valgrind=`expr $valgrind + 1` ;; -c|--cachegrind) valopts='--tool=cachegrind'; valgrind=4 ;; -g|--gdb-attach) valopts='--gdb-attach=yes' ;; + -V|--verbose) verbose=1 ;; + -n|--no-make-ppds) make_ppds='' ;; + -O|--output) shift; outdir="$1" ;; + -o|--option) shift; cupsargs="$cupsargs $1" ;; + -m|--md5dir) shift; md5dir="$1" ;; --) shift; args="$@"; return ;; *) return ;; esac @@ -35,20 +45,47 @@ set_args() { done } +set_args `getopt vcgsVnO:m:o: "$@"` -set_args `getopt vcgs "$@"` +if [ -n "$outdir" -a ! -d "$outdir" ] ; then + mkdir -p "$outdir" +fi +if [ -n "$md5dir" -a ! -d "$md5dir" ] ; then + mkdir -p "$md5dir" +fi version="@GUTENPRINT_MAJOR_VERSION@.@GUTENPRINT_MINOR_VERSION@"; cupsdir="@cups_conf_serverbin@/filter" -pages='24-26' +if [ -x "$cupsdir/pstoraster" ] ; then + pages='page-ranges=24-26 ' +else + pages='' +fi if [ ! -x "$cupsdir/cgpdftoraster" -a ! -x "$cupsdir/pdftops" ] ; then echo 'CUPS does not appear to be installed, skipping test' exit 0 fi -STP_SUPPRESS_MESSAGES=1 -export STP_SUPPRESS_MESSAGES +cleanup() { + if [ -f "$tfile" ] ; then + rm -f $tfile + fi + exit 1 +} + +pdftops="`type -p pdftops`" + +if [ -n "$pdftops" -a ! -x "$cupsdir/cgpdftoraster" ] ; then + tfile=`mktemp` + trap cleanup 1 2 3 6 14 15 30 + $pdftops -f 24 -l 26 ../../doc/gutenprint-users-manual.pdf $tfile +fi + +if [ -z "$verbose" ] ; then + STP_SUPPRESS_MESSAGES=1 + export STP_SUPPRESS_MESSAGES +fi is_duplicate() { model=`gunzip -c "$1" | grep '^.StpDriverModelFamily' | awk '{print $2}'` @@ -60,13 +97,20 @@ is_duplicate() { all_models="$model $all_models" } +# Note that using CUPS arguments may trigger valgrind memory leaks in +# CUPS. +#cupsargs='PageSize=Custom.400.00x500.00' +#cupsargs='PageSize=Custom.324x495 Resolution=180dpi' +#cupsargs='PageSize=w324h495 Resolution=180dpi' +#cupsargs='PageSize=A8' + run_rastertogp() { case "$valgrind" in - 1) valgrind $valopts -q --num-callers=100 --leak-check=yes --error-limit=no ./rastertogutenprint.$version 1 1 1 1 '' ;; - 2) valgrind $valopts --num-callers=100 --leak-resolution=high --leak-check=yes --error-limit=no ./rastertogutenprint.$version 1 1 1 1 '' ;; - 3) valgrind $valopts --error-limit=no --num-callers=100 --show-reachable=yes --leak-resolution=high --leak-check=yes ./rastertogutenprint.$version 1 1 1 1 '' ;; - 4) valgrind $valopts ./rastertogutenprint.$version 1 1 1 1 '' ;; - *) ./rastertogutenprint.$version 1 1 1 1 '' ;; + 1) valgrind $valopts -q --num-callers=100 --leak-check=yes --error-limit=no ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; + 2) valgrind $valopts --num-callers=100 --leak-resolution=high --leak-check=yes --error-limit=no ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; + 3) valgrind $valopts --error-limit=no --num-callers=100 --show-reachable=yes --leak-resolution=high --leak-check=yes ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; + 4) valgrind $valopts ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; + *) ./rastertogutenprint.$version 1 1 1 1 "$cupsargs" ;; esac if [ $? -ne 0 ] ; then retval=1 @@ -74,8 +118,87 @@ run_rastertogp() { exit $retval } +get_ppds() { + args="$@" + if [ -n "$args" ] ; then + for f in "$@" ; do + if [ -r "$f" ] ; then + echo $f + elif [ -r "ppd/C/$f" ] ; then + echo "ppd/C/$f" + elif [ -f "ppd/C/${f}.ppd" ] ; then + echo "ppd/C/${f}.ppd" + elif [ -f "ppd/C/${f}.ppd.gz" ] ; then + echo "ppd/C/${f}.ppd.gz" + elif [ -f "ppd/C/${f}.ppd.GZ" ] ; then + echo "ppd/C/${f}.ppd.GZ" + elif [ -f "ppd/C/${f}.ppd.bz2" ] ; then + echo "ppd/C/${f}.ppd.bz2" + elif [ -f "ppd/C/${f}.ppd.BZ2" ] ; then + echo "ppd/C/${f}.ppd.BZ2" + elif [ -f "ppd/C/${f}.ppd.z" ] ; then + echo "ppd/C/${f}.ppd.z" + elif [ -f "ppd/C/${f}.ppd.Z" ] ; then + echo "ppd/C/${f}.ppd.Z" + elif [ -f "ppd/C/stp-${f}.ppd" ] ; then + echo "ppd/C/stp-${f}.ppd" + elif [ -f "ppd/C/stp-${f}.ppd.gz" ] ; then + echo "ppd/C/stp-${f}.ppd.gz" + elif [ -f "ppd/C/stp-${f}.ppd.GZ" ] ; then + echo "ppd/C/stp-${f}.ppd.GZ" + elif [ -f "ppd/C/stp-${f}.ppd.bz2" ] ; then + echo "ppd/C/stp-${f}.ppd.bz2" + elif [ -f "ppd/C/stp-${f}.ppd.BZ2" ] ; then + echo "ppd/C/stp-${f}.ppd.BZ2" + elif [ -f "ppd/C/stp-${f}.ppd.z" ] ; then + echo "ppd/C/stp-${f}.ppd.z" + elif [ -f "ppd/C/stp-${f}.ppd.Z" ] ; then + echo "ppd/C/stp-${f}.ppd.Z" + elif [ -f "ppd/C/stp-${f}.${version}.ppd" ] ; then + echo "ppd/C/stp-${f}.${version}.ppd" + elif [ -f "ppd/C/stp-${f}.${version}.ppd.gz" ] ; then + echo "ppd/C/stp-${f}.${version}.ppd.gz" + elif [ -f "ppd/C/stp-${f}.${version}.ppd.GZ" ] ; then + echo "ppd/C/stp-${f}.${version}.ppd.GZ" + elif [ -f "ppd/C/stp-${f}.${version}.ppd.bz2" ] ; then + echo "ppd/C/stp-${f}.${version}.ppd.bz2" + elif [ -f "ppd/C/stp-${f}.${version}.ppd.BZ2" ] ; then + echo "ppd/C/stp-${f}.${version}.ppd.BZ2" + elif [ -f "ppd/C/stp-${f}.${version}.ppd.z" ] ; then + echo "ppd/C/stp-${f}.${version}.ppd.z" + elif [ -f "ppd/C/stp-${f}.${version}.ppd.Z" ] ; then + echo "ppd/C/stp-${f}.${version}.ppd.Z" + fi + done + else + echo ppd/C/*.ppd* + fi +} + +if [ -n "$make_ppds" -o ! -d ppd/C ] ; then + make ppd-nonls +fi + +do_output() { + if [ -n "`echo "$PPD" |grep '\.gz$'`" ] ; then + driver=`gunzip -c "$PPD" | grep '^\*StpDriverName:' |awk '{print $2}' | sed 's/"//g'` + else + driver=`grep '^\*StpDriverName:' "$PPD" |awk '{print $2}' | sed 's/"//g'` + fi + if [ -n "$outdir" ] ; then + cat > "$outdir/$driver.prn" + if [ -n "$md5dir" ] ; then + (cd "$outdir"; cat "$driver.prn") | md5sum | sed "s/-/\*$driver/" > "$md5dir/$driver.md5" + fi + elif [ -n "$md5dir" ] ; then + cat | md5sum | sed "s/-/\*$driver/" > "$md5dir/$driver.md5" + else + cat > /dev/null + fi +} + if [ -d ppd/C ] ; then - for f in ppd/C/*.ppd* ; do + for f in `get_ppds $args` ; do skip='' if [ -n "$single" ] ; then is_duplicate $f @@ -85,9 +208,13 @@ if [ -d ppd/C ] ; then PPD=$f export PPD if [ -x "$cupsdir/cgpdftoraster" ] ; then - output="`($cupsdir/cgpdftoraster 1 1 1 1 page-ranges=$pages < ../../doc/gutenprint-users-manual.pdf 2>/dev/null | run_rastertogp > /dev/null) 2>&1`" + output="`($cupsdir/cgpdftoraster 1 1 1 1 $pages < ../../doc/gutenprint-users-manual.pdf 2>/dev/null | run_rastertogp | do_output) 2>&1`" + elif [ -f "$tfile" ] ; then + output="`($cupsdir/pstops 1 1 1 1 \"$cupsargs\" < $tfile 2>/dev/null | $cupsdir/pstoraster 2>/dev/null | run_rastertogp | do_output) 2>&1`" + elif [ -x "$cupsdir/pstoraster" ] ; then + output="`($cupsdir/pdftops 1 1 1 1 \"$pages$cupsargs\" < ../../doc/gutenprint-users-manual.pdf 2>/dev/null | $cupsdir/pstops 1 1 1 1 \"$pages$cupsargs\" 2>/dev/null | $cupsdir/pstoraster 2>/dev/null | run_rastertogp | do_output) 2>&1`" else - output="`($cupsdir/pdftops 1 1 1 1 page-ranges=$pages < ../../doc/gutenprint-users-manual.pdf 2>/dev/null | $cupsdir/pstops 1 1 1 1 page-ranges=$pages 2>/dev/null | $cupsdir/pstoraster 2>/dev/null | run_rastertogp > /dev/null) 2>&1`" + output="`($cupsdir/imagetoraster 1 1 1 1 \"$pages$cupsargs\" < calibrate.ppm 2>/dev/null | run_rastertogp | do_output) 2>&1`" fi if [ $? -ne 0 ] ; then retval=1 @@ -100,4 +227,7 @@ if [ -d ppd/C ] ; then fi done fi +if [ -f "$tfile" ] ; then + rm -f $tfile +fi exit $retval |