#
# rebuild_ccfindex
#
# Usage: rebuild_ccfindex *.ccf
#
# Takes a list of Chimera cache files on the command line
# and writes a new cache index file to stdout.
#
# 27jan97
#

print <<EndOfHTML;
<html>
<head>
<title>Chimera Cache Index</title>
</head>

<body>
<h1>Chimera Cache Index</h1>

<ul>
EndOfHTML

for ($i=0; $i<=$#ARGV; $i++) {
        if (!open(CCF, "<$ARGV[$i]")) {
                warn "$ARGV[$i]: $!";
                next;
        }
        chop($url = <CCF>);
        close(CCF);
        $url =~ s/^x-url: //;

        $cid = $ARGV[$i];
        $cid =~ s/.*\///;
        $cid =~ s/\.ccf$//;

        $size = (stat($ARGV[$i]))[7];

        print "<li> <a size=$size cid=$cid href=\"$url\">$url</a>\n";
}
print "</ul>\n</body>\n</html>\n";
exit(0);
