File: filtdef

package info (click to toggle)
libfilter-perl 1.50-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 612 kB
  • ctags: 759
  • sloc: perl: 654; makefile: 8
file content (37 lines) | stat: -rwxr-xr-x 724 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl

use strict ;
use warnings ;

my ($file, $output, $status) ;

use Compress::Zlib ;

die "Create a decompressor for a pl.gz\nUsage: filtdef file > filtfile\n"
    unless @ARGV == 1;

foreach $file (@ARGV) 
{
    open (F, "<$file") or die "Cannot open $file: $!\n" ;
    my $x = deflateInit()
       or die "Cannot create a deflation stream\n" ;

    print "use Filter::Decompress;\n" ;
    while (<F>)
    {
        ($output, $status) = $x->deflate($_) ;
    
        $status == Z_OK
            or die "deflation failed\n" ;
    
        print $output ;
    }
    
    ($output, $status) = $x->flush() ;
    
    $status == Z_OK
        or die "deflation failed\n" ;
    
    print $output ;
    close F ;
}