LZO Stream Library

Apparently LZO compression library provides no stream API. Unlike Zlib or BZlib it is 
not possible to use stream compressor out of the box. Liblzostream provides 
same stream interface as Zlib stream does. In addition Adler CRC from LZO library is
used to enforce data integrity.

There is paging algorithm used to slice input stream data into paged and compress
them separately. Page size is adjustable. Stream will accumulate data until input buffer
is filled or flush() method called. Every compressed page in output stream is sealed with
signature and CRC, and data integrity checked upon decompressing.
When you use stream to decompress data it behaves the same way as Zlib stream, so you
just feed stream with another portion of data and copy ready uncompressed stream info
your program.

Usage in brief:


// compress

 CLzoStream::lzo_stream zs;
 zs.next_in = orig_buf;   // pointer to your data
 zs.avail_in = data_len;  // available

 zs.next_out = dest_buf;          // pointer to out data
 zs.avail_out = sizeof(dest_buf); // size of buffer

 int rv = lzoDeflateRev(&zs, CLzoStream::ELzoSyncFlush);

 if (rv != CLzoStream::EStreamEnd )
   // error !
   dest_processed = zs.avail_out; // compressed size

// decompress
 memset (&zs, 0x0, sizeof(lzo_stream)); // clean buffer
 zs.next_in = dest_buf;
 zs.avail_in = dest_processed;

 zs.next_out = my_dest;
 zs.avail_out = sizeof(my_dest);

 rv = lzoInflate(&zs, CLzoStream::ELzoSyncFlush);

 if (rv != CLzoStream::EStreamEnd)
   // error!
  printf ("Uncompressed: avail_in= %d, avail_out= %d\n", zs.avail_in, zs.avail_out);


See examples/ directory for more info.