Prusa MINI Firmware overview
|
#include "zutil.h"
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
#include "inffixed.h"
◆ LOAD
Value:do { \
left =
strm->avail_out; \
} while (0)
◆ 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)
◆ INITBITS
Value:do { \
hold = 0; \
bits = 0; \
} while (0)
◆ PULL
Value:do { \
if (have == 0) { \
have = in(in_desc, &next); \
if (have == 0) { \
goto inf_leave; \
} \
} \
} while (0)
◆ PULLBYTE
Value:do { \
PULL(); \
have--; \
hold += (unsigned long)(*next++) << bits; \
bits += 8; \
} while (0)
◆ 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
Value:do { \
hold >>= bits & 7; \
bits -= bits & 7; \
} while (0)
◆ ROOM
Value:do { \
if (left == 0) { \
state->whave = left; \
if (out(out_desc, put, left)) { \
goto inf_leave; \
} \
} \
} while (0)
◆ OF()
◆ inflateBackInit_()
int ZEXPORT inflateBackInit_ |
( |
z_streamp |
strm, |
|
|
int |
windowBits, |
|
|
unsigned char FAR * |
window, |
|
|
const char * |
version, |
|
|
int |
stream_size |
|
) |
| |
38 stream_size != (
int)(
sizeof(
z_stream)))
41 windowBits < 8 || windowBits > 15)
44 if (
strm->zalloc == (alloc_func)0) {
52 if (
strm->zfree == (free_func)0)
61 Tracev((stderr,
"inflate: allocated\n"));
65 state->wsize = 1U << windowBits;
◆ fixedtables()
86 static int virgin = 1;
88 static code fixed[544];
97 while (sym < 144)
state->lens[sym++] = 8;
98 while (sym < 256)
state->lens[sym++] = 9;
99 while (sym < 280)
state->lens[sym++] = 7;
100 while (sym < 288)
state->lens[sym++] = 8;
108 while (sym < 32)
state->lens[sym++] = 5;
◆ inflateBack()
259 unsigned char FAR *put;
264 unsigned char FAR *from;
269 static const unsigned short order[19] =
270 {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
291 switch (
state->mode) {
304 Tracev((stderr,
"inflate: stored block%s\n",
305 state->last ?
" (last)" :
""));
310 Tracev((stderr,
"inflate: fixed codes block%s\n",
311 state->last ?
" (last)" :
""));
315 Tracev((stderr,
"inflate: dynamic codes block%s\n",
316 state->last ?
" (last)" :
""));
320 strm->msg = (
char *)
"invalid block type";
330 if ((
hold & 0xffff) != ((
hold >> 16) ^ 0xffff)) {
331 strm->msg = (
char *)
"invalid stored block lengths";
336 Tracev((stderr,
"inflate: stored length %u\n",
341 while (
state->length != 0) {
342 copy =
state->length;
346 if (copy > left) copy = left;
352 state->length -= copy;
354 Tracev((stderr,
"inflate: stored end\n"));
367 #ifndef PKZIP_BUG_WORKAROUND
369 strm->msg = (
char *)
"too many length or distance symbols";
374 Tracev((stderr,
"inflate: table sizes ok\n"));
383 while (
state->have < 19)
391 strm->msg = (
char *)
"invalid code lengths set";
395 Tracev((stderr,
"inflate: code lengths ok\n"));
402 if ((
unsigned)(here.
bits) <=
bits)
break;
410 if (here.
val == 16) {
413 if (
state->have == 0) {
414 strm->msg = (
char *)
"invalid bit length repeat";
418 len = (unsigned)(
state->lens[
state->have - 1]);
422 else if (here.
val == 17) {
437 strm->msg = (
char *)
"invalid bit length repeat";
442 state->lens[
state->have++] = (
unsigned short)len;
450 if (
state->lens[256] == 0) {
451 strm->msg = (
char *)
"invalid code -- missing end-of-block";
465 strm->msg = (
char *)
"invalid literal/lengths set";
474 strm->msg = (
char *)
"invalid distances set";
478 Tracev((stderr,
"inflate: codes ok\n"));
483 if (
have >= 6 && left >= 258) {
495 if ((
unsigned)(here.
bits) <=
bits)
break;
498 if (here.
op && (here.
op & 0xf0) == 0) {
514 "inflate: literal '%c'\n" :
515 "inflate: literal 0x%02x\n", here.
val));
517 *put++ = (
unsigned char)(
state->length);
525 Tracevv((stderr,
"inflate: end of block\n"));
532 strm->msg = (
char *)
"invalid literal/length code";
538 state->extra = (unsigned)(here.
op) & 15;
539 if (
state->extra != 0) {
544 Tracevv((stderr,
"inflate: length %u\n",
state->length));
549 if ((
unsigned)(here.
bits) <=
bits)
break;
552 if ((here.
op & 0xf0) == 0) {
564 strm->msg = (
char *)
"invalid distance code";
571 state->extra = (
unsigned)(here.
op) & 15;
572 if (
state->extra != 0) {
579 strm->msg = (
char *)
"invalid distance too far back";
583 Tracevv((stderr,
"inflate: distance %u\n",
state->offset));
594 from = put -
state->offset;
597 if (copy >
state->length) copy =
state->length;
598 state->length -= copy;
603 }
while (
state->length != 0);
609 if (left < state->
wsize) {
610 if (out(out_desc,
state->window,
state->wsize - left))
◆ inflateBackEnd()
638 Tracev((stderr,
"inflate: end\n"));
#define Z_MEM_ERROR
Definition: zlib.h:183
voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size)
Definition: zutil.c:305
unsigned char FAR * window
Definition: inflate.h:99
unsigned short val
Definition: inftrees.h:27
#define Z_BUF_ERROR
Definition: zlib.h:184
static const code lenfix[512]
Definition: inffixed.h:10
#define LOAD()
Definition: infback.c:128
#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
code FAR * next
Definition: inflate.h:118
Definition: deflate.h:100
#define Z_STREAM_ERROR
Definition: zlib.h:181
Definition: inftrees.h:55
#define INITBITS()
Definition: infback.c:150
static volatile fsensor_t state
Definition: filament_sensor.c:23
#define NEEDBITS(n)
Definition: infback.c:183
#define Tracev(x)
Definition: zutil.h:250
z_streamp strm
Definition: deflate.h:101
#define ZLIB_VERSION
Definition: zlib.h:40
Byte FAR * voidpf
Definition: zconf.h:413
z_streamp strm
Definition: inflate.h:83
#define PULLBYTE()
Definition: infback.c:172
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
unsigned char op
Definition: inftrees.h:25
#define z_const
Definition: zconf.h:237
unsigned bits
Definition: inflate.h:102
#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
int last
Definition: inflate.h:85
#define Z_STREAM_END
Definition: zlib.h:178
#define ROOM()
Definition: infback.c:210
void ZLIB_INTERNAL zmemcpy(Bytef *dest, const Bytef *source, uInt len)
Definition: zutil.c:149
#define BITS(n)
Definition: infback.c:190
void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr)
Definition: zutil.c:315
unsigned char bits
Definition: inftrees.h:26
#define PULL()
Definition: infback.c:158
#define Z_VERSION_ERROR
Definition: zlib.h:185
#define RESTORE()
Definition: infback.c:139
unsigned long hold
Definition: inflate.h:101
Bytef * window
Definition: deflate.h:119
unsigned int uInt
Definition: zconf.h:393
#define ZALLOC(strm, items, size)
Definition: zutil.h:262
Definition: inftrees.h:24
#define ZFREE(strm, addr)
Definition: zutil.h:264
void fixedtables(struct inflate_state FAR *state)
Definition: infback.c:82
#define Tracevv(x)
Definition: zutil.h:251
Definition: inftrees.h:57
#define DROPBITS(n)
Definition: infback.c:194
static const code distfix[32]
Definition: inffixed.h:87
#define BYTEBITS()
Definition: infback.c:201
Definition: inftrees.h:56