Index: /trunk/gsdl/bin/script/import.pl
===================================================================
--- /trunk/gsdl/bin/script/import.pl	(revision 1268)
+++ /trunk/gsdl/bin/script/import.pl	(revision 1269)
@@ -56,4 +56,6 @@
     print STDERR "                          directory -- use with care\n";
     print STDERR "   -gzip                  Use gzip to compress resulting gml documents\n";
+    print STDERR "                          (don't forget to include ZIPPlug in your plugin\n";
+    print STDERR "                          list when building from compressed documents)\n";
     print STDERR "   -maxdocs number        Maximum number of documents to import\n";
     print STDERR "   -groupsize number      Number of GML documents to group into one file\n";
Index: /trunk/gsdl/perllib/plugins/GMLPlug.pm
===================================================================
--- /trunk/gsdl/perllib/plugins/GMLPlug.pm	(revision 1268)
+++ /trunk/gsdl/perllib/plugins/GMLPlug.pm	(revision 1269)
@@ -49,5 +49,5 @@
     my $self = shift (@_);
 
-    return q^(?i)\.gml(\.gz)?$^;
+    return q^(?i)\.gml?$^;
 }
 
@@ -72,22 +72,7 @@
     $parent_dir = &util::filename_cat ($base_dir, $parent_dir);
 
-    # all this gzip stuff should one day be replaced by a gzip/bzip/zip/tar
-    # handling plugin
-    my $gz = 0;
-    if ($file =~ /\.gz$/i) {
-	$gz = 1;
-    }
-
-    # read in the document - input is assumed throughout this plugin to already be utf8
-    if ($gz) {
-	if (!open (INFILE, "zcat $filename |")) {
-	    print STDERR "GMLPlug::read - zcat couldn't read $filename\n";
-	    return 0;
-	}
-    } else {
-	if (!open (INFILE, $filename)) {
-	    print STDERR "GMLPlug::read - couldn't read $filename\n";
-	    return 0;
-	}
+    if (!open (INFILE, $filename)) {
+	print STDERR "GMLPlug::read - couldn't read $filename\n";
+	return 0;
     }
 
Index: /trunk/gsdl/perllib/plugins/ZIPPlug.pm
===================================================================
--- /trunk/gsdl/perllib/plugins/ZIPPlug.pm	(revision 1269)
+++ /trunk/gsdl/perllib/plugins/ZIPPlug.pm	(revision 1269)
@@ -0,0 +1,144 @@
+###########################################################################
+#
+# ZIPPlug.pm --
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 1999 New Zealand Digital Library Project
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+# plugin which handles compressed and/or archived input formats
+#
+# currently handled formats and file extensions are:
+# 
+# gzip (.gz, .z, .tgz, .taz)
+# bzip (.bz)
+# zip (.zip)
+# tar (.tar)
+#
+# this plugin relies on the following utilities being present 
+# (if trying to process the corresponding formats)
+#
+# gunzip (for gzip)
+# bunzip (for bzip)
+# unzip (for zip)
+# tar (for tar) 
+
+package ZIPPlug;
+
+use BasPlug;
+use plugin;
+use util;
+use Cwd;
+
+
+BEGIN {
+    @ISA = ('BasPlug');
+}
+
+use strict;
+
+sub new {
+    my ($class) = @_;
+    my $self = new BasPlug ("ZIPPlug", @_);
+
+    return bless $self, $class;
+}
+
+# this is a recursive plugin
+sub is_recursive {
+    my $self = shift (@_);
+
+    return 1;
+}
+
+# return number of files processed, undef if can't process
+# Note that $base_dir might be "" and that $file might 
+# include directories
+sub read {
+    my $self = shift (@_);
+    my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs) = @_;
+
+    if ($file =~ /\.(gz|tgz|z|taz|bz|zip|tar)$/i) {
+
+	my $filename = &util::filename_cat ($base_dir, $file);
+	if (!-e $filename) {
+	    print STDERR "ZIPPLug: WARNING: $filename does not exist\n";
+	    return undef;
+	}
+	
+	my ($file_only) = $file =~ /([^\\\/]*)$/;
+	my $tmpdir = &util::get_tmp_filename ();
+	&util::mk_all_dir ($tmpdir);
+
+	print STDERR "ZIPPlug: extracting $file_only to $tmpdir\n";
+
+	# save current working directory
+	my $cwd = cwd();
+	chdir ($tmpdir) || die;
+	&util::cp ($filename, $tmpdir);
+	
+	if ($file =~ /\.bz$/i) {
+	    $self->bunzip ($file_only);
+	} elsif ($file =~ /\.zip$/i) {
+	    $self->unzip ($file_only);
+	} elsif ($file =~ /\.tar$/i) {
+	    $self->untar ($file_only);
+	} else {
+	    $self->gunzip ($file_only);
+	}
+
+	chdir ($cwd) || die;
+
+	my $numdocs = &plugin::read ($pluginfo, "", $tmpdir, $metadata, $processor, $maxdocs);
+	&util::rm_r ($tmpdir);
+	return $numdocs;
+
+    } else {
+	return undef;
+    }
+}
+
+sub bunzip {
+    my $self = shift (@_);
+    my ($file) = @_;
+    system ("bunzip $file");
+}
+
+sub unzip {
+    my $self = shift (@_);
+    my ($file) = @_;
+    system ("unzip $file");
+    &util::rm ($file) if -e $file;
+}
+
+sub untar {
+    my $self = shift (@_);
+    my ($file) = @_;
+    system ("tar xf $file");
+    &util::rm ($file) if -e $file;
+}
+
+sub gunzip {
+    my $self = shift (@_);
+    my ($file) = @_;
+    system ("gunzip $file");
+}
+
+1;
