//////////////////////////////////////////////////////////////////////////// // // lzw.h // // 1/13/01 (Jeff Ondich) Started. Adapted from code published // by Mark R. Nelson in Dr. Dobbs' Journal, April 1989. //////////////////////////////////////////////////////////////////////////// #ifndef LZW_H #define LZW_H #ifndef UINT #define UINT unsigned int #endif #ifndef ULONG #define ULONG unsigned long #endif #ifndef UCHAR #define UCHAR unsigned char #endif #define BITS 12 /* Setting the number of bits to 12, 13*/ #define HASHING_SHIFT BITS-8 /* or 14 affects several constants. */ #define MAX_VALUE (1 << BITS) - 1 /* Note that MS-DOS machines need to */ #define MAX_CODE MAX_VALUE - 1 /* compile their code in large model if*/ /* 14 bits are selected. */ #if BITS == 14 #define TABLE_SIZE 18041 /* The string table size needs to be a */ #endif /* prime number that is somewhat larger*/ #if BITS == 13 /* than 2**BITS. */ #define TABLE_SIZE 9029 #endif #if BITS == 12 #define TABLE_SIZE 5021 #endif #if BITS == 11 #define TABLE_SIZE 2081 #endif #if BITS <= 10 #define TABLE_SIZE 1049 #endif int compress( unsigned char *source, UCHAR *destination, UINT nBytes ); int expand( UCHAR *source, UCHAR *destination ); int output_code( UCHAR **destination, UINT code, UINT& output_bit_count, ULONG& output_bit_buffer ); UINT input_code( UCHAR **source, UINT& input_bit_count, ULONG& input_bit_buffer ); UINT find_match( UINT hash_prefix, UINT hash_character); UCHAR *decode_string( UCHAR *buffer, UINT code ); #endif