Modernize, and add support for other authors than ThinkSec.

git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@445 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
Dag-Erling Smørgrav 2011-10-22 02:45:26 +00:00
parent 874f75e8f4
commit ebd4f02f4b

View file

@ -41,7 +41,7 @@ use locale;
use Fcntl; use Fcntl;
use Getopt::Std; use Getopt::Std;
use POSIX qw(locale_h strftime); use POSIX qw(locale_h strftime);
use vars qw($COPYRIGHT $TODAY %FUNCTIONS %PAMERR); use vars qw($COPYRIGHT %AUTHORS $TODAY %FUNCTIONS %PAMERR);
$COPYRIGHT = ".\\\"- $COPYRIGHT = ".\\\"-
.\\\" Copyright (c) 2001-2003 Networks Associates Technology, Inc. .\\\" Copyright (c) 2001-2003 Networks Associates Technology, Inc.
@ -77,9 +77,18 @@ $COPYRIGHT = ".\\\"-
.\\\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\\\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\\\" SUCH DAMAGE. .\\\" SUCH DAMAGE.
.\\\" .\\\"
.\\\" \$" . "P4" . "\$ .\\\" \$" . "Id" . "\$
.\\\""; .\\\"";
%AUTHORS = (
THINKSEC => "ThinkSec AS and Network Associates Laboratories, the
Security Research Division of Network Associates, Inc.\\& under
DARPA/SPAWAR contract N66001-01-C-8035
.Pq Dq CBOSS ,
as part of the DARPA CHATS research program.",
DES => ".An Dag-Erling Sm\\(/orgrav Aq des\@FreeBSD.org .",
);
%PAMERR = ( %PAMERR = (
PAM_SUCCESS => "Success", PAM_SUCCESS => "Success",
PAM_OPEN_ERR => "Failed to load module", PAM_OPEN_ERR => "Failed to load module",
@ -128,13 +137,14 @@ sub parse_source($) {
my $inliteral; my $inliteral;
my %xref; my %xref;
my @errors; my @errors;
my $author;
if ($fn !~ m,\.c$,) { if ($fn !~ m,\.c$,) {
warn("$fn: not C source, ignoring\n"); warn("$fn: not C source, ignoring\n");
return undef; return undef;
} }
sysopen(FILE, $fn, O_RDONLY) open(FILE, "<", "$fn")
or die("$fn: open(): $!\n"); or die("$fn: open(): $!\n");
$source = join('', <FILE>); $source = join('', <FILE>);
close(FILE); close(FILE);
@ -142,6 +152,11 @@ sub parse_source($) {
return undef return undef
if ($source =~ m/^ \* NOPARSE\s*$/m); if ($source =~ m/^ \* NOPARSE\s*$/m);
$author = 'THINKSEC';
if ($source =~ s/^ \* AUTHOR\s+(.*?)\s*$//m) {
$author = $1;
}
$func = $fn; $func = $fn;
$func =~ s,^(?:.*/)?([^/]+)\.c$,$1,; $func =~ s,^(?:.*/)?([^/]+)\.c$,$1,;
if ($source !~ m,\n \* ([\S ]+)\n \*/\n\n([\S ]+)\n$func\((.*?)\)\n\{,s) { if ($source !~ m,\n \* ([\S ]+)\n \*/\n\n([\S ]+)\n$func\((.*?)\)\n\{,s) {
@ -211,7 +226,7 @@ sub parse_source($) {
++$xref{$sect}->{$page}; ++$xref{$sect}->{$page};
next; next;
} }
if (s/^\s+(=?\w+):\s*/.It $1/) { if (s/^\s+([=%]?\w+):\s*/.It $1/) {
if ($inliteral) { if ($inliteral) {
$man .= ".Ed\n"; $man .= ".Ed\n";
$inliteral = 0; $inliteral = 0;
@ -263,6 +278,7 @@ sub parse_source($) {
if ($inliteral) { if ($inliteral) {
$man .= ".Ed\n"; $man .= ".Ed\n";
} }
$man =~ s/\%/\\&\%/gs;
$man =~ s/(\n\.[A-Z][a-z] [\w ]+)\n([\.,:;-]\S*)\s*/$1 $2\n/gs; $man =~ s/(\n\.[A-Z][a-z] [\w ]+)\n([\.,:;-]\S*)\s*/$1 $2\n/gs;
$man =~ s/\s*$/\n/gm; $man =~ s/\s*$/\n/gm;
$man =~ s/\n+/\n/gs; $man =~ s/\n+/\n/gs;
@ -282,6 +298,7 @@ sub parse_source($) {
'man' => $man, 'man' => $man,
'xref' => \%xref, 'xref' => \%xref,
'errors' => \@errors, 'errors' => \@errors,
'author' => $author,
}; };
if ($source =~ m/^ \* NODOC\s*$/m) { if ($source =~ m/^ \* NODOC\s*$/m) {
$FUNCTIONS{$func}->{'nodoc'} = 1; $FUNCTIONS{$func}->{'nodoc'} = 1;
@ -445,15 +462,9 @@ The
.Nm .Nm
function and this manual page were developed for the function and this manual page were developed for the
.Fx .Fx
Project by ThinkSec AS and Network Associates Laboratories, the Project by\n" . $AUTHORS{$func->{'author'} // 'THINKSEC_DARPA'} . "\n";
Security Research Division of Network Associates, Inc.\\& under
DARPA/SPAWAR contract N66001-01-C-8035
.Pq Dq CBOSS ,
as part of the DARPA CHATS research program.
";
$fn = "$func->{'name'}.3"; $fn = "$func->{'name'}.3";
if (sysopen(FILE, $fn, O_RDWR|O_CREAT|O_TRUNC)) { if (open(FILE, ">", $fn)) {
print(FILE $mdoc); print(FILE $mdoc);
close(FILE); close(FILE);
} else { } else {
@ -467,7 +478,7 @@ sub readproto($) {
local *FILE; local *FILE;
my %func; my %func;
sysopen(FILE, $fn, O_RDONLY) open(FILE, "<", "$fn")
or die("$fn: open(): $!\n"); or die("$fn: open(): $!\n");
while (<FILE>) { while (<FILE>) {
if (m/^\.Nm ((?:open)?pam_.*?)\s*$/) { if (m/^\.Nm ((?:open)?pam_.*?)\s*$/) {
@ -494,10 +505,11 @@ sub gensummary($) {
my $func; my $func;
my %xref; my %xref;
sysopen(FILE, "$page.3", O_RDWR|O_CREAT|O_TRUNC) open(FILE, ">", "$page.3")
or die("$page.3: $!\n"); or die("$page.3: $!\n");
$upage = uc($page); $page =~ m/(\w+)$/;
$upage = uc($1);
print FILE "$COPYRIGHT print FILE "$COPYRIGHT
.Dd $TODAY .Dd $TODAY
.Dt $upage 3 .Dt $upage 3
@ -570,7 +582,7 @@ as part of the DARPA CHATS research program.
sub usage() { sub usage() {
print(STDERR "usage: gendoc [-s] source [...]\n"); print(STDERR "usage: gendoc [-op] source [...]\n");
exit(1); exit(1);
} }
@ -579,7 +591,7 @@ MAIN:{
usage() usage()
unless (@ARGV && getopts("op", \%opts)); unless (@ARGV && getopts("op", \%opts));
setlocale(LC_ALL, "en_US.ISO8859-1"); setlocale(LC_ALL, "en_US.UTF-8");
$TODAY = strftime("%B %e, %Y", localtime(time())); $TODAY = strftime("%B %e, %Y", localtime(time()));
$TODAY =~ s,\s+, ,g; $TODAY =~ s,\s+, ,g;
if ($opts{'o'} || $opts{'p'}) { if ($opts{'o'} || $opts{'p'}) {