From: weasel Date: Tue, 16 Aug 2005 14:25:08 +0000 (+0000) Subject: Sort keys by creation date. X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=09b910f3487e2e5438db1bee5745c902da13e6f3;p=pgp-tools.git Sort keys by creation date. git-svn-id: svn://svn.debian.org/pgp-tools/trunk@179 b513b33f-fedd-0310-b452-c3deb5f4c849 --- diff --git a/keylookup/NEWS b/keylookup/NEWS index 6e90f92..db8a732 100644 --- a/keylookup/NEWS +++ b/keylookup/NEWS @@ -3,6 +3,7 @@ $Id$ Release notes for keylookup 3.0 (2005-08-16) * Make keylookup use gpg --search instead of querying the keyserver directly. + * Sort keys by creation date. Release notes for keylookup 2.2 (2002-09-24) * Some keyservers have started putting the key type (DSA or RSA) diff --git a/keylookup/keylookup b/keylookup/keylookup index 0b46a69..4c3ccef 100755 --- a/keylookup/keylookup +++ b/keylookup/keylookup @@ -105,13 +105,10 @@ sub getHits($) { my ($type, undef) = split /:/; if ($type eq 'pub') { my ($type, $keyid, $algo, $bits, $created, undef, $revoked) = split /:/; - my (undef,undef,undef,$mday,$mon,$year,undef,undef,undef) = localtime ($created); $currentKey = { 'bits' => $bits, 'type' => (defined $ALGOS{$algo} ? $ALGOS{$algo} : '#'.$algo), 'keyid' => $keyid, - 'year' => $year+1900, - 'month' => $mon+1, - 'day' => $mday, + 'created' => $created, 'revoked' => $revoked, 'uid' => [] }; @@ -169,13 +166,15 @@ sub prepareForDialog { my $keys = shift; my @keyargs = (); - for my $keyid (keys %$keys) { + for my $keyid (sort {- ($keys->{$a}->{'created'} <=> $keys->{$b}->{'created'})} keys %$keys) { for (@{ $keys->{$keyid}->{'uid'} }) { push @keyargs, $keys->{$keyid}->{'keyid'}, length() <= $MAX_UID_FIELD_LEN ? $_ : substr($_, 0, $MAX_UID_FIELD_LEN-2) . '..', 'off'; }; + my (undef,undef,undef,$mday,$mon,$year,undef,undef,undef) = localtime ($keys->{$keyid}->{'created'}); + push @keyargs, $keys->{$keyid}->{'keyid'}, sprintf( "[created: %s-%s-%s]", $year+1900, $mon+1, $mday ), 'off'; push @keyargs, '-'x8, '-'x40, 'off'; }; pop @keyargs; @@ -189,14 +188,13 @@ sub prepareForTXT { my $keys = shift; my @lines = (); - for my $keyid (keys %$keys) { + for my $keyid (sort {- ($keys->{$a}->{'created'} <=> $keys->{$b}->{'created'})} keys %$keys) { + my (undef,undef,undef,$mday,$mon,$year,undef,undef,undef) = localtime ($keys->{$keyid}->{'created'}); push @lines, sprintf( "%s%s/%s %s-%s-%s\n", $keys->{$keyid}->{'bits'}, $keys->{$keyid}->{'type'}, $keys->{$keyid}->{'keyid'}, - $keys->{$keyid}->{'year'}, - $keys->{$keyid}->{'month'}, - $keys->{$keyid}->{'day'} ); + $year+1900, $mon+1, $mday ); push @lines, map { ' 'x26 . $_ . "\n" } @{ $keys->{$keyid}->{'uid'} }; push @lines, "\n"; };