File Coverage

blib/lib/Palm/PunchClock.pm
Criterion Covered Total %
statement 13 41 31.7
branch 0 10 0.0
condition 0 3 0.0
subroutine 5 7 71.4
pod 2 2 100.0
total 20 63 31.7


line stmt bran cond sub pod time code
1             package Palm::PunchClock;
2              
3 1     1   1564 use strict;
  1         2  
  1         36  
4 1     1   1341 use Palm::PDB;
  1         7296  
  1         31  
5 1     1   1417 use Palm::StdAppInfo;
  1         10779  
  1         7  
6              
7 1     1   59 use vars qw($VERSION @ISA $AUTOLOAD);
  1         2  
  1         809  
8              
9             $VERSION = '1.2';
10             @ISA = qw( Palm::PDB Palm::StdAppInfo );
11              
12             sub import {
13 1     1   13 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             sub ParseRecord {
30 0     0 1   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   0       while ($again && $_) {
39 0 0         if (/^\000/) { # Unknown ???
    0          
    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             sub ParseAppInfoBlock {
77 0     0 1   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;
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
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