cscvs to tla changeset 1
[onak.git] / gpgstats-0.0.2 / gpgprecolons
1 #!/usr/bin/perl -Tw
2 # Written by Jonathan McDowell <noodles@earth.li>
3 # Dedicated to linguists called Simon everywhere.
4 #
5 # An attempt at parsing the output of gpg -v --with-colons --list-keys
6 # Not completed yet. Will replace gpgpre and allow info on keysize/type.
7
8 use strict;
9
10 my ($curline, $rsa, $dsa, $elg, $elgeo);
11
12 $rsa=$dsa=$elg=$elgeo=0;
13
14 while ($curline = <>) {
15         chomp $curline;
16
17         if ($curline =~ /^pub:.*:\d*:(\d*):([0-9a-fA-F]*):.*:.*:.*:.*:(.*):/) {
18                 if ($1 == 1) {
19                         $rsa++;
20                 } elsif ($1 == 16) {
21                         $elgeo++;
22                 } elsif ($1 == 17) {
23                         $dsa++;
24                 } elsif ($1 == 20) {
25                         $elg++;
26                 }
27 #               print "P$2\n";
28 #               print "N$3\n";
29         } elsif ($curline =~ /^sig:.*:\d*:(\d*):([0-9a-fA-F]*):.*:.*:.*:.*:.*/) {
30 #               print "S$2\n";
31         } elsif ($curline =~ /^uid:/) {
32                 # Extra uid. Ignore.
33         } elsif ($curline =~ /^sub:/) {
34                 # Subkey. Ignore.
35         } elsif ($curline =~ /^rev:/) {
36                 # Unsure. Ignore.
37         } else {
38                 print "$curline\n";
39         }
40 }
41
42 print "RSA keys: $rsa, DSA keys: $dsa, ELG encrypt-only: $elgeo, ELG: $elg\n";