ReactOS  0.4.15-dev-5649-gd5999c6
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 32 of file zlib.h.

◆ MAX_MEM_LEVEL

#define MAX_MEM_LEVEL   9

Definition at line 150 of file zlib.h.

◆ MAX_WBITS

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

Definition at line 149 of file zlib.h.

◆ Z_ASCII

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

Definition at line 140 of file zlib.h.

◆ Z_BEST_COMPRESSION

#define Z_BEST_COMPRESSION   9

Definition at line 127 of file zlib.h.

◆ Z_BEST_SPEED

#define Z_BEST_SPEED   1

Definition at line 126 of file zlib.h.

◆ Z_BINARY

#define Z_BINARY   0

Definition at line 138 of file zlib.h.

◆ Z_BLOCK

#define Z_BLOCK   5

Definition at line 108 of file zlib.h.

◆ Z_BUF_ERROR

#define Z_BUF_ERROR   (-5)

Definition at line 119 of file zlib.h.

◆ z_const

#define z_const   const

Definition at line 33 of file zlib.h.

◆ Z_DATA_ERROR

#define Z_DATA_ERROR   (-3)

Definition at line 117 of file zlib.h.

◆ Z_DEFAULT_COMPRESSION

#define Z_DEFAULT_COMPRESSION   (-1)

Definition at line 128 of file zlib.h.

◆ Z_DEFAULT_STRATEGY

#define Z_DEFAULT_STRATEGY   0

Definition at line 135 of file zlib.h.

◆ Z_DEFLATED

#define Z_DEFLATED   8

Definition at line 144 of file zlib.h.

◆ Z_ERRNO

#define Z_ERRNO   (-1)

Definition at line 115 of file zlib.h.

◆ Z_FILTERED

#define Z_FILTERED   1

Definition at line 131 of file zlib.h.

◆ Z_FINISH

#define Z_FINISH   4

Definition at line 107 of file zlib.h.

◆ Z_FIXED

#define Z_FIXED   4

Definition at line 134 of file zlib.h.

◆ Z_FULL_FLUSH

#define Z_FULL_FLUSH   3

Definition at line 106 of file zlib.h.

◆ Z_HUFFMAN_ONLY

#define Z_HUFFMAN_ONLY   2

Definition at line 132 of file zlib.h.

◆ Z_MEM_ERROR

#define Z_MEM_ERROR   (-4)

Definition at line 118 of file zlib.h.

◆ Z_NEED_DICT

#define Z_NEED_DICT   2

Definition at line 114 of file zlib.h.

◆ Z_NO_COMPRESSION

#define Z_NO_COMPRESSION   0

Definition at line 125 of file zlib.h.

◆ Z_NO_FLUSH

#define Z_NO_FLUSH   0

Definition at line 103 of file zlib.h.

◆ Z_NULL

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

Definition at line 147 of file zlib.h.

◆ Z_OK

#define Z_OK   0

Definition at line 112 of file zlib.h.

◆ Z_PARTIAL_FLUSH

#define Z_PARTIAL_FLUSH   1

Definition at line 104 of file zlib.h.

◆ Z_RLE

#define Z_RLE   3

Definition at line 133 of file zlib.h.

◆ Z_STREAM_END

#define Z_STREAM_END   1

Definition at line 113 of file zlib.h.

◆ Z_STREAM_ERROR

#define Z_STREAM_ERROR   (-2)

Definition at line 116 of file zlib.h.

◆ Z_SYNC_FLUSH

#define Z_SYNC_FLUSH   2

Definition at line 105 of file zlib.h.

◆ Z_TEXT

#define Z_TEXT   1

Definition at line 139 of file zlib.h.

◆ Z_TREES

#define Z_TREES   6

Definition at line 109 of file zlib.h.

◆ Z_UNKNOWN

#define Z_UNKNOWN   2

Definition at line 141 of file zlib.h.

◆ Z_VERSION_ERROR

#define Z_VERSION_ERROR   (-6)

Definition at line 120 of file zlib.h.

Typedef Documentation

◆ alloc_func

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

Definition at line 51 of file zlib.h.

◆ Byte

typedef unsigned char Byte

Definition at line 35 of file zlib.h.

◆ Bytef

typedef Byte FAR Bytef

Definition at line 39 of file zlib.h.

◆ charf

typedef char FAR charf

Definition at line 42 of file zlib.h.

◆ free_func

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

Definition at line 52 of file zlib.h.

◆ gz_header

◆ gz_headerp

Definition at line 101 of file zlib.h.

◆ intf

typedef int FAR intf

Definition at line 43 of file zlib.h.

◆ uch

typedef unsigned char uch

Definition at line 45 of file zlib.h.

◆ uchf

typedef uch FAR uchf

Definition at line 46 of file zlib.h.

◆ uInt

typedef unsigned int uInt

Definition at line 36 of file zlib.h.

◆ ulg

typedef unsigned long ulg

Definition at line 49 of file zlib.h.

◆ uLong

typedef unsigned long uLong

Definition at line 37 of file zlib.h.

◆ ush

typedef unsigned short ush

Definition at line 47 of file zlib.h.

◆ ushf

typedef ush FAR ushf

Definition at line 48 of file zlib.h.

◆ voidpf

typedef void FAR* voidpf

Definition at line 40 of file zlib.h.

◆ z_stream

◆ z_streamp

Definition at line 78 of file zlib.h.

Function Documentation

◆ deflate()

int deflate ( z_streamp  strm,
int  flush 
)

Definition at line 815 of file deflate.c.

818 {
819  int old_flush; /* value of flush param for previous deflate call */
820  deflate_state *s;
821 
822  if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) {
823  return Z_STREAM_ERROR;
824  }
825  s = strm->state;
826 
827  if (strm->next_out == Z_NULL ||
828  (strm->avail_in != 0 && strm->next_in == Z_NULL) ||
829  (s->status == FINISH_STATE && flush != Z_FINISH)) {
831  }
832  if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
833 
834  old_flush = s->last_flush;
835  s->last_flush = flush;
836 
837  /* Flush as much pending output as possible */
838  if (s->pending != 0) {
840  if (strm->avail_out == 0) {
841  /* Since avail_out is 0, deflate will be called again with
842  * more output space, but possibly with both pending and
843  * avail_in equal to zero. There won't be anything to do,
844  * but this is not an error situation so make sure we
845  * return OK instead of BUF_ERROR at next call of deflate:
846  */
847  s->last_flush = -1;
848  return Z_OK;
849  }
850 
851  /* Make sure there is something to do and avoid duplicate consecutive
852  * flushes. For repeated and useless calls with Z_FINISH, we keep
853  * returning Z_STREAM_END instead of Z_BUF_ERROR.
854  */
855  } else if (strm->avail_in == 0 && RANK(flush) <= RANK(old_flush) &&
856  flush != Z_FINISH) {
858  }
859 
860  /* User must not provide more input after the first FINISH: */
861  if (s->status == FINISH_STATE && strm->avail_in != 0) {
863  }
864 
865  /* Write the header */
866  if (s->status == INIT_STATE && s->wrap == 0)
867  s->status = BUSY_STATE;
868  if (s->status == INIT_STATE) {
869  /* zlib header */
870  uInt header = (Z_DEFLATED + ((s->w_bits - 8) << 4)) << 8;
871  uInt level_flags;
872 
873  if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
874  level_flags = 0;
875  else if (s->level < 6)
876  level_flags = 1;
877  else if (s->level == 6)
878  level_flags = 2;
879  else
880  level_flags = 3;
881  header |= (level_flags << 6);
882  if (s->strstart != 0) header |= PRESET_DICT;
883  header += 31 - (header % 31);
884 
885  putShortMSB(s, header);
886 
887  /* Save the adler32 of the preset dictionary: */
888  if (s->strstart != 0) {
889  putShortMSB(s, (uInt)(strm->adler >> 16));
890  putShortMSB(s, (uInt)(strm->adler & 0xffff));
891  }
892  strm->adler = adler32(0L, Z_NULL, 0);
893  s->status = BUSY_STATE;
894 
895  /* Compression must start with an empty pending buffer */
897  if (s->pending != 0) {
898  s->last_flush = -1;
899  return Z_OK;
900  }
901  }
902 #ifdef GZIP
903  if (s->status == GZIP_STATE) {
904  /* gzip header */
905  strm->adler = crc32(0L, Z_NULL, 0);
906  put_byte(s, 31);
907  put_byte(s, 139);
908  put_byte(s, 8);
909  if (s->gzhead == Z_NULL) {
910  put_byte(s, 0);
911  put_byte(s, 0);
912  put_byte(s, 0);
913  put_byte(s, 0);
914  put_byte(s, 0);
915  put_byte(s, s->level == 9 ? 2 :
916  (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
917  4 : 0));
918  put_byte(s, OS_CODE);
919  s->status = BUSY_STATE;
920 
921  /* Compression must start with an empty pending buffer */
923  if (s->pending != 0) {
924  s->last_flush = -1;
925  return Z_OK;
926  }
927  }
928  else {
929  put_byte(s, (s->gzhead->text ? 1 : 0) +
930  (s->gzhead->hcrc ? 2 : 0) +
931  (s->gzhead->extra == Z_NULL ? 0 : 4) +
932  (s->gzhead->name == Z_NULL ? 0 : 8) +
933  (s->gzhead->comment == Z_NULL ? 0 : 16)
934  );
935  put_byte(s, (Byte)(s->gzhead->time & 0xff));
936  put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
937  put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
938  put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
939  put_byte(s, s->level == 9 ? 2 :
940  (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
941  4 : 0));
942  put_byte(s, s->gzhead->os & 0xff);
943  if (s->gzhead->extra != Z_NULL) {
944  put_byte(s, s->gzhead->extra_len & 0xff);
945  put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
946  }
947  if (s->gzhead->hcrc)
948  strm->adler = crc32(strm->adler, s->pending_buf,
949  s->pending);
950  s->gzindex = 0;
951  s->status = EXTRA_STATE;
952  }
953  }
954  if (s->status == EXTRA_STATE) {
955  if (s->gzhead->extra != Z_NULL) {
956  ulg beg = s->pending; /* start of bytes to update crc */
957  uInt left = (s->gzhead->extra_len & 0xffff) - s->gzindex;
958  while (s->pending + left > s->pending_buf_size) {
959  uInt copy = s->pending_buf_size - s->pending;
960  zmemcpy(s->pending_buf + s->pending,
961  s->gzhead->extra + s->gzindex, copy);
962  s->pending = s->pending_buf_size;
963  HCRC_UPDATE(beg);
964  s->gzindex += copy;
966  if (s->pending != 0) {
967  s->last_flush = -1;
968  return Z_OK;
969  }
970  beg = 0;
971  left -= copy;
972  }
973  zmemcpy(s->pending_buf + s->pending,
974  s->gzhead->extra + s->gzindex, left);
975  s->pending += left;
976  HCRC_UPDATE(beg);
977  s->gzindex = 0;
978  }
979  s->status = NAME_STATE;
980  }
981  if (s->status == NAME_STATE) {
982  if (s->gzhead->name != Z_NULL) {
983  ulg beg = s->pending; /* start of bytes to update crc */
984  int val;
985  do {
986  if (s->pending == s->pending_buf_size) {
987  HCRC_UPDATE(beg);
989  if (s->pending != 0) {
990  s->last_flush = -1;
991  return Z_OK;
992  }
993  beg = 0;
994  }
995  val = s->gzhead->name[s->gzindex++];
996  put_byte(s, val);
997  } while (val != 0);
998  HCRC_UPDATE(beg);
999  s->gzindex = 0;
1000  }
1001  s->status = COMMENT_STATE;
1002  }
1003  if (s->status == COMMENT_STATE) {
1004  if (s->gzhead->comment != Z_NULL) {
1005  ulg beg = s->pending; /* start of bytes to update crc */
1006  int val;
1007  do {
1008  if (s->pending == s->pending_buf_size) {
1009  HCRC_UPDATE(beg);
1011  if (s->pending != 0) {
1012  s->last_flush = -1;
1013  return Z_OK;
1014  }
1015  beg = 0;
1016  }
1017  val = s->gzhead->comment[s->gzindex++];
1018  put_byte(s, val);
1019  } while (val != 0);
1020  HCRC_UPDATE(beg);
1021  }
1022  s->status = HCRC_STATE;
1023  }
1024  if (s->status == HCRC_STATE) {
1025  if (s->gzhead->hcrc) {
1026  if (s->pending + 2 > s->pending_buf_size) {
1028  if (s->pending != 0) {
1029  s->last_flush = -1;
1030  return Z_OK;
1031  }
1032  }
1033  put_byte(s, (Byte)(strm->adler & 0xff));
1034  put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
1035  strm->adler = crc32(0L, Z_NULL, 0);
1036  }
1037  s->status = BUSY_STATE;
1038 
1039  /* Compression must start with an empty pending buffer */
1041  if (s->pending != 0) {
1042  s->last_flush = -1;
1043  return Z_OK;
1044  }
1045  }
1046 #endif
1047 
1048  /* Start a new block or continue the current one.
1049  */
1050  if (strm->avail_in != 0 || s->lookahead != 0 ||
1051  (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
1052  block_state bstate;
1053 
1054  bstate = s->level == 0 ? deflate_stored(s, flush) :
1056  s->strategy == Z_RLE ? deflate_rle(s, flush) :
1058 
1059  if (bstate == finish_started || bstate == finish_done) {
1060  s->status = FINISH_STATE;
1061  }
1062  if (bstate == need_more || bstate == finish_started) {
1063  if (strm->avail_out == 0) {
1064  s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
1065  }
1066  return Z_OK;
1067  /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
1068  * of deflate should use the same flush parameter to make sure
1069  * that the flush is complete. So we don't have to output an
1070  * empty block here, this will be done at next call. This also
1071  * ensures that for a very small output buffer, we emit at most
1072  * one empty block.
1073  */
1074  }
1075  if (bstate == block_done) {
1076  if (flush == Z_PARTIAL_FLUSH) {
1077  _tr_align(s);
1078  } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
1079  _tr_stored_block(s, (char*)0, 0L, 0);
1080  /* For a full flush, this empty block will be recognized
1081  * as a special marker by inflate_sync().
1082  */
1083  if (flush == Z_FULL_FLUSH) {
1084  CLEAR_HASH(s); /* forget history */
1085  if (s->lookahead == 0) {
1086  s->strstart = 0;
1087  s->block_start = 0L;
1088  s->insert = 0;
1089  }
1090  }
1091  }
1093  if (strm->avail_out == 0) {
1094  s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
1095  return Z_OK;
1096  }
1097  }
1098  }
1099 
1100  if (flush != Z_FINISH) return Z_OK;
1101  if (s->wrap <= 0) return Z_STREAM_END;
1102 
1103  /* Write the trailer */
1104 #ifdef GZIP
1105  if (s->wrap == 2) {
1106  put_byte(s, (Byte)(strm->adler & 0xff));
1107  put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
1108  put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
1109  put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
1110  put_byte(s, (Byte)(strm->total_in & 0xff));
1111  put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
1112  put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
1113  put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
1114  }
1115  else
1116 #endif
1117  {
1118  putShortMSB(s, (uInt)(strm->adler >> 16));
1119  putShortMSB(s, (uInt)(strm->adler & 0xffff));
1120  }
1122  /* If avail_out is zero, the application will call deflate again
1123  * to flush the rest.
1124  */
1125  if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
1126  return s->pending != 0 ? Z_OK : Z_STREAM_END;
1127 }
#define Z_BLOCK
Definition: zlib.h:110
#define INIT_STATE
Definition: deflate.h:54
GLenum func
Definition: glext.h:6028
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
GLint level
Definition: gl.h:1546
#define RANK(f)
Definition: deflate.c:149
#define Z_RLE
Definition: zlib.h:135
void putShortMSB(deflate_state *s, uInt b)
Definition: deflate.c:768
#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:897
block_state
Definition: deflate.c:66
#define OS_CODE
Definition: zutil.h:139
#define L(x)
Definition: ntvdm.h:50
const config configuration_table[10]
Definition: deflate.c:128
#define Z_STREAM_END
Definition: zlib.h:115
#define BUSY_STATE
Definition: deflate.h:62
z_streamp strm
Definition: deflate.h:101
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:389
GLint left
Definition: glext.h:7726
#define put_byte(s, c)
Definition: deflate.h:276
#define COMMENT_STATE
Definition: deflate.h:60
#define CLEAR_HASH(s)
Definition: deflate.c:186
block_state deflate_rle(deflate_state *s, int flush)
Definition: deflate.c:2110
#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:1690
#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:782
#define HCRC_UPDATE(beg)
Definition: deflate.c:807
block_state deflate_huff(deflate_state *s, int flush)
Definition: deflate.c:2184
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 deflateParams().

◆ deflateEnd()

int deflateEnd ( z_streamp  strm)

Definition at line 1130 of file deflate.c.

1132 {
1133  int status;
1134 
1135  if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
1136 
1137  status = strm->state->status;
1138 
1139  /* Deallocate in reverse order of allocations: */
1140  TRY_FREE(strm, strm->state->pending_buf);
1141  TRY_FREE(strm, strm->state->head);
1142  TRY_FREE(strm, strm->state->prev);
1143  TRY_FREE(strm, strm->state->window);
1144 
1145  ZFREE(strm, strm->state);
1146  strm->state = Z_NULL;
1147 
1148  return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
1149 }
#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
z_streamp strm
Definition: deflate.h:101
int deflateStateCheck(z_streamp strm)
Definition: deflate.c:389
#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 deflateCopy(), and deflateInit2_().

◆ deflateInit()

int deflateInit ( z_streamp  strm,
int  level 
)

◆ 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
if(dx==0 &&dy==0)
Definition: linetemp.h:174
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 L(x)
Definition: ntvdm.h:50
#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
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 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(), gzip_read(), 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
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#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
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(), gzip_destroy(), gzip_read(), 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().