summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2006-02-08 03:26:27 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2006-02-08 03:26:27 +0000
commitd94bc29f52de81d373ae910cde980dc209a5b0eb (patch)
tree4d5414e01a59150a62316865dd1ce25f2c6bf1c1
parent500b8b393be54ef65546f223daf3c531547e56ea (diff)
Add zlibcat
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@55 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
-rwxr-xr-xzlibcat24
1 files changed, 24 insertions, 0 deletions
diff --git a/zlibcat b/zlibcat
new file mode 100755
index 0000000..71ebb4a
--- /dev/null
+++ b/zlibcat
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Compress::Zlib;
+
+
+for my $file (@ARGV) {
+ my $x = inflateInit() or die "Cannot create a inflation stream\n" ;
+
+ my $input = '';
+
+ my ($output, $status);
+ open(FH, "<$file") or die ("Cannot open $file: $!\n");
+ while (read(FH, $input, 4096))
+ {
+ ($output, $status) = $x->inflate(\$input);
+
+ print $output if $status == Z_OK or $status == Z_STREAM_END ;
+
+ last if $status != Z_OK ;
+ }
+
+ die "inflation failed\n" unless $status == Z_STREAM_END ;
+};