* Created : 22nd January 1996
* Version : 2.000
*
- * Copyright (c) 1995-2012 Paul Marquess. All rights reserved.
+ * Copyright (c) 1995-2013 Paul Marquess. All rights reserved.
* This program is free software; you can redistribute it and/or
* modify it under the same terms as Perl itself.
*
#define EnDis(f) (s->flags & f ? "Enabled" : "Disabled")
- printf("DispStream 0x%p", s) ;
+ printf("DispStream %p", s) ;
if (message)
printf("- %s \n", message) ;
printf("\n") ;
printf(" stream pointer is NULL\n");
}
else {
- printf(" stream 0x%p\n", &(s->stream));
- printf(" zalloc 0x%p\n", s->stream.zalloc);
- printf(" zfree 0x%p\n", s->stream.zfree);
- printf(" opaque 0x%p\n", s->stream.opaque);
+ printf(" stream %p\n", &(s->stream));
+ printf(" zalloc %p\n", s->stream.zalloc);
+ printf(" zfree %p\n", s->stream.zfree);
+ printf(" opaque %p\n", s->stream.opaque);
+ printf(" state %p\n", s->stream.state);
if (s->stream.msg)
printf(" msg %s\n", s->stream.msg);
else
printf(" msg \n");
- printf(" next_in 0x%p", s->stream.next_in);
+ printf(" next_in %p", s->stream.next_in);
if (s->stream.next_in){
printf(" =>");
DispHex(s->stream.next_in, 4);
}
printf("\n");
- printf(" next_out 0x%p", s->stream.next_out);
+ printf(" next_out %p", s->stream.next_out);
if (s->stream.next_out){
printf(" =>");
DispHex(s->stream.next_out, 4);
printf(" total_out %ld\n", s->stream.total_out);
printf(" adler %ld\n", s->stream.adler );
printf(" bufsize %ld\n", s->bufsize);
- printf(" dictionary 0x%p\n", s->dictionary);
+ printf(" dictionary %p\n", s->dictionary);
printf(" dict_adler 0x%ld\n",s->dict_adler);
printf(" zip_mode %d\n", s->zip_mode);
printf(" crc32 0x%x\n", (unsigned)s->crc32);
#ifdef MAGIC_APPEND
- printf(" window 0x%p\n", s->window);
+ printf(" window %p\n", s->window);
#endif
printf("\n");
err = deflateInit2(&(s->stream), level,
method, windowBits, memLevel, strategy);
- if (trace)
- warn(" _deflateInit2 returned %d\n", err);
+ if (trace) {
+ warn(" _deflateInit2 returned %d (state %p)\n", err, s);
+ DispStream(s, "INIT");
+ }
/* Check if a dictionary has been specified */
SvGETMAGIC(dictionary);
croak("Wide character in Compress::Raw::Zlib::Deflate::new dicrionary parameter");
#endif
err = deflateSetDictionary(&(s->stream), (const Bytef*) SvPVX(dictionary), SvCUR(dictionary)) ;
+ if (trace)
+ warn("deflateSetDictionary returned %d\n", err);
s->dict_adler = s->stream.adler ;
}
}
}
else
-#endif
+#endif
/* Dictionary specified - take a copy for use in inflate */
s->dictionary = newSVsv(dictionary) ;
}
bufinc *= 2 ;
}
+ if (trace) {
+ printf("DEFLATE Avail In %d, Out %d\n", s->stream.avail_in, s->stream.avail_out);
+ DispStream(s, "BEFORE");
+ /* Perl_sv_dump(output); */
+ }
+
RETVAL = deflate(&(s->stream), Z_NO_FLUSH);
+
+ if (trace) {
+ printf("DEFLATE returned %d %s, avail in %d, out %d\n", RETVAL,
+ GetErrorString(RETVAL), s->stream.avail_in, s->stream.avail_out);
+ DispStream(s, "AFTER");
+ }
+
if (RETVAL != Z_OK)
break;
}
DESTROY(s)
Compress::Raw::Zlib::deflateStream s
CODE:
+ if (trace)
+ printf("Compress::Raw::Zlib::deflateStream::DESTROY %p\n", s);
deflateEnd(&s->stream) ;
if (s->dictionary)
SvREFCNT_dec(s->dictionary) ;
availableout = s->stream.avail_out ;
+ if (trace) {
+ printf("flush (%d) DEFLATE Avail In %d, Out %d\n", f, s->stream.avail_in, s->stream.avail_out);
+ DispStream(s, "BEFORE");
+ /* Perl_sv_dump(output); */
+ }
+
RETVAL = deflate(&(s->stream), f);
+ if (trace) {
+ printf("flush DEFLATE returned %d %s, avail in %d, out %d\n", RETVAL,
+ GetErrorString(RETVAL), s->stream.avail_in, s->stream.avail_out);
+ DispStream(s, "AFTER");
+ }
+
/* Ignore the second of two consecutive flushes: */
if (availableout == s->stream.avail_out && RETVAL == Z_BUF_ERROR)
RETVAL = Z_OK;
use bytes ;
our ($VERSION, $XS_VERSION, @ISA, @EXPORT, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD, %DEFLATE_CONSTANTS, @DEFLATE_CONSTANTS );
-$VERSION = '2.059';
+$VERSION = '2.060';
$XS_VERSION = $VERSION;
$VERSION = eval $VERSION;
use constant Parse_unsigned => 0x02;
use constant Parse_signed => 0x04;
use constant Parse_boolean => 0x08;
-use constant Parse_string => 0x10;
-use constant Parse_custom => 0x12;
+#use constant Parse_string => 0x10;
+#use constant Parse_custom => 0x12;
-use constant Parse_store_ref => 0x100 ;
+#use constant Parse_store_ref => 0x100 ;
use constant OFF_PARSED => 0 ;
use constant OFF_TYPE => 1 ;
#local $Carp::CarpLevel = $level ;
#print "PARSE $type $key $value $validate $sub\n" ;
- if ( $type & Parse_store_ref)
- {
- #$value = $$value
- # if ref ${ $value } ;
-
- $$output = $value ;
- return 1;
- }
+# if ( $type & Parse_store_ref)
+# {
+# #$value = $$value
+# # if ref ${ $value } ;
+#
+# $$output = $value ;
+# return 1;
+# }
$value = $$value ;
$$output = defined $value ? $value != 0 : 0 ;
return 1;
}
- elsif ($type & Parse_string)
- {
- $$output = defined $value ? $value : "" ;
- return 1;
- }
+# elsif ($type & Parse_string)
+# {
+# $$output = defined $value ? $value : "" ;
+# return 1;
+# }
$$output = $value ;
return 1;
return $self->{Got}{lc $name}[OFF_FIXED] ;
}
+our $OPTIONS_deflate =
+ {
+ 'AppendOutput' => [1, 1, Parse_boolean, 0],
+ 'CRC32' => [1, 1, Parse_boolean, 0],
+ 'ADLER32' => [1, 1, Parse_boolean, 0],
+ 'Bufsize' => [1, 1, Parse_unsigned, 4096],
+
+ 'Level' => [1, 1, Parse_signed, Z_DEFAULT_COMPRESSION()],
+ 'Method' => [1, 1, Parse_unsigned, Z_DEFLATED()],
+ 'WindowBits' => [1, 1, Parse_signed, MAX_WBITS()],
+ 'MemLevel' => [1, 1, Parse_unsigned, MAX_MEM_LEVEL()],
+ 'Strategy' => [1, 1, Parse_unsigned, Z_DEFAULT_STRATEGY()],
+ 'Dictionary' => [1, 1, Parse_any, ""],
+ };
+
sub Compress::Raw::Zlib::Deflate::new
{
my $pkg = shift ;
- my ($got) = ParseParameters(0,
- {
- 'AppendOutput' => [1, 1, Parse_boolean, 0],
- 'CRC32' => [1, 1, Parse_boolean, 0],
- 'ADLER32' => [1, 1, Parse_boolean, 0],
- 'Bufsize' => [1, 1, Parse_unsigned, 4096],
-
- 'Level' => [1, 1, Parse_signed, Z_DEFAULT_COMPRESSION()],
- 'Method' => [1, 1, Parse_unsigned, Z_DEFLATED()],
- 'WindowBits' => [1, 1, Parse_signed, MAX_WBITS()],
- 'MemLevel' => [1, 1, Parse_unsigned, MAX_MEM_LEVEL()],
- 'Strategy' => [1, 1, Parse_unsigned, Z_DEFAULT_STRATEGY()],
- 'Dictionary' => [1, 1, Parse_any, ""],
- }, @_) ;
-
+ my ($got) = ParseParameters(0, $OPTIONS_deflate, @_);
croak "Compress::Raw::Zlib::Deflate::new: Bufsize must be >= 1, you specified " .
$got->value('Bufsize')
}
+our $OPTIONS_inflate =
+ {
+ 'AppendOutput' => [1, 1, Parse_boolean, 0],
+ 'LimitOutput' => [1, 1, Parse_boolean, 0],
+ 'CRC32' => [1, 1, Parse_boolean, 0],
+ 'ADLER32' => [1, 1, Parse_boolean, 0],
+ 'ConsumeInput' => [1, 1, Parse_boolean, 1],
+ 'Bufsize' => [1, 1, Parse_unsigned, 4096],
+
+ 'WindowBits' => [1, 1, Parse_signed, MAX_WBITS()],
+ 'Dictionary' => [1, 1, Parse_any, ""],
+ } ;
+
sub Compress::Raw::Zlib::Inflate::new
{
my $pkg = shift ;
- my ($got) = ParseParameters(0,
- {
- 'AppendOutput' => [1, 1, Parse_boolean, 0],
- 'LimitOutput' => [1, 1, Parse_boolean, 0],
- 'CRC32' => [1, 1, Parse_boolean, 0],
- 'ADLER32' => [1, 1, Parse_boolean, 0],
- 'ConsumeInput' => [1, 1, Parse_boolean, 1],
- 'Bufsize' => [1, 1, Parse_unsigned, 4096],
-
- 'WindowBits' => [1, 1, Parse_signed, MAX_WBITS()],
- 'Dictionary' => [1, 1, Parse_any, ""],
- }, @_) ;
-
+ my ($got) = ParseParameters(0, $OPTIONS_inflate, @_);
croak "Compress::Raw::Zlib::Inflate::new: Bufsize must be >= 1, you specified " .
$got->value('Bufsize')
=head1 ACCESSING ZIP FILES
Although it is possible (with some effort on your part) to use this module
-to access .zip files, there are other perl modules available that will
-do all the hard work for you. Check out C<Archive::Zip>,
-C<IO::Compress::Zip> and C<IO::Uncompress::Unzip>.
+to access .zip files, there are other perl modules available that will do
+all the hard work for you. Check out C<Archive::Zip>,
+C<Archive::Zip::SimpleZip>, C<IO::Compress::Zip> and
+C<IO::Uncompress::Unzip>.
=head1 FAQ
=head1 COPYRIGHT AND LICENSE
-Copyright (c) 2005-2012 Paul Marquess. All rights reserved.
+Copyright (c) 2005-2013 Paul Marquess. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.