summaryrefslogtreecommitdiffstats
path: root/g10/compress.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-05-15 20:49:19 +0200
committerWerner Koch <wk@gnupg.org>1998-05-15 20:49:19 +0200
commitf9a70437820d05f7f98ffd1c9003edd83872e9b5 (patch)
treedc17bdc0dea76ddc28ae651a3dc341b83784dd12 /g10/compress.c
parentcan create v4 signatures (diff)
downloadgnupg2-f9a70437820d05f7f98ffd1c9003edd83872e9b5.tar.xz
gnupg2-f9a70437820d05f7f98ffd1c9003edd83872e9b5.zip
new releaseV0-2-18
Diffstat (limited to 'g10/compress.c')
-rw-r--r--g10/compress.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/g10/compress.c b/g10/compress.c
index 4bf1a87f8..4e4d438e0 100644
--- a/g10/compress.c
+++ b/g10/compress.c
@@ -40,7 +40,6 @@ init_compress( compress_filter_context_t *zfx, z_stream *zs )
int rc;
int level;
-
if( opt.compress >= 0 && opt.compress <= 9 )
level = opt.compress;
else if( opt.compress == -1 )
@@ -52,7 +51,11 @@ init_compress( compress_filter_context_t *zfx, z_stream *zs )
level = Z_DEFAULT_COMPRESSION;
}
- if( (rc = deflateInit( zs, level )) != Z_OK ) {
+
+ if( (rc = zfx->algo == 1? deflateInit2( zs, level, Z_DEFLATED,
+ -13, 8, Z_DEFAULT_STRATEGY)
+ : deflateInit( zs, level )
+ ) != Z_OK ) {
log_fatal("zlib problem: %s\n", zs->msg? zs->msg :
rc == Z_MEM_ERROR ? "out of core" :
rc == Z_VERSION_ERROR ? "invalid lib version" :
@@ -104,8 +107,8 @@ init_uncompress( compress_filter_context_t *zfx, z_stream *zs )
* it forces zlib not to expect a zlib header. This is a
* undocumented feature Peter Gutmann told me about.
*/
- if( (rc = zfx->pgpmode? inflateInit2( zs, -13)
- : inflateInit( zs )) != Z_OK ) {
+ if( (rc = zfx->algo == 1? inflateInit2( zs, -13)
+ : inflateInit( zs )) != Z_OK ) {
log_fatal("zlib problem: %s\n", zs->msg? zs->msg :
rc == Z_MEM_ERROR ? "out of core" :
rc == Z_VERSION_ERROR ? "invalid lib version" :
@@ -187,9 +190,11 @@ compress_filter( void *opaque, int control,
PACKET pkt;
PKT_compressed cd;
+ if( !zfx->algo )
+ zfx->algo = opt.def_compress_algo;
memset( &cd, 0, sizeof cd );
cd.len = 0;
- cd.algorithm = 2; /* zlib */
+ cd.algorithm = zfx->algo;
init_packet( &pkt );
pkt.pkttype = PKT_COMPRESSED;
pkt.pkt.compressed = &cd;
@@ -237,10 +242,9 @@ handle_compressed( PKT_compressed *cd,
int rc;
memset( &cfx, 0, sizeof cfx );
- if( cd->algorithm == 1 )
- cfx.pgpmode = 1;
- else if( cd->algorithm != 2 )
+ if( cd->algorithm < 1 || cd->algorithm > 2 )
return G10ERR_COMPR_ALGO;
+ cfx.algo = cd->algorithm;
iobuf_push_filter( cd->buf, compress_filter, &cfx );
if( callback )