import from branch_1_1:
[freeradius.git] / doc / rfc / per-rfc.pl
1 #!/usr/bin/env perl
2
3 #
4 #   Read in the references, and put into an associative array
5 #
6 open FILE, "<refs" || die "Error opening refs: $!\n";
7 while (<FILE>) {
8     chop;
9     split;
10     
11     $refs{$_[1]} = $_[0];
12     $defs{$_[0]}{$_[1]}++;
13 }
14 close FILE;
15
16 #
17 #  now loop over the input RFC's.
18 #
19 foreach $file (@ARGV) {
20     $def=$file;
21     $def =~ s/\.txt//;
22
23     $attribute = "zzzzz";
24
25     # get the current reference
26     $ref = $file;
27     $ref =~ s/\..*//g;
28     $rfc = $ref;
29     $ref = "attributes-$ref";
30
31     open OUTPUT, ">$ref.html" || die "Error creating $ref.html: $!\n";
32
33     #
34     #  Print out the HTML header
35     #
36     print OUTPUT <<EOF;
37 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
38 <HTML>
39 <head>
40    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
41    <meta name="GENERATOR" content="Perl">
42    <title>$rfc Index of Attributes</title>
43 </head>
44 <body>
45 <h1>$rfc Attribute List</h1>
46 EOF
47
48   $letter = "@";
49
50   foreach $key (sort keys %{$defs{$def}}) {
51     if (substr($key,0,1) ne $letter) {
52       print OUTPUT "</UL>\n" if ($letter ne "@");
53       $letter = substr($key,0,1);
54       print OUTPUT "\n<H3>$letter</H3>\n\n";
55       print OUTPUT "<UL>\n";
56     }
57     
58     print OUTPUT "<A HREF=\"$refs{$key}.html#$key\">$key</A><BR />\n";
59
60   }
61
62   print OUTPUT "</UL>\n";
63   print OUTPUT "</BODY>\n";
64   close OUTPUT;
65 }