Prusa MINI Firmware overview
|
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
#include "inffixed.h"
|
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) |
|
◆ UPDATE
#define UPDATE |
( |
|
check, |
|
|
|
buf, |
|
|
|
len |
|
) |
| (state->flags ? crc32(check, buf, len) : adler32(check, buf, len)) |
◆ CRC2
#define CRC2 |
( |
|
check, |
|
|
|
word |
|
) |
| |
Value:do { \
hbuf[0] = (
unsigned char)(
word); \
hbuf[1] = (
unsigned char)((
word) >> 8); \
} while (0)
◆ 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); \
} while (0)
◆ LOAD
Value:do { \
left =
strm->avail_out; \
} while (0)
◆ RESTORE
Value:do { \
strm->next_out = put; \
strm->avail_out = left; \
} while (0)
◆ INITBITS
Value:do { \
hold = 0; \
bits = 0; \
} while (0)
◆ PULLBYTE
Value:do { \
if (
have == 0) goto inf_leave; \
◆ NEEDBITS
Value:do { \
while (
bits < (
unsigned)(n)) \
PULLBYTE(); \
} while (0)
◆ BITS
#define BITS |
( |
|
n | ) |
((unsigned)hold & ((1U << (n)) - 1)) |
◆ DROPBITS
Value:do { \
hold >>= (n); \
bits -= (unsigned)(n); \
} while (0)
◆ BYTEBITS
◆ OF() [1/4]
◆ OF() [2/4]
◆ OF() [3/4]
◆ OF() [4/4]
◆ inflateStateCheck()
110 strm->zalloc == (alloc_func)0 ||
strm->zfree == (free_func)0)
◆ inflateResetKeep()
133 state->dmax = 32768U;
140 Tracev((stderr,
"inflate: reset\n"));
◆ inflateReset()
◆ inflateReset2()
169 if (windowBits < 0) {
171 windowBits = -windowBits;
174 wrap = (windowBits >> 4) + 5;
182 if (windowBits && (windowBits < 8 || windowBits > 15))
191 state->wbits = (unsigned)windowBits;
◆ inflateInit2_()
205 stream_size != (
int)(
sizeof(
z_stream)))
209 if (
strm->zalloc == (alloc_func)0) {
217 if (
strm->zfree == (free_func)0)
226 Tracev((stderr,
"inflate: allocated\n"));
◆ inflateInit_()
◆ inflatePrime()
262 value &= (1
L <<
bits) - 1;
263 state->hold += (unsigned)value <<
state->bits;
◆ fixedtables()
282 static int virgin = 1;
284 static code fixed[544];
293 while (sym < 144)
state->lens[sym++] = 8;
294 while (sym < 256)
state->lens[sym++] = 9;
295 while (sym < 280)
state->lens[sym++] = 7;
296 while (sym < 288)
state->lens[sym++] = 8;
304 while (sym < 32)
state->lens[sym++] = 5;
◆ updatewindow()
408 state->window = (
unsigned char FAR *)
410 sizeof(
unsigned char));
415 if (
state->wsize == 0) {
422 if (copy >=
state->wsize) {
429 if (dist > copy) dist = copy;
438 state->wnext += dist;
◆ inflate()
628 unsigned char FAR *put;
634 unsigned char FAR *from;
640 unsigned char hbuf[4];
642 static const unsigned short order[19] =
643 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
656 switch (
state->mode) {
658 if (
state->wrap == 0) {
664 if ((
state->wrap & 2) &&
hold == 0x8b1f) {
665 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)
694 if (len > 15 || len >
state->wbits) {
695 strm->msg = (
char *)
"invalid window size";
699 state->dmax = 1U << len;
700 Tracev((stderr,
"inflate: zlib header ok\n"));
710 strm->msg = (
char *)
"unknown compression method";
714 if (
state->flags & 0xe000) {
715 strm->msg = (
char *)
"unknown header flags set";
721 if ((
state->flags & 0x0200) && (
state->wrap & 4))
729 if ((
state->flags & 0x0200) && (
state->wrap & 4))
739 if ((
state->flags & 0x0200) && (
state->wrap & 4))
744 if (
state->flags & 0x0400) {
749 if ((
state->flags & 0x0200) && (
state->wrap & 4))
757 if (
state->flags & 0x0400) {
758 copy =
state->length;
765 len + copy >
state->head->extra_max ?
766 state->head->extra_max - len : copy);
768 if ((
state->flags & 0x0200) && (
state->wrap & 4))
772 state->length -= copy;
774 if (
state->length)
goto inf_leave;
779 if (
state->flags & 0x0800) {
780 if (
have == 0)
goto inf_leave;
783 len = (unsigned)(
next[copy++]);
788 }
while (len && copy <
have);
789 if ((
state->flags & 0x0200) && (
state->wrap & 4))
793 if (len)
goto inf_leave;
800 if (
state->flags & 0x1000) {
801 if (
have == 0)
goto inf_leave;
804 len = (unsigned)(
next[copy++]);
809 }
while (len && copy <
have);
810 if ((
state->flags & 0x0200) && (
state->wrap & 4))
814 if (len)
goto inf_leave;
820 if (
state->flags & 0x0200) {
823 strm->msg = (
char *)
"header crc mismatch";
831 state->head->done = 1;
843 if (
state->havedict == 0) {
862 Tracev((stderr,
"inflate: stored block%s\n",
863 state->last ?
" (last)" :
""));
868 Tracev((stderr,
"inflate: fixed codes block%s\n",
869 state->last ?
" (last)" :
""));
877 Tracev((stderr,
"inflate: dynamic codes block%s\n",
878 state->last ?
" (last)" :
""));
882 strm->msg = (
char *)
"invalid block type";
890 if ((
hold & 0xffff) != ((
hold >> 16) ^ 0xffff)) {
891 strm->msg = (
char *)
"invalid stored block lengths";
896 Tracev((stderr,
"inflate: stored length %u\n",
900 if (flush ==
Z_TREES)
goto inf_leave;
904 copy =
state->length;
907 if (copy > left) copy = left;
908 if (copy == 0)
goto inf_leave;
914 state->length -= copy;
917 Tracev((stderr,
"inflate: stored end\n"));
928 #ifndef PKZIP_BUG_WORKAROUND
930 strm->msg = (
char *)
"too many length or distance symbols";
935 Tracev((stderr,
"inflate: table sizes ok\n"));
944 while (
state->have < 19)
952 strm->msg = (
char *)
"invalid code lengths set";
956 Tracev((stderr,
"inflate: code lengths ok\n"));
963 if ((
unsigned)(here.
bits) <=
bits)
break;
971 if (here.
val == 16) {
974 if (
state->have == 0) {
975 strm->msg = (
char *)
"invalid bit length repeat";
983 else if (here.
val == 17) {
998 strm->msg = (
char *)
"invalid bit length repeat";
1003 state->lens[
state->have++] = (
unsigned short)len;
1011 if (
state->lens[256] == 0) {
1012 strm->msg = (
char *)
"invalid code -- missing end-of-block";
1026 strm->msg = (
char *)
"invalid literal/lengths set";
1031 state->distbits = 6;
1035 strm->msg = (
char *)
"invalid distances set";
1039 Tracev((stderr,
"inflate: codes ok\n"));
1041 if (flush ==
Z_TREES)
goto inf_leave;
1045 if (
have >= 6 && left >= 258) {
1056 if ((
unsigned)(here.
bits) <=
bits)
break;
1059 if (here.
op && (here.
op & 0xf0) == 0) {
1072 state->length = (unsigned)here.
val;
1073 if ((
int)(here.
op) == 0) {
1075 "inflate: literal '%c'\n" :
1076 "inflate: literal 0x%02x\n", here.
val));
1081 Tracevv((stderr,
"inflate: end of block\n"));
1087 strm->msg = (
char *)
"invalid literal/length code";
1091 state->extra = (unsigned)(here.
op) & 15;
1100 Tracevv((stderr,
"inflate: length %u\n",
state->length));
1106 if ((
unsigned)(here.
bits) <=
bits)
break;
1109 if ((here.
op & 0xf0) == 0) {
1123 strm->msg = (
char *)
"invalid distance code";
1127 state->offset = (unsigned)here.
val;
1128 state->extra = (
unsigned)(here.
op) & 15;
1137 #ifdef INFLATE_STRICT
1139 strm->msg = (
char *)
"invalid distance too far back";
1144 Tracevv((stderr,
"inflate: distance %u\n",
state->offset));
1147 if (left == 0)
goto inf_leave;
1149 if (
state->offset > copy) {
1150 copy =
state->offset - copy;
1151 if (copy >
state->whave) {
1153 strm->msg = (
char *)
"invalid distance too far back";
1157 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1158 Trace((stderr,
"inflate.c too far\n"));
1159 copy -=
state->whave;
1160 if (copy >
state->length) copy =
state->length;
1161 if (copy > left) copy = left;
1163 state->length -= copy;
1171 if (copy >
state->wnext) {
1172 copy -=
state->wnext;
1173 from =
state->window + (
state->wsize - copy);
1176 from =
state->window + (
state->wnext - copy);
1177 if (copy >
state->length) copy =
state->length;
1180 from = put -
state->offset;
1181 copy =
state->length;
1183 if (copy > left) copy = left;
1185 state->length -= copy;
1192 if (left == 0)
goto inf_leave;
1193 *put++ = (
unsigned char)(
state->length);
1201 strm->total_out += out;
1202 state->total += out;
1203 if ((
state->wrap & 4) && out)
1207 if ((
state->wrap & 4) && (
1212 strm->msg = (
char *)
"incorrect data check";
1217 Tracev((stderr,
"inflate: check matches trailer\n"));
1224 if (
hold != (
state->total & 0xffffffffUL)) {
1225 strm->msg = (
char *)
"incorrect length check";
1230 Tracev((stderr,
"inflate: length matches trailer\n"));
1261 in -=
strm->avail_in;
1262 out -=
strm->avail_out;
1263 strm->total_in += in;
1264 strm->total_out += out;
1265 state->total += out;
1266 if ((
state->wrap & 4) && out)
1272 if (((in == 0 && out == 0) || flush ==
Z_FINISH) && ret ==
Z_OK)
◆ inflateEnd()
1287 Tracev((stderr,
"inflate: end\n"));
◆ inflateGetDictionary()
1309 if (dictLength !=
Z_NULL)
1310 *dictLength =
state->whave;
◆ inflateSetDictionary()
1320 unsigned long dictid;
1332 dictid =
adler32(dictid, dictionary, dictLength);
1333 if (dictid !=
state->check)
1344 state->havedict = 1;
1345 Tracev((stderr,
"inflate: dictionary set\n"));
◆ inflateGetHeader()
◆ syncsearch()
unsigned syncsearch |
( |
unsigned FAR * |
have, |
|
|
const unsigned char FAR * |
buf, |
|
|
unsigned |
len |
|
) |
| |
1387 while (
next < len && got < 4) {
1388 if ((
int)(buf[
next]) == (got < 2 ? 0 : 0xff))
◆ inflateSync()
1404 unsigned long in, out;
1405 unsigned char buf[4];
1419 while (
state->bits >= 8) {
1420 buf[len++] = (
unsigned char)(
state->hold);
1430 strm->avail_in -= len;
1431 strm->next_in += len;
1432 strm->total_in += len;
1436 in =
strm->total_in; out =
strm->total_out;
1438 strm->total_in = in;
strm->total_out = out;
◆ inflateSyncPoint()
◆ inflateCopy()
1482 ZALLOC(source, 1U <<
state->wbits,
sizeof(
unsigned char));
1484 ZFREE(source, copy);
1495 copy->lencode = copy->codes + (
state->lencode -
state->codes);
1496 copy->distcode = copy->codes + (
state->distcode -
state->codes);
1498 copy->next = copy->codes + (
state->next -
state->codes);
◆ inflateUndermine()
1516 #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
1517 state->sane = !subvert;
◆ inflateValidate()
◆ inflateMark()
1549 return (
long)(((
unsigned long)((
long)
state->back)) << 16) +
◆ inflateCodesUsed()
1560 return (
unsigned long)(
state->next -
state->codes);
#define Z_MEM_ERROR
Definition: zlib.h:183
Byte FAR Bytef
Definition: zconf.h:400
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
Definition: zutil.c:305
unsigned char FAR * window
Definition: inflate.h:99
int wrap
Definition: inflate.h:86
#define CRC4(check, word)
Definition: inflate.c:465
unsigned short val
Definition: inftrees.h:27
#define NEEDBITS(n)
Definition: inflate.c:516
#define Z_BUF_ERROR
Definition: zlib.h:184
int ZEXPORT inflateResetKeep(z_streamp strm)
Definition: inflate.c:119
#define DROPBITS(n)
Definition: inflate.c:527
static const code lenfix[512]
Definition: inffixed.h:10
#define Trace(x)
Definition: zutil.h:249
#define Z_DATA_ERROR
Definition: zlib.h:182
unsigned wsize
Definition: inflate.h:96
void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start)
Definition: inffast.c:50
#define Z_TREES
Definition: zlib.h:174
#define Z_FINISH
Definition: zlib.h:172
code FAR * next
Definition: inflate.h:118
Definition: deflate.h:100
#define ENOUGH
Definition: inftrees.h:51
unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, unsigned len)
Definition: inflate.c:1377
#define Z_STREAM_ERROR
Definition: zlib.h:181
Definition: inftrees.h:55
int inflateStateCheck(z_streamp strm)
Definition: inflate.c:105
#define Z_NEED_DICT
Definition: zlib.h:179
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uInt len)
Definition: crc32.c:237
static volatile fsensor_t state
Definition: filament_sensor.c:23
#define Tracev(x)
Definition: zutil.h:250
z_streamp strm
Definition: deflate.h:101
#define BYTEBITS()
Definition: inflate.c:534
gz_headerp head
Definition: inflate.h:93
#define ZSWAP32(q)
Definition: zutil.h:268
#define CRC2(check, word)
Definition: inflate.c:458
int ZEXPORT inflateReset2(z_streamp strm, int windowBits)
Definition: inflate.c:157
#define ZLIB_VERSION
Definition: zlib.h:40
Byte FAR * voidpf
Definition: zconf.h:413
end
Definition: createSpeedLookupTable.py:33
int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
Definition: inflate.c:396
z_streamp strm
Definition: inflate.h:83
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR *FAR *table, unsigned FAR *bits, unsigned short FAR *work)
Definition: inftrees.c:32
#define Z_NULL
Definition: zlib.h:212
#define Z_BLOCK
Definition: zlib.h:173
unsigned char op
Definition: inftrees.h:25
#define z_const
Definition: zconf.h:237
unsigned bits
Definition: inflate.h:102
#define DEF_WBITS
Definition: zutil.h:61
void fixedtables(struct inflate_state FAR *state)
Definition: inflate.c:278
#define BITS(n)
Definition: inflate.c:523
#define Z_OK
Definition: zlib.h:177
#define FAR
Definition: zconf.h:387
unsigned have
Definition: inflate.h:117
if(size<=((png_alloc_size_t) -1) - ob)
Definition: pngwrite.c:2176
while(sofevent)
Definition: USB_HOST_SHIELD.h:456
#define LOAD()
Definition: inflate.c:476
#define L(CODE)
Definition: macros.h:76
#define GUNZIP
Definition: inflate.h:16
int last
Definition: inflate.h:85
#define Z_STREAM_END
Definition: zlib.h:178
unsigned long check
Definition: inflate.h:91
unsigned int word
Definition: wiring_constants.h:108
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:149
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
Definition: zutil.c:315
unsigned char bits
Definition: inftrees.h:26
#define Z_DEFLATED
Definition: zlib.h:209
#define UPDATE(check, buf, len)
Definition: inflate.c:450
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size)
Definition: inflate.c:195
#define Z_VERSION_ERROR
Definition: zlib.h:185
#define INITBITS()
Definition: inflate.c:498
#define PULLBYTE()
Definition: inflate.c:506
int
Definition: createSpeedLookupTable.py:15
unsigned long hold
Definition: inflate.h:101
#define RESTORE()
Definition: inflate.c:487
unsigned int uInt
Definition: zconf.h:393
#define ZALLOC(strm, items, size)
Definition: zutil.h:262
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
Definition: adler32.c:134
Definition: inftrees.h:24
#define ZFREE(strm, addr)
Definition: zutil.h:264
#define Tracevv(x)
Definition: zutil.h:251
int ZEXPORT inflateReset(z_streamp strm)
Definition: inflate.c:144
Definition: inftrees.h:57
static const code distfix[32]
Definition: inffixed.h:87
Definition: inftrees.h:56