--- a/BZip2Stream.st Tue Jul 26 10:51:00 2005 +0200
+++ b/BZip2Stream.st Mon Aug 01 14:37:49 2005 +0200
@@ -90,70 +90,68 @@
!
zdeflate
- "low level - deflate
- "
+ "low level - deflate"
+
|errorNo|
-
errorNo := nil.
-
%{
OBJ _zstreamObj = __INST( zstream );
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 invalidArgument.
].
self zerror:errorNo.
!
zdeflateInit
- "low level - open for reading
- "
+ "low level - open for reading"
+
|errorNo blockSize100k workFactor|
errorNo := nil.
@@ -164,23 +162,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 invalidArgument.
].
self zerror:errorNo.
!
@@ -325,35 +323,34 @@
!
zset_avail_in:count
- "set the 'avail_in'
- "
+ "set the 'avail_in'"
%{
OBJ _zstreamObj = __INST( zstream );
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 ].
- self invalidArguments.
+ self invalidArgument.
! !
!BZip2Stream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/BZip2Stream.st,v 1.8 2005-07-08 17:30:34 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/BZip2Stream.st,v 1.9 2005-08-01 12:37:43 stefan Exp $'
! !
--- a/ZipStream.st Tue Jul 26 10:51:00 2005 +0200
+++ b/ZipStream.st Mon Aug 01 14:37:49 2005 +0200
@@ -86,20 +86,19 @@
examples
"
-
- [exBegin]
+ [exBegin]
|compressed zipStream|
+self halt.
compressed := #[] writeStream.
zipStream := self writeOpenOn:compressed.
zipStream nextPutAll:'This is some text 1234567890'.
zipStream flush.
- self information:compressed contents size printString.
-
+ self information:'Compressed size: ', compressed contents size printString.
self halt.
zipStream := self readOpenOn:compressed contents readStream.
self information:zipStream contents.
- [exEnd]
+ [exEnd]
"
! !
@@ -326,10 +325,9 @@
!
zdeflate
- "low level - deflate
- "
+ "low level - deflate"
+
|errorNo|
-
errorNo := nil.
%{
@@ -337,69 +335,69 @@
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 != _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 invalidArgument.
].
self zerror:errorNo.
!
zdeflateInit
- "low level - deflateInit
- "
+ "low level - deflateInit"
+
|errorNo level|
errorNo := nil.
@@ -409,28 +407,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 invalidArguments .
+ zstream ifNil:[ self errorNotOpen ].
+ self invalidArgument .
].
self zerror:errorNo.
!
@@ -625,34 +623,33 @@
!
zset_avail_in:count
- "set the 'avail_in' and compute the crc
- "
+ "set the 'avail_in' and compute the crc"
%{
OBJ _zstreamObj = __INST( zstream );
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 ].
- self invalidArguments.
+ self invalidArgument.
! !
!ZipStream methodsFor:'startup & release'!
@@ -720,7 +717,7 @@
!ZipStream class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.23 2005-07-11 20:42:30 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/ZipStream.st,v 1.24 2005-08-01 12:37:49 stefan Exp $'
! !
ZipStream initialize!