#!/usr/bin/perl
###############

use FindBin qw{$Bin};

my $outputdir = shift() || usage();
my $len = int(shift()) || 65537;
my %protos = ();
my $ready;

select(STDERR); $|++;

if (!chdir($outputdir))
{
    mkdir($outputdir, 0700) || die "could not create output directory: $!";
    chdir($outputdir) || die "could not change to output directory: $!";
}

print STDERR ":: creating data files...\n";
while (<DATA>)
{
    chomp();
    open (HTML, ">". $_ . ".html") || die "could not open file: $!"; 
    print HTML "<a href=\"$_:/" . ("A" x $len)  . "\">TEST</a>\n";
    close (HTML);
  
    $protos{"$_"} = "$_.html";
}

print STDERR ":: ".scalar(keys(%protos))." files created.\n";

foreach $protocol (keys(%protos))
{
    print STDERR ":: protocol $protocol ? ";
    $ready = <STDIN>;
    system("konqueror", $protos{$protocol});
}

exit(0);

sub usage {
    print STDERR "\nusage: $0 <output directory> [url len]\n\n";
    exit(1);
}

__DATA__
audiocd
bzip
bzip2
file
finger
floppy
ftp
gopher
gzip
help
http
https
imap4
imaps
info
kmailservice
knewsservice
lan
man
nfs
nntp
pop3
pop3s
rlan
rlogin
smb
tar
telnet
thumbnail
