#! @PERL@ -w # vim:syntax=perl use strict; use File::Basename qw/dirname/; use Cwd qw/realpath/; use lib realpath(dirname(__FILE__) . "/../.." ); use Lire::DlfSchema; use Lire::Test::HashConfig; use Lire::Config; # This program is run in a separate instance than the # unit test to which it is related. It must recreate # the fixture of the unit test. BEGIN { my $src_spec_dir = realpath( dirname( __FILE__ ) . "/../../config-spec" ); my $cfg = new Lire::Config::XMLFilesConfig(); $Lire::Config::SINGLETON = $cfg; foreach my $d ( $cfg->config_spec_path() ) { $cfg->del_config_spec_path_dir( $d ); } foreach my $f ( $cfg->config_files() ) { $cfg->del_config_file( $f ); } $cfg->add_config_spec_path_dir( $src_spec_dir ); $cfg->init(); $cfg->init_vars(); } use Lire::Program qw( :msg :dlf ); my $lines = 0; my $dlflines = 0; my $errorlines = 0; $Lire::Config::SINGLETON = new Lire::Test::HashConfig( { lr_schemas_path => [ split/:/, $ENV{OldDlfAdapterTest}]} ); my $schema = Lire::DlfSchema::load_schema( "message" ); my $dlf_maker = $schema->make_hashref2asciidlf_func( qw/ts host ipaddr message/ ); my $line; init_dlf_converter( "oldconverter" ); LINE: while ( defined( $line = <>)) { chomp $line; $lines++; my %r = (); my @fields = split /;/, $line; foreach my $f ( @fields ) { my ( $key, $value ) = $f =~ /^(\w+)=(.+)$/; if ( defined $key && defined $value ) { $r{$key} = $value; } else { lr_warn( "line $line contains an invalid field" ); $errorlines++; next LINE; } } my $dlf = $dlf_maker->( \%r ); print join( " ", @$dlf ), "\n"; $dlflines++; } end_dlf_converter( $lines, $dlflines, $errorlines ); # Local Variables: # mode: cperl # End: