This has been an incredibly difficult question to Google. I am not looking for gzip or Zip or deflate. The algorithm I want to use is called "compress" but that does not mean I am trying to implement compression in general. I am looking for a specific algorithm.
I am looking for the adaptive Lempel-Ziv algorithm used by the compress
command line tool in Unix-like systems. I am looking for the algorithm HTTP says you should use when you receive a Content-Encoding: compress
header. It's the algorithm you see described when you type man compress
in a POSIX shell, and in this Wikipedia article.
I understand this compression algorithm is very old and has been replaced by gzip, Zip, deflate, etc. for almost all practical purposes. But I am writing a server in C++ as a pet project and IANA specifies this Unix "compress" algorithm as one of the encodings every server should support.
The compress
utility has been part of the Unix shell for a long time - since before POSIX - and I have trouble believing there's no standard C language implementation. I could use calls to system
or exec
to do the compression in the shell (creating another process...ugh) but that would be so much less efficient than just compiling the algorithm into my executable.
Is there a standard C implementation/library for this algorithm?