abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
uncompr.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "misc/util/abc_global.h"
#include "zlib.h"

Go to the source code of this file.

Macros

#define ZLIB_INTERNAL
 

Functions

ABC_NAMESPACE_IMPL_START int
ZEXPORT 
uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
 

Macro Definition Documentation

#define ZLIB_INTERNAL

Definition at line 13 of file uncompr.c.

Function Documentation

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

Definition at line 31 of file uncompr.c.

32 {
33  z_stream stream;
34  int err;
35 
36  stream.next_in = (Bytef*)source;
37  stream.avail_in = (uInt)sourceLen;
38  /* Check for source > 64K on 16-bit machine: */
39  if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
40 
41  stream.next_out = dest;
42  stream.avail_out = (uInt)*destLen;
43  if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
44 
45  stream.zalloc = (alloc_func)0;
46  stream.zfree = (free_func)0;
47 
48  err = inflateInit(&stream);
49  if (err != Z_OK) return err;
50 
51  err = inflate(&stream, Z_FINISH);
52  if (err != Z_STREAM_END) {
53  inflateEnd(&stream);
54  if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
55  return Z_DATA_ERROR;
56  return err;
57  }
58  *destLen = stream.total_out;
59 
60  err = inflateEnd(&stream);
61  return err;
62 }
Bytef * next_in
Definition: zlib.h:94
uInt avail_in
Definition: zlib.h:95
#define Z_NEED_DICT
Definition: zlib.h:183
unsigned long uLong
Definition: zconf.h:336
Byte FAR Bytef
Definition: zconf.h:342
free_func zfree
Definition: zlib.h:106
#define Z_FINISH
Definition: zlib.h:176
#define Z_DATA_ERROR
Definition: zlib.h:186
#define Z_STREAM_END
Definition: zlib.h:182
alloc_func zalloc
Definition: zlib.h:105
Bytef * next_out
Definition: zlib.h:98
uLong total_out
Definition: zlib.h:100
#define Z_BUF_ERROR
Definition: zlib.h:188
#define inflateInit(strm)
Definition: zlib.h:1556
uInt avail_out
Definition: zlib.h:99
#define Z_OK
Definition: zlib.h:181
int ZEXPORT inflate(z_streamp strm, int flush)
Definition: inflate.c:580
int ZEXPORT inflateEnd(z_streamp strm)
Definition: inflate.c:1227
unsigned int uInt
Definition: zconf.h:335