summaryrefslogtreecommitdiff
path: root/zlibcat
blob: 71ebb4a1be080e39ad84d00a1e23643cbe103b9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 ;
};