# For details, see the HELM World-Wide-Web page,
# http://cs.unibo.it/helm/.
+#use strict;
+
my $VERSION = "@VERSION@";
+# various variables
+my ($HELM_LIB_PATH);
+my (%map);
+
# First of all, let's load HELM configuration
use Env;
my $HELM_LIB_DIR = $ENV{"HELM_LIB_DIR"};
require $HELM_LIB_PATH;
# Let's override the configuration file
-$style_dir = $ENV{"HELM_STYLE_DIR"} if (defined ($ENV{"HELM_STYLE_DIR"}));
-$dtd_dir = $ENV{"HELM_DTD_DIR"} if (defined ($ENV{"HELM_DTD_DIR"}));
+my $style_dir = $ENV{"HELM_STYLE_DIR"} if (defined ($ENV{"HELM_STYLE_DIR"}));
+my $dtd_dir = $ENV{"HELM_DTD_DIR"} if (defined ($ENV{"HELM_DTD_DIR"}));
use HTTP::Daemon;
use HTTP::Status;
sub gzip { # gzip the content argument and save it to filename argument
my ($cont, $filename) = @_;
+ #my $debug=1; # debug only
- my ($gz, $cont);
-
- $gz = gzopen($filename, "w")
+ print "gzopening $filename ...\n" if (defined($debug));
+ my $gz = gzopen($filename, "w")
or die "Cannot gzopen for writing file $filename: $gzerrno";
- $gz->gzwrite($cont) or die "error writing: $gzerrno\n" ;
+ print "gzwriting ...\n" if (defined($debug));
+ $gz->gzwrite($cont) or die "error writing: $gzerrno, exiting!\n";
+ print "gzclosing ...\n" if (defined($debug));
$gz->gzclose();
}
my ($remove_headers,$str,$url,$filename) = @_;
my ($gz, $buffer);
+ #my $debug=1; # for DEBUG only
+
my $resourcetype; # retrieve mode: "normal" (.xml) or "gzipped" (.xml.gz)
if ($filename =~ /\.xml$/) { # set retrieve mode
$resourcetype = "normal";
# <ZACK/> TODO: inefficent, I haven't yet undestood how to deflate
# in memory gzipped file, without call "gzopen"
print "Storing the $str file\n";
+ print "Making dirs ...\n" if (defined($debug));
mkdirs($filename);
+ print "Opening tmp file for writing ...\n" if (defined($debug));
open(FD, ">".$filename.".tmp") or die "Cannot open $filename.tmp\n";
+ print "Writing on tmp file ...\n" if (defined($debug));
print FD $cont;
+ print "Closing tmp file ...\n" if (defined($debug));
close(FD);
# handle cache conversion normal->gzipped or gzipped->normal as user choice
+ print "cachemode:$cachemode, resourcetype:$resourcetype\n" if (defined($debug));
if (($cachemode eq 'normal') and ($resourcetype eq 'normal')) {
# cache the file as is
rename "$filename.tmp", $filename;
unlink "$filename.tmp"; # delete old gzipped file
} elsif (($cachemode eq 'gzipped') and ($resourcetype eq 'normal')) {
# compress cache entry
+ print "gzipping ...\n" if (defined($debug));
gzip($cont, $basefname.".gz");
unlink "$filename.tmp"; # delete old uncompressed file
} else {