I want my program to be able to use zlib, lzma, lzo and bzip2 compression algorithms.
Is there any compression library for C which simlifies working with multiple algorithms (like libmcrypt supporting multiple encryption modes and algorithms)?
Expecting something like this:
struct compressor c;
universal_compressor_init(&c, "lzma", 7 /* compression level */);
universal_compressor_compress(&c, inputbuf, inputsize, outputbuf, &outputsize);
universal_compressor_save_state(&c, statebuf, &statesize);
Note: It is not about zip/rar/7z/tar/cpio and other archive formats, it's about compression of raw buffers. Think of compressed networking protocol or about random access to compressed block device (like cloop).
LibArchive fulfills your requirements.
From the introduction:
The libarchive library features:
- Support for a variety of archive and compression formats.
- Robust automatic format detection, including archive/compression combinations such as tar.gz. ...
EDIT: for handling raw streams (at least until they split libfilter from libarchive), consider using Boost::iostreams or libbu++ (just found on GitHub)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With