QuickLZ ZIP

The QuickLZ ZIP library will offer light but fast ZIP and deflate compression. The project is still in its prototype phase which is why this website is so sparse.

Prototype version 0.4, 01-Oct-2007:

    zip.c
    zip.h
    demo.c

Pre-compiled demo.c for Windows: demo.exe

ZIP API
There is currently no manual for QuickLZ ZIP, but its usage can be seen from the demo projects and an outline is presented here.

QuickLZ ZIP does not perform file I/O. Instead, functions take an argument named destination at which they place data that you must write to a zip file. Before calling end_file you are required to seek backwards in the zip file. This is because the zip format stores the compressed size of files before the compressed data itself in order for a decompressor to be able to quickly seek through files.

  1. Call new_zip.

  2. Save file position indicator of the output file (will be 0 first time).

  3. Call add_file to begin adding a file to the zip archive.

  4. Repeatedly call add_data to add data from the file. The eof argument must be 1 for the last call and 0 for all prior calls.

  5. Seek backwards to the saved file position indicator.

  6. Call end_file.

  7. Seek file position indicator to end of file.

  8. Repeat step 2 to 7 for each file to add to the archive.

  9. Call end_zip.

Zip files larger than 4 Gbyte are currently not supported.

Deflate API
Following deflate function is implemented. A large data entity can be compressed in smaller pieces at a time by setting last = 0 for the first calls and last = 1 for the last call.

unsigned int deflate(unsigned char *source, unsigned char *destination, unsigned int bitoffset, unsigned int size, unsigned int last);

Compress size amount of bytes from source and store the result at destination plus bit offset bitoffset.

The size argument must be between 0 and 1,073,741,823 bytes, both inclusive.

The bitoffset argument must be between 0 and 7, both inclusive. Because compressed data has bit size grannularity in the deflate format, the bitoffset argument can be used to append one block of compressed data to another.

The last argument must be 1 for the last call to deflate and 0 for all prior calls.

Return value: Size of compressed result is bits.