text: ComprLib - A Data Compression Library
  WEBINAR:
  On-Demand
  Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js
  Environment: VC4
  To use ComprLib, first you set up the I/O function pointers, and then you call a function that encodes or decodes (or computes the checksum) the data.
  The following function pointers are used for I/O in ComprLib (defined in ComprLib.h):
  extern bool (*end_of_data)(); // Returns true if no more input data left extern unsigned char (*read_byte)(); // Reads a byte from the input data extern void (*write_byte)(unsigned char); // Writes a byte to output data extern void (*beginning_of_data)(); // Resets position of input data extern long (*stream_size)(); // Returns the size of the input dataend_of_data() returns true if there is no more input data left, read_byte() reads a byte from the input data and returns it, write_byte() writes a byte to the output data, beginning_of_data() resets the position of the input file back to the beginning, and finally stream_size() returns the size of the input data. All of these function pointers should be set to functions that do the things described above.
  These functions that are pointed to by the global I/O function pointers may be grouped in a class. You can derive the I/O class from CComprLibIOBase, which is defined as follows:
  class ComprLibIOBase { public: static bool end_of_data(); static unsigned char read_byte(); static void write_byte(unsigned char); static void beginning_of_data(); static long stream_size(); static void write_array(void*, int); static void write_block(unsigned char, int); };The derived class should provide implementation for each of these functions. Classes should also provide a Set() method that sets all of the global I/O function pointers to the ones in the class. Optionally it may also provide member functions that set only the input or output function pointers, this way applications can combine multiple I/O routines.
  Note that all of the functions are static. This is because one should never instanate a I/O class, but rather call the static functions in it.
  Two I/O classes are provided with ComprLib. These are CComprLibFileIO, CComprLibMemIO.
  CComprLibFileIO handles file I/O. By setting the two FILE* variables CComprLibFileIO::source_file and CComprLibFileIO::dest_file, you can control what files are used for reading and writing. Setting CComprLibFileIO::file_limit allows you to consider a certain position end the input file the end of the file (i.e., no more data will be read beyond this point).static char* source_ptr; static char* dest_ptr; static long source_len; static long dest_len; static long grow_by;
  CComprLibMemIO handles memory "I/O". It is much faster than the file I/O class. The following member variables are in CComprLibMemIO:
  It is recommended that you use the memory I/O if you want speed.
  After you have set all the variables in the I/O class of your choice to the correct values, call the Set() method in the class. It will set the global I/O function pointers to point to the ones in the class.
  After all the I/O stuff is set, you can call a function that compresses, encrypts, converts to plain text, or figures out the checksum of a file. ComprLib has over 45 functions for doing this, but beware - not all of them work. Some crash. Sorry about that.
  Stable functions include:
  unsigned int UpdateCRC (unsigned int crc, int c); unsigned int UpdateCRCReverse (unsigned int crc, int c); unsigned long adler32(); unsigned long crc32(); void addsub_decode (char* pw); void addsub_encode (char* pw); void adler32 (char c, char* buf, long len); void crc32 (unsigned char c, unsigned long* crc); void hex_decode(); void hex_encode(); void invert_decode(); void invert_encode(); void lzari_decode (); void lzari_encode (); void lzhuf_decode (); void lzhuf_encode (); void lzss_decode (); void lzss_encode (); void lzw_encode (); void rle1_decode (); void rle1_encode (); void rle2_decode (); void rle2_encode (); void uu_decode(); void uu_encode(); void xor_decode (char*); void xor_encode (char*); void xx_decode(); void xx_encode(); void spin(int speed /*= 10*/, char chars[] /*= "|/-\\\0"*/);
  Now for an example program:
  #include "comprlib.h" int main() { // Set the functions in 'ComprLibFileIO' class to the global I/O ones ComprLibFileIO::Set(); // Set the source and dest files to the standard input and output // streams. To compress a file, use 'fopen'. ComprLibFileIO::source_file = stdin; ComprLibFileIO::dest_file = stdout; fprintf (stderr, "Compressing stdin to stdout...\n"); // Compress the streams using LZSS method. lzss_encode(); }This example will compress standard input to standard output. But this is not MFC - see WinCompr for an MFC example. WinCompr is pretty easy to use, so I won't explain it here.
  Hope you like it!
  DownloadsDownload demo project - 79KB
  Download source - 372KB
  Please help mePosted by Legacy on 03/24/2003 12:00am
  Originally posted by: mrNghia
  When I runed WinCompr in VC++ 6.0:Command line error D2016 : '/ZI' and '/Ob2' command-line options are incompatible.Please help me.
  thanhk
  nihaoPosted by Legacy on 07/11/2001 12:00am
  Originally posted by: hjwang
  niaoReply
  some words to the compression-formatsPosted by Legacy on 04/09/2001 12:00am
  Originally posted by: M.Rissler
  hello, can someone tell me which of these used compress formats can be included into commercial applications for free ;-) .
  thanks a lot!
  M. Ri�lerReply
  Where is the comprlib.lib file in your demo source?Posted by Legacy on 04/20/2000 12:00am
  Originally posted by: Jayson
  LZW PatentPosted by Legacy on 02/22/2000 12:00am
  Originally posted by: Greg Heck
  Be careful when using the LZW encode in any software you plan to release outside your home. LZW is patented by Unisys and anyone implementing the decoder or encoder in their software must obtain a license.
  Reply
  Can you tell a word where's "lzw_decode"?Posted by Legacy on 10/25/1999 12:00am
  Originally posted by: Victor
  I could not find function lzw_decode... :o(
  Can I decode data, encoded with LZW method(used here)?
  (And one more comment:
  I needed to compress data from source to destination memory block, but lz-huffman algorithm described in this project use its' own memory cycle buffer. It copies source mem buffer through its' own to desination block(with compression, of course).
  ( There is no problem if You have PII... :)
  I'll get rid of this buffer...
  )
  Any way Thanks for "WinCompr". It was interesting to decrypt it ;-)Reply