1*cdf0e10cSrcweir: 2*cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}' 3*cdf0e10cSrcweir if 0; 4*cdf0e10cSrcweir#************************************************************************* 5*cdf0e10cSrcweir# 6*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7*cdf0e10cSrcweir# 8*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 9*cdf0e10cSrcweir# 10*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite 11*cdf0e10cSrcweir# 12*cdf0e10cSrcweir# This file is part of OpenOffice.org. 13*cdf0e10cSrcweir# 14*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify 15*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3 16*cdf0e10cSrcweir# only, as published by the Free Software Foundation. 17*cdf0e10cSrcweir# 18*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful, 19*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of 20*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details 22*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code). 23*cdf0e10cSrcweir# 24*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License 25*cdf0e10cSrcweir# version 3 along with OpenOffice.org. If not, see 26*cdf0e10cSrcweir# <http://www.openoffice.org/license.html> 27*cdf0e10cSrcweir# for a copy of the LGPLv3 License. 28*cdf0e10cSrcweir# 29*cdf0e10cSrcweir#************************************************************************* 30*cdf0e10cSrcweir# 31*cdf0e10cSrcweir# 32*cdf0e10cSrcweir# check_xml.pl - check xml,xcs,xcu files size, NULL character 33*cdf0e10cSrcweir# 34*cdf0e10cSrcweir 35*cdf0e10cSrcweirmy 36*cdf0e10cSrcweir$is_debug=0; 37*cdf0e10cSrcweirmy $err = 0; 38*cdf0e10cSrcweirmy $path = $ENV{'SOLARVERSION'} . '/' . $ENV{'INPATH'} . '/xml' . "$ENV{'UPDMINOREXT'}/"; 39*cdf0e10cSrcweirmy $pck_path = $ENV{'SOLARVERSION'} . '/' . $ENV{'INPATH'} . '/pck' . "$ENV{'UPDMINOREXT'}/"; 40*cdf0e10cSrcweirmy $unzipexe="unzip"; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir#Path of the directory from which the recursion starts (must have ending '/'). 43*cdf0e10cSrcweirprint "Checking:$path\n"; 44*cdf0e10cSrcweir# Initiate the recursion 45*cdf0e10cSrcweir&RecurseDirs($path); 46*cdf0e10cSrcweir$err += &check_registry_zips($pck_path); 47*cdf0e10cSrcweirif ($err > 0) 48*cdf0e10cSrcweir{ 49*cdf0e10cSrcweir print "Error: $err damaged files encountered\n"; 50*cdf0e10cSrcweir exit(1); # stop dmake 51*cdf0e10cSrcweir} else 52*cdf0e10cSrcweir{ 53*cdf0e10cSrcweir print "ok.\n"; 54*cdf0e10cSrcweir} 55*cdf0e10cSrcweirexit; 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir#### SUBROUTINES SECTION #### 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir# Function that recurses through the directory tree calling FileFunction on all files 60*cdf0e10cSrcweirsub RecurseDirs { 61*cdf0e10cSrcweir my ($path) = @_; 62*cdf0e10cSrcweir my $file; #Variable for a file 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir opendir (DIRECTORY, $path) or 65*cdf0e10cSrcweir die "Can't read $path\n"; 66*cdf0e10cSrcweir my @all_files = grep (!/^\.\.?$/, readdir (DIRECTORY)); #Read all the files except for '.' and '..' 67*cdf0e10cSrcweir closedir (DIRECTORY); 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir foreach $file (@all_files) { 70*cdf0e10cSrcweir if (-d "$path$file/") { 71*cdf0e10cSrcweir &RecurseDirs("$path$file/"); 72*cdf0e10cSrcweir } else { 73*cdf0e10cSrcweir &check($path, $file); 74*cdf0e10cSrcweir } 75*cdf0e10cSrcweir } 76*cdf0e10cSrcweir} 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir############################################################################ 79*cdf0e10cSrcweirsub check #04.02.2005 13:40 80*cdf0e10cSrcweir############################################################################ 81*cdf0e10cSrcweir { 82*cdf0e10cSrcweir my $path = shift; 83*cdf0e10cSrcweir my $file = shift; 84*cdf0e10cSrcweir print "$path$file\n" if ((-e "$path$file") && $is_debug); 85*cdf0e10cSrcweir return if ( $file !~ /.+\.(xcu|xml|xcs)/ ); #check xml and xcu files only 86*cdf0e10cSrcweir if ( -z "$path$file" ) { 87*cdf0e10cSrcweir print "Error: $path$file 0 Bytes!\n"; 88*cdf0e10cSrcweir $err++; 89*cdf0e10cSrcweir } else 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir open( FH, "<$path$file" ); 92*cdf0e10cSrcweir while ( $line = <FH> ) { 93*cdf0e10cSrcweir #print $line; 94*cdf0e10cSrcweir if ( $line =~ /\000+/ ) { 95*cdf0e10cSrcweir print "Error: NULL characters detected in $path$file\n"; 96*cdf0e10cSrcweir $err++; 97*cdf0e10cSrcweir } 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir close(FH); 100*cdf0e10cSrcweir } 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir ############################################################################ 104*cdf0e10cSrcweir sub check_registry_zips #20.04.2005 18:47 105*cdf0e10cSrcweir ############################################################################ 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir my $path = shift; 108*cdf0e10cSrcweir my $error = 0; 109*cdf0e10cSrcweir my $commandargs; 110*cdf0e10cSrcweir opendir (DIRECTORY, $path) or 111*cdf0e10cSrcweir die "Can't read $path\n"; 112*cdf0e10cSrcweir my @all_files = grep (!/^\.\.?$/, readdir (DIRECTORY)); #Read all the files except for '.' and '..' 113*cdf0e10cSrcweir closedir (DIRECTORY); 114*cdf0e10cSrcweir foreach $file (@all_files) { 115*cdf0e10cSrcweir if ( $file =~ /registry_.+\.zip$/ ) { 116*cdf0e10cSrcweir $commandargs="$path$file"; 117*cdf0e10cSrcweir # Cygwin's perl needs escaped \ in system() and open( COMMAND ... ) 118*cdf0e10cSrcweir if ( "$^O" eq "cygwin" ) { $commandargs =~ s/\\/\\\\/g; } 119*cdf0e10cSrcweir print "file=$commandargs\n" if ($is_debug); 120*cdf0e10cSrcweir open(UNZIP,"$unzipexe -l $commandargs |"); 121*cdf0e10cSrcweir my $ferror = 0; 122*cdf0e10cSrcweir while ( $line = <UNZIP> ) { 123*cdf0e10cSrcweir #print $line; 124*cdf0e10cSrcweir my @param = split(" ",$line); 125*cdf0e10cSrcweir if ( $param[0] =~ /\d+/ ) { 126*cdf0e10cSrcweir if ( $param[0] == 0 && $param[3] =~ /.+\.xcu$/) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir $error++; $ferror=1; 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir } 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir if ( $ferror ) { 133*cdf0e10cSrcweir print "Error: $commandargs contains files with 0 byte size\n"; 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir close(UNZIP); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir } 138*cdf0e10cSrcweir 139*cdf0e10cSrcweir ($error); 140*cdf0e10cSrcweir } ##check_registry_zips 141