suppress header & checksum configurable
authorca
Mon, 03 Aug 2009 14:50:50 +0200
changeset 2193 db70507b21ba
parent 2192 aa40ad91e77a
child 2194 38a073a3261b
suppress header & checksum configurable
ZipStream.st
--- a/ZipStream.st	Fri Jul 31 14:15:06 2009 +0200
+++ b/ZipStream.st	Mon Aug 03 14:50:50 2009 +0200
@@ -443,10 +443,12 @@
 zdeflateInit
     "low level - deflateInit"
 
-    |errorNo level|
+    |errorNo level windowBits|
 
     errorNo := nil.
     level   := BlockSize.
+    windowBits := self zget_windowBits.
+
 %{
     OBJ _zstreamObj = __INST( zstream );
 
@@ -460,7 +462,7 @@
 	_errorNo = deflateInit2( & _zstream->stream
 			       , __intVal( level )
 			       , Z_DEFLATED
-			       , MAX_WBITS
+			       , __intVal( windowBits )
 			       , DEF_MEM_LEVEL
 			       , Z_DEFAULT_STRATEGY
 			       );
@@ -497,6 +499,22 @@
     self errorNotOpen.
 !
 
+zget_windowBits
+    "answer the bits used for inflateInit2 or deflateInit2...
+    a negative WindowBits value suppresses the zlib header and the checksum..."
+
+    |windowBits|
+%{
+    windowBits = __MKSMALLINT( MAX_WBITS );
+%}.
+
+    self isHeaderAndChecksumSuppressed ifTrue:[
+	"/ undocumented feature.....
+	^ windowBits negated
+    ].
+    ^ windowBits
+!
+
 zinflate
     "low level - inflate
     "
@@ -599,9 +617,10 @@
 zinflateInit
     "low level - inflateInit
     "
-    |errorNo|
+    |errorNo windowBits|
 
     errorNo := nil.
+    windowBits := self zget_windowBits.
 
 %{
     OBJ _zstreamObj = __INST( zstream );
@@ -612,7 +631,9 @@
 	zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
 
 	_zstream->op_mode = e_opmode_inflate;
-	_errorNo = inflateInit2( & _zstream->stream, MAX_WBITS );
+	_errorNo = inflateInit2 ( & _zstream->stream
+				, __intVal( windowBits )
+				);
 
 	if( _errorNo == Z_OK )
 	    RETURN( self );
@@ -774,7 +795,7 @@
 !ZipStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.34 2009-07-31 11:16:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.35 2009-08-03 12:50:50 ca Exp $'
 ! !
 
 ZipStream initialize!