diff options
author | Heinrich Wendel <lanius@gentoo.org> | 2003-11-25 18:07:44 +0000 |
---|---|---|
committer | Heinrich Wendel <lanius@gentoo.org> | 2003-11-25 18:07:44 +0000 |
commit | 9293020da206440cabf5b5f77707c1a1b115f0bf (patch) | |
tree | 3f21b260d718362c2a4ca58acfa150a225dee618 /net-print/cups | |
parent | bump (diff) | |
download | gentoo-2-9293020da206440cabf5b5f77707c1a1b115f0bf.tar.gz gentoo-2-9293020da206440cabf5b5f77707c1a1b115f0bf.tar.bz2 gentoo-2-9293020da206440cabf5b5f77707c1a1b115f0bf.zip |
bump
Diffstat (limited to 'net-print/cups')
-rw-r--r-- | net-print/cups/ChangeLog | 5 | ||||
-rw-r--r-- | net-print/cups/Manifest | 11 | ||||
-rw-r--r-- | net-print/cups/cups-1.1.18-r5.ebuild | 133 | ||||
-rw-r--r-- | net-print/cups/cups-1.1.20.ebuild (renamed from net-print/cups/cups-1.1.19.ebuild) | 36 | ||||
-rw-r--r-- | net-print/cups/files/cups-1.1.18-str75.patchv2 | 270 | ||||
-rw-r--r-- | net-print/cups/files/cupsomatic | 1172 | ||||
-rw-r--r-- | net-print/cups/files/digest-cups-1.1.18-r5 | 1 | ||||
-rw-r--r-- | net-print/cups/files/digest-cups-1.1.19 | 1 | ||||
-rw-r--r-- | net-print/cups/files/digest-cups-1.1.20 | 1 | ||||
-rw-r--r-- | net-print/cups/files/foomatic-gswrapper | 48 |
10 files changed, 20 insertions, 1658 deletions
diff --git a/net-print/cups/ChangeLog b/net-print/cups/ChangeLog index 39f15e339ffb..6446838e32ec 100644 --- a/net-print/cups/ChangeLog +++ b/net-print/cups/ChangeLog @@ -1,6 +1,9 @@ # ChangeLog for net-print/cups # Copyright 2002-2003 Gentoo Technologies, Inc.; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-print/cups/ChangeLog,v 1.51 2003/11/05 20:08:43 lanius Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-print/cups/ChangeLog,v 1.52 2003/11/25 18:07:37 lanius Exp $ + + 25 Nov 2003; Heinrich Wendel <lanius@gentoo.org> cups-1.1.20.ebuild: + version bump, removed libjpeg patch 05 Nov 2003; Heinrich Wendel <lanius@gentoo.org> files/cupsd.rc6: bug #32768 (hotplug dep) diff --git a/net-print/cups/Manifest b/net-print/cups/Manifest index 3a5730c2aec6..579b59e890a6 100644 --- a/net-print/cups/Manifest +++ b/net-print/cups/Manifest @@ -1,19 +1,12 @@ -MD5 0fc1604543cfe18b311fa3c4830e64e5 cups-1.1.19.ebuild 3609 -MD5 bc1ada92d83e3ed3b95f677f99189de4 cups-1.1.20.ebuild 3360 -MD5 14e365c5a028c9a90352629c7d553950 cups-1.1.18-r5.ebuild 3646 +MD5 436aa5c7ae305b00aea26f1ecb0a0d71 cups-1.1.20.ebuild 3357 MD5 d93b395afbc972253aac99fa0172866c cups-1.1.19-r1.ebuild 3930 -MD5 3c35fc853c8899bff07a73af12403ad4 ChangeLog 7605 +MD5 7ffc114e7d40a6695b50bc113ff4392d ChangeLog 7716 MD5 26b4b081d538c195dc39bcb2ec8e6f3a metadata.xml 161 -MD5 a3301abd5242f434926ff77967e352d0 files/foomatic-gswrapper 1711 -MD5 7f2456e05feba9417282438030ea7590 files/cupsomatic 38029 MD5 4b190a6fe4d933beb1bbe60dfd055715 files/cupsd.rc6 532 MD5 cc4ea180acf9945f4c121de0c02093e7 files/cups.pam 233 -MD5 28180a32f4b7e4d332f17fd20c99ee91 files/digest-cups-1.1.19 72 MD5 baaa1e0bc63f959779998f5e57de6f9d files/digest-cups-1.1.20 72 -MD5 23295c953b3c5dfed3b9ecff049f3421 files/digest-cups-1.1.18-r5 72 MD5 28180a32f4b7e4d332f17fd20c99ee91 files/digest-cups-1.1.19-r1 72 MD5 7bce495a238ee9dbebb61496f3b3ae51 files/disable-strip.patch 422 MD5 e8608b3605ae84d0f10dbc635d65292a files/cupsd.conf-1.1.18 20538 -MD5 5484493b0e4d631f7ccea67f988ff0e6 files/cups-1.1.18-str75.patchv2 7223 MD5 ec90893091ccb9fa45c107c08dc7152c files/configure-jpeg-buildfix.diff 308 MD5 ea78abb13208bbcb5b870b53abc64a7e files/cups.xinetd 367 diff --git a/net-print/cups/cups-1.1.18-r5.ebuild b/net-print/cups/cups-1.1.18-r5.ebuild deleted file mode 100644 index f2542107b061..000000000000 --- a/net-print/cups/cups-1.1.18-r5.ebuild +++ /dev/null @@ -1,133 +0,0 @@ -# Copyright 1999-2003 Gentoo Technologies, Inc. -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-print/cups/cups-1.1.18-r5.ebuild,v 1.8 2003/09/19 18:02:18 rajiv Exp $ - -inherit eutils flag-o-matic - -IUSE="ssl slp pam usb" - -DESCRIPTION="The Common Unix Printing System" -HOMEPAGE="http://www.cups.org" - -S=${WORKDIR}/${P} -SRC_URI="ftp://ftp.easysw.com/pub/cups/${PV}/${P}-source.tar.bz2" -PROVIDE="virtual/lpr" - -DEPEND="virtual/glibc - pam? ( >=sys-libs/pam-0.75 ) - ssl? ( >=dev-libs/openssl-0.9.6b ) - slp? ( >=net-libs/openslp-1.0.4 ) - >=media-libs/libpng-1.2.1 - >=media-libs/tiff-3.5.5 - >=media-libs/jpeg-6b - usb? ( >=sys-apps/hotplug-20020401-r1 )" -RDEPEND="${DEPEND} !virtual/lpr" - -LICENSE="GPL-2" -SLOT="0" -KEYWORDS="x86 ppc sparc alpha hppa" - -filter-flags -fomit-frame-pointer - -src_unpack() { - unpack ${A} || die - cd ${S} || die - - epatch ${FILESDIR}/${P}-str75.patchv2 - - #make sure libcupsimage gets linked with libjpeg - epatch ${FILESDIR}/configure-jpeg-buildfix.diff || die - - epatch ${FILESDIR}/disable-strip.patch || die - - WANT_AUTOCONF_2_5=1 autoconf || die -} - -src_compile() { - local myconf - use pam || myconf="${myconf} --disable-pam" - use ssl || myconf="${myconf} --disable-ssl" - use slp || myconf="${myconf} --disable-slp" - - ./configure \ - --with-cups-user=lp \ - --with-cups-group=lp \ - --host=${CHOST} ${myconf} || die "bad ./configure" - - make || die "compile problem" -} - -src_install() { - dodir /var/spool /var/log/cups /etc/cups - - make \ - LOCALEDIR=${D}/usr/share/locale \ - DOCDIR=${D}/usr/share/cups/docs \ - REQUESTS=${D}/var/spool/cups \ - SERVERBIN=${D}/usr/lib/cups \ - DATADIR=${D}/usr/share/cups \ - INCLUDEDIR=${D}/usr/include \ - AMANDIR=${D}/usr/share/man \ - PMANDIR=${D}/usr/share/man \ - MANDIR=${D}/usr/share/man \ - SERVERROOT=${D}/etc/cups \ - LOGDIR=${D}/var/log/cups \ - SBINDIR=${D}/usr/sbin \ - PAMDIR=${D}/etc/pam.d \ - EXEC_PREFIX=${D}/usr \ - LIBDIR=${D}/usr/lib \ - BINDIR=${D}/usr/bin \ - bindir=${D}/usr/bin \ - INITDIR=${D}/etc \ - PREFIX=${D} \ - install || die "install problem" - - dodoc {CHANGES,CREDITS,ENCRYPTION,LICENSE,README}.txt - dosym /usr/share/cups/docs /usr/share/doc/${PF}/html - - #seems nobody installs it like this anymore.. security risk? - #fowners lp.root /usr/bin/lppasswd - #fperms 4755 /usr/bin/lppasswd - - # cleanups - rm -rf ${D}/etc/init.d - rm -rf ${D}/etc/pam.d - rm -rf ${D}/etc/rc* - rm -rf ${D}/usr/share/man/cat* - rm -rf ${D}/etc/cups/{certs,interfaces,ppd} - rm -rf ${D}/var - - mv ${D}/etc/cups/cupsd.conf ${D}/etc/cups/cupsd.conf.orig - sed -e "s:^#\(DocumentRoot\).*:\1 /usr/share/cups/docs:" \ - -e "s:^#\(SystemGroup\).*:\1 lp:" \ - -e "s:^#\(User\).*:\1 lp:" \ - -e "s:^#\(Group\).*:\1 lp:" \ - ${D}/etc/cups/cupsd.conf.orig > ${D}/etc/cups/cupsd.conf - rm -f ${D}/etc/cups/cupsd.conf.orig - - # foomatic cups filters - exeinto /usr/lib/cups/filter - doexe ${FILESDIR}/cupsomatic - doexe ${FILESDIR}/foomatic-gswrapper - - insinto /etc/pam.d ; newins ${FILESDIR}/cups.pam cups - exeinto /etc/init.d ; newexe ${FILESDIR}/cupsd.rc6 cupsd - insinto /etc/xinetd.d ; newins ${FILESDIR}/cups.xinetd cups-lpd - - insinto /etc/cups; newins ${FILESDIR}/cupsd.conf-1.1.18 cupsd.conf -} - -pkg_postinst() { - install -d -m0755 ${ROOT}/var/log/cups - install -d -m0755 ${ROOT}/var/spool - install -m0700 -o lp -d ${ROOT}/var/spool/cups - install -m1700 -o lp -d ${ROOT}/var/spool/cups/tmp - install -m0711 -o lp -d ${ROOT}/etc/cups/certs - install -d -m0755 ${ROOT}/etc/cups/{interfaces,ppd} - - einfo - einfo "emerge >=app-text/ghostscript-7.05-r1 if you need to print" - einfo "to a non-postscript printer(after cups itself! even if it's" - einfo "already installed!)" - einfo -} diff --git a/net-print/cups/cups-1.1.19.ebuild b/net-print/cups/cups-1.1.20.ebuild index ab61701d367d..4f559fa26d17 100644 --- a/net-print/cups/cups-1.1.19.ebuild +++ b/net-print/cups/cups-1.1.20.ebuild @@ -1,10 +1,10 @@ # Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/net-print/cups/cups-1.1.19.ebuild,v 1.5 2003/09/19 18:02:18 rajiv Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-print/cups/cups-1.1.20.ebuild,v 1.1 2003/11/25 18:07:37 lanius Exp $ inherit eutils flag-o-matic -IUSE="ssl slp pam usb" +IUSE="ssl slp pam" DESCRIPTION="The Common Unix Printing System" HOMEPAGE="http://www.cups.org" @@ -19,13 +19,14 @@ DEPEND="virtual/glibc slp? ( >=net-libs/openslp-1.0.4 ) >=media-libs/libpng-1.2.1 >=media-libs/tiff-3.5.5 - >=media-libs/jpeg-6b - usb? ( >=sys-apps/hotplug-20020401-r1 )" + >=media-libs/jpeg-6b" RDEPEND="${DEPEND} !virtual/lpr" +has_version net-print/foomatic && newdepend ">=net-print/foomatic-3.0.0" + LICENSE="GPL-2" SLOT="0" -KEYWORDS="x86 ppc sparc alpha hppa amd64" +KEYWORDS="~x86 ~ppc ~sparc ~alpha ~hppa ~amd64 ~ia64" filter-flags -fomit-frame-pointer @@ -33,9 +34,6 @@ src_unpack() { unpack ${A} || die cd ${S} || die - #make sure libcupsimage gets linked with libjpeg - epatch ${FILESDIR}/configure-jpeg-buildfix.diff || die - epatch ${FILESDIR}/disable-strip.patch || die WANT_AUTOCONF_2_5=1 autoconf || die @@ -95,24 +93,17 @@ src_install() { rm -rf ${D}/etc/cups/{certs,interfaces,ppd} rm -rf ${D}/var - mv ${D}/etc/cups/cupsd.conf ${D}/etc/cups/cupsd.conf.orig - sed -e "s:^#\(DocumentRoot\).*:\1 /usr/share/cups/docs:" \ + sed -i -e "s:^#\(DocumentRoot\).*:\1 /usr/share/cups/docs:" \ -e "s:^#\(SystemGroup\).*:\1 lp:" \ -e "s:^#\(User\).*:\1 lp:" \ -e "s:^#\(Group\).*:\1 lp:" \ - ${D}/etc/cups/cupsd.conf.orig > ${D}/etc/cups/cupsd.conf - rm -f ${D}/etc/cups/cupsd.conf.orig - - # foomatic cups filters - exeinto /usr/lib/cups/filter - doexe ${FILESDIR}/cupsomatic - doexe ${FILESDIR}/foomatic-gswrapper + ${D}/etc/cups/cupsd.conf insinto /etc/pam.d ; newins ${FILESDIR}/cups.pam cups exeinto /etc/init.d ; newexe ${FILESDIR}/cupsd.rc6 cupsd insinto /etc/xinetd.d ; newins ${FILESDIR}/cups.xinetd cups-lpd - insinto /etc/cups; newins ${FILESDIR}/cupsd.conf-1.1.18 cupsd.conf + #insinto /etc/cups; newins ${FILESDIR}/cupsd.conf-1.1.18 cupsd.conf } pkg_postinst() { @@ -123,9 +114,8 @@ pkg_postinst() { install -m0711 -o lp -d ${ROOT}/etc/cups/certs install -d -m0755 ${ROOT}/etc/cups/{interfaces,ppd} - einfo - einfo "emerge >=app-text/ghostscript-7.05-r1 if you need to print" - einfo "to a non-postscript printer(after cups itself! even if it's" - einfo "already installed!)" - einfo + einfo "If you're using a USB printer, \"emerge hotplug; rc-update add" + einfo "hotplug default\" is something you should probably do. This" + einfo "will allow any USB kernel modules (if present) to be loaded" + einfo "automatically at boot." } diff --git a/net-print/cups/files/cups-1.1.18-str75.patchv2 b/net-print/cups/files/cups-1.1.18-str75.patchv2 deleted file mode 100644 index 701864b65325..000000000000 --- a/net-print/cups/files/cups-1.1.18-str75.patchv2 +++ /dev/null @@ -1,270 +0,0 @@ -diff -ur cups-1.1.18/cups/http.c cups-1.1.18.patched/cups/http.c ---- cups-1.1.18/cups/http.c Tue Dec 17 13:56:42 2002 -+++ cups-1.1.18.patched/cups/http.c Mon May 12 16:41:26 2003 -@@ -29,6 +29,7 @@ - * default HTTP proxy (if any). - * httpCheck() - Check to see if there is a pending response from - * the server. -+ * httpWait() - Wait for data available on a connection. - * httpClose() - Close an HTTP connection... - * httpConnect() - Connect to a HTTP server. - * httpConnectEncrypt() - Connect to a HTTP server using encryption. -@@ -240,6 +241,18 @@ - int /* O - 0 = no data, 1 = data available */ - httpCheck(http_t *http) /* I - HTTP connection */ - { -+ return (httpWait(http, 0)); -+} -+ -+ -+/* -+ * 'httpWait()' - Wait for data available on a connection. -+ */ -+ -+int /* O - 0 = no data, 1 = data available */ -+httpWait(http_t *http, /* I - HTTP connection */ -+ int msec) /* I - Milliseconds to wait */ -+{ - fd_set input; /* Input set for select() */ - struct timeval timeout; /* Timeout */ - -@@ -254,6 +267,14 @@ - if (http->used) - return (1); - -+#ifdef HAVE_LIBSSL -+ if (http->tls) -+ { -+ if (SSL_pending((SSL *)(http->tls))) -+ return (1); -+ } -+#endif /* HAVE_LIBSSL */ -+ - /* - * Then try doing a select() to poll the socket... - */ -@@ -261,10 +282,15 @@ - FD_ZERO(&input); - FD_SET(http->fd, &input); - -- timeout.tv_sec = 0; -- timeout.tv_usec = 0; -+ if (msec >= 0) -+ { -+ timeout.tv_sec = msec / 1000; -+ timeout.tv_usec = (msec % 1000) * 1000; - -- return (select(http->fd + 1, &input, NULL, NULL, &timeout) > 0); -+ return (select(http->fd + 1, &input, NULL, NULL, &timeout) > 0); -+ } -+ else -+ return (select(http->fd + 1, &input, NULL, NULL, NULL) > 0); - } - - -@@ -857,7 +883,10 @@ - char buffer[8192]; /* Junk buffer */ - - -- while (httpRead(http, buffer, sizeof(buffer)) > 0); -+ if (http->state != HTTP_WAITING) -+ { -+ while (httpRead(http, buffer, sizeof(buffer)) > 0); -+ } - } - - -@@ -931,6 +960,9 @@ - * Buffer small reads for better performance... - */ - -+ if (!http->blocking && !httpWait(http, 1000)) -+ return (0); -+ - if (http->data_remaining > sizeof(http->buffer)) - bytes = sizeof(http->buffer); - else -@@ -967,7 +999,10 @@ - #endif /* WIN32 */ - } - else -+ { -+ http->error = EPIPE; - return (0); -+ } - } - - if (http->used > 0) -@@ -987,10 +1022,18 @@ - } - #ifdef HAVE_LIBSSL - else if (http->tls) -+ { -+ if (!http->blocking && !httpWait(http, 1000)) -+ return (0); -+ - bytes = SSL_read((SSL *)(http->tls), buffer, length); -+ } - #endif /* HAVE_LIBSSL */ - else - { -+ if (!http->blocking && !httpWait(http, 1000)) -+ return (0); -+ - DEBUG_printf(("httpRead: reading %d bytes from socket...\n", length)); - bytes = recv(http->fd, buffer, length, 0); - DEBUG_printf(("httpRead: read %d bytes from socket...\n", bytes)); -@@ -1009,6 +1052,11 @@ - http->error = errno; - #endif /* WIN32 */ - } -+ else -+ { -+ http->error = EPIPE; -+ return (0); -+ } - - if (http->data_remaining == 0) - { -@@ -1247,13 +1295,16 @@ - * No newline; see if there is more data to be read... - */ - -+ if (!http->blocking && !httpWait(http, 1000)) -+ return (NULL); -+ - #ifdef HAVE_LIBSSL - if (http->tls) - bytes = SSL_read((SSL *)(http->tls), bufend, - HTTP_MAX_BUFFER - http->used); - else - #endif /* HAVE_LIBSSL */ -- bytes = recv(http->fd, bufend, HTTP_MAX_BUFFER - http->used, 0); -+ bytes = recv(http->fd, bufend, HTTP_MAX_BUFFER - http->used, 0); - - if (bytes < 0) - { -@@ -1285,8 +1336,7 @@ - } - else if (bytes == 0) - { -- if (http->blocking) -- http->error = EPIPE; -+ http->error = EPIPE; - - return (NULL); - } -@@ -1554,6 +1604,7 @@ - case HTTP_POST_RECV : - case HTTP_PUT : - http->state ++; -+ case HTTP_POST_SEND : - break; - - default : -diff -ur cups-1.1.18/cups/http.h cups-1.1.18.patched/cups/http.h ---- cups-1.1.18/cups/http.h Tue Dec 17 13:56:42 2002 -+++ cups-1.1.18.patched/cups/http.h Fri May 9 13:59:10 2003 -@@ -338,6 +338,9 @@ - char [33]); - extern char *httpMD5String(const md5_byte_t *, char [33]); - -+/**** New in CUPS 1.1.19 ****/ -+extern int httpWait(http_t *http, int msec); -+ - - /* - * C++ magic... -diff -ur cups-1.1.18/cups/ipp.c cups-1.1.18.patched/cups/ipp.c ---- cups-1.1.18/cups/ipp.c Tue Dec 17 13:56:42 2002 -+++ cups-1.1.18.patched/cups/ipp.c Fri May 9 14:08:44 2003 -@@ -2036,7 +2036,14 @@ - if (http->data_remaining == 0) - { - if (http->data_encoding == HTTP_ENCODE_CHUNKED) -- httpGets(len, sizeof(len), http); -+ { -+ /* -+ * Get the trailing CR LF after the chunk... -+ */ -+ -+ if (!httpGets(len, sizeof(len), http)) -+ return (-1); -+ } - - if (http->data_encoding != HTTP_ENCODE_CHUNKED) - { -diff -ur cups-1.1.18/scheduler/client.c cups-1.1.18.patched/scheduler/client.c ---- cups-1.1.18/scheduler/client.c Tue Dec 17 14:00:14 2002 -+++ cups-1.1.18.patched/scheduler/client.c Fri May 9 14:25:52 2003 -@@ -82,6 +82,8 @@ - client_t *con; /* New client pointer */ - unsigned address;/* Address of client */ - struct hostent *host; /* Host entry for address */ -+ static time_t last_dos = 0; -+ /* Time of last DoS attack */ - - - LogMessage(L_DEBUG2, "AcceptClient(%p) %d NumClients = %d", -@@ -134,8 +136,12 @@ - - if (count >= MaxClientsPerHost) - { -- LogMessage(L_WARN, "Possible DoS attack - more than %d clients connecting from %s!", -- MaxClientsPerHost, Clients[i].http.hostname); -+ if ((time(NULL) - last_dos) >= 60) -+ { -+ last_dos = time(NULL); -+ LogMessage(L_WARN, "Possible DoS attack - more than %d clients connecting from %s!", -+ MaxClientsPerHost, Clients[i].http.hostname); -+ } - - #ifdef WIN32 - closesocket(con->http.fd); -@@ -272,7 +278,7 @@ - setsockopt(con->http.fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); - - /* -- * Add the socket to the select() input mask. -+ * Close this file on all execs... - */ - - fcntl(con->http.fd, F_SETFD, fcntl(con->http.fd, F_GETFD) | FD_CLOEXEC); -@@ -1438,6 +1444,10 @@ - } - } - } -+ else if (con->http.state == HTTP_POST_RECV) -+ { -+ return (0); -+ } - else if (con->http.state != HTTP_POST_SEND) - { - CloseClient(con); -@@ -1784,6 +1794,14 @@ - shutdown(con->http.fd, 0); - con->http.used = 0; - -+ /* -+ * Update the activity time so that we timeout after 30 seconds rather -+ * then the current Timeout setting (300 by default). This prevents -+ * some DoS situations... -+ */ -+ -+ con->http.activity = time(NULL) - Timeout + 30; -+ - LogMessage(L_DEBUG2, "ShutdownClient: Removing fd %d from InputSet...", - con->http.fd); - -diff -ur cups-1.1.18/test/run-stp-tests.sh cups-1.1.18.patched/test/run-stp-tests.sh ---- cups-1.1.18/test/run-stp-tests.sh Tue Dec 17 14:00:25 2002 -+++ cups-1.1.18.patched/test/run-stp-tests.sh Fri May 9 14:18:48 2003 -@@ -142,6 +142,7 @@ - - cat >/tmp/$user/cupsd.conf <<EOF - Browsing Off -+FileDevice Yes - Listen 127.0.0.1:$port - User $user - ServerRoot /tmp/$user - ServerRoot /tmp/$user diff --git a/net-print/cups/files/cupsomatic b/net-print/cups/files/cupsomatic deleted file mode 100644 index ef98b1410e19..000000000000 --- a/net-print/cups/files/cupsomatic +++ /dev/null @@ -1,1172 +0,0 @@ -#!/usr/bin/perl - -# The above Perl path may vary on your system; fix it!!! - -# Cupsomatic is intended to be used as a CUPS filter for printers -# defined in a PPD file (CUPS-O-Matic or PPD-O-Matic) obtained from -# the Linux Printing Database. -# -# See http://www.linuxprinting.org/cups-doc.html - -# ========================================================================== -# -# User-configurable settings, edit them if needed -# -# ========================================================================== - -# What path to use for filter programs and such. Your printer driver -# must be in the path, as must be Ghostscript, $enscriptcommand, and -# possibly other stuff. The default path is often fine on Linux, but -# may not be on other systems. -# -my $execpath = "/usr/local/bin:/usr/bin:/bin"; - -# Location of the configuration file "filter.conf", this file can be -# used for settings which should apply to all filters (lpdomatic, -# cupsomatic, ...). -# This variable must contain the full pathname of the directory which -# contains the configuration file, usually "/etc/foomatic". -my $configpath = "/etc/foomatic"; - -# For the stuff below, the settings in the configuration file have priority. - -# Enter here your personal command for converting non-postscript files -# (especially text) to PostScript. If you leave it blank, at first the -# line "textfilter: ..." from /etc/foomatic/filter.conf is read and -# then the commands given on the list below are tried, beginning with -# the first one. -# You can set this to "a2ps", "enscript" or "mpage" to select one of the -# default command strings. -my $enscriptcommand = ""; - -# Set to 1 to insert postscript code for accounting. -my $ps_accounting = 1; - -# Set debug to 1 to enable the debug logfile for this filter; it will -# appear as /tmp/prnlog It will contain status from this filter, plus -# Ghostscript stderr output. You can also add a line "debug: 1" to -# your /etc/foomatic/filter.conf to get all your Foomatic filters into -# debug mode. -# -# WARNING: This logfile is a security hole; do not use in production. -my $debug = 0; - -# This is the location of the debug logfile in case you have enabled debugging -# above. -my $logfile = "/tmp/prnlog"; - -# End interesting enduser options - -# ========================================================================== -# -# cupsomatic Perl Foomatic filter script for CUPS -# -# Copyright 2000-2001 Grant Taylor <gtaylor at picante dot com> -# & Till Kamppeter <till dot kamppeter at gmx dot net> -# -# 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. -# - -# Read config file if present -%conf = readConfFile("$configpath/filter.conf"); - -# Determine which filter to use for non-PostScript files to be converted -# to PostScript - -my @enscriptcommands = - ('a2ps -1 @@--medium=@@PAGESIZE@@ @@--center-title=@@JOBTITLE@@ -o - 2>/dev/null', - 'enscript -G @@-M @@PAGESIZE@@ @@-b "Page $%|@@JOBTITLE@@ -p- 2>/dev/null', - 'mpage -o -1 @@-b @@PAGESIZE@@ @@-H -h @@JOBTITLE@@ -P- -'); - -if (defined(%conf) and $conf{textfilter}) -{ - $enscriptcommand = $conf{textfilter}; - $enscriptcommand eq 'a2ps' and $enscriptcommand = $enscriptcommands[0]; - $enscriptcommand eq 'enscript' and $enscriptcommand = $enscriptcommands[1]; - $enscriptcommand eq 'mpage' and $enscriptcommand = $enscriptcommands[2]; -} - -if ($execpath) {$ENV{'PATH'} = $execpath;} - -# Set debug mode -$debug = $conf{debug} if defined(%conf) and defined $conf{debug}; - -# Where to send debugging log output to -if ($debug) { - # Grotesquely unsecure; use for debugging only - open LOG, ">$logfile"; - $logh = *LOG; - - use IO::Handle; - $logh->autoflush(1); -} else { - $logh=*STDERR; -} - -# This piece of PostScript code (initial idea 2001 by Michael Allerhand -# (michael.allerhand at ed dot ac dot uk, vastly improved by Till Kamppeter -# in 2002) lets GhostScript output the page accounting information which -# CUPS needs on standard error. - -$ps_accounting = $conf{ps_accounting} - if defined(%conf) and defined $conf{ps_accounting}; -my $accounting_prolog = $ps_accounting ? "[{ -%% Code for writing CUPS accounting tags on standard error - -/cupsPSLevel2 % Determine whether we can do PostScript level 2 or newer - systemdict/languagelevel 2 copy - known{get exec}{pop pop 1}ifelse 2 ge -def - -/cupsGetNumCopies { % Read the number of Copies requested for the current - % page - cupsPSLevel2 - { - % PS Level 2+: Get number of copies from Page Device dictionary - currentpagedevice /NumCopies get - } - { - % PS Level 1: Number of copies not in Page Device dictionary - null - } - ifelse - % Check whether the number is defined, if it is \"null\" use #copies - % instead - dup null eq { - pop #copies - } - if - % Check whether the number is defined now, if it is still \"null\" use 1 - % instead - dup null eq { - pop 1 - } if -} bind def - -/cupsWrite { % write a string onto standard error - (%stderr) (w) file - exch writestring -} bind def - -/cupsEndPage { % write page log info when we were invoked by \"showpage\" - % or \"copypage\" return \"true\" or \"false\" as we had no - % redefinition of \"EndPage\" - - 2 ne % If the reason code is 0 or 1, we have finshed a page - % (we were invoked by \"showpage\" or \"copypage\"), - % write log info and exit with \"true\" to push out the page. - % In case of reason code 2, we are invoked during device - % deactivation (happens also at a \"setpagedevice\" call), - % here we should not log and return \"false\" - { - % write \"Page <# of page> <# of copies><LF>\" to stderr - (PAGE: ) cupsWrite - % we must add 1 here, the number on the stack is the number - % of \"showpage\" already executed during this job - 1 add 40 string cvs cupsWrite - % space - ( ) cupsWrite - % get the number of copies for this page - cupsGetNumCopies 40 string cvs cupsWrite - % line feed - (\\n) cupsWrite - % page should be ejected - true - } - { - pop % ignore the number of pages already printed - % do not eject paper - false - } - ifelse -} bind def - -<</EndPage{cupsEndPage}>>setpagedevice -} stopped cleartomark -" : ""; - - -# Flush everything immediately. -$|=1; - -my $comversion='$Revision: 1.3 $'; -#'# Fix emacs syntax highlighting -print $logh "Cupsomatic backend version $comversion running...\n"; -# print the command line only in debug mode, Mac OS X adds very many -# options so that CUPS cannot handle the output of the command line -# in its log files. If CUPS encounters a line with more than 1024 characters -# sent into its log files, it aborts the job with an error. -if ($debug) { - print $logh "called with arguments: '",join("','",@ARGV),"'\n"; -} -my $jobtitle = $ARGV[2]; -# Check for and handle inputfile vs stdin -my $inputfile = $ARGV[5]; -if ($inputfile and $inputfile ne '-') { - print $logh 'inputfile handling is broken!!!'; - warn 'inputfile handling is broken!!!'; -} - -# We get the PPD filename in environment variable PPD. -# Load the cups-o-matic data structure from it -# Load also the defaults from the PPD syntax... -my $ppdfile = $ENV{'PPD'}; - -print $logh "ppd=$ppdfile\n"; - -open PPD, "$ppdfile" || do { - print $logh "error opening $ppdfile.\n"; - die "unable to open ppd file $ppdfile"; -}; - -my @datablob; # embedded data -my %ppddefaults; # defaults from PPD -while(<PPD>) { - if (s!^\*\% COMDATA \#!!) { - push (@datablob, $_); - } elsif (m!^\*Default(\w+): ([\w\.\+]+)!) { - # The dot in the default value is needed to support float - # options - $ppddefaults{$1} = $2; - } -} -close PPD; - -# OK, we have the datablob -eval join('',@datablob) || do { - print $logh "unable to evaluate datablob\n"; - die "error in datablob eval"; -}; - -$dat = $VAR1; - -# Determine with which command non-PostScript files are converted to PostScript -if ($enscriptcommand eq "") { - for my $c (@enscriptcommands) { - ($c =~ m/^\s*(\S+)\s+/) || ($c = m/^\s*(\S+)$/); - $command = $1; - for (split(':', $ENV{'PATH'})) { - if (-x "$_/$command") { - $enscriptcommand = $c; - last; - } - } - if ($enscriptcommand ne "") { - last; - } - } - if ($enscriptcommand eq "") { - $enscriptcommand = "echo \"Cannot convert file to PostScript!\" 1>&2"; - } -} - -## First, for arguments with a default, stick the default in as the -## userval. First take the defaults from the embedded data, then take -## the defaults as found in the PPD file: some people modify the PPD -## file directly to set new system-wide defaults. - -# from metadata -for $arg (@{$dat->{'args'}}) { - if ($arg->{'default'}) { - $arg->{'userval'} = $arg->{'default'}; - } -} - -# from ppd file; these overwrite the standard defaults -for $arg (@{$dat->{'args'}}) { - my $ppddef = $ppddefaults{$arg->{'name'}}; - if (defined($ppddef)) { - my $name = $arg->{'name'}; - if ($arg->{'type'} eq 'bool') { - # This maps Unknown to mean False. Good? Bad? - $arg->{'userval'} = ($ppddef eq 'True' ? '1' : '0'); - } elsif ($arg->{'type'} eq 'enum') { - if (defined($arg->{'vals_byname'}{$ppddef})) { - $arg->{'userval'} = $ppddef; - } else { - # wtf!? that's not a choice! - my $name=$arg->{'name'}; - print $logh - "PPD default value $ppddef for $name is not a choice!\n"; - } - } elsif (($arg->{'type'} eq 'int') || - ($arg->{'type'} eq 'float')) { - if (($ppddef <= $arg->{'max'}) && - ($ppddef >= $arg->{'min'})) { - $arg->{'userval'} = $ppddef; - } else { - print $logh - "PPD default value $ppddef for $name is out of range!\n"; - } - } - } -} - -# so now what were the defaults? print them if debugging... -if ($debug) { - for $arg (@{$dat->{'args'}}) { - my ($name, $val) = ($arg->{'name'}, $arg->{'userval'}); - print $logh "Default for option $name is $val\n"; - } -} - -## We get various options as argument 5. Parse these out. User-set -## values get stored as 'userval' in the argument's structure -my $optstr = $ARGV[4]; - -# print the options string only in debug mode, Mac OS X adds very many -# options so that CUPS cannot handle the output of the option string -# in its log files. If CUPS encounters a line with more than 1024 characters -# sent into its log files, it aborts the job with an error. -if ($debug) { - print $logh "options: ->$optstr<-\n"; -} - -# Parse them. They're foo='bar nut', or foo, or 'bar nut', or -# foo:'bar nut' (when GPR was used) all with spaces between... - -my @opts; - -# foo='bar nut' -while ($optstr =~ s!(\w+=\'.+?\') ?!!) { - push (@opts, $1); -} - -# foo:'bar nut' (GPR separates option and setting with a colon ":") -while ($optstr =~ s!(\w+:\'.+?\') ?!!) { - push (@opts, $1); -} - -# 'bar nut' -while ($optstr =~ s!(\'.+?\') ?!!) { - push (@opts, $1); -} - -# foo -push(@opts, split(/ /,$optstr)); - - -# Now actually process those pesky options... - -for (@opts) { - print $logh "Pondering option `$_'\n"; - - if ((lc($_) =~ /^\s*docs\s*$/) || - (lc($_) =~ /^\s*docs\s*=\s*true\s*$/)) { - # The second one is necessary becuase CUPS 1.1.15 or newer sees - # "docs" as boolean option and modifies it to "docs=true" - $do_docs = 1; - last; - } - - my $arg; - if ((m!(.+)=\'?(.+)\'?!) || (m!(.+):\'?(.+)\'?!)) { - # GPR separates option and setting with a colon ":", all other - # frontends use "=". - my ($aname, $avalue) = ($1, $2); - - # Standard arguments? - # media=x,y,z - # sides=one|two-sided-long|short-edge - - # handled by cups for us? - # page-ranges= - # page-set= - # number-up= - - # brightness= gamma= these probably collide with printer-specific - # options. Hmm. CUPS has a stupid design for option - # handling; everything gets all muddled together. - - # Rummage around in the media= option for known media, source, etc types. - # We ought to do something sensible to make the common manual - # boolean option work when specified as a media= tray thing. - # - # Note that this fails miserably when the option value is in - # fact a number; they all look alike. It's unclear how many - # drivers do that. We may have to standardize the verbose - # names to make them work as selections, too. - - if ($aname =~ m!^media$!i) { - my @values = split(',',$avalue); - for (@values) { - if ($dat->{'args_byname'}{'PageSize'} - and $val=valbyname($dat->{'args_byname'}{'PageSize'},$_)) { - $dat->{'args_byname'}{'PageSize'}{'userval'} = - $val->{'value'}; - } elsif ($dat->{'args_byname'}{'MediaType'} - and $val=valbyname($dat->{'args_byname'}{'MediaType'},$_)) { - $dat->{'args_byname'}{'MediaType'}{'userval'} = - $val->{'value'}; - } elsif ($dat->{'args_byname'}{'InputSlot'} - and $val=valbyname($dat->{'args_byname'}{'InputSlot'},$_)) { - $dat->{'args_byname'}{'InputSlot'}{'userval'} = - $val->{'value'}; - } elsif (lc($_) eq 'manualfeed') { - # Special case for our typical boolean manual - # feeder option if we didn't match an InputSlot above - if (defined($dat->{'args_byname'}{'ManualFeed'})) { - $dat->{'args_byname'}{'ManualFeed'}{'userval'} = 1; - } - } else { - print $logh "Unknown media= component $_.\n"; - } - } - - } elsif ($aname =~ m!^sides$!i) { - # Handle the standard duplex option, mostly - if ($avalue =~ m!^two-sided!i) { - if (defined($dat->{'args_byname'}{'Duplex'})) { - # We set "Duplex" to '1' here, the real argument setting - # will be done later - $dat->{'args_byname'}{'Duplex'}{'userval'} = '1'; - # Check the binding: "long edge" or "short edge" - if ($avalue =~ m!long-edge!i) { - if (defined($dat->{'args_byname'}{'Binding'})) { - $dat->{'args_byname'}{'Binding'}{'userval'} = - $dat->{'args_byname'}{'Binding'}{'vals_byname'}{'LongEdge'}{'value'}; - } else { - $dat->{'args_byname'}{'Duplex'}{'userval'} = - 'LongEdge'; - } - } elsif ($avalue =~ m!short-edge!i) { - if (defined($dat->{'args_byname'}{'Binding'})) { - $dat->{'args_byname'}{'Binding'}{'userval'} = - $dat->{'args_byname'}{'Binding'}{'vals_byname'}{'ShortEdge'}{'value'}; - } else { - $dat->{'args_byname'}{'Duplex'}{'userval'} = - 'ShortEdge'; - } - } - } - } elsif ($avalue =~ m!^one-sided!i) { - if (defined($dat->{'args_byname'}{'Duplex'})) { - # We set "Duplex" to '0' here, the real argument setting - # will be done later - $dat->{'args_byname'}{'Duplex'}{'userval'} = '0'; - } - } - - # We should handle the other half of this option - the - # BindEdge bit. Also, are there well-known ipp/cups - # options for Collate and StapleLocation? These may be - # here... - - } else { - # Various non-standard printer-specific options - if ($arg=argbyname($aname)) { - $arg->{'userval'} = $avalue; - - # Special case for PPD undef in required defaults; etc. - # The user himself should never be specifying 'Unknown'. - if (lc($avalue) eq 'unknown') { - $arg->{'userval'} = undef; - } - } else { - print $logh "Unknown option $aname=$avalue.\n"; - } - } - } elsif (m!no(.+)!i) { - # standard bool args: - # landscape; what to do here? - # duplex; we should just handle this one OK now? - - if ($arg=argbyname($1)) { - $arg->{'userval'} = 0; - } else { - print $logh "Unknown bool option $1.\n"; - } - } elsif (m!(.+)!) { - if ($arg=argbyname($1)) { - $arg->{'userval'} = 1; - } else { - print $logh "Unknown bool? option $1.\n"; - } - } -} - - -## Next, examine the postscript job itself for traces of command-line -## and pjl options. Sometimes these don't show up in the CUPS filter -## 'options' argument! - -# Examination strategy: read some lines from STDIN. Put those lines -# onto the stack @examined_stuff, which will be stuffed into -# Ghostscript/whatever later on. - -print $logh "Seaerching job for option settings ...\n"; -my $maxlines = 1000; # how many lines to examine? -my $more_stuff = 1; # there is more stuff in stdin. -my $linect = 0; # how many lines have we examined? -my $insertprepend = 1; # number of the line where the PostScript - # commands of numerical options should be - # inserted. This must be after the option - # settings inserted by CUPS, because when one - # uses a PPD-O-Matic PPD file and sets a - # numerical option to a value which is not - # under the choices of the PPD representation - # of the option CUPS inserts the PostScript - # code for the default setting. -my $inheader = 1; # Are we still in the header formed by the - # option PostScript code inserted by CUPS? -my $infeature = 0; # Are we in a "[{ %%BeginFeature ... } stopped - # cleartomark" structure? - -do { - my $line; - if ($line=<STDIN>) { - if ($linect == 0) { - # Line zero should be postscript leader - die 'job does not start with Postscript %! thing' - if $line !~ m/^.?%!/; # There can be a Windows control char - # before "%!" - # Insert page accounting code in the beginning of the - # PostScript data stream - $line .= $accounting_prolog; - } else { - if (($line =~ m/\%\%BeginFeature:\s+\*?([^\s=]+)\s+(\S.*)$/) || - ($line =~ m/\%\%\s*FoomaticOpt:\s*([^\s=]+)\s*=\s*(\S.*)$/)) { - my ($option, $value) = ($1, $2); - - # OK, we have an option. If it's not a - # *ostscript-style option (ie, it's command-line or - # PJL) then we should note that fact, since the - # attribute-to-filteroption passing in CUPS is kind of - # funky, especially wrt boolean options. - - print $logh "Found: $line"; - if ($arg=argbyname($option)) { - print $logh " Option: $option=$value"; - if ($arg->{'style'} ne 'G') { - print $logh " --> Setting option\n"; - if ($arg->{'type'} eq 'bool') { - # Boolean options are 1 or 0 - if ($value eq 'True') { - $arg->{'userval'} = 1; - } elsif ($value eq 'False') { - $arg->{'userval'} = 0; - } else { - warn "job contained boolean option", - " with neither True nor False value!?"; - } - } elsif (($arg->{'type'} eq 'enum') || - ($arg->{'type'} eq 'int') || - ($arg->{'type'} eq 'float')) { - # enum options go as the value, unless - # they were Unknown... - # Same with numerical options, they can appear - # here when the client has used the Adobe- - # compliant PPD-O-MATIC PPD file. - - if (lc($value) eq 'unknown') { - $arg->{'userval'} = undef; - } else { - $arg->{'userval'} = $value; - } - } - } else { - # it is a postscript style option, presuemably - # all applied for us and such... - print $logh " --> Option will be set by PostScript interpreter\n"; - } - } else { - # This option is unknown to us. WTF? - warn "unknown option $option=$value found in the job"; - } - - } elsif ($line =~ /^\s*\[\{/) { - # Initial line ("[{") of an option setting inserted by CUPS - $infeature ++; - } elsif ($line =~ /\}\s*stopped\s+cleartomark\s*$/) { - # Final line ("} stopped cleartomark") of an option setting - # inserted by CUPS - $infeature --; - } elsif (($inheader) && (!$infeature) && - ($line !~ /^\s*$/) && ($line =~ /ESPrc/)) { - # Found end of option settings inserted by CUPS - # (CUPS defines the "ESPrc" function then) - $inheader = 0; - $insertprepend = $linect; - } - } - - # Push the line onto the stack for later spitting up... - push (@examined_stuff, $line); - $linect++; - - } else { - # EOF! - $more_stuff = 0; - } - # CUPS has inserted more than 1000 ($maxlines) lines with option - # settings, so increase $maxlines. - if (($linect >= $maxlines) && ($inheader)) { - $maxlines += 200; - } -} while (($linect < $maxlines) and ($more_stuff != 0)); - -#### Everything below here ought to be generic for any printing -#### system? It just uses the $dat structure, with user values filled -#### in, and turns postscript into printer data. - - -# Construct the proper command line. -my $commandline = $dat->{'cmd'}; -my $arg; - argument: - for $arg (sort { $a->{'order'} <=> $b->{'order'} } - @{$dat->{'args'}}) { - - # Only do command-line and postscript style arguments. - # I think PJL options may break some drivers? Uncomment if so - # next argument if ($arg->{'style'} eq 'J'); - - my $name = $arg->{'name'}; - my $spot = $arg->{'spot'}; - my $varname = $arg->{'varname'}; - my $cmd = $arg->{'proto'}; - my $comment = $arg->{'comment'}; - my $type = $arg->{'type'}; - my $cmdvar = ""; - my $userval = $arg->{'userval'}; - - my $psarg = ($arg->{'style'} eq 'G' ? 1 : 0); - - if ($type eq 'bool') { - - if ($psarg && !$do_docs) { - # CUPS handles bools for us, only for docs printing we must do - # it again, because we do not print the file which CUPS has - # filtered - } else { - # If true, stick the proto into the command line - if (defined($userval) && $userval == 1) { - $cmdvar = $cmd; - } - } - - } elsif ($type eq 'int' or $type eq 'float') { - - # If defined, process the proto and stick the result into - # the command line or postscript queue. - if (defined($userval)) { - my $min = $arg->{'min'}; - my $max = $arg->{'max'}; - if ($userval >= $min and $userval <= $max) { - my $sprintfcmd = $cmd; - $sprintfcmd =~ s!\%([^s])!\%\%$1!g; - $cmdvar = sprintf($sprintfcmd, - ($type eq 'int' - ? sprintf("%d", $userval) - : sprintf("%f", $userval))); - } else { - print $logh "Value $userval for $name is out of range $min<=x<=$max.\n"; - } - } - - } elsif ($type eq 'enum') { - - if ($psarg && !$do_docs) { - # CUPS handles enums for us, only for docs printing we must do - # it again, because we do not print the file which CUPS has - # filtered - } else { - # If defined, stick the selected value into the proto and - # thence into the commandline - if (defined($userval)) { - # CUPS assumes that options with the choises "Yes", "No", - # "On", "Off", "True", or "False" are boolean options and - # maps "-o Option=On" to "-o Option" and "-o Option=Off" - # to "-o noOption", which cupsomatic maps to "0" and "1". - # So when "0" or "1" is unavailable in the option, we try - # "Yes", "No", "On", "Off", "True", and "False". - my $found = 0; - my $val; - if ($val=valbyname($arg,$userval)) { - $found = 1; - } elsif ($userval eq '0') { - foreach (qw(No Off False None)) { - if ($val=valbyname($arg,$_)) { - $userval = $_; - $arg->{'userval'} = $userval; - $found = 1; - last; - } - } - } elsif ($userval eq '1') { - foreach (qw(Yes On True)) { - if ($val=valbyname($arg,$_)) { - $userval = $_; - $arg->{'userval'} = $userval; - $found = 1; - last; - } - } - } elsif ($userval eq 'LongEdge') { - # Handle different names for the choices of the - # "Duplex" option - foreach (qw(LongEdge DuplexNoTumble)) { - if ($val=valbyname($arg,$_)) { - $userval = $_; - $arg->{'userval'} = $userval; - $found = 1; - last; - } - } - } elsif ($userval eq 'ShortEdge') { - foreach (qw(ShortEdge DuplexTumble)) { - if ($val=valbyname($arg,$_)) { - $userval = $_; - $arg->{'userval'} = $userval; - $found = 1; - last; - } - } - } - if ($found) { - my $sprintfcmd = $cmd; - $sprintfcmd =~ s!\%([^s])!\%\%$1!g; - $cmdvar = sprintf($sprintfcmd, - (defined($val->{'driverval'}) - ? $val->{'driverval'} - : $val->{'value'})); - } else { - # User gave unknown value? - print $logh "Value $userval for $name is not a valid choice.\n"; - } - } - } - - } else { - - print $logh "unknown type for argument $name!?\n"; - # die "evil type!?"; - - } - - if ($arg->{'style'} eq 'G') { - if ($type eq 'int' or $type eq 'float' or $do_docs) { - # Place this Postscript command onto the prepend queue. - push (@prepend, "$cmdvar\n") if $cmdvar; - } else { - # non numeric arguments are done for us by cups (except - # for docs printing, here the file prepared by CUPS will - # be replaced by the docs file which is generated by this - # script - } - - } elsif ($arg->{'style'} eq 'J') { - - if (defined($dat->{'pjl'})) { - # put PJL commands onto PJL stack... - push (@pjlprepend, "\@PJL $cmdvar\n") if $cmdvar; - } - - } elsif ($arg->{'style'} eq 'C') { - # command-line argument - - # Insert the processed argument in the commandline - # just before the spot marker. - $commandline =~ s!\%$spot!$cmdvar\%$spot!; - } - - } - - -### Tidy up after computing option statements for all of P, J, and C types: - -## C type finishing -# Pluck out all of the %n's from the command line prototype -my @letters = qw/A B C D E F G H I J K L M Z/; -for $spot (@letters) { - # Remove the letter marker from the commandline - $commandline =~ s!\%$spot!!; -} - -## G type finishing -# Insert PostScript code of the numerical options after the options settings -# which CUPS has inserted -splice(@examined_stuff, $insertprepend, 0, @prepend); -print $logh "$0: inserted option PS code:\n", @prepend; - -## J type finishing -# Compute the proper stuff to say around the job - -if (defined($dat->{'pjl'})) { - - # PJL "frame" with "JOB" and "EOJ" commands - - # Stick beginning of job cruft on the front of the pjl stuff... - #unshift (@pjlprepend, - # "\033%-12345X\@PJL JOB NAME=\"CUPSOMATIC\"\n"); - - # Arrange for PJL EOJ command at end of job - #push (@pjlappend, - # "\33%-12345X\@PJL RESET\n\@PJL EOJ\n"); - - # PJL "frame" without "JOB" and "EOJ" commands. We use this because - # some printers do not support these commands - - # Stick beginning of job cruft on the front of the pjl stuff... - unshift (@pjlprepend, - "\033%-12345X\@PJL\n"); - - # Arrange for PJL RESET command at end of job - push (@pjlappend, - "\33%-12345X\@PJL RESET\n"); - - print $logh "PJL: ", @pjlprepend, "<job data>\n", @pjlappend; -} - -# Insert the page size into the $enscriptcommand -if ($enscriptcommand =~ /\@\@([^@]+)\@\@PAGESIZE\@\@/) { - my $optstr = ((($arg = argbyname('PageSize'))) - ? $1 . $arg->{'userval'} - : ""); - $enscriptcommand =~ s/\@\@([^@]+)\@\@PAGESIZE\@\@/$optstr/; -} - -# Insert the job title into the $enscriptcommand -if ($enscriptcommand =~ /\@\@([^@]+)\@\@JOBTITLE\@\@/) { - if ($do_docs) { - $jobtitle = "Documentation for the $dat->{'make'} $dat->{'model'}"; - } - my $titlearg = $1; - my ($arg, $optstr); - ($arg = $jobtitle) =~ s/\"/\\\"/g; - if (($titlearg =~ /\"/) || $arg) { - $optstr = $titlearg . ($titlearg =~ /\"/ ? '' : '"') . - ($arg ? "$arg\"" : '"'); - } else { - $optstr = ""; - } - $enscriptcommand =~ s/\@\@([^@]+)\@\@JOBTITLE\@\@/$optstr/; -} - -# Debugging printout of all option values -if ($debug) { - for $arg (@{$dat->{'args'}}) { - my ($name, $val) = ($arg->{'name'}, $arg->{'userval'}); - print $logh "Final value for option $name is $val\n"; - } -} - -# Now print the darned thing! -if (! $do_docs) { - # Run the proper command line. - my ($driverh, $driverpid) = getdriverhandle(); - - print $driverh @examined_stuff; # first 1000 lines or so - if ($debug != 0) { - open DRIVERINPUT, "> /tmp/prnjob" - or die "error opening /tmp/prnjob"; - print DRIVERINPUT @examined_stuff; - } - if ($more_stuff) { - while (<STDIN>) { - print $driverh $_; - if ($debug != 0) { - print DRIVERINPUT $_; - } - } - } - - close $driverh - or die "error closing $driverh"; - if ($debug != 0) { - close DRIVERINPUT - or die "error closing /tmp/prnjob"; - } - - # Wait for driver child - waitpid($driverpid, 0); - print $logh "Main process finished\n"; - exit(0); - - ### End of non-doc processing... - -} else { - - print $logh "printing docs\n"; - - my $pid, $sleep_count=0; - do { - $pid = open(KID1, "|-"); - unless (defined $pid) { - warn "cannot fork: $!"; - die "bailing out" if $sleep_count++ > 6; - sleep 10; - } - } until defined $pid; - - if (! $pid) { - # child/driver; exec enscript... - - my ($driverhandle, $driverpid) = getdriverhandle(); - - print $logh "setting STDOUT to be $driverhandle and spawning $enscriptcommand\n"; - - open (STDOUT, ">&$driverhandle") - or die "Couldn't dup driverhandle"; - # PostScript option settings, as "PageSize" - print $logh "Prepending option PS code:\n@prepend"; - print "@prepend"; - system "$enscriptcommand" - and die "Couldn't exec $enscriptcommand"; - - close STDOUT; - close $driverhandle; - - # Wait for driver child - waitpid($driverpid, 0); - print $logh "KID1 finished\n"; - exit(0); - } - - # parent; write the job into KID1 aka $enscriptcommand - select KID1; - - my ($make, $model, $driver) - = ($dat->{'make'}, $dat->{'model'}, $dat->{'driver'}); - - my $optstr = ("Specify each option with a -o argument to lp/lpr ie\n", - "% lpr -o duplex -o two=2 -o three=3\n"); - - print "Invokation summary for your $make $model printer as driven by -the $driver driver. - -$optstr - -The following options are available for this printer: - -"; - - for $arg (@{$dat->{'args'}}) { - my ($name, - $required, - $type, - $comment, - $spot, - $default) = ($arg->{'name'}, - $arg->{'required'}, - $arg->{'type'}, - $arg->{'comment'}, - $arg->{'spot'}, - $arg->{'default'}); - - my $reqstr = ($required ? " required" : "n optional"); - print "Option `$name':\n A$reqstr $type argument.\n $comment\n"; - print " This options corresponds to a PJL command.\n" if ($arg->{'style'} eq 'J'); - - if ($type eq 'bool') { - if (defined($default)) { - my $defstr = ($default ? "True" : "False"); - print " Default: $defstr\n"; - } - print " Example: `$name'\n"; - } elsif ($type eq 'enum') { - print " Possible choices:\n"; - my $exarg; - for (@{$arg->{'vals'}}) { - my ($choice, $comment) = ($_->{'value'}, $_->{'comment'}); - print " o $choice: $comment\n"; - $exarg=$choice; - } - if (defined($default)) { - print " Default: $default\n"; - } - print " Example: $name=$exarg\n"; - } elsif ($type eq 'int' or $type eq 'float') { - my ($max, $min) = ($arg->{'max'}, $arg->{'min'}); - my $exarg; - if (defined($max)) { - print " Range: $min <= x <= $max\n"; - $exarg=$max; - } - if (defined($default)) { - print " Default: $default\n"; - $exarg=$default; - } - if (!$exarg) { $exarg=0; } - print " Example: $name=$exarg\n"; - } - - print "\n"; - } - - select STDOUT; - close KID1 - or warn "error closign KID1/enscript for docs print"; -} - -# Wait for enscript child -waitpid($pid, 0); -print $logh "Main process finished\n"; -close $logh; -exit(0); - - -## Everything below here *is* the same in lpdomatic and cupsomatic -## KEEP IT THAT WAY! - -# return glob ref to "| commandline | self(pjlstuffer) | $postpipe" -# ugly, we use $commandline, $postpipe, @prepend, @pjlprepend, @pjlappend globals -sub getdriverhandle { - - pipe KID3_IN, KID3; - my $pid3 = fork(); - if (!defined($pid3)) { - print $logh "$0: cannot fork for kid3!\n"; - die "can't for for kid3\n"; - } - if ($pid3) { - - # we are the parent; return a glob to the filehandle - close KID3_IN; - - KID3->flush(); - return ( *KID3, $pid3 ); - - } else { - close KID3; - - pipe KID4_IN, KID4; - my $pid2 = fork(); - if (!defined($pid2)) { - print $logh "$0: cannot fork for kid4!\n"; - die "can't fork for kid4\n"; - } - - if ($pid2) { - # parent, child of primary task; we are |commandline| - close KID4_IN; - - print $logh "gs PID pid2=$pid2\n"; - print $logh "gs command: $commandline\n"; - - close STDIN or die "couldn't close STDIN in $pid2"; - open (STDIN, "<&KID3_IN") or die "Couldn't dup KID3_IN"; - open (STDOUT, ">&KID4") or die "Couldn't dup KID4"; - if ($debug) { - open (STDERR, ">&$logh") - or die "Couldn't dup logh to stderr"; - } - - # Massage commandline to execute foomatic-gswrapper - my $havewrapper = 0; - for (split(':', $ENV{'PATH'})) { - if (-x "$_/foomatic-gswrapper") { - $havewrapper=1; - last; - } - } - if ($havewrapper) { - $commandline =~ s!^\s*gs !foomatic-gswrapper !; - $commandline =~ s!(\|\s*)gs !\|foomatic-gswrapper !; - $commandline =~ s!(;\s*)gs !; foomatic-gswrapper !; - } - - # Actually run the thing... - system "$commandline" - and die "Couldn't exec $commandline"; - close STDOUT; - close KID4; - close STDIN; - close KID3_IN; - # Wait for output child - waitpid($pid2, 0); - print $logh "KID3 finished\n"; - exit(0); - } else { - # child, trailing task on the pipe; we write pjl stuff - close KID4; - - my $fileh = *STDOUT; - if ($postpipe) { - open PIPE,$postpipe - or "die cannot open postpipe $postpipe"; - $fileh = *PIPE; - } - - # wrap the PJL around the job data... - # wrap the PJL around the job data, if there are any - # options specified... - if ( @pjlprepend > 1 ) { - print $fileh @pjlprepend; - } - while (<KID4_IN>) { - print $fileh $_; - } - if ( @pjlprepend > 1 ) { - print $fileh @pjlappend; - } - - close $fileh or die "error closing $fileh"; - close KID4_IN; - - print $logh "tail process done writing data to $fileh\n"; - - print $logh "KID4 finished\n"; - exit(0); - } - } -} - -# Find an argument by name in a case-insensitive way -sub argbyname { - my $name = @_[0]; - - my $arg; - for $arg (@{$dat->{'args'}}) { - return $arg if (lc($name) eq lc($arg->{'name'})); - } - - return undef; -} - -sub valbyname { - my ($arg,$name) = @_; - - my $val; - for $val (@{$arg->{'vals'}}) { - return $val if (lc($name) eq lc($val->{'value'})); - } - - return undef; -} - -sub readConfFile { - my ($file) = @_; - - my %conf; - # Read config file if present - if (open CONF, "< $file") { - while (<CONF>) - { - $conf{$1}="$2" if (m/^\s*([^\#\s]\S*)\s*:\s*(.*)\s*$/); - } - close CONF; - } - - return %conf; -} - - -# Emacs tabulator/indentation - -### Local Variables: -### tab-width: 8 -### perl-indent-level: 4 -### End: diff --git a/net-print/cups/files/digest-cups-1.1.18-r5 b/net-print/cups/files/digest-cups-1.1.18-r5 deleted file mode 100644 index 0d007fa65558..000000000000 --- a/net-print/cups/files/digest-cups-1.1.18-r5 +++ /dev/null @@ -1 +0,0 @@ -MD5 4a8a423a8268d088bffa19f6515883a7 cups-1.1.18-source.tar.bz2 3491321 diff --git a/net-print/cups/files/digest-cups-1.1.19 b/net-print/cups/files/digest-cups-1.1.19 deleted file mode 100644 index 6ea23d0802d6..000000000000 --- a/net-print/cups/files/digest-cups-1.1.19 +++ /dev/null @@ -1 +0,0 @@ -MD5 04cbeed9a8acfe23624f1cb6be9c3eac cups-1.1.19-source.tar.bz2 3691376 diff --git a/net-print/cups/files/digest-cups-1.1.20 b/net-print/cups/files/digest-cups-1.1.20 new file mode 100644 index 000000000000..002ebb34be36 --- /dev/null +++ b/net-print/cups/files/digest-cups-1.1.20 @@ -0,0 +1 @@ +MD5 09d0be2bad1b0617bc0eba6eef81f6e9 cups-1.1.20-source.tar.bz2 3741510 diff --git a/net-print/cups/files/foomatic-gswrapper b/net-print/cups/files/foomatic-gswrapper deleted file mode 100644 index 3b8f6a5ca757..000000000000 --- a/net-print/cups/files/foomatic-gswrapper +++ /dev/null @@ -1,48 +0,0 @@ -#! /usr/bin/perl -# $Header: /var/cvsroot/gentoo-x86/net-print/cups/files/foomatic-gswrapper,v 1.2 2002/05/04 22:45:53 woodchip Exp $ - -# $Revision: 1.2 $ - -# This is a little Ghostscript regularization script. It massages -# arguments to make Ghostscript execute properly as a filter, with -# output on stdout and errors etc on stderr. - -# Arbitrary other option processing could happen here, too. - -# IT WOULD BE WRONG to have this file do any processing of the input -# or output data. Such job transforms belong in actual filters, or -# inside Ghostscript itself. - -grep (m!\-sOutputFile=\-! - && do { - # Send the job to fd 3; errors will be on 2(stderr) and job - # ps program interpreter output on 1(stdout) - # The /dev/fd/3 is equivalent to "| cat >&3" but it works with - # all versions of GhostScript under every shell and every Unix. - $_ = '-sOutputFile=/dev/fd/3'; # quoted properly below... - }, @ARGV); - -grep (m!^\-$! - && do { - # Get the input from fd 0; The /dev/fd/0 is equivalent to - # "-" but there are some pesky PostScript files which do not - # work with "-". This works with all versions of GhostScript - # under every shell and every Unix. - $_ = '/dev/fd/0'; - }, @ARGV); - -# Turn *off* -q (quiet!); now that stderr is useful! :) -my @myargs = grep (! m!^\-q$!, @ARGV); - -# Escape any quotes, and then quote everything just to be sure... -grep (s!\'!\\'!g, @myargs); -#'# Fix Emacs syntax highlighting -my $args = "'" . join("' '", @myargs) . "'"; - -# Execute Ghostscript, with both job and gs errors on stderr, and job -# output on stdout... - -print STDERR "foomatic-gswrapper: gs $args 3>&1 1>&2\n"; -exec "gs $args 3>&1 1>&2"; - -die "Failed to execute Ghostscript?!"; |