6 use POSIX
":sys_wait_h";
9 http://tools.ietf.org/html/rfc1951#section-3.2
10 5 Bits: HLIT, # of Literal/Length codes - 257 (257 - 286)
11 5 Bits: HDIST, # of Distance codes - 1 (1 - 32)
12 4 Bits: HCLEN, # of Code Length codes - 4 (4 - 19)
16 ? bytes compressed data
18 4 bytes uncompressed input size modulo 2^32
20 my $minGZ=10; # (5+5+4)b + 8 byte
23 #$Str=v0 if $Str eq '';
24 if (length $Str <= $minGZ) {
28 my ($pid,$chld_out, $chld_in);
31 $pid = open2
($chld_out, $chld_in, 'gzip','-6nc');
32 unless (defined $pid) {
33 warn "[!]Cannot fork gzip: $!";
34 die "[x]Bailing out" if $sleep_count++ > 6;
40 local $/; # enable "slurp" mode
43 $_[1] = substr $Bin,10;
47 my $GZHeader = v31
.139
.8.0.0.0.0.0.0.3; # -9 => 2.3; -2~8 => 0.3
48 #cat t.pl|while read a;do echo "$a"|gzip -6nc|hexdump -C;done
49 #00000000 1f 8b 08 00 00 00 00 00 00 03 e3 02 00 93 06 d7
52 if (length $Bin <= $minGZ) {
56 my ($pid,$chld_out, $chld_in);
59 $pid = open2
($chld_out, $chld_in, 'gzip','-dc');
60 unless (defined $pid) {
61 warn "[!]Cannot fork gzip: $!";
62 die "[x]Bailing out" if $sleep_count++ > 6;
66 print $chld_in $GZHeader,$Bin;
68 local $/; # enable "slurp" mode
78 $kid = waitpid(-1, WNOHANG
);
85 pid_t waitpid(pid_t pid, int *status, int options);
86 The value of pid can be:
88 < -1 meaning wait for any child process whose process group ID is
89 equal to the absolute value of pid.
91 -1 meaning wait for any child process.
93 0 meaning wait for any child process whose process group ID is
94 equal to that of the calling process.
96 > 0 meaning wait for the child whose process ID is equal to the
99 The value of options is an OR of zero or more of the following conĀ©\
102 WNOHANG return immediately if no child has exited.
104 WUNTRACED also return if a child has stopped (but not traced via
105 ptrace(2)). Status for traced children which have stopped
106 is provided even if this option is not specified.
108 WCONTINUED (since Linux 2.6.10)
109 also return if a stopped child has been resumed by delivery
114 my($chld_out, $chld_in);
116 my ($a,$b,$c,$sumA,$sumB);
117 open IN
,'<',$ARGV[0] or die "$!";
124 deCompress
($ttt,$aaa);
127 print int(1000*$b/$a)/10," %\t$a\t$b\t$c,[$aaa]\n" if $a > 0;
128 $sumA += $a; $sumB += $b;
130 #waitGout() unless $i % 100;
137 print '-'x75
,"\n",int(10000*$sumB/$sumA)/100," %\t$sumA\t$sumB\n";