From d2c0cf34bcd17f14f0e77b1df81bc993da8254e8 Mon Sep 17 00:00:00 2001 From: Didier Raboud Date: Sat, 22 May 2010 22:10:36 +0200 Subject: Imported Upstream version 3.0.2-20060113 --- foomatic-rip.in | 87 +++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 12 deletions(-) (limited to 'foomatic-rip.in') diff --git a/foomatic-rip.in b/foomatic-rip.in index 74e6798..8c72927 100755 --- a/foomatic-rip.in +++ b/foomatic-rip.in @@ -5,7 +5,7 @@ use strict; use POSIX; use Cwd; -my $ripversion='$Revision: 3.43.2.13 $'; +my $ripversion='$Revision: 3.43.2.15 $'; #'# Fix emacs syntax highlighting # foomatic-rip is a spooler-independent filter script which takes @@ -204,8 +204,22 @@ my $printer = ""; # Printing options my $optstr = ""; +# Job ID +my $jobid = ""; + +# User who sent job +my $jobuser = ((getpwuid($<))[0] || `whoami` || ""); +chomp $jobuser; + +# Host from which job was sent +my $jobhost = `hostname`; +chomp $jobhost; + # Job title -my $jobtitle = ""; +my $jobtitle = "$jobuser\@$jobhost"; + +# Number of copies +my $copies = "1"; # Post pipe (command into which the output of this filter should be piped) my $postpipe = ""; @@ -225,6 +239,10 @@ my $jcltointerpreter = ""; # keyword in the PPD file): my $jclend = "\033%-12345X\@PJL RESET\n"; +# Prefix for starting every JCL command (Can be modified by +# "*FoomaticJCLPrefix:" keyword in the PPD file): +my $jclprefix = "\@PJL "; + # Under which name were we called and in which directory do we reside $0 =~ m!^(.*/)([^/]+)$!; my $programdir = $1; @@ -442,14 +460,26 @@ while ($argstr =~ s/\x01--ppd(\x01|=|)([^\x01]+)\x01/\x01/) { # the filter's command line (options "-w": text width, "-l": text # length, "-i": indent, "-x", "-y": graphics size, "-c": raw printing, # "-n": user name, "-h": host name) +if ($argstr =~ s/\x01-h(\x01|)([^\x01]+)\x01/\x01/) { + # We have LPD or GNUlpr + if (($spooler ne 'lpd') && ($spooler ne 'gnulpr') && ($spooler ne 'lprng')) { + $spooler = 'lpd'; + } + $jobhost = $2; +} +if ($argstr =~ s/\x01-n(\x01|)([^\x01]+)\x01/\x01/) { + # We have LPD or GNUlpr + if (($spooler ne 'lpd') && ($spooler ne 'gnulpr') && ($spooler ne 'lprng')) { + $spooler = 'lpd'; + } + $jobuser = $2; +} if (($argstr =~ s/\x01-w(\x01|)\d+\x01/\x01/) || ($argstr =~ s/\x01-l(\x01|)\d+\x01/\x01/) || ($argstr =~ s/\x01-x(\x01|)\d+\x01/\x01/) || ($argstr =~ s/\x01-y(\x01|)\d+\x01/\x01/) || ($argstr =~ s/\x01-i(\x01|)\d+\x01/\x01/) || - ($argstr =~ s/\x01-c\x01/\x01/) || - ($argstr =~ s/\x01-n(\x01|)[^\x01]+\x01/\x01/) || - ($argstr =~ s/\x01-h(\x01|)[^\x01]+\x01/\x01/)) { + ($argstr =~ s/\x01-c\x01/\x01/)) { # We have LPD or GNUlpr if (($spooler ne 'lpd') && ($spooler ne 'gnulpr') && ($spooler ne 'lprng')) { $spooler = 'lpd'; @@ -685,7 +715,10 @@ if ($spooler eq 'cups') { # Common job parameters #$printer = $cups_printer; + $jobid = $cups_jobid; $jobtitle = $cups_jobtitle; + $jobuser = $cups_user; + $copies = $cups_copies; $optstr .= $cups_options; # Check for and handle inputfile vs stdin @@ -1017,6 +1050,7 @@ my $currentargument = ""; # We are currently reading this argument # @datablob, and correct the default settings according to the ones of # the main PPD structure my @datablob; +my $jclprefixset = 0; # Parse the PPD file sub undossify( $ ); @@ -1454,12 +1488,12 @@ while() { } else { $dat->{'args_byname'}{$argname}{'vals_byname'}{$setting}{'driverval'} = unhtmlify($code); } - } elsif (m!^\*JCL(Begin|ToPSInterpreter|End):\s*\"(.*)$!) { - # "*JCL(Begin|ToPSInterpreter|End): " + } elsif (m!^\*(Foomatic|)JCL(Begin|ToPSInterpreter|End|Prefix):\s*\"(.*)$!) { + # "*(Foomatic|)JCL(Begin|ToPSInterpreter|End|Prefix): " # The printer supports PJL/JCL when there is such a line $dat->{'jcl'} = 1; - my $item = $1; - my $line = $2; + my $item = $2; + my $line = $3; # Store the value # Code string can have multiple lines, read all of them my $code = ""; @@ -1479,10 +1513,14 @@ while() { $code .= $1; if ($item eq 'Begin') { $jclbegin = unhexify($code); + $jclprefix = "" if (!$jclprefixset) && ($jclbegin !~ /PJL/s); } elsif ($item eq 'ToPSInterpreter') { $jcltointerpreter = unhexify($code); } elsif ($item eq 'End') { $jclend = unhexify($code); + } elsif ($item eq 'Prefix') { + $jclprefix = unhexify($code); + $jclprefixset = 1; } } elsif (m!^\*\% COMDATA \#(.*)$!) { # If we have an old Foomatic 2.0.x PPD file, collect its Perl data @@ -4494,7 +4532,7 @@ sub getdocgeneratorhandle { } print "Option '$name':\n$commentstr $typestr argument\n"; - print " This options corresponds to a PJL command\n" if ($arg->{'style'} eq 'J'); + print " This options corresponds to a JCL command\n" if ($arg->{'style'} eq 'J'); if ($type eq 'bool') { print " Possible choices:\n"; @@ -4804,13 +4842,38 @@ sub removespecialchars { } sub unhtmlify { - # Replace HTML/XML entities by the original characters my $str = $_[0]; + + # Replace HTML/XML entities by the original characters $str =~ s/\'/\'/g; $str =~ s/\"/\"/g; $str =~ s/\>/\>/g; $str =~ s/\</\{'jcl'} = 1; # put JCL commands onto JCL stack... - push (@jclprepend, "\@PJL $cmdvar\n") if $cmdvar; + push (@jclprepend, "$jclprefix$cmdvar\n") if $cmdvar; } elsif ($arg->{'style'} eq 'C') { # command-line argument -- cgit v1.2.3