line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mobile::WURFL; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
26735
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
93
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
507
|
use BerkeleyDB ; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Storable qw/freeze thaw/; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Mobile::WURFL::Device; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use base 'Mobile::WURFL::Base'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init { |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$self->SUPER::init; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $metaname = 'dbase/wurfl.db'; |
23
|
|
|
|
|
|
|
my $meta_db = BerkeleyDB::Btree->new( |
24
|
|
|
|
|
|
|
-Filename => $metaname, |
25
|
|
|
|
|
|
|
-Flags => DB_RDONLY |
26
|
|
|
|
|
|
|
) or confess "Cannot open file $metaname: $!: $BerkeleyDB::Error\n"; |
27
|
|
|
|
|
|
|
$self->meta_db( $meta_db ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $mapname = 'dbase/wurfl_map.db'; |
30
|
|
|
|
|
|
|
my $map_db = BerkeleyDB::Btree->new( |
31
|
|
|
|
|
|
|
-Filename => $mapname, |
32
|
|
|
|
|
|
|
-Flags => DB_RDONLY |
33
|
|
|
|
|
|
|
) or confess "Cannot open file $mapname: $!: $BerkeleyDB::Error\n"; |
34
|
|
|
|
|
|
|
$self->map_db( $map_db ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $dbname = 'dbase/wurfl_data.db'; |
37
|
|
|
|
|
|
|
my $data_db = BerkeleyDB::Btree->new( |
38
|
|
|
|
|
|
|
-Filename => $dbname, |
39
|
|
|
|
|
|
|
-Flags => DB_RDONLY |
40
|
|
|
|
|
|
|
) or confess "Cannot open file $dbname: $!: $BerkeleyDB::Error\n"; |
41
|
|
|
|
|
|
|
$self->data_db( $data_db ); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub meta_db { |
47
|
|
|
|
|
|
|
$_[0]->{'meta_db'} = $_[1] if @_ > 1; |
48
|
|
|
|
|
|
|
return $_[0]->{'meta_db'}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub map_db { |
52
|
|
|
|
|
|
|
$_[0]->{'map_db'} = $_[1] if @_ > 1; |
53
|
|
|
|
|
|
|
return $_[0]->{'map_db'}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub data_db { |
57
|
|
|
|
|
|
|
$_[0]->{'data_db'} = $_[1] if @_ > 1; |
58
|
|
|
|
|
|
|
return $_[0]->{'data_db'}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub search { |
62
|
|
|
|
|
|
|
my $self = shift; |
63
|
|
|
|
|
|
|
my $uas = shift; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $device_id; |
66
|
|
|
|
|
|
|
my $found; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
while (not $found) { |
69
|
|
|
|
|
|
|
my $rc = $self->map_db->db_get("-$uas", $device_id); |
70
|
|
|
|
|
|
|
if ($rc == 0) { |
71
|
|
|
|
|
|
|
$found++; |
72
|
|
|
|
|
|
|
} else { |
73
|
|
|
|
|
|
|
chop $uas; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $buffer; |
78
|
|
|
|
|
|
|
$self->data_db->db_get($device_id, $buffer); |
79
|
|
|
|
|
|
|
my $s = thaw( $buffer ); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
return Mobile::WURFL::Device->new({ device_data => $s }); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
__END__ |