/*******************************************************************************
  TPI - flexible but useless plug-in framework.
  Copyright (C) 2002-2009 Silky

  This library is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the Free
  Software Foundation; either version 2.1 of the License, or (at your option)
  any later version.

  This library 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 Lesser General Public License
  for more details.

  You should have received a copy of the GNU Lesser General Public License along
  with this library; if not, write to the Free Software Foundation, Inc.,
  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

  $Id: 7zArc.h 231 2010-02-18 03:32:41Z sirakaba $
*******************************************************************************/

#include "StdAfx.h"

#include "Common/IntToString.h"
#include "Common/MyInitGuid.h"
#include "Common/StringConvert.h"

#include "Windows/DLL.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
#include "Windows/FileName.h"
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
#include "Windows/Time.h"

#include "../../Common/FileStreams.h"

#include "../../Archive/IArchive.h"

#include "../../IPassword.h"
#include "../../MyVersion.h"

//******************************************************************************
//    Defines
//******************************************************************************

DEFINE_GUID(CLSID_CFormatZip,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x01, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatBZip2, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x02, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatRar,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x03, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatArj,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x04, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatZ,     0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x05, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatLzh,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x06, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormat7z,    0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatCab,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x08, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatNsis,  0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x09, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatLzma,  0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x0A, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatLzma86,0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x0B, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatXz,    0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x0C, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatApm,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD4, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatMslz,  0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD5, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatFlv,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD6, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatSwf,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD7, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatSwfc,  0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD8, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatNtfs,  0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xD9, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatFat,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDA, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatMbr,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDB, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatVhd,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDC, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatPe,    0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDD, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatElf,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDE, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatMachO, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xDF, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatUdf,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE0, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatXar,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE1, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatMub,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE2, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatHfs,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE3, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatDmg,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE4, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatCom,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE5, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatWim,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE6, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatIso,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE7, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatBkf,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE8, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatChm,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xE9, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatSplit, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEA, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatRpm,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEB, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatDeb,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEC, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatCpio,  0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xED, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatTar,   0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEE, 0x00, 0x00);
DEFINE_GUID(CLSID_CFormatGZip,  0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEF, 0x00, 0x00);

const GUID guidList[] = {
	CLSID_CFormatZip,
	CLSID_CFormatBZip2,
#if 0
	CLSID_CFormatRar,
#endif
#ifdef __LINUX__
	CLSID_CFormatArj,
#endif
	CLSID_CFormatZ,
#ifdef __LINUX__
	CLSID_CFormatLzh,
#endif
	CLSID_CFormat7z,
#ifdef __LINUX__
	CLSID_CFormatCab,
#endif
	CLSID_CFormatNsis,
	CLSID_CFormatLzma,
	CLSID_CFormatLzma86,
	CLSID_CFormatXz,
	CLSID_CFormatApm,
	CLSID_CFormatMslz,
	CLSID_CFormatFlv,
	CLSID_CFormatSwf,
	CLSID_CFormatSwfc,
	CLSID_CFormatNtfs,
	CLSID_CFormatFat,
	CLSID_CFormatMbr,
	CLSID_CFormatVhd,
#if 0
	CLSID_CFormatPe,
	CLSID_CFormatElf,
#endif
	CLSID_CFormatMachO,
	CLSID_CFormatUdf,
	CLSID_CFormatXar,
	CLSID_CFormatMub,
	CLSID_CFormatHfs,
	CLSID_CFormatDmg,
	CLSID_CFormatCom,
	CLSID_CFormatWim,
	CLSID_CFormatIso,
	CLSID_CFormatBkf,
	CLSID_CFormatChm,
	CLSID_CFormatSplit,
#ifdef __LINUX__
	CLSID_CFormatRpm,
	CLSID_CFormatDeb,
	CLSID_CFormatCpio,
	CLSID_CFormatTar,
#endif
	CLSID_CFormatGZip
};

//******************************************************************************
//    Structures
//******************************************************************************

