Automatic import for version 1.4.8

This commit is contained in:
Rosa 2012-02-01 14:24:38 +04:00
commit 9b122cb3fe
35 changed files with 6086 additions and 0 deletions

4
.abf.yml Normal file
View file

@ -0,0 +1,4 @@
sources:
"cups-1.4.8-source.tar.bz2": 9167f556e78e0bc075f1eb2f695d79cc1f334007
"pap-backend.tar.bz2": 89e1e7eb4258d47069d2a60c383b8bd555a11e63
"pap-docu.pdf.bz2": 7e7d44bb58532ab2fc4c1ca3581787877f1b5733

11
cjktexttops Normal file
View file

@ -0,0 +1,11 @@
#!/bin/bash
INPUT=-
if [ $# == 6 ]
then
INPUT=$6
fi
# Extract the papersize
PAPERSIZE=`grep '^\*DefaultPageSize' "$PPD" | cut -d\ -f2`
LC_ALL=ja_JP mpage -b$PAPERSIZE -1 -o -f -m18lr36bt -P- "$INPUT"

141
cleanppd.pl Normal file
View file

@ -0,0 +1,141 @@
#!/usr/bin/perl -w
sub treatfile
{
my $deletethis;
my $readval;
my $manufacturer;
my $manuflinefound = 0;
my $manufvalid;
my $havemanuf;
my $model;
my $modellinefound;
my $modelvalid;
my $kap;
$kap = "";
$manufacturer = "";
$deletethis = 0;
print "$_[0] ... ";
#
# Read file for the first time to get manufacturer info and to check
# whether it should be deleted
#
# open file
if (!(open(PPDFILE,"< $_[0]"))) {
print STDERR "Can't open PPD file: $_[0]\n";
return(0);
}
# read data
$manufvalid = 0;
$manuflinefound = 0;
while (defined($readval = <PPDFILE>)) {
# Remove "Birmy PowerRIP" PPD files (they are for the commercial
# Birmy Power RIP software PostScript interpreter (Windows/Mac)
if (($readval =~ /birmy/) ||
($readval =~ /Birmy/) ||
($readval =~ /BIRMY/)) {$deletethis = 1;}
# Search for manufacturer tag
if ($readval =~ /^\*Manufacturer:\s*"(.*)"\s*$/)
{
$manufacturer = $1;
$manuflinefound = 1;
$manufvalid = 1;
if (($readval =~ /"Manufacturer"/) || ($readval =~ /"ESP"/))
{$manufvalid = 0};
}
}
# close file
close(PPDFILE);
# delete file and stop if a deletion criteria is fulfilled
if ($deletethis == 1) {
print ("Deleted\n");
system("rm -f $_[0]");
return(0);
}
$havemanuf = $manufvalid;
#
# Read file for the second time to get model info
#
if (($havemanuf == 0) && ($manufvalid == 0)) {
# open file
if (!(open(PPDFILE,"< $_[0]"))) {
print STDERR "Can't open PPD file: $_[0]\n";
return(0);
}
# read data
$modelvalid = 0;
while (defined($readval = <PPDFILE>)) {
if ($readval =~ /^\*ModelName:\s*"(.*)"\s*$/)
{
$model=$1;
$modelvalid = 1;
if (($model eq "Model") || ($readval eq "model")) {$modelvalid = 0};
}
}
# close file
close(PPDFILE);
# Extract manufacturers name
if ($modelvalid == 0) { $manufacturer="UNKNOWN MANUFACTURER"
} else {
@sep = split(/ /,$model);
$manufacturer = $sep[0];
}
}
#
# Rewrite file to insert manufacturer info
#
# open file to read
if (!(open(PPDFILE,"< $_[0]"))) {
print STDERR "Can't open PPD file: $_[0]\n";
return(0);
}
# open file to write
if (!(open(NPPDFILE,"> $_[0].new"))) {
print STDERR "Can't open new PPD file: $_[0].new\n";
return(0);
}
# read data
while (defined($readval = <PPDFILE>)) {
if (substr($readval, 0, 14) eq "*Manufacturer:") {
$manuflinefound = 1;
print NPPDFILE "*Manufacturer: \"$manufacturer\"\n"
} else {
print NPPDFILE $readval;
}
if ((substr($readval, 0, 4) ne "*PPD") &&
(substr($readval, 0, 2) ne "*%")){
if ($manuflinefound == 0) {
$manuflinefound = 1;
print NPPDFILE "*Manufacturer: \"$manufacturer\"\n"
}
}
}
# close files
close(PPDFILE);
close(NPPDFILE);
# move new file onto place of old file
system("mv -f $_[0].new $_[0]");
# Compress the file
system("gzip $_[0]");
print("Processed\n");
return(0);
}
# main program
{
treatfile($ARGV[0]);
}

107
correctcupsconfig Normal file
View file

@ -0,0 +1,107 @@
#!/usr/bin/perl -w
#
# Till Kamppeter (till@mandrakesoft.com)
#
# Copyright 2001
#
# This software may be freely redistributed under the terms of the GNU
# General Public License.
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Some great piece of code taken from
# /usr/lib/perl5/site_perl/5.6.1/MDK/Common/DataStructure.pm
# member( $a, @b ) returns 1 if $a is in @b, 0 otherwise.
sub member { my $e = shift; foreach (@_) { $e eq $_ and return 1 } 0 };
# Do not do any changes when the user chose manual configuration in
# printerdrake
my $manual = 0;
my $manualconffile = "/etc/sysconfig/printing";
if (open MANUALCONFFILE, "< $manualconffile") {
@manualconf_content = <MANUALCONFFILE>;
close MANUALCONFFILE;
($_ =~ /^\s*CUPS_CONFIG\s*=\s*manual\s*$/ and $manual = 1) foreach @manualconf_content;
}
if ($manual) {exit;}
# Read CUPS config file or create a new one if necessary.
my $cups_conf = "/etc/cups/cupsd.conf";
my @cups_conf_content;
my $config_modified = 0;
if (!(-f $cups_conf)) {
warn "No CUPS configuration file $cups_conf, creating one ...\n";
@cups_conf_content = split('\n',
"LogLevel info
TempDir /var/spool/cups/tmp
Port 631
BrowseAddress \@LOCAL
BrowseDeny All
BrowseAllow 127.0.0.1
BrowseAllow \@LOCAL
BrowseOrder deny,allow
<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From \@LOCAL
</Location>
<Location /admin>
AuthType Basic
AuthClass System
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
</Location>
");
($_ =~ s/$/\n/) foreach @cups_conf_content;
$config_modified = 1;
} else {
open CONF_CUPS, "$cups_conf" or die "Can't open $cups_conf!";
@cups_conf_content = <CONF_CUPS>;
close CONF_CUPS;
}
# Check whether LPD/LPRng is installed and turn off creation of an
# /etc/printcap file by CUPS.
if ((-x "/usr/sbin/lpd") &&
!(grep { /^\s*Printcap\s*$/ } @cups_conf_content)) {
my $oldprintcap = "";
($_ =~ /^\s*Printcap\s+(\S*)\s*$/ and $oldprintcap = $1)
foreach @cups_conf_content;
if (($oldprintcap eq "") || ($oldprintcap eq "/etc/printcap")) {
print STDERR "WARNING: Inserted \"Printcap\" line in /etc/cups/cupsd.conf\n (to avoid overwriting the /etc/printcap of the installed LPD/LPRng)\n";
# Remove all valid "Printcap" lines
($_ =~ /^\s*Printcap[^:]/ and $_="") foreach @cups_conf_content;
# Insert the new "Printcap" line
push @cups_conf_content, "Printcap\n";
# Remove the /etc/printcap file which the CUPS daemon left during
# shutdown and replace it by an empty file
unlink "/etc/printcap";
system "touch /etc/printcap";
$config_modified = 1;
}
}
# Write back the modified CUPS config file
if ($config_modified) {
open CONF_CUPS, ">$cups_conf" or die "Can't open $cups_conf";
print CONF_CUPS @cups_conf_content;
close CONF_CUPS;
}

11
cups-1.3.7-peercred.patch Normal file
View file

@ -0,0 +1,11 @@
diff -up cups-1.3.5/scheduler/auth.c.peercred cups-1.3.5/scheduler/auth.c
--- cups-1.3.5/scheduler/auth.c.peercred 2008-02-05 16:52:20.000000000 +0000
+++ cups-1.3.5/scheduler/auth.c 2008-02-05 18:20:06.000000000 +0000
@@ -54,6 +54,7 @@
* Include necessary headers...
*/
+#define _GNU_SOURCE
#include "cupsd.h"
#include <grp.h>
#ifdef HAVE_SHADOW_H

View file

@ -0,0 +1,21 @@
--- cups-1.4svn-r8684/Makedefs.in~ 2009-05-21 19:20:06.000000000 +0200
+++ cups-1.4svn-r8684/Makedefs.in 2009-05-26 21:50:03.000000000 +0200
@@ -40,13 +40,13 @@
# Installation programs...
#
-INSTALL_BIN = $(LIBTOOL) $(INSTALL) -c -m 555 @INSTALL_STRIP@
+INSTALL_BIN = $(LIBTOOL) $(INSTALL) -c -m 755 @INSTALL_STRIP@
INSTALL_CONFIG = $(INSTALL) -c -m @CUPS_CONFIG_FILE_PERM@
-INSTALL_DATA = $(INSTALL) -c -m 444
+INSTALL_DATA = $(INSTALL) -c -m 644
INSTALL_DIR = $(INSTALL) -d
-INSTALL_LIB = $(LIBTOOL) $(INSTALL) -c -m 555 @INSTALL_STRIP@
-INSTALL_MAN = $(INSTALL) -c -m 444
-INSTALL_SCRIPT = $(INSTALL) -c -m 555
+INSTALL_LIB = $(LIBTOOL) $(INSTALL) -c -m 755 @INSTALL_STRIP@
+INSTALL_MAN = $(INSTALL) -c -m 644
+INSTALL_SCRIPT = $(INSTALL) -c -m 755
#
# Default user, group, and system groups for the scheduler...

View file

@ -0,0 +1,26 @@
--- cups-1.4svn-r8703/scheduler/cups-driverd.cxx~ 2009-06-09 20:43:47.000000000 +0200
+++ cups-1.4svn-r8703/scheduler/cups-driverd.cxx 2009-06-09 21:09:32.000000000 +0200
@@ -211,7 +211,6 @@
const char *scheme) /* I - PPD scheme */
{
ppd_info_t *ppd; /* PPD */
- char *recommended; /* Foomatic driver string */
/*
@@ -250,15 +249,6 @@
strlcpy(ppd->record.scheme, scheme, sizeof(ppd->record.scheme));
/*
- * Strip confusing (and often wrong) "recommended" suffix added by
- * Foomatic drivers...
- */
-
- if ((recommended = strstr(ppd->record.make_and_model,
- " (recommended)")) != NULL)
- *recommended = '\0';
-
- /*
* Add the PPD to the PPD arrays...
*/

View file

@ -0,0 +1,569 @@
diff -Naur -x '*~' -x '*.orig' -x '*.rej' cups-1.4.3/backend/ieee1284.c cups-1.4.3-both-usblp-and-libusb/backend/ieee1284.c
--- cups-1.4.3/backend/ieee1284.c 2009-12-08 03:13:42.000000000 +0100
+++ cups-1.4.3-both-usblp-and-libusb/backend/ieee1284.c 2010-03-31 13:53:53.000000000 +0200
@@ -255,6 +255,7 @@
cups_option_t *values; /* Keys and values in device ID */
const char *mfg, /* Manufacturer */
*mdl, /* Model */
+ *des, /* Description */
*sern; /* Serial number */
char temp[256], /* Temporary manufacturer string */
*tempptr; /* Pointer into temp string */
@@ -285,10 +286,20 @@
}
else
{
- strlcpy(temp, make_model, sizeof(temp));
+ /*
+ * No manufacturer? Use the model string or description...
+ */
+
+ if (mdl)
+ _ppdNormalizeMakeAndModel(mdl, temp, sizeof(temp));
+ else if ((des = cupsGetOption("DESCRIPTION", num_values, values)) != NULL ||
+ (des = cupsGetOption("DES", num_values, values)) != NULL)
+ _ppdNormalizeMakeAndModel(des, temp, sizeof(temp));
+ else
+ strlcpy(temp, "Unknown", sizeof(temp));
if ((tempptr = strchr(temp, ' ')) != NULL)
- *tempptr = '\0';
+ *tempptr = '\0';
mfg = temp;
}
diff -Naur -x '*~' -x '*.orig' -x '*.rej' cups-1.4.3/backend/Makefile cups-1.4.3-both-usblp-and-libusb/backend/Makefile
--- cups-1.4.3/backend/Makefile 2009-03-03 20:39:21.000000000 +0100
+++ cups-1.4.3-both-usblp-and-libusb/backend/Makefile 2010-03-31 13:53:53.000000000 +0200
@@ -267,7 +267,7 @@
echo Linking $@...
$(CC) $(LDFLAGS) -o usb usb.o libbackend.a $(LIBUSB) \
$(BACKLIBS) $(LIBS)
-usb.o: usb.c usb-darwin.c usb-libusb.c usb-unix.c
+usb.o: usb.c usb-darwin.c usb-hybrid.c usb-libusb.c usb-unix.c
#
diff -Naur -x '*~' -x '*.orig' -x '*.rej' cups-1.4.3/backend/usb.c cups-1.4.3-both-usblp-and-libusb/backend/usb.c
--- cups-1.4.3/backend/usb.c 2008-06-24 03:28:36.000000000 +0200
+++ cups-1.4.3-both-usblp-and-libusb/backend/usb.c 2010-03-31 13:53:53.000000000 +0200
@@ -56,7 +56,7 @@
*/
#ifdef HAVE_USB_H
-# include "usb-libusb.c"
+# include "usb-hybrid.c"
#elif defined(__APPLE__)
# include "usb-darwin.c"
#elif defined(__linux) || defined(__sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
diff -Naur -x '*~' -x '*.orig' -x '*.rej' cups-1.4.3/backend/usb-hybrid.c cups-1.4.3-both-usblp-and-libusb/backend/usb-hybrid.c
--- cups-1.4.3/backend/usb-hybrid.c 1970-01-01 01:00:00.000000000 +0100
+++ cups-1.4.3-both-usblp-and-libusb/backend/usb-hybrid.c 2010-03-31 13:53:53.000000000 +0200
@@ -0,0 +1,87 @@
+/*
+ * "$Id: usb-hybrid.c 8807 2009-08-31 18:45:43Z mike $"
+ *
+ * USB port backend for the Common UNIX Printing System (CUPS).
+ *
+ * This file is included from "usb.c" when compiled on Linux.
+ *
+ * Copyright 2007-2008 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ *
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * "LICENSE" which should have been included with this file. If this
+ * file is missing or damaged, see the license at "http://www.cups.org/".
+ *
+ * This file is subject to the Apple OS-Developed Software exception.
+ *
+ * Contents:
+ *
+ * print_device() - Print a file to a USB device.
+ * list_devices() - List all USB devices.
+ */
+
+/*
+ * Include necessary headers.
+ */
+
+#include <sys/select.h>
+
+/*
+ * Include the two USB implementations used under Linux ...
+ */
+
+#include "usb-libusb.c"
+#include "usb-unix.c"
+
+/*
+ * 'print_device()' - Print a file to a USB device.
+ */
+
+int /* O - Exit status */
+print_device(const char *uri, /* I - Device URI */
+ const char *hostname, /* I - Hostname/manufacturer */
+ const char *resource, /* I - Resource/modelname */
+ char *options, /* I - Device options/serial number */
+ int print_fd, /* I - File descriptor to print */
+ int copies, /* I - Copies to print */
+ int argc, /* I - Number of command-line arguments (6 or 7) */
+ char *argv[]) /* I - Command-line arguments */
+{
+ int result;
+ for(;;)
+ {
+ result = print_device_unix(uri, hostname, resource, options, print_fd,
+ copies, argc, argv);
+ if (result == -1)
+ {
+ result = print_device_libusb(uri, hostname, resource, options, print_fd,
+ copies, argc, argv);
+ if (result == -1)
+ sleep(5);
+ else
+ return(result);
+ }
+ else
+ return(result);
+ }
+}
+
+/*
+ * 'list_devices()' - List all USB devices.
+ */
+
+void
+list_devices(void)
+{
+ /* Try both discovery methods, each device will appear only under one
+ of them */
+ list_devices_libusb();
+ list_devices_unix();
+}
+
+
+/*
+ * End of "$Id: usb-hybrid.c 8807 2009-08-31 18:45:43Z mike $".
+ */
diff -Naur -x '*~' -x '*.orig' -x '*.rej' cups-1.4.3/backend/usb-libusb.c cups-1.4.3-both-usblp-and-libusb/backend/usb-libusb.c
--- cups-1.4.3/backend/usb-libusb.c 2009-09-11 22:03:31.000000000 +0200
+++ cups-1.4.3-both-usblp-and-libusb/backend/usb-libusb.c 2010-03-31 13:53:53.000000000 +0200
@@ -13,16 +13,16 @@
*
* Contents:
*
- * list_devices() - List the available printers.
- * print_device() - Print a file to a USB device.
+ * list_devices_libusb() - List the available printers.
+ * print_device_libusb() - Print a file to a USB device.
* close_device() - Close the connection to the USB printer.
* find_device() - Find or enumerate USB printers.
* get_device_id() - Get the IEEE-1284 device ID for the printer.
* list_cb() - List USB printers for discovery.
* make_device_uri() - Create a device URI for a USB printer.
- * open_device() - Open a connection to the USB printer.
+ * open_device_libusb() - Open a connection to the USB printer.
* print_cb() - Find a USB printer for printing.
- * side_cb() - Handle side-channel requests.
+ * side_cb_libusb() - Handle side-channel requests.
*/
/*
@@ -65,30 +65,30 @@
static char *make_device_uri(usb_printer_t *printer,
const char *device_id,
char *uri, size_t uri_size);
-static int open_device(usb_printer_t *printer, int verbose);
+static int open_device_libusb(usb_printer_t *printer, int verbose);
static int print_cb(usb_printer_t *printer, const char *device_uri,
const char *device_id, const void *data);
-static ssize_t side_cb(usb_printer_t *printer, int print_fd);
+static ssize_t side_cb_libusb(usb_printer_t *printer, int print_fd);
/*
- * 'list_devices()' - List the available printers.
+ * 'list_devices_libusb()' - List the available printers.
*/
void
-list_devices(void)
+list_devices_libusb(void)
{
- fputs("DEBUG: list_devices\n", stderr);
+ fputs("DEBUG: list_devices_libusb\n", stderr);
find_device(list_cb, NULL);
}
/*
- * 'print_device()' - Print a file to a USB device.
+ * 'print_device_libusb()' - Print a file to a USB device.
*/
int /* O - Exit status */
-print_device(const char *uri, /* I - Device URI */
+print_device_libusb(const char *uri, /* I - Device URI */
const char *hostname, /* I - Hostname/manufacturer */
const char *resource, /* I - Resource/modelname */
char *options, /* I - Device options/serial number */
@@ -105,19 +105,23 @@
struct pollfd pfds[2]; /* Poll descriptors */
- fputs("DEBUG: print_device\n", stderr);
+ fputs("DEBUG: print_device_libusb\n", stderr);
/*
* Connect to the printer...
*/
+#if defined(__linux) || defined(__sun) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
+ if ((printer = find_device(print_cb, uri)) == NULL)
+ return(-1);
+#else
while ((printer = find_device(print_cb, uri)) == NULL)
{
_cupsLangPuts(stderr,
_("INFO: Waiting for printer to become available...\n"));
sleep(5);
}
-
+#endif
/*
* If we are printing data from a print driver on stdin, ignore SIGTERM
@@ -189,7 +193,7 @@
if (pfds[1].revents & (POLLIN | POLLHUP))
{
- if ((bytes = side_cb(printer, print_fd)) < 0)
+ if ((bytes = side_cb_libusb(printer, print_fd)) < 0)
pfds[1].events = 0; /* Filter has gone away... */
else
tbytes += bytes;
@@ -359,7 +363,7 @@
printer.iface = iface;
printer.handle = NULL;
- if (!open_device(&printer, data != NULL))
+ if (!open_device_libusb(&printer, data != NULL))
{
if (!get_device_id(&printer, device_id, sizeof(device_id)))
{
@@ -583,6 +587,14 @@
mfg = tempmfg;
}
+ if (!strncasecmp(mdl, mfg, strlen(mfg)))
+ {
+ mdl += strlen(mfg);
+
+ while (isspace(*mdl & 255))
+ mdl ++;
+ }
+
/*
* Generate the device URI from the manufacturer, model, serial number,
* and interface number...
@@ -611,11 +623,11 @@
/*
- * 'open_device()' - Open a connection to the USB printer.
+ * 'open_device_libusb()' - Open a connection to the USB printer.
*/
static int /* O - 0 on success, -1 on error */
-open_device(usb_printer_t *printer, /* I - Printer */
+open_device_libusb(usb_printer_t *printer, /* I - Printer */
int verbose) /* I - Update connecting-to-device state? */
{
int number; /* Configuration/interface/altset numbers */
@@ -733,16 +745,73 @@
const char *device_id, /* I - IEEE-1284 device ID */
const void *data) /* I - User data (make, model, S/N) */
{
- return (!strcmp((char *)data, device_uri));
+ char *uri = (char *)data,
+ *str1,
+ *str2,
+ buf[255],
+ requested_uri[1024];
+
+ /* Work on a copy of uri */
+ strncpy(requested_uri, uri, sizeof(requested_uri));
+ requested_uri[sizeof(requested_uri) - 1] = '\0';
+
+ /*
+ * libusb-discovered URIs can have an "interface" specification and this
+ * never happens for usblp-discovered URIs, so remove the "interface"
+ * specification from the URI which we are checking currently. This way a
+ * queue for a usblp-discovered printer can now be accessed via libusb
+ */
+ if (((str1 = strstr(requested_uri, "interface=")) == NULL) &&
+ ((str2 = strstr(device_uri, "interface=")) != NULL))
+ {
+ *(str2 - 1) = '\0';
+ }
+
+ /*
+ * Old URI with "serial=?". Cut this part off and consider this as
+ * an URI without serial number
+ */
+ if ((str1 = strstr(requested_uri, "serial=?")) != NULL)
+ *(str1 - 1) = '\0';
+
+ /*
+ * Old URI without serial number. Match it also with URIs with serial
+ * number
+ */
+ if (((str1 = strstr(requested_uri, "serial=")) == NULL) &&
+ ((str2 = strstr(device_uri, "serial=")) != NULL))
+ *(str2 - 1) = '\0';
+
+ /*
+ * libusb-discovered URIs can have a "serial" specification when the
+ * usblp-discovered URI for the same printer does not have one, as
+ * with libusb we can discover serial numbers also with other methods
+ * than only via the device ID. Therefore we accept also a
+ * usblp-discovered printer without serial number as a match. This we
+ * do by removing the serial number from the queue's (libusb-discovered)
+ * URI before comparing. Also warn the user because of the incapability
+ * of the usblp-based access to distinguish printers by the serial
+ * number.
+ */
+ if (((str1 = strstr(requested_uri, "serial=")) == NULL) &&
+ ((str2 = strstr(device_uri, "serial=")) != NULL))
+ {
+ *(str2 - 1) = '\0';
+ if (backendGetMakeModel(device_id, buf, sizeof(buf)) == 0)
+ fprintf(stderr, "WARNING: If you have more than one %s printer connected to this machine, please make sure that the \"usblp\" kernel module is always unloaded (and blacklisted) and re-create the queues for these printers. Otherwise CUPS will not be able to distinguish them.\n",
+ buf);
+ }
+
+ return (!strcmp(requested_uri, device_uri));
}
/*
- * 'side_cb()' - Handle side-channel requests.
+ * 'side_cb_libusb()' - Handle side-channel requests.
*/
static ssize_t /* O - Number of bytes written */
-side_cb(usb_printer_t *printer, /* I - Printer */
+side_cb_libusb(usb_printer_t *printer, /* I - Printer */
int print_fd) /* I - File to print */
{
ssize_t bytes, /* Bytes read/written */
diff -Naur -x '*~' -x '*.orig' -x '*.rej' cups-1.4.3/backend/usb-unix.c cups-1.4.3-both-usblp-and-libusb/backend/usb-unix.c
--- cups-1.4.3/backend/usb-unix.c 2009-12-08 03:13:42.000000000 +0100
+++ cups-1.4.3-both-usblp-and-libusb/backend/usb-unix.c 2010-03-31 13:59:05.000000000 +0200
@@ -18,10 +18,10 @@
*
* Contents:
*
- * print_device() - Print a file to a USB device.
- * list_devices() - List all USB devices.
- * open_device() - Open a USB device...
- * side_cb() - Handle side-channel requests...
+ * print_device_unix() - Print a file to a USB device.
+ * list_devices_unix() - List all USB devices.
+ * open_device_unix() - Open a USB device...
+ * side_cb_unix() - Handle side-channel requests...
*/
/*
@@ -35,17 +35,17 @@
* Local functions...
*/
-static int open_device(const char *uri, int *use_bc);
-static int side_cb(int print_fd, int device_fd, int snmp_fd,
+static int open_device_unix(const char *uri, int *use_bc);
+static int side_cb_unix(int print_fd, int device_fd, int snmp_fd,
http_addr_t *addr, int use_bc);
/*
- * 'print_device()' - Print a file to a USB device.
+ * 'print_device_unix()' - Print a file to a USB device.
*/
int /* O - Exit status */
-print_device(const char *uri, /* I - Device URI */
+print_device_unix(const char *uri, /* I - Device URI */
const char *hostname, /* I - Hostname/manufacturer */
const char *resource, /* I - Resource/modelname */
char *options, /* I - Device options/serial number */
@@ -102,7 +102,7 @@
strncasecmp(hostname, "Minolta", 7);
#endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ || __DragonFly__ */
- if ((device_fd = open_device(uri, &use_bc)) == -1)
+ if ((device_fd = open_device_unix(uri, &use_bc)) == -1)
{
if (getenv("CLASS") != NULL)
{
@@ -132,6 +132,10 @@
_("INFO: Printer busy; will retry in 10 seconds...\n"));
sleep(10);
}
+#ifdef HAVE_USB_H
+ else
+ return (-1);
+#else
else if (errno == ENXIO || errno == EIO || errno == ENOENT ||
errno == ENODEV)
{
@@ -147,6 +151,7 @@
resource, strerror(errno));
return (CUPS_BACKEND_FAILED);
}
+#endif
}
}
while (device_fd < 0);
@@ -190,7 +195,7 @@
tbytes = backendRunLoop(print_fd, device_fd, -1, NULL, use_bc, 1, NULL);
#else
- tbytes = backendRunLoop(print_fd, device_fd, -1, NULL, use_bc, 1, side_cb);
+ tbytes = backendRunLoop(print_fd, device_fd, -1, NULL, use_bc, 1, side_cb_unix);
#endif /* __sun */
if (print_fd != 0 && tbytes >= 0)
@@ -214,11 +219,11 @@
/*
- * 'list_devices()' - List all USB devices.
+ * 'list_devices_unix()' - List all USB devices.
*/
void
-list_devices(void)
+list_devices_unix(void)
{
#ifdef __linux
int i; /* Looping var */
@@ -320,11 +325,11 @@
/*
- * 'open_device()' - Open a USB device...
+ * 'open_device_unix()' - Open a USB device...
*/
static int /* O - File descriptor or -1 on error */
-open_device(const char *uri, /* I - Device URI */
+open_device_unix(const char *uri, /* I - Device URI */
int *use_bc) /* O - Set to 0 for unidirectional */
{
int fd; /* File descriptor */
@@ -357,9 +362,12 @@
char device[255], /* Device filename */
device_id[1024], /* Device ID string */
make_model[1024], /* Make and model */
- device_uri[1024]; /* Device URI string */
-
+ device_uri[1024], /* Device URI string */
+ requested_uri[1024], /* Device URI string */
+ *str1,
+ *str2;
+
/*
* Find the correct USB device...
*/
@@ -407,7 +415,55 @@
device_uri[0] = '\0';
}
- if (!strcmp(uri, device_uri))
+ /* Work on a copy of uri */
+ strncpy(requested_uri, uri, sizeof(requested_uri));
+ requested_uri[sizeof(requested_uri) - 1] = '\0';
+
+ /*
+ * libusb-discovered URIs can have an "interface" specification and this
+ * never happens for usblp-discovered URIs, so remove the "interface"
+ * specification from the URI of the print queue. This way a queue for
+ * a libusb-discovered printer can now be accessed via the usblip kernel
+ * module
+ */
+ if ((str1 = strstr(requested_uri, "interface=")) != NULL)
+ *(str1 - 1) = '\0';
+
+ /*
+ * Old URI with "serial=?". Cut this part off and consider this as
+ * an URI without serial number
+ */
+ if ((str1 = strstr(requested_uri, "serial=?")) != NULL)
+ *(str1 - 1) = '\0';
+
+ /*
+ * Old URI without serial number. Match it also with URIs with serial
+ * number
+ */
+ if (((str1 = strstr(requested_uri, "serial=")) == NULL) &&
+ ((str2 = strstr(device_uri, "serial=")) != NULL))
+ *(str2 - 1) = '\0';
+
+ /*
+ * libusb-discovered URIs can have a "serial" specification when the
+ * usblp-discovered URI for the same printer does not have one, as
+ * with libusb we can discover serial numbers also with other methods
+ * than only via the device ID. Therefore we accept also a
+ * usblp-discovered printer without serial number as a match. This we
+ * do by removing the serial number from the queue's (libusb-discovered)
+ * URI before comparing. Also warn the user because of the incapability
+ * of the usblp-based access to distinguish printers by the serial
+ * number.
+ */
+ if (((str1 = strstr(requested_uri, "serial=")) != NULL) &&
+ ((str2 = strstr(device_uri, "serial=")) == NULL))
+ {
+ *(str1 - 1) = '\0';
+ fprintf(stderr, "WARNING: If you have more than one %s printer connected to this machine, please unload (and blacklist) the \"usblp\" kernel module as otherwise CUPS will not be able to distinguish your printers.\n",
+ make_model);
+ }
+
+ if (!strcmp(requested_uri, device_uri))
{
/*
* Yes, return this file descriptor...
@@ -433,10 +489,14 @@
*/
if (busy)
+ {
_cupsLangPuts(stderr,
_("INFO: Printer busy; will retry in 5 seconds...\n"));
- sleep(5);
+ sleep(5);
+ }
+ else
+ return -1;
}
}
#elif defined(__sun) && defined(ECPPIOC_GETDEVID)
@@ -557,11 +617,11 @@
/*
- * 'side_cb()' - Handle side-channel requests...
+ * 'side_cb_unix()' - Handle side-channel requests...
*/
-static int /* O - 0 on success, -1 on error */
-side_cb(int print_fd, /* I - Print file */
+static int
+side_cb_unix(int print_fd, /* I - Print file */
int device_fd, /* I - Device file */
int snmp_fd, /* I - SNMP socket (unused) */
http_addr_t *addr, /* I - Device address (unused) */

43
cups-1.4.4-getpass.patch Normal file
View file

@ -0,0 +1,43 @@
diff -Naur -x '*.orig' -x '*.rej' -x '*~' cups-1.4.4/cups/usersys.c cups-1.4.4-getpass//cups/usersys.c
--- cups-1.4.4/cups/usersys.c 2010-03-31 00:07:33.000000000 +0200
+++ cups-1.4.4-getpass//cups/usersys.c 2010-09-09 19:57:49.000000000 +0200
@@ -41,6 +41,8 @@
#include "globals.h"
#include <stdlib.h>
#include <sys/stat.h>
+#include <termios.h>
+#include <signal.h>
#ifdef WIN32
# include <windows.h>
#else
@@ -406,7 +408,29 @@
* Use the standard getpass function to get a password from the console.
*/
- return (getpass(prompt));
+ static char password[100];
+ struct termios oldtio, newtio;
+ sigset_t oldset, newset;
+ int nread;
+ sigprocmask (SIG_BLOCK, NULL, &newset);
+ sigaddset (&newset, SIGINT);
+ sigaddset (&newset, SIGTSTP);
+ sigprocmask (SIG_BLOCK, &newset, &oldset);
+ tcgetattr (STDIN_FILENO, &oldtio);
+ newtio = oldtio;
+ newtio.c_lflag &= ~ECHO;
+ tcsetattr (STDIN_FILENO, TCSAFLUSH, &newtio);
+ fputs (prompt, stdout);
+ fflush (stdout);
+ nread = read (STDIN_FILENO, password, sizeof (password));
+ tcsetattr (STDIN_FILENO, TCSAFLUSH, &oldtio);
+ fputc ('\n', stdout);
+ sigprocmask (SIG_SETMASK, &oldset, NULL);
+ if (nread > 0)
+ password[nread - 1] = '\0';
+ else
+ password[0] ='\0';
+ return password;
#endif /* WIN32 */
}

View file

@ -0,0 +1,33 @@
diff -Naurp cups-1.4.8/scheduler/client.c cups-1.4.8.oden/scheduler/client.c
--- cups-1.4.8/scheduler/client.c 2011-01-22 01:07:22.000000000 +0100
+++ cups-1.4.8.oden/scheduler/client.c 2011-08-23 12:32:14.592896201 +0200
@@ -430,7 +430,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)
{
if (httpAddrLocalhost(&temp))
strlcpy(con->servername, "localhost", sizeof(con->servername));
- else if (HostNameLookups || RemotePort)
+ else if (HostNameLookups)
httpAddrLookup(&temp, con->servername, sizeof(con->servername));
else
httpAddrString(&temp, con->servername, sizeof(con->servername));
@@ -443,7 +443,7 @@ cupsdAcceptClient(cupsd_listener_t *lis)
{
if (httpAddrLocalhost(&temp))
strlcpy(con->servername, "localhost", sizeof(con->servername));
- else if (HostNameLookups || RemotePort)
+ else if (HostNameLookups)
httpAddrLookup(&temp, con->servername, sizeof(con->servername));
else
httpAddrString(&temp, con->servername, sizeof(con->servername));
diff -Naurp cups-1.4.8/scheduler/conf.c cups-1.4.8.oden/scheduler/conf.c
--- cups-1.4.8/scheduler/conf.c 2011-01-11 08:05:58.000000000 +0100
+++ cups-1.4.8.oden/scheduler/conf.c 2011-08-23 12:32:14.593896179 +0200
@@ -750,7 +750,7 @@ cupsdReadConfiguration(void)
cupsdAddAlias(ServerAlias, temp);
cupsdLogMessage(CUPSD_LOG_DEBUG, "Added auto ServerAlias %s", temp);
- if (HostNameLookups || RemotePort)
+ if (HostNameLookups)
{
struct hostent *host; /* Host entry to get FQDN */

View file

@ -0,0 +1,91 @@
--- filter/pstops.c 2010-11-17 20:58:22.000000000 +0100
+++ filter/pstops.c.oden 2011-01-08 13:01:17.450527001 +0100
@@ -108,6 +108,7 @@ typedef struct /**** Document informa
int num_options; /* Number of document-wide options */
cups_option_t *options; /* Document-wide options */
int normal_landscape, /* Normal rotation for landscape? */
+ orientation, /* Original orientation of the document */
saw_eof, /* Saw the %%EOF comment? */
slow_collate, /* Collate copies by hand? */
slow_duplex, /* Duplex pages slowly? */
@@ -2083,7 +2084,7 @@ do_setup(pstops_doc_t *doc, /* I - Docu
* of the pages...
*/
- if (Orientation & 1)
+ if (doc->orientation & 1)
write_label_prolog(doc, doc->page_label, PageBottom,
PageWidth - PageLength + PageTop, PageLength);
else
@@ -2091,7 +2092,30 @@ do_setup(pstops_doc_t *doc, /* I - Docu
PageLength);
}
else
- write_label_prolog(doc, doc->page_label, PageBottom, PageTop, PageWidth);
+ {
+ switch (doc->orientation)
+ {
+ case 0 :
+ write_label_prolog(doc, doc->page_label, PageBottom, PageTop,
+ PageWidth);
+ break;
+
+ case 1 :
+ write_label_prolog(doc, doc->page_label, PageLeft, PageRight,
+ PageLength);
+ break;
+
+ case 2 :
+ write_label_prolog(doc, doc->page_label, PageLength - PageTop,
+ PageLength - PageBottom, PageWidth);
+ break;
+
+ case 3 :
+ write_label_prolog(doc, doc->page_label, PageWidth - PageRight,
+ PageWidth - PageLeft, PageLength);
+ break;
+ }
+ }
}
@@ -2176,7 +2200,7 @@ end_nup(pstops_doc_t *doc, /* I - Docum
case 1 :
if (doc->use_ESPshowpage)
{
- write_labels(doc, Orientation);
+ write_labels(doc, doc->orientation);
doc_puts(doc, "ESPshowpage\n");
}
break;
@@ -2191,7 +2215,7 @@ end_nup(pstops_doc_t *doc, /* I - Docum
* Rotate the labels back to portrait...
*/
- write_labels(doc, Orientation - 1);
+ write_labels(doc, doc->orientation - 1);
}
else if (Orientation == 0)
{
@@ -2217,7 +2241,7 @@ end_nup(pstops_doc_t *doc, /* I - Docum
default :
if (is_last_page(number) && doc->use_ESPshowpage)
{
- write_labels(doc, Orientation);
+ write_labels(doc, doc->orientation);
doc_puts(doc, "ESPshowpage\n");
}
break;
@@ -2421,6 +2445,12 @@ set_pstops_options(
doc->new_bounding_box[3] = INT_MIN;
/*
+ * Save original orientation of the document
+ */
+
+ doc->orientation = Orientation;
+
+ /*
* AP_FIRSTPAGE_* and the corresponding non-first-page options.
*/

View file

@ -0,0 +1,250 @@
diff -rup cups-1.4.4/cups/http.c cups-1.4.4-str3461-1.4.patch.reverted/cups/http.c
--- cups-1.4.4/cups/http.c 2010-06-16 07:27:41.000000000 +0200
+++ cups-1.4.4-str3461-1.4.patch.reverted/cups/http.c 2010-06-25 11:02:31.000000000 +0200
@@ -83,12 +83,10 @@
* http_debug_hex() - Do a hex dump of a buffer.
* http_field() - Return the field index for a field name.
* http_read_ssl() - Read from a SSL/TLS connection.
- * http_locking_cb() - Lock/unlock a thread's mutex.
* http_send() - Send a request with all fields and the trailing
* blank line.
* http_setup_ssl() - Set up SSL/TLS support on a connection.
* http_shutdown_ssl() - Shut down SSL/TLS on a connection.
- * http_threadid_cb() - Return the current thread ID.
* http_upgrade() - Force upgrade to TLS encryption.
* http_write() - Write a buffer to a HTTP connection.
* http_write_chunk() - Write a chunked buffer.
@@ -146,19 +144,6 @@ static int http_setup_ssl(http_t *http)
static void http_shutdown_ssl(http_t *http);
static int http_upgrade(http_t *http);
static int http_write_ssl(http_t *http, const char *buf, int len);
-
-# ifdef HAVE_GNUTLS
-# ifdef HAVE_PTHREAD_H
-GCRY_THREAD_OPTION_PTHREAD_IMPL;
-# endif /* HAVE_PTHREAD_H */
-
-# elif defined(HAVE_LIBSSL) && defined(HAVE_PTHREAD_H)
-static pthread_mutex_t *http_locks; /* OpenSSL lock mutexes */
-
-static void http_locking_cb(int mode, int type, const char *file,
- int line);
-static unsigned long http_threadid_cb(void);
-# endif /* HAVE_GNUTLS */
#endif /* HAVE_SSL */
@@ -1188,22 +1173,21 @@ httpHead(http_t *http, /* I - Conne
void
httpInitialize(void)
{
- static int initialized = 0; /* Have we been called before? */
-#ifdef WIN32
- WSADATA winsockdata; /* WinSock data */
-#endif /* WIN32 */
#ifdef HAVE_LIBSSL
- int i; /* Looping var */
- unsigned char data[1024]; /* Seed data */
+# ifndef WIN32
+ struct timeval curtime; /* Current time in microseconds */
+# endif /* !WIN32 */
+ int i; /* Looping var */
+ unsigned char data[1024]; /* Seed data */
#endif /* HAVE_LIBSSL */
-
- if (initialized)
- return;
-
#ifdef WIN32
- WSAStartup(MAKEWORD(2,2), &winsockdata);
+ WSADATA winsockdata; /* WinSock data */
+
+ static int initialized = 0; /* Has WinSock been initialized? */
+ if (!initialized)
+ WSAStartup(MAKEWORD(1,1), &winsockdata);
#elif !defined(SO_NOSIGPIPE)
/*
* Ignore SIGPIPE signals...
@@ -1226,56 +1210,29 @@ httpInitialize(void)
#endif /* WIN32 */
#ifdef HAVE_GNUTLS
- /*
- * Make sure we handle threading properly...
- */
-
-# ifdef HAVE_PTHREAD_H
- gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
-# endif /* HAVE_PTHREAD_H */
-
- /*
- * Initialize GNU TLS...
- */
-
gnutls_global_init();
+#endif /* HAVE_GNUTLS */
-#elif defined(HAVE_LIBSSL)
- /*
- * Initialize OpenSSL...
- */
-
+#ifdef HAVE_LIBSSL
SSL_load_error_strings();
SSL_library_init();
/*
- * Set the threading callbacks...
- */
-
-# ifdef HAVE_PTHREAD_H
- http_locks = calloc(CRYPTO_num_locks(), sizeof(pthread_mutex_t));
-
- for (i = 0; i < CRYPTO_num_locks(); i ++)
- pthread_mutex_init(http_locks + i, NULL);
-
- CRYPTO_set_id_callback(http_threadid_cb);
- CRYPTO_set_locking_callback(http_locking_cb);
-# endif /* HAVE_PTHREAD_H */
-
- /*
* Using the current time is a dubious random seed, but on some systems
* it is the best we can do (on others, this seed isn't even used...)
*/
- CUPS_SRAND(time(NULL));
+# ifdef WIN32
+# else
+ gettimeofday(&curtime, NULL);
+ srand(curtime.tv_sec + curtime.tv_usec);
+# endif /* WIN32 */
for (i = 0; i < sizeof(data); i ++)
- data[i] = CUPS_RAND();
+ data[i] = rand();
RAND_seed(data, sizeof(data));
-#endif /* HAVE_GNUTLS */
-
- initialized = 1;
+#endif /* HAVE_LIBSSL */
}
@@ -2834,25 +2791,6 @@ http_read_ssl(http_t *http, /* I - Conn
#endif /* HAVE_SSL */
-#if defined(HAVE_LIBSSL) && defined(HAVE_PTHREAD_H)
-/*
- * 'http_locking_cb()' - Lock/unlock a thread's mutex.
- */
-
-static void
-http_locking_cb(int mode, /* I - Lock mode */
- int type, /* I - Lock type */
- const char *file, /* I - Source file */
- int line) /* I - Line number */
-{
- if (mode & CRYPTO_LOCK)
- pthread_mutex_lock(http_locks + type);
- else
- pthread_mutex_unlock(http_locks + type);
-}
-#endif /* HAVE_LIBSSL && HAVE_PTHREAD_H */
-
-
/*
* 'http_send()' - Send a request with all fields and the trailing blank line.
*/
@@ -3224,19 +3162,6 @@ http_shutdown_ssl(http_t *http) /* I -
#endif /* HAVE_SSL */
-#if defined(HAVE_LIBSSL) && defined(HAVE_PTHREAD_H)
-/*
- * 'http_threadid_cb()' - Return the current thread ID.
- */
-
-static unsigned long /* O - Thread ID */
-http_threadid_cb(void)
-{
- return ((unsigned long)pthread_self());
-}
-#endif /* HAVE_LIBSSL && HAVE_PTHREAD_H */
-
-
#ifdef HAVE_SSL
/*
* 'http_upgrade()' - Force upgrade to TLS encryption.
diff -rup cups-1.4.4/cups/http-private.h cups-1.4.4-str3461-1.4.patch.reverted/cups/http-private.h
--- cups-1.4.4/cups/http-private.h 2010-04-12 06:03:53.000000000 +0200
+++ cups-1.4.4-str3461-1.4.patch.reverted/cups/http-private.h 2010-06-25 11:03:34.000000000 +0200
@@ -98,7 +98,6 @@ extern BIO_METHOD *_httpBIOMethods(void)
* The GNU TLS library is more of a "bare metal" SSL/TLS library...
*/
# include <gnutls/gnutls.h>
-# include <gcrypt.h>
typedef struct
{
diff -rup cups-1.4.4/scheduler/main.c cups-1.4.4-str3461-1.4.patch.reverted/scheduler/main.c
--- cups-1.4.4/scheduler/main.c 2010-04-23 20:56:34.000000000 +0200
+++ cups-1.4.4-str3461-1.4.patch.reverted/scheduler/main.c 2010-06-25 11:14:07.000000000 +0200
@@ -549,8 +549,6 @@ main(int argc, /* I - Number of comm
* Startup the server...
*/
- httpInitialize();
-
cupsdStartServer();
/*
diff -rup cups-1.4.4/scheduler/server.c cups-1.4.4-str3461-1.4.patch.reverted/scheduler/server.c
--- cups-1.4.4/scheduler/server.c 2010-04-12 06:03:53.000000000 +0200
+++ cups-1.4.4-str3461-1.4.patch.reverted/scheduler/server.c 2010-06-25 11:12:52.000000000 +0200
@@ -44,6 +44,42 @@ static int started = 0;
void
cupsdStartServer(void)
{
+#ifdef HAVE_LIBSSL
+ int i; /* Looping var */
+ struct timeval curtime; /* Current time in microseconds */
+ unsigned char data[1024]; /* Seed data */
+#endif /* HAVE_LIBSSL */
+
+
+#ifdef HAVE_LIBSSL
+ /*
+ * Initialize the encryption libraries...
+ */
+
+ SSL_library_init();
+ SSL_load_error_strings();
+
+ /*
+ * Using the current time is a dubious random seed, but on some systems
+ * it is the best we can do (on others, this seed isn't even used...)
+ */
+
+ gettimeofday(&curtime, NULL);
+ srand(curtime.tv_sec + curtime.tv_usec);
+
+ for (i = 0; i < sizeof(data); i ++)
+ data[i] = rand(); /* Yes, this is a poor source of random data... */
+
+ RAND_seed(&data, sizeof(data));
+#elif defined(HAVE_GNUTLS)
+ /*
+ * Initialize the encryption libraries...
+ */
+
+ gnutls_global_init();
+#endif /* HAVE_LIBSSL */
+
+
/*
* Create the default security profile...
*/

1098
cups-avahi.patch Normal file

File diff suppressed because it is too large Load diff

11
cups-banners.patch Normal file
View file

@ -0,0 +1,11 @@
--- cups-1.2rc2/scheduler/banners.c.banners 2006-04-19 16:12:07.000000000 +0100
+++ cups-1.2rc2/scheduler/banners.c 2006-04-19 16:12:42.000000000 +0100
@@ -119,6 +119,8 @@
if ((ext = strrchr(dent->filename, '.')) != NULL)
if (!strcmp(ext, ".bck") ||
!strcmp(ext, ".bak") ||
+ !strcmp(ext, ".rpmnew") ||
+ !strcmp(ext, ".rpmsave") ||
!strcmp(ext, ".sav"))
continue;

View file

@ -0,0 +1,90 @@
diff -up cups-1.4rc1/cups/dest.c.cups-get-classes cups-1.4rc1/cups/dest.c
--- cups-1.4rc1/cups/dest.c.cups-get-classes 2009-05-13 22:39:17.000000000 +0100
+++ cups-1.4rc1/cups/dest.c 2009-07-28 22:17:40.285709944 +0100
@@ -1735,6 +1735,7 @@ cups_get_sdests(http_t *http, /* I
char uri[1024]; /* printer-uri value */
int num_options; /* Number of options */
cups_option_t *options; /* Options */
+ int get_classes; /* Whether we need to fetch class */
#ifdef __APPLE__
char media_default[41]; /* Default paper size */
#endif /* __APPLE__ */
@@ -1791,6 +1792,8 @@ cups_get_sdests(http_t *http, /* I
* printer-uri [for IPP_GET_PRINTER_ATTRIBUTES]
*/
+ get_classes = (op == CUPS_GET_PRINTERS);
+
request = ippNewRequest(op);
ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
@@ -1848,6 +1851,23 @@ cups_get_sdests(http_t *http, /* I
attr->value_tag != IPP_TAG_URI)
continue;
+ if (get_classes &&
+
+ /* Is this a class? */
+ ((attr->value_tag == IPP_TAG_ENUM &&
+ !strcmp(attr->name, "printer-type") &&
+ (attr->values[0].integer & CUPS_PRINTER_CLASS)) ||
+
+ /* Or, is this an attribute from CUPS 1.2 or later? */
+ !strcmp(attr->name, "auth-info-required") ||
+ !strncmp(attr->name, "marker-", 7) ||
+ !strcmp(attr->name, "printer-commands") ||
+ !strcmp(attr->name, "printer-is-shared")))
+ /* We are talking to a recent enough CUPS server that
+ * CUPS_GET_PRINTERS returns classes as well.
+ */
+ get_classes = 0;
+
if (!strcmp(attr->name, "auth-info-required") ||
!strcmp(attr->name, "device-uri") ||
!strcmp(attr->name, "marker-change-time") ||
@@ -1939,6 +1959,28 @@ cups_get_sdests(http_t *http, /* I
continue;
}
+ /*
+ * If we sent a CUPS_GET_CLASSES request, check whether
+ * CUPS_GET_PRINTERS already gave us this destination and exit
+ * early if so.
+ */
+
+ if (op == CUPS_GET_CLASSES)
+ {
+ int diff;
+ cups_find_dest (printer_name, NULL, num_dests, *dests, 0, &diff);
+ if (diff == 0)
+ {
+ /*
+ * Found it. The CUPS server already gave us the classes in
+ * its CUPS_GET_PRINTERS response.
+ */
+
+ cupsFreeOptions(num_options, options);
+ break;
+ }
+ }
+
if ((dest = cups_add_dest(printer_name, NULL, &num_dests, dests)) != NULL)
{
dest->num_options = num_options;
@@ -1955,6 +1997,16 @@ cups_get_sdests(http_t *http, /* I
}
/*
+ * If this is a CUPS_GET_PRINTERS request but we didn't see any
+ * classes we might be talking to an older CUPS server that requires
+ * CUPS_GET_CLASSES as well.
+ */
+
+ if (get_classes)
+ num_dests = cups_get_sdests (http, CUPS_GET_CLASSES, name,
+ num_dests, dests);
+
+ /*
* Return the count...
*/

View file

@ -0,0 +1,21 @@
diff -up cups-1.3.7/scheduler/ipp.c.driverd-timeout cups-1.3.7/scheduler/ipp.c
--- cups-1.3.7/scheduler/ipp.c.driverd-timeout 2008-07-15 13:40:51.000000000 +0100
+++ cups-1.3.7/scheduler/ipp.c 2008-07-15 13:40:51.000000000 +0100
@@ -4293,7 +4293,7 @@ copy_model(cupsd_client_t *con, /* I -
close(temppipe[1]);
/*
- * Wait up to 30 seconds for the PPD file to be copied...
+ * Wait up to 70 seconds for the PPD file to be copied...
*/
total = 0;
@@ -4315,7 +4315,7 @@ copy_model(cupsd_client_t *con, /* I -
FD_SET(temppipe[0], &input);
FD_SET(CGIPipes[0], &input);
- timeout.tv_sec = 30;
+ timeout.tv_sec = 70;
timeout.tv_usec = 0;
if ((i = select(maxfd, &input, NULL, NULL, &timeout)) < 0)

130
cups-eggcups.patch Normal file
View file

@ -0,0 +1,130 @@
diff -up cups-1.4b1/backend/ipp.c.eggcups cups-1.4b1/backend/ipp.c
--- cups-1.4b1/backend/ipp.c.eggcups 2008-10-15 19:27:45.000000000 +0100
+++ cups-1.4b1/backend/ipp.c 2008-11-11 15:43:30.000000000 +0000
@@ -51,6 +51,70 @@ static char pstmpname[1024] = ""; /* Tem
static char tmpfilename[1024] = ""; /* Temporary spool file name */
static int job_cancelled = 0; /* Job cancelled? */
+#if HAVE_DBUS
+#include <dbus/dbus.h>
+
+static DBusConnection *dbus_connection = NULL;
+
+static int
+init_dbus (void)
+{
+ DBusConnection *connection;
+ DBusError error;
+
+ if (dbus_connection &&
+ !dbus_connection_get_is_connected (dbus_connection)) {
+ dbus_connection_unref (dbus_connection);
+ dbus_connection = NULL;
+ }
+
+ dbus_error_init (&error);
+ connection = dbus_bus_get (getuid () ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ dbus_error_free (&error);
+ return -1;
+ }
+
+ dbus_connection = connection;
+ return 0;
+}
+
+int
+dbus_broadcast_queued_remote (const char *printer_uri,
+ ipp_status_t status,
+ unsigned int local_job_id,
+ unsigned int remote_job_id,
+ const char *username,
+ const char *printer_name)
+{
+ DBusMessage *message;
+ DBusMessageIter iter;
+ const char *errstr;
+
+ if (!dbus_connection || !dbus_connection_get_is_connected (dbus_connection)) {
+ if (init_dbus () || !dbus_connection)
+ return -1;
+ }
+
+ errstr = ippErrorString (status);
+ message = dbus_message_new_signal ("/com/redhat/PrinterSpooler",
+ "com.redhat.PrinterSpooler",
+ "JobQueuedRemote");
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_uri);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &errstr);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &local_job_id);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UINT32, &remote_job_id);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &username);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &printer_name);
+
+ dbus_connection_send (dbus_connection, message, NULL);
+ dbus_connection_flush (dbus_connection);
+ dbus_message_unref (message);
+
+ return 0;
+}
+#endif /* HAVE_DBUS */
/*
* Local functions...
@@ -1058,6 +1122,15 @@ main(int argc, /* I - Number of comm
job_id);
}
+#if HAVE_DBUS
+ dbus_broadcast_queued_remote (argv[0],
+ ipp_status,
+ atoi (argv[1]),
+ job_id,
+ argv[2],
+ getenv ("PRINTER"));
+#endif /* HAVE_DBUS */
+
ippDelete(response);
if (job_cancelled)
diff -up cups-1.4b1/backend/Makefile.eggcups cups-1.4b1/backend/Makefile
--- cups-1.4b1/backend/Makefile.eggcups 2008-10-06 22:08:27.000000000 +0100
+++ cups-1.4b1/backend/Makefile 2008-11-11 15:45:31.000000000 +0000
@@ -188,7 +188,7 @@ dnssd: dnssd.o ../cups/$(LIBCUPS) libbac
ipp: ipp.o ../cups/$(LIBCUPS) libbackend.a
echo Linking $@...
- $(CC) $(LDFLAGS) -o ipp ipp.o libbackend.a $(LIBS)
+ $(CC) $(LDFLAGS) -o ipp ipp.o libbackend.a $(LIBS) $(CUPSDLIBS)
$(RM) http
$(LN) ipp http
diff -up cups-1.4b1/scheduler/subscriptions.c.eggcups cups-1.4b1/scheduler/subscriptions.c
--- cups-1.4b1/scheduler/subscriptions.c.eggcups 2008-08-01 22:11:55.000000000 +0100
+++ cups-1.4b1/scheduler/subscriptions.c 2008-11-11 15:43:30.000000000 +0000
@@ -1302,13 +1302,13 @@ cupsd_send_dbus(cupsd_eventmask_t event,
what = "PrinterAdded";
else if (event & CUPSD_EVENT_PRINTER_DELETED)
what = "PrinterRemoved";
- else if (event & CUPSD_EVENT_PRINTER_CHANGED)
- what = "QueueChanged";
else if (event & CUPSD_EVENT_JOB_CREATED)
what = "JobQueuedLocal";
else if ((event & CUPSD_EVENT_JOB_STATE) && job &&
job->state_value == IPP_JOB_PROCESSING)
what = "JobStartedLocal";
+ else if (event & (CUPSD_EVENT_PRINTER_CHANGED|CUPSD_EVENT_JOB_STATE_CHANGED|CUPSD_EVENT_PRINTER_STATE_CHANGED))
+ what = "QueueChanged";
else
return;
@@ -1344,7 +1344,7 @@ cupsd_send_dbus(cupsd_eventmask_t event,
dbus_message_append_iter_init(message, &iter);
if (dest)
dbus_message_iter_append_string(&iter, dest->name);
- if (job)
+ if (job && strcmp (what, "QueueChanged") != 0)
{
dbus_message_iter_append_uint32(&iter, job->id);
dbus_message_iter_append_string(&iter, job->username);

63
cups-logrotate.patch Normal file
View file

@ -0,0 +1,63 @@
diff -up cups-1.3.5/scheduler/log.c.logrotate cups-1.3.5/scheduler/log.c
--- cups-1.3.5/scheduler/log.c.logrotate 2008-02-14 12:21:25.000000000 +0000
+++ cups-1.3.5/scheduler/log.c 2008-02-14 12:24:16.000000000 +0000
@@ -29,6 +29,9 @@
#include "cupsd.h"
#include <stdarg.h>
#include <syslog.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
/*
@@ -467,12 +470,10 @@ check_log_file(cups_file_t **lf, /* IO -
return (1);
/*
- * Format the filename as needed...
+ * Format the filename...
*/
- if (!*lf ||
- (strncmp(logname, "/dev/", 5) && cupsFileTell(*lf) > MaxLogSize &&
- MaxLogSize > 0))
+ if (strncmp(logname, "/dev/", 5))
{
/*
* Handle format strings...
@@ -565,6 +566,34 @@ check_log_file(cups_file_t **lf, /* IO -
}
/*
+ * Has someone else (i.e. logrotate) already rotated the log for us?
+ */
+ else if (strncmp(filename, "/dev/", 5))
+ {
+ struct stat st;
+ if (stat(filename, &st) || st.st_size == 0)
+ {
+ /* File is either missing or has zero size. */
+
+ cupsFileClose(*lf);
+ if ((*lf = cupsFileOpen(filename, "a")) == NULL)
+ {
+ syslog(LOG_ERR, "Unable to open log file \"%s\" - %s", filename,
+ strerror(errno));
+
+ return (0);
+ }
+
+ /*
+ * Change ownership and permissions of non-device logs...
+ */
+
+ fchown(cupsFileNumber(*lf), RunUser, Group);
+ fchmod(cupsFileNumber(*lf), LogFilePerm);
+ }
+ }
+
+ /*
* Do we need to rotate the log?
*/

56
cups-lpr-help.patch Normal file
View file

@ -0,0 +1,56 @@
diff -up cups-1.4b1/berkeley/lpr.c.lpr-help cups-1.4b1/berkeley/lpr.c
--- cups-1.4b1/berkeley/lpr.c.lpr-help 2008-07-11 23:46:21.000000000 +0100
+++ cups-1.4b1/berkeley/lpr.c 2008-11-11 16:20:32.000000000 +0000
@@ -30,6 +30,31 @@
#include <cups/i18n.h>
+static void
+usage (const char *name)
+{
+ _cupsLangPrintf(stdout,
+"Usage: %s [OPTION] [ file(s) ]\n"
+"Print files.\n\n"
+" -E force encryption\n"
+" -H server[:port] specify alternate server\n"
+" -C title, -J title, -T title\n"
+" set the job name\n\n"
+" -P destination/instance print to named printer\n"
+" -U username specify alternate username\n"
+" -# num-copies set number of copies\n"
+" -h disable banner printing\n"
+" -l print without filtering\n"
+" -m send email on completion\n"
+" -o option[=value] set a job option\n"
+" -p format text file with header\n"
+" -q hold job for printing\n"
+" -r delete files after printing\n"
+"\nWith no file given, read standard input.\n"
+, name);
+}
+
+
/*
* 'main()' - Parse options and send files for printing.
*/
@@ -54,7 +79,6 @@ main(int argc, /* I - Number of comm
int deletefile; /* Delete file after print? */
char buffer[8192]; /* Copy buffer */
-
_cupsSetLocale(argv);
deletefile = 0;
@@ -282,6 +306,12 @@ main(int argc, /* I - Number of comm
break;
default :
+ if (!strcmp (argv[i], "--help"))
+ {
+ usage (argv[0]);
+ return (0);
+ }
+
_cupsLangPrintf(stderr,
_("%s: Error - unknown option \'%c\'!\n"),
argv[0], argv[i][1]);

15
cups-multilib.patch Normal file
View file

@ -0,0 +1,15 @@
--- cups-1.2.3/cups-config.in.multilib 2006-08-03 01:54:38.000000000 +0100
+++ cups-1.2.3/cups-config.in 2006-08-30 15:47:35.000000000 +0100
@@ -30,8 +30,10 @@
exec_prefix=@exec_prefix@
bindir=@bindir@
includedir=@includedir@
-libdir=@libdir@
-imagelibdir=@libdir@
+# Fetch libdir from gnutls's pkg-config script. This is a bit
+# of a cheat, but the cups-devel package requires gnutls-devel anyway.
+libdir=`pkg-config --variable=libdir gnutls`
+imagelibdir=`pkg-config --variable=libdir gnutls`
datarootdir=@datadir@
datadir=@datadir@
sysconfdir=@sysconfdir@

View file

@ -0,0 +1,12 @@
diff -up cups-1.4b2-svn8404/config-scripts/cups-ssl.m4.no-export-ssllibs cups-1.4b2-svn8404/config-scripts/cups-ssl.m4
--- cups-1.4b2-svn8404/config-scripts/cups-ssl.m4.no-export-ssllibs 2009-02-17 17:45:27.000000000 +0000
+++ cups-1.4b2-svn8404/config-scripts/cups-ssl.m4 2009-03-05 11:12:59.000000000 +0000
@@ -110,7 +110,7 @@ fi
AC_SUBST(SSLFLAGS)
AC_SUBST(SSLLIBS)
-EXPORT_SSLLIBS="$SSLLIBS"
+EXPORT_SSLLIBS=""
AC_SUBST(EXPORT_SSLLIBS)

18
cups-no-gzip-man.patch Normal file
View file

@ -0,0 +1,18 @@
diff -up cups-1.4b2-svn8404/config-scripts/cups-manpages.m4.no-gzip-man cups-1.4b2-svn8404/config-scripts/cups-manpages.m4
--- cups-1.4b2-svn8404/config-scripts/cups-manpages.m4.no-gzip-man 2009-01-16 08:58:42.000000000 +0000
+++ cups-1.4b2-svn8404/config-scripts/cups-manpages.m4 2009-03-05 11:11:12.000000000 +0000
@@ -69,10 +69,10 @@ case "$uname" in
;;
Linux* | GNU* | Darwin*)
# Linux, GNU Hurd, and Mac OS X
- MAN1EXT=1.gz
- MAN5EXT=5.gz
- MAN7EXT=7.gz
- MAN8EXT=8.gz
+ MAN1EXT=1
+ MAN5EXT=5
+ MAN7EXT=7
+ MAN8EXT=8
MAN8DIR=8
;;
*)

36
cups-pid.patch Normal file
View file

@ -0,0 +1,36 @@
--- cups-1.1.21/scheduler/main.c.pid 2004-09-24 11:29:05.073748138 +0100
+++ cups-1.1.21/scheduler/main.c 2004-09-24 11:44:35.826446564 +0100
@@ -349,6 +349,8 @@
* Setup signal handlers for the parent...
*/
+ pid_t pid;
+
#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
sigset(SIGUSR1, parent_handler);
sigset(SIGCHLD, parent_handler);
@@ -372,7 +374,7 @@
signal(SIGHUP, SIG_IGN);
#endif /* HAVE_SIGSET */
- if (fork() > 0)
+ if ((pid = fork()) > 0)
{
/*
* OK, wait for the child to startup and send us SIGUSR1 or to crash
@@ -384,7 +386,15 @@
sleep(1);
if (parent_signal == SIGUSR1)
+ {
+ FILE *f = fopen ("/var/run/cupsd.pid", "w");
+ if (f)
+ {
+ fprintf (f, "%d\n", pid);
+ fclose (f);
+ }
return (0);
+ }
if (wait(&i) < 0)
{

12
cups-res_init.patch Normal file
View file

@ -0,0 +1,12 @@
diff -up cups-1.4b2-svn8404/cups/http-addrlist.c.res_init cups-1.4b2-svn8404/cups/http-addrlist.c
--- cups-1.4b2-svn8404/cups/http-addrlist.c.res_init 2009-03-23 17:41:03.000000000 +0000
+++ cups-1.4b2-svn8404/cups/http-addrlist.c 2009-03-23 17:41:26.000000000 +0000
@@ -373,7 +373,7 @@ httpAddrGetList(const char *hostname, /*
freeaddrinfo(results);
}
- else if (error == EAI_FAIL)
+ else if (error == EAI_FAIL || error == EAI_AGAIN)
cg->need_res_init = 1;
#else

192
cups-serverbin-compat.patch Normal file
View file

@ -0,0 +1,192 @@
diff -up cups-1.4rc1/scheduler/conf.c.serverbin-compat cups-1.4rc1/scheduler/conf.c
--- cups-1.4rc1/scheduler/conf.c.serverbin-compat 2009-05-26 16:41:04.000000000 +0100
+++ cups-1.4rc1/scheduler/conf.c 2009-06-17 11:03:24.286442640 +0100
@@ -490,6 +490,9 @@ cupsdReadConfiguration(void)
cupsdClearString(&ServerName);
cupsdClearString(&ServerAdmin);
cupsdSetString(&ServerBin, CUPS_SERVERBIN);
+#ifdef __x86_64__
+ cupsdSetString(&ServerBin_compat, "/usr/lib64/cups");
+#endif /* __x86_64__ */
cupsdSetString(&RequestRoot, CUPS_REQUESTS);
cupsdSetString(&CacheDir, CUPS_CACHEDIR);
cupsdSetString(&DataDir, CUPS_DATADIR);
@@ -1320,7 +1323,12 @@ cupsdReadConfiguration(void)
* Read the MIME type and conversion database...
*/
+#ifdef __x86_64__
+ snprintf(temp, sizeof(temp), "%s/filter:%s/filter", ServerBin,
+ ServerBin_compat);
+#else
snprintf(temp, sizeof(temp), "%s/filter", ServerBin);
+#endif
snprintf(mimedir, sizeof(mimedir), "%s/mime", DataDir);
MimeDatabase = mimeLoadTypes(NULL, mimedir);
diff -up cups-1.4rc1/scheduler/conf.h.serverbin-compat cups-1.4rc1/scheduler/conf.h
--- cups-1.4rc1/scheduler/conf.h.serverbin-compat 2009-05-11 23:46:01.000000000 +0100
+++ cups-1.4rc1/scheduler/conf.h 2009-06-17 11:03:24.287442308 +0100
@@ -106,6 +106,10 @@ VAR char *ConfigurationFile VALUE(NULL)
/* Root directory for scheduler */
*ServerBin VALUE(NULL),
/* Root directory for binaries */
+#ifdef __x86_64__
+ *ServerBin_compat VALUE(NULL),
+ /* Compat directory for binaries */
+#endif /* __x86_64__ */
*StateDir VALUE(NULL),
/* Root directory for state data */
*RequestRoot VALUE(NULL),
diff -up cups-1.4rc1/scheduler/env.c.serverbin-compat cups-1.4rc1/scheduler/env.c
--- cups-1.4rc1/scheduler/env.c.serverbin-compat 2008-06-18 23:31:26.000000000 +0100
+++ cups-1.4rc1/scheduler/env.c 2009-06-17 11:03:24.288442597 +0100
@@ -86,8 +86,13 @@ cupsdInitEnv(void)
cupsdSetEnv("LD_LIBRARY_PATH", NULL);
cupsdSetEnv("LD_PRELOAD", NULL);
cupsdSetEnv("NLSPATH", NULL);
+#ifdef __x86_64__
+ cupsdSetEnvf("PATH", "%s/filter:%s/filter:" CUPS_BINDIR ":" CUPS_SBINDIR
+ ":/bin:/usr/bin", ServerBin, ServerBin_compat);
+#else /* ! defined(__x86_64__) */
cupsdSetEnvf("PATH", "%s/filter:" CUPS_BINDIR ":" CUPS_SBINDIR
":/bin:/usr/bin", ServerBin);
+#endif
cupsdSetEnv("SERVER_ADMIN", ServerAdmin);
cupsdSetEnv("SHLIB_PATH", NULL);
cupsdSetEnv("SOFTWARE", CUPS_MINIMAL);
diff -up cups-1.4rc1/scheduler/ipp.c.serverbin-compat cups-1.4rc1/scheduler/ipp.c
--- cups-1.4rc1/scheduler/ipp.c.serverbin-compat 2009-05-26 23:01:23.000000000 +0100
+++ cups-1.4rc1/scheduler/ipp.c 2009-06-17 11:03:24.295443078 +0100
@@ -2539,9 +2539,18 @@ add_printer(cupsd_client_t *con, /* I -
* Could not find device in list!
*/
+#ifdef __x86_64__
+ snprintf(srcfile, sizeof(srcfile), "%s/backend/%s", ServerBin_compat,
+ scheme);
+ if (access(srcfile, X_OK))
+ {
+#endif /* __x86_64__ */
send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad device-uri scheme \"%s\"!"),
scheme);
return;
+#ifdef __x86_64__
+ }
+#endif /* __x86_64__ */
}
}
diff -up cups-1.4rc1/scheduler/job.c.serverbin-compat cups-1.4rc1/scheduler/job.c
--- cups-1.4rc1/scheduler/job.c.serverbin-compat 2009-05-11 23:46:01.000000000 +0100
+++ cups-1.4rc1/scheduler/job.c 2009-06-17 11:03:24.305442437 +0100
@@ -972,8 +972,32 @@ cupsdContinueJob(cupsd_job_t *job) /* I
i ++, filter = (mime_filter_t *)cupsArrayNext(filters))
{
if (filter->filter[0] != '/')
- snprintf(command, sizeof(command), "%s/filter/%s", ServerBin,
- filter->filter);
+ {
+ snprintf(command, sizeof(command), "%s/filter/%s", ServerBin,
+ filter->filter);
+#ifdef __x86_64__
+ if (access(command, F_OK))
+ {
+ snprintf(command, sizeof(command), "%s/filter/%s",
+ ServerBin_compat, filter->filter);
+ if (!access(command, F_OK))
+ {
+ /* Not in the correct directory, but found it in the compat
+ * directory. Issue a warning. */
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Filter '%s' not in %s/filter!",
+ filter->filter, ServerBin);
+ }
+ else
+ {
+ /* Not in the compat directory either; make any error
+ * messages use the correct directory name then. */
+ snprintf(command, sizeof(command), "%s/filter/%s", ServerBin,
+ filter->filter);
+ }
+ }
+#endif /* __x86_64__ */
+ }
else
strlcpy(command, filter->filter, sizeof(command));
@@ -1119,6 +1143,28 @@ cupsdContinueJob(cupsd_job_t *job) /* I
cupsdClosePipe(job->print_pipes);
cupsdClosePipe(job->back_pipes);
cupsdClosePipe(job->side_pipes);
+#ifdef __x86_64__
+ if (access(command, F_OK))
+ {
+ snprintf(command, sizeof(command), "%s/backend/%s", ServerBin_compat,
+ method);
+ if (!access(command, F_OK))
+ {
+ /* Not in the correct directory, but we found it in the compat
+ * directory. Issue a warning. */
+ cupsdLogMessage(CUPSD_LOG_INFO,
+ "Backend '%s' not in %s/backend!", method,
+ ServerBin);
+ }
+ else
+ {
+ /* Not in the compat directory either; make any error
+ messages use the correct directory name then. */
+ snprintf(command, sizeof(command), "%s/backend/%s", ServerBin,
+ method);
+ }
+ }
+#endif /* __x86_64__ */
close(job->status_pipes[1]);
job->status_pipes[1] = -1;
diff -up cups-1.4rc1/scheduler/printers.c.serverbin-compat cups-1.4rc1/scheduler/printers.c
--- cups-1.4rc1/scheduler/printers.c.serverbin-compat 2009-05-16 22:49:57.000000000 +0100
+++ cups-1.4rc1/scheduler/printers.c 2009-06-17 11:08:13.888317742 +0100
@@ -1015,9 +1015,19 @@ cupsdLoadAllPrinters(void)
* Backend does not exist, stop printer...
*/
+#ifdef __x86_64__
+ snprintf(line, sizeof(line), "%s/backend/%s", ServerBin_compat,
+ p->device_uri);
+ if (access(line, 0))
+ {
+#endif /* __x86_64__ */
+
p->state = IPP_PRINTER_STOPPED;
snprintf(p->state_message, sizeof(p->state_message),
"Backend %s does not exist!", line);
+#ifdef __x86_64__
+ }
+#endif /* __x86_64__ */
}
}
@@ -3549,6 +3559,12 @@ add_printer_filter(
if (stat(filename, &fileinfo))
{
+#ifdef __x86_64__
+ snprintf(filename, sizeof(filename), "%s/filter/%s", ServerBin_compat,
+ program);
+ if (stat(filename, &fileinfo))
+ {
+#endif /* __x86_64__ */
memset(&fileinfo, 0, sizeof(fileinfo));
snprintf(p->state_message, sizeof(p->state_message),
@@ -3557,6 +3573,9 @@ add_printer_filter(
cupsdSetPrinterReasons(p, "+cups-missing-filter-warning");
cupsdLogMessage(CUPSD_LOG_ERROR, "%s", p->state_message);
+#ifdef __x86_64__
+ }
+#endif /* __x86_64__ */
}
/*

5
cups.logrotate Normal file
View file

@ -0,0 +1,5 @@
/var/log/cups/*_log {
missingok
notifempty
sharedscripts
}

14
cups.service Normal file
View file

@ -0,0 +1,14 @@
[Unit]
Description=CUPS printing server daemon
After=syslog.target oki4daemon.service
Requires=network.target
[Service]
Type=forking
EnvironmentFile=-/etc/sysconfig/cups
ExecStartPre=/sbin/portrelease cups
ExecStart=/usr/sbin/cupsd
[Install]
WantedBy=multi-user.target

1849
cups.spec Normal file

File diff suppressed because it is too large Load diff

200
cups.startup Normal file
View file

@ -0,0 +1,200 @@
#!/bin/bash
# Init file for the CUPS server daemon
#
# chkconfig: 2345 15 60
# description: The Common UNIX Printing System (CUPS), an \
# advanced printer spooling system which \
# allows setting of printer options and \
# automatic availability of a printer \
# configured on one server in the whole \
# network. Default printing system of Mandriva \
# Linux.
#
# processname: cupsd
# config: /etc/cups/cupsd.conf
# config: /etc/cups/client.conf
# config: /etc/cups/classes.conf
# config: /etc/cups/printers.conf
# config: /etc/cups/mime.types
# config: /etc/cups/mime.convs
# config: /etc/cups/ppds.dat
#
### BEGIN INIT INFO
# Provides: cups
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Short-Description: CUPS printing server daemon
# Description: The Common UNIX Printing System (CUPS), an
# advanced printer spooling system which
# allows setting of printer options and
# automatic availability of a printer
# configured on one server in the whole
# network. Default printing system of Mandriva
# Linux.
### END INIT INFO
# source function library
. /etc/rc.d/init.d/functions
# default printing auto admin settings
ENABLE_QUEUES_ON_SPOOLER_START=no
# source printing auto admin configuration
if [ -r /etc/sysconfig/printing ]; then
. /etc/sysconfig/printing
fi
# Source an auxiliary options file if we have one, and pick up OPTIONS
# CUPS can now play nice (use NICELEVEL=<number> in /etc/sysconfig/cups)
if [ -r /etc/sysconfig/cups ] ; then
. /etc/sysconfig/cups
fi
# Don't use TMPDIR environment variable from init script, as that can
# cause cupsd to set TempDir to a user's temporary directory instead
# of the default...
#
unset TMPDIR
RETVAL=0
case "$1" in
start)
# Turn off the CUPS-LPD mini-daemon when LPD is running
if [ -x /etc/rc.d/init.d/lpd ]; then
if (export LC_ALL=C; /sbin/service lpd status | /bin/egrep "running" > /dev/null 2>&1); then
if (export LC_ALL=C; /sbin/chkconfig --list cups-lpd | /bin/egrep "on$" > /dev/null 2>&1); then
echo "Turning off CUPS-LPD mini daemon ..."
/sbin/chkconfig --del cups-lpd
if [ -x /usr/sbin/xinetd ]; then
/sbin/service xinetd condrestart
fi
fi
fi
fi
# Check whether a parallel printer is configured and if
# so, but if the parallel printer kernel module not being
# loaded, load the module.
if (/bin/egrep "^[^#]*/dev/lp" /etc/cups/printers.conf > /dev/null 2>&1); then
if (! (export LC_ALL=C; /sbin/lsmod | /bin/egrep "^lp +" > /dev/null 2>&1) || \
! (export LC_ALL=C; /sbin/lsmod | /bin/egrep "^parport_pc +" > /dev/null 2>&1)); then
echo "Loading parallel port printer kernel modules ..."
modprobe parport_pc > /dev/null 2>&1;
RET=$?
if [ $RET -eq 0 ]; then
modprobe lp > /dev/null 2>&1;
RET=$?
fi
if [ $RET -ne 0 ]; then
echo
echo "WARNING: Parallel printer kernel modules could not be loaded, your parallel"
echo " printer may not work."
echo
fi
fi
fi
# Check whether an OKI winprinter is configured with and if so,
# but if the oki4daemon not being running, start the oki4daemon.
if (/bin/egrep "^[^#]*/dev/oki4drv" /etc/cups/printers.conf > /dev/null 2>&1); then
if ! (/bin/ps auxwww | /bin/grep -v "grep" | /bin/grep "oki4daemon" > /dev/null 2>&1); then
echo "Starting oki4daemon ..."
chkconfig --add oki4daemon
/sbin/service oki4daemon start
fi
fi
# Do automatic correction of CUPS configuration to avoid
# /etc/printcap from LPD/LPRng being overwritten and also
# to avoid printer info with hostname "localhost" being
# broadcasted. Can be turned off in printerdrake
if [ -x /usr/sbin/correctcupsconfig ]; then
/usr/sbin/correctcupsconfig
fi
echo -n "Starting CUPS printing system: "
portrelease cups
daemon cupsd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/cups
# CUPS daemon must be listening for the following steps
if (ps auxwww | grep cupsd | grep -v grep > /dev/null 2>&1); then
if ! (lpstat -r > /dev/null 2>&1); then
echo -en "Waiting for the CUPS daemon getting ready"
for ((i=0; i < 30; i ++)); do
if (lpstat -r > /dev/null 2>&1); then
break;
fi;
sleep 1;
echo -en ".";
done;
echo ""
fi
if ! (lpstat -r > /dev/null 2>&1); then
echo "WARNING: CUPS daemon still not listening after 30 sec, aborting auto-admin tasks."
exit $RETVAL
fi;
fi
if [ "$ENABLE_QUEUES_ON_SPOOLER_START" == "yes" ]; then
# Re-enable disabled print queues
gprintf "Re-enabling disabled print queues:\n"
for printer in `lpstat -p | grep disabled | cut -d ' ' -f 2`; do
if cat /etc/cups/printers.conf | egrep -q "<(Default|)Printer $printer>"; then
#if (( ! `lpstat -p $printer | grep -c Paused` )); then
gprintf " Printer: $printer\n";
/usr/bin/enable $printer
#fi
fi
done
fi
if [ $RETVAL = 0 ]; then
echo_success
echo
else
echo_failure
echo
fi
;;
stop)
echo -n "Stopping CUPS printing system: "
killproc cupsd
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/cups
;;
restart)
$0 stop
$0 start
RETVAL=$?
;;
status)
status cupsd
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/cups ]; then
$0 stop
$0 start
RETVAL=$?
fi
;;
reload)
echo -n "Reinitializing CUPS printing system: "
killproc cupsd -HUP
RETVAL=$?
echo
;;
*)
echo "Usage: cups {start|stop|restart|reload|status|condrestart}"
exit 1
esac
exit $RETVAL

2
cups.sysconfig Normal file
View file

@ -0,0 +1,2 @@
# nice level for cupsd
NICELEVEL=0

362
lphelp.c Normal file
View file

@ -0,0 +1,362 @@
/*
*
* lphelp
* ------
#
# A simple tool for getting information about an installed printer or a
# PPD file. Especially the printer-specific options defined in the PPD
# file are listed, so that one can make use of them with the "lp", "lpr",
# and "lpoptions" commands. The programm can also be used by installation/
# configuration scripts to give a "preview" to a PPD file.
#
# ONLY WORKS WITH CUPS DAEMON RUNNING!
# The CUPS library (libcups.so.*) must be installed!
#
# Compile with: gcc -olphelp -lcups lphelp.c
#
* Copyright 2000 by Till Kamppeter
*
* 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 necessary headers...
*/
#include <cups/cups.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
/*
* 'main()' - Main entry for test program.
*/
int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
int i, j, k, m; /* Looping vars */
const char *filename; /* File to load */
FILE *ppdfile;
// Temporary file name (for reading from stdin)
char tmpfile[19] = "/tmp/lphelp.XXXXXX";
const int blocksize = 1024;
char buffer[blocksize];
int bytesread;
// variables for parsing PPD file for usual options (boolean, enumerated)
ppd_file_t *ppd; /* PPD file record */
ppd_size_t *size; /* Size record */
ppd_group_t *group; /* UI group */
ppd_option_t *option; /* Standard UI option */
ppd_choice_t *choice; /* Standard UI option choice */
static char *uis[] = { "BOOLEAN", "PICKONE", "PICKMANY" };
static char *sections[] = { "ANY", "DOCUMENT", "EXIT",
"JCL", "PAGE", "PROLOG" };
// variables for parsing CUPS-O-MATIC info for numerical options (float, int)
char line[1024], /* buffer for reading PPD file line by
line to search numerical options */
item[1024], /* item to be defined (left of "=>") */
value[1024], /* value for item (right of "=>") */
argname[1024], /* name of the current argument */
comment[1024]; /* human-readable argument name */
const char *line_contents; /* contents of line */
const char *scan; /* pointer scanning the line */
char *writepointer;
double min, max, defvalue; /* Range of numerical
CUPS-O-MATIC option */
int opttype; /* 0 = other, 1 = int, 2 = float */
int openbrackets; /* How many curled brackets are open? */
int inquotes; /* are we in quotes now? */
int inargspart; /* are we in the arguments part now? */
/*
* Display PPD files for each file listed on the command-line...
*/
if (argc == 1) {
fputs("Usage: lphelp <filename1>.ppd [<filename2>.ppd ...]\n lphelp <printername1> [<printername2> ...]\n lphelp -\n", stderr);
return (1);
}
for (i = 1; i < argc; i ++) {
if ((strstr(argv[i], ".ppd")) || (strstr(argv[i], "-")))
filename = argv[i];
else
filename = cupsGetPPD(argv[i]);
if (strcmp(filename,"-") == 0) {
if ((ppdfile = fdopen(mkstemp(tmpfile), "w")) == NULL) {
fprintf(stderr, "Unable to generate temporary file!\n");
}
while ((bytesread = fread(buffer, 1, blocksize, stdin)) > 0) {
fwrite(buffer, 1, bytesread, ppdfile);
}
fclose(ppdfile);
filename = tmpfile;
}
if ((ppd = ppdOpenFile(filename)) == NULL) {
fprintf(stderr, "Unable to open \'%s\' as a PPD file!\n", filename);
continue;
}
printf("==============================================================================\n\n");
printf("%s\n\n", ppd->modelname);
printf("==============================================================================\n\n");
printf(" %s printer\n\n", ppd->color_device ? "Colour" : "Black & white");
printf(" Printer-specific options\n");
printf(" ------------------------\n\n");
printf(" Besides the options described in the CUPS software users manual\n");
printf(" (http://localhost:631/sum.html) you can use also the following options\n");
printf(" when you print on this printer with the \"lp\" or \"lpr\" command (a choice\n");
printf(" with the \"default\" mark represents the behaviour of the printer when the\n");
printf(" appropriate option is not given on the command line):\n\n");
for (j = 0, group = ppd->groups; j < ppd->num_groups; j ++, group ++) {
for (k = 0, option = group->options; k < group->num_options;
k ++, option ++) {
if (strcmp(option->keyword, "PageRegion") != 0) {
if ((strcmp(uis[option->ui],"BOOLEAN") == 0) ||
(strcmp(uis[option->ui],"PICKONE") == 0)) {
printf(" %s: -o %s=<choice>\n\n",
option->text, option->keyword);
printf(" <choice> can be one of the following:\n\n");
} else {
printf(" %s: -o %s=<choice1>,<choice2>,...\n\n",
option->text, option->keyword);
printf(" <choice1>, <choice2>, and so on can be out of the following:\n\n");
}
if (strcmp(option->keyword, "PageSize") == 0) {
for (m = option->num_choices, choice = option->choices;
m > 0;
m --, choice ++) {
size = ppdPageSize(ppd, choice->choice);
if (size == NULL)
printf(" %s (%s, size unknown", choice->choice, choice->text);
else
printf(" %s (%s, size: %.2fx%.2fin", choice->choice,
choice->text, size->width / 72.0, size->length / 72.0);
if (strcmp(option->defchoice, choice->choice) == 0)
puts(", default)");
else
puts(")");
}
} else {
for (m = option->num_choices, choice = option->choices;
m > 0;
m --, choice ++) {
printf(" %s (%s", choice->choice, choice->text);
if (strcmp(option->defchoice, choice->choice) == 0)
puts(", default)");
else
puts(")");
}
}
printf("\n");
}
}
}
ppdClose(ppd);
// Search for numerical options of CUPS-O-MATIC
if ((ppdfile = fopen(filename,"r")) == NULL) {
fprintf(stderr, "Unable to open \'%s\' as a PPD file!\n", filename);
continue;
}
// Reset all variables
opttype = 0;
min = 0.0; max = 0.0; defvalue = 0.0;
openbrackets = 0;
inquotes = 0;
writepointer = item;
inargspart = 0;
// Read the PPD file again, line by line.
while (fgets(line,sizeof(line),ppdfile)) {
// evaluate only lines with CUPS-O-MATIC info
if (line_contents = strstr(line,"*% COMDATA #")) {
line_contents += 12; // Go to the text after
// "*% COMDATA #"
for (scan = line_contents;
(*scan != '\n') && (*scan != '\0');
scan ++) {
switch(*scan) {
case '[': // open square bracket
case '{': // open curled bracket
if (!inquotes) {
openbrackets ++;
// we are on the left hand side now
*writepointer = '\0';
writepointer = item;
// in which type of block are we now?
if ((openbrackets == 2) &&
(strncasecmp(item,"args",4) == 0)) {
// we are entering the arguments section now
inargspart = 1;
}
if ((openbrackets == 3) &&
(inargspart == 1)) {
// new argument, get its name
strcpy(argname,item);
}
// item already evaluated now
item[0] = '\0';
} else {*writepointer = *scan; writepointer ++;}
break;
case ',': // end of logical line
case ']': // close square bracket
case '}': // close curled bracket
if (!inquotes) {
// right hand side completed, go to left hand side
*writepointer = '\0';
writepointer = item;
// evaluate logical line
if (item[0]) {
// Machine-readable argument name
if ((openbrackets == 3) &&
(inargspart == 1) &&
(strcasecmp(item,"name") == 0)) {
strcpy(argname,value);
}
// Human-readable argument name
if ((openbrackets == 3) &&
(inargspart == 1) &&
(strcasecmp(item,"comment") == 0)) {
strcpy(comment,value);
}
// argument type
if ((openbrackets == 3) &&
(inargspart == 1) &&
(strcasecmp(item,"type") == 0)) {
if (strcasecmp(value,"int") == 0) opttype = 1;
if (strcasecmp(value,"float") == 0) opttype = 2;
}
// minimum value
if ((openbrackets == 3) &&
(inargspart == 1) &&
(strcasecmp(item,"min") == 0)) {
min = atof(value);
}
// maximum value
if ((openbrackets == 3) &&
(inargspart == 1) &&
(strcasecmp(item,"max") == 0)) {
max = atof(value);
}
// default value
if ((openbrackets == 3) &&
(inargspart == 1) &&
(strcasecmp(item,"default") == 0)) {
defvalue = atof(value);
}
// item already evaluated now
item[0] = '\0';
}
// close bracket
if ((*scan == '}') || (*scan == ']')) {
// which block did we complete now?
if ((openbrackets == 2) &&
(inargspart == 1)) {
// We are leaving the arguments part now
inargspart = 0;
}
if ((openbrackets == 3) &&
(inargspart == 1)) {
// The current option is completely parsed
// Is the option a valid numerical option?
if ((opttype > 0) &&
(min != max) &&
(argname[0])) {
// Correct the default value, if necessary
if (min < max) {
if (defvalue < min) defvalue = min;
if (defvalue > max) defvalue = max;
} else {
if (defvalue < max) defvalue = max;
if (defvalue > min) defvalue = min;
}
// Show the found argument
printf(" %s: -o %s=<value>\n\n",
comment, argname);
if (opttype == 1) {
printf(
" <value> must be an integer number in the range %d..%d\n",
(int)(min),(int)(max));
printf(
" The default value is %d\n\n",
(int)(defvalue));
} else {
printf(
" <value> must be a decimal number in the range %.2f..%.2f\n",
min,max);
printf(
" The default value is %.2f\n\n",
defvalue);
}
}
// reset the values
argname[0] = '\0';
opttype = 0;
min = 0.0; max = 0.0; defvalue = 0.0;
}
openbrackets --;
}
} else {*writepointer = *scan; writepointer ++;}
break;
case '\'': // quote
if (!inquotes) { // open quote pair
inquotes = 1;
} else { // close quote pair
inquotes = 0;
}
break;
case '=': // "=>"
if ((!inquotes) && (*(scan + 1) == '>')) {
scan ++;
// left hand side completed, go to right hand side
*writepointer = '\0';
writepointer = value;
} else {*writepointer = *scan; writepointer ++;}
break;
case ' ': // white space
case '\t':
if (!inquotes) {
// ignore white space outside quotes
} else {*writepointer = *scan; writepointer ++;}
break;
default:
// write all other characters
*writepointer = *scan; writepointer ++;
break;
}
}
inquotes = 0; // quote pairs cannot enclose more
// than one line
}
}
fclose(ppdfile);
printf("\n\n\n");
}
if (!(strstr(tmpfile, "XXXXXX"))) {
unlink(tmpfile);
}
return (0);
}

125
nprint.2002011801 Normal file
View file

@ -0,0 +1,125 @@
#!/bin/bash
VERSION=2002011801
### NPRINT CUPS backend
### Copyright (C) 2001 Mark J. Horn <mark at hornclan dot 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.
###
### A copy of the GNU General Public License is available at:
### http://www.gnu.org/licenses/gpl.txt
### INSTALLATION
### ------------
### To use this script, copy it into your CUPS backends directory, which
### might be in /usr/lib/cups/backends or /usr/local/lib/cups/backends.
### Make sure that the script is executable by whatever id cupsd runs
### with, and then restart CUPS.
###
### In order for CUPS to detect your novell printers at boot time you
### will have to have correctly configured ipx in your kernel, and CUPS
### must start *after* your network interface card is up.
###
### As root, you must be able run "pqlist" and get a list of the
### printers on your server. The "pqlist" program uses ~root/.nwclient
### as a mechinism for determining the default novell server to use.
### This file must be properly configured in order for this backend to
### detect and use novell printers. Currently this script will only
### enable printing to print queue's on a single server. If anyone
### has any ideas on how to support more than one server, please let
### me know.
###
### You should then be able to configure printers in CUPS with the
### devices you've configured. I have only been able to configure
### devices with the CUPS web interface.
###
### This single script can be used to support multiple devices. However,
### at this point it can only support access to one print server.
### This is due to the inability of pqlist to enumerate more than a
### single server's printers at a time. If anyone has any ideas on how
### I might make printing to multiple servers function, I'd be glad to
### hear them.
###
### DEPENDANCIES
### ------------
### This script is dependant upon builtin commands in bash. It has not
### been tested against other non-bash shells. I don't expect that
### it will work with them. You are invited to test other shells.
### Please let me know if you have any success.
###
### This script depends on correctly installed ncpfs software
### available at: ftp://platan.vc.cvut.cz/pub/linux/ncpfs/
###
### This script depends on the following programs being in the PATH
### pqlist, nprint, basename, cat
### If these commands are not in /bin, /usr/bin, or /usr/local/bin on
### your computer, set PATH below to include where they are located.
PATH=$PATH:/bin:/usr/bin:/usr/local/bin
### Set root's home directory here:
#HOME=/root
HOME=~root
export HOME
### Uncomment for crude debugging output
#DEBUG=true
if [ ! -z "$DEBUG" ]; then
echo "Args: $0 $*" > /tmp/printargs
echo "Arg1: $1" >> /tmp/printargs
echo "Arg2: $2" >> /tmp/printargs
echo "Arg2: $3" >> /tmp/printargs
echo "Arg2: $4" >> /tmp/printargs
echo "Arg2: $5" >> /tmp/printargs
echo "Arg2: $6" >> /tmp/printargs
echo "Arg2: $7" >> /tmp/printargs
command -V pqlist >> /tmp/printargs 2>&1
command -V nprint >> /tmp/printargs 2>&1
command -V basename >> /tmp/printargs 2>&1
command -V cat >> /tmp/printargs 2>&1
declare -p >> /tmp/printargs
echo "pqlist\n------" >> /tmp/printargs
pqlist >> /tmp/printargs
fi
ME=`basename $0`
if [ -z "$*" ]; then
pqlist | while read printq qid; do
echo network $ME:/$printq \"$printq\" \"NPRINT $printq\"
done
exit 0
fi
### For raw printing, $6 is the file to print. For driver processed
### printing, $6 is empty and the data to print is in stdin.
FILE=$6
### When advertising multiple printers, the script has to be able
### determine where it should send real print jobs. This is done
### through the environment variable $DEVICE_URI
SENDTO=${DEVICE_URI#${ME}:/}
if [ ! -z "$DEBUG" ]; then
echo "SENDTO: $SENDTO" >> /tmp/printargs
cat $6 > /tmp/printout
cat /tmp/printout | nprint -q $SENDTO -
else
cat $FILE | nprint -q $SENDTO -
fi

79
pdfdistiller Normal file
View file

@ -0,0 +1,79 @@
#!/bin/sh
#
# This script is intended to be used as a CUPS backend, to create
# PDF file on-the-fly. Just create a printer using the device uri
# pdf:/path/to/dir/. When printing to this printer, a PDF file
# will be generated in the directory specified. The file name will
# be either "<jobname>.pdf" or "unknown.pdf", depending wether the
# jobname is empty or not.
#
# To use it, simply copy this script to your backend directory, and
# create a printer with the correct URI. That's it.
#
# Copyright (C) Michael Goffioul (goffioul@imec.be) 2001
LOGFILE=/dev/null
PDFBIN=`which ps2pdf`
FILENAME=
# this is borrowed from printpdf script for the filename
PRINTTIME=`date +%b%d-%H%M%S`
echo "Executable: $PDFBIN" > $LOGFILE
echo "Arguments: |$1|$2|$3|$4|$5|$6|" >> $LOGFILE
echo $# $PRINTTIME >> $LOGFILE
# case of no argument, prints available URIs
if [ $# -eq 0 ]; then
if [ ! -x "$PDFBIN" ]; then
exit 0
fi
echo "direct pdf \"Unknown\" \"PDF Writing\""
exit 0
fi
# case of wrong number of arguments
if [ $# -ne 5 -a $# -ne 6 ]; then
echo "Usage: pdf job-id user title copies options [file]"
exit 1
fi
# get PDF directory from device URI, and check write status
PDFDIR=${DEVICE_URI#pdf:}
if [ ! -d "$PDFDIR" -o ! -w "$PDFDIR" ]; then
echo "ERROR: directory $PDFDIR not writable"
exit 1
fi
echo "PDF directory: $PDFDIR" >> $LOGFILE
# generate output filename
OUTPUTFILENAME=
if [ "$3" = "" ]; then
OUTPUTFILENAME="$PDFDIR/unknown.pdf"
else
# OUTPUTFILENAME="$PDFDIR/${3//[^[:alnum:]]/_}.pdf"
# I changed this to user name, and the printtime to track down who
# printed the PDF and when, samba printing just uses nobody
OUTPUTFILENAME="$PDFDIR/$2-$PRINTTIME.pdf"
echo "PDF file: $OUTPUTFILENAME placed in: $PDFDIR" >> $LOGFILE
fi
echo "Output file name: $OUTPUTFILENAME" >> $LOGFILE
# run ghostscript
if [ $# -eq 6 ]; then
$PDFBIN $6 "$OUTPUTFILENAME"
#>& /dev/null
else
$PDFBIN - "$OUTPUTFILENAME" >& /dev/null
fi
# modify ownership and permissions on the file
# - world readable
# - owns to user specified in argument
chmod a+r "$OUTPUTFILENAME"
if [ "$2" != "" ]; then
chown $2 "$OUTPUTFILENAME"
fi
exit 0

136
photo_print Normal file
View file

@ -0,0 +1,136 @@
#!/bin/bash
#set -x
#
# Photo Print
# -----------
#
# Till Kamppeter (http://www.linuxprinting.org/till/)
#
# Derived from a script from Max Barel (max dot barel at wanadoo dot fr)
#
# License: GPL (www.gnu.org)
#
#
# Script for printing several photos/image files on on sheet of paper.
#
# For example for printing 4 postcard-sized photos on one A4/Letter sheet
# (1 A4/Letter sheet of photo paper is much cheaper than 4 postcard-sized
# sheets, and 1 A4/Letter image is printed faster than 4 postcards).
#
# Reqirements:
#
# CUPS printing system (www.cups.org)
# ImageMagick (www.imagemagick.org)
#
# Installation:
#
# Copy this file into the /usr/bin or /usr/local/bin directory and make it
# executable with the command "chmod a+rx photo_print".
#
# This script mounts photos together to one big image using the "montage"
# command of ImageMagick without scaling the images to avoid quality loss.
# It sends the resulting image to the printer and lets the image file filter
# of CUPS scale the image to fit into the page. By default, 4 images are
# printed on one sheet, but the number can be changed with the "-t" option.
# On the command line can be given any number of photos, if necessary more
# than one page is printed. So one can easily print all the photos from one
# directory with one command line:
#
# photo_print -P Epson1290 *.jpg
#
#
#
# Command line parameters and their defaults:
#
# "-t XxY": Matrix size (Number of columns x number of rows)
tile=2x2
#
# "-s n": Scaling (100 % fills the sheet exactly)
# If parts of the edges of the images get lost due to unprintable borders,
# use a scaling value lower than 100 to shrink the image to fit the printable
# area. With an HP DeskJet 990C you get the best result with a value of 95 when
# using A4 paper and 90 when using Letter paper assuming the width/height ratio
# of the images being 4:3.
scaling=100
#
# "-p": Preview: when this option is given, from every page a preview is shown
# and the user is asked on the console whether he wants to print the page.
preview=0
#
# "-P xxx": Printer on which the photos should be printed (leave blank to use
# the default printer)
printer=""
#
# "-o option=value": Driver options ("-o option=value") to give on the command
# line of the "lpr" command of CUPS
options=""
#
#Get parameters from above from the command line
moreoptions=1;
while [ $moreoptions == 1 ]
do
case $1 in
-t)
shift
tile=$1
shift
;;
-s)
shift
scaling=$1
shift
;;
-p)
shift
preview=1
;;
-o)
shift
options="$options -o $1"
shift
;;
-P)
shift
printer="-P $1"
shift
;;
-h)
echo "Usage: $0 -P printer -s Scaling -t COLUMNSxROWS -o option=value ... file1 file2 ..."
exit 0
;;
* )
moreoptions=0;
;;
esac
done
l=$(echo $tile |cut -f1 -dx);
L=$(echo $tile |cut -f2 -dx);
nbfich=$[ $l * $L ]
freespaces=0
page=1
while [ "$#" -gt 0 ]
do
if [ "$nbfich" -gt "$#" ]; then
freespaces=$[ $nbfich - $# ]
nbfich="$#"
fi
images=$( echo $* | cut -f1-$nbfich -d " " )
shift $nbfich
while [ "$freespaces" -gt 0 ]; do
images="$images NULL:"
freespaces=$[ $freespaces - 1 ]
done
( [ $preview == 0 ] ||
(montage -geometry "128x96+2+2" -tile $tile $images miff:-\
| display -title "Page $page" &
echo -n "Print this page? "; read in; killall display; [ x$in == xy ] ) ) &&\
montage -cache 10 -geometry "100%+2+2" -tile $tile $images pro$page.bmp &&\
lpr $printer -o scaling=$scaling $options pro$page.bmp -r
page=$[page + 1]
done
wait
rm -f pro[0-9]*.bmp

253
poll_ppd_base.c Normal file
View file

@ -0,0 +1,253 @@
/*
*
* poll_ppd_base
* -------------
#
# A simple tool for getting a list of all installed PPD files
# with printer manufacturer and printer model, polling the database
# of the CUPS daemon. This program is mainly intended to be called
# from installation/configuration scripts for CUPS.
#
# ONLY WORKS WITH CUPS DAEMON RUNNING!
# The CUPS library (libcups.so.*) must be installed!
#
# Compile with: gcc -opoll_ppd_base -lcups poll_ppd_base.c
#
* Copyright 2000 by Till Kamppeter
*
* 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 necessary headers...
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <cups/cups.h>
#include <cups/ipp.h>
#include <cups/language.h>
// IPP Request routines for getting the printer type, stolen from QTCUPS from
// Michael Goffioul (file qtcups/cupshelper.cpp)
ipp_t* newIppRequest()
{
ipp_t *request;
cups_lang_t *lang;
request = ippNew();
request->request.op.request_id = 1;
lang = cupsLangDefault();
ippAddString(request,IPP_TAG_OPERATION,IPP_TAG_CHARSET,"attributes-charset",NULL,cupsLangEncoding(lang));
ippAddString(request,IPP_TAG_OPERATION,IPP_TAG_LANGUAGE,"attributes-natural-language",NULL,lang->language);
return request;
}
ipp_t* processRequest(ipp_t *req, const char *res)
{
http_t *HTTP;
ipp_t *answer;
HTTP = httpConnect(cupsServer(),ippPort());
if (!HTTP) {
ippDelete(req);
return 0;
}
answer = cupsDoRequest(HTTP,req,res);
httpClose(HTTP);
if (!answer) return 0;
if (answer->state == IPP_ERROR || answer->state == IPP_IDLE) {
ippDelete(answer);
return 0;
}
return answer;
}
ipp_t *getPPDList()
{
ipp_t *request = newIppRequest();
char str[1024];
const char* server = cupsServer();
int port = ippPort();
request->request.op.operation_id = CUPS_GET_PPDS;
if ((!server) || (port < 0)) return NULL;
sprintf(str,"ipp://%s:%d/printers/",cupsServer(),ippPort());
ippAddString(request,IPP_TAG_OPERATION,IPP_TAG_URI,"printer-uri",NULL,str);
//str.sprintf("/printers/%s",name);
request = processRequest(request,"/");
return request;
}
/*
* Main program
*/
int /* O - exit state */
main(int argc, /* I - Number of command-line arguments */
char *argv[]) /* I - Command-line arguments */
{
int i,j; /* Looping vars */
int makelen = 0; /* Length of current manufacturer name */
int makelist = 0; /* List of manufacturers */
int makegiven = 0; /* List of models for given manufacturer */
int all = 0; /* LIst of all models */
char *make; /* Chosen manufacturer */
ipp_t *ppdlist; /* List of PPD files resulting from IPP */
/* request */
ipp_attribute_t *attr, /* Current attribute */
*last; /* Last attribute */
char *currmake, /* current data read from PPD list */
*currmod,
*currlang,
*currfile,
*currid,
*c;
char buffer[80],
buffer2[256];
int lineprinted = 1; /* Is the current line already printed to
stdout */
// read command line arguments
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'm' : /* Manufacturer options */
if (argv[i][2] != '\0') {
if (strcmp(argv[i],"-ml") == 0) {
makelist = 1;
} else {
make = argv[i] + 2;
makegiven = 1;
}
} else {
i ++;
if (!(make = argv[i])) return 1;
makegiven = 1;
}
break;
case 'a' : /* List all PPD files */
all = 1;
break;
default :
fprintf(stderr,"Unknown option \'%c\'!\n", argv[i][1]);
fprintf(stderr,"Start program without options for help!\n");
return(1);
}
} else {
fprintf(stderr,"Unknown option \'%s\'!", argv[i]);
fprintf(stderr,"Start program without options for help!\n");
return(1);
}
if ((all) || (makegiven)) { // list all PPDs or PPDs of given manufacturer
ppdlist = getPPDList();
if (!ppdlist) return 1;
for (attr = ppdlist->attrs; // go through all entries
attr != NULL;
attr = attr->next)
if (attr->name) {
// read data items
if (strcmp(attr->name, "ppd-name") == 0) {
currfile = attr->values[0].string.text;
lineprinted = 0;
} else if (strcmp(attr->name, "ppd-make") == 0) {
currmake = attr->values[0].string.text;
} else if (strcmp(attr->name, "ppd-make-and-model") == 0) {
currmod = attr->values[0].string.text;
} else if (strcmp(attr->name, "ppd-natural-language") == 0) {
currlang = attr->values[0].string.text;
} else if (strcmp(attr->name, "ppd-device-id") == 0) {
currid = attr->values[0].string.text;
}
} else { // attr->name = NULL ==> data set completed
lineprinted = 1;
// Fill empty entries with some default stuff
if (!currmod) currmod = "UNKNOWN";
if (!currmake) currmake = "UNKNOWN";
if (!currlang) currlang = "en";
// Put data to stdout when "all" is chosen or when the manufacturer
// matches the given one.
if ((currfile) && ((all) || !strcasecmp(currmake,make))) {
if (currid && (currid[0]))
printf("%s|%s|%s|%s|%s\n",currfile,currmake,currmod,currlang,
currid);
else
printf("%s|%s|%s|%s\n",currfile,currmake,currmod,currlang);
}
currfile = NULL; currmake = NULL; currmod = NULL;
currlang = NULL; currid = NULL;
}
if (!lineprinted) {
// Fill empty entries with some default stuff
if (!currmod) currmod = "UNKNOWN";
if (!currmake) currmake = "UNKNOWN";
if (!currlang) currlang = "en";
// Put data to stdout when "all" is chosen or when the manufacturer
// matches the given one.
if ((currfile) && ((all) || !strcasecmp(currmake,make))) {
if (currid && (currid[0]))
printf("%s|%s|%s|%s|%s\n",currfile,currmake,currmod,currlang,
currid);
else
printf("%s|%s|%s|%s\n",currfile,currmake,currmod,currlang);
}
}
} else if (makelist) { // list all manufacturers
ppdlist = getPPDList();
if (!ppdlist) return 1;
for (attr = ppdlist->attrs, last = NULL; // go through all entries
attr != NULL;
attr = attr->next)
if (attr->name && strcmp(attr->name, "ppd-make") == 0)
// only search for manufacturerer entriees
if (last == NULL ||
strcasecmp(last->values[0].string.text,
attr->values[0].string.text) != 0)
// Do not take the same manufacturer twice
{
// Put found manufacturer to stdout
printf("%s\n",attr->values[0].string.text);
last = attr;
}
} else { // Help!
fprintf(stderr,"Usage:\n");
fprintf(stderr,"------\n");
fprintf(stderr,"\n");
fprintf(stderr," poll_ppd_base\n");
fprintf(stderr,"\n");
fprintf(stderr," This help page\n");
fprintf(stderr,"\n");
fprintf(stderr," poll_ppd_base -a\n");
fprintf(stderr,"\n");
fprintf(stderr," List all PPD files\n");
fprintf(stderr,"\n");
fprintf(stderr," poll_ppd_base -ml\n");
fprintf(stderr,"\n");
fprintf(stderr," List of all printer manufacturers supported by the PPD files installed\n");
fprintf(stderr,"\n");
fprintf(stderr," poll_ppd_base -m <manufacturers name>\n");
fprintf(stderr,"\n");
fprintf(stderr," List of all supported printer models of this manufacturer\n");
fprintf(stderr,"\n");
fprintf(stderr,"ONLY WORKS WITH CUPS DAEMON RUNNING!\n");
fprintf(stderr,"\n");
return(1);
}
return(0);
}