100 void makefixed
OF((
void));
110 strm->zalloc == (alloc_func)0 ||
strm->zfree == (free_func)0)
134 state->dmax = 32768U;
141 Tracev((stderr,
"inflate: reset\n"));
170 if (windowBits < 0) {
172 windowBits = -windowBits;
175 wrap = (windowBits >> 4) + 5;
183 if (windowBits && (windowBits < 8 || windowBits > 15))
206 stream_size != (
int)(
sizeof(
z_stream)))
210 if (
strm->zalloc == (alloc_func)0) {
218 if (
strm->zfree == (free_func)0)
227 Tracev((stderr,
"inflate: allocated\n"));
283 static int virgin = 1;
294 while (sym < 144)
state->lens[sym++] = 8;
295 while (sym < 256)
state->lens[sym++] = 9;
296 while (sym < 280)
state->lens[sym++] = 7;
297 while (sym < 288)
state->lens[sym++] = 8;
305 while (sym < 32)
state->lens[sym++] = 5;
349 puts(
" /* inffixed.h -- table for decoding fixed codes");
350 puts(
" * Generated automatically by makefixed().");
353 puts(
" /* WARNING: this file should *not* be used by applications.");
354 puts(
" It is part of the implementation of this library and is");
355 puts(
" subject to change. Applications should only use zlib.h.");
359 printf(
" static const code lenfix[%u] = {",
size);
362 if ((low % 7) == 0)
printf(
"\n ");
363 printf(
"{%u,%u,%d}", (low & 127) == 99 ? 64 :
state.lencode[low].op,
364 state.lencode[low].bits,
state.lencode[low].val);
365 if (++low ==
size)
break;
370 printf(
"\n static const code distfix[%u] = {",
size);
373 if ((low % 6) == 0)
printf(
"\n ");
375 state.distcode[low].val);
376 if (++low ==
size)
break;
409 state->window = (
unsigned char FAR *)
411 sizeof(
unsigned char));
416 if (
state->wsize == 0) {
423 if (copy >=
state->wsize) {
430 if (dist > copy) dist = copy;
439 state->wnext += dist;
451 # define UPDATE_CHECK(check, buf, len) \
452 (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
454 # define UPDATE_CHECK(check, buf, len) adler32(check, buf, len)
459 # define CRC2(check, word) \
461 hbuf[0] = (unsigned char)(word); \
462 hbuf[1] = (unsigned char)((word) >> 8); \
463 check = crc32(check, hbuf, 2); \
466 # define CRC4(check, word) \
468 hbuf[0] = (unsigned char)(word); \
469 hbuf[1] = (unsigned char)((word) >> 8); \
470 hbuf[2] = (unsigned char)((word) >> 16); \
471 hbuf[3] = (unsigned char)((word) >> 24); \
472 check = crc32(check, hbuf, 4); \
479 put = strm->next_out; \
480 left = strm->avail_out; \
481 next = strm->next_in; \
482 have = strm->avail_in; \
483 hold = state->hold; \
484 bits = state->bits; \
490 strm->next_out = put; \
491 strm->avail_out = left; \
492 strm->next_in = next; \
493 strm->avail_in = have; \
494 state->hold = hold; \
495 state->bits = bits; \
509 if (have == 0) goto inf_leave; \
511 hold += (unsigned long)(*next++) << bits; \
517 #define NEEDBITS(n) \
519 while (bits < (unsigned)(n)) \
525 ((unsigned)hold & ((1U << (n)) - 1))
528 #define DROPBITS(n) \
531 bits -= (unsigned)(n); \
629 unsigned char FAR *put;
641 unsigned char hbuf[4];
643 static const unsigned short order[19] =
644 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
657 switch (
state->mode) {
659 if (
state->wrap == 0) {
665 if ((
state->wrap & 2) &&
hold == 0x8b1f) {
666 if (
state->wbits == 0)
675 state->head->done = -1;
676 if (!(
state->wrap & 1) ||
680 ((
BITS(8) << 8) + (
hold >> 8)) % 31) {
681 strm->msg = (
char *)
"incorrect header check";
686 strm->msg = (
char *)
"unknown compression method";
692 if (
state->wbits == 0)
695 strm->msg = (
char *)
"invalid window size";
701 Tracev((stderr,
"inflate: zlib header ok\n"));
711 strm->msg = (
char *)
"unknown compression method";
715 if (
state->flags & 0xe000) {
716 strm->msg = (
char *)
"unknown header flags set";
722 if ((
state->flags & 0x0200) && (
state->wrap & 4))
731 if ((
state->flags & 0x0200) && (
state->wrap & 4))
742 if ((
state->flags & 0x0200) && (
state->wrap & 4))
748 if (
state->flags & 0x0400) {
753 if ((
state->flags & 0x0200) && (
state->wrap & 4))
762 if (
state->flags & 0x0400) {
763 copy =
state->length;
770 len + copy >
state->head->extra_max ?
771 state->head->extra_max -
len : copy);
773 if ((
state->flags & 0x0200) && (
state->wrap & 4))
777 state->length -= copy;
779 if (
state->length)
goto inf_leave;
785 if (
state->flags & 0x0800) {
786 if (
have == 0)
goto inf_leave;
795 if ((
state->flags & 0x0200) && (
state->wrap & 4))
799 if (
len)
goto inf_leave;
807 if (
state->flags & 0x1000) {
808 if (
have == 0)
goto inf_leave;
817 if ((
state->flags & 0x0200) && (
state->wrap & 4))
821 if (
len)
goto inf_leave;
828 if (
state->flags & 0x0200) {
831 strm->msg = (
char *)
"header crc mismatch";
839 state->head->done = 1;
852 if (
state->havedict == 0) {
873 Tracev((stderr,
"inflate: stored block%s\n",
874 state->last ?
" (last)" :
""));
879 Tracev((stderr,
"inflate: fixed codes block%s\n",
880 state->last ?
" (last)" :
""));
888 Tracev((stderr,
"inflate: dynamic codes block%s\n",
889 state->last ?
" (last)" :
""));
893 strm->msg = (
char *)
"invalid block type";
901 if ((
hold & 0xffff) != ((
hold >> 16) ^ 0xffff)) {
902 strm->msg = (
char *)
"invalid stored block lengths";
907 Tracev((stderr,
"inflate: stored length %u\n",
911 if (flush ==
Z_TREES)
goto inf_leave;
917 copy =
state->length;
920 if (copy > left) copy = left;
921 if (copy == 0)
goto inf_leave;
927 state->length -= copy;
930 Tracev((stderr,
"inflate: stored end\n"));
941 #ifndef PKZIP_BUG_WORKAROUND
943 strm->msg = (
char *)
"too many length or distance symbols";
948 Tracev((stderr,
"inflate: table sizes ok\n"));
958 while (
state->have < 19)
966 strm->msg = (
char *)
"invalid code lengths set";
970 Tracev((stderr,
"inflate: code lengths ok\n"));
978 if ((
unsigned)(here.
bits) <=
bits)
break;
986 if (here.
val == 16) {
989 if (
state->have == 0) {
990 strm->msg = (
char *)
"invalid bit length repeat";
998 else if (here.
val == 17) {
1009 copy = 11 +
BITS(7);
1013 strm->msg = (
char *)
"invalid bit length repeat";
1026 if (
state->lens[256] == 0) {
1027 strm->msg = (
char *)
"invalid code -- missing end-of-block";
1041 strm->msg = (
char *)
"invalid literal/lengths set";
1046 state->distbits = 6;
1050 strm->msg = (
char *)
"invalid distances set";
1054 Tracev((stderr,
"inflate: codes ok\n"));
1056 if (flush ==
Z_TREES)
goto inf_leave;
1062 if (
have >= 6 && left >= 258) {
1073 if ((
unsigned)(here.
bits) <=
bits)
break;
1076 if (here.
op && (here.
op & 0xf0) == 0) {
1090 if ((
int)(here.
op) == 0) {
1092 "inflate: literal '%c'\n" :
1093 "inflate: literal 0x%02x\n", here.
val));
1098 Tracevv((stderr,
"inflate: end of block\n"));
1104 strm->msg = (
char *)
"invalid literal/length code";
1118 Tracevv((stderr,
"inflate: length %u\n",
state->length));
1125 if ((
unsigned)(here.
bits) <=
bits)
break;
1128 if ((here.
op & 0xf0) == 0) {
1142 strm->msg = (
char *)
"invalid distance code";
1147 state->extra = (
unsigned)(here.
op) & 15;
1157 #ifdef INFLATE_STRICT
1159 strm->msg = (
char *)
"invalid distance too far back";
1164 Tracevv((stderr,
"inflate: distance %u\n",
state->offset));
1168 if (left == 0)
goto inf_leave;
1170 if (
state->offset > copy) {
1171 copy =
state->offset - copy;
1172 if (copy >
state->whave) {
1174 strm->msg = (
char *)
"invalid distance too far back";
1178 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1179 Trace((stderr,
"inflate.c too far\n"));
1180 copy -=
state->whave;
1181 if (copy >
state->length) copy =
state->length;
1182 if (copy > left) copy = left;
1184 state->length -= copy;
1192 if (copy >
state->wnext) {
1193 copy -=
state->wnext;
1198 if (copy >
state->length) copy =
state->length;
1202 copy =
state->length;
1204 if (copy > left) copy = left;
1206 state->length -= copy;
1213 if (left == 0)
goto inf_leave;
1214 *put++ = (
unsigned char)(
state->length);
1228 if ((
state->wrap & 4) && (
1233 strm->msg = (
char *)
"incorrect data check";
1238 Tracev((stderr,
"inflate: check matches trailer\n"));
1247 strm->msg = (
char *)
"incorrect length check";
1252 Tracev((stderr,
"inflate: length matches trailer\n"));
1311 Tracev((stderr,
"inflate: end\n"));
1333 if (dictLength !=
Z_NULL)
1334 *dictLength =
state->whave;
1340 const Bytef *dictionary;
1344 unsigned long dictid;
1356 dictid =
adler32(dictid, dictionary, dictLength);
1357 if (dictid !=
state->check)
1368 state->havedict = 1;
1369 Tracev((stderr,
"inflate: dictionary set\n"));
1403 const unsigned char FAR *
buf;
1411 while (
next <
len && got < 4) {
1412 if ((
int)(
buf[
next]) == (got < 2 ? 0 : 0xff))
1429 unsigned long in,
out;
1430 unsigned char buf[4];
1444 while (
state->bits >= 8) {
1461 if (
state->flags == -1)
1547 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1548 state->sane = !subvert;
1580 return (
long)(((
unsigned long)((
long)
state->back)) << 16) +
int bits(struct state *s, int need)
const lzma_allocator const uint8_t * in
const lzma_allocator const uint8_t size_t uint8_t * out
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags long
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start)
static const code distfix[32]
static const code lenfix[512]
void fixedtables(struct inflate_state FAR *state)
unsigned long ZEXPORT inflateCodesUsed(z_streamp strm)
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
int inflateStateCheck OF((z_streamp strm))
#define CRC2(check, word)
long ZEXPORT inflateMark(z_streamp strm)
int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, uInt *dictLength)
int ZEXPORT inflateSyncPoint(z_streamp strm)
#define CRC4(check, word)
int ZEXPORT inflatePrime(z_streamp strm, int bits, int value)
int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head)
int ZEXPORT inflateUndermine(z_streamp strm, int subvert)
int ZEXPORT inflateSync(z_streamp strm)
int inflateStateCheck(z_streamp strm)
int ZEXPORT inflateResetKeep(z_streamp strm)
int ZEXPORT inflate(z_streamp strm, int flush)
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size)
int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
int ZEXPORT inflateReset(z_streamp strm)
unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, unsigned len)
int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
int ZEXPORT inflateEnd(z_streamp strm)
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
#define UPDATE_CHECK(check, buf, len)
int ZEXPORT inflateValidate(z_streamp strm, int check)
int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf unsigned
int fixed(struct state *s)
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void flags
code const FAR * distcode
unsigned char FAR * window
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
if(dbg->bits==RZ_SYS_BITS_64)
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
gz_header FAR * gz_headerp
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
#define ZALLOC(strm, items, size)
#define ZFREE(strm, addr)