<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
#
# Copyright ÂŠ 2000,2001 by VA Linux Systems, Inc.
#
# Generate index files for HTML man pages.
#
# Author:	David Dawes &lt;dawes@xfree86.org&gt;
#

#
# Best viewed with tabs set to 4
#

if ($#ARGV ne 0) {
	print STDERR "Usage: mkhtmlindex.pl htmlmandir\n";
	exit 1;
}

$dir = $ARGV[0];

if (! -d $dir) {
	print STDERR "$dir is not a directory\n";
	exit 1;
}

@vollist = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "o", "l", "n", "p");

$indexprefix = "manindex";

foreach $vol (@vollist) {
	$empty = "yes";
	$indexname="$dir/$indexprefix$vol.html";

	# print "Processing volume $vol\n";

	open(mindex, "&gt;$indexname") || die "Can't create $indexname";
	opendir(dir, "$dir") || die "Can't open $dir";

	print mindex &lt;&lt;EOF;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"&gt;
&lt;TITLE&gt;X.Org Manual pages: Section $vol&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY BGCOLOR="#efefef" TEXT="black" LINK="blue" VLINK="#551A8B" ALINK="red"&gt;

&lt;H1&gt;X.Org Manual pages: Section $vol&lt;/H1&gt;
&lt;P&gt;
&lt;UL&gt;
EOF

	foreach $file (sort readdir dir) {
		if ($file =~ "\.$vol\.html") {
			open(file, "&lt;$dir/$file") || die "Can't open $dir/$file";
			while (&lt;file&gt;) {
				chop;
				if (/^&lt;[hH]2&gt;/) {
					if (! /&lt;\/[hH]2&gt;$/) {
						while (&lt;file&gt; &amp;&amp; ! /&lt;\/[hH]2&gt;$/) {
							;
						}
					}
					$heading = "";
					while (&lt;file&gt;) {
						if (/^&lt;[hH]2&gt;/) {
							last;
						}
						$heading = "$heading" . "$_";
					}
					if ($heading) {
						undef $empty;
						$heading =~ s/--/-/;
						($name, $descr) = split(/-/, $heading, 2);
						$file =~ /(.*)\.$vol\.html/;
						$fname = $1;
						$descr =~ s/&lt;[pP]&gt;//g;
						print mindex
							"&lt;LI&gt;&lt;A href=\"$file\"&gt;$fname&lt;/A&gt; - $descr&lt;/LI&gt;";
					}
					last;
				}
			}
			close file;
		}
	}

	print mindex &lt;&lt;EOF;
&lt;/UL&gt;
&lt;P&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
EOF

	close mindex;
	closedir dir;
	if (defined $empty) {
		# print "Removing empty $indexname\n";
		unlink $indexname;
	}
}
</pre></body></html>