On Linux with Mozilla (this should also work with Netscape 4.x) you can register your application by creating a new entry with the correct mime_type/extension in the Edit/Preferences/Navigator/HelperApp menu.
When mozilla find a registered file type, it download the file into /tmp, then launch your application and pass this file as the first argument.
Here is a simple helper application that will log the filename and its content to the $HOME/helper.log file :
#!/usr/bin/perl -w
use strict;
# get the filename (/tmp/xxx)
my $file = shift;
# open a log file
open(LOG, ">>$ENV{HOME}/helper.log") or die "Oops : $!\n";
print LOG "Got file $file\n";
# open the file downloaded by mozilla
if( not open(FILE, "<$file") ) {
print LOG "Error opening file $file\n";
close LOG;
exit 1;
}
# read the whole file
undef $/;
my $content = <FILE>;
print LOG "Content {\n$content\n}\n";
close FILE;
close LOG;
Another way would be to use something like Plugger, that allow you to register an application that will work like a plugin, and allow you to access the content like a stream.
|