#!/usr/bin/perl #--------------------------------------------------------- # infocat #--------------------------------------------------------- # # PURPOSE # This perl script prints a catalog of the info files # available via info2html at this site. # # AUTHOR # Jon Howell # # HISTORY # 1997.05.16 V 1.0 # 1998.05.05 V 1.2 became part of info2html distribution # Jon Howell # 2003.09.28 V 1.4dcm changed the output to be easily parsable # instead of being HTML - for Documancer # Vaclav Slavik # #------------------------------------------------------- # set here the full path of the info2html.conf $VERSION = "1.4dcm"; $INFO2HTMLCONF = "helpers/info2html/info2html.conf"; require($INFO2HTMLCONF); #-- configuration settings use CGI; #-- patterns $NODEBORDER = '\037\014?'; #-- delimiter of an info node $REDIRSEP = '\177'; #-- delimiter in tag tables $WS = '[ \t]+'; #-- white space + $WSS = '[ \t]*'; #-- white space * $TE = '[\t\,\.\n]'; #-- end of a tag $TAG = '[^\t\,\.\n]+'; #-- pattern for a tag $FTAG = '[^\)]+'; #-- pattern for a file name in #-- a cross reference #--------------------------------------------------------- # Escape #--------------------------------------------------------- # This procedures escapes some special characeters. The # escape sequence follows the WWW guide for escaped # characters in URLs #--------------------------------------------------------- sub Escape{ local($Tag) = @_; #-- escaping is not needed anymore KG/28.6.94 # $Tag =~ s/ /%20/g; # space # $Tag =~ s/\+/%AB/g; # + #-- oh yes it is -- jonh 5/16/97 #$Tag; return CGI::escape($Tag); } #---------------------------------------------------------- # DeEscape #---------------------------------------------------------- sub DeEscape{ local($Tag) = @_; #-- deescaping is not needed anymore. KG/28.6.94 #$Tag =~ s/%AB/+/g; #$Tag =~ s/%20/ /g; #-- yes it is jonh 5/16/97 #$Tag; return CGI::unescape($Tag); } # #------------------- MAIN ----------------------------- # #print CGI::header('-type'=>'text/html', # '-expires'=>60*60*24); # expires each day, in case I add new .info files # to the @INFODIR path. # -- jonh 1998.05.04 # Collect them all into an array that can be sorted foreach $dir (@INFODIR) { opendir DIR, $dir; while ($infofile = readdir(DIR)) { if ($infofile =~ m/.info.bz2$/ ) { open INFOFILE, "bzcat $dir/$infofile|"; $collect = 0; } elsif ($infofile =~ m/.info.gz$/ ) { open INFOFILE, "gzip -dc $dir/$infofile|"; $collect = 0; } elsif ($infofile =~ m/.info$/) { open INFOFILE, $dir."/".$infofile; $collect = 0; } else { next; } $filedesc = ""; while () { last if (m/END-INFO-DIR-ENTRY/); s/^\* //; if ($collect and not ($_ =~ m/^[\s\n]*$/)) { $filedesc .= "" if ($collect < 4); $filedesc .= $_; --$collect; #$filedesc .= " ...\n" unless $collect; } $collect=4 if (m/START-INFO-DIR-ENTRY/); } close INFOFILE; $filedesc = $infofile if ($filedesc eq ""); # Add to the hash $InfoFile{$filedesc} = $infofile; #$filedesc =~ s/\n/\n/; # print "
  • $filedesc\n"; } } # Now output the list my @sorted = sort { lc($a) cmp lc($b) } keys %InfoFile; foreach my $name ( @sorted ) { print "$InfoFile{$name}/Top.html\n" . "$name\n" ; }