summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/examples
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/examples')
-rw-r--r--gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/examples/filtdef27
-rw-r--r--gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/examples/filtinf29
2 files changed, 56 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/examples/filtdef b/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/examples/filtdef
new file mode 100644
index 00000000000..6046498692c
--- /dev/null
+++ b/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/examples/filtdef
@@ -0,0 +1,27 @@
+#!/usr/local/bin/perl
+
+use Compress::Raw::Zlib ;
+
+use strict ;
+use warnings ;
+
+binmode STDIN;
+binmode STDOUT;
+
+my $x = new Compress::Raw::Zlib::Deflate()
+ or die "Cannot create a deflation stream\n" ;
+
+my $output = '' ;
+
+while (<>)
+{
+ $x->deflate($_, $output) == Z_OK
+ or die "deflate failed\n" ;
+
+ print $output ;
+}
+
+$x->flush($output) == Z_OK
+ or die "flush failed\n" ;
+
+print $output ;
diff --git a/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/examples/filtinf b/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/examples/filtinf
new file mode 100644
index 00000000000..0662c142bcf
--- /dev/null
+++ b/gnu/usr.bin/perl/cpan/Compress-Raw-Zlib/examples/filtinf
@@ -0,0 +1,29 @@
+#!/usr/local/bin/perl
+
+use Compress::Raw::Zlib ;
+
+use strict ;
+use warnings ;
+
+binmode STDIN;
+binmode STDOUT;
+
+my $x = new Compress::Raw::Zlib::Inflate
+ or die "Cannot create a inflation stream\n" ;
+
+my $input = '' ;
+my $output = '' ;
+my $status ;
+
+while (read(STDIN, $input, 4096))
+{
+ $status = $x->inflate($input, $output) ;
+
+ 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 ;