| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Palm::Raw.pm |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Perl class for dealing with "raw" PDB databases. A "raw" database is |
|
4
|
|
|
|
|
|
|
# one where the AppInfo and sort blocks, and all of the |
|
5
|
|
|
|
|
|
|
# records/resources, are just strings of bytes. |
|
6
|
|
|
|
|
|
|
# This is useful as a default PDB handler, for cases where you want to |
|
7
|
|
|
|
|
|
|
# be able to handle any kind of database in a generic fashion. |
|
8
|
|
|
|
|
|
|
# You may also find it useful to subclass this class, for cases where |
|
9
|
|
|
|
|
|
|
# you don't care about every type of thing in a database. |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# Copyright (C) 1999, 2000, Andrew Arensburger. |
|
12
|
|
|
|
|
|
|
# You may distribute this file under the terms of the Artistic |
|
13
|
|
|
|
|
|
|
# License, as specified in the README file. |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# $Id: Raw.pm,v 1.10 2002/11/03 16:43:16 azummo Exp $ |
|
16
|
|
|
|
|
|
|
|
|
17
|
9
|
|
|
9
|
|
49
|
use strict; |
|
|
9
|
|
|
|
|
20
|
|
|
|
9
|
|
|
|
|
379
|
|
|
18
|
|
|
|
|
|
|
package EBook::MOBI::MobiPerl::Palm::Raw; |
|
19
|
9
|
|
|
9
|
|
49
|
use EBook::MOBI::MobiPerl::Palm::PDB; |
|
|
9
|
|
|
|
|
31
|
|
|
|
9
|
|
|
|
|
239
|
|
|
20
|
9
|
|
|
9
|
|
45
|
use vars qw( $VERSION @ISA ); |
|
|
9
|
|
|
|
|
16
|
|
|
|
9
|
|
|
|
|
3916
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# One liner, to allow MakeMaker to work. |
|
23
|
|
|
|
|
|
|
$VERSION = do { my @r = (q$Revision: 1.10 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
@ISA = qw( EBook::MOBI::MobiPerl::Palm::PDB ); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Palm::Raw - Handler for "raw" Palm databases. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use Palm::Raw; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
For standalone programs. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
use Palm::Raw(); |
|
38
|
|
|
|
|
|
|
@ISA = qw( Palm::Raw ); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
For Palm::PDB helper modules. |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The Raw PDB handler is a helper class for the Palm::PDB package. It is |
|
45
|
|
|
|
|
|
|
intended as a generic handler for any database, or as a fallback |
|
46
|
|
|
|
|
|
|
default handler. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
If you have a standalone program and want it to be able to parse any |
|
49
|
|
|
|
|
|
|
type of database, use |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
use Palm::Raw; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
If you are using Palm::Raw as a parent class for your own database |
|
54
|
|
|
|
|
|
|
handler, use |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
use Palm::Raw(); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
If you omit the parentheses, Palm::Raw will register itself as the |
|
59
|
|
|
|
|
|
|
default handler for all databases, which is probably not what you |
|
60
|
|
|
|
|
|
|
want. |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The Raw handler does no processing on the database whatsoever. The |
|
63
|
|
|
|
|
|
|
AppInfo block, sort block, records and resources are simply strings, |
|
64
|
|
|
|
|
|
|
raw data from the database. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
By default, the Raw handler only handles record databases (.pdb |
|
67
|
|
|
|
|
|
|
files). If you want it to handle resource databases (.prc files) as |
|
68
|
|
|
|
|
|
|
well, you need to call |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
&Palm::PDB::RegisterPRCHandlers("Palm::Raw", ""); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
in your script. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 AppInfo block |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$pdb->{appinfo} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This is a scalar, the raw data of the AppInfo block. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 Sort block |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
$pdb->{sort} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is a scalar, the raw data of the sort block. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 Records |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
@{$pdb->{records}}; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Each element in the "records" array is a scalar, the raw data of that |
|
91
|
|
|
|
|
|
|
record. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 Resources |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
@{$pdb->{resources}}; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Each element in the "resources" array is a scalar, the raw data of |
|
98
|
|
|
|
|
|
|
that resource. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
#' |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub import |
|
104
|
|
|
|
|
|
|
{ |
|
105
|
|
|
|
|
|
|
# This package handles any PDB. |
|
106
|
0
|
|
|
0
|
|
0
|
&Palm::PDB::RegisterPDBHandlers(__PACKAGE__, |
|
107
|
|
|
|
|
|
|
[ "", "" ] |
|
108
|
|
|
|
|
|
|
); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
# sub new |
|
112
|
|
|
|
|
|
|
# sub new_Record |
|
113
|
|
|
|
|
|
|
# These are just inherited. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub ParseAppInfoBlock |
|
116
|
|
|
|
|
|
|
{ |
|
117
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
118
|
0
|
|
|
|
|
0
|
my $data = shift; |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
0
|
return $data; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub ParseSortBlock |
|
124
|
|
|
|
|
|
|
{ |
|
125
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
126
|
0
|
|
|
|
|
0
|
my $data = shift; |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
0
|
return $data; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub ParseRecord |
|
132
|
|
|
|
|
|
|
{ |
|
133
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
134
|
0
|
|
|
|
|
0
|
my %record = @_; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
0
|
return \%record; |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub ParseResource |
|
140
|
|
|
|
|
|
|
{ |
|
141
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
142
|
0
|
|
|
|
|
0
|
my %resource = @_; |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
0
|
return \%resource; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub PackAppInfoBlock |
|
148
|
|
|
|
|
|
|
{ |
|
149
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
|
150
|
|
|
|
|
|
|
|
|
151
|
3
|
|
|
|
|
10
|
return $self->{appinfo}; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub PackSortBlock |
|
155
|
|
|
|
|
|
|
{ |
|
156
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
|
157
|
|
|
|
|
|
|
|
|
158
|
3
|
|
|
|
|
10
|
return $self->{sort}; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub PackRecord |
|
162
|
|
|
|
|
|
|
{ |
|
163
|
6
|
|
|
6
|
1
|
8
|
my $self = shift; |
|
164
|
6
|
|
|
|
|
15
|
my $record = shift; |
|
165
|
|
|
|
|
|
|
|
|
166
|
6
|
|
|
|
|
18
|
return $record->{data}; |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub PackResource |
|
170
|
|
|
|
|
|
|
{ |
|
171
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
172
|
0
|
|
|
|
|
|
my $resource = shift; |
|
173
|
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
return $resource->{data}; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |
|
178
|
|
|
|
|
|
|
__END__ |