#ifndef SFXDefsH
#define SFXDefsH


typedef unsigned TCRC32Table[257];

//struct Thuft;
//typedef Thuft *PT;

#pragma pack(push, 1)
struct Thuft
{
	signed char e;
	signed char b;
	unsigned short n;
	Thuft *Next;
} ;
#pragma pack(pop)


enum TSFXOverwriteMode { somOverwrite, somSkip, somAsk };
//enum TSFXOption { soAskCmdLine, soAskFiles, soHideOverWriteBox, soAutoRun, soNoSuccessMsg,
//                  soExpandVariables, soInitiallyHideFiles, soForceHideFiles,
//                  soCheckAutoRunFileName, soCanBeCancelled };

//typedef Set<TSFXOption, soAskCmdLine, soCanBeCancelled>  TSFXOptions;

const int soAskCmdLine           = 0x001;
const int soAskFiles             = 0x002;
const int soHideOverWriteBox     = 0x004;
const int soAutoRun              = 0x008;
const int soNoSuccessMsg         = 0x010;
const int soExpandVariables      = 0x020;
const int soInitiallyHideFiles   = 0x040;
const int soForceHideFiles       = 0x080;
const int soCheckAutoRunFileName = 0x100;
const int soCanBeCancelled       = 0x200;

#pragma pack(push, 1)
struct TSFXFileHeader
{
	unsigned Signature;
	unsigned short Size;
  unsigned short Options;
	TSFXOverwriteMode DefOVW;
	unsigned char CaptionSize;
	unsigned char PathSize;
	unsigned char CmdLineSize;
	unsigned char RegFailPathSize;
	unsigned char StartMsgSize;
	unsigned StartMsgType;
} ;
#pragma pack(pop)

//-- const---------------------------------------------------
#define MaxInt (int)(2147483647)
const unsigned CRCPOLY = 0xEDB88320;
const int  UCHARMAX = 256;
const int  CHARBIT = 8;
const unsigned IMAGE_PE_SIGNATURE  = 0x00004550;
const int  RAND_HEAD_LEN = 12;
const unsigned CRC_MASK = 0xFFFFFFFF;
// window size--must be a power OF two, and at least 32k
const int WSIZE = 32768;   // = 0x8000
// 'DZ'#0#1;  // current header signature
const int SFX_HEADER_SIG = 0x01005A44;
  // 'DZ'#10#1; // current end of header signature
const int SFX_HEADER_END_SIG = 0x010A5A44;

const int ZipLocalHeaderSig = 0x4034b51;// +1 because ZipDll doesn't like
const int ZipCentralHeaderSig = 0x2014b51;// this sigs in the .bin
const int ZipEndOfCentralSig = 0x6054b51;


const int BMAX = 16;    // maximum bit length of any code (16 for explode)
const int N_MAX = 288;  // maximum number of codes in any set
static const int lbits = 9;     // bits in base literal/length lookup table
static const int dbits = 6;     // bits in base distance lookup table

/* Tables for deflate from PKZIP's appnote.txt. */
static const unsigned border[] =
{      /* Order of the bit length code lengths */
  16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
};
static const unsigned short cplens[] =
{   /* Copy lengths for literal codes 257..285 */
  3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
  35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
};
        /* note: see note #13 above about the 258 in this list. */
static const unsigned short cplext[] =
{   /* Extra bits for literal codes 257..285 */
  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
  3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99
};                              /* 99==invalid */
static const unsigned short cpdist[] =
{   /* Copy offsets for distance codes 0..29 */
  1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
  257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
  8193, 12289, 16385, 24577
};
static const unsigned short cpdext[] =
{   /* Extra bits for distance codes */
  0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
  7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
  12, 12, 13, 13
};
/* And'ing with mask_bits[n] masks the lower n bits */
const unsigned short mask_bits[] = {
  0x0000,
  0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
  0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};



#endif	// SFXDefs
