#ifndef SFXStructsHPP
#define SFXStructsHPP

typedef unsigned TCRC32Table[257];
enum TSFXOverwriteMode { somOverwrite, somSkip, somAsk };

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;
const int soDetached             = 0x400;

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

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;
} ;

struct TZipLocalHeader
{
	unsigned HeaderSig;
	unsigned short VersionNeed;
	unsigned short Flag;
	unsigned short ComprMethod;
	unsigned short ModifTime;
	unsigned short ModifDate;
	unsigned CRC32;
	unsigned ComprSize;
	unsigned UnComprSize;
	unsigned short FileNameLen;
	unsigned short ExtraLen;
} ;

struct TZipCentralHeader
{
	unsigned HeaderSig;
	unsigned char VersionMadeBy0;
	unsigned char VersionMadeBy1;
	unsigned short VersionNeed;
	unsigned short Flag;
	unsigned short ComprMethod;
	unsigned short ModifTime;
	unsigned short ModifDate;
	unsigned CRC32;
	unsigned ComprSize;
	unsigned UnComprSize;
	unsigned short FileNameLen;
	unsigned short ExtraLen;
	unsigned short FileComLen;
	unsigned short DiskStart;
	unsigned short IntFileAtt;
	unsigned ExtFileAtt;
	unsigned RelOffLocal;
} ;

struct TZipEndOfCentral
{
	unsigned HeaderSig;
	unsigned short ThisDiskNo;
	unsigned short CentralDiskNo;
	unsigned short CentralEntries;
	unsigned short TotalEntries;
	unsigned CentralSize;
	unsigned CentralOffSet;
	unsigned short ZipCommentLen;
} ;

struct TZipExtLocalHeader
{
	unsigned DataDescSig;
	unsigned CRC32;
	unsigned ComprSize;
	unsigned UnComprSize;
} ;

union ZipVersion
{
 unsigned short Version;
 struct
 {
 unsigned char VerNo;   // Made by version number
 unsigned char SysNo;   // Made by host number
 };
};

  // in detached sfx archives, the sfx contains an additional record following the header
struct TSFXDetachedHeader
{
  unsigned Signature; // must be SFX_DETACHED_HEADER_SIG or SFX_DETACHED_HEADER_END_SIG
  unsigned NameLen;
  unsigned ExtLen; // contains the length of the filename/fileext of the archive (without path)
};


#pragma pack(pop)

#endif	// SFXStructs
