abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
compress_.c File Reference
#include "zlib.h"

Go to the source code of this file.

Macros

#define ZLIB_INTERNAL
 

Functions

ABC_NAMESPACE_IMPL_START int
ZEXPORT 
compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
 
int ZEXPORT compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
 
uLong ZEXPORT compressBound (uLong sourceLen)
 

Macro Definition Documentation

#define ZLIB_INTERNAL

Definition at line 8 of file compress_.c.

Function Documentation

int ZEXPORT compress ( Bytef dest,
uLongf destLen,
const Bytef source,
uLong  sourceLen 
)

Definition at line 59 of file compress_.c.

60 {
61  return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
62 }
ABC_NAMESPACE_IMPL_START int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
Definition: compress_.c:24
#define Z_DEFAULT_COMPRESSION
Definition: zlib.h:197
ABC_NAMESPACE_IMPL_START int ZEXPORT compress2 ( Bytef dest,
uLongf destLen,
const Bytef source,
uLong  sourceLen,
int  level 
)

Definition at line 24 of file compress_.c.

25 {
26  z_stream stream;
27  int err;
28 
29  stream.next_in = (Bytef*)source;
30  stream.avail_in = (uInt)sourceLen;
31 #ifdef MAXSEG_64K
32  /* Check for source > 64K on 16-bit machine: */
33  if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
34 #endif
35  stream.next_out = dest;
36  stream.avail_out = (uInt)*destLen;
37  if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
38 
39  stream.zalloc = (alloc_func)0;
40  stream.zfree = (free_func)0;
41  stream.opaque = (voidpf)0;
42 
43  err = deflateInit(&stream, level);
44  if (err != Z_OK) return err;
45 
46  err = deflate(&stream, Z_FINISH);
47  if (err != Z_STREAM_END) {
48  deflateEnd(&stream);
49  return err == Z_OK ? Z_BUF_ERROR : err;
50  }
51  *destLen = stream.total_out;
52 
53  err = deflateEnd(&stream);
54  return err;
55 }
Byte FAR * voidpf
Definition: zconf.h:355
Bytef * next_in
Definition: zlib.h:94
uInt avail_in
Definition: zlib.h:95
unsigned long uLong
Definition: zconf.h:336
int ZEXPORT deflateEnd(z_streamp strm)
Definition: deflate.c:866
Byte FAR Bytef
Definition: zconf.h:342
voidpf opaque
Definition: zlib.h:107
free_func zfree
Definition: zlib.h:106
#define Z_FINISH
Definition: zlib.h:176
#define Z_STREAM_END
Definition: zlib.h:182
alloc_func zalloc
Definition: zlib.h:105
Bytef * next_out
Definition: zlib.h:98
int ZEXPORT deflate(z_streamp strm, int flush)
Definition: deflate.c:555
uLong total_out
Definition: zlib.h:100
#define Z_BUF_ERROR
Definition: zlib.h:188
#define deflateInit(strm, level)
Definition: zlib.h:1554
uInt avail_out
Definition: zlib.h:99
#define Z_OK
Definition: zlib.h:181
unsigned int uInt
Definition: zconf.h:335
uLong ZEXPORT compressBound ( uLong  sourceLen)

Definition at line 68 of file compress_.c.

69 {
70  return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
71  (sourceLen >> 25) + 13;
72 }