| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/local/bin/perl -w |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/) |
|
5
|
|
|
|
|
|
|
# All rights reserved. |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package Stream::DataOutputStream; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
@DataOutputStream::ISA = qw(Stream::DataOutputStream); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# DataOutputStream |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
# Inherits from OutputStream (write, skip & writeAll) |
|
17
|
|
|
|
|
|
|
# |
|
18
|
|
|
|
|
|
|
# Implements DataOutput (the write* functions) |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
# Uses an OutputStream for its input |
|
21
|
|
|
|
|
|
|
# |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
25
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
59
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
551
|
use Stream::DataEncoding qw(/^encode/ ); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
896
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub usage |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
0
|
|
|
0
|
0
|
0
|
my ($package, $filename, $line, $subr) = caller(1); |
|
33
|
0
|
|
|
|
|
0
|
$Carp::CarpLevel = 2; |
|
34
|
0
|
|
|
|
|
0
|
croak "Usage: $subr(@_)"; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
9
|
50
|
|
9
|
0
|
37
|
usage("OutputStream") unless @_ == 2; |
|
40
|
|
|
|
|
|
|
|
|
41
|
9
|
|
|
|
|
12
|
my $type = shift; my $self = {}; bless $self, $type; |
|
|
9
|
|
|
|
|
13
|
|
|
|
9
|
|
|
|
|
16
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
9
|
|
33
|
|
|
35
|
$self->{'os'} = shift || croak("OutputStream undefined"); |
|
44
|
|
|
|
|
|
|
|
|
45
|
9
|
|
|
|
|
28
|
$self; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub write |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
9
|
50
|
|
9
|
0
|
55
|
usage("data") unless @_ == 2; |
|
51
|
|
|
|
|
|
|
|
|
52
|
9
|
|
|
|
|
13
|
my $self = shift; |
|
53
|
9
|
|
33
|
|
|
18
|
my $data = shift || usage("data"); |
|
54
|
9
|
|
|
|
|
36
|
$self->{'os'}->write($data); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub writeByte |
|
58
|
|
|
|
|
|
|
{ |
|
59
|
9
|
50
|
|
9
|
0
|
85
|
usage("byte") unless @_ == 2; |
|
60
|
|
|
|
|
|
|
|
|
61
|
9
|
|
|
|
|
11
|
my $self = shift; |
|
62
|
9
|
|
|
|
|
11
|
my $data = shift; |
|
63
|
9
|
|
|
|
|
25
|
$self->{'os'}->write(encodeByte($data)); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub writeInt16 |
|
67
|
|
|
|
|
|
|
{ |
|
68
|
9
|
50
|
|
9
|
0
|
53
|
usage("int16") unless @_ == 2; |
|
69
|
|
|
|
|
|
|
|
|
70
|
9
|
|
|
|
|
13
|
my $self = shift; |
|
71
|
9
|
|
|
|
|
25
|
my $data = shift; |
|
72
|
9
|
|
|
|
|
26
|
$self->{'os'}->write(encodeInt16($data)); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub writeInt32 |
|
76
|
|
|
|
|
|
|
{ |
|
77
|
9
|
50
|
|
9
|
0
|
53
|
usage("int32") unless @_ == 2; |
|
78
|
|
|
|
|
|
|
|
|
79
|
9
|
|
|
|
|
10
|
my $self = shift; |
|
80
|
9
|
|
|
|
|
11
|
my $data = shift; |
|
81
|
9
|
|
|
|
|
24
|
$self->{'os'}->write(encodeInt32($data)); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub writeFloat |
|
85
|
|
|
|
|
|
|
{ |
|
86
|
9
|
50
|
|
9
|
0
|
50
|
usage("float") unless @_ == 2; |
|
87
|
|
|
|
|
|
|
|
|
88
|
9
|
|
|
|
|
17
|
my $self = shift; |
|
89
|
9
|
|
|
|
|
11
|
my $data = shift; |
|
90
|
9
|
|
|
|
|
24
|
$self->{'os'}->write(encodeFloat($data)); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub writeDouble |
|
94
|
|
|
|
|
|
|
{ |
|
95
|
9
|
50
|
|
9
|
0
|
54
|
usage("double") unless @_ == 2; |
|
96
|
|
|
|
|
|
|
|
|
97
|
9
|
|
|
|
|
12
|
my $self = shift; |
|
98
|
9
|
|
|
|
|
9
|
my $data = shift; |
|
99
|
9
|
|
|
|
|
28
|
$self->{'os'}->write(encodeDouble($data)); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub writeTime |
|
103
|
|
|
|
|
|
|
{ |
|
104
|
9
|
50
|
|
9
|
0
|
55
|
usage("time") unless @_ == 2; |
|
105
|
|
|
|
|
|
|
|
|
106
|
9
|
|
|
|
|
10
|
my $self = shift; |
|
107
|
9
|
|
|
|
|
10
|
my $data = shift; |
|
108
|
9
|
|
|
|
|
27
|
$self->{'os'}->write(encodeTime($data)); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub writeLength |
|
112
|
|
|
|
|
|
|
{ |
|
113
|
36
|
50
|
|
36
|
0
|
180
|
usage("length") unless @_ == 2; |
|
114
|
|
|
|
|
|
|
|
|
115
|
36
|
|
|
|
|
40
|
my $self = shift; |
|
116
|
36
|
|
|
|
|
36
|
my $len = shift; |
|
117
|
|
|
|
|
|
|
|
|
118
|
36
|
|
|
|
|
82
|
$self->{'os'}->write(encodeLength($len)); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub writeString |
|
122
|
|
|
|
|
|
|
{ |
|
123
|
9
|
50
|
|
9
|
0
|
52
|
usage("string") unless @_ == 2; |
|
124
|
|
|
|
|
|
|
|
|
125
|
9
|
|
|
|
|
10
|
my $self = shift; |
|
126
|
9
|
|
|
|
|
11
|
my $str = shift; |
|
127
|
|
|
|
|
|
|
|
|
128
|
9
|
|
|
|
|
23
|
$self->{'os'}->write(encodeString($str)); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |