| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Protocol::BitTorrent::Bencode; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$Protocol::BitTorrent::Bencode::VERSION = '0.004'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
4
|
|
|
4
|
|
2030
|
use strict; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
128
|
|
|
6
|
4
|
|
|
4
|
|
19
|
use warnings FATAL => 'all', NONFATAL => 'redefine'; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
156
|
|
|
7
|
4
|
|
|
4
|
|
5141
|
use Convert::Bencode_XS qw(); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Protocol::BitTorrent::Bencode - mixin for bencode/bdecode support |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
version 0.004 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Some::Package; |
|
20
|
|
|
|
|
|
|
use parent qw(Protocol::BitTorrent::Bencode); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { bless {}, shift } |
|
23
|
|
|
|
|
|
|
sub method { |
|
24
|
|
|
|
|
|
|
my $self = shift; |
|
25
|
|
|
|
|
|
|
$self->bencode({ data => ... }); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
A simple mixin that provides L and L methods for |
|
31
|
|
|
|
|
|
|
use in other classes. The intention is to allow different bencode |
|
32
|
|
|
|
|
|
|
implementations by changing a single class. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 METHODS |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 bdecode |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Decode the given data. May die() if the given bytestring is not valid |
|
43
|
|
|
|
|
|
|
bencoded data. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub bdecode { |
|
48
|
|
|
|
|
|
|
my $self = shift; |
|
49
|
|
|
|
|
|
|
my $data = shift; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Convert::Bencode_XS::bdecode($data); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 bencode |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Encode the given data. May die() if the given Perl data structure contains |
|
57
|
|
|
|
|
|
|
any undefined values. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub bencode { |
|
62
|
|
|
|
|
|
|
my $self = shift; |
|
63
|
|
|
|
|
|
|
my $data = shift; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Convert::Bencode_XS::bencode($data); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |