// ---------------------------------------------------------------------------
// 
//   Lily Engine alpha
// 
//   Copyright (c) 2010 Clifford Jolly
//     http://cliffjolly.com
//     cliff@cliffjolly.com
// 
// ---------------------------------------------------------------------------
// 
//   This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//  
//   This program is distributed in the hope that it will be useful, but
//   WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//   General Public License for more details.
// 
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
//   USA
// -------------------------- END HEADER -------------------------------------

#ifndef MALCOMPRESS_H
#define MALCOMPRESS_H

/// Compress a chunk of data. Compressed data will be returned and is
/// owned by the caller (must eventually delete[] it). Length of the
/// returned chunk is stored in outLength. groupSize is the number of
/// bytes to be considered a single unit for the purposes of run-length
/// encoding.
char *compressRLE(const char *inData, unsigned int inLength, unsigned int *outLength, int groupSize = 1);

/// Same as above, but takes a previously compressed chunk and returns
/// a decompressed chunk. Make sure to use the same groupSize for
/// decompression. If decompression fails due to corrupt data or
/// incorrect groupSize, will return NULL. (Or possibly just crash. :D)
char *decompressRLE(const char *inData, unsigned int inLength, unsigned int *outLength, int groupSize = 1);

#endif
