| 1 | /* compress.c -- compress a memory buffer
|
|---|
| 2 | * Copyright (C) 1995-2003 Jean-loup Gailly.
|
|---|
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /* @(#) $Id$ */
|
|---|
| 7 |
|
|---|
| 8 | #define ZLIB_INTERNAL
|
|---|
| 9 | #include "zlib.h"
|
|---|
| 10 |
|
|---|
| 11 | /* ===========================================================================
|
|---|
| 12 | Compresses the source buffer into the destination buffer. The level
|
|---|
| 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte
|
|---|
| 14 | length of the source buffer. Upon entry, destLen is the total size of the
|
|---|
| 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus
|
|---|
| 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
|
|---|
| 17 |
|
|---|
| 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
|---|
| 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
|---|
| 20 | Z_STREAM_ERROR if the level parameter is invalid.
|
|---|
| 21 | */
|
|---|
| 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
|---|
| 23 | Bytef *dest;
|
|---|
| 24 | uLongf *destLen;
|
|---|
| 25 | const Bytef *source;
|
|---|
| 26 | uLong sourceLen;
|
|---|
| 27 | int level;
|
|---|
| 28 | {
|
|---|
| 29 | z_stream stream;
|
|---|
| 30 | int err;
|
|---|
| 31 |
|
|---|
| 32 | stream.next_in = (Bytef*)source;
|
|---|
| 33 | stream.avail_in = (uInt)sourceLen;
|
|---|
|
|---|