/[cwmp]/google/trunk/bin/dump2test.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /google/trunk/bin/dump2test.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 232 by dpavlin, Sun Nov 25 23:25:49 2007 UTC revision 234 by dpavlin, Sun Nov 25 23:26:42 2007 UTC
# Line 11  use Data::Dump qw/dump/; Line 11  use Data::Dump qw/dump/;
11  use File::Slurp;  use File::Slurp;
12  use blib;  use blib;
13  use CWMP::Request;  use CWMP::Request;
14    use YAML::Syck;
15    
16  my $path = shift @ARGV || die "usage: $0 dump/client_ip/\n";  my $path = shift @ARGV || die "usage: $0 dump/client_ip/\n";
17    
# Line 37  warn "## requests = ",dump( $requests ); Line 38  warn "## requests = ",dump( $requests );
38    
39  my $test_path = 't/dump/';  my $test_path = 't/dump/';
40    
41    sub xml2state {
42            my $xml = shift;
43            $xml =~ s/^.*?</</s;
44            return CWMP::Request->parse( $xml );
45    }
46    
47  if ( my $i = $requests->{Inform} ) {  if ( my $i = $requests->{Inform} ) {
48    
49          my $xml = read_file($i);          my $xml = read_file($i);
         $xml =~ s/^.*?</</s;  
50    
51  #       warn "## xml: $xml\n";  #       warn "## xml: $xml\n";
52    
53          my $state = CWMP::Request->parse( $xml );          my $state = xml2state( $xml );
54    
55  #       warn "## state = ",dump( $state );  #       warn "## state = ",dump( $state );
56    
# Line 67  foreach my $name ( keys %$requests ) { Line 73  foreach my $name ( keys %$requests ) {
73          my $to   = "$test_path/$name";          my $to   = "$test_path/$name";
74          warn "## $from -> $to\n";          warn "## $from -> $to\n";
75          next if -e $to;          next if -e $to;
76          write_file( $to, read_file( $from ) );          my $xml = read_file( $from );
77            write_file( $to, $xml );
78            DumpFile( "$to.yml", xml2state( $xml ) );
79          warn "created $to\n";          warn "created $to\n";
80  }  }

Legend:
Removed from v.232  
changed lines
  Added in v.234

  ViewVC Help
Powered by ViewVC 1.1.26