--- a/BZip2Stream.st Tue May 06 17:11:14 2003 +0200
+++ b/BZip2Stream.st Tue May 06 18:19:20 2003 +0200
@@ -1,4 +1,4 @@
-"{ Package: 'ca:Compress' }"
+"{ Package: 'stx:libbasic2' }"
CompressionStream subclass:#BZipStream
instanceVariableNames:''
@@ -18,18 +18,18 @@
#include "bzlib/bzlib.h"
typedef enum {
- e_opmode_unspecified /* processing done */
- , e_opmode_deflate /* running deflate */
- , e_opmode_inflate /* running inflate */
+ e_opmode_unspecified /* processing done */
+ , e_opmode_deflate /* running deflate */
+ , e_opmode_inflate /* running inflate */
} e_opmode;
typedef struct {
- bz_stream stream; /* pointer to the external in -stream */
- char * in_ref; /* size of the external in -stream */
- char * out_ref; /* pointer to the external out-stream */
- unsigned int out_total; /* size of the external out-stream */
+ bz_stream stream; /* pointer to the external in -stream */
+ char * in_ref; /* size of the external in -stream */
+ char * out_ref; /* pointer to the external out-stream */
+ unsigned int out_total; /* size of the external out-stream */
- e_opmode op_mode; /* current operational mode */
+ e_opmode op_mode; /* current operational mode */
} zstream_s;
%}
@@ -46,18 +46,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 )
- BZ2_bzDecompressEnd( & _zstream->stream );
- else
- BZ2_bzCompressEnd( & _zstream->stream );
- }
- free( _zstream );
+ if( _zstream->stream.state != NULL )
+ {
+ if( _zstream->op_mode == e_opmode_inflate )
+ BZ2_bzDecompressEnd( & _zstream->stream );
+ else
+ BZ2_bzCompressEnd( & _zstream->stream );
+ }
+ free( _zstream );
}
%}.
!
@@ -74,52 +74,52 @@
if( _zstreamObj != nil )
{
- int _errorNo, _action;
- unsigned int _bfsize;
- zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
+ int _errorNo, _action;
+ unsigned int _bfsize;
+ zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
- if( _zstream->op_mode != e_opmode_deflate )
- RETURN( nil );
+ if( _zstream->op_mode != e_opmode_deflate )
+ RETURN( nil );
- _bfsize = _zstream->out_total;
+ _bfsize = _zstream->out_total;
- if( _zstream->stream.state == NULL )
- {
- _zstream->op_mode = e_opmode_unspecified;
- RETURN( nil );
- }
- _action = (__INST(hitEOF) == true) ? BZ_FINISH : BZ_RUN;
+ if( _zstream->stream.state == NULL )
+ {
+ _zstream->op_mode = e_opmode_unspecified;
+ RETURN( nil );
+ }
+ _action = (__INST(hitEOF) == true) ? BZ_FINISH : BZ_RUN;
- _zstream->stream.avail_out = _bfsize;
- _zstream->stream.next_out = _zstream->out_ref;
+ _zstream->stream.avail_out = _bfsize;
+ _zstream->stream.next_out = _zstream->out_ref;
- _errorNo = BZ2_bzCompress( & _zstream->stream, _action );
+ _errorNo = BZ2_bzCompress( & _zstream->stream, _action );
- if( _errorNo == BZ_STREAM_END )
- {
- _zstream->stream.avail_in = 0;
- _zstream->stream.next_in = NULL;
- _errorNo = BZ2_bzCompressEnd( & _zstream->stream );
- }
+ if( _errorNo == BZ_STREAM_END )
+ {
+ _zstream->stream.avail_in = 0;
+ _zstream->stream.next_in = NULL;
+ _errorNo = BZ2_bzCompressEnd( & _zstream->stream );
+ }
- if( (_errorNo == BZ_OK)
- || (_errorNo == BZ_RUN_OK)
- || (_errorNo == BZ_FINISH_OK)
- )
- {
- if( (_zstream->stream.avail_out != _bfsize)
- || (_zstream->stream.avail_in != 0)
- )
- RETURN( true );
+ if( (_errorNo == BZ_OK)
+ || (_errorNo == BZ_RUN_OK)
+ || (_errorNo == BZ_FINISH_OK)
+ )
+ {
+ if( (_zstream->stream.avail_out != _bfsize)
+ || (_zstream->stream.avail_in != 0)
+ )
+ RETURN( true );
- RETURN( false );
- }
- errorNo = __MKSMALLINT( _errorNo );
+ RETURN( false );
+ }
+ errorNo = __MKSMALLINT( _errorNo );
}
%}.
errorNo ifNil:[
- zstream ifNil:[self errorNotOpen].
- self invalidArguments.
+ zstream ifNil:[self errorNotOpen].
+ self invalidArguments.
].
self zerror:errorNo.
!
@@ -137,23 +137,23 @@
if( (_zstreamObj != nil) && __bothSmallInteger(blockSize100k, workFactor) )
{
- 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 = BZ2_bzCompressInit( & _zstream->stream
- , __intVal( blockSize100k ), 0, __intVal( workFactor ) );
+ _errorNo = BZ2_bzCompressInit( & _zstream->stream
+ , __intVal( blockSize100k ), 0, __intVal( workFactor ) );
- if( _errorNo == BZ_OK )
- RETURN( self );
+ if( _errorNo == BZ_OK )
+ RETURN( self );
- errorNo = __MKSMALLINT( _errorNo );
+ errorNo = __MKSMALLINT( _errorNo );
}
%}.
errorNo ifNil:[
- zstream ifNil:[ self errorNotOpen ].
- self invalidArguments .
+ zstream ifNil:[ self errorNotOpen ].
+ self invalidArguments .
].
self zerror:errorNo.
!
@@ -166,12 +166,12 @@
if( _zstreamObj != nil )
{
- unsigned int _count;
- zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
+ unsigned int _count;
+ zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
- _count = _zstream->out_total - _zstream->stream.avail_out;
+ _count = _zstream->out_total - _zstream->stream.avail_out;
- RETURN( __MKSMALLINT (_count) );
+ RETURN( __MKSMALLINT (_count) );
}
%}.
self errorNotOpen.
@@ -188,37 +188,37 @@
if( _zstreamObj != nil )
{
- int _errorNo, _count;
- zstream_s * _zstream;
+ int _errorNo, _count;
+ zstream_s * _zstream;
- _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
+ _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
- if( _zstream->op_mode != e_opmode_inflate )
- RETURN( nil );
+ if( _zstream->op_mode != e_opmode_inflate )
+ RETURN( nil );
- if( _zstream->stream.state == NULL )
- {
- _zstream->op_mode = e_opmode_unspecified;
- RETURN( nil );
- }
- if( _zstream->stream.avail_in == 0 )
- RETURN( __MKSMALLINT (0) );
+ if( _zstream->stream.state == NULL )
+ {
+ _zstream->op_mode = e_opmode_unspecified;
+ RETURN( nil );
+ }
+ if( _zstream->stream.avail_in == 0 )
+ RETURN( __MKSMALLINT (0) );
- _zstream->stream.avail_out = _zstream->out_total;
- _zstream->stream.next_out = _zstream->out_ref;
+ _zstream->stream.avail_out = _zstream->out_total;
+ _zstream->stream.next_out = _zstream->out_ref;
- _errorNo = BZ2_bzDecompress( & _zstream->stream );
+ _errorNo = BZ2_bzDecompress( & _zstream->stream );
- if( _errorNo == BZ_STREAM_END )
- _errorNo = BZ2_bzDecompressEnd( & _zstream->stream );
+ if( _errorNo == BZ_STREAM_END )
+ _errorNo = BZ2_bzDecompressEnd( & _zstream->stream );
- if( _errorNo == BZ_OK )
- {
- _count = _zstream->out_total - _zstream->stream.avail_out;
+ if( _errorNo == BZ_OK )
+ {
+ _count = _zstream->out_total - _zstream->stream.avail_out;
- RETURN( __MKSMALLINT (_count) );
- }
- errorNo = __MKSMALLINT( _errorNo );
+ RETURN( __MKSMALLINT (_count) );
+ }
+ errorNo = __MKSMALLINT( _errorNo );
}
%}.
errorNo ifNil:[ self errorNotOpen ].
@@ -237,17 +237,17 @@
if( _zstreamObj != nil )
{
- int _errorNo;
- zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
+ int _errorNo;
+ zstream_s * _zstream = (zstream_s *) __externalBytesAddress( _zstreamObj );
- _zstream->op_mode = e_opmode_inflate;
- _errorNo = BZ2_bzDecompressInit( & _zstream->stream, 0, 1 );
+ _zstream->op_mode = e_opmode_inflate;
+ _errorNo = BZ2_bzDecompressInit( & _zstream->stream, 0, 1 );
- if( _errorNo == BZ_OK )
- RETURN( self );
+ if( _errorNo == BZ_OK )
+ RETURN( self );
- _zstream->stream.avail_in = 0;
- errorNo = __MKSMALLINT( _errorNo );
+ _zstream->stream.avail_in = 0;
+ errorNo = __MKSMALLINT( _errorNo );
}
%}.
errorNo ifNil:[ self errorNotOpen ].
@@ -265,32 +265,32 @@
if( _zstream )
{
- OBJ _zobj = __MKEXTERNALADDRESS( _zstream );
- OBJ _outObj = __INST( outputBytes );
- OBJ _inpObj = __INST( inputBytes );
+ OBJ _zobj = __MKEXTERNALADDRESS( _zstream );
+ OBJ _outObj = __INST( outputBytes );
+ OBJ _inpObj = __INST( inputBytes );
- _zstream->in_ref = (char *) __externalBytesAddress( _inpObj );
- _zstream->stream.next_in = NULL;
- _zstream->stream.avail_in = 0;
- _zstream->stream.total_in_lo32 = 0;
- _zstream->stream.total_in_hi32 = 0;
+ _zstream->in_ref = (char *) __externalBytesAddress( _inpObj );
+ _zstream->stream.next_in = NULL;
+ _zstream->stream.avail_in = 0;
+ _zstream->stream.total_in_lo32 = 0;
+ _zstream->stream.total_in_hi32 = 0;
- _zstream->out_total = __intVal( outTotal );
- _zstream->out_ref = (char *) __externalBytesAddress( _outObj );
- _zstream->stream.next_out = _zstream->out_ref;
- _zstream->stream.avail_out = _zstream->out_total;
+ _zstream->out_total = __intVal( outTotal );
+ _zstream->out_ref = (char *) __externalBytesAddress( _outObj );
+ _zstream->stream.next_out = _zstream->out_ref;
+ _zstream->stream.avail_out = _zstream->out_total;
- _zstream->stream.total_out_lo32 = 0;
- _zstream->stream.total_out_hi32 = 0;
+ _zstream->stream.total_out_lo32 = 0;
+ _zstream->stream.total_out_hi32 = 0;
- _zstream->stream.bzalloc = 0;
- _zstream->stream.bzfree = 0;
- _zstream->stream.opaque = 0;
+ _zstream->stream.bzalloc = 0;
+ _zstream->stream.bzfree = 0;
+ _zstream->stream.opaque = 0;
- _zstream->op_mode = e_opmode_unspecified;
+ _zstream->op_mode = e_opmode_unspecified;
- __INST (zstream) = _zobj;
- __STORE(self, _zobj);
+ __INST (zstream) = _zobj;
+ __STORE(self, _zobj);
}
%}.
!
@@ -303,20 +303,20 @@
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 )
- {
- char * _in_ref = _zstream->in_ref;
+ if( (_count = __intVal( count )) > 0 )
+ {
+ char * _in_ref = _zstream->in_ref;
- _zstream->stream.avail_in = _count;
- _zstream->stream.next_in = _in_ref;
- } else {
- _zstream->stream.avail_in = 0;
- _zstream->stream.next_in = NULL;
- }
- RETURN( self );
+ _zstream->stream.avail_in = _count;
+ _zstream->stream.next_in = _in_ref;
+ } else {
+ _zstream->stream.avail_in = 0;
+ _zstream->stream.next_in = NULL;
+ }
+ RETURN( self );
}
%}.
zstream ifNil:[ self errorNotOpen ].
@@ -326,5 +326,5 @@
!BZipStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/BZip2Stream.st,v 1.4 2003-05-06 13:59:34 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/BZip2Stream.st,v 1.5 2003-05-06 16:19:20 stefan Exp $'
! !