blib/lib/Palm/PunchClock.pm

filter: Statementstmt 36.3% 16 / 44 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 71.4% 5 / 7 Podpod 100% 2 / 2 totaltotal 32.8% 23 / 70 CC 8 SCAR 37.3
CC
8
Cov
27%
ParseRecord
72.0
ParseAppInfoBlock
2.0
BEGIN
1.0
CRAP 41.6
↑ Summary
1 package Palm::PunchClock;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Palm::PDB;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Palm::StdAppInfo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use vars qw($VERSION @ISA $AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 $VERSION = '1.2';
10 1 @ISA = qw( Palm::PDB Palm::StdAppInfo );
11  
12 1 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
13 1 Palm::PDB::RegisterPDBHandlers(__PACKAGE__, [ "PClk", "TIME" ] );
14 }
15  
16 #my $pack = __PACKAGE__."::";
17 #
18 #sub AUTOLOAD {
19 # my($self) = shift;
20 # my(%data) = @_;
21 #
22 # my($sub) = $AUTOLOAD;
23 # $sub =~ s/$pack//;
24 # printf "AUTOLOAD(%s) [%s]\n", $sub, join "] [", @_;
25 #
26 # return \%data;
27 #}
28  
29 0 ▶sub ParseRecord {
Subroutine ParseRecord: not called CC=8 SCAR=42.8
Pod documented
30 0 my($self) = shift;
31 0 my(%rec) = @_;
32 0 my($again) = 1;
33  
34 0 local $_ = $rec{data};
35  
36 0 $rec{data} = { };
37
38 0 ▶ while ($again && $_) {
Branch: 1 branch
BranchTrueFalseTotal
if ($again and $_) 0 0 0
Condition0%0/3
$again and $_
!ll&&!rl&&r
000
MC/DC0%0/2
$again and $_
$again $_
Truth table0%0/3
A and B
A= $againB= $_
ABresult
0X0
100
111
39 0 ▶ if (/^\000/) { # Unknown ???
Branch: 5 branches
BranchTrueFalseTotal
if (/^\000/) { } 0 0 0
elsif (/^\001/) { } 0 0 0
elsif (/^\002/) { } 0 0 0
elsif (/^\005/) { } 0 0 0
elsif (/^\006/) { } 0 0 0
40 # $rec{data}{HEX00} = unpack "xH2",
41 0 substr $_, 0, 2, '';
42  
43 } elsif (/^\001/) { # startdate MMDDYYYY
44 0 my($raw) = unpack "N", substr $_, 0, 4, '';
45  
46 0 $rec{data}{month} = ($raw & 0xF00000) >> 20;
47 0 $rec{data}{day} = ($raw & 0x0F8000) >> 15;
48 0 $rec{data}{year} = ($raw & 0x007fff);
49
50 } elsif (/^\002/) { # starttime
51 0 my($hour, $min) = unpack "xCC", substr $_, 0, 3, '';
52  
53 0 $rec{data}{hour} = $hour;
54 0 $rec{data}{min} = $min;
55  
56 } elsif (/^\005/) { # duration in seconds
57 0 my($duration) = unpack "xN", substr $_, 0, 5, '';
58
59 0 $rec{data}{duration} = $duration/60;
60
61 } elsif (/^\006/) { # Zero terminated note
62 0 my($note) = unpack "xZ*", $_;
63 0 substr $_, 0, 2+length $note, '';
64  
65 0 $rec{data}{note} = $note;
66  
67 } else {
68 0 warn "unknown data!";
69 0 $again = 0;
70 }
71 }
72  
73 0 return \%rec;
74 }
75  
76 0 ▶sub ParseAppInfoBlock {
Subroutine ParseAppInfoBlock: not called CC=1 SCAR=6.9
Pod documented
77 0 my($self) = shift;
78 0 my($data) = @_;
79 0 my($appinfo) = Palm::StdAppInfo::ParseAppInfoBlock($self, $data);
80  
81 0 substr $data, 0, $Palm::StdAppInfo::stdAppInfoSize, '';
82  
83 # $appinfo->{DATA} = $data if $data;
84  
85 0 return $appinfo;
86 }
87  
88 1 1;
89 # Below is stub documentation for your module. You better edit it!
90  
91 =head1 NAME
92  
93 Palm::PunchClock - Perl extension for parsing PunchClock pdb files
94  
95 =head1 SYNOPSIS
96  
97 use Palm::PDB
98 use Palm::PunchClock;
99  
100 $pdb = new Palm::PDB;
101 $pdb->Load("PC_Div-PClk.PDB");
102  
103 =head1 DESCRIPTION
104  
105 The Palm::PunchClock module does an attempt to parse PuchClock pdb
106 files. PunchClock is a timemanagement program for PalmOS written by
107 Psync, Inc.
108  
109 =head1 BUGS
110  
111 Since this module was written in a few hours with no knowlegde of
112 PunchClocks internal format I have only guessed at the format, thus it
113 only parses the most vital data. Categories and such is ignored :-)
114  
115 =head1 AUTHOR
116  
117 Peder Stray <pederst@cpan.org>
118  
119 PunchClock is written by Psync, Inc. http://www.psync.com/
120  
121 =head1 SEE ALSO
122  
123 perl(1), Palm::PDB(3).
124  
125 =cut
↑ Summary