summaryrefslogtreecommitdiff
path: root/src/cups/cups-genppdupdate.in
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2009-08-02 12:01:21 +0100
committerRoger Leigh <rleigh@debian.org>2009-08-02 12:01:21 +0100
commit0f09a5be038c93c1bd5ca2988e152345bbf74c00 (patch)
tree279995ae9eece33b9b05cd82993f4fce98356fe8 /src/cups/cups-genppdupdate.in
parenta68ece422e0be1a0101dae2fa2408ef0e533c2e9 (diff)
Imported Upstream version 5.2.4
Diffstat (limited to 'src/cups/cups-genppdupdate.in')
-rw-r--r--src/cups/cups-genppdupdate.in54
1 files changed, 43 insertions, 11 deletions
diff --git a/src/cups/cups-genppdupdate.in b/src/cups/cups-genppdupdate.in
index 48324ee..1286c45 100644
--- a/src/cups/cups-genppdupdate.in
+++ b/src/cups/cups-genppdupdate.in
@@ -1,5 +1,5 @@
#! @PERL@ -w
-# $Id: cups-genppdupdate.in,v 1.53 2008/09/22 11:04:24 rlk Exp $
+# $Id: cups-genppdupdate.in,v 1.57 2009/06/07 02:34:55 rlk Exp $
# Update CUPS PPDs for Gutenprint queues.
# Copyright (C) 2002-2003 Roger Leigh (rleigh@debian.org)
#
@@ -20,8 +20,11 @@
use strict;
use Getopt::Std;
use Fcntl qw(:mode);
+use FileHandle;
+use IPC::Open2;
sub parse_options ();
+sub get_driver_version ();
sub update_ppd ($); # Original PPD filename
sub get_ppd_fh ($$$$$); # Return contents of desired PPD
sub find_ppd ($$$$); # Gutenprint Filename, driver, language (e.g. en, sv),
@@ -68,9 +71,11 @@ my @languages = qw(Global C @ALL_LINGUAS@);
my $serverdir = "@cups_conf_serverbin@";
my $driver_bin = "$serverdir/driver/gutenprint.$version";
my $driver_version = "";
+my $server_multicat = 0;
+my $server_multicat_initialized = 0;
+
if (-x $driver_bin) {
- $driver_version = `$driver_bin VERSION`;
- chomp $driver_version;
+ get_driver_version();
}
$Getopt::Std::STANDARD_HELP_VERSION = 1;
@@ -222,6 +227,24 @@ sub VERSION_MESSAGE($;$$$) {
sub help() {
HELP_MESSAGE(\*STDOUT);
}
+
+sub check_multicat() {
+}
+
+sub get_driver_version() {
+ open(DBIN, "$driver_bin org.gutenprint.extensions 2>/dev/null |") or return 0;
+ my ($line);
+ $server_multicat = 0;
+ while ($line = <DBIN>) {
+ if ($line =~ /^org.gutenprint.multicat$/) {
+ $server_multicat = 1;
+ last;
+ }
+ }
+ close DBIN;
+ $driver_version = `$driver_bin VERSION`;
+ chomp $driver_version;
+}
sub parse_options () {
if (!getopts('d:hnqs:vNo:p:P:r:ifl:')) {
@@ -259,6 +282,7 @@ sub parse_options () {
if (-d $opt_s) {
$ppd_base_dir = "$opt_s";
$driver_bin = "";
+ $server_multicat = 0;
$use_static_ppd = "yes";
} else {
die "$opt_s: invalid directory: $!\n";
@@ -272,9 +296,8 @@ sub parse_options () {
# for an exact match.
$file_version = "\"$version";
if (-x $driver_bin) {
- $driver_version = `$driver_bin VERSION`;
+ get_driver_version();
$use_static_ppd = "no";
- chomp $driver_version;
$file_version = "\"$driver_version\"\$";
} elsif (! -d $ppd_base_dir && ! -l $ppd_base_dir) {
die "Gutenprint $version does not appear to be installed!\n";
@@ -285,6 +308,7 @@ sub parse_options () {
if (-d $opt_s) {
$ppd_base_dir = "$opt_s";
$driver_bin = "";
+ $server_multicat = 0;
$driver_version = "";
$use_static_ppd = "yes";
}
@@ -303,8 +327,7 @@ sub parse_options () {
if ($opt_P) {
if (-x $opt_P) {
$driver_bin = "$opt_P";
- $driver_version = `$driver_bin VERSION`;
- chomp $driver_version;
+ get_driver_version();
$use_static_ppd = "no";
}
else {
@@ -356,7 +379,15 @@ sub get_ppd_fh($$$$$) {
foreach $url (@url_list) {
$new_ppd_filename = $url;
if ($debug & 8) {
- print "Trying $driver_bin cat $url for $driver, $simplified, $locale, $region\n";
+ print "Trying ", (! $server_multicat ? "$driver_bin cat " : ""), "$url for $driver, $simplified, $locale, $region\n";
+ }
+ if ($server_multicat) {
+ if (! $server_multicat_initialized) {
+ my ($pid) = open2(*Reader, *Writer, "$driver_bin org.gutenprint.multicat");
+ $server_multicat_initialized = 1;
+ }
+ print Writer "$url\n";
+ return ($new_ppd_filename, \*Reader);
}
if (open PPD, "$driver_bin cat $url |") {
return ($new_ppd_filename, \*PPD);
@@ -491,11 +522,11 @@ sub update_ppd ($) {
print "Update PPD $ppd_source_filename from $new_ppd_filename [nyq]? ";
my $input = readline(*STDIN);
if ($input =~ /^q/i) {
- close $source_fd;
+ close $source_fd if !$server_multicat;
print "Skipping all...\n";
return -2;
} elsif (! ($input =~ /^y/i)) {
- close $source_fd;
+ close $source_fd if !$server_multicat;
print "Skipping...\n";
return -1;
}
@@ -511,7 +542,7 @@ sub update_ppd ($) {
# Close original and temporary files...
close ORIG;
- if (! close $source_fd) {
+ if (! $server_multicat && ! close $source_fd) {
print "Unable to retrieve new PPD file: $!\n";
return 0;
}
@@ -808,6 +839,7 @@ sub get_ppd_data(*$$$$$) {
if ($resolutions || $types || $opts || $defaults || $data) {
while (<$fh>) {
+ last if $_ eq "*%*%EOFEOF\n";
$source_data .= $_ if ($data);
chomp;
if (($types || $opts) && m/^\*OpenUI/) {