~ubuntu-branches/ubuntu/wily/libsereal-encoder-perl/wily-proposed

« back to all changes in this revision

Viewing changes to author_tools/hobodecoder.pl

  • Committer: Package Import Robot
  • Author(s): gregor herrmann
  • Date: 2014-06-06 13:17:09 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20140606131709-apeauugiwzej1b7p
Tags: 3.001-1
* Team upload.
* New upstream release.
* debian/copyright: add information about new miniz.* files.
* Bump versioned build dependency on libsereal-decoder-perl to 3.000.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
my %const_names = map {$_ => eval "$_"} @Sereal::Constants::EXPORT_OK;
23
23
 
24
24
sub parse_header {
25
 
  $data =~ s/^(=srl)(.)// or die "invalid header: $data";
 
25
  $data =~ s/^(=[s\xF3]rl)(.)// or die "invalid header: $data";
26
26
  $done .= $1 . $2;
27
27
  my $flags = $2;
28
28
  my $len = varint();
44
44
  else {
45
45
    print "Empty Header.\n";
46
46
  }
 
47
 
47
48
  my $encoding= ord($flags) & SRL_PROTOCOL_ENCODING_MASK;
48
49
 
49
 
  if ($encoding == SRL_PROTOCOL_ENCODING_SNAPPY) {
 
50
  printf "%i %i %i\n", $encoding, ord(SRL_PROTOCOL_ENCODING_MASK), ord($flags);
 
51
  if ($encoding == SRL_PROTOCOL_ENCODING_RAW) {
 
52
    print "Header says: Document body is uncompressed.\n";
 
53
  } elsif ($encoding == SRL_PROTOCOL_ENCODING_SNAPPY) {
50
54
    print "Header says: Document body is Snappy-compressed.\n";
51
55
    require Compress::Snappy;
52
56
    my $out = Compress::Snappy::decompress($data);
57
61
    require Compress::Snappy;
58
62
    my $out = Compress::Snappy::decompress($data);
59
63
    $data = $out;
60
 
  } elsif ($encoding) {
 
64
  } elsif ($encoding == SRL_PROTOCOL_ENCODING_ZLIB) {
 
65
    print "Header says: Document body is ZLIB-compressed.\n";
 
66
    my $uncompressed_len = varint();
 
67
    my $compressed_len = varint();
 
68
    require Compress::Zlib;
 
69
    my $out = Compress::Zlib::uncompress($data);
 
70
    $data = $out;
 
71
  } else {
61
72
    die "Invalid encoding '" . ($encoding >> SRL_PROTOCOL_VERSION_BITS) . "'";
62
73
  }
63
74
  $hlen= length($done);
159
170
    printf "HASH";
160
171
    parse_hv($ind);
161
172
  }
 
173
  elsif ($o == SRL_HDR_CANONICAL_UNDEF) {
 
174
    printf "CANONICAL_UNDEF\n";
 
175
  }
162
176
  elsif ($o == SRL_HDR_UNDEF) {
163
177
    printf "UNDEF\n";
164
178
  }