What is the POSIX System Library for the LZW Algorithm Used by the Compress Utility What is the POSIX System Library for the LZW Algorithm Used by the Compress Utility unix unix

What is the POSIX System Library for the LZW Algorithm Used by the Compress Utility


I think I've found some good references:

First here is the Free BSD implementation of compress based on Lempel-Ziv:https://www.freebsd.org/security/advisories/FreeBSD-SA-11:04.compress.asc

Here and here a modified version of the Lempel-Ziv algorithm (among the authors you will find Spencer W. Thomas).

Newer implementation

DOS porting

Apple version based on FREE BSD.

hint: search "compress.c" quoted.


Certainly in Linux the system library libarchive supports LZW as used by compress.

The library has its own project page, and in that sense therefore is portable, although it is no doubt used on other, if not all POSIX systems. Try man libarchive perhaps?


You can find an unlzw() function that I wrote here to decompress a Content-Encoding: compress transfer.

However, you do not have to support compress to be http-compliant. The compression method is a negotiation, and you can either not say that you accept compress (if you are the client) or not deliver compress when the client accepts it (if you are the server). It is not true that "every server should support" the compress encoding.