10 tr
:A
-Za
-z0
-9+/::cd
; # remove non-base64 chars
11 tr
:A
-Za
-z0
-9+/: -_
:; # convert to uuencoded format
12 my $len = pack("c", 32 + 0.75*length); # compute length byte
13 return unpack("u", $len . $_); # uudecode and print
17 # if $part is undefined (ie only one argument) then
18 # return the attributes of the section
20 my ($section, $part)=@_;
25 # print "Section: $section, part: $part\n";
28 # print "$inside: $_";
29 if(!$inside && ($_ =~ /^ *\<$section/)) {
32 if((1 ==$inside) && ( ($_ =~ /^ *\<$part([^>]*)/) ||
38 while($attr =~ s/ *([^=]*)= *(\"([^\"]*)\"|([^\"> ]*))//) {
39 my ($var, $cont)=($1, $2);
40 $cont =~ s/^\"(.*)\"$/$1/;
45 elsif((2 ==$inside) && ($_ =~ /^ *\<\/$part/)) {
53 my ($section, $part)=@_;
59 # print "Section: $section, part: $part\n";
62 # print "$inside: $_";
63 if(!$inside && ($_ =~ /^ *\<$section/)) {
66 elsif((1 ==$inside) && ($_ =~ /^ *\<$part[ \>]/)) {
67 if($_ =~ /$part [^>]*base64=/) {
68 # attempt to detect base64 encoded parts
73 elsif((2 ==$inside) && ($_ =~ /^ *\<\/$part/)) {
76 elsif((1==$inside) && ($_ =~ /^ *\<\/$section/)) {
78 print STDERR
"*** getpart.pm: $section/$part returned data!\n";
80 if(!@this && $warning) {
81 print STDERR
"*** getpart.pm: $section/$part returned empty!\n";
84 # decode the whole array before returning it!
86 my $decoded = decode_base64
($_);
97 print STDERR
"*** getpart.pm: $section/$part returned empty!\n";
107 if(open(XML
, "<$file")) {
108 binmode XML
; # for crapage systems, use binary
117 print STDERR
"file $file wouldn't open!\n";
125 # Strip off all lines that match the specified pattern and return
130 my ($pattern, $arrayref) = @_;
135 if($_ !~ /$pattern/) {
143 # pass array *REFERENCES* !
146 my ($firstref, $secondref)=@_;
148 my $first = join("", @
$firstref);
149 my $second = join("", @
$secondref);
151 # we cannot compare arrays index per index since with the base64 chunks,
152 # they may not be "evenly" distributed
154 # NOTE: this no longer strips off carriage returns from the arrays. Is that
155 # really necessary? It ruins the testing of newlines. I believe it was once
156 # added to enable tests on win32.
158 if($first ne $second) {
166 # Write a given array to the specified file
169 my ($filename, $arrayref)=@_;
171 open(TEMP
, ">$filename");
172 binmode(TEMP
,":raw"); # cygwin fix by Kevin Roth
180 # Load a specified file an return it as an array
186 open(TEMP
, "<$filename");
194 # Given two array references, this function will store them in two temporary
195 # files, run 'diff' on them, store the result and return the diff output!
198 my ($logdir, $firstref, $secondref)=@_;
200 my $file1="$logdir/check-generated";
201 my $file2="$logdir/check-expected";
203 open(TEMP
, ">$file1");
209 open(TEMP
, ">$file2");
214 my @out = `diff -u $file2 $file1 2>/dev/null`;
217 @out = `diff -c $file2 $file1 2>/dev/null`;