Giter Site home page Giter Site logo

tinf's Introduction

tinf - tiny inflate library

Version 1.2.1

Copyright (c) 2003-2019 Joergen Ibsen

http://www.ibsensoftware.com/

tinf CI codecov

About

tinf is a small library implementing the decompression algorithm for the deflate compressed data format (called 'inflate'). Deflate compression is used in e.g. zlib, gzip, zip, and png.

I wrote it because I needed a small in-memory zlib decompressor for a self- extracting archive, and the zlib library added 15k to my program. The tinf code added only 2k.

Naturally the size difference is insignificant in most cases. Also, the zlib library has many more features, is well-tested, and mostly faster. But if you have a project that calls for a small and simple deflate decompressor, give it a try :-)

Usage

The include file src/tinf.h contains documentation in the form of doxygen comments.

Wrappers for decompressing zlib and gzip data in memory are supplied.

tgunzip, an example command-line gzip decompressor in C, is included.

tinf uses CMake to generate build systems. To create one for the tools on your platform, and build tinf, use something along the lines of:

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release

You can also compile the source files and link them into your project. CMake just provides an easy way to build and test across various platforms and toolsets.

Notes

tinf requires int to be at least 32-bit.

The inflate algorithm and data format are from 'DEFLATE Compressed Data Format Specification version 1.3' (RFC 1951).

The zlib data format is from 'ZLIB Compressed Data Format Specification version 3.3' (RFC 1950).

The gzip data format is from 'GZIP file format specification version 4.3' (RFC 1952).

The original version of tinf assumed it was given valid compressed data, and that there was sufficient space for the decompressed data. If code size is of the utmost importance, and you are absolutely sure you can trust the compressed data, you may want to check out tinf 1.1.0 (last release without security checks).

Ideas for future versions:

  • Memory for the tinf_data object should be passed, to avoid using more than 1k of stack space
  • Wrappers for unpacking zip archives and png images
  • Blocking of some sort, so everything does not have to be in memory
  • Optional table-based Huffman decoder
  • Small compressor using fixed Huffman trees

Related Projects

License

This projected is licensed under the zlib License (Zlib).

tinf's People

Contributors

jibsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinf's Issues

tgunzip example may crash on files less than 4 bytes

The last four bytes of a gzip "frame" are the decompressed size. If the input file is less than 4 bytes, tgunzip will read before the buffer allocated for the compressed data.

This is an error in the tgunzip example, not in tinf_gzip_uncompress.

Activate more gcc/clang warnings

I compile tinf with the following flags and get many warnings due to implicit casts (-Wconversion and -Wsign-conversion).

gcc -Isrc -Wall -Wextra -Wconversion -Wsign-conversion test/test_tinf.c src/*.c

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.