*** empty log message ***
authorca
Tue, 16 Jan 2007 17:21:51 +0100
changeset 1828 47cd819e24af
parent 1827 b635239b983c
child 1829 4dd5f9f30878
*** empty log message ***
ZipStream.st
--- a/ZipStream.st	Tue Jan 16 17:21:14 2007 +0100
+++ b/ZipStream.st	Tue Jan 16 17:21:51 2007 +0100
@@ -86,7 +86,7 @@
 
 examples
 "
-                                                                [exBegin]
+								[exBegin]
     |compressed zipStream|
 
 self halt.
@@ -98,7 +98,7 @@
 self halt.
     zipStream := self readOpenOn:compressed contents readStream.
     self information:zipStream contents.
-                                                                [exEnd]
+								[exEnd]
 "
 ! !
 
@@ -130,10 +130,10 @@
 
 compress: aUncompressedByteArray into: aCompressedByteArray
     ^ self flatBytesIn: aUncompressedByteArray
-                  from: 1
-                    to: (aUncompressedByteArray size)
-                  into: aCompressedByteArray
-            doCompress: true.
+		  from: 1
+		    to: (aUncompressedByteArray size)
+		  into: aCompressedByteArray
+	    doCompress: true.
 !
 
 flatBytesIn:bytesIn from:start to:stop into:bytesOut doCompress:doCompress
@@ -149,7 +149,7 @@
       and:[bytesIn  size >= stop
       and:[bytesOut size >  0]]]
      ) ifFalse:[
-        ^ self error:'invalid argument size'
+	^ self error:'invalid argument size'
     ].
 
 %{
@@ -160,42 +160,42 @@
 
     if( (__isSmallInteger(start)) && (__isSmallInteger(stop)) && (__isSmallInteger(size)) )
     {
-        __countIn = __intVal( size );
+	__countIn = __intVal( size );
 
-        if (__isBytes(bytesIn)) {
-            __bytesIn = __ByteArrayInstPtr(bytesIn)->ba_element;
-        } else {
-            if (__isString(bytesIn)) {
-                __bytesIn = __stringVal( bytesIn );
-            }
-        }
+	if (__isBytes(bytesIn)) {
+	    __bytesIn = __ByteArrayInstPtr(bytesIn)->ba_element;
+	} else {
+	    if (__isString(bytesIn)) {
+		__bytesIn = __stringVal( bytesIn );
+	    }
+	}
 
-        if (__isBytes(bytesOut)) {
-            __bytesOut = __ByteArrayInstPtr(bytesOut)->ba_element;
-            __countOut = __byteArraySize( bytesOut );
-        } else {
-            if (__isString(bytesOut)) {
-                __bytesOut = __stringVal( bytesOut );
-                __countOut = __stringSize( bytesOut );
-            }
-        }
+	if (__isBytes(bytesOut)) {
+	    __bytesOut = __ByteArrayInstPtr(bytesOut)->ba_element;
+	    __countOut = __byteArraySize( bytesOut );
+	} else {
+	    if (__isString(bytesOut)) {
+		__bytesOut = __stringVal( bytesOut );
+		__countOut = __stringSize( bytesOut );
+	    }
+	}
     }
 
     if( __bytesOut && __bytesIn )
     {
-        int __result = Z_OK;
+	int __result = Z_OK;
 
-        __bytesIn += (__intVal( start)) - 1;
+	__bytesIn += (__intVal( start)) - 1;
 
-        if( doCompress == true )
-            __result   = compress  ( (Byte *) __bytesOut, & __countOut, (Byte *) __bytesIn, __countIn );
-        else
-            __result   = uncompress( (Byte *) __bytesOut, & __countOut, (Byte *) __bytesIn, __countIn );
+	if( doCompress == true )
+	    __result   = compress  ( (Byte *) __bytesOut, & __countOut, (Byte *) __bytesIn, __countIn );
+	else
+	    __result   = uncompress( (Byte *) __bytesOut, & __countOut, (Byte *) __bytesIn, __countIn );
 
-        if( __result == Z_OK )
-            { RETURN(__MKSMALLINT(__countOut)); }
+	if( __result == Z_OK )
+	    { RETURN(__MKSMALLINT(__countOut)); }
 
-        errorNr = __MKSMALLINT( __result );
+	errorNr = __MKSMALLINT( __result );
     }
 %}.
 
@@ -210,10 +210,10 @@
 
 uncompress: aCompressedByteArray into: aUncompressedByteArray
     ^ self flatBytesIn: aCompressedByteArray
-                  from: 1
-                    to: (aCompressedByteArray size)
-                  into: aUncompressedByteArray
-            doCompress: false.
+		  from: 1
+		    to: (aCompressedByteArray size)
+		  into: aUncompressedByteArray
+	    doCompress: false.
 ! !
 
 !ZipStream class methodsFor:'ZipInterface compatibility - crc'!
@@ -306,18 +306,18 @@
 
     if( _zstreamObj != nil )
     {
-        zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
+	zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
 
-        __INST(zstream) = nil;
+	__INST(zstream) = nil;
 
-        if( _zstream->stream.state != NULL )
-        {
-            if( _zstream->op_mode == e_opmode_inflate )
-                inflateEnd( & _zstream->stream );
-            else
-                deflateEnd( & _zstream->stream );
-        }
-        free( _zstream );
+	if( _zstream->stream.state != NULL )
+	{
+	    if( _zstream->op_mode == e_opmode_inflate )
+		inflateEnd( & _zstream->stream );
+	    else
+		deflateEnd( & _zstream->stream );
+	}
+	free( _zstream );
     }
 %}.
 !
@@ -333,62 +333,60 @@
 
     if( _zstreamObj != nil )
     {
-        int         _errorNo, _action;
-        uLong       _bfsize;
-        zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
+	int         _errorNo, _action;
+	uLong       _bfsize;
+	zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
 
-        if( _zstream->op_mode != e_opmode_deflate )
-            RETURN( false );
+	if( _zstream->op_mode != e_opmode_deflate )
+	    RETURN( false );
 
-        _bfsize = _zstream->out_total;
+	_bfsize = _zstream->out_total;
 
-        if( _zstream->stream.state == NULL )
-        {
-            /* processing finished; write crc_32 and the total size
-            */
-            uLong   v, i;
-            Bytef * p = _zstream->out_ref;
+	if( _zstream->stream.state == NULL )
+	{
+	    /* processing finished; write crc_32 and the total size
+	    */
+	    uLong   v, i;
+	    Bytef * p = _zstream->out_ref;
 
-            v = _zstream->crc_32;
-            for( i = 0; i < 4; ++i ) { p[i] = v & 0xff; v >>= 8; }
+	    v = _zstream->crc_32;
+	    for( i = 0; i < 4; ++i ) { p[i] = v & 0xff; v >>= 8; }
 
-            v = _zstream->stream.total_in;
-            for( i = 4; i < 8; ++i ) { p[i] = v & 0xff; v >>= 8; }
+	    v = _zstream->stream.total_in;
+	    for( i = 4; i < 8; ++i ) { p[i] = v & 0xff; v >>= 8; }
 
-            _zstream->op_mode          = e_opmode_unspecified;
-            _zstream->stream.avail_in  = 0;
-            _zstream->stream.next_in   = Z_NULL;
-            _zstream->stream.avail_out = _bfsize - 8;
-            RETURN( true );
-        }
-        _zstream->stream.avail_out = _bfsize;
-        _zstream->stream.next_out  = _zstream->out_ref;
+	    _zstream->op_mode          = e_opmode_unspecified;
+	    _zstream->stream.avail_in  = 0;
+	    _zstream->stream.next_in   = Z_NULL;
+	    _zstream->stream.avail_out = _bfsize - 8;
+	    RETURN( true );
+	}
+	_zstream->stream.avail_out = _bfsize;
+	_zstream->stream.next_out  = _zstream->out_ref;
 
-        _action  = (__INST(hitEOF) == true) ? Z_FINISH : Z_NO_FLUSH;
-        _errorNo = deflate( & _zstream->stream, _action );
+	_action  = (__INST(hitEOF) == true) ? Z_FINISH : Z_NO_FLUSH;
+	_errorNo = deflate( & _zstream->stream, _action );
 
-        if( _errorNo == Z_STREAM_END )
-        {
-            _zstream->stream.avail_in = 0;
-            _zstream->stream.next_in  = Z_NULL;
-            _errorNo = deflateEnd( & _zstream->stream );
-        }
+	if( _errorNo == Z_STREAM_END )
+	{
+	    _zstream->stream.avail_in = 0;
+	    _zstream->stream.next_in  = Z_NULL;
+	    _errorNo = deflateEnd( & _zstream->stream );
+	}
 
-        if( _errorNo == Z_OK )
-        {
-            if(   (_zstream->stream.avail_out != _bfsize)
-               || (_zstream->stream.avail_in  != 0)
-              )
-              RETURN( true );
+	if( _errorNo == Z_OK )
+	{
+	    if( _zstream->stream.avail_out == 0 )
+	      RETURN( true );
 
-            RETURN( false );
-        }
-        errorNo = __MKSMALLINT( _errorNo );
+	    RETURN( false );
+	}
+	errorNo = __MKSMALLINT( _errorNo );
     }
 %}.
     errorNo ifNil:[
-        zstream ifNil:[self errorNotOpen].
-        self invalidArgument.
+	zstream ifNil:[self errorNotOpen].
+	self invalidArgument.
     ].
     self zerror:errorNo.
 !
@@ -405,28 +403,28 @@
 
     if( (_zstreamObj != nil) && __isSmallInteger(level) )
     {
-        int         _errorNo;
-        zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
+	int         _errorNo;
+	zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
 
-        _zstream->op_mode = e_opmode_deflate;
+	_zstream->op_mode = e_opmode_deflate;
 
-        _errorNo = deflateInit2( & _zstream->stream
-                               , __intVal( level )
-                               , Z_DEFLATED
-                               , -MAX_WBITS
-                               , DEF_MEM_LEVEL
-                               , Z_DEFAULT_STRATEGY
-                               );
+	_errorNo = deflateInit2( & _zstream->stream
+			       , __intVal( level )
+			       , Z_DEFLATED
+			       , -MAX_WBITS
+			       , DEF_MEM_LEVEL
+			       , Z_DEFAULT_STRATEGY
+			       );
 
-        if( _errorNo == Z_OK )
-            RETURN( self );
+	if( _errorNo == Z_OK )
+	    RETURN( self );
 
-        errorNo = __MKSMALLINT( _errorNo );
+	errorNo = __MKSMALLINT( _errorNo );
     }
 %}.
     errorNo ifNil:[
-        zstream ifNil:[ self errorNotOpen ].
-        self invalidArgument .
+	zstream ifNil:[ self errorNotOpen ].
+	self invalidArgument .
     ].
     self zerror:errorNo.
 !
@@ -627,23 +625,23 @@
 
     if( (_zstreamObj != nil) && __isSmallInteger(count) )
     {
-        int         _count;
-        zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
+	int         _count;
+	zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
 
-        if( (_count = __intVal( count )) > 0 )
-        {
-            Bytef * _in_ref = _zstream->in_ref;
+	if( (_count = __intVal( count )) > 0 )
+	{
+	    Bytef * _in_ref = _zstream->in_ref;
 
-            _zstream->stream.avail_in = _count;
-            _zstream->stream.next_in  = _in_ref;
+	    _zstream->stream.avail_in = _count;
+	    _zstream->stream.next_in  = _in_ref;
 
-            if( _zstream->op_mode == e_opmode_deflate )
-                _zstream->crc_32 = crc32( _zstream->crc_32, _in_ref, _count );
-        } else {
-            _zstream->stream.avail_in = 0;
-            _zstream->stream.next_in  = Z_NULL;
-        }
-        RETURN( self );
+	    if( _zstream->op_mode == e_opmode_deflate )
+		_zstream->crc_32 = crc32( _zstream->crc_32, _in_ref, _count );
+	} else {
+	    _zstream->stream.avail_in = 0;
+	    _zstream->stream.next_in  = Z_NULL;
+	}
+	RETURN( self );
     }
 %}.
     zstream ifNil:[ self errorNotOpen ].
@@ -715,7 +713,7 @@
 !ZipStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.25 2006-03-28 21:02:16 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.26 2007-01-16 16:21:51 ca Exp $'
 ! !
 
 ZipStream initialize!