summaryrefslogtreecommitdiff
path: root/lib/uzlib/tinfzlib.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2023-06-27 01:34:31 +1000
committerDamien George <damien@micropython.org>2023-07-21 19:29:34 +1000
commitd75a3cd8611c421d03784ebc459c3faa878bf77b (patch)
treed79c4f80d064552e5f1ec8f5ebcc999e25c319c6 /lib/uzlib/tinfzlib.c
parentc2b8e6e5d685ce0ef7cd7186f326cac8a39eb2a3 (diff)
lib/uzlib: Combine zlib/gzip header parsing to allow auto-detect.
This supports `wbits` values between +40 to +47. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'lib/uzlib/tinfzlib.c')
-rw-r--r--lib/uzlib/tinfzlib.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/lib/uzlib/tinfzlib.c b/lib/uzlib/tinfzlib.c
deleted file mode 100644
index 03954cefa..000000000
--- a/lib/uzlib/tinfzlib.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * uzlib - tiny deflate/inflate library (deflate, gzip, zlib)
- *
- * Copyright (c) 2003 by Joergen Ibsen / Jibz
- * All Rights Reserved
- *
- * http://www.ibsensoftware.com/
- *
- * Copyright (c) 2014-2018 by Paul Sokolovsky
- *
- * This software is provided 'as-is', without any express
- * or implied warranty. In no event will the authors be
- * held liable for any damages arising from the use of
- * this software.
- *
- * Permission is granted to anyone to use this software
- * for any purpose, including commercial applications,
- * and to alter it and redistribute it freely, subject to
- * the following restrictions:
- *
- * 1. The origin of this software must not be
- * misrepresented; you must not claim that you
- * wrote the original software. If you use this
- * software in a product, an acknowledgment in
- * the product documentation would be appreciated
- * but is not required.
- *
- * 2. Altered source versions must be plainly marked
- * as such, and must not be misrepresented as
- * being the original software.
- *
- * 3. This notice may not be removed or altered from
- * any source distribution.
- */
-
-#include "uzlib.h"
-
-int uzlib_zlib_parse_header(uzlib_uncomp_t *d)
-{
- unsigned char cmf, flg;
-
- /* -- get header bytes -- */
-
- cmf = uzlib_get_byte(d);
- flg = uzlib_get_byte(d);
-
- /* -- check format -- */
-
- /* check checksum */
- if ((256*cmf + flg) % 31) return UZLIB_DATA_ERROR;
-
- /* check method is deflate */
- if ((cmf & 0x0f) != 8) return UZLIB_DATA_ERROR;
-
- /* check window size is valid */
- if ((cmf >> 4) > 7) return UZLIB_DATA_ERROR;
-
- /* check there is no preset dictionary */
- if (flg & 0x20) return UZLIB_DATA_ERROR;
-
- /* initialize for adler32 checksum */
- d->checksum_type = UZLIB_CHKSUM_ADLER;
- d->checksum = 1;
-
- return cmf >> 4;
-}