#!/usr/bin/perl -T -w # # Copyright (C) 2003 Mark Suter # # This program is a re-implementation of "party-table.pl" version 1.0 # by V. Alex Brennen . He wrote that script as part # of http://www.cryptnet.net/fdp/crypto/gpg-party.html # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. =head1 NAME key-party-table-latex - filter for output of "gpg --fingerprint" =head1 SYNOPSIS gpg --fingerprint | key-party-table-latex =head1 DESCRIPTION B is a filter for the output of "gpg --fingerprint" that produces good looking and easy to use LaTeX output. =head1 EXIT CODES If B exits with a zero exit status and the correct output is on standard output. Nothing else is ever printed to standard output. B will exit with a non-zero exit status if there was a fatal error. Both fatal and non-fatal errors will cause output on standard error. =head1 MORE INFORMATION The Keysigning Party HOWTO: http://www.cryptnet.net/fdp/crypto/gpg-party.html The GNU Privacy Handbook: http://www.gnupg.org/gph/en/manual.html =head1 AUTHOR Mark Suter EFE =head1 COPYRIGHT Copyright (C) 2003 Mark Suter EFE This program is in part a re-implementation of "party-table.pl" version 1.0 by V. Alex Brennen . He wrote that script as part of http://www.cryptnet.net/fdp/crypto/gpg-party.html This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA or from the following webpage. http://www.gnu.org/licenses/gpl.txt =cut use strict; use constant MAX_EMAIL_WIDTH => 55; ## Clean up the email address (it is the only item that isn't bounded) sub clean_email($) { my ($email) = @_; my ($name, $addr) = $email =~ m{^ (.+) < (.+) > $}ix or do die "Aborting on weird email $email\n"; my $width = MAX_EMAIL_WIDTH - length $addr; $width > 0 or do die "Aborting on lengthy email: $email\n"; my ($in, $out) = $name =~ m{^ (.{0,$width}) (.*) $ }ix; $email = "$in" . ($out ne "" ? "..." : "") . "<$addr>"; return $email; } ## Slurp in paragraphs $/ = ""; ## Populate the array my @keys = (); while(<>) { my ($size, $type, $id, $date, $email, $fingerprint) = m{ ^ pub \s+ (\d+) (D|R|G) / ([0-9A-F]{8}) \s (\d{4}-\d{2}-\d{2}) \s+ (.+?) $ \s+ Key \s fingerprint \s = \s+ ( [ 0-9A-F]+ ) \s* $ }imsx or die "Key not found in paragraph:\n$_\n"; ## Clean up the email address $email = clean_email $email; ## Get any extra user ids my @uids = map { clean_email $_ } m{ ^ uid \s+ (.+?) \s* $ }imsxg; push @keys, [ $id, $email, $fingerprint, "$size/${type}SA", \@uids ]; } ## Start the latex output, basically removing all margins print <<\EOF; \documentclass[10pt,a4paper,landscape,oneside,onecolumn,notitlepage]{article} \usepackage{longtable} \usepackage{layout,alltt} \pagestyle{headings} % Based on page 84-85 of _The LaTeX Companion_ ISBN 0-201-54199-8 \setlength{\hoffset}{-2cm} % Remove the one inch default \setlength{\voffset}{-2cm} % that is "added" to these two \setlength{\textwidth}{\paperwidth} % Use the entire page for the body \addtolength{\textwidth}{-1.5cm} % ... minus 1.5cm \setlength{\textheight}{\paperheight} % Use the entire page for the body \addtolength{\textheight}{-1.5cm} % ... minus 1.5cm \setlength{\headheight}{0.5cm} % Fit in the page number \renewcommand{\baselinestretch}{1.1} % Increase line spacing \setlength{\oddsidemargin}{0cm} % ... \setlength{\headsep}{0cm} % ... \setlength{\marginparsep}{0cm} % ... All other values \setlength{\marginparwidth}{0cm} % ... are set to zero \setlength{\footskip}{0cm} % ... \setlength{\headsep}{0cm} % ... \setlength{\topmargin}{0cm} % ... \begin{document} GPG Keying printed on \today \setlongtables \begin{longtable}[c]{|l|p{11cm}|l|c|c|c|} \hline ID & Owner & Fingerprint & Type & \makebox[1.3cm][c]{Key ?} & \makebox[1.3cm][c]{Owner ?} \\ \hline \endhead EOF ## Print the array, sorted by id foreach (sort { hex $a->[0] <=> hex $b->[0] } @keys) { print join(" & ", map "\\verb!$_!", $_->[0], $_->[1], $_->[2], $_->[3], "", ""), "\\\\ \n"; scalar @{$_->[4]} and print map " & \\verb!$_! & & & & \\\\ \n", @{$_->[4]}; print "\\hline\n" } ## Finish the latex output print <<\EOF; \end{longtable} Last page of the GPG Keying printed \today. This was produced by \verb!$Id: key-party-table-latex,v 1.2 2003/10/07 02:32:59 suter Exp $!. \end{document} EOF # $Id: key-party-table-latex,v 1.2 2003/10/07 02:32:59 suter Exp $