-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathzlib
executable file
·80 lines (58 loc) · 1.26 KB
/
zlib
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl
#
# Perl script (zlib.pl) to inflate and deflate AppleHDA resource files in Mountain Lion DP3 and greater.
#
# Version 0.1 - Copyright (c) 2012 by RevoGirl <[email protected]>
#
use strict;
use warnings;
use Compress::Zlib;
my $data = '';
my ($output, $status);
binmode STDOUT;
sub inflate
{
my $x = inflateInit() or die "Cannot create a inflation stream\n";
if (open(FILE, $ARGV[1]))
{
binmode FILE;
while (read(FILE, $data, 4096))
{
($output, $status) = $x->inflate(\$data);
print $output if $status == Z_OK or $status == Z_STREAM_END;
last if $status != Z_OK;
}
close (FILE);
die "inflation failed\n" unless $status == Z_STREAM_END;
}
}
sub deflate
{
my $x = deflateInit() or die "Cannot create a deflation stream\n";
if (open(FILE, $ARGV[1]))
{
binmode FILE;
while (read(FILE, $data, 4096))
{
($output, $status) = $x->deflate(\$data);
$status == Z_OK or die "deflation failed\n";
print $output;
}
($output, $status) = $x->flush();
$status == Z_OK or die "deflation failed\n";
print $output;
}
}
sub main()
{
if ($ARGV[0] eq "inflate")
{
inflate()
}
if ($ARGV[0] eq "deflate")
{
deflate()
}
}
main();
exit(0);