ReactOS 0.4.15-dev-7924-g5949c20
inflate.c File Reference
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
#include "inffixed.h"
Include dependency graph for inflate.c:

Go to the source code of this file.

Macros

#define UPDATE_CHECK(check, buf, len)    (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
 
#define CRC2(check, word)
 
#define CRC4(check, word)
 
#define LOAD()
 
#define RESTORE()
 
#define INITBITS()
 
#define PULLBYTE()
 
#define NEEDBITS(n)
 
#define BITS(n)    ((unsigned)hold & ((1U << (n)) - 1))
 
#define DROPBITS(n)
 
#define BYTEBITS()
 

Functions

int inflateStateCheck OF ((z_streamp strm))
 
void fixedtables OF ((struct inflate_state FAR *state))
 
int updatewindow OF ((z_streamp strm, const unsigned char FAR *end, unsigned copy))
 
unsigned syncsearch OF ((unsigned FAR *have, const unsigned char FAR *buf, unsigned len))
 
int inflateStateCheck (z_streamp strm)
 
int ZEXPORT inflateResetKeep (z_streamp strm)
 
int ZEXPORT inflateReset (z_streamp strm)
 
int ZEXPORT inflateReset2 (z_streamp strm, int windowBits)
 
int ZEXPORT inflateInit2_ (z_streamp strm, int windowBits, const char *version, int stream_size)
 
int ZEXPORT inflateInit_ (z_streamp strm, const char *version, int stream_size)
 
int ZEXPORT inflatePrime (z_streamp strm, int bits, int value)
 
void fixedtables (struct inflate_state FAR *state)
 
int updatewindow (z_streamp strm, const Bytef *end, unsigned copy)
 
int ZEXPORT inflate (z_streamp strm, int flush)
 
int ZEXPORT inflateEnd (z_streamp strm)
 
int ZEXPORT inflateGetDictionary (z_streamp strm, Bytef *dictionary, uInt *dictLength)
 
int ZEXPORT inflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength)
 
int ZEXPORT inflateGetHeader (z_streamp strm, gz_headerp head)
 
unsigned syncsearch (unsigned FAR *have, const unsigned char FAR *buf, unsigned len)
 
int ZEXPORT inflateSync (z_streamp strm)
 
int ZEXPORT inflateSyncPoint (z_streamp strm)
 
int ZEXPORT inflateCopy (z_streamp dest, z_streamp source)
 
int ZEXPORT inflateUndermine (z_streamp strm, int subvert)
 
int ZEXPORT inflateValidate (z_streamp strm, int check)
 
long ZEXPORT inflateMark (z_streamp strm)
 
unsigned long ZEXPORT inflateCodesUsed (z_streamp strm)
 

Macro Definition Documentation

◆ BITS

#define BITS (   n)     ((unsigned)hold & ((1U << (n)) - 1))

Definition at line 526 of file inflate.c.

◆ BYTEBITS

#define BYTEBITS ( )
Value:
do { \
hold >>= bits & 7; \
bits -= bits & 7; \
} while (0)
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929

Definition at line 537 of file inflate.c.

◆ CRC2

#define CRC2 (   check,
  word 
)
Value:
do { \
hbuf[0] = (unsigned char)(word); \
hbuf[1] = (unsigned char)((word) >> 8); \
check = crc32(check, hbuf, 2); \
} while (0)
#define crc32(crc, buf, len)
Definition: inflate.c:1081
unsigned char
Definition: typeof.h:29
#define check(expected, result)
Definition: dplayx.c:32
const WCHAR * word
Definition: lex.c:36

Definition at line 461 of file inflate.c.

◆ CRC4

#define CRC4 (   check,
  word 
)
Value:
do { \
hbuf[0] = (unsigned char)(word); \
hbuf[1] = (unsigned char)((word) >> 8); \
hbuf[2] = (unsigned char)((word) >> 16); \
hbuf[3] = (unsigned char)((word) >> 24); \
check = crc32(check, hbuf, 4); \
} while (0)

Definition at line 468 of file inflate.c.

◆ DROPBITS

#define DROPBITS (   n)
Value:
do { \
hold >>= (n); \
bits -= (unsigned)(n); \
} while (0)
GLdouble n
Definition: glext.h:7729
static unsigned(__cdecl *hash_bstr)(bstr_t s)

Definition at line 530 of file inflate.c.

◆ INITBITS

#define INITBITS ( )
Value:
do { \
hold = 0; \
bits = 0; \
} while (0)

Definition at line 501 of file inflate.c.

◆ LOAD

#define LOAD ( )
Value:
do { \
put = strm->next_out; \
left = strm->avail_out; \
next = strm->next_in; \
have = strm->avail_in; \
hold = state->hold; \
bits = state->bits; \
} while (0)
static int state
Definition: maze.c:121
GLint left
Definition: glext.h:7726
#define put(ret, state, sp, n)
Definition: match.c:105
static unsigned __int64 next
Definition: rand_nt.c:6

Definition at line 479 of file inflate.c.

◆ NEEDBITS

#define NEEDBITS (   n)
Value:
do { \
while (bits < (unsigned)(n)) \
PULLBYTE(); \
} while (0)

Definition at line 519 of file inflate.c.

◆ PULLBYTE

#define PULLBYTE ( )
Value:
do { \
if (have == 0) goto inf_leave; \
have--; \
hold += (unsigned long)(*next++) << bits; \
bits += 8; \
} while (0)
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))

Definition at line 509 of file inflate.c.

◆ RESTORE

#define RESTORE ( )
Value:
do { \
strm->next_out = put; \
strm->avail_out = left; \
strm->next_in = next; \
strm->avail_in = have; \
state->hold = hold; \
state->bits = bits; \
} while (0)
#define bits
Definition: infblock.c:15

Definition at line 490 of file inflate.c.

◆ UPDATE_CHECK

#define UPDATE_CHECK (   check,
  buf,
  len 
)     (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))

Definition at line 453 of file inflate.c.

Function Documentation

◆ fixedtables()

void fixedtables ( struct inflate_state FAR state)

Definition at line 281 of file inflate.c.

283{
284#ifdef BUILDFIXED
285 static int virgin = 1;
286 static code *lenfix, *distfix;
287 static code fixed[544];
288
289 /* build fixed huffman tables if first call (may not be thread safe) */
290 if (virgin) {
291 unsigned sym, bits;
292 static code *next;
293
294 /* literal/length table */
295 sym = 0;
296 while (sym < 144) state->lens[sym++] = 8;
297 while (sym < 256) state->lens[sym++] = 9;
298 while (sym < 280) state->lens[sym++] = 7;
299 while (sym < 288) state->lens[sym++] = 8;
300 next = fixed;
301 lenfix = next;
302 bits = 9;
303 inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
304
305 /* distance table */
306 sym = 0;
307 while (sym < 32) state->lens[sym++] = 5;
308 distfix = next;
309 bits = 5;
310 inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
311
312 /* do this just once */
313 virgin = 0;
314 }
315#else /* !BUILDFIXED */
316# include "inffixed.h"
317#endif /* BUILDFIXED */
318 state->lencode = lenfix;
319 state->lenbits = 9;
320 state->distcode = distfix;
321 state->distbits = 5;
322}
ios_base &_STLP_CALL fixed(ios_base &__s)
Definition: _ios_base.h:332
@ LENS
Definition: inflate.c:152
@ DISTS
Definition: inflate.c:153
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
Definition: inflate.c:139
static const code distfix[32]
Definition: inffixed.h:87
static const code lenfix[512]
Definition: inffixed.h:10

◆ inflate()

int ZEXPORT inflate ( z_streamp  strm,
int  flush 
)

Definition at line 625 of file inflate.c.

628{
629 struct inflate_state FAR *state;
630 z_const unsigned char FAR *next; /* next input */
631 unsigned char FAR *put; /* next output */
632 unsigned have, left; /* available input and output */
633 unsigned long hold; /* bit buffer */
634 unsigned bits; /* bits in bit buffer */
635 unsigned in, out; /* save starting available input and output */
636 unsigned copy; /* number of stored or match bytes to copy */
637 unsigned char FAR *from; /* where to copy match bytes from */
638 code here; /* current decoding table entry */
639 code last; /* parent table entry */
640 unsigned len; /* length to copy for repeats, bits to drop */
641 int ret; /* return code */
642#ifdef GUNZIP
643 unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
644#endif
645 static const unsigned short order[19] = /* permutation of code lengths */
646 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
647
648 if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
649 (strm->next_in == Z_NULL && strm->avail_in != 0))
650 return Z_STREAM_ERROR;
651
652 state = (struct inflate_state FAR *)strm->state;
653 if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
654 LOAD();
655 in = have;
656 out = left;
657 ret = Z_OK;
658 for (;;)
659 switch (state->mode) {
660 case HEAD:
661 if (state->wrap == 0) {
662 state->mode = TYPEDO;
663 break;
664 }
665 NEEDBITS(16);
666#ifdef GUNZIP
667 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
668 if (state->wbits == 0)
669 state->wbits = 15;
670 state->check = crc32(0L, Z_NULL, 0);
671 CRC2(state->check, hold);
672 INITBITS();
673 state->mode = FLAGS;
674 break;
675 }
676 if (state->head != Z_NULL)
677 state->head->done = -1;
678 if (!(state->wrap & 1) || /* check if zlib header allowed */
679#else
680 if (
681#endif
682 ((BITS(8) << 8) + (hold >> 8)) % 31) {
683 strm->msg = (char *)"incorrect header check";
684 state->mode = BAD;
685 break;
686 }
687 if (BITS(4) != Z_DEFLATED) {
688 strm->msg = (char *)"unknown compression method";
689 state->mode = BAD;
690 break;
691 }
692 DROPBITS(4);
693 len = BITS(4) + 8;
694 if (state->wbits == 0)
695 state->wbits = len;
696 if (len > 15 || len > state->wbits) {
697 strm->msg = (char *)"invalid window size";
698 state->mode = BAD;
699 break;
700 }
701 state->dmax = 1U << len;
702 state->flags = 0; /* indicate zlib header */
703 Tracev((stderr, "inflate: zlib header ok\n"));
704 strm->adler = state->check = adler32(0L, Z_NULL, 0);
705 state->mode = hold & 0x200 ? DICTID : TYPE;
706 INITBITS();
707 break;
708#ifdef GUNZIP
709 case FLAGS:
710 NEEDBITS(16);
711 state->flags = (int)(hold);
712 if ((state->flags & 0xff) != Z_DEFLATED) {
713 strm->msg = (char *)"unknown compression method";
714 state->mode = BAD;
715 break;
716 }
717 if (state->flags & 0xe000) {
718 strm->msg = (char *)"unknown header flags set";
719 state->mode = BAD;
720 break;
721 }
722 if (state->head != Z_NULL)
723 state->head->text = (int)((hold >> 8) & 1);
724 if ((state->flags & 0x0200) && (state->wrap & 4))
725 CRC2(state->check, hold);
726 INITBITS();
727 state->mode = TIME;
728 /* fallthrough */
729 case TIME:
730 NEEDBITS(32);
731 if (state->head != Z_NULL)
732 state->head->time = hold;
733 if ((state->flags & 0x0200) && (state->wrap & 4))
734 CRC4(state->check, hold);
735 INITBITS();
736 state->mode = OS;
737 /* fallthrough */
738 case OS:
739 NEEDBITS(16);
740 if (state->head != Z_NULL) {
741 state->head->xflags = (int)(hold & 0xff);
742 state->head->os = (int)(hold >> 8);
743 }
744 if ((state->flags & 0x0200) && (state->wrap & 4))
745 CRC2(state->check, hold);
746 INITBITS();
747 state->mode = EXLEN;
748 /* fallthrough */
749 case EXLEN:
750 if (state->flags & 0x0400) {
751 NEEDBITS(16);
752 state->length = (unsigned)(hold);
753 if (state->head != Z_NULL)
754 state->head->extra_len = (unsigned)hold;
755 if ((state->flags & 0x0200) && (state->wrap & 4))
756 CRC2(state->check, hold);
757 INITBITS();
758 }
759 else if (state->head != Z_NULL)
760 state->head->extra = Z_NULL;
761 state->mode = EXTRA;
762 /* fallthrough */
763 case EXTRA:
764 if (state->flags & 0x0400) {
765 copy = state->length;
766 if (copy > have) copy = have;
767 if (copy) {
768 if (state->head != Z_NULL &&
769 state->head->extra != Z_NULL &&
770 (len = state->head->extra_len - state->length) <
771 state->head->extra_max) {
772 zmemcpy(state->head->extra + len, next,
773 len + copy > state->head->extra_max ?
774 state->head->extra_max - len : copy);
775 }
776 if ((state->flags & 0x0200) && (state->wrap & 4))
777 state->check = crc32(state->check, next, copy);
778 have -= copy;
779 next += copy;
780 state->length -= copy;
781 }
782 if (state->length) goto inf_leave;
783 }
784 state->length = 0;
785 state->mode = NAME;
786 /* fallthrough */
787 case NAME:
788 if (state->flags & 0x0800) {
789 if (have == 0) goto inf_leave;
790 copy = 0;
791 do {
792 len = (unsigned)(next[copy++]);
793 if (state->head != Z_NULL &&
794 state->head->name != Z_NULL &&
795 state->length < state->head->name_max)
796 state->head->name[state->length++] = (Bytef)len;
797 } while (len && copy < have);
798 if ((state->flags & 0x0200) && (state->wrap & 4))
799 state->check = crc32(state->check, next, copy);
800 have -= copy;
801 next += copy;
802 if (len) goto inf_leave;
803 }
804 else if (state->head != Z_NULL)
805 state->head->name = Z_NULL;
806 state->length = 0;
807 state->mode = COMMENT;
808 /* fallthrough */
809 case COMMENT:
810 if (state->flags & 0x1000) {
811 if (have == 0) goto inf_leave;
812 copy = 0;
813 do {
814 len = (unsigned)(next[copy++]);
815 if (state->head != Z_NULL &&
816 state->head->comment != Z_NULL &&
817 state->length < state->head->comm_max)
818 state->head->comment[state->length++] = (Bytef)len;
819 } while (len && copy < have);
820 if ((state->flags & 0x0200) && (state->wrap & 4))
821 state->check = crc32(state->check, next, copy);
822 have -= copy;
823 next += copy;
824 if (len) goto inf_leave;
825 }
826 else if (state->head != Z_NULL)
827 state->head->comment = Z_NULL;
828 state->mode = HCRC;
829 /* fallthrough */
830 case HCRC:
831 if (state->flags & 0x0200) {
832 NEEDBITS(16);
833 if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
834 strm->msg = (char *)"header crc mismatch";
835 state->mode = BAD;
836 break;
837 }
838 INITBITS();
839 }
840 if (state->head != Z_NULL) {
841 state->head->hcrc = (int)((state->flags >> 9) & 1);
842 state->head->done = 1;
843 }
844 strm->adler = state->check = crc32(0L, Z_NULL, 0);
845 state->mode = TYPE;
846 break;
847#endif
848 case DICTID:
849 NEEDBITS(32);
850 strm->adler = state->check = ZSWAP32(hold);
851 INITBITS();
852 state->mode = DICT;
853 /* fallthrough */
854 case DICT:
855 if (state->havedict == 0) {
856 RESTORE();
857 return Z_NEED_DICT;
858 }
859 strm->adler = state->check = adler32(0L, Z_NULL, 0);
860 state->mode = TYPE;
861 /* fallthrough */
862 case TYPE:
863 if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
864 /* fallthrough */
865 case TYPEDO:
866 if (state->last) {
867 BYTEBITS();
868 state->mode = CHECK;
869 break;
870 }
871 NEEDBITS(3);
872 state->last = BITS(1);
873 DROPBITS(1);
874 switch (BITS(2)) {
875 case 0: /* stored block */
876 Tracev((stderr, "inflate: stored block%s\n",
877 state->last ? " (last)" : ""));
878 state->mode = STORED;
879 break;
880 case 1: /* fixed block */
882 Tracev((stderr, "inflate: fixed codes block%s\n",
883 state->last ? " (last)" : ""));
884 state->mode = LEN_; /* decode codes */
885 if (flush == Z_TREES) {
886 DROPBITS(2);
887 goto inf_leave;
888 }
889 break;
890 case 2: /* dynamic block */
891 Tracev((stderr, "inflate: dynamic codes block%s\n",
892 state->last ? " (last)" : ""));
893 state->mode = TABLE;
894 break;
895 case 3:
896 strm->msg = (char *)"invalid block type";
897 state->mode = BAD;
898 }
899 DROPBITS(2);
900 break;
901 case STORED:
902 BYTEBITS(); /* go to byte boundary */
903 NEEDBITS(32);
904 if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
905 strm->msg = (char *)"invalid stored block lengths";
906 state->mode = BAD;
907 break;
908 }
909 state->length = (unsigned)hold & 0xffff;
910 Tracev((stderr, "inflate: stored length %u\n",
911 state->length));
912 INITBITS();
913 state->mode = COPY_;
914 if (flush == Z_TREES) goto inf_leave;
915 /* fallthrough */
916 case COPY_:
917 state->mode = COPY;
918 /* fallthrough */
919 case COPY:
920 copy = state->length;
921 if (copy) {
922 if (copy > have) copy = have;
923 if (copy > left) copy = left;
924 if (copy == 0) goto inf_leave;
925 zmemcpy(put, next, copy);
926 have -= copy;
927 next += copy;
928 left -= copy;
929 put += copy;
930 state->length -= copy;
931 break;
932 }
933 Tracev((stderr, "inflate: stored end\n"));
934 state->mode = TYPE;
935 break;
936 case TABLE:
937 NEEDBITS(14);
938 state->nlen = BITS(5) + 257;
939 DROPBITS(5);
940 state->ndist = BITS(5) + 1;
941 DROPBITS(5);
942 state->ncode = BITS(4) + 4;
943 DROPBITS(4);
944#ifndef PKZIP_BUG_WORKAROUND
945 if (state->nlen > 286 || state->ndist > 30) {
946 strm->msg = (char *)"too many length or distance symbols";
947 state->mode = BAD;
948 break;
949 }
950#endif
951 Tracev((stderr, "inflate: table sizes ok\n"));
952 state->have = 0;
953 state->mode = LENLENS;
954 /* fallthrough */
955 case LENLENS:
956 while (state->have < state->ncode) {
957 NEEDBITS(3);
958 state->lens[order[state->have++]] = (unsigned short)BITS(3);
959 DROPBITS(3);
960 }
961 while (state->have < 19)
962 state->lens[order[state->have++]] = 0;
963 state->next = state->codes;
964 state->lencode = (const code FAR *)(state->next);
965 state->lenbits = 7;
966 ret = inflate_table(CODES, state->lens, 19, &(state->next),
967 &(state->lenbits), state->work);
968 if (ret) {
969 strm->msg = (char *)"invalid code lengths set";
970 state->mode = BAD;
971 break;
972 }
973 Tracev((stderr, "inflate: code lengths ok\n"));
974 state->have = 0;
975 state->mode = CODELENS;
976 /* fallthrough */
977 case CODELENS:
978 while (state->have < state->nlen + state->ndist) {
979 for (;;) {
980 here = state->lencode[BITS(state->lenbits)];
981 if ((unsigned)(here.bits) <= bits) break;
982 PULLBYTE();
983 }
984 if (here.val < 16) {
985 DROPBITS(here.bits);
986 state->lens[state->have++] = here.val;
987 }
988 else {
989 if (here.val == 16) {
990 NEEDBITS(here.bits + 2);
991 DROPBITS(here.bits);
992 if (state->have == 0) {
993 strm->msg = (char *)"invalid bit length repeat";
994 state->mode = BAD;
995 break;
996 }
997 len = state->lens[state->have - 1];
998 copy = 3 + BITS(2);
999 DROPBITS(2);
1000 }
1001 else if (here.val == 17) {
1002 NEEDBITS(here.bits + 3);
1003 DROPBITS(here.bits);
1004 len = 0;
1005 copy = 3 + BITS(3);
1006 DROPBITS(3);
1007 }
1008 else {
1009 NEEDBITS(here.bits + 7);
1010 DROPBITS(here.bits);
1011 len = 0;
1012 copy = 11 + BITS(7);
1013 DROPBITS(7);
1014 }
1015 if (state->have + copy > state->nlen + state->ndist) {
1016 strm->msg = (char *)"invalid bit length repeat";
1017 state->mode = BAD;
1018 break;
1019 }
1020 while (copy--)
1021 state->lens[state->have++] = (unsigned short)len;
1022 }
1023 }
1024
1025 /* handle error breaks in while */
1026 if (state->mode == BAD) break;
1027
1028 /* check for end-of-block code (better have one) */
1029 if (state->lens[256] == 0) {
1030 strm->msg = (char *)"invalid code -- missing end-of-block";
1031 state->mode = BAD;
1032 break;
1033 }
1034
1035 /* build code tables -- note: do not change the lenbits or distbits
1036 values here (9 and 6) without reading the comments in inftrees.h
1037 concerning the ENOUGH constants, which depend on those values */
1038 state->next = state->codes;
1039 state->lencode = (const code FAR *)(state->next);
1040 state->lenbits = 9;
1041 ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
1042 &(state->lenbits), state->work);
1043 if (ret) {
1044 strm->msg = (char *)"invalid literal/lengths set";
1045 state->mode = BAD;
1046 break;
1047 }
1048 state->distcode = (const code FAR *)(state->next);
1049 state->distbits = 6;
1050 ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
1051 &(state->next), &(state->distbits), state->work);
1052 if (ret) {
1053 strm->msg = (char *)"invalid distances set";
1054 state->mode = BAD;
1055 break;
1056 }
1057 Tracev((stderr, "inflate: codes ok\n"));
1058 state->mode = LEN_;
1059 if (flush == Z_TREES) goto inf_leave;
1060 /* fallthrough */
1061 case LEN_:
1062 state->mode = LEN;
1063 /* fallthrough */
1064 case LEN:
1065 if (have >= 6 && left >= 258) {
1066 RESTORE();
1068 LOAD();
1069 if (state->mode == TYPE)
1070 state->back = -1;
1071 break;
1072 }
1073 state->back = 0;
1074 for (;;) {
1075 here = state->lencode[BITS(state->lenbits)];
1076 if ((unsigned)(here.bits) <= bits) break;
1077 PULLBYTE();
1078 }
1079 if (here.op && (here.op & 0xf0) == 0) {
1080 last = here;
1081 for (;;) {
1082 here = state->lencode[last.val +
1083 (BITS(last.bits + last.op) >> last.bits)];
1084 if ((unsigned)(last.bits + here.bits) <= bits) break;
1085 PULLBYTE();
1086 }
1087 DROPBITS(last.bits);
1088 state->back += last.bits;
1089 }
1090 DROPBITS(here.bits);
1091 state->back += here.bits;
1092 state->length = (unsigned)here.val;
1093 if ((int)(here.op) == 0) {
1094 Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
1095 "inflate: literal '%c'\n" :
1096 "inflate: literal 0x%02x\n", here.val));
1097 state->mode = LIT;
1098 break;
1099 }
1100 if (here.op & 32) {
1101 Tracevv((stderr, "inflate: end of block\n"));
1102 state->back = -1;
1103 state->mode = TYPE;
1104 break;
1105 }
1106 if (here.op & 64) {
1107 strm->msg = (char *)"invalid literal/length code";
1108 state->mode = BAD;
1109 break;
1110 }
1111 state->extra = (unsigned)(here.op) & 15;
1112 state->mode = LENEXT;
1113 /* fallthrough */
1114 case LENEXT:
1115 if (state->extra) {
1116 NEEDBITS(state->extra);
1117 state->length += BITS(state->extra);
1118 DROPBITS(state->extra);
1119 state->back += state->extra;
1120 }
1121 Tracevv((stderr, "inflate: length %u\n", state->length));
1122 state->was = state->length;
1123 state->mode = DIST;
1124 /* fallthrough */
1125 case DIST:
1126 for (;;) {
1127 here = state->distcode[BITS(state->distbits)];
1128 if ((unsigned)(here.bits) <= bits) break;
1129 PULLBYTE();
1130 }
1131 if ((here.op & 0xf0) == 0) {
1132 last = here;
1133 for (;;) {
1134 here = state->distcode[last.val +
1135 (BITS(last.bits + last.op) >> last.bits)];
1136 if ((unsigned)(last.bits + here.bits) <= bits) break;
1137 PULLBYTE();
1138 }
1139 DROPBITS(last.bits);
1140 state->back += last.bits;
1141 }
1142 DROPBITS(here.bits);
1143 state->back += here.bits;
1144 if (here.op & 64) {
1145 strm->msg = (char *)"invalid distance code";
1146 state->mode = BAD;
1147 break;
1148 }
1149 state->offset = (unsigned)here.val;
1150 state->extra = (unsigned)(here.op) & 15;
1151 state->mode = DISTEXT;
1152 /* fallthrough */
1153 case DISTEXT:
1154 if (state->extra) {
1155 NEEDBITS(state->extra);
1156 state->offset += BITS(state->extra);
1157 DROPBITS(state->extra);
1158 state->back += state->extra;
1159 }
1160#ifdef INFLATE_STRICT
1161 if (state->offset > state->dmax) {
1162 strm->msg = (char *)"invalid distance too far back";
1163 state->mode = BAD;
1164 break;
1165 }
1166#endif
1167 Tracevv((stderr, "inflate: distance %u\n", state->offset));
1168 state->mode = MATCH;
1169 /* fallthrough */
1170 case MATCH:
1171 if (left == 0) goto inf_leave;
1172 copy = out - left;
1173 if (state->offset > copy) { /* copy from window */
1174 copy = state->offset - copy;
1175 if (copy > state->whave) {
1176 if (state->sane) {
1177 strm->msg = (char *)"invalid distance too far back";
1178 state->mode = BAD;
1179 break;
1180 }
1181#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1182 Trace((stderr, "inflate.c too far\n"));
1183 copy -= state->whave;
1184 if (copy > state->length) copy = state->length;
1185 if (copy > left) copy = left;
1186 left -= copy;
1187 state->length -= copy;
1188 do {
1189 *put++ = 0;
1190 } while (--copy);
1191 if (state->length == 0) state->mode = LEN;
1192 break;
1193#endif
1194 }
1195 if (copy > state->wnext) {
1196 copy -= state->wnext;
1197 from = state->window + (state->wsize - copy);
1198 }
1199 else
1200 from = state->window + (state->wnext - copy);
1201 if (copy > state->length) copy = state->length;
1202 }
1203 else { /* copy from output */
1204 from = put - state->offset;
1205 copy = state->length;
1206 }
1207 if (copy > left) copy = left;
1208 left -= copy;
1209 state->length -= copy;
1210 do {
1211 *put++ = *from++;
1212 } while (--copy);
1213 if (state->length == 0) state->mode = LEN;
1214 break;
1215 case LIT:
1216 if (left == 0) goto inf_leave;
1217 *put++ = (unsigned char)(state->length);
1218 left--;
1219 state->mode = LEN;
1220 break;
1221 case CHECK:
1222 if (state->wrap) {
1223 NEEDBITS(32);
1224 out -= left;
1225 strm->total_out += out;
1226 state->total += out;
1227 if ((state->wrap & 4) && out)
1228 strm->adler = state->check =
1229 UPDATE_CHECK(state->check, put - out, out);
1230 out = left;
1231 if ((state->wrap & 4) && (
1232#ifdef GUNZIP
1233 state->flags ? hold :
1234#endif
1235 ZSWAP32(hold)) != state->check) {
1236 strm->msg = (char *)"incorrect data check";
1237 state->mode = BAD;
1238 break;
1239 }
1240 INITBITS();
1241 Tracev((stderr, "inflate: check matches trailer\n"));
1242 }
1243#ifdef GUNZIP
1244 state->mode = LENGTH;
1245 /* fallthrough */
1246 case LENGTH:
1247 if (state->wrap && state->flags) {
1248 NEEDBITS(32);
1249 if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
1250 strm->msg = (char *)"incorrect length check";
1251 state->mode = BAD;
1252 break;
1253 }
1254 INITBITS();
1255 Tracev((stderr, "inflate: length matches trailer\n"));
1256 }
1257#endif
1258 state->mode = DONE;
1259 /* fallthrough */
1260 case DONE:
1261 ret = Z_STREAM_END;
1262 goto inf_leave;
1263 case BAD:
1264 ret = Z_DATA_ERROR;
1265 goto inf_leave;
1266 case MEM:
1267 return Z_MEM_ERROR;
1268 case SYNC:
1269 /* fallthrough */
1270 default:
1271 return Z_STREAM_ERROR;
1272 }
1273
1274 /*
1275 Return from inflate(), updating the total counts and the check value.
1276 If there was no progress during the inflate() call, return a buffer
1277 error. Call updatewindow() to create and/or update the window state.
1278 Note: a memory error from inflate() is non-recoverable.
1279 */
1280 inf_leave:
1281 RESTORE();
1282 if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
1283 (state->mode < CHECK || flush != Z_FINISH)))
1284 if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
1285 state->mode = MEM;
1286 return Z_MEM_ERROR;
1287 }
1288 in -= strm->avail_in;
1289 out -= strm->avail_out;
1290 strm->total_in += in;
1291 strm->total_out += out;
1292 state->total += out;
1293 if ((state->wrap & 4) && out)
1294 strm->adler = state->check =
1295 UPDATE_CHECK(state->check, strm->next_out - out, out);
1296 strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
1297 (state->mode == TYPE ? 128 : 0) +
1298 (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
1299 if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
1300 ret = Z_BUF_ERROR;
1301 return ret;
1302}
INT copy(TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
Definition: copy.c:51
#define LOAD()
Definition: inflate.c:1111
@ CODES
Definition: inflate.c:151
@ HEAD
Definition: inflate.c:158
@ MATCH
Definition: inflate.c:182
@ DICT
Definition: inflate.c:168
@ TABLE
Definition: inflate.c:174
@ LENGTH
Definition: inflate.c:185
@ FLAGS
Definition: inflate.c:159
@ LIT
Definition: inflate.c:183
@ SYNC
Definition: inflate.c:189
@ OS
Definition: inflate.c:161
@ EXLEN
Definition: inflate.c:162
@ MEM
Definition: inflate.c:188
@ NAME
Definition: inflate.c:164
@ STORED
Definition: inflate.c:171
@ CODELENS
Definition: inflate.c:176
@ DICTID
Definition: inflate.c:167
@ DONE
Definition: inflate.c:186
@ TYPEDO
Definition: inflate.c:170
@ COMMENT
Definition: inflate.c:165
@ LENLENS
Definition: inflate.c:175
@ TYPE
Definition: inflate.c:169
@ COPY
Definition: inflate.c:173
@ LEN_
Definition: inflate.c:177
@ COPY_
Definition: inflate.c:172
@ DIST
Definition: inflate.c:180
@ LENEXT
Definition: inflate.c:179
@ HCRC
Definition: inflate.c:166
@ TIME
Definition: inflate.c:160
@ CHECK
Definition: inflate.c:184
@ DISTEXT
Definition: inflate.c:181
@ BAD
Definition: inflate.c:187
@ LEN
Definition: inflate.c:178
@ EXTRA
Definition: inflate.c:163
#define CRC2(check, word)
Definition: inflate.c:1093
#define zmemcpy
Definition: inflate.c:38
#define INITBITS()
Definition: inflate.c:1133
#define CRC4(check, word)
Definition: inflate.c:1100
#define BITS(n)
Definition: inflate.c:1158
static void inflate_fast(z_streamp strm, unsigned start)
Definition: inflate.c:274
#define DROPBITS(n)
Definition: inflate.c:1162
static int inflateStateCheck(z_streamp strm)
Definition: inflate.c:802
#define Tracev(x)
Definition: inflate.c:43
static void fixedtables(struct inflate_state FAR *state)
Definition: inflate.c:924
#define Trace(x)
Definition: inflate.c:42
#define BYTEBITS()
Definition: inflate.c:1169
#define ZSWAP32(q)
Definition: inflate.c:55
static uLong adler32(uLong adler, const Bytef *buf, uInt len)
Definition: inflate.c:72
#define NEEDBITS(n)
Definition: inflate.c:1151
#define PULLBYTE()
Definition: inflate.c:1141
#define Tracevv(x)
Definition: inflate.c:44
#define GUNZIP
Definition: inflate.c:47
static int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
Definition: inflate.c:1032
#define RESTORE()
Definition: inflate.c:1122
#define Z_TREES
Definition: zlib.h:111
#define Z_DEFLATED
Definition: zlib.h:146
#define Z_NEED_DICT
Definition: zlib.h:116
#define Z_BUF_ERROR
Definition: zlib.h:121
#define Z_BLOCK
Definition: zlib.h:110
#define Z_STREAM_END
Definition: zlib.h:115
#define Z_FINISH
Definition: zlib.h:109
#define Z_OK
Definition: zlib.h:114
#define z_const
Definition: zlib.h:35
#define Z_DATA_ERROR
Definition: zlib.h:119
#define Z_STREAM_ERROR
Definition: zlib.h:118
#define Z_NULL
Definition: zlib.h:149
#define Z_MEM_ERROR
Definition: zlib.h:120
Byte FAR Bytef
Definition: zlib.h:41
#define FAR
Definition: zlib.h:34
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
TYPE
Definition: eventcreate.c:652
GLuint in
Definition: glext.h:9616
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
GLenum GLsizei len
Definition: glext.h:6722
#define stderr
Definition: stdio.h:100
if(dx< 0)
Definition: linetemp.h:194
static UINT UINT last
Definition: font.c:45
#define L(x)
Definition: ntvdm.h:50
static FILE * out
Definition: regtests2xml.c:44
int flush
Definition: zlib.h:309
#define UPDATE_CHECK(check, buf, len)
Definition: inflate.c:453
CardRegion * from
Definition: spigame.cpp:19
unsigned char op
Definition: inflate.c:140
unsigned char bits
Definition: inflate.c:141
unsigned short val
Definition: inflate.c:142
unsigned have
Definition: inflate.c:229
unsigned long hold
Definition: inflate.c:213
z_streamp strm
Definition: inflate.c:195
int ret

◆ inflateCodesUsed()

unsigned long ZEXPORT inflateCodesUsed ( z_streamp  strm)

Definition at line 1588 of file inflate.c.

1590{
1591 struct inflate_state FAR *state;
1592 if (inflateStateCheck(strm)) return (unsigned long)-1;
1593 state = (struct inflate_state FAR *)strm->state;
1594 return (unsigned long)(state->next - state->codes);
1595}
return
Definition: dirsup.c:529

◆ inflateCopy()

int ZEXPORT inflateCopy ( z_streamp  dest,
z_streamp  source 
)

Definition at line 1495 of file inflate.c.

1498{
1499 struct inflate_state FAR *state;
1500 struct inflate_state FAR *copy;
1501 unsigned char FAR *window;
1502 unsigned wsize;
1503
1504 /* check input */
1506 return Z_STREAM_ERROR;
1507 state = (struct inflate_state FAR *)source->state;
1508
1509 /* allocate space */
1510 copy = (struct inflate_state FAR *)
1511 ZALLOC(source, 1, sizeof(struct inflate_state));
1512 if (copy == Z_NULL) return Z_MEM_ERROR;
1513 window = Z_NULL;
1514 if (state->window != Z_NULL) {
1515 window = (unsigned char FAR *)
1516 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
1517 if (window == Z_NULL) {
1518 ZFREE(source, copy);
1519 return Z_MEM_ERROR;
1520 }
1521 }
1522
1523 /* copy state */
1524 zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
1525 zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
1526 copy->strm = dest;
1527 if (state->lencode >= state->codes &&
1528 state->lencode <= state->codes + ENOUGH - 1) {
1529 copy->lencode = copy->codes + (state->lencode - state->codes);
1530 copy->distcode = copy->codes + (state->distcode - state->codes);
1531 }
1532 copy->next = copy->codes + (state->next - state->codes);
1533 if (window != Z_NULL) {
1534 wsize = 1U << state->wbits;
1535 zmemcpy(window, state->window, wsize);
1536 }
1537 copy->window = window;
1538 dest->state = (struct internal_state FAR *)copy;
1539 return Z_OK;
1540}
#define ZALLOC(strm, items, size)
Definition: inflate.c:49
#define ZFREE(strm, addr)
Definition: inflate.c:51
#define ENOUGH
Definition: inflate.c:147
void FAR * voidpf
Definition: zlib.h:42
static IHTMLWindow2 * window
Definition: events.c:77
static char * dest
Definition: rtl.c:135
unsigned wsize
Definition: inflate.c:208

◆ inflateEnd()

int ZEXPORT inflateEnd ( z_streamp  strm)

Definition at line 1304 of file inflate.c.

1306{
1307 struct inflate_state FAR *state;
1309 return Z_STREAM_ERROR;
1310 state = (struct inflate_state FAR *)strm->state;
1311 if (state->window != Z_NULL) ZFREE(strm, state->window);
1312 ZFREE(strm, strm->state);
1313 strm->state = Z_NULL;
1314 Tracev((stderr, "inflate: end\n"));
1315 return Z_OK;
1316}

◆ inflateGetDictionary()

int ZEXPORT inflateGetDictionary ( z_streamp  strm,
Bytef dictionary,
uInt dictLength 
)

Definition at line 1318 of file inflate.c.

1322{
1323 struct inflate_state FAR *state;
1324
1325 /* check state */
1327 state = (struct inflate_state FAR *)strm->state;
1328
1329 /* copy dictionary */
1330 if (state->whave && dictionary != Z_NULL) {
1331 zmemcpy(dictionary, state->window + state->wnext,
1332 state->whave - state->wnext);
1333 zmemcpy(dictionary + state->whave - state->wnext,
1334 state->window, state->wnext);
1335 }
1336 if (dictLength != Z_NULL)
1337 *dictLength = state->whave;
1338 return Z_OK;
1339}

◆ inflateGetHeader()

int ZEXPORT inflateGetHeader ( z_streamp  strm,
gz_headerp  head 
)

Definition at line 1376 of file inflate.c.

1379{
1380 struct inflate_state FAR *state;
1381
1382 /* check state */
1384 state = (struct inflate_state FAR *)strm->state;
1385 if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
1386
1387 /* save header structure */
1388 state->head = head;
1389 head->done = 0;
1390 return Z_OK;
1391}
struct outqueuenode * head
Definition: adnsresfilter.c:66

◆ inflateInit2_()

int ZEXPORT inflateInit2_ ( z_streamp  strm,
int  windowBits,
const char version,
int  stream_size 
)

Definition at line 198 of file inflate.c.

203{
204 int ret;
205 struct inflate_state FAR *state;
206
207 if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
208 stream_size != (int)(sizeof(z_stream)))
209 return Z_VERSION_ERROR;
210 if (strm == Z_NULL) return Z_STREAM_ERROR;
211 strm->msg = Z_NULL; /* in case we return an error */
212 if (strm->zalloc == (alloc_func)0) {
213#ifdef Z_SOLO
214 return Z_STREAM_ERROR;
215#else
216 strm->zalloc = zcalloc;
217 strm->opaque = (voidpf)0;
218#endif
219 }
220 if (strm->zfree == (free_func)0)
221#ifdef Z_SOLO
222 return Z_STREAM_ERROR;
223#else
224 strm->zfree = zcfree;
225#endif
226 state = (struct inflate_state FAR *)
227 ZALLOC(strm, 1, sizeof(struct inflate_state));
228 if (state == Z_NULL) return Z_MEM_ERROR;
229 Tracev((stderr, "inflate: allocated\n"));
230 strm->state = (struct internal_state FAR *)state;
231 state->strm = strm;
232 state->window = Z_NULL;
233 state->mode = HEAD; /* to pass state test in inflateReset2() */
235 if (ret != Z_OK) {
236 ZFREE(strm, state);
237 strm->state = Z_NULL;
238 }
239 return ret;
240}
#define Z_SOLO
Definition: cabinet.c:15
static int inflateReset2(z_streamp strm, int windowBits)
Definition: inflate.c:851
void(* free_func)(voidpf opaque, voidpf address)
Definition: zlib.h:54
voidpf(* alloc_func)(voidpf opaque, uInt items, uInt size)
Definition: zlib.h:53
#define Z_VERSION_ERROR
Definition: zlib.h:122
static const WCHAR version[]
Definition: asmname.c:66
void zcfree(voidpf opaque, voidpf ptr)
Definition: zutil.c:173
voidpf zcalloc(voidpf opaque, unsigned items, unsigned size)
Definition: zutil.c:164
#define ZLIB_VERSION
Definition: zlib.h:40
int const char int stream_size
Definition: zlib.h:814
int windowBits
Definition: zlib.h:813
z_streamp strm
Definition: deflate.h:101

Referenced by inflateInit_().

◆ inflateInit_()

int ZEXPORT inflateInit_ ( z_streamp  strm,
const char version,
int  stream_size 
)

Definition at line 242 of file inflate.c.

246{
248}
#define DEF_WBITS
Definition: inflate.c:37
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size)
Definition: inflate.c:198

◆ inflateMark()

long ZEXPORT inflateMark ( z_streamp  strm)

Definition at line 1575 of file inflate.c.

1577{
1578 struct inflate_state FAR *state;
1579
1581 return -(1L << 16);
1582 state = (struct inflate_state FAR *)strm->state;
1583 return (long)(((unsigned long)((long)state->back)) << 16) +
1584 (state->mode == COPY ? state->length :
1585 (state->mode == MATCH ? state->was - state->length : 0));
1586}
#define long
Definition: qsort.c:33

◆ inflatePrime()

int ZEXPORT inflatePrime ( z_streamp  strm,
int  bits,
int  value 
)

Definition at line 250 of file inflate.c.

254{
255 struct inflate_state FAR *state;
256
258 state = (struct inflate_state FAR *)strm->state;
259 if (bits < 0) {
260 state->hold = 0;
261 state->bits = 0;
262 return Z_OK;
263 }
264 if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
265 value &= (1L << bits) - 1;
266 state->hold += (unsigned)value << state->bits;
267 state->bits += (uInt)bits;
268 return Z_OK;
269}
unsigned int uInt
Definition: zlib.h:38
Definition: pdh_main.c:94

◆ inflateReset()

int ZEXPORT inflateReset ( z_streamp  strm)

Definition at line 145 of file inflate.c.

147{
148 struct inflate_state FAR *state;
149
151 state = (struct inflate_state FAR *)strm->state;
152 state->wsize = 0;
153 state->whave = 0;
154 state->wnext = 0;
155 return inflateResetKeep(strm);
156}
static int inflateResetKeep(z_streamp strm)
Definition: inflate.c:815

◆ inflateReset2()

int ZEXPORT inflateReset2 ( z_streamp  strm,
int  windowBits 
)

Definition at line 158 of file inflate.c.

161{
162 int wrap;
163 struct inflate_state FAR *state;
164
165 /* get the state */
167 state = (struct inflate_state FAR *)strm->state;
168
169 /* extract wrap request from windowBits parameter */
170 if (windowBits < 0) {
171 if (windowBits < -15)
172 return Z_STREAM_ERROR;
173 wrap = 0;
175 }
176 else {
177 wrap = (windowBits >> 4) + 5;
178#ifdef GUNZIP
179 if (windowBits < 48)
180 windowBits &= 15;
181#endif
182 }
183
184 /* set number of window bits, free window if different */
185 if (windowBits && (windowBits < 8 || windowBits > 15))
186 return Z_STREAM_ERROR;
187 if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
188 ZFREE(strm, state->window);
189 state->window = Z_NULL;
190 }
191
192 /* update state and reset the rest of it */
193 state->wrap = wrap;
194 state->wbits = (unsigned)windowBits;
195 return inflateReset(strm);
196}
static int inflateReset(z_streamp strm)
Definition: inflate.c:839
#define wrap(journal, var)
Definition: recovery.c:207

◆ inflateResetKeep()

int ZEXPORT inflateResetKeep ( z_streamp  strm)

Definition at line 119 of file inflate.c.

121{
122 struct inflate_state FAR *state;
123
125 state = (struct inflate_state FAR *)strm->state;
126 strm->total_in = strm->total_out = state->total = 0;
127 strm->msg = Z_NULL;
128 if (state->wrap) /* to support ill-conceived Java test suite */
129 strm->adler = state->wrap & 1;
130 state->mode = HEAD;
131 state->last = 0;
132 state->havedict = 0;
133 state->flags = -1;
134 state->dmax = 32768U;
135 state->head = Z_NULL;
136 state->hold = 0;
137 state->bits = 0;
138 state->lencode = state->distcode = state->next = state->codes;
139 state->sane = 1;
140 state->back = -1;
141 Tracev((stderr, "inflate: reset\n"));
142 return Z_OK;
143}

◆ inflateSetDictionary()

int ZEXPORT inflateSetDictionary ( z_streamp  strm,
const Bytef dictionary,
uInt  dictLength 
)

Definition at line 1341 of file inflate.c.

1345{
1346 struct inflate_state FAR *state;
1347 unsigned long dictid;
1348 int ret;
1349
1350 /* check state */
1352 state = (struct inflate_state FAR *)strm->state;
1353 if (state->wrap != 0 && state->mode != DICT)
1354 return Z_STREAM_ERROR;
1355
1356 /* check for correct dictionary identifier */
1357 if (state->mode == DICT) {
1358 dictid = adler32(0L, Z_NULL, 0);
1359 dictid = adler32(dictid, dictionary, dictLength);
1360 if (dictid != state->check)
1361 return Z_DATA_ERROR;
1362 }
1363
1364 /* copy dictionary to window using updatewindow(), which will amend the
1365 existing dictionary if appropriate */
1366 ret = updatewindow(strm, dictionary + dictLength, dictLength);
1367 if (ret) {
1368 state->mode = MEM;
1369 return Z_MEM_ERROR;
1370 }
1371 state->havedict = 1;
1372 Tracev((stderr, "inflate: dictionary set\n"));
1373 return Z_OK;
1374}

◆ inflateStateCheck()

int inflateStateCheck ( z_streamp  strm)

Definition at line 105 of file inflate.c.

107{
108 struct inflate_state FAR *state;
109 if (strm == Z_NULL ||
110 strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
111 return 1;
112 state = (struct inflate_state FAR *)strm->state;
113 if (state == Z_NULL || state->strm != strm ||
114 state->mode < HEAD || state->mode > SYNC)
115 return 1;
116 return 0;
117}
Definition: ntuser.h:180

◆ inflateSync()

int ZEXPORT inflateSync ( z_streamp  strm)

Definition at line 1427 of file inflate.c.

1429{
1430 unsigned len; /* number of bytes to look at or looked at */
1431 int flags; /* temporary to save header status */
1432 unsigned long in, out; /* temporary to save total_in and total_out */
1433 unsigned char buf[4]; /* to restore bit buffer to byte string */
1434 struct inflate_state FAR *state;
1435
1436 /* check parameters */
1438 state = (struct inflate_state FAR *)strm->state;
1439 if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
1440
1441 /* if first time, start search in bit buffer */
1442 if (state->mode != SYNC) {
1443 state->mode = SYNC;
1444 state->hold <<= state->bits & 7;
1445 state->bits -= state->bits & 7;
1446 len = 0;
1447 while (state->bits >= 8) {
1448 buf[len++] = (unsigned char)(state->hold);
1449 state->hold >>= 8;
1450 state->bits -= 8;
1451 }
1452 state->have = 0;
1453 syncsearch(&(state->have), buf, len);
1454 }
1455
1456 /* search available input */
1457 len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
1458 strm->avail_in -= len;
1459 strm->next_in += len;
1460 strm->total_in += len;
1461
1462 /* return no joy or set up to restart inflate() on a new block */
1463 if (state->have != 4) return Z_DATA_ERROR;
1464 if (state->flags == -1)
1465 state->wrap = 0; /* if no header yet, treat as raw */
1466 else
1467 state->wrap &= ~4; /* no point in computing a check value now */
1468 flags = state->flags;
1469 in = strm->total_in; out = strm->total_out;
1471 strm->total_in = in; strm->total_out = out;
1472 state->flags = flags;
1473 state->mode = TYPE;
1474 return Z_OK;
1475}
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, unsigned len)
Definition: inflate.c:1404

◆ inflateSyncPoint()

int ZEXPORT inflateSyncPoint ( z_streamp  strm)

Definition at line 1485 of file inflate.c.

1487{
1488 struct inflate_state FAR *state;
1489
1491 state = (struct inflate_state FAR *)strm->state;
1492 return state->mode == STORED && state->bits == 0;
1493}

◆ inflateUndermine()

int ZEXPORT inflateUndermine ( z_streamp  strm,
int  subvert 
)

Definition at line 1542 of file inflate.c.

1545{
1546 struct inflate_state FAR *state;
1547
1549 state = (struct inflate_state FAR *)strm->state;
1550#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1551 state->sane = !subvert;
1552 return Z_OK;
1553#else
1554 (void)subvert;
1555 state->sane = 1;
1556 return Z_DATA_ERROR;
1557#endif
1558}
else
Definition: tritemp.h:161

◆ inflateValidate()

int ZEXPORT inflateValidate ( z_streamp  strm,
int  check 
)

Definition at line 1560 of file inflate.c.

1563{
1564 struct inflate_state FAR *state;
1565
1567 state = (struct inflate_state FAR *)strm->state;
1568 if (check && state->wrap)
1569 state->wrap |= 4;
1570 else
1571 state->wrap &= ~4;
1572 return Z_OK;
1573}

◆ OF() [1/4]

◆ OF() [2/4]

◆ OF() [3/4]

int inflateStateCheck OF ( (z_streamp strm)  )

◆ OF() [4/4]

◆ syncsearch()

unsigned syncsearch ( unsigned FAR have,
const unsigned char FAR buf,
unsigned  len 
)

Definition at line 1404 of file inflate.c.

1408{
1409 unsigned got;
1410 unsigned next;
1411
1412 got = *have;
1413 next = 0;
1414 while (next < len && got < 4) {
1415 if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
1416 got++;
1417 else if (buf[next])
1418 got = 0;
1419 else
1420 got = 4 - got;
1421 next++;
1422 }
1423 *have = got;
1424 return next;
1425}

Referenced by inflateSync().

◆ updatewindow()

int updatewindow ( z_streamp  strm,
const Bytef end,
unsigned  copy 
)

Definition at line 399 of file inflate.c.

403{
404 struct inflate_state FAR *state;
405 unsigned dist;
406
407 state = (struct inflate_state FAR *)strm->state;
408
409 /* if it hasn't been done already, allocate space for the window */
410 if (state->window == Z_NULL) {
411 state->window = (unsigned char FAR *)
412 ZALLOC(strm, 1U << state->wbits,
413 sizeof(unsigned char));
414 if (state->window == Z_NULL) return 1;
415 }
416
417 /* if window not in use yet, initialize */
418 if (state->wsize == 0) {
419 state->wsize = 1U << state->wbits;
420 state->wnext = 0;
421 state->whave = 0;
422 }
423
424 /* copy state->wsize or less output bytes into the circular window */
425 if (copy >= state->wsize) {
426 zmemcpy(state->window, end - state->wsize, state->wsize);
427 state->wnext = 0;
428 state->whave = state->wsize;
429 }
430 else {
431 dist = state->wsize - state->wnext;
432 if (dist > copy) dist = copy;
433 zmemcpy(state->window + state->wnext, end - copy, dist);
434 copy -= dist;
435 if (copy) {
436 zmemcpy(state->window, end - copy, copy);
437 state->wnext = copy;
438 state->whave = state->wsize;
439 }
440 else {
441 state->wnext += dist;
442 if (state->wnext == state->wsize) state->wnext = 0;
443 if (state->whave < state->wsize) state->whave += dist;
444 }
445 }
446 return 0;
447}
GLuint GLuint end
Definition: gl.h:1545