Add perl scripts to auto-magically convert the RADIUS RFC's
authoraland <aland>
Tue, 9 Jul 2002 20:48:49 +0000 (20:48 +0000)
committeraland <aland>
Tue, 9 Jul 2002 20:48:49 +0000 (20:48 +0000)
to cross-indexed HTML.

doc/rfc/Makefile [new file with mode: 0644]
doc/rfc/genref.pl [new file with mode: 0755]
doc/rfc/rewrite.pl [new file with mode: 0755]

diff --git a/doc/rfc/Makefile b/doc/rfc/Makefile
new file mode 100644 (file)
index 0000000..f16168b
--- /dev/null
@@ -0,0 +1,11 @@
+RFC    = rfc2865.txt rfc2866.txt rfc2867.txt rfc2868.txt rfc2869.txt \
+         rfc3162.txt 
+
+all: refs
+       ./rewrite.pl $(RFC)
+
+refs: $(RFC)
+       ./genref.pl $(RFC) > refs
+
+clean:
+       rm -f refs *.html
diff --git a/doc/rfc/genref.pl b/doc/rfc/genref.pl
new file mode 100755 (executable)
index 0000000..6ab0ab1
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+foreach $file (@ARGV) {
+    open FILE, "<$file" || die "Error opening $file: $!\n";
+
+    $ref = $file;
+    $ref =~ s/\..*//g;
+
+    while (<FILE>) {
+       next if (!/^(\d+\.)+\s+([a-zA-Z]+-)+[a-zA-Z]/);
+
+       chop;
+       split;
+       print $ref, "\t", $_[1], "\n";
+    }
+
+    close FILE;
+}
diff --git a/doc/rfc/rewrite.pl b/doc/rfc/rewrite.pl
new file mode 100755 (executable)
index 0000000..78d7be1
--- /dev/null
@@ -0,0 +1,155 @@
+#!/usr/bin/perl
+
+#
+#   Read in the references, and put into an associative array
+#
+open FILE, "<refs" || die "Error opening refs: $!\n";
+while (<FILE>) {
+    chop;
+    split;
+    
+    $refs{$_[1]} = $_[0];
+}
+close FILE;
+
+#
+#  now loop over the input RFC's.
+#
+foreach $file (@ARGV) {
+    open FILE, "<$file" || die "Error opening $file: $!\n";
+
+    $attribute = "zzzzz";
+
+    # get the current reference
+    $ref = $file;
+    $ref =~ s/\..*//g;
+       
+    open OUTPUT, ">$ref.html" || die "Error creating $ref.html: $!\n";
+
+    #
+    #  Print out the HTML header
+    #
+    print OUTPUT <<EOF;
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<HTML>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Perl">
+   <title>$ref.html</title>
+</head>
+<body>
+<PRE>
+
+EOF
+
+    #  loop over the input file
+    while (<FILE>) {
+       # html-ize it
+       s/&/&amp;/g;
+       s/</&lt;/g;
+       s/>/&gt;/g;
+       
+       if (/\[Page/) {
+           print OUTPUT;
+           next;
+       }
+       
+       if (/^RFC \d+/) {
+           print OUTPUT;
+           next;
+       }
+       
+       chop;
+       
+       #
+       #  Attribute name header.
+       #
+       if (/^\d+\./) {
+           split;
+
+           if ($refs{$_[1]} ne "") {
+               $attribute = $_[1];
+               
+               print OUTPUT "<A NAME=\"$attribute\"><H2>$_[0] $attribute</H2></a>\n";
+               
+           } else {
+               print OUTPUT "<H2>$_</H2>\n";
+               $attribute = "zzzz";
+           }
+           next;
+       }
+
+       #
+       #  Mark these up special.
+       #
+       if ((/^   Description/) ||
+           (/^   Type/) ||
+           (/^   Length/) ||
+           (/^   Value/)) {
+           print OUTPUT "<B>$_</B>\n";
+           next;
+       }
+       
+       # Make the current attribute name bold
+       s/$attribute/<B>$attribute<\/B>/g;
+
+       split;
+
+       #
+       #  Re-write the output with links to where-ever
+       #
+       foreach $word (@_) {
+           $word =~ s/[^-a-zA-Z]//g;
+
+           if ($refs{$word} ne "") {
+               if ($refs{$word} eq $ref) {
+                   s/$word/<A HREF="#$word">$word<\/A>/g;
+               } else {
+                   s/$word/<A HREF="$refs{$word}.html#$word">$word<\/A>/g;
+               }
+           }
+       }
+
+       print OUTPUT $_, "\n";
+    }
+
+    print OUTPUT "</PRE>\n";
+    print OUTPUT "</BODY>\n";
+    close OUTPUT;
+    close FILE;
+}
+
+#
+#  And finally, create the index.
+#
+open OUTPUT, ">index.html" || die "Error creating index.html: $!\n";
+
+#
+#  Print out the HTML header
+#
+print OUTPUT <<EOF;
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<HTML>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Perl">
+   <title>$ref.html</title>
+</head>
+<body>
+
+<H2>RADIUS Attribute List</H2>
+EOF
+
+$letter = "@";
+
+foreach $key (sort keys %refs) {
+    if (substr($key,0,1) ne $letter) {
+       $letter = substr($key,0,1);
+       print OUTPUT "\n<H3>$letter</H3>\n\n";
+    }
+    
+    print OUTPUT "<A HREF=\"$refs{$key}.html#$key\">$key</A><BR>\n";
+}
+
+print OUTPUT "</BODY>\n";
+close OUTPUT;