{"id":16251570,"url":"https://github.com/pfalcon/uzlib","last_synced_at":"2025-04-05T21:11:27.632Z","repository":{"id":19912460,"uuid":"23178102","full_name":"pfalcon/uzlib","owner":"pfalcon","description":"Radically unbloated DEFLATE/zlib/gzip compression/decompression library. Can decompress any gzip/zlib data, and offers simplified compressor which produces gzip-compatible output, while requiring much less resources (and providing less compression ratio of course).","archived":false,"fork":false,"pushed_at":"2023-10-09T18:12:50.000Z","size":235,"stargazers_count":316,"open_issues_count":9,"forks_count":89,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-29T20:09:49.305Z","etag":null,"topics":["compression","deflate","gzip","minimalist","suckless","unbloated","zlib"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pfalcon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-08-21T07:26:14.000Z","updated_at":"2025-03-18T21:09:17.000Z","dependencies_parsed_at":"2024-11-17T02:17:04.900Z","dependency_job_id":null,"html_url":"https://github.com/pfalcon/uzlib","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fuzlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fuzlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fuzlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pfalcon%2Fuzlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pfalcon","download_url":"https://codeload.github.com/pfalcon/uzlib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399887,"owners_count":20932880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compression","deflate","gzip","minimalist","suckless","unbloated","zlib"],"created_at":"2024-10-10T15:10:38.499Z","updated_at":"2025-04-05T21:11:27.596Z","avatar_url":"https://github.com/pfalcon.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"uzlib - Deflate/Zlib-compatible LZ77 compression/decompression library\n======================================================================\n\nuzlib is a library which can decompress any valid Deflate, Zlib, and Gzip\n(further called just \"Deflate\") bitstream, and compress data to Deflate-\ncompatible bitstream, albeit with lower compression ratio than Zlib Deflate\nalgorithm (very basic LZ77 compression algorithm is used instead, static\nDeflate Huffman tree encoding is used for bitstream).\n\nuzlib aims for minimal code size and runtime memory requirements, and thus\nsuitable for (deeply) embedded systems.\n\nuzlib is based on:\n\n* tinf library by Joergen Ibsen (Deflate decompression)\n* Deflate Static Huffman tree routines by Simon Tatham\n* LZ77 compressor by Paul Sokolovsky\n\nLibrary integrated and maintained by Paul Sokolovsky.\n\n(c) 2014-2020 Paul Sokolovsky\n\nuzlib library is licensed under Zlib license.\n\n\nDecompressor features\n---------------------\n\nHandling of input (compressed) stream:\n\n* Can reside (fully) in memory.\n* Can be received, byte by byte, from an application-defined callback\n  function (which e.g. can read it from file or another I/O device).\n* Combination of the above: a chunk of input is buffered in memory,\n  when buffer is exhausted, the application callback is called to refill\n  it.\n\nHandling of output (decompressed) stream:\n\n* In-memory decompression, where output stream fully resides in memory.\n* Streaming decompression, which allows to process arbitrary-sized streams\n  (longer than available memory), but requires in-memory buffer for Deflate\n  dictionary window.\n* Application specifies number of output bytes it wants to decompress,\n  which can be as high as UINT_MAX to decompress everything into memory\n  at once, or as low as 1 to decompress byte by byte, or any other value\n  to decompress a chunk of that size.\n\nNote that in regard to input stream handling, uzlib employs callback-based,\n\"pull-style\" design. The control flow looks as follows:\n\n1. Application requests uzlib to decompress given number of bytes.\n2. uzlib performs decompression.\n3. If more input is needed to decompress given number of bytes, uzlib\n   calls back into application to provide more input bytes. (An\n   implication of this is that uzlib will always return given number of\n   output bytes, unless end of stream (or error) happens).\n\nThe original Zlib library instead features \"push-style\" design:\n\n1. An application prepares arbitrary number of input bytes in a buffer,\n   and free space in output buffer, and calls Zlib with these buffers.\n2. Zlib tries to decode as much as possible input and produce as much\n   as possible output. It returns back to the application if input\n   buffer is exhausted, or output buffer is full, whatever happens\n   first.\n\nCurrently, uzlib doesn't support push-style operation a-la Zlib.\n\nCompressor features\n-------------------\n\nCompressor uses very basic implementation of LZ77 algorithm using hash\ntable to find repeating substrings. The size of the hash table (on which\ncompression efficiency depends), pointer to the hashtable memory, and\nthe size of LZ77 dictionary should be configured in `struct uzlib_comp`.\n\nCurrently, compressor doesn't support streaming operation, both input and\noutput must reside in memory. Neither it supports incremental operation,\nentire input buffer is compressed at once with a single call to uzlib.\n\nAPI and configuration\n---------------------\n\nThe API is defined in the file [uzlib.h](src/uzlib.h) and should be largely\nself-describing. There are also examples implementing gzip-compatible\ncompression and decompression applications in [examples/](examples/) for\nfurther reference. (You may also refer to the original `tinf` README\nbelow for additional information, but it's mostly provided for\nhistorical reference, and `uzlib` largely evolved beyond it).\n\nThere are some compile-time options for the library, defined in\nthe file [uzlib_conf.h](src/uzlib_conf.h). They can be altered directly\nin the file, or passed as the compiler options (`-DXXX=YYY`) when\nbuilding library.\n\nBinary sizes\n------------\n\nTo give an impression of code/data sizes of uzlib, the following figures\nare provided. Numbers for *.o files are code sizes of individual\ncomponents (tinflate.o is decompressor, genlz77.o and defl_static.o -\ncompressor), and TINF_DATA is the size of the corresponding data\nstructure. These numbers are provided for different architectures,\nwith default uzlib configuration, and with compilers/their options\nas specified.\n\n```\ngcc -m32 -Os\ngcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0\n2891 src/tinflate.o\n381 src/genlz77.o\n1685 src/defl_static.o\n1284 TINF_DATA\n\narm-none-eabi-gcc -mthumb -mcpu=cortex-m4 -Os\narm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]\n1620 src/tinflate.o\n180 src/genlz77.o\n1131 src/defl_static.o\n1284 TINF_DATA\n```\n\n---\n\nOriginal tinf library README\n============================\n\n*For historical reference and to provide proper credit, the original `tinf`\nlibrary README follows. NOTE: Many parts no longer apply to `uzlib`. In\nparticular, API is different, features supported are largely extended,\nand during decompression, there are checks to avoid erroneous/undefined\nbehavior on incorrect Deflate bitstreams.*\n\ntinf - tiny inflate library\n===========================\n\nVersion 1.00\n\nCopyright (c) 2003 Joergen Ibsen\n\n\u003chttp://www.ibsensoftware.com/\u003e\n\n\nAbout\n-----\n\ntinf is a small library implementing the decompression algorithm for the\ndeflate compressed data format (called 'inflate'). Deflate compression is\nused in e.g. zlib, gzip, zip and png.\n\nI wrote it because I needed a small in-memory zlib decompressor for a self-\nextracting archive, and the zlib library added 15k to my program. The tinf\ncode added only 2k.\n\nNaturally the size difference is insignificant in most cases. Also, the\nzlib library has many more features, is more secure, and mostly faster.\nBut if you have a project that calls for a small and simple deflate\ndecompressor, give it a try :-)\n\nWhile the implementation should be fairly compliant, it does assume it is\ngiven valid compressed data, and that there is sufficient space for the\ndecompressed data.\n\nSimple wrappers for decompressing zlib streams and gzip'ed data in memory\nare supplied.\n\ntgunzip, an example command-line gzip decompressor in C, is included.\n\nThe inflate algorithm and data format are from 'DEFLATE Compressed Data\nFormat Specification version 1.3' ([RFC 1951][1]).\n\nThe zlib data format is from 'ZLIB Compressed Data Format Specification\nversion 3.3' ([RFC 1950][2]).\n\nThe gzip data format is from 'GZIP file format specification version 4.3'\n([RFC 1952][3]).\n\nIdeas for future versions:\n\n- the fixed Huffman trees could be built by `tinf_decode_trees()`\n  using a small table\n- memory for the `TINF_DATA` object should be passed, to avoid using\n  more than 1k of stack space\n- wrappers for unpacking zip archives and png images\n- implement more in x86 assembler\n- more sanity checks\n- in `tinf_uncompress`, the (entry value of) `destLen` and `sourceLen`\n  are not used\n- blocking of some sort, so everything does not have to be in memory\n- optional table-based huffman decoder\n\n[1]: http://www.rfc-editor.org/rfc/rfc1951.txt\n[2]: http://www.rfc-editor.org/rfc/rfc1950.txt\n[3]: http://www.rfc-editor.org/rfc/rfc1952.txt\n\n\nFunctionality\n-------------\n\n    void tinf_init();\n\nInitialise the global uninitialised data used by the decompression code.\nThis function must be called once before any calls to the decompression\nfunctions.\n\n    int tinf_uncompress(void *dest,\n                        unsigned int *destLen,\n                        const void *source,\n                        unsigned int sourceLen);\n\nDecompress data in deflate compressed format from `source[]` to `dest[]`.\n`destLen` is set to the length of the decompressed data. Returns `TINF_OK`\non success, and `TINF_DATA_ERROR` on error.\n\n    int tinf_gzip_uncompress(void *dest,\n                             unsigned int *destLen,\n                             const void *source,\n                             unsigned int sourceLen);\n\nDecompress data in gzip compressed format from `source[]` to `dest[]`.\n`destLen` is set to the length of the decompressed data. Returns `TINF_OK`\non success, and `TINF_DATA_ERROR` on error.\n\n    int tinf_zlib_uncompress(void *dest,\n                             unsigned int *destLen,\n                             const void *source,\n                             unsigned int sourceLen);\n\nDecompress data in zlib compressed format from `source[]` to `dest[]`.\n`destLen` is set to the length of the decompressed data. Returns `TINF_OK`\non success, and `TINF_DATA_ERROR` on error.\n\n    unsigned int tinf_adler32(const void *data,\n                              unsigned int length);\n\nComputes the Adler-32 checksum of `length` bytes starting at `data`. Used by\n`tinf_zlib_uncompress()`.\n\n    unsigned int tinf_crc32(const void *data,\n                            unsigned int length);\n\nComputes the CRC32 checksum of `length` bytes starting at `data`. Used by\n`tinf_gzip_uncompress()`.\n\n\nSource Code\n-----------\n\nThe source code is ANSI C, and assumes that int is 32-bit. It has been\ntested on the x86 platform under Windows and Linux.\n\nThe decompression functions should be endian-neutral, and also reentrant\nand thread-safe (not tested).\n\nIn src/nasm there are 32-bit x86 assembler (386+) versions of some of the\nfiles.\n\nMakefiles (GNU Make style) for a number of compilers are included.\n\n\nFrequently Asked Questions\n--------------------------\n\nQ: Is it really free? Can I use it in my commercial ExpenZip software?\n\nA: It's open-source software, available under the zlib license (see\n   later), which means you can use it for free -- even in commercial\n   products. If you do, please be kind enough to add an acknowledgement.\n\nQ: Did you just strip stuff from the zlib source to make it smaller?\n\nA: No, tinf was written from scratch, using the RFC documentation of\n   the formats it supports.\n\nQ: What do you mean by: 'the zlib library .. is more secure'?\n\nA: The zlib decompression code checks the compressed data for validity\n   while decompressing, so even on corrupted data it will not crash.\n   The tinf code assumes it is given valid compressed data.\n\nQ: I'm a Delphi programmer, can I use tinf?\n\nA: Sure, the object files produced by both Borland C and Watcom C should\n   be linkable with Delphi.\n\nQ: Will tinf work on UltraSTRANGE machines running WhackOS?\n\nA: I have no idea .. please try it out and let me know!\n\nQ: Why are all the makefiles in GNU Make style?\n\nA: I'm used to GNU Make, and it has a number of features that are missing\n   in some of the other Make utilities.\n\nQ: This is the first release, how can there be frequently asked questions?\n\nA: Ok, ok .. I made the questions up ;-)\n\n\nLicense\n-------\n\ntinf - tiny inflate library\n\nCopyright (c) 2003 Joergen Ibsen\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no event will the authors be held liable for any damages\narising from the use of this software.\n\nPermission is granted to anyone to use this software for any purpose,\nincluding commercial applications, and to alter it and redistribute it\nfreely, subject to the following restrictions:\n\n1. The origin of this software must not be misrepresented; you must\n   not claim that you wrote the original software. If you use this\n   software in a product, an acknowledgment in the product\n   documentation would be appreciated but is not required.\n\n2. Altered source versions must be plainly marked as such, and must\n   not be misrepresented as being the original software.\n\n3. This notice may not be removed or altered from any source\n   distribution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfalcon%2Fuzlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpfalcon%2Fuzlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpfalcon%2Fuzlib/lists"}