Commit dd2ad029 authored by Didier Raboud's avatar Didier Raboud

Imported Upstream version 3.0.2-20060113

parent 746c259b
/COPYING/3.1/Tue Jan 28 23:01:10 2003//Tfoomatic-3_0-branch
/ChangeLog/3.99.2.27/Tue Jul 12 23:38:02 2005//Tfoomatic-3_0-branch
/ChangeLog/3.99.2.37/Mon Jan 9 20:48:59 2006//Tfoomatic-3_0-branch
/Foomatic-Devel-Ideas.txt/3.2/Tue Apr 22 23:19:52 2003//Tfoomatic-3_0-branch
/Makefile.in/3.16.2.3/Fri Jan 28 16:17:13 2005//Tfoomatic-3_0-branch
/README/3.26.2.7/Tue Jul 12 23:38:02 2005//Tfoomatic-3_0-branch
......@@ -7,17 +7,17 @@
/TODO/3.1/Fri Nov 29 01:31:37 2002//Tfoomatic-3_0-branch
/USAGE/3.14.2.4/Tue Sep 14 21:08:37 2004//Tfoomatic-3_0-branch
/acinclude.m4/3.0/Fri Oct 11 01:16:34 2002//Tfoomatic-3_0-branch
/configure.in/3.13.2.2/Tue Jul 20 15:54:10 2004//Tfoomatic-3_0-branch
/configure.ac/1.1.2.1/Fri Jan 6 17:37:50 2006//Tfoomatic-3_0-branch
/extract_pjl/3.1/Wed Nov 19 03:23:50 2003//Tfoomatic-3_0-branch
/foomatic-addpjloptions.8.in/3.2/Wed Nov 19 03:23:50 2003//Tfoomatic-3_0-branch
/foomatic-addpjloptions.in/3.1/Wed Nov 19 03:23:50 2003//Tfoomatic-3_0-branch
/foomatic-cleanupdrivers.in/3.0.2.2/Fri Jan 28 16:17:13 2005//Tfoomatic-3_0-branch
/foomatic-cleanupdrivers.in/3.0.2.3/Fri Jan 6 17:37:50 2006//Tfoomatic-3_0-branch
/foomatic-combo-xml.1.in/3.0/Fri Oct 11 01:16:34 2002//Tfoomatic-3_0-branch
/foomatic-combo-xml.c/3.3.2.1/Wed Mar 24 22:18:18 2004//Tfoomatic-3_0-branch
/foomatic-combo-xml.c/3.3.2.2/Tue Aug 23 21:50:09 2005//Tfoomatic-3_0-branch
/foomatic-compiledb.1.in/3.1/Thu Nov 28 02:42:26 2002//Tfoomatic-3_0-branch
/foomatic-compiledb.in/3.6.2.1/Tue Nov 30 14:29:43 2004//Tfoomatic-3_0-branch
/foomatic-compiledb.in/3.6.2.2/Sun Oct 23 01:03:45 2005//Tfoomatic-3_0-branch
/foomatic-configure.1.in/3.1/Thu Nov 28 02:42:26 2002//Tfoomatic-3_0-branch
/foomatic-configure.in/3.18.2.4/Mon May 30 00:44:48 2005//Tfoomatic-3_0-branch
/foomatic-configure.in/3.18.2.8/Sun Oct 23 00:43:39 2005//Tfoomatic-3_0-branch
/foomatic-filters-ppds-README/3.1/Sun Feb 23 07:14:18 2003//Tfoomatic-3_0-branch
/foomatic-filters-ppds-install/3.1/Sun Feb 23 07:14:18 2003//Tfoomatic-3_0-branch
/foomatic-fix-xml.in/3.0/Fri Oct 11 01:16:34 2002//Tfoomatic-3_0-branch
......@@ -27,11 +27,11 @@
/foomatic-kitload.in/3.0/Fri Oct 11 01:16:34 2002//Tfoomatic-3_0-branch
/foomatic-nonumericalids.in/3.1/Thu Mar 27 21:01:58 2003//Tfoomatic-3_0-branch
/foomatic-perl-data.1.in/3.0/Fri Oct 11 01:16:34 2002//Tfoomatic-3_0-branch
/foomatic-perl-data.c/3.14.2.1/Wed Mar 24 22:18:18 2004//Tfoomatic-3_0-branch
/foomatic-perl-data.c/3.14.2.4/Sun Oct 23 00:43:39 2005//Tfoomatic-3_0-branch
/foomatic-ppd-options.1.in/3.1/Wed Nov 19 03:23:50 2003//Tfoomatic-3_0-branch
/foomatic-ppd-options.in/3.2/Wed Nov 19 03:41:29 2003//Tfoomatic-3_0-branch
/foomatic-ppdfile.1.in/3.2/Wed Nov 19 03:23:50 2003//Tfoomatic-3_0-branch
/foomatic-ppdfile.in/3.4.2.2/Tue Nov 30 14:29:43 2004//Tfoomatic-3_0-branch
/foomatic-ppdfile.in/3.4.2.4/Sun Oct 23 00:43:39 2005//Tfoomatic-3_0-branch
/foomatic-preferred-driver.8.in/3.0/Fri Oct 11 01:16:34 2002//Tfoomatic-3_0-branch
/foomatic-preferred-driver.in/3.3.2.1/Sun Mar 28 23:04:51 2004//Tfoomatic-3_0-branch
/foomatic-printermap-to-gimp-print-xml.in/1.1.2.2/Sun Mar 28 23:04:51 2004//Tfoomatic-3_0-branch
......
2006-01-09 Till Kamppeter <till.kamppeter@gmx.net>
* lib/Foomatic/DB.pm: Let PPD files with "*CloseGroup" without
group name being parsed correctly, eliminate warning about
uninitialized variable when a PPD file is built out of Foomatic
data.
2006-01-06 Till Kamppeter <till.kamppeter@gmx.net>
* configure.in, configure.ac: Renamed configure.in to
configure.ac, to make the package working with the current
versions of aclocal and autoconf.
* foomatic-cleanupdrivers.in: Delete also driver XML files
without "<prototype>" tags at all, as they also do not
contain a driver command line prototype.
2005-10-26 Till Kamppeter <till.kamppeter@gmx.net>
* lib/Foomatic/DB.pm: Fix on support for gzipped PPDs.
2005-10-25 Till Kamppeter <till.kamppeter@gmx.net>
* lib/Foomatic/DB.pm: Added support for gzipping the custom
PPD files without needing to adapt the links in the printer
XML files.
2005-10-22 Till Kamppeter <till.kamppeter@gmx.net>
* foomatic-perl-data.c, foomatic-configure.in,
foomatic-ppdfile.in, foomatic-compiledb.in, lib/Foomatic/DB.pm:
Let the Foomatic tools use custom-made PPD files if they are
linked in the printer XML file and available in the local
Foomatic database.
2005-09-13 Till Kamppeter <till.kamppeter@gmx.net>
* lib/Foomatic/DB.pm: Made "translate_printer_id()" not crashing
when it is called with a weird printer ID.
2005-08-23 Till Kamppeter <till.kamppeter@gmx.net>
* foomatic-combo-xml.c: Added the links to the ready-made PPD
files for all drivers to the overview output. Eliminated
compiler warnings.
* foomatic-perl-data.c: Eliminated compiler warnings.
2005-08-15 Till Kamppeter <till.kamppeter@gmx.net>
* foomatic-configure.in: Added support for the new "beh"
(Backend Error Handler for CUPS) backend (included
in foomatic-filters now).
2005-08-05 Till Kamppeter <till.kamppeter@gmx.net>
* foomatic-perl-data.c: Added support for "<ppd>" tags in the
"<drivers>" list of the printer XML files. This is needed
to provide ready-made PPDs for arbitrary drivers on the
linuxprinting.org site.
2005-08-04 Till Kamppeter <till.kamppeter@gmx.net>
* foomatic-configure.in: Fixed bug of multiple "tc=..." items in
an /etc/printcap entry of LPRng not being supported.
2005-07-12 Till Kamppeter <till.kamppeter@gmx.net>
* READNE: Updated links to Adobe PostScript specifications.
......
This diff is collapsed.
dnl Process this file with autoconf to produce a configure script.
AC_INIT(foomatic-perl-data.c)
AC_INIT([footmatic-db-engine], 3.0.2)
AC_CONFIG_SRCDIR(foomatic-perl-data.c)
dnl If the user didn't specify the $sysconfdir on the command line, let it
dnl be /etc, not /usr/local/etc or /usr/etc
......
#!@PERL@
# -*- perl -*-
# This is foomatic-cleanupdrivers. It removes all driver XML files which have
# an empty command line. So one can avoid that "unusable" printer/driver
# combos are shown in frontends. This program also runs when Foomatic is not
# installed.
# This is foomatic-cleanupdrivers. It removes all driver XML files
# which have an empty command line. So one can avoid that "unusable"
# printer/driver combos are shown in frontends. This program also runs
# when Foomatic is not installed.
use Foomatic::Defaults;
if ($#ARGV > -1) {
......@@ -28,7 +29,8 @@ while ($driver = readdir(DRIVERDIR)) {
close DRIVERENTRY;
my $driverentry = join ('', @driverentryfield);
if (($driverentry =~ m!<prototype>\s*</prototype>!sg) ||
($driverentry =~ m!<prototype\s*/\s*>!sg)) {
($driverentry =~ m!<prototype\s*/\s*>!sg) ||
($driverentry !~ m!<prototype[>/\s]!sg)) {
unlink("$libdir/db/source/driver/$driver") ||
die "Cannot delete $driver!\n";
print "$driver has an empty command line, deleted!\n";
......
......@@ -41,18 +41,24 @@
* overview ("-O" option)
*/
typedef struct { /* structure for a driver entries (linear list) */
typedef struct { /* structure for a driver entry (linear list) */
char name[128]; /* Name of driver */
struct driverlist_t *next; /* pointer to next driver */
} driverlist_t;
typedef struct { /* structure for a driver entries (linear list) */
typedef struct { /* structure for a printer entry (linear list) */
char id[128]; /* ID of printer */
driverlist_t *drivers; /* pointer to the list of the drivers
with which this printer works */
struct printerlist_t *next; /* pointer to next printer */
} printerlist_t;
typedef struct { /* structure for a ready-made PPD entry (linear list) */
char driver[128]; /* ID of driver */
char ppd[1024]; /* ID of PPD URL */
struct ppdlist_t *next; /* pointer to next PPD */
} ppdlist_t;
typedef struct { /* structure for printer ID translations (linear list) */
char *oldid, /* old ID of printer */
*newid; /* current ID of printer */
......@@ -150,7 +156,7 @@ idlist_t /* O - pointer to the printer ID translation table */
newitem->newid = newid;
newitem->next = NULL;
if (currentitem) {
currentitem->next = newitem;
currentitem->next = (struct idlist_t *)newitem;
} else {
idlist = newitem;
}
......@@ -239,10 +245,14 @@ parse(const char **data, /* I/O - Data to process */
int inmodel = 0;
int inautodetect = 0;
int indriver = 0;
int indrivers = 0;
int inexecution = 0;
int innopjl = 0;
int inprinters = 0;
int inid = 0;
int inppd = 0;
int inlang = 0;
int inpostscript = 0;
int inoption = 0;
int inargshortname = 0;
int inargexecution = 0;
......@@ -291,6 +301,8 @@ parse(const char **data, /* I/O - Data to process */
char cmake[256];
char cmodel[256];
char cdriver[256];
char cid[256];
char cppd[1024];
char cfunctionality[256];
int cunverified = 0;
char cautodetectentry[4096];
......@@ -317,8 +329,11 @@ parse(const char **data, /* I/O - Data to process */
int k;
printerlist_t *plistpointer; /* pointers to navigate through the printer */
driverlist_t *dlistpointer; /* list for the overview */
ppdlist_t *ppdlistpointer;
printerlist_t *plistpreventry;
driverlist_t *dlistpreventry;
ppdlist_t *ppdlistpreventry;
ppdlist_t *ppdlist = NULL;
/* Translate printer ID */
if (pid) trpid = translateid(pid, idlist);
......@@ -528,12 +543,49 @@ parse(const char **data, /* I/O - Data to process */
cunverified = 1;
} else if (strcmp(currtagname, "driver") == 0) {
indriver = nestinglevel + 1;
if (indrivers) {
if (tagtype == 1) {
if (debug)
fprintf(stderr,
" Resetting Driver/PPD.\n");
cid[0] = '\0';
cppd[0] = '\0';
}
}
} else if (strcmp(currtagname, "drivers") == 0) {
indrivers = nestinglevel + 1;
} else if (strcmp(currtagname, "id") == 0) {
inid = nestinglevel + 1;
} else if (strcmp(currtagname, "ppd") == 0) {
inppd = nestinglevel + 1;
} else if (strcmp(currtagname, "lang") == 0) {
inlang = nestinglevel + 1;
} else if (strcmp(currtagname, "postscript") == 0) {
inpostscript = nestinglevel + 1;
if (inlang) {
if (tagtype == 1) {
if (debug)
fprintf(stderr,
" Resetting Driver/PPD.\n");
strcpy(cid, "Postscript");
cppd[0] = '\0';
}
}
} else if (strcmp(currtagname, "autodetect") == 0) {
inautodetect = nestinglevel + 1;
if (tagtype == 1) lastautodetect = (char*)lasttag;
} else if (strcmp(currtagname, "printer") == 0) {
inprinter = nestinglevel + 1;
if (tagtype == 1) {
if (debug) fprintf(stderr,
" Initializing PPD list.\n");
while(ppdlist != NULL) {
ppdlistpointer = ppdlist;
ppdlist = (ppdlist_t *)ppdlist->next;
free(ppdlistpointer);
}
if (debug) fprintf(stderr,
" Initializing fields.\n");
cprinter[0] = '\0';
cmake[0] = '\0';
cmodel[0] = '\0';
......@@ -618,7 +670,7 @@ parse(const char **data, /* I/O - Data to process */
if (tagnamefound) { /* '/' after tag name, this tag has no
body */
tagtype = 0;
} else { /* we a closing a tag */
} else { /* we are closing a tag */
tagtype = -1;
}
if (debug)
......@@ -1169,7 +1221,8 @@ parse(const char **data, /* I/O - Data to process */
plistpointer->drivers = NULL;
plistpointer->next = NULL;
if (plistpreventry != NULL)
plistpreventry->next = plistpointer;
plistpreventry->next =
(struct printerlist_t *)plistpointer;
else
*printerlist = plistpointer;
}
......@@ -1185,7 +1238,8 @@ parse(const char **data, /* I/O - Data to process */
strcpy(dlistpointer->name, cdriver);
dlistpointer->next = NULL;
if (dlistpreventry != NULL)
dlistpreventry->next = dlistpointer;
dlistpreventry->next =
(struct driverlist_t *)dlistpointer;
else
plistpointer->drivers = dlistpointer;
}
......@@ -1210,9 +1264,61 @@ parse(const char **data, /* I/O - Data to process */
strcpy(cfunctionality, currtagbody);
}
if (nestinglevel < inunverified) inunverified = 0;
if (nestinglevel < indriver) {
indriver = 0;
strcpy(cdriver, currtagbody);
if (nestinglevel < indrivers) indrivers = 0;
if (nestinglevel < inlang) inlang = 0;
if ((nestinglevel < indriver) ||
(nestinglevel < inpostscript)) {
if (nestinglevel < indriver) indriver = 0;
if (nestinglevel < inpostscript) inpostscript = 0;
if (indrivers || inlang) {
if (debug) fprintf(stderr,
" Driver/PPD: %s %s\n",
cid, cppd);
if ((cid[0] != '\0') && (cppd[0] != '\0')) {
if (debug)
fprintf(stderr,
" Adding Driver/PPD to list.\n");
ppdlistpointer = ppdlist;
ppdlistpreventry = NULL;
if (debug)
fprintf(stderr,
" Going through list: ");
while (ppdlistpointer != NULL) {
ppdlistpreventry = ppdlistpointer;
ppdlistpointer = (ppdlist_t *)ppdlistpointer->next;
if (debug)
fprintf(stderr,
".");
}
ppdlistpointer =
(ppdlist_t *)malloc(sizeof(ppdlist_t));
strcpy(ppdlistpointer->driver, cid);
strcpy(ppdlistpointer->ppd, cppd);
ppdlistpointer->next = NULL;
if (ppdlistpreventry != NULL)
ppdlistpreventry->next =
(struct ppdlist_t *)ppdlistpointer;
else
ppdlist = ppdlistpointer;
if (debug)
fprintf(stderr,
" Driver/PPD in list: %s %s\n",
ppdlistpointer->driver,
ppdlistpointer->ppd);
}
} else strcpy(cdriver, currtagbody);
}
if (nestinglevel < inid) {
inid = 0;
strcpy(cid, currtagbody);
if (debug) fprintf(stderr,
" Driver ID for PPD: %s\n", cid);
}
if (nestinglevel < inppd) {
inppd = 0;
strcpy(cppd, currtagbody);
if (debug) fprintf(stderr,
" PPD URL: %s\n", cppd);
}
if (nestinglevel < inautodetect) {
inautodetect = 0;
......@@ -1329,7 +1435,29 @@ parse(const char **data, /* I/O - Data to process */
dlistpointer = (driverlist_t *)(dlistpointer->next);
}
}
strcat((char *)(*data), " </drivers>\n </printer>\n");
strcat((char *)(*data), " </drivers>\n");
if (ppdlist != NULL) {
strcat((char *)(*data), " <ppds>\n");
ppdlistpointer = ppdlist;
if (debug)
fprintf(stderr,
" Going through list: ");
while (ppdlistpointer) {
if (debug)
fprintf(stderr,
".");
strcat((char *)(*data), " <ppd>\n");
strcat((char *)(*data), " <driver>");
strcat((char *)(*data), ppdlistpointer->driver);
strcat((char *)(*data), "</driver>\n <ppdfile>");
strcat((char *)(*data), ppdlistpointer->ppd);
strcat((char *)(*data), "</ppdfile>\n");
strcat((char *)(*data), " </ppd>\n");
ppdlistpointer = (ppdlist_t *)(ppdlistpointer->next);
}
strcat((char *)(*data), " </ppds>\n");
}
strcat((char *)(*data), " </printer>\n");
}
} else if (operation == 2) { /* Option XML file */
if (debug) fprintf(stderr, " Resulting option XML:\n%s\n", *data);
......@@ -1723,5 +1851,5 @@ main(int argc, /* I - Number of command-line arguments */
}
/*
* End of "$Id: foomatic-combo-xml.c,v 3.3.2.1 2004/03/24 22:18:18 till Exp $".
* End of "$Id: foomatic-combo-xml.c,v 3.3.2.2 2005/08/23 21:50:09 till Exp $".
*/
#!@PERL@
# -*- perl -*-
use Foomatic::Defaults;
use Foomatic::DB;
......@@ -187,8 +188,10 @@ sub spawn_child {
my $possible = $db->getdat($driver, $printer);
# Do not create a PPD file if the printer/driver combo
# is not possible or if the renderer command line is
# empty
next if (!$possible) or (!$db->{'dat'}{'cmd'});
# empty and no custom PPD file is available
next if ((!$possible) or
((!$db->{'dat'}{'cmd'}) and
(!$db->{'dat'}{'ppdfile'})));
@data = $db->getppd();
}
open OUTPUT, "> $filename" ||
......
This diff is collapsed.
This diff is collapsed.
#!@PERL@
# -*- perl -*-
use Foomatic::Defaults;
use Foomatic::DB;
use Getopt::Std;
......@@ -45,6 +45,10 @@ if( $showall or $showmatch ){
help() if( not defined( $poid ) );
# If the user supplies an old numerical printer ID, translate it to
# a new clear-text ID
$poid = Foomatic::DB::translate_printer_id($poid);
my $lcname = lc( $poid );
my $pentry;
for $printer (@{$db->{'overview'}}) {
......@@ -57,12 +61,12 @@ for $printer (@{$db->{'overview'}}) {
}
print "found " . Dumper($pentry) if $debug;
die "printer '$poid' not found" if( not defined $pentry );
die "printer '$poid' not found!\n" if( not defined $pentry );
if (not defined($driver) ) {
$driver = $pentry->{'driver'};
if( not defined( $driver ) ){
die "printer '$poid' does not have default driver";
die "printer '$poid' does not have default driver!\n";
}
}
......@@ -78,27 +82,23 @@ for my $d (@drivers) {
last if ($found = ($driver eq $d));
}
if( not $found ){
die "ERROR: driver '$driver' not in database\n";
die "ERROR: driver '$driver' not in database!\n";
}
# If the user supplies an old numerical printer ID, translate it to
# a new clear-text ID
$poid = Foomatic::DB::translate_printer_id($poid);
my $db = Foomatic::DB->new();
# Get all the data about this driver/printer pair
my $possible = $db->getdat($driver, $poid);
# Stop if the printer is not supported by the given driver
die "That printer and driver combination is not possible.\n"
if (!$possible);
# Stop if the driver entry has an empty command line prototype
die "The driver database entry does not contain sufficient data to build a PPD file.\n"
if (!$db->{'dat'}{'cmd'});
# Stop if the driver entry has an empty command line prototype or if there
# is no custom PPD file
die "There is neither a custom PPD file nor the driver database entry contains sufficient data to build a PPD file.\n"
if (!$db->{'dat'}{'cmd'}) && (!$db->{'dat'}{'ppdfile'});
my @data;
@data = $db->getppd($opt_w);
die "ERROR: no PPD file for printer '$poid' and driver '$driver'\n"
die "ERROR: no PPD file for printer '$poid' and driver '$driver'!\n"
if not @data;
print @data;
......
/DB.pm/3.56.2.13/Mon May 30 00:44:49 2005//Tfoomatic-3_0-branch
/DB.pm/3.56.2.20/Mon Jan 9 20:48:59 2006//Tfoomatic-3_0-branch
/PPD.pm/3.0/Fri Oct 11 01:16:34 2002//Tfoomatic-3_0-branch
/UIElem.pm/3.0/Fri Oct 11 01:16:34 2002//Tfoomatic-3_0-branch
D
......@@ -15,7 +15,7 @@ use Data::Dumper;
use POSIX; # for rounding integers
use strict;
my $ver = '$Revision: 3.56.2.13 $ ';
my $ver = '$Revision: 3.56.2.20 $ ';
# constructor for Foomatic::DB
sub new {
......@@ -38,7 +38,8 @@ sub translate_printer_id {
open TRTAB, "< $translation_table" or return $oldid;
while (<TRTAB>) {
chomp;
if (/^\s*$oldid\s+(\S+)\s*$/) {
my $searcholdid = quotemeta($oldid);
if (/^\s*$searcholdid\s+(\S+)\s*$/) {
# ID found, return new ID
my $newid = $1;
close TRTAB;
......@@ -521,9 +522,43 @@ sub sortvals {
sub getdat ($ $ $) {
my ($this, $drv, $poid) = @_;
my %dat; # Our purpose in life...
my $ppdfile;
# Do we have a link to a custom PPD file for this driver in the
# printer XML file? Then return the custom PPD
my $p = $this->get_printer($poid);
if (defined($p->{'drivers'})) {
for my $d (@{$p->{'drivers'}}) {
next if ($d->{'id'} ne $drv);
$ppdfile = $d->{'ppd'} if defined($d->{'ppd'});
last;
}
}
# Do we have a PostScript printer and a link to a manufacturer-
# supplied PPD file? Then return the manufacturer-supplied PPD
if ($drv =~ /^Postscript$/i) {
$ppdfile = $p->{'ppdurl'} if defined($p->{'ppdurl'});
}
# There is a link to a custom PPD, if it is installed on the local
# machine, use the custom PPD instead of generating one from the
# Foomatic data
if ($ppdfile) {
$ppdfile =~ s,^http://.*/(PPD/.*)$,$1,;
$ppdfile = $libdir . "/db/source/" . $ppdfile;
$ppdfile = "${ppdfile}.gz" if (! -r $ppdfile);
if (-r $ppdfile) {
$this->getdatfromppd($ppdfile);
$this->{'dat'}{'ppdfile'} = $ppdfile;
return $this->{'dat'};
}
}
# Generate Perl data structure from database
my %dat; # Our purpose in life...
my $VAR1;
eval (`$bindir/foomatic-combo-xml -d '$drv' -p '$poid' -l '$libdir' | $bindir/foomatic-perl-data -C`) ||
die ("Could not run \"foomatic-combo-xml\"/" .
......@@ -743,6 +778,12 @@ sub ppdfromvartoperl ($) {
$currentgroup =~ s!$group$!!;
$currentgroup =~ s!/$!!;
pop(@currentgrouptrans);
} elsif (m!^\*Close(Sub|)Group\s*$!) {
# "*Close[Sub]Group"
# NOTE: This expression is not Adobe-conforming
$currentgroup =~ s![^/]+$!!;
$currentgroup =~ s!/$!!;
pop(@currentgrouptrans);
} elsif (m!^\*(JCL|)OpenUI\s+\*([^:]+):\s*(\S+)\s*$!) {
# "*[JCL]OpenUI *<option>[/<translation>]: <type>"
my $argnametrans = $2;
......@@ -1299,28 +1340,28 @@ sub ppdgetdefaults {
}
sub ppdsetdefaults {
sub ppdvarsetdefaults {
my ($this, @ppdlinesin) = @_;
my ($this, $ppdfile) = @_;
my @ppdlines;
my $ppd;
# Load the complete PPD file into memory but remove the postpipe
open PPD, ($ppdfile !~ /\.gz$/i ? "< $ppdfile" :
"$sysdeps->{'gzip'} -cd \'$ppdfile\' |") or
die ("Unable to open PPD file \'$ppdfile\'\n");
while (my $line = <PPD>) {
for (my $i = 0; $i < @ppdlinesin; $i ++) {
my $line = $ppdlinesin[$i];
# Remove a postpipe definition if one is there
if ($line =~ m!^\*FoomaticRIPPostPipe:\s*\"(.*)$!) {
# "*FoomaticRIPPostPipe: <code>"
# Code string can have multiple lines, read all of them
my $line = $1;
$line = $1;
while ($line !~ m!\"!) {
# Read next line
$line = <PPD>;
$i++;
$line = $ppdlinesin[$i];
}
# We also have to remove the "*End" line
$line = <PPD>;
$i++;
$line = $ppdlinesin[$i];
if ($line !~ /^\*End/) {
push(@ppdlines, $line);
}
......@@ -1328,8 +1369,9 @@ sub ppdsetdefaults {
push(@ppdlines, $line);
}
}
close PPD;
$ppd = join('', @ppdlines);
# No option info read yet? Do not try to set deafaults
return $ppd if !$this->{'dat'}{'args'};
# If the settings for "PageSize" and "PageRegion" are different,
# set the one for "PageRegion" to the one for "PageSize".
......@@ -1440,8 +1482,11 @@ sub ppdsetdefaults {
}
}
}
} else {
$def = checkoptionvalue($this->{'dat'}, $name, $def, 0);
}
$ppd =~ s!^(\*Default$name:\s*)([^/:\s\r]*)(\s*\r?)$!$1$def$3!m;
$ppd =~ s!^(\*Default$name:\s*)([^/:\s\r]*)(\s*\r?)$!$1$def$3!m
if defined($def);
}
}
......@@ -1457,6 +1502,23 @@ sub ppdsetdefaults {
$ppd =~ s/((\r\n|\n\r|\r|\n))/$1$postpipestr/s;
}
return $ppd;
}
sub ppdsetdefaults {
my ($this, $ppdfile) = @_;
# Load the complete PPD file into memory
open PPD, ($ppdfile !~ /\.gz$/i ? "< $ppdfile" :
"$sysdeps->{'gzip'} -cd \'$ppdfile\' |") or
die ("Unable to open PPD file \'$ppdfile\'\n");
my @ppdlines = <PPD>;
close PPD;
# Set the defaults
my $ppd = $this->ppdvarsetdefaults(@ppdlines);
# Write back the modified PPD file
open PPD, ($ppdfile !~ /\.gz$/i ? "> $ppdfile" :
"| $sysdeps->{'gzip'} > \'$ppdfile\'") or
......@@ -1644,7 +1706,7 @@ sub checkoptionvalue {
return 0;
}
} elsif ($arg->{'type'} eq 'enum') {
if (defined($arg->{'vals_byname'}{$value})) {
if ($arg->{'vals_byname'}{$value}) {
return $value;
} elsif ((($arg->{'name'} eq "PageSize") ||
($arg->{'name'} eq "PageRegion")) &&
......@@ -1965,7 +2027,7 @@ sub cutguiname {
}
}
#####################
#
# PPD generation
#
......@@ -2055,10 +2117,10 @@ sub setgroupandorder {
# first.
sub getppd ( $ $ $ ) {
# If $shortgui is set, all GUI strings ("translations" in PPD files) will
# be cut to a maximum length of 39 characters. This is needed by the
# current (as of July 2003) version of the CUPS PostScript driver for
# Windows.
# If $shortgui is set, all GUI strings ("translations" in PPD
# files) will be cut to a maximum length of 39 characters. This is
# needed by the current (as of July 2003) version of the CUPS
# PostScript driver for Windows.
# If $members_in_subgroup is set, the member options of a composite
# option go into a subgroup of the group where the composite option
......@@ -2072,6 +2134,23 @@ sub getppd ( $ $ $ ) {
# The Perl data structure of the current printer/driver combo.
my $dat = $db->{'dat'};
# Do we have a custom pre-made PPD? If so, return this one
if (defined($dat->{'ppdfile'})) {
my $ppdfile = $dat->{'ppdfile'};
$ppdfile = "${ppdfile}.gz" if (! -r $ppdfile);
if (-r $ppdfile) {
# Load the complete PPD file into memory
if (open PPD, ($ppdfile !~ /\.gz$/i ? "< $ppdfile" :
"$sysdeps->{'gzip'} -cd \'$ppdfile\' |")) {
my @ppdlines = <PPD>;
close PPD;
# Set the default values
my $ppd = $db->ppdvarsetdefaults(@ppdlines);
return $ppd;
}
}
}
my @optionblob; # Lines for command line and options in the PPD file
# Insert the printer/driver IDs and the command line prototype
......@@ -3272,10 +3351,10 @@ EOFPGSZ
$pcfilename = 'FOOMATIC' if !defined($pcfilename);
my $model = $dat->{'model'};
my $make = $dat->{'make'};
my $ieee1284 = "";
my $ieee1284;
$ieee1284 = $dat->{'general_ieee'} or $ieee1284 = $dat->{'pnp_ieee'} or
$ieee1284 = $dat->{'par_ieee'} or $ieee1284 = $dat->{'usb_ieee'} or
$ieee1284 = $dat->{'snmp_ieee'};
$ieee1284 = $dat->{'snmp_ieee'} or $ieee1284 = "";
my $ieeemodel;
my $ieeemake;
if ($ieee1284) {
......@@ -4629,8 +4708,7 @@ sub get_javascript2 {
return $javascript;
}
#################################
#################################
# Modify comments text to contain only what it should:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment