| version 1.7, 2007/12/04 03:37:48 |
version 1.12, 2009/12/16 22:54:55 |
|
|
| #!/usr/bin/perl |
#!/usr/bin/perl |
| # $RedRiver: example3.pl,v 1.6 2007/09/12 03:59:37 andrew Exp $ |
# $RedRiver: example3.pl,v 1.11 2008/09/17 14:49:50 andrew Exp $ |
| ######################################################################## |
######################################################################## |
| # palmkeyring.pl *** a command line client for Keyring databases. |
# palmkeyring.pl *** a command line client for Keyring databases. |
| # |
# |
|
|
| Getopt::Long::Configure('bundling'); |
Getopt::Long::Configure('bundling'); |
| use Term::ReadLine; |
use Term::ReadLine; |
| |
|
| use YAML; |
|
| |
|
| use Palm::PDB; |
use Palm::PDB; |
| use Palm::Keyring; |
use Palm::Keyring; |
| |
|
|
|
| my $PDBFile; |
my $PDBFile; |
| my $Categories; |
my $Categories; |
| my $Names; |
my $Names; |
| |
my $Accounts; |
| my $Action_List; |
my $Action_List; |
| my $Action_Show; |
my $Action_Show; |
| |
|
|
|
| "file|f=s" => \$PDBFile, |
"file|f=s" => \$PDBFile, |
| "categories|c:s@" => \$Categories, |
"categories|c:s@" => \$Categories, |
| "name|n=s@" => \$Names, |
"name|n=s@" => \$Names, |
| |
"account|a=s@" => \$Accounts, |
| "list|l" => \$Action_List, |
"list|l" => \$Action_List, |
| "show|s" => \$Action_Show, |
"show|s" => \$Action_Show, |
| ); |
); |
|
|
| if ($Action_List) { |
if ($Action_List) { |
| show_list(); |
show_list(); |
| } elsif ($Action_Show) { |
} elsif ($Action_Show) { |
| |
push @{ $Names }, @ARGV; |
| show_items($Names); |
show_items($Names); |
| } elsif (defined $Categories) { |
} elsif (defined $Categories) { |
| show_categories(); |
show_categories(); |
|
|
| sub show_items |
sub show_items |
| { |
{ |
| get_password() || die "Couldn't decrypt file!"; |
get_password() || die "Couldn't decrypt file!"; |
| |
|
| foreach (0..$#{ $pdb->{'records'} }) { |
foreach (0..$#{ $pdb->{'records'} }) { |
| my $r = $pdb->{'records'}->[$_]; |
my $r = $pdb->{'records'}->[$_]; |
| |
|
| my $category = |
my $category = |
| $pdb->{'appinfo'}->{'categories'}->[ $r->{'category'} ]->{'name'}; |
$pdb->{'appinfo'}->{'categories'}->[ $r->{'category'} ]->{'name'}; |
| |
|
|
|
| } |
} |
| next if ( @{ $Categories } || @{ $Names } ) && not $matched; |
next if ( @{ $Categories } || @{ $Names } ) && not $matched; |
| |
|
| my $a = $pdb->Decrypt($r); |
my $a = $pdb->Decrypt($r); |
| |
|
| |
$matched = 0; |
| |
foreach my $account (@{ $Accounts }) { |
| |
$matched++ if uc($a->{1}->{data}) eq uc($account); |
| |
} |
| |
next if ( @{ $Accounts } ) && not $matched; |
| |
|
| # XXX Fix up formatting |
# XXX Fix up formatting |
| print $a->{0}->{data} . "\n\t" . |
print $a->{0}->{data} . "\n\t" . |