#!perl -w # # A tool to create boot floppy images. # # Author: Milong Sabandith (milongs) # ############################################################################## use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts"; use lib $ENV{RAZZLETOOLPATH}; use PbuildEnv; use ParseArgs; use cksku; use ReadSetupFiles; use Logmsg; sub Usage { print<) { chomp $_; $line = lc $_; if ($line =~ /^\[/) { $InSection = 0; } if ($line =~ /^\[$section/) { $InSection = 1; next LINEG; } if (! $InSection) { next LINEG; } @linefields = split('=', $line); # empty line if ( $#linefields == -1) { next LINEG; } $nameg = $linefields[0]; #print "nameg = " . $#linefields . $nameg . "\n"; if( length( $nameg) < 1) { next LINEG; } $nameg =~ s/ *$//g; if ( not ($nameg =~ /$name/)) { next LINEG; } @linefields2 = split(',', $linefields[1]); $retvalue = $linefields2[$num]; # Remove spaces $retvalue =~ s/ *$//g; $retvalue =~ s/^ *//g; if( length( $retvalue) > 0) { last LINEG; } } # while (there is still data in this inputfile) close( INFFILE); return $retvalue; } sub insku{ local($testsku) = @_; $count = 0; while ($count < $listlength) { #printf( "%s %s\n", $testsku, $skulist[$count]); if ($testsku =~ /^$skulist[$count]$/ ) { return $count+1; } $count = $count+1; } return 0; } sub myprocess { local($inputfile) = @_; open(OLD, "<" . $inputfile) or die "can't open inputfile: $!"; open(NEW, ">" . $inputfile."dat") or die "can't open outputfile: $!"; # $count = 0; #while( <@skulist>) { #$count = $count+1; #printf( "count %d, %s\n", $count, $_); #} #$listlength = $count; $count = 0; while( $count < $listlength) { $skulist[$count] = lc $skulist[$count]; printf( "count %d, %s\n", $count, $skulist[$count]); $count = $count+1; } printf( "length = %d\n", $listlength); LINE1: while( ) { chomp $_; $line = lc $_; if ($line =~ /^\[/) { (printf NEW $line."\n"); next LINE1; } @linefields = split('=', $line); # empty line if ( $#linefields == -1) { next LINE1; } $sku = $linefields[0]; $error = $linefields[1]; $result = $linefields[2]; $count = insku( $sku); if ($count) { #(printf "%s %s=%s,%s", $sku, $replist[$count-1], $error, $result."\n"); (printf NEW "%s=%s,%s\n", $replist[$count-1], $error, $result); } else { (printf "* %s=%s,%s", $sku, $error, $result."\n"); (printf NEW "* %s=%s,%s\n", $sku, $error, $result); } } # while (there is still data in this inputfile) close(OLD); close(NEW); } foreach $share (@ARGV) { #print "arg is $file\n"; #@filelist = <$file>; #@filelist = `dir /b /a-d $file`; foreach (@ARGV) { chomp $share; myprocess( $share); } exit($ErrorCode); }