source: openpam/trunk/misc/gendoc.pl @ 44

Last change on this file since 44 was 44, checked in by Dag-Erling Smørgrav, 19 years ago

Wording tweak.

Sponsored by: DARPA, NAI Labs

File size: 5.0 KB
Line 
1#!/usr/bin/perl -w
2#-
3# Copyright (c) 2002 Networks Associates Technologies, Inc.
4# All rights reserved.
5#
6# This software was developed for the FreeBSD Project by ThinkSec AS and
7# NAI Labs, the Security Research Division of Network Associates, Inc.
8# under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
9# DARPA CHATS research program.
10#
11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions
13# are met:
14# 1. Redistributions of source code must retain the above copyright
15#    notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright
17#    notice, this list of conditions and the following disclaimer in the
18#    documentation and/or other materials provided with the distribution.
19# 3. The name of the author may not be used to endorse or promote
20#    products derived from this software without specific prior written
21#    permission.
22#
23# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33# SUCH DAMAGE.
34#
35# $Id$
36#
37
38use strict;
39use Fcntl;
40use POSIX qw(strftime);
41use vars qw($COPYRIGHT $TODAY %FUNCTIONS);
42
43sub gendoc($) {
44    my $fn = shift;
45
46    local *FILE;
47    my $source;
48    my $mdoc;
49    my $func;
50    my $descr;
51    my $type;
52    my $args;
53    my $name;
54
55    if ($fn !~ m,\.c$,) {
56        warn("$fn: not C source, ignoring\n");
57        return;
58    }
59   
60    sysopen(FILE, $fn, O_RDONLY)
61        or die("$fn: open(): $!\n");
62    $source = join('', <FILE>);
63    close(FILE);
64
65    if ($source =~ m,^(/\*-\n.*?)\s*\*/,s) {
66        $mdoc = $1;
67        $mdoc =~ s,^.\*,.\\\",gm;
68        $mdoc .= "\n.\\\"\n";
69        $COPYRIGHT = $mdoc;
70    } else {
71        $mdoc = ".\\\" \$" . "Id" . "\$\n";
72    }
73    $func = $fn;
74    $func =~ s,^(?:.*/)?([^/]+)\.c$,$1,;
75    if ($source !~ m,\n \* ([\S ]+)\n \*/\n\n([\S ]+)\n$func\((.*?)\)\n\{,s) {
76        warn("$fn: can't find $func\n");
77        return;
78    }
79    ($descr, $type, $args) = ($1, $2, $3);
80    $descr =~ s,^([A-Z][a-z]),lc($1),e;
81    $descr =~ s,[\.\s]*$,,;
82    while ($args =~ s/^((?:[^\(]|\([^\)]*\))*),\s*/$1\" \"/g) {
83        # nothing
84    }
85    $args =~ s/,\s+/, /gs;
86    $args = "\"$args\"";
87
88    $FUNCTIONS{$func} = [ $type, $args ];
89   
90    $mdoc .= ".Dd $TODAY
91.Dt " . uc($func) . " 3
92.Os
93.Sh NAME
94.Nm $func
95.Nd $descr
96.Sh LIBRARY
97.Lb libpam
98.Sh SYNOPSIS
99.In security/pam_appl.h
100.Ft $type
101.Fn $func $args
102.Sh DESCRIPTION
103The
104.Nm
105function is not yet documented.
106.Sh RETURN VALUES
107The
108.Fn
109function returns one of the following values:
110.Bl -tag -width PAM_AUTHTOK_DISABLE_AGING
111.El
112.Sh SEE ALSO
113.Xr pam_strerror 3 ,
114.Xr pam 3
115.Sh STANDARDS
116.Rs
117.%T \"X/Open Single Sign-On Service (XSSO) - Pluggable Authentication Modules\"
118.%D \"June 1997\"
119.Re
120.Sh AUTHORS
121The
122.Nm
123function and this manual page were developed for the FreeBSD Project
124by ThinkSec AS and NAI Labs, the Security Research Division of Network
125Associates, Inc.  under DARPA/SPAWAR contract N66001-01-C-8035
126.Pq Dq CBOSS ,
127as part of the DARPA CHATS research program.
128";
129
130     $fn = "$func.3";
131     sysopen(FILE, $fn, O_RDWR|O_CREAT|O_TRUNC)
132        or die("$fn: open(): $!\n");
133     print(FILE $mdoc);
134     close(FILE);
135}
136
137sub gensummary() {
138
139    print "$COPYRIGHT";
140    print ".Dd $TODAY
141.Dt PAM 3
142.Os
143.Sh NAME
144";
145    my @funcs = sort(keys(%FUNCTIONS));
146    while (@funcs) {
147        print ".Nm " . shift(@funcs) . (@funcs ? " ,\n" : "\n");
148    }
149    print ".Nd Pluggable Authentication Modules Library
150.Sh LIBRARY
151.Lb libpam
152.Sh SYNOPSIS
153.In security/pam_appl.h
154";
155    foreach my $func (sort(keys(%FUNCTIONS))) {
156        print ".Ft $FUNCTIONS{$func}->[0]\n";
157        print ".Fn $func $FUNCTIONS{$func}->[1]\n";
158    }
159    print ".Sh DESCRIPTION
160.Sh RETURN VALUES
161.Sh SEE ALSO
162";
163    foreach my $func (sort(keys(%FUNCTIONS))) {
164        print ".Xr $func 3 ,\n";
165    }
166    print ".Xr pam.conf 5
167.Sh STANDARDS
168.Rs
169.%T \"X/Open Single Sign-On Service (XSSO) - Pluggable Authentication Modules\"
170.%D \"June 1997\"
171.Re
172.Sh AUTHORS
173The OpenPAM library and this manual page were developed for the
174FreeBSD Project by ThinkSec AS and NAI Labs, the Security Research
175Division of Network Associates, Inc.  under DARPA/SPAWAR contract
176N66001-01-C-8035
177.Pq Dq CBOSS ,
178as part of the DARPA CHATS research program.
179"
180}
181
182MAIN:{
183    $TODAY = strftime("%B %e, %Y", localtime(time()));
184    $TODAY =~ s,\s+, ,g;
185    foreach my $fn (@ARGV) {
186        gendoc($fn);
187    }
188    gensummary();
189}
Note: See TracBrowser for help on using the repository browser.