123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- use strict;
- use XML::Simple;
- use FileHandle;
- require Exporter;
- use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $PREFERRED_PARSER);
- @ISA = qw(Exporter);
- @EXPORT = qw(swiLaunch);
- @EXPORT_OK = qw();
- $VERSION = '1.0';
- $PREFERRED_PARSER = undef;
- use Internal::Output;
- require SWI::Appraiser;
- require SWI::Converter;
- require SWI::Merger;
- require SWI::Processor;
- my $config = undef;
- sub swiLaunch
- {
- my $returnCode = 0;
- my $rootLocation = shift();
- my $swiConfiguration = shift();
-
-
-
- if ( $returnCode >= 0 )
- {
- if ( $swiConfiguration eq "" )
- {
- STATUS("Configuration file should be specified!");
- $returnCode = -1;
- }
- else
- {
- STATUS("Configuration file: $swiConfiguration.");
- }
- }
- if ( $returnCode >= 0 )
- {
- if ( swiConfigurationValidate($swiConfiguration) != 0 )
- {
- STATUS("Wrong configuration file!");
- $returnCode = -2;
- }
- }
- if ( $returnCode >= 0 )
- {
-
- for (
- my $i = 0 ;
- $i <= $#{ $config->{"swi:modules"}->{"swi:module"} } ;
- $i++
- )
- {
- STATUS( "Processing module: '"
- . $config->{"swi:modules"}->{"swi:module"}[$i]
- ->{"swi:name"} . "'." );
- my $result = swiProcess( $config, $i, $rootLocation );
- if ( $result < 0 )
- {
- STATUS(
- "The are problems to report the index for the module!");
- $returnCode = -5;
- }
- elsif ( $result > 0 )
- {
- STATUS("The are scan warnings and/or errors.");
- $returnCode = $result;
- }
- else
- {
- STATUS("The module has been processed succesfully.");
- }
- }
- }
- if ( $returnCode >= 0 )
- {
-
- if ( swiMerge($config) )
- {
- STATUS("The are problems to merge files to one report!");
- $returnCode = -3;
- }
- else
- {
- STATUS("Merged report has been created.");
- }
- }
- if ( $returnCode >= 0 )
- {
-
- if ( swiAppraise($config) )
- {
- STATUS(
- "The are problems to add average/min/max/total values!");
- $returnCode = -4;
- }
- else
- {
- STATUS("Average/min/max/total values have been added.");
- }
- }
- if ( $returnCode >= 0 )
- {
-
- my $result = swiConvert($config);
- if ( $result < 0 )
- {
- STATUS("The are problems to convert the report!");
- $returnCode = -5;
- }
- elsif ( $result > 0 )
- {
- STATUS("Report has been converted. There are exceeded limitations.");
- $returnCode = $result;
- }
- else
- {
- STATUS("Report has been converted.");
- }
- }
- return $returnCode;
- }
- sub swiConfigurationValidate
- {
- $config =
- XMLin( shift(),
- ForceArray => [ "swi:module", "swi:rule", "swi:pattern" ] );
- DEBUG("Configuration structure is: " . Dumper($config));
- return 0;
- }
- return 1;
|