199767f8919635c4928607450d9e0abb932109ceToomas Soome/* compress.c -- compress a memory buffer
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (C) 1995-2005 Jean-loup Gailly.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * For conditions of distribution and use, see copyright notice in zlib.h
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* @(#) $Id$ */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* ===========================================================================
199767f8919635c4928607450d9e0abb932109ceToomas Soome Compresses the source buffer into the destination buffer. The level
199767f8919635c4928607450d9e0abb932109ceToomas Soome parameter has the same meaning as in deflateInit. sourceLen is the byte
199767f8919635c4928607450d9e0abb932109ceToomas Soome length of the source buffer. Upon entry, destLen is the total size of the
199767f8919635c4928607450d9e0abb932109ceToomas Soome destination buffer, which must be at least 0.1% larger than sourceLen plus
199767f8919635c4928607450d9e0abb932109ceToomas Soome 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
199767f8919635c4928607450d9e0abb932109ceToomas Soome memory, Z_BUF_ERROR if there was not enough room in the output buffer,
199767f8919635c4928607450d9e0abb932109ceToomas Soome Z_STREAM_ERROR if the level parameter is invalid.
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* Check for source > 64K on 16-bit machine: */
199767f8919635c4928607450d9e0abb932109ceToomas Soome if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
199767f8919635c4928607450d9e0abb932109ceToomas Soome if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* ===========================================================================
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint ZEXPORT compress (dest, destLen, source, sourceLen)
199767f8919635c4928607450d9e0abb932109ceToomas Soome return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* ===========================================================================
199767f8919635c4928607450d9e0abb932109ceToomas Soome If the default memLevel or windowBits for deflateInit() is changed, then
199767f8919635c4928607450d9e0abb932109ceToomas Soome this function needs to be updated.
199767f8919635c4928607450d9e0abb932109ceToomas Soome return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +