| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::FreeDB2::Connection; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Copyright 2002, Vincenzo Zocca. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# See LICENSE section for usage and distribution rights. |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require 5.005_62; |
|
8
|
3
|
|
|
3
|
|
18
|
use strict; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
101
|
|
|
9
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
99
|
|
|
10
|
3
|
|
|
3
|
|
840
|
use Error qw (:try); |
|
|
3
|
|
|
|
|
7681
|
|
|
|
3
|
|
|
|
|
39
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Exporter; |
|
13
|
3
|
|
|
3
|
|
1482
|
use AutoLoader qw(AUTOLOAD); |
|
|
3
|
|
|
|
|
1898
|
|
|
|
3
|
|
|
|
|
18
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
|
18
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
|
19
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# This allows declaration use Net::FreeDB2::Connection ':all'; |
|
22
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
|
23
|
|
|
|
|
|
|
# will save memory. |
|
24
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
) ] ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
our ( $VERSION ) = '$Revision: 0.8.2.4 $ ' =~ /\$Revision:\s+([^\s]+)/; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new { |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $self = {}; |
|
40
|
0
|
|
0
|
|
|
|
bless ($self, (ref($class) || $class)); |
|
41
|
0
|
|
|
|
|
|
return ($self->_initialize (@_)); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _initialize { |
|
45
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
46
|
0
|
|
0
|
|
|
|
my $opt = shift || {}; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Set client_name and client_version |
|
49
|
0
|
0
|
|
|
|
|
defined ($opt->{client_name}) || throw Error::Simple ('ERROR: Net::FreeDB2::Connection::_initialize, mandatory option \'client_name\' missing.'); |
|
50
|
0
|
|
|
|
|
|
$self->setClientName ($opt->{client_name}); |
|
51
|
0
|
0
|
|
|
|
|
defined ($opt->{client_version}) || throw Error::Simple ('ERROR: Net::FreeDB2::Connection::_initialize, mandatory option \'client_version\' missing.'); |
|
52
|
0
|
|
|
|
|
|
$self->setClientVersion ($opt->{client_version}); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Set client_host |
|
55
|
0
|
0
|
|
|
|
|
if ($opt->{client_host}) { |
|
56
|
0
|
|
|
|
|
|
$self->setClientHost ($opt->{client_host}); |
|
57
|
|
|
|
|
|
|
} else { |
|
58
|
3
|
|
|
3
|
|
3795
|
use Sys::Hostname; |
|
|
3
|
|
|
|
|
4004
|
|
|
|
3
|
|
|
|
|
3901
|
|
|
59
|
0
|
|
|
|
|
|
$self->setClientHost (&Sys::Hostname::hostname ()); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Set client_user |
|
63
|
0
|
0
|
|
|
|
|
if ($opt->{client_user}) { |
|
64
|
0
|
|
|
|
|
|
$self->setClientUser ($opt->{client_user}); |
|
65
|
|
|
|
|
|
|
} else { |
|
66
|
0
|
|
|
|
|
|
$self->setClientUser (scalar (getpwuid ($>))); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Set freedb_host |
|
70
|
0
|
0
|
|
|
|
|
if ($opt->{freedb_host}) { |
|
71
|
0
|
|
|
|
|
|
$self->setFreeDBHost ($opt->{freedb_host}); |
|
72
|
|
|
|
|
|
|
} else { |
|
73
|
0
|
|
|
|
|
|
$self->setFreeDBHost ('freedb.freedb.org'); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Set freedb_port |
|
77
|
0
|
|
|
|
|
|
$self->setFreeDBPort ($opt->{freedb_port}); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Set proxy_host |
|
80
|
0
|
|
|
|
|
|
$self->setProxyHost ($opt->{proxy_host}); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Set proxy_port |
|
83
|
0
|
|
|
|
|
|
$self->setProxyPort ($opt->{proxy_port}); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Set proxy_user |
|
86
|
0
|
|
|
|
|
|
$self->setProxyUser ($opt->{proxy_user}); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# Set proxy_passwd |
|
89
|
0
|
|
|
|
|
|
$self->setProxyPasswd ($opt->{proxy_passwd}); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Connect |
|
92
|
0
|
0
|
|
|
|
|
exists ($opt->{no_connect}) || $self->connect (); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Return instance |
|
95
|
0
|
|
|
|
|
|
return ($self); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub connect { |
|
99
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::connect, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub lscat { |
|
103
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::lscat, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub query { |
|
107
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::query, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub read { |
|
111
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::read, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub write { |
|
115
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::write, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub help { |
|
119
|
0
|
|
|
0
|
0
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::help, oh come on, RTFM!!!"); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub log { |
|
123
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::log, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub motd { |
|
127
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::motd, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub discid { |
|
131
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::discid, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub proto { |
|
135
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::proto, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub sites { |
|
139
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::sites, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub stat { |
|
143
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::stat, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub ver { |
|
147
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::ver, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub update { |
|
151
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::update, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub whom { |
|
155
|
0
|
|
|
0
|
1
|
|
throw Error::Simple ("ERROR: Net::FreeDB2::Connection::whom, call this method either in package Net::FreeDB2::CDDBP or in package Net::FreeDB2::HTTP."); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub setClientName { |
|
159
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Set client name |
|
162
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{client_name} = shift; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub getClientName { |
|
166
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# Return client version |
|
169
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{client_name}); |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub setClientVersion { |
|
173
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# Set client version |
|
176
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{client_version} = shift; |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub getClientVersion { |
|
180
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# Return client name |
|
183
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{client_version}); |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub setClientHost { |
|
187
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
# Set client host |
|
190
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{client_host} = shift; |
|
191
|
|
|
|
|
|
|
} |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub getClientHost { |
|
194
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# Return client host |
|
197
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{client_host}); |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub setClientUser { |
|
201
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
# Set client user |
|
204
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{client_user} = shift; |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub getClientUser { |
|
208
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# Return client user |
|
211
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{client_user}); |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub setFreeDBHost { |
|
215
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# Set freedb/cddb host |
|
218
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{freedb_host} = shift; |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub getFreeDBHost { |
|
222
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# Return freedb/cddb host |
|
225
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{freedb_host}); |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub setFreeDBPort { |
|
229
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
# Set freedb/cddb port |
|
232
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{freedb_port} = shift; |
|
233
|
|
|
|
|
|
|
} |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub getFreeDBPort { |
|
236
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
# Return freedb/cddb port |
|
239
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{freedb_port}); |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub setProxyHost { |
|
243
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# Set proxy host |
|
246
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{proxy_host} = shift; |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
sub getProxyHost { |
|
250
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
251
|
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
# Return proxy host |
|
253
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{proxy_host}); |
|
254
|
|
|
|
|
|
|
} |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub setProxyPort { |
|
257
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# Set proxy port |
|
260
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{proxy_port} = shift; |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
sub getProxyPort { |
|
264
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
# Return proxy port |
|
267
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{proxy_port}); |
|
268
|
|
|
|
|
|
|
} |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
sub setProxyUser { |
|
271
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
# Set proxy user |
|
274
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{proxy_user} = shift; |
|
275
|
|
|
|
|
|
|
} |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
sub getProxyUser { |
|
278
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
# Return proxy user |
|
281
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{proxy_user}); |
|
282
|
|
|
|
|
|
|
} |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
sub setProxyPasswd { |
|
285
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
# Set proxy passwd |
|
288
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{proxy_passwd} = shift; |
|
289
|
|
|
|
|
|
|
} |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
sub getProxyPasswd { |
|
292
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
# Return proxy passwd |
|
295
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{proxy_passwd}); |
|
296
|
|
|
|
|
|
|
} |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
sub setConnection { |
|
299
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
# Set connection |
|
302
|
0
|
|
|
|
|
|
$self->{Net_FreeDB2_Connection}{connection} = shift; |
|
303
|
|
|
|
|
|
|
} |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
sub getConnection { |
|
306
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
# Return connection |
|
309
|
0
|
|
|
|
|
|
return ($self->{Net_FreeDB2_Connection}{connection}); |
|
310
|
|
|
|
|
|
|
} |
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
1; |
|
313
|
|
|
|
|
|
|
__END__ |