ReactOS  0.4.15-dev-1201-gb2cf5a4
zlib.h File Reference
#include "windef.h"
Include dependency graph for zlib.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  z_stream_s
 
struct  gz_header_s
 

Macros

#define FAR
 
#define z_const   const
 
#define Z_NO_FLUSH   0
 
#define Z_PARTIAL_FLUSH   1
 
#define Z_SYNC_FLUSH   2
 
#define Z_FULL_FLUSH   3
 
#define Z_FINISH   4
 
#define Z_BLOCK   5
 
#define Z_TREES   6
 
#define Z_OK   0
 
#define Z_STREAM_END   1
 
#define Z_NEED_DICT   2
 
#define Z_ERRNO   (-1)
 
#define Z_STREAM_ERROR   (-2)
 
#define Z_DATA_ERROR   (-3)
 
#define Z_MEM_ERROR   (-4)
 
#define Z_BUF_ERROR   (-5)
 
#define Z_VERSION_ERROR   (-6)
 
#define Z_NO_COMPRESSION   0
 
#define Z_BEST_SPEED   1
 
#define Z_BEST_COMPRESSION   9
 
#define Z_DEFAULT_COMPRESSION   (-1)
 
#define Z_FILTERED   1
 
#define Z_HUFFMAN_ONLY   2
 
#define Z_RLE   3
 
#define Z_FIXED   4
 
#define Z_DEFAULT_STRATEGY   0
 
#define Z_BINARY   0
 
#define Z_TEXT   1
 
#define Z_ASCII   Z_TEXT /* for compatibility with 1.2.2 and earlier */
 
#define Z_UNKNOWN   2
 
#define Z_DEFLATED   8
 
#define Z_NULL   0 /* for initializing zalloc, zfree, opaque */
 
#define MAX_WBITS   15 /* 32K LZ77 window */
 
#define MAX_MEM_LEVEL   9
 

Typedefs

typedef unsigned char Byte
 
typedef unsigned int uInt
 
typedef unsigned long uLong
 
typedef Byte FAR Bytef
 
typedef void FARvoidpf
 
typedef char FAR charf
 
typedef int FAR intf
 
typedef unsigned char uch
 
typedef uch FAR uchf
 
typedef unsigned short ush
 
typedef ush FAR ushf
 
typedef unsigned long ulg
 
typedef voidpf(* alloc_func) (voidpf opaque, uInt items, uInt size)
 
typedef void(* free_func) (voidpf opaque, voidpf address)
 
typedef struct z_stream_s z_stream
 
typedef z_stream FARz_streamp
 
typedef struct gz_header_s gz_header
 
typedef gz_header FARgz_headerp
 

Functions

int inflateInit (z_streamp strm) DECLSPEC_HIDDEN
 
int inflateInit2 (z_streamp strm, int windowBits) DECLSPEC_HIDDEN
 
int inflate (z_streamp strm, int flush) DECLSPEC_HIDDEN
 
int inflateEnd (z_streamp strm) DECLSPEC_HIDDEN
 
int deflateInit (z_streamp strm, int level) DECLSPEC_HIDDEN
 
int deflateInit2 (z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy) DECLSPEC_HIDDEN
 
int deflate (z_streamp strm, int flush) DECLSPEC_HIDDEN
 
int deflateEnd (z_streamp strm) DECLSPEC_HIDDEN
 

Macro Definition Documentation

◆ FAR

#define FAR

Definition at line 34 of file zlib.h.

◆ MAX_MEM_LEVEL

#define MAX_MEM_LEVEL   9

Definition at line 152 of file zlib.h.

◆ MAX_WBITS

#define MAX_WBITS   15 /* 32K LZ77 window */

Definition at line 151 of file zlib.h.

◆ Z_ASCII

#define Z_ASCII   Z_TEXT /* for compatibility with 1.2.2 and earlier */

Definition at line 142 of file zlib.h.

◆ Z_BEST_COMPRESSION

#define Z_BEST_COMPRESSION   9

Definition at line 129 of file zlib.h.

◆ Z_BEST_SPEED

#define Z_BEST_SPEED   1

Definition at line 128 of file zlib.h.

◆ Z_BINARY

#define Z_BINARY   0

Definition at line 140 of file zlib.h.

◆ Z_BLOCK

#define Z_BLOCK   5

Definition at line 110 of file zlib.h.

◆ Z_BUF_ERROR

#define Z_BUF_ERROR   (-5)

Definition at line 121 of file zlib.h.

◆ z_const

#define z_const   const

Definition at line 35 of file zlib.h.

◆ Z_DATA_ERROR

#define Z_DATA_ERROR   (-3)

Definition at line 119 of file zlib.h.

◆ Z_DEFAULT_COMPRESSION

#define Z_DEFAULT_COMPRESSION   (-1)

Definition at line 130 of file zlib.h.

◆ Z_DEFAULT_STRATEGY

#define Z_DEFAULT_STRATEGY   0

Definition at line 137 of file zlib.h.

◆ Z_DEFLATED

#define Z_DEFLATED   8

Definition at line 146 of file zlib.h.

◆ Z_ERRNO

#define Z_ERRNO   (-1)

Definition at line 117 of file zlib.h.

◆ Z_FILTERED

#define Z_FILTERED   1

Definition at line 133 of file zlib.h.

◆ Z_FINISH

#define Z_FINISH   4

Definition at line 109 of file zlib.h.

◆ Z_FIXED

#define Z_FIXED   4

Definition at line 136 of file zlib.h.

◆ Z_FULL_FLUSH

#define Z_FULL_FLUSH   3

Definition at line 108 of file zlib.h.

◆ Z_HUFFMAN_ONLY

#define Z_HUFFMAN_ONLY   2

Definition at line 134 of file zlib.h.

◆ Z_MEM_ERROR

#define Z_MEM_ERROR   (-4)

Definition at line 120 of file zlib.h.

◆ Z_NEED_DICT

#define Z_NEED_DICT   2

Definition at line 116 of file zlib.h.

◆ Z_NO_COMPRESSION

#define Z_NO_COMPRESSION   0

Definition at line 127 of file zlib.h.

◆ Z_NO_FLUSH

#define Z_NO_FLUSH   0

Definition at line 105 of file zlib.h.

◆ Z_NULL

#define Z_NULL   0 /* for initializing zalloc, zfree, opaque */

Definition at line 149 of file zlib.h.

◆ Z_OK

#define Z_OK   0

Definition at line 114 of file zlib.h.

◆ Z_PARTIAL_FLUSH

#define Z_PARTIAL_FLUSH   1

Definition at line 106 of file zlib.h.

◆ Z_RLE

#define Z_RLE   3

Definition at line 135 of file zlib.h.

◆ Z_STREAM_END

#define Z_STREAM_END   1

Definition at line 115 of file zlib.h.

◆ Z_STREAM_ERROR

#define Z_STREAM_ERROR   (-2)

Definition at line 118 of file zlib.h.

◆ Z_SYNC_FLUSH

#define Z_SYNC_FLUSH   2

Definition at line 107 of file zlib.h.

◆ Z_TEXT

#define Z_TEXT   1

Definition at line 141 of file zlib.h.

◆ Z_TREES

#define Z_TREES   6

Definition at line 111 of file zlib.h.

◆ Z_UNKNOWN

#define Z_UNKNOWN   2

Definition at line 143 of file zlib.h.

◆ Z_VERSION_ERROR

#define Z_VERSION_ERROR   (-6)

Definition at line 122 of file zlib.h.

Typedef Documentation

◆ alloc_func

typedef voidpf(* alloc_func) (voidpf opaque, uInt items, uInt size)

Definition at line 53 of file zlib.h.

◆ Byte

typedef unsigned char Byte

Definition at line 37 of file zlib.h.

◆ Bytef

typedef Byte FAR Bytef

Definition at line 41 of file zlib.h.

◆ charf

typedef char FAR charf

Definition at line 44 of file zlib.h.

◆ free_func

typedef void(* free_func) (voidpf opaque, voidpf address)

Definition at line 54 of file zlib.h.

◆ gz_header

◆ gz_headerp

Definition at line 103 of file zlib.h.

◆ intf

typedef int FAR intf

Definition at line 45 of file zlib.h.

◆ uch

typedef unsigned char uch

Definition at line 47 of file zlib.h.

◆ uchf

typedef uch FAR uchf

Definition at line 48 of file zlib.h.

◆ uInt

typedef unsigned int uInt

Definition at line 38 of file zlib.h.

◆ ulg

typedef unsigned long ulg

Definition at line 51 of file zlib.h.

◆ uLong

typedef uLong

Definition at line 39 of file zlib.h.

◆ ush

typedef unsigned short ush

Definition at line 49 of file zlib.h.

◆ ushf

typedef ush FAR ushf

Definition at line 50 of file zlib.h.

◆ voidpf

typedef voidpf

Definition at line 42 of file zlib.h.

◆ z_stream

◆ z_streamp

Definition at line 80 of file zlib.h.

Function Documentation

◆ deflate()

int deflate ( z_streamp  strm,
int  flush 
)

Definition at line 766 of file deflate.c.

769 {
770  int old_flush; /* value of flush param for previous deflate call */
771  deflate_state *s;
772 
773  if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
774  return Z_STREAM_ERROR;
775  }
776  s = strm->state;
777 
778  if (strm->next_out == Z_NULL ||
779  (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
780  (s->status == FINISH_STATE && flush != Z_FINISH)) {
781  ERR_RETURN(strm, Z_STREAM_ERROR);
782  }
783  if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
784 
785  old_flush = s->last_flush;
786  s->last_flush = flush;
787 
788  /* Flush as much pending output as possible */
789  if (s->pending != 0) {
790  flush_pending(strm);
791  if (strm->avail_out == 0) {
792  /* Since avail_out is 0, deflate will be called again with
793  * more output space, but possibly with both pending and
794  * avail_in equal to zero. There won't be anything to do,
795  * but this is not an error situation so make sure we
796  * return OK instead of BUF_ERROR at next call of deflate:
797  */
798  s->last_flush = -1;
799  return Z_OK;
800  }
801 
802  /* Make sure there is something to do and avoid duplicate consecutive
803  * flushes. For repeated and useless calls with Z_FINISH, we keep
804  * returning Z_STREAM_END instead of Z_BUF_ERROR.
805  */
806  } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
807  flush != Z_FINISH) {
808  ERR_RETURN(strm, Z_BUF_ERROR);
809  }
810 
811  /* User must not provide more input after the first FINISH: */
812  if (s->status == FINISH_STATE && strm->avail_in != 0) {
813  ERR_RETURN(strm, Z_BUF_ERROR);
814  }
815 
816  /* Write the header */
817  if (s->status == INIT_STATE) {
818  /* zlib header */
819  uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
820  uInt level_flags;
821 
822  if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
823  level_flags = 0;
824  else if (s->level < 6)
825  level_flags = 1;
826  else if (s->level == 6)
827  level_flags = 2;
828  else
829  level_flags = 3;
830  header |= (level_flags << 6);
831  if (s->strstart != 0) header |= PRESET_DICT;
832  header += 31 - (header % 31);
833 
834  putShortMSB(s, header);
835 
836  /* Save the adler32 of the preset dictionary: */
837  if (s->strstart != 0) {
838  putShortMSB(s, (uInt)(strm->adler >> 16));
839  putShortMSB(s, (uInt)(strm->adler & 0xffff));
840  }
841  strm->adler = adler32(0L, Z_NULL, 0);
842  s->status = BUSY_STATE;
843 
844  /* Compression must start with an empty pending buffer */
845  flush_pending(strm);
846  if (s->pending != 0) {
847  s->last_flush = -1;
848  return Z_OK;
849  }
850  }
851 #ifdef GZIP
852  if (s->status == GZIP_STATE) {
853  /* gzip header */
854  strm->adler = crc32(0L, Z_NULL, 0);
855  put_byte(s, 31);
856  put_byte(s, 139);
857  put_byte(s, 8);
858  if (s->gzhead == Z_NULL) {
859  put_byte(s, 0);
860  put_byte(s, 0);
861  put_byte(s, 0);
862  put_byte(s, 0);
863  put_byte(s, 0);
864  put_byte(s, s->level == 9 ? 2 :
865  (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
866  4 : 0));
867  put_byte(s, OS_CODE);
868  s->status = BUSY_STATE;
869 
870  /* Compression must start with an empty pending buffer */
871  flush_pending(strm);
872  if (s->pending != 0) {
873  s->last_flush = -1;
874  return Z_OK;
875  }
876  }
877  else {
878  put_byte(s, (s->gzhead->text ? 1 : 0) +
879  (s->gzhead->hcrc ? 2 : 0) +
880  (s->gzhead->extra == Z_NULL ? 0 : 4) +
881  (s->gzhead->name == Z_NULL ? 0 : 8) +
882  (s->gzhead->comment == Z_NULL ? 0 : 16)
883  );
884  put_byte(s, (Byte)(s->gzhead->time & 0xff));
885  put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
886  put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
887  put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
888  put_byte(s, s->level == 9 ? 2 :
889  (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
890  4 : 0));
891  put_byte(s, s->gzhead->os & 0xff);
892  if (s->gzhead->extra != Z_NULL) {
893  put_byte(s, s->gzhead->extra_len & 0xff);
894  put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
895  }
896  if (s->gzhead->hcrc)
897  strm->adler = crc32(strm->adler, s->pending_buf,
898  s->pending);
899  s->gzindex = 0;
900  s->status = EXTRA_STATE;
901  }
902  }
903  if (s->status == EXTRA_STATE) {
904  if (s->gzhead->extra != Z_NULL) {
905  ulg beg = s->pending; /* start of bytes to update crc */
906  uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
907  while (s->pending + left > s->pending_buf_size) {
908  uInt copy = s->pending_buf_size - s->pending;
909  zmemcpy(s->pending_buf + s->pending,
910  s->gzhead->extra + s->gzindex, copy);
911  s->pending = s->pending_buf_size;
912  HCRC_UPDATE(beg);
913  s->gzindex += copy;
914  flush_pending(strm);
915  if (s->pending != 0) {
916  s->last_flush = -1;
917  return Z_OK;
918  }
919  beg = 0;
920  left -= copy;
921  }
922  zmemcpy(s->pending_buf + s->pending,
923  s->gzhead->extra + s->gzindex, left);
924  s->pending += left;
925  HCRC_UPDATE(beg);
926  s->gzindex = 0;
927  }
928  s->status = NAME_STATE;
929  }
930  if (s->status == NAME_STATE) {
931  if (s->gzhead->name != Z_NULL) {
932  ulg beg = s->pending; /* start of bytes to update crc */
933  int val;
934  do {
935  if (s->pending == s->pending_buf_size) {
936  HCRC_UPDATE(beg);
937  flush_pending(strm);
938  if (s->pending != 0) {
939  s->last_flush = -1;
940  return Z_OK;
941  }
942  beg = 0;
943  }
944  val = s->gzhead->name[s->gzindex++];
945  put_byte(s, val);
946  } while (val != 0);
947  HCRC_UPDATE(beg);
948  s->gzindex = 0;
949  }
950  s->status = COMMENT_STATE;
951  }
952  if (s->status == COMMENT_STATE) {
953  if (s->gzhead->comment != Z_NULL) {
954  ulg beg = s->pending; /* start of bytes to update crc */
955  int val;
956  do {
957  if (s->pending == s->pending_buf_size) {
958  HCRC_UPDATE(beg);
959  flush_pending(strm);
960  if (s->pending != 0) {
961  s->last_flush = -1;
962  return Z_OK;
963  }
964  beg = 0;
965  }
966  val = s->gzhead->comment[s->gzindex++];
967  put_byte(s, val);
968  } while (val != 0);
969  HCRC_UPDATE(beg);
970  }
971  s->status = HCRC_STATE;
972  }
973  if (s->status == HCRC_STATE) {
974  if (s->gzhead->hcrc) {
975  if (s->pending + 2 > s->pending_buf_size) {
976  flush_pending(strm);
977  if (s->pending != 0) {
978  s->last_flush = -1;
979  return Z_OK;
980  }
981  }
982  put_byte(s, (Byte)(strm->adler & 0xff));
983  put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
984  strm->adler = crc32(0L, Z_NULL, 0);
985  }
986  s->status = BUSY_STATE;
987 
988  /* Compression must start with an empty pending buffer */
989  flush_pending(strm);
990  if (s->pending != 0) {
991  s->last_flush = -1;
992  return Z_OK;
993  }
994  }
995 #endif
996 
997  /* Start a new block or continue the current one.
998  */
999  if (strm->avail_in != 0 || s->lookahead != 0 ||
1000  (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
1001  block_state bstate;
1002 
1003  bstate = s->level == 0 ? deflate_stored(s, flush) :
1004  s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
1005  s->strategy == Z_RLE ? deflate_rle(s, flush) :
1007 
1008  if (bstate == finish_started || bstate == finish_done) {
1009  s->status = FINISH_STATE;
1010  }
1011  if (bstate == need_more || bstate == finish_started) {
1012  if (strm->avail_out == 0) {
1013  s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
1014  }
1015  return Z_OK;
1016  /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
1017  * of deflate should use the same flush parameter to make sure
1018  * that the flush is complete. So we don't have to output an
1019  * empty block here, this will be done at next call. This also
1020  * ensures that for a very small output buffer, we emit at most
1021  * one empty block.
1022  */
1023  }
1024  if (bstate == block_done) {
1025  if (flush == Z_PARTIAL_FLUSH) {
1026  _tr_align(s);
1027  } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
1028  _tr_stored_block(s, (char*)0, 0L, 0);
1029  /* For a full flush, this empty block will be recognized
1030  * as a special marker by inflate_sync().
1031  */
1032  if (flush == Z_FULL_FLUSH) {
1033  CLEAR_HASH(s); /* forget history */
1034  if (s->lookahead == 0) {
1035  s->strstart = 0;
1036  s->block_start = 0L;
1037  s->insert = 0;
1038  }
1039  }
1040  }
1041  flush_pending(strm);
1042  if (strm->avail_out == 0) {
1043  s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
1044  return Z_OK;
1045  }
1046  }
1047  }
1048 
1049  if (flush != Z_FINISH) return Z_OK;
1050  if (s->wrap <= 0) return Z_STREAM_END;
1051 
1052  /* Write the trailer */
1053 #ifdef GZIP
1054  if (s->wrap == 2) {
1055  put_byte(s, (Byte)(strm->adler & 0xff));
1056  put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
1057  put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
1058  put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
1059  put_byte(s, (Byte)(strm->total_in & 0xff));
1060  put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
1061  put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
1062  put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
1063  }
1064  else
1065 #endif
1066  {
1067  putShortMSB(s, (uInt)(strm->adler >> 16));
1068  putShortMSB(s, (uInt)(strm->adler & 0xffff));
1069  }
1070  flush_pending(strm);
1071  /* If avail_out is zero, the application will call deflate again
1072  * to flush the rest.
1073  */
1074  if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
1075  return s->pending != 0 ? Z_OK : Z_STREAM_END;
1076 }
#define Z_BLOCK
Definition: zlib.h:110
#define INIT_STATE
Definition: deflate.h:54
GLenum func
Definition: glext.h:6028
GLint level
Definition: gl.h:1546
#define RANK(f)
Definition: deflate.c:155
#define Z_RLE
Definition: zlib.h:135
void putShortMSB(deflate_state *s, uInt b)
Definition: deflate.c:719
#define HCRC_STATE
Definition: deflate.h:61
#define Z_STREAM_ERROR
Definition: zlib.h:118
#define Z_OK
Definition: zlib.h:114
#define PRESET_DICT
Definition: zutil.h:68
void ZLIB_INTERNAL _tr_align(deflate_state *s)
Definition: trees.c:896
block_state
Definition: deflate.c:66
#define OS_CODE
Definition: zutil.h:139
while(1)
Definition: macro.lex.yy.c:740
const config configuration_table[10]
Definition: deflate.c:134
#define Z_STREAM_END
Definition: zlib.h:115
#define BUSY_STATE
Definition: deflate.h:62
GLuint GLfloat * val
Definition: glext.h:7180
int flush
Definition: zlib.h:309
#define zmemcpy
Definition: inflate.c:38
char * name
Definition: compiler.c:66
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
GLint left
Definition: glext.h:7726
#define put_byte(s, c)
Definition: deflate.h:281
#define COMMENT_STATE
Definition: deflate.h:60
static const WCHAR L[]
Definition: oid.c:1250
#define CLEAR_HASH(s)
Definition: deflate.c:192
block_state deflate_rle(deflate_state *s, int flush)
Definition: deflate.c:2060
#define NAME_STATE
Definition: deflate.h:59
GLdouble s
Definition: gl.h:2039
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int last)
Definition: trees.c:863
#define Z_DEFLATED
Definition: zlib.h:146
#define FINISH_STATE
Definition: deflate.h:63
block_state deflate_stored(deflate_state *s, int flush)
Definition: deflate.c:1646
#define Z_FINISH
Definition: zlib.h:109
unsigned int uInt
Definition: zlib.h:38
#define Z_NULL
Definition: zlib.h:149
#define Z_PARTIAL_FLUSH
Definition: zlib.h:106
#define Z_BUF_ERROR
Definition: zlib.h:121
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
unsigned long ulg
Definition: zlib.h:51
#define Z_FULL_FLUSH
Definition: zlib.h:108
#define GZIP_STATE
Definition: deflate.h:56
#define EXTRA_STATE
Definition: deflate.h:58
unsigned char Byte
Definition: zlib.h:37
#define crc32(crc, buf, len)
Definition: inflate.c:1081
#define Z_NO_FLUSH
Definition: zlib.h:105
void flush_pending(z_streamp strm)
Definition: deflate.c:733
#define HCRC_UPDATE(beg)
Definition: deflate.c:758
block_state deflate_huff(deflate_state *s, int flush)
Definition: deflate.c:2133
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.c:134
#define ERR_RETURN(strm, err)
Definition: zutil.h:41
#define Z_HUFFMAN_ONLY
Definition: zlib.h:134

Referenced by CMSZipCodec::Compress(), compress2(), deflateParams(), gz_comp(), zipCloseFileInZipRaw64(), zipWriteInFileInZip(), and zlib_compress().

◆ deflateEnd()

int deflateEnd ( z_streamp  strm)

Definition at line 1079 of file deflate.c.

1081 {
1082  int status;
1083 
1084  if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
1085 
1086  status = strm->state->status;
1087 
1088  /* Deallocate in reverse order of allocations: */
1089  TRY_FREE(strm, strm->state->pending_buf);
1090  TRY_FREE(strm, strm->state->head);
1091  TRY_FREE(strm, strm->state->prev);
1092  TRY_FREE(strm, strm->state->window);
1093 
1094  ZFREE(strm, strm->state);
1095  strm->state = Z_NULL;
1096 
1097  return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
1098 }
#define Z_STREAM_ERROR
Definition: zlib.h:118
#define Z_OK
Definition: zlib.h:114
#define BUSY_STATE
Definition: deflate.h:62
#define ZFREE(strm, addr)
Definition: inflate.c:51
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:356
DWORD state
Definition: ps.c:98
#define Z_NULL
Definition: zlib.h:149
#define TRY_FREE(s, p)
Definition: inflate.c:52
#define Z_DATA_ERROR
Definition: zlib.h:119
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by CMSZipCodec::Compress(), compress2(), deflateCopy(), deflateInit2_(), gzclose_w(), zipCloseFileInZipRaw64(), and zlib_compress().

◆ deflateInit()

int deflateInit ( z_streamp  strm,
int  level 
)

Referenced by compress2(), and zlib_compress().

◆ deflateInit2()

int deflateInit2 ( z_streamp  strm,
int  level,
int  method,
int  windowBits,
int  memLevel,
int  strategy 
)

◆ inflate()

int inflate ( z_streamp  strm,
int  flush 
)

Definition at line 1257 of file inflate.c.

1258 {
1259  struct inflate_state FAR *state;
1260  z_const unsigned char FAR *next; /* next input */
1261  unsigned char FAR *put; /* next output */
1262  unsigned have, left; /* available input and output */
1263  unsigned long hold; /* bit buffer */
1264  unsigned bits; /* bits in bit buffer */
1265  unsigned in, out; /* save starting available input and output */
1266  unsigned copy; /* number of stored or match bytes to copy */
1267  unsigned char FAR *from; /* where to copy match bytes from */
1268  code here; /* current decoding table entry */
1269  code last; /* parent table entry */
1270  unsigned len; /* length to copy for repeats, bits to drop */
1271  int ret; /* return code */
1272 #ifdef GUNZIP
1273  unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
1274 #endif
1275  static const unsigned short order[19] = /* permutation of code lengths */
1276  {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
1277 
1278  if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
1279  (strm->next_in == Z_NULL && strm->avail_in != 0))
1280  return Z_STREAM_ERROR;
1281 
1282  state = (struct inflate_state FAR *)strm->state;
1283  if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
1284  LOAD();
1285  in = have;
1286  out = left;
1287  ret = Z_OK;
1288  for (;;)
1289  switch (state->mode) {
1290  case HEAD:
1291  if (state->wrap == 0) {
1292  state->mode = TYPEDO;
1293  break;
1294  }
1295  NEEDBITS(16);
1296 #ifdef GUNZIP
1297  if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
1298  if (state->wbits == 0)
1299  state->wbits = 15;
1300  state->check = crc32(0L, Z_NULL, 0);
1301  CRC2(state->check, hold);
1302  INITBITS();
1303  state->mode = FLAGS;
1304  break;
1305  }
1306  state->flags = 0; /* expect zlib header */
1307  if (state->head != Z_NULL)
1308  state->head->done = -1;
1309  if (!(state->wrap & 1) || /* check if zlib header allowed */
1310 #else
1311  if (
1312 #endif
1313  ((BITS(8) << 8) + (hold >> 8)) % 31) {
1314  strm->msg = (char *)"incorrect header check";
1315  state->mode = BAD;
1316  break;
1317  }
1318  if (BITS(4) != Z_DEFLATED) {
1319  strm->msg = (char *)"unknown compression method";
1320  state->mode = BAD;
1321  break;
1322  }
1323  DROPBITS(4);
1324  len = BITS(4) + 8;
1325  if (state->wbits == 0)
1326  state->wbits = len;
1327  if (len > 15 || len > state->wbits) {
1328  strm->msg = (char *)"invalid window size";
1329  state->mode = BAD;
1330  break;
1331  }
1332  state->dmax = 1U << len;
1333  Tracev((stderr, "inflate: zlib header ok\n"));
1334  strm->adler = state->check = adler32(0L, Z_NULL, 0);
1335  state->mode = hold & 0x200 ? DICTID : TYPE;
1336  INITBITS();
1337  break;
1338 #ifdef GUNZIP
1339  case FLAGS:
1340  NEEDBITS(16);
1341  state->flags = (int)(hold);
1342  if ((state->flags & 0xff) != Z_DEFLATED) {
1343  strm->msg = (char *)"unknown compression method";
1344  state->mode = BAD;
1345  break;
1346  }
1347  if (state->flags & 0xe000) {
1348  strm->msg = (char *)"unknown header flags set";
1349  state->mode = BAD;
1350  break;
1351  }
1352  if (state->head != Z_NULL)
1353  state->head->text = (int)((hold >> 8) & 1);
1354  if ((state->flags & 0x0200) && (state->wrap & 4))
1355  CRC2(state->check, hold);
1356  INITBITS();
1357  state->mode = TIME;
1358  case TIME:
1359  NEEDBITS(32);
1360  if (state->head != Z_NULL)
1361  state->head->time = hold;
1362  if ((state->flags & 0x0200) && (state->wrap & 4))
1363  CRC4(state->check, hold);
1364  INITBITS();
1365  state->mode = OS;
1366  case OS:
1367  NEEDBITS(16);
1368  if (state->head != Z_NULL) {
1369  state->head->xflags = (int)(hold & 0xff);
1370  state->head->os = (int)(hold >> 8);
1371  }
1372  if ((state->flags & 0x0200) && (state->wrap & 4))
1373  CRC2(state->check, hold);
1374  INITBITS();
1375  state->mode = EXLEN;
1376  case EXLEN:
1377  if (state->flags & 0x0400) {
1378  NEEDBITS(16);
1379  state->length = (unsigned)(hold);
1380  if (state->head != Z_NULL)
1381  state->head->extra_len = (unsigned)hold;
1382  if ((state->flags & 0x0200) && (state->wrap & 4))
1383  CRC2(state->check, hold);
1384  INITBITS();
1385  }
1386  else if (state->head != Z_NULL)
1387  state->head->extra = Z_NULL;
1388  state->mode = EXTRA;
1389  case EXTRA:
1390  if (state->flags & 0x0400) {
1391  copy = state->length;
1392  if (copy > have) copy = have;
1393  if (copy) {
1394  if (state->head != Z_NULL &&
1395  state->head->extra != Z_NULL) {
1396  len = state->head->extra_len - state->length;
1397  zmemcpy(state->head->extra + len, next,
1398  len + copy > state->head->extra_max ?
1399  state->head->extra_max - len : copy);
1400  }
1401  if ((state->flags & 0x0200) && (state->wrap & 4))
1402  state->check = crc32(state->check, next, copy);
1403  have -= copy;
1404  next += copy;
1405  state->length -= copy;
1406  }
1407  if (state->length) goto inf_leave;
1408  }
1409  state->length = 0;
1410  state->mode = NAME;
1411  case NAME:
1412  if (state->flags & 0x0800) {
1413  if (have == 0) goto inf_leave;
1414  copy = 0;
1415  do {
1416  len = (unsigned)(next[copy++]);
1417  if (state->head != Z_NULL &&
1418  state->head->name != Z_NULL &&
1419  state->length < state->head->name_max)
1420  state->head->name[state->length++] = (Bytef)len;
1421  } while (len && copy < have);
1422  if ((state->flags & 0x0200) && (state->wrap & 4))
1423  state->check = crc32(state->check, next, copy);
1424  have -= copy;
1425  next += copy;
1426  if (len) goto inf_leave;
1427  }
1428  else if (state->head != Z_NULL)
1429  state->head->name = Z_NULL;
1430  state->length = 0;
1431  state->mode = COMMENT;
1432  case COMMENT:
1433  if (state->flags & 0x1000) {
1434  if (have == 0) goto inf_leave;
1435  copy = 0;
1436  do {
1437  len = (unsigned)(next[copy++]);
1438  if (state->head != Z_NULL &&
1439  state->head->comment != Z_NULL &&
1440  state->length < state->head->comm_max)
1441  state->head->comment[state->length++] = (Bytef)len;
1442  } while (len && copy < have);
1443  if ((state->flags & 0x0200) && (state->wrap & 4))
1444  state->check = crc32(state->check, next, copy);
1445  have -= copy;
1446  next += copy;
1447  if (len) goto inf_leave;
1448  }
1449  else if (state->head != Z_NULL)
1450  state->head->comment = Z_NULL;
1451  state->mode = HCRC;
1452  case HCRC:
1453  if (state->flags & 0x0200) {
1454  NEEDBITS(16);
1455  if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
1456  strm->msg = (char *)"header crc mismatch";
1457  state->mode = BAD;
1458  break;
1459  }
1460  INITBITS();
1461  }
1462  if (state->head != Z_NULL) {
1463  state->head->hcrc = (int)((state->flags >> 9) & 1);
1464  state->head->done = 1;
1465  }
1466  strm->adler = state->check = crc32(0L, Z_NULL, 0);
1467  state->mode = TYPE;
1468  break;
1469 #endif
1470  case DICTID:
1471  NEEDBITS(32);
1472  strm->adler = state->check = ZSWAP32(hold);
1473  INITBITS();
1474  state->mode = DICT;
1475  case DICT:
1476  if (state->havedict == 0) {
1477  RESTORE();
1478  return Z_NEED_DICT;
1479  }
1480  strm->adler = state->check = adler32(0L, Z_NULL, 0);
1481  state->mode = TYPE;
1482  case TYPE:
1483  if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
1484  case TYPEDO:
1485  if (state->last) {
1486  BYTEBITS();
1487  state->mode = CHECK;
1488  break;
1489  }
1490  NEEDBITS(3);
1491  state->last = BITS(1);
1492  DROPBITS(1);
1493  switch (BITS(2)) {
1494  case 0: /* stored block */
1495  Tracev((stderr, "inflate: stored block%s\n",
1496  state->last ? " (last)" : ""));
1497  state->mode = STORED;
1498  break;
1499  case 1: /* fixed block */
1500  fixedtables(state);
1501  Tracev((stderr, "inflate: fixed codes block%s\n",
1502  state->last ? " (last)" : ""));
1503  state->mode = LEN_; /* decode codes */
1504  if (flush == Z_TREES) {
1505  DROPBITS(2);
1506  goto inf_leave;
1507  }
1508  break;
1509  case 2: /* dynamic block */
1510  Tracev((stderr, "inflate: dynamic codes block%s\n",
1511  state->last ? " (last)" : ""));
1512  state->mode = TABLE;
1513  break;
1514  case 3:
1515  strm->msg = (char *)"invalid block type";
1516  state->mode = BAD;
1517  }
1518  DROPBITS(2);
1519  break;
1520  case STORED:
1521  BYTEBITS(); /* go to byte boundary */
1522  NEEDBITS(32);
1523  if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
1524  strm->msg = (char *)"invalid stored block lengths";
1525  state->mode = BAD;
1526  break;
1527  }
1528  state->length = (unsigned)hold & 0xffff;
1529  Tracev((stderr, "inflate: stored length %u\n",
1530  state->length));
1531  INITBITS();
1532  state->mode = COPY_;
1533  if (flush == Z_TREES) goto inf_leave;
1534  case COPY_:
1535  state->mode = COPY;
1536  case COPY:
1537  copy = state->length;
1538  if (copy) {
1539  if (copy > have) copy = have;
1540  if (copy > left) copy = left;
1541  if (copy == 0) goto inf_leave;
1542  zmemcpy(put, next, copy);
1543  have -= copy;
1544  next += copy;
1545  left -= copy;
1546  put += copy;
1547  state->length -= copy;
1548  break;
1549  }
1550  Tracev((stderr, "inflate: stored end\n"));
1551  state->mode = TYPE;
1552  break;
1553  case TABLE:
1554  NEEDBITS(14);
1555  state->nlen = BITS(5) + 257;
1556  DROPBITS(5);
1557  state->ndist = BITS(5) + 1;
1558  DROPBITS(5);
1559  state->ncode = BITS(4) + 4;
1560  DROPBITS(4);
1561 #ifndef PKZIP_BUG_WORKAROUND
1562  if (state->nlen > 286 || state->ndist > 30) {
1563  strm->msg = (char *)"too many length or distance symbols";
1564  state->mode = BAD;
1565  break;
1566  }
1567 #endif
1568  Tracev((stderr, "inflate: table sizes ok\n"));
1569  state->have = 0;
1570  state->mode = LENLENS;
1571  case LENLENS:
1572  while (state->have < state->ncode) {
1573  NEEDBITS(3);
1574  state->lens[order[state->have++]] = (unsigned short)BITS(3);
1575  DROPBITS(3);
1576  }
1577  while (state->have < 19)
1578  state->lens[order[state->have++]] = 0;
1579  state->next = state->codes;
1580  state->lencode = (const code FAR *)(state->next);
1581  state->lenbits = 7;
1582  ret = inflate_table(CODES, state->lens, 19, &(state->next),
1583  &(state->lenbits), state->work);
1584  if (ret) {
1585  strm->msg = (char *)"invalid code lengths set";
1586  state->mode = BAD;
1587  break;
1588  }
1589  Tracev((stderr, "inflate: code lengths ok\n"));
1590  state->have = 0;
1591  state->mode = CODELENS;
1592  case CODELENS:
1593  while (state->have < state->nlen + state->ndist) {
1594  for (;;) {
1595  here = state->lencode[BITS(state->lenbits)];
1596  if ((unsigned)(here.bits) <= bits) break;
1597  PULLBYTE();
1598  }
1599  if (here.val < 16) {
1600  DROPBITS(here.bits);
1601  state->lens[state->have++] = here.val;
1602  }
1603  else {
1604  if (here.val == 16) {
1605  NEEDBITS(here.bits + 2);
1606  DROPBITS(here.bits);
1607  if (state->have == 0) {
1608  strm->msg = (char *)"invalid bit length repeat";
1609  state->mode = BAD;
1610  break;
1611  }
1612  len = state->lens[state->have - 1];
1613  copy = 3 + BITS(2);
1614  DROPBITS(2);
1615  }
1616  else if (here.val == 17) {
1617  NEEDBITS(here.bits + 3);
1618  DROPBITS(here.bits);
1619  len = 0;
1620  copy = 3 + BITS(3);
1621  DROPBITS(3);
1622  }
1623  else {
1624  NEEDBITS(here.bits + 7);
1625  DROPBITS(here.bits);
1626  len = 0;
1627  copy = 11 + BITS(7);
1628  DROPBITS(7);
1629  }
1630  if (state->have + copy > state->nlen + state->ndist) {
1631  strm->msg = (char *)"invalid bit length repeat";
1632  state->mode = BAD;
1633  break;
1634  }
1635  while (copy--)
1636  state->lens[state->have++] = (unsigned short)len;
1637  }
1638  }
1639 
1640  /* handle error breaks in while */
1641  if (state->mode == BAD) break;
1642 
1643  /* check for end-of-block code (better have one) */
1644  if (state->lens[256] == 0) {
1645  strm->msg = (char *)"invalid code -- missing end-of-block";
1646  state->mode = BAD;
1647  break;
1648  }
1649 
1650  /* build code tables -- note: do not change the lenbits or distbits
1651  values here (9 and 6) without reading the comments in inftrees.h
1652  concerning the ENOUGH constants, which depend on those values */
1653  state->next = state->codes;
1654  state->lencode = (const code FAR *)(state->next);
1655  state->lenbits = 9;
1656  ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
1657  &(state->lenbits), state->work);
1658  if (ret) {
1659  strm->msg = (char *)"invalid literal/lengths set";
1660  state->mode = BAD;
1661  break;
1662  }
1663  state->distcode = (const code FAR *)(state->next);
1664  state->distbits = 6;
1665  ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
1666  &(state->next), &(state->distbits), state->work);
1667  if (ret) {
1668  strm->msg = (char *)"invalid distances set";
1669  state->mode = BAD;
1670  break;
1671  }
1672  Tracev((stderr, "inflate: codes ok\n"));
1673  state->mode = LEN_;
1674  if (flush == Z_TREES) goto inf_leave;
1675  case LEN_:
1676  state->mode = LEN;
1677  case LEN:
1678  if (have >= 6 && left >= 258) {
1679  RESTORE();
1680  inflate_fast(strm, out);
1681  LOAD();
1682  if (state->mode == TYPE)
1683  state->back = -1;
1684  break;
1685  }
1686  state->back = 0;
1687  for (;;) {
1688  here = state->lencode[BITS(state->lenbits)];
1689  if ((unsigned)(here.bits) <= bits) break;
1690  PULLBYTE();
1691  }
1692  if (here.op && (here.op & 0xf0) == 0) {
1693  last = here;
1694  for (;;) {
1695  here = state->lencode[last.val +
1696  (BITS(last.bits + last.op) >> last.bits)];
1697  if ((unsigned)(last.bits + here.bits) <= bits) break;
1698  PULLBYTE();
1699  }
1700  DROPBITS(last.bits);
1701  state->back += last.bits;
1702  }
1703  DROPBITS(here.bits);
1704  state->back += here.bits;
1705  state->length = (unsigned)here.val;
1706  if ((int)(here.op) == 0) {
1707  Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
1708  "inflate: literal '%c'\n" :
1709  "inflate: literal 0x%02x\n", here.val));
1710  state->mode = LIT;
1711  break;
1712  }
1713  if (here.op & 32) {
1714  Tracevv((stderr, "inflate: end of block\n"));
1715  state->back = -1;
1716  state->mode = TYPE;
1717  break;
1718  }
1719  if (here.op & 64) {
1720  strm->msg = (char *)"invalid literal/length code";
1721  state->mode = BAD;
1722  break;
1723  }
1724  state->extra = (unsigned)(here.op) & 15;
1725  state->mode = LENEXT;
1726  case LENEXT:
1727  if (state->extra) {
1728  NEEDBITS(state->extra);
1729  state->length += BITS(state->extra);
1730  DROPBITS(state->extra);
1731  state->back += state->extra;
1732  }
1733  Tracevv((stderr, "inflate: length %u\n", state->length));
1734  state->was = state->length;
1735  state->mode = DIST;
1736  case DIST:
1737  for (;;) {
1738  here = state->distcode[BITS(state->distbits)];
1739  if ((unsigned)(here.bits) <= bits) break;
1740  PULLBYTE();
1741  }
1742  if ((here.op & 0xf0) == 0) {
1743  last = here;
1744  for (;;) {
1745  here = state->distcode[last.val +
1746  (BITS(last.bits + last.op) >> last.bits)];
1747  if ((unsigned)(last.bits + here.bits) <= bits) break;
1748  PULLBYTE();
1749  }
1750  DROPBITS(last.bits);
1751  state->back += last.bits;
1752  }
1753  DROPBITS(here.bits);
1754  state->back += here.bits;
1755  if (here.op & 64) {
1756  strm->msg = (char *)"invalid distance code";
1757  state->mode = BAD;
1758  break;
1759  }
1760  state->offset = (unsigned)here.val;
1761  state->extra = (unsigned)(here.op) & 15;
1762  state->mode = DISTEXT;
1763  case DISTEXT:
1764  if (state->extra) {
1765  NEEDBITS(state->extra);
1766  state->offset += BITS(state->extra);
1767  DROPBITS(state->extra);
1768  state->back += state->extra;
1769  }
1770 #ifdef INFLATE_STRICT
1771  if (state->offset > state->dmax) {
1772  strm->msg = (char *)"invalid distance too far back";
1773  state->mode = BAD;
1774  break;
1775  }
1776 #endif
1777  Tracevv((stderr, "inflate: distance %u\n", state->offset));
1778  state->mode = MATCH;
1779  case MATCH:
1780  if (left == 0) goto inf_leave;
1781  copy = out - left;
1782  if (state->offset > copy) { /* copy from window */
1783  copy = state->offset - copy;
1784  if (copy > state->whave) {
1785  if (state->sane) {
1786  strm->msg = (char *)"invalid distance too far back";
1787  state->mode = BAD;
1788  break;
1789  }
1790 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1791  Trace((stderr, "inflate.c too far\n"));
1792  copy -= state->whave;
1793  if (copy > state->length) copy = state->length;
1794  if (copy > left) copy = left;
1795  left -= copy;
1796  state->length -= copy;
1797  do {
1798  *put++ = 0;
1799  } while (--copy);
1800  if (state->length == 0) state->mode = LEN;
1801  break;
1802 #endif
1803  }
1804  if (copy > state->wnext) {
1805  copy -= state->wnext;
1806  from = state->window + (state->wsize - copy);
1807  }
1808  else
1809  from = state->window + (state->wnext - copy);
1810  if (copy > state->length) copy = state->length;
1811  }
1812  else { /* copy from output */
1813  from = put - state->offset;
1814  copy = state->length;
1815  }
1816  if (copy > left) copy = left;
1817  left -= copy;
1818  state->length -= copy;
1819  do {
1820  *put++ = *from++;
1821  } while (--copy);
1822  if (state->length == 0) state->mode = LEN;
1823  break;
1824  case LIT:
1825  if (left == 0) goto inf_leave;
1826  *put++ = (unsigned char)(state->length);
1827  left--;
1828  state->mode = LEN;
1829  break;
1830  case CHECK:
1831  if (state->wrap) {
1832  NEEDBITS(32);
1833  out -= left;
1834  strm->total_out += out;
1835  state->total += out;
1836  if ((state->wrap & 4) && out)
1837  strm->adler = state->check =
1838  UPDATE(state->check, put - out, out);
1839  out = left;
1840  if ((state->wrap & 4) && (
1841 #ifdef GUNZIP
1842  state->flags ? hold :
1843 #endif
1844  ZSWAP32(hold)) != state->check) {
1845  strm->msg = (char *)"incorrect data check";
1846  state->mode = BAD;
1847  break;
1848  }
1849  INITBITS();
1850  Tracev((stderr, "inflate: check matches trailer\n"));
1851  }
1852 #ifdef GUNZIP
1853  state->mode = LENGTH;
1854  case LENGTH:
1855  if (state->wrap && state->flags) {
1856  NEEDBITS(32);
1857  if (hold != (state->total & 0xffffffffUL)) {
1858  strm->msg = (char *)"incorrect length check";
1859  state->mode = BAD;
1860  break;
1861  }
1862  INITBITS();
1863  Tracev((stderr, "inflate: length matches trailer\n"));
1864  }
1865 #endif
1866  state->mode = DONE;
1867  case DONE:
1868  ret = Z_STREAM_END;
1869  goto inf_leave;
1870  case BAD:
1871  ret = Z_DATA_ERROR;
1872  goto inf_leave;
1873  case MEM:
1874  return Z_MEM_ERROR;
1875  case SYNC:
1876  default:
1877  return Z_STREAM_ERROR;
1878  }
1879 
1880  /*
1881  Return from inflate(), updating the total counts and the check value.
1882  If there was no progress during the inflate() call, return a buffer
1883  error. Call updatewindow() to create and/or update the window state.
1884  Note: a memory error from inflate() is non-recoverable.
1885  */
1886  inf_leave:
1887  RESTORE();
1888  if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
1889  (state->mode < CHECK || flush != Z_FINISH)))
1890  if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
1891  state->mode = MEM;
1892  return Z_MEM_ERROR;
1893  }
1894  in -= strm->avail_in;
1895  out -= strm->avail_out;
1896  strm->total_in += in;
1897  strm->total_out += out;
1898  state->total += out;
1899  if ((state->wrap & 4) && out)
1900  strm->adler = state->check =
1901  UPDATE(state->check, strm->next_out - out, out);
1902  strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
1903  (state->mode == TYPE ? 128 : 0) +
1904  (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
1905  if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
1906  ret = Z_BUF_ERROR;
1907  return ret;
1908 }
#define Z_BLOCK
Definition: zlib.h:110
Definition: inflate.c:161
Definition: inflate.c:152
unsigned short val
Definition: inflate.c:142
#define RESTORE()
Definition: inflate.c:1122
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
Definition: inflate.c:159
static int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
Definition: inflate.c:1032
Definition: inflate.c:186
Definition: inflate.c:164
Definition: inflate.c:160
Definition: inflate.c:177
Definition: inflate.c:184
POINT last
Definition: font.c:46
#define Z_STREAM_ERROR
Definition: zlib.h:118
#define Z_OK
Definition: zlib.h:114
#define U(x)
Definition: wordpad.c:45
z_streamp strm
Definition: inflate.c:195
unsigned have
Definition: inflate.c:229
Definition: inflate.c:173
#define LOAD()
Definition: inflate.c:1111
static void inflate_fast(z_streamp strm, unsigned start)
Definition: inflate.c:274
#define Tracevv(x)
Definition: inflate.c:44
#define UPDATE(check, buf, len)
Definition: inflate.c:1085
#define PULLBYTE()
Definition: inflate.c:1141
static uLong adler32(uLong adler, const Bytef *buf, uInt len)
Definition: inflate.c:72
#define DROPBITS(n)
Definition: inflate.c:1162
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
unsigned char op
Definition: inflate.c:140
Definition: inflate.c:187
Definition: inflate.c:178
#define put(ret, state, sp, n)
Definition: match.c:105
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define Z_STREAM_END
Definition: zlib.h:115
#define BYTEBITS()
Definition: inflate.c:1169
unsigned char
Definition: typeof.h:29
static int inflateStateCheck(z_streamp strm)
Definition: inflate.c:802
#define Tracev(x)
Definition: inflate.c:43
Definition: inflate.c:180
unsigned long hold
Definition: inflate.c:213
Definition: inflate.c:172
int flush
Definition: zlib.h:309
#define zmemcpy
Definition: inflate.c:38
Definition: inflate.c:169
if(!(yy_init))
Definition: macro.lex.yy.c:714
Definition: inflate.c:188
#define CRC2(check, word)
Definition: inflate.c:1093
#define GUNZIP
Definition: inflate.c:47
#define ZSWAP32(q)
Definition: inflate.c:55
static FILE * out
Definition: regtests2xml.c:44
GLint left
Definition: glext.h:7726
#define BITS(n)
Definition: inflate.c:1158
Definition: inflate.c:162
int ret
unsigned char bits
Definition: inflate.c:141
Definition: inflate.c:153
static const WCHAR L[]
Definition: oid.c:1250
static int state
Definition: maze.c:121
GLenum GLsizei len
Definition: glext.h:6722
#define Trace(x)
Definition: inflate.c:42
#define INITBITS()
Definition: inflate.c:1133
Definition: inflate.c:139
#define CRC4(check, word)
Definition: inflate.c:1100
#define Z_DEFLATED
Definition: zlib.h:146
#define Z_TREES
Definition: zlib.h:111
#define Z_FINISH
Definition: zlib.h:109
#define Z_NULL
Definition: zlib.h:149
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: inflate.c:189
#define NEEDBITS(n)
Definition: inflate.c:1151
GLuint in
Definition: glext.h:9616
TYPE
Definition: eventcreate.c:651
Definition: inflate.c:168
#define Z_BUF_ERROR
Definition: zlib.h:121
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
Definition: inflate.c:182
#define Z_NEED_DICT
Definition: zlib.h:116
static void fixedtables(struct inflate_state FAR *state)
Definition: inflate.c:924
Byte FAR Bytef
Definition: zlib.h:41
#define Z_MEM_ERROR
Definition: zlib.h:120
#define crc32(crc, buf, len)
Definition: inflate.c:1081
#define z_const
Definition: zlib.h:35
Definition: inflate.c:166
#define Z_DATA_ERROR
Definition: zlib.h:119
FILE * stderr
Definition: inflate.c:183
Definition: inflate.c:158
#define FAR
Definition: zlib.h:34
CardRegion * from
Definition: spigame.cpp:19
Definition: inflate.c:151
Definition: inflate.c:163
Definition: inflate.c:174
static unsigned(__cdecl *hash_bstr)(bstr_t s)
static int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
Definition: inflate.c:533
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by dwarf2_init_zsection(), ExtractZipImage(), gz_decomp(), MSZipCodecUncompress(), test_boundsrect(), CMSZipCodec::Uncompress(), uncompress2(), unzReadCurrentFile(), and zlib_decompress().

◆ inflateEnd()

int inflateEnd ( z_streamp  strm)

Definition at line 1910 of file inflate.c.

1911 {
1912  struct inflate_state FAR *state;
1913  if (inflateStateCheck(strm))
1914  return Z_STREAM_ERROR;
1915  state = (struct inflate_state FAR *)strm->state;
1916  if (state->window != Z_NULL) ZFREE(strm, state->window);
1917  ZFREE(strm, strm->state);
1918  strm->state = Z_NULL;
1919  Tracev((stderr, "inflate: end\n"));
1920  return Z_OK;
1921 }
#define Z_STREAM_ERROR
Definition: zlib.h:118
#define Z_OK
Definition: zlib.h:114
z_streamp strm
Definition: inflate.c:195
#define ZFREE(strm, addr)
Definition: inflate.c:51
static int inflateStateCheck(z_streamp strm)
Definition: inflate.c:802
#define Tracev(x)
Definition: inflate.c:43
if(!(yy_init))
Definition: macro.lex.yy.c:714
static int state
Definition: maze.c:121
#define Z_NULL
Definition: zlib.h:149
FILE * stderr
#define FAR
Definition: zlib.h:34

Referenced by dwarf2_init_zsection(), ExtractZipImage(), gzclose_r(), MSZipCodecUncompress(), CMSZipCodec::Uncompress(), uncompress2(), unzCloseCurrentFile(), and zlib_decompress().

◆ inflateInit()

int inflateInit ( z_streamp  strm)

Definition at line 909 of file inflate.c.

910 {
911  return inflateInit2(strm, DEF_WBITS);
912 }
z_streamp strm
Definition: inflate.c:195
int inflateInit2(z_streamp strm, int windowBits)
Definition: inflate.c:887
#define DEF_WBITS
Definition: inflate.c:37

◆ inflateInit2()

int inflateInit2 ( z_streamp  strm,
int  windowBits 
)

Definition at line 887 of file inflate.c.

888 {
889  int ret;
890  struct inflate_state FAR *state;
891 
892  strm->msg = Z_NULL; /* in case we return an error */
893  state = (struct inflate_state FAR *)
894  ZALLOC(strm, 1, sizeof(struct inflate_state));
895  if (state == Z_NULL) return Z_MEM_ERROR;
896  Tracev((stderr, "inflate: allocated\n"));
897  strm->state = (struct internal_state FAR *)state;
898  state->strm = strm;
899  state->window = Z_NULL;
900  state->mode = HEAD; /* to pass state test in inflateReset2() */
902  if (ret != Z_OK) {
903  ZFREE(strm, state);
904  strm->state = Z_NULL;
905  }
906  return ret;
907 }
int windowBits
Definition: zlib.h:813
#define Z_OK
Definition: zlib.h:114
z_streamp strm
Definition: inflate.c:195
#define ZFREE(strm, addr)
Definition: inflate.c:51
z_streamp strm
Definition: deflate.h:101
#define Tracev(x)
Definition: inflate.c:43
int ret
static int state
Definition: maze.c:121
#define ZALLOC(strm, items, size)
Definition: inflate.c:49
#define Z_NULL
Definition: zlib.h:149
#define Z_MEM_ERROR
Definition: zlib.h:120
FILE * stderr
Definition: inflate.c:158
#define FAR
Definition: zlib.h:34
static int inflateReset2(z_streamp strm, int windowBits)
Definition: inflate.c:851

Referenced by inflateInit().