Below is an implementation of a program to decompress Microsoft style
sliding window compression files (program.ex_). I do not have the
complimentary sliding window compression program - if you do, please
send it.
/*-- slide.h --*/
#ifndef _SLIDE_
#define _SLIDE_
//
// Compressed file header
//
typedef struct _HEADER
{
DWORD dwMagic1;
DWORD dwMagic2;
BYTE bIs41;
CHAR chFileFix;
DWORD dwUnCompSize;
} HEADER;
//
// Microsoft's magic numbers for compressed file headers
//
#define MAGIC1 0x44445A53
#define MAGIC2 0x3327F088
//
// Misc other
//
//
// 2^12 -> 12 bit offset size
//
#define WINSIZE 4096
//
// Compression code:
//
// bByte1: bByte2:
// 0 1 2 3 4 5 6 7 | 0 1 2 3 4 5 6 7
// [ OFFSET DATA ][LENGTH]
// (12 bits) (4 bits)
//
//
// How to extract the 4-bit length code from the 2-byte compression code
// the +3 part makes 0, 1 and 2 byte lengths impossible (since we won't ever
// use them) and allows 16, 17 and 18 byte values from a 4 bit width field.
// Pass only the second byte since it's all in there...
//
#define LENGTH(x) ((((x) & 0x0F)) + 3)
//
// How to extract the 12-bit offset code from the 2-byte compression code
// Pass both bytes.
//
#define OFFSET(x1, x2) ((((x2 & 0xF0) << 4) + (x1) + 0x0010) & 0x0FFF)
//
// Given a position in the file, xlate it into a position in the window.
//
#define WRAPFIX(x) ((x) & (WINSIZE - 1))
//
// Is a certain bit set in a byte.
//
#define BITSET(byte, bit) (((byte) & (1<<(bit))) > 0)
#endif
|