| 1 | package Palm::Memo; | ||
| 2 | # | ||
| 3 | # ABSTRACT: Read/write Palm OS Memo databases | ||
| 4 | # | ||
| 5 | # Copyright (C) 1999, 2000, Andrew Arensburger. | ||
| 6 | # | ||
| 7 | # This program is free software; you can redistribute it and/or modify | ||
| 8 | # it under the same terms as Perl itself. | ||
| 9 | # | ||
| 10 | # This program is distributed in the hope that it will be useful, | ||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the | ||
| 13 | # GNU General Public License or the Artistic License for more details. | ||
| 14 | |||
| 15 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 3 | ▶ | use Palm::Raw(); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 3 | ▶ | use Palm::StdAppInfo(); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 3 | ▶ | use vars qw( $VERSION @ISA ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | |||
| 20 | # One liner, to allow MakeMaker to work. | ||
| 21 | 3 | $VERSION = '1.400'; | |
| 22 | # This file is part of Palm 1.400 (March 14, 2015) | ||
| 23 | |||
| 24 | 3 | @ISA = qw( Palm::StdAppInfo Palm::Raw ); | |
| 25 | |||
| 26 | #' | ||
| 27 | |||
| 28 | sub import | ||
| 29 | 2 | ▶ | { |
|
Subroutine
import: called CC=1 SCAR=0.0
| |||
| 30 | 2 | &Palm::PDB::RegisterPDBHandlers(__PACKAGE__, | |
| 31 | [ "memo", "DATA" ], | ||
| 32 | ); | ||
| 33 | } | ||
| 34 | |||
| 35 | #' | ||
| 36 | sub new | ||
| 37 | 0 | ▶ | { |
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 38 | 0 | my $classname = shift; | |
| 39 | 0 | my $self = $classname->SUPER::new(@_); | |
| 40 | # Create a generic PDB. No need to rebless it, | ||
| 41 | # though. | ||
| 42 | |||
| 43 | 0 | $self->{name} = "MemoDB"; # Default | |
| 44 | 0 | $self->{creator} = "memo"; | |
| 45 | 0 | $self->{type} = "DATA"; | |
| 46 | 0 | $self->{attributes}{resource} = 0; | |
| 47 | # The PDB is not a resource database by | ||
| 48 | # default, but it's worth emphasizing, | ||
| 49 | # since MemoDB is explicitly not a PRC. | ||
| 50 | |||
| 51 | # Initialize the AppInfo block | ||
| 52 | $self->{appinfo} = { | ||
| 53 | 0 | sortOrder => undef, # XXX - ? | |
| 54 | }; | ||
| 55 | |||
| 56 | # Add the standard AppInfo block stuff | ||
| 57 | 0 | &Palm::StdAppInfo::seed_StdAppInfo($self->{appinfo}); | |
| 58 | |||
| 59 | # Give the PDB a blank sort block | ||
| 60 | 0 | $self->{sort} = undef; | |
| 61 | |||
| 62 | # Give the PDB an empty list of records | ||
| 63 | 0 | $self->{records} = []; | |
| 64 | |||
| 65 | 0 | return $self; | |
| 66 | } | ||
| 67 | |||
| 68 | |||
| 69 | sub new_Record | ||
| 70 | 0 | ▶ | { |
|
Subroutine
new_Record: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 71 | 0 | my $classname = shift; | |
| 72 | 0 | my $retval = $classname->SUPER::new_Record(@_); | |
| 73 | |||
| 74 | 0 | $retval->{data} = ""; | |
| 75 | |||
| 76 | 0 | return $retval; | |
| 77 | } | ||
| 78 | |||
| 79 | # ParseAppInfoBlock | ||
| 80 | # Parse the AppInfo block for Memo databases. | ||
| 81 | sub ParseAppInfoBlock | ||
| 82 | 1 | ▶ | { |
|
Subroutine
ParseAppInfoBlock: called CC=1 SCAR=0.0
Pod
documented
| |||
| 83 | 1 | my $self = shift; | |
| 84 | 1 | my $data = shift; | |
| 85 | 1 | my $sortOrder; | |
| 86 | my $i; | ||
| 87 | 1 | my $appinfo = {}; | |
| 88 | 1 | my $std_len; | |
| 89 | |||
| 90 | # Get the standard parts of the AppInfo block | ||
| 91 | 1 | $std_len = &Palm::StdAppInfo::parse_StdAppInfo($appinfo, $data); | |
| 92 | |||
| 93 | 1 | $data = $appinfo->{other}; # Look at the non-category part | |
| 94 | |||
| 95 | # Get the rest of the AppInfo block | ||
| 96 | 1 | my $unpackstr = # Argument to unpack() | |
| 97 | "x4" . # Padding | ||
| 98 | "C"; # Sort order | ||
| 99 | |||
| 100 | 1 | ($sortOrder) = unpack $unpackstr, $data; | |
| 101 | |||
| 102 | 1 | $appinfo->{sortOrder} = $sortOrder; | |
| 103 | |||
| 104 | 1 | return $appinfo; | |
| 105 | } | ||
| 106 | |||
| 107 | sub PackAppInfoBlock | ||
| 108 | 0 | ▶ | { |
|
Subroutine
PackAppInfoBlock: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 109 | 0 | my $self = shift; | |
| 110 | 0 | my $retval; | |
| 111 | my $i; | ||
| 112 | |||
| 113 | # Pack the non-category part of the AppInfo block | ||
| 114 | $self->{appinfo}{other} = | ||
| 115 | 0 | pack("x4 C x1", $self->{appinfo}{sortOrder}); | |
| 116 | |||
| 117 | # Pack the AppInfo block | ||
| 118 | 0 | $retval = &Palm::StdAppInfo::pack_StdAppInfo($self->{appinfo}); | |
| 119 | |||
| 120 | 0 | return $retval; | |
| 121 | } | ||
| 122 | |||
| 123 | sub PackSortBlock | ||
| 124 | 0 | ▶ | { |
|
Subroutine
PackSortBlock: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 125 | # XXX | ||
| 126 | 0 | return undef; | |
| 127 | } | ||
| 128 | |||
| 129 | sub ParseRecord | ||
| 130 | 4 | ▶ | { |
|
Subroutine
ParseRecord: called CC=1 SCAR=0.0
Pod
documented
| |||
| 131 | 4 | my $self = shift; | |
| 132 | 4 | my %record = @_; | |
| 133 | |||
| 134 | 4 | delete $record{offset}; # This is useless | |
| 135 | 4 | $record{data} =~ s/\0$//; # Trim trailing NUL | |
| 136 | |||
| 137 | 4 | return \%record; | |
| 138 | } | ||
| 139 | |||
| 140 | sub PackRecord | ||
| 141 | 0 | ▶ | { |
|
Subroutine
PackRecord: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 142 | 0 | my $self = shift; | |
| 143 | 0 | my $record = shift; | |
| 144 | |||
| 145 | 0 | return $record->{data} . "\0"; # Add the trailing NUL | |
| 146 | } | ||
| 147 | |||
| 148 | 3 | 1; | |
| 149 | |||
| 150 | __END__ | ||