=================================================================== RCS file: /cvs/palm/Palm-Keyring/examples/example3.pl,v retrieving revision 1.4 retrieving revision 1.9 diff -u -r1.4 -r1.9 --- palm/Palm-Keyring/examples/example3.pl 2007/02/10 16:24:16 1.4 +++ palm/Palm-Keyring/examples/example3.pl 2008/02/28 00:17:33 1.9 @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $RedRiver$ +# $RedRiver: example3.pl,v 1.8 2008/02/27 23:54:02 andrew Exp $ ######################################################################## # palmkeyring.pl *** a command line client for Keyring databases. # @@ -26,6 +26,7 @@ my $PDBFile; my $Categories; my $Names; +my $Accounts; my $Action_List; my $Action_Show; @@ -33,6 +34,7 @@ "file|f=s" => \$PDBFile, "categories|c:s@" => \$Categories, "name|n=s@" => \$Names, + "account|a=s@" => \$Accounts, "list|l" => \$Action_List, "show|s" => \$Action_Show, ); @@ -57,11 +59,9 @@ sub show_list { print "Showing List\n"; - foreach (0..$#{ $pdb->{'records'} }) { - next if $_ == 0; - my $r = $pdb->{'records'}->[$_]; + foreach my $r (@{ $pdb->{records} }) { my $category = - $pdb->{'appinfo'}->{'categories'}->[ $r->{'category'} ]->{'name'}; + $pdb->{appinfo}->{categories}->[ $r->{category} ]->{name}; my $matched = 0; foreach my $cat (@{ $Categories }) { @@ -73,9 +73,9 @@ next if ( @{ $Categories } || @{ $Names } ) && not $matched; # XXX Fix up formatting - print $r->{'name'} . + print $r->{plaintext}->{0}->{data} . ":" . - $r->{'category'} . + $r->{category} . ":" . $category . "\n"; @@ -94,10 +94,7 @@ sub show_items { - get_password() || die "Couldn't decrypt file!"; - foreach (0..$#{ $pdb->{'records'} }) { - next if $_ == 0; my $r = $pdb->{'records'}->[$_]; my $category = @@ -108,18 +105,26 @@ $matched++ if uc($category) eq uc($cat); } foreach my $name (@{ $Names}) { - $matched++ if uc($r->{'name'}) eq uc($name); + $matched++ if uc($r->{plaintext}->{0}->{data}) eq uc($name); } next if ( @{ $Categories } || @{ $Names } ) && not $matched; + get_password() || die "Couldn't decrypt file!"; + my $a = $pdb->Decrypt($r); + $matched = 0; + foreach my $account (@{ $Accounts }) { + $matched++ if uc($r->{plaintext}->{1}->{data}) eq uc($account); + } + next if ( @{ $Accounts } ) && not $matched; + # XXX Fix up formatting - print $r->{'name'} . "\n\t" . + print $a->{0}->{data} . "\n\t" . "Category: " . $category . "\n\t" . - "Account: " . $a->{'account'} . "\n\t" . - "Password: " . $a->{'password'} . "\n"; - print "\tNotes: " . $a->{'notes'} . "\n" if $a->{'notes'}; + "Account: " . $a->{1}->{data} . "\n\t" . + "Password: " . $a->{2}->{data} . "\n"; + print "\tNotes: " . $a->{255}->{data} . "\n" if $a->{255}->{data}; } }