#!/usr/local/bin/perl -w my $RCS_Id = '$Id: nsindex.pl,v 1.1 1998/08/13 12:59:46 eserte Exp $ '; # Author : Johan Vromans # Created On : Tue Sep 15 15:59:04 1992 # Last Modified By: Johan Vromans # Last Modified On: Thu Aug 13 13:57:52 1998 # Update Count : 177 # Status : Unknown, Use with caution! ################ Common stuff ################ use strict; # Package or program libraries, if appropriate. # $LIBDIR = $ENV{'LIBDIR'} || '/usr/local/lib/sample'; # use lib qw($LIBDIR); # require 'common.pl'; # Package name. my $my_package = 'Sciurix'; # Program name and version. my ($my_name, $my_version) = $RCS_Id =~ /: (.+).pl,v ([\d.]+)/; # Tack '*' if it is not checked in into RCS. $my_version .= '*' if length('$Locker: $ ') > 12; ################ Command line parameters ################ use Getopt::Long 2.13; # Location of Netscape cache my $cachedir; # Output options, e.g. 'site' or 'date'. my @output; sub app_options(); my $verbose = 0; # verbose processing # Development options (not shown with -help). my $debug = 0; # debugging my $trace = 0; # trace (show process) my $test = 0; # test (no actual processing) app_options(); # Options post-processing. @output = qw(site date) unless @output; $trace |= ($debug || $test); ################ Presets ################ my $TMPDIR = $ENV{TMPDIR} || '/usr/tmp'; ################ The Process ################ # Register time stamp. my $ts = localtime; # Open the cache index file. use Netscape::Cache; # If cachedir is not defined, will use default from .netscape/preferences. my $cache = new Netscape::Cache (-cachedir => $cachedir); # Indexes for dates/sites seen. my %dates = (); my %sites = (); my $entries = 0; # Create temp file. my $tmp = $TMPDIR."/tp$$"; open (TMP, ">$tmp"); # Gathering phase. { my $i=-1; # entry number my $entry; # value while ( defined ($entry = $cache->next_object) ) { my $url = $entry->{URL}; $entries++; $url =~ s|^wysiwyg://\d+/||; # Decompose. my $site = ''; my $proto = ''; ($proto,$site,$url) = $url =~ m|(^[^:]+)://([^/]+)(.*)$|; $sites{$site} = 1; # register site my $file = $entry->{CACHEFILE}; my @t = localtime ($entry->{LAST_VISITED}); # access time my $date = sprintf ("%4d/%02d/%02d", 1900+$t[5], 1+$t[4], $t[3]); $dates{$date} = 1; # register date # type, e.g. text/html. #my $type = $entry->{MIME_TYPE}; my $sz = $entry->{CONTENT_LENGTH}; # Write sort record. print TMP ("$proto\t$site\t$url\t$file\t$date\t$sz\n"); } } close (TMP); # Output preamble. print STDOUT ("\n", "
\n", "\n"); } # Generate output. foreach ( @output ) { gen_sitesort_plain (), next if $_ eq 'site'; gen_datesort (), next if $_ eq 'date'; } # Trailer. print STDOUT ("
\n
\n