/usr/share/perl5/Data/AMF/IO.pm is in libdata-amf-perl 0.09-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | package Data::AMF::IO;
use Any::Moose;
require bytes;
use constant ENDIAN => unpack('S', pack('C2', 0, 1)) == 1 ? 'BIG' : 'LITTLE';
has data => (
is => 'rw',
isa => 'Str',
default => sub { '' },
lazy => 1,
);
has pos => (
is => 'rw',
isa => 'Int',
default => sub { 0 },
lazy => 1,
);
has refs => (
is => 'rw',
isa => 'ArrayRef',
default => sub { [] },
lazy => 1,
);
no Any::Moose;
sub read {
my ($self, $len) = @_;
if ($len + $self->pos > bytes::length($self->data) ) {
return;
}
my $data = substr $self->data, $self->pos, $len;
$self->pos( $self->pos + $len );
$data;
}
sub read_u8 {
my $self = shift;
my $data = $self->read(1);
return unless defined $data;
unpack('C', $data);
}
sub read_u16 {
my $self = shift;
my $data = $self->read(2);
return unless defined $data;
unpack('n', $data);
}
sub read_s16 {
my $self = shift;
my $data = $self->read(2);
return unless defined $data;
return unpack('s>', $data) if $] >= 5.009002;
return unpack('s', $data) if ENDIAN eq 'BIG';
return unpack('s', swap($data));
}
sub read_u24 {
my $self = shift;
my $data = $self->read(3);
return unpack('N', "\0$data");
}
sub read_u32 {
my $self = shift;
my $data = $self->read(4);
unpack('N', $data);
}
sub read_double {
my $self = shift;
my $data = $self->read(8);
return unpack('d>', $data) if $] >= 5.009002;
return unpack('d', $data) if ENDIAN eq 'BIG';
return unpack('d', swap($data));
}
sub read_utf8 {
my $self = shift;
my $len = $self->read_u16;
return unless defined $len;
$self->read($len);
}
sub read_utf8_long {
my $self = shift;
my $len = $self->read_u32;
return unless defined $len;
$self->read($len);
}
sub swap {
join '', reverse split '', $_[0];
}
sub write {
my ($self, $data) = @_;
$self->{data} .= $data;
}
sub write_u8 {
my ($self, $data) = @_;
$self->write( pack('C', $data) );
}
sub write_u16 {
my ($self, $data) = @_;
$self->write( pack('n', $data) );
}
sub write_s16 {
my ($self, $data) = @_;
return $self->write( pack('s>', $data) ) if $] >= 5.009002;
return $self->write( pack('s', $data) ) if ENDIAN eq 'BIG';
return $self->write( swap pack('s', $data) );
}
sub write_u24 {
my ($self, $data) = @_;
$data = pack('N', $data);
$data = substr $data, 1, 3;
$self->write($data);
}
sub write_u32 {
my ($self, $data) = @_;
$self->write( pack('N', $data) );
}
sub write_double {
my ($self, $data) = @_;
return $self->write( pack('d>', $data) ) if $] >= 5.009002;
return $self->write( pack('d', $data) ) if ENDIAN eq 'BIG';
return $self->write( swap pack('d', $data) );
}
sub write_utf8 {
my ($self, $data) = @_;
my $len = bytes::length($data);
$self->write_u16($len);
$self->write($data);
}
sub write_utf8_long {
my ($self, $data) = @_;
my $len = bytes::length($data);
$self->write_u32($len);
$self->write($data);
}
__PACKAGE__->meta->make_immutable;
__END__
=head1 NAME
Data::AMF::IO - IO class for reading/writing AMF data
=head1 DESCRIPTION
IO class for reading/writing AMF data
=head1 METHODS
=head2 new
=head2 read
=head2 read_u8
=head2 read_u16
=head2 read_s16
=head2 read_u24
=head2 read_u32
=head2 read_double
=head2 read_utf8
=head2 read_utf8_long
=head2 write
=head2 write_u8
=head2 write_u16
=head2 write_s16
=head2 write_u24
=head2 write_u32
=head2 write_double
=head2 write_utf8
=head2 write_utf8_long
=head2 swap
=head2 ENDIAN
=head1 AUTHOR
Daisuke Murase <typester@cpan.org>
=head1 COPYRIGHT
This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the
LICENSE file included with this module.
=cut
|