diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2007-01-20 03:00:00 +0300 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:15:49 +0300 |
commit | d9666cf046a8453b33b3e2fbf4d82295a9f87df3 (patch) | |
tree | c722ed19b844b53042aec0c1d7d2f8381140a5ed /CPP/7zip/Archive/RPM | |
parent | 804edc5756fede54dbb1aefda6d39d306111938d (diff) |
4.44 beta
Diffstat (limited to 'CPP/7zip/Archive/RPM')
-rwxr-xr-x | CPP/7zip/Archive/RPM/DllExports.cpp | 68 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/Rpm.dsp | 205 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/Rpm.dsw | 29 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/RpmHandler.cpp | 194 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/RpmHandler.h | 46 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/RpmHeader.h | 63 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/RpmIn.cpp | 112 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/RpmIn.h | 15 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/StdAfx.cpp | 3 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/StdAfx.h | 8 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/makefile | 42 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/resource.rc | 5 | ||||
-rwxr-xr-x | CPP/7zip/Archive/RPM/rpm.ico | bin | 0 -> 3638 bytes |
13 files changed, 790 insertions, 0 deletions
diff --git a/CPP/7zip/Archive/RPM/DllExports.cpp b/CPP/7zip/Archive/RPM/DllExports.cpp new file mode 100755 index 00000000..ed21e64f --- /dev/null +++ b/CPP/7zip/Archive/RPM/DllExports.cpp @@ -0,0 +1,68 @@ +// DLLExports.cpp + +#include "StdAfx.h" + +#include "Common/MyInitGuid.h" +#include "Common/ComTry.h" +#include "Windows/PropVariant.h" +#include "../../ICoder.h" +#include "RpmHandler.h" + +// {23170F69-40C1-278A-1000-000110EB0000} +DEFINE_GUID(CLSID_CRpmHandler, + 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEB, 0x00, 0x00); + +extern "C" +BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /* lpReserved */) +{ + return TRUE; +} + +STDAPI CreateObject( + const GUID *classID, + const GUID *interfaceID, + void **outObject) +{ + COM_TRY_BEGIN + *outObject = 0; + if (*classID != CLSID_CRpmHandler) + return CLASS_E_CLASSNOTAVAILABLE; + if (*interfaceID != IID_IInArchive) + return E_NOINTERFACE; + CMyComPtr<IInArchive> inArchive = (IInArchive *)new NArchive::NRpm::CHandler; + *outObject = inArchive.Detach(); + COM_TRY_END + return S_OK; +} + +STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value) +{ + NWindows::NCOM::CPropVariant propVariant; + switch(propID) + { + case NArchive::kName: + propVariant = L"Rpm"; + break; + case NArchive::kClassID: + { + if ((value->bstrVal = ::SysAllocStringByteLen( + (const char *)&CLSID_CRpmHandler, sizeof(GUID))) != 0) + value->vt = VT_BSTR; + return S_OK; + } + case NArchive::kExtension: + propVariant = L"rpm"; + break; + case NArchive::kAddExtension: + propVariant = L".cpio.gz"; + break; + case NArchive::kUpdate: + propVariant = false; + break; + case NArchive::kKeepName: + propVariant = false; + break; + } + propVariant.Detach(value); + return S_OK; +} diff --git a/CPP/7zip/Archive/RPM/Rpm.dsp b/CPP/7zip/Archive/RPM/Rpm.dsp new file mode 100755 index 00000000..085fe137 --- /dev/null +++ b/CPP/7zip/Archive/RPM/Rpm.dsp @@ -0,0 +1,205 @@ +# Microsoft Developer Studio Project File - Name="Rpm" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=Rpm - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "Rpm.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "Rpm.mak" CFG="Rpm - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "Rpm - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "Rpm - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "Rpm - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RPM_EXPORTS" /YX /FD /c +# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RPM_EXPORTS" /Yu"StdAfx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x419 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-zip\Formats\rpm.dll" /opt:NOWIN98 +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "Rpm - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 1 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RPM_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RPM_EXPORTS" /Yu"StdAfx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x419 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-zip\Formats\rpm.dll" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "Rpm - Win32 Release" +# Name "Rpm - Win32 Debug" +# Begin Group "Spec" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\Archive.def +# End Source File +# Begin Source File + +SOURCE=.\DllExports.cpp +# End Source File +# Begin Source File + +SOURCE=.\resource.rc +# End Source File +# Begin Source File + +SOURCE=.\Rpm.ico +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"StdAfx.h" +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Windows" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\..\Windows\PropVariant.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\PropVariant.h +# End Source File +# End Group +# Begin Group "7-zip Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\Common\ProgressUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Common\ProgressUtils.h +# End Source File +# Begin Source File + +SOURCE=..\..\Common\StreamUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Common\StreamUtils.h +# End Source File +# End Group +# Begin Group "Compress" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\Compress\Copy\CopyCoder.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Compress\Copy\CopyCoder.h +# End Source File +# End Group +# Begin Group "Common" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\..\..\Common\Alloc.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\Alloc.h +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\NewHandler.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Common\NewHandler.h +# End Source File +# End Group +# Begin Source File + +SOURCE=.\RpmHandler.cpp +# End Source File +# Begin Source File + +SOURCE=.\RpmHandler.h +# End Source File +# Begin Source File + +SOURCE=.\RpmHeader.h +# End Source File +# Begin Source File + +SOURCE=.\RpmIn.cpp +# End Source File +# Begin Source File + +SOURCE=.\RpmIn.h +# End Source File +# End Target +# End Project diff --git a/CPP/7zip/Archive/RPM/Rpm.dsw b/CPP/7zip/Archive/RPM/Rpm.dsw new file mode 100755 index 00000000..a67232ed --- /dev/null +++ b/CPP/7zip/Archive/RPM/Rpm.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "Rpm"=.\Rpm.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/CPP/7zip/Archive/RPM/RpmHandler.cpp b/CPP/7zip/Archive/RPM/RpmHandler.cpp new file mode 100755 index 00000000..b1a5bf7d --- /dev/null +++ b/CPP/7zip/Archive/RPM/RpmHandler.cpp @@ -0,0 +1,194 @@ +// RPM/Handler.cpp + +#include "StdAfx.h" + +#include "RpmHandler.h" +#include "RpmIn.h" + +#include "Common/Defs.h" +#include "Common/StringConvert.h" +#include "Common/NewHandler.h" +#include "Common/ComTry.h" + +#include "Windows/PropVariant.h" +#include "Windows/Defs.h" + +#include "../../Common/StreamObjects.h" +#include "../../Common/ProgressUtils.h" +#include "../../Common/LimitedStreams.h" + +#include "../../Compress/Copy/CopyCoder.h" +#include "../Common/ItemNameUtils.h" + +using namespace NWindows; + +namespace NArchive { +namespace NRpm { + +STATPROPSTG kProperties[] = +{ +// { NULL, kpidPath, VT_BSTR}, +// { NULL, kpidIsFolder, VT_BOOL}, + { NULL, kpidSize, VT_UI8}, + { NULL, kpidPackedSize, VT_UI8} +}; + +STDMETHODIMP CHandler::GetArchiveProperty(PROPID /* propID */, PROPVARIANT *value) +{ + value->vt = VT_EMPTY; + return S_OK; +} + +STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 *numProperties) +{ + *numProperties = sizeof(kProperties) / sizeof(kProperties[0]); + return S_OK; +} + +STDMETHODIMP CHandler::GetPropertyInfo(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType) +{ + if(index >= sizeof(kProperties) / sizeof(kProperties[0])) + return E_INVALIDARG; + const STATPROPSTG &srcItem = kProperties[index]; + *propID = srcItem.propid; + *varType = srcItem.vt; + *name = 0; + return S_OK; +} + +STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) +{ + *numProperties = 0; + return S_OK; +} + +STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32 /* index */, + BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */) +{ + return E_INVALIDARG; +} + +STDMETHODIMP CHandler::Open(IInStream *inStream, + const UInt64 * /* maxCheckStartPosition */, + IArchiveOpenCallback * /* openArchiveCallback */) +{ + COM_TRY_BEGIN + try + { + if(OpenArchive(inStream) != S_OK) + return S_FALSE; + RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Pos)); + m_InStream = inStream; + UInt64 endPosition; + RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPosition)); + m_Size = endPosition - m_Pos; + return S_OK; + } + catch(...) + { + return S_FALSE; + } + COM_TRY_END +} + +STDMETHODIMP CHandler::Close() +{ + m_InStream.Release(); + return S_OK; +} + +STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems) +{ + *numItems = 1; + return S_OK; +} + +STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value) +{ + COM_TRY_BEGIN + NWindows::NCOM::CPropVariant propVariant; + + switch(propID) + { + /* + case kpidPath: + propVariant = (const wchar_t *)L"a.cpio.gz"; + break; + */ + case kpidIsFolder: + propVariant = false; + break; + case kpidSize: + case kpidPackedSize: + propVariant = m_Size; + break; + } + propVariant.Detach(value); + return S_OK; + COM_TRY_END +} + +STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems, + Int32 _aTestMode, IArchiveExtractCallback *extractCallback) +{ + COM_TRY_BEGIN + bool allFilesMode = (numItems == UInt32(-1)); + if (allFilesMode) + numItems = 1; + if(numItems == 0) + return S_OK; + if(numItems != 1) + return E_FAIL; + if (indices[0] != 0) + return E_FAIL; + + bool testMode = (_aTestMode != 0); + + UInt64 currentTotalSize = 0; + RINOK(extractCallback->SetTotal(m_Size)); + RINOK(extractCallback->SetCompleted(¤tTotalSize)); + CMyComPtr<ISequentialOutStream> realOutStream; + Int32 askMode; + askMode = testMode ? NArchive::NExtract::NAskMode::kTest : + NArchive::NExtract::NAskMode::kExtract; + Int32 index = 0; + + RINOK(extractCallback->GetStream(index, &realOutStream, askMode)); + + if(!testMode && (!realOutStream)) + return S_OK; + + RINOK(extractCallback->PrepareOperation(askMode)); + + if (testMode) + { + RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + return S_OK; + } + + RINOK(m_InStream->Seek(m_Pos, STREAM_SEEK_SET, NULL)); + + CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder; + + CLocalProgress *localProgressSpec = new CLocalProgress; + CMyComPtr<ICompressProgressInfo> progress = localProgressSpec; + localProgressSpec->Init(extractCallback, false); + + try + { + RINOK(copyCoder->Code(m_InStream, realOutStream, NULL, NULL, progress)); + } + catch(...) + { + realOutStream.Release(); + RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kDataError)); + return S_OK; + } + realOutStream.Release(); + RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK)); + return S_OK; + COM_TRY_END +} + +}} diff --git a/CPP/7zip/Archive/RPM/RpmHandler.h b/CPP/7zip/Archive/RPM/RpmHandler.h new file mode 100755 index 00000000..484c6c54 --- /dev/null +++ b/CPP/7zip/Archive/RPM/RpmHandler.h @@ -0,0 +1,46 @@ +// RPM/Handler.h + +#ifndef __RPM_HANDLER_H +#define __RPM_HANDLER_H + +#include "Common/MyCom.h" +#include "../IArchive.h" + +namespace NArchive { +namespace NRpm { + +class CHandler: + public IInArchive, + public CMyUnknownImp +{ +public: + MY_UNKNOWN_IMP + + STDMETHOD(Open)(IInStream *stream, + const UInt64 *maxCheckStartPosition, + IArchiveOpenCallback *openArchiveCallback); + STDMETHOD(Close)(); + STDMETHOD(GetNumberOfItems)(UInt32 *numItems); + STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value); + STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems, + Int32 testMode, IArchiveExtractCallback *extractCallback); + + STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value); + + STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties); + STDMETHOD(GetPropertyInfo)(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType); + + STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties); + STDMETHOD(GetArchivePropertyInfo)(UInt32 index, + BSTR *name, PROPID *propID, VARTYPE *varType); + +private: + CMyComPtr<IInStream> m_InStream; + UInt64 m_Pos; + UInt64 m_Size; +}; + +}} + +#endif diff --git a/CPP/7zip/Archive/RPM/RpmHeader.h b/CPP/7zip/Archive/RPM/RpmHeader.h new file mode 100755 index 00000000..d76963bd --- /dev/null +++ b/CPP/7zip/Archive/RPM/RpmHeader.h @@ -0,0 +1,63 @@ +// Archive/RpmHeader.h + +#ifndef __ARCHIVE_RPM_HEADER_H +#define __ARCHIVE_RPM_HEADER_H + +#include "Common/Types.h" + +namespace NArchive { +namespace NRpm { + +/* Reference: lib/signature.h of rpm package */ +#define RPMSIG_NONE 0 /* Do not change! */ +/* The following types are no longer generated */ +#define RPMSIG_PGP262_1024 1 /* No longer generated */ /* 256 byte */ +/* These are the new-style signatures. They are Header structures. */ +/* Inside them we can put any number of any type of signature we like. */ + +#define RPMSIG_HEADERSIG 5 /* New Header style signature */ + +const UInt32 kLeadSize = 96; +struct CLead +{ + unsigned char Magic[4]; + unsigned char Major; // not supported ver1, only support 2,3 and lator + unsigned char Minor; + UInt16 Type; + UInt16 ArchNum; + char Name[66]; + UInt16 OSNum; + UInt16 SignatureType; + char Reserved[16]; // pad to 96 bytes -- 8 byte aligned + bool MagicCheck() const + { return Magic[0] == 0xed && Magic[1] == 0xab && Magic[2] == 0xee && Magic[3] == 0xdb; }; +}; + +const UInt32 kEntryInfoSize = 16; +/* +struct CEntryInfo +{ + int Tag; + int Type; + int Offset; // Offset from beginning of data segment, only defined on disk + int Count; +}; +*/ + +// case: SignatureType == RPMSIG_HEADERSIG +const UInt32 kCSigHeaderSigSize = 16; +struct CSigHeaderSig +{ + unsigned char Magic[4]; + UInt32 Reserved; + UInt32 IndexLen; // count of index entries + UInt32 DataLen; // number of bytes + bool MagicCheck() + { return Magic[0] == 0x8e && Magic[1] == 0xad && Magic[2] == 0xe8 && Magic[3] == 0x01; }; + UInt32 GetLostHeaderLen() + { return IndexLen * kEntryInfoSize + DataLen; }; +}; + +}} + +#endif diff --git a/CPP/7zip/Archive/RPM/RpmIn.cpp b/CPP/7zip/Archive/RPM/RpmIn.cpp new file mode 100755 index 00000000..c1600894 --- /dev/null +++ b/CPP/7zip/Archive/RPM/RpmIn.cpp @@ -0,0 +1,112 @@ +// Archive/RpmIn.cpp + +#include "StdAfx.h" + +#include "RpmIn.h" + +#include "RpmHeader.h" + +#include "Windows/Defs.h" +#include "Common/MyCom.h" + +#include "../../Common/StreamUtils.h" + +namespace NArchive { +namespace NRpm { + +static UInt16 GetUInt16(const char *data) +{ + return (UInt16)((Byte)data[1] | (((UInt16)(Byte)data[0]) << 8)); +} + +static UInt32 GetUInt32(const char *data) +{ + return + ((UInt32)(Byte)data[3]) | + (((UInt32)(Byte)data[2]) << 8) | + (((UInt32)(Byte)data[1]) << 16) | + (((UInt32)(Byte)data[0]) << 24); +} + +static HRESULT RedSigHeaderSig(IInStream *inStream, CSigHeaderSig &h) +{ + char dat[kCSigHeaderSigSize]; + char *cur = dat; + UInt32 processedSize; + RINOK(ReadStream(inStream, dat, kCSigHeaderSigSize, &processedSize)); + if (kCSigHeaderSigSize != processedSize) + return S_FALSE; + memmove(h.Magic, cur, 4); + cur += 4; + cur += 4; + h.IndexLen = GetUInt32(cur); + cur += 4; + h.DataLen = GetUInt32(cur); + return S_OK; +} + +HRESULT OpenArchive(IInStream *inStream) +{ + UInt64 pos; + char leadData[kLeadSize]; + char *cur = leadData; + CLead lead; + UInt32 processedSize; + RINOK(ReadStream(inStream, leadData, kLeadSize, &processedSize)); + if (kLeadSize != processedSize) + return S_FALSE; + memmove(lead.Magic, cur, 4); + cur += 4; + lead.Major = *cur++; + lead.Minor = *cur++; + lead.Type = GetUInt16(cur); + cur += 2; + lead.ArchNum = GetUInt16(cur); + cur += 2; + memmove(lead.Name, cur, sizeof(lead.Name)); + cur += sizeof(lead.Name); + lead.OSNum = GetUInt16(cur); + cur += 2; + lead.SignatureType = GetUInt16(cur); + cur += 2; + + if (!lead.MagicCheck() || lead.Major < 3) + return S_FALSE; + + CSigHeaderSig sigHeader, header; + if(lead.SignatureType == RPMSIG_NONE) + { + ; + } + else if(lead.SignatureType == RPMSIG_PGP262_1024) + { + UInt64 pos; + RINOK(inStream->Seek(256, STREAM_SEEK_CUR, &pos)); + } + else if(lead.SignatureType == RPMSIG_HEADERSIG) + { + RINOK(RedSigHeaderSig(inStream, sigHeader)); + if(!sigHeader.MagicCheck()) + return S_FALSE; + UInt32 len = sigHeader.GetLostHeaderLen(); + RINOK(inStream->Seek(len, STREAM_SEEK_CUR, &pos)); + if((pos % 8) != 0) + { + RINOK(inStream->Seek((pos / 8 + 1) * 8 - pos, + STREAM_SEEK_CUR, &pos)); + } + } + else + return S_FALSE; + + RINOK(RedSigHeaderSig(inStream, header)); + if(!header.MagicCheck()) + return S_FALSE; + int headerLen = header.GetLostHeaderLen(); + if(headerLen == -1) + return S_FALSE; + RINOK(inStream->Seek(headerLen, STREAM_SEEK_CUR, &pos)); + return S_OK; +} + +}} diff --git a/CPP/7zip/Archive/RPM/RpmIn.h b/CPP/7zip/Archive/RPM/RpmIn.h new file mode 100755 index 00000000..ec798cb8 --- /dev/null +++ b/CPP/7zip/Archive/RPM/RpmIn.h @@ -0,0 +1,15 @@ +// Archive/RpmIn.h + +#ifndef __ARCHIVE_RPM_IN_H +#define __ARCHIVE_RPM_IN_H + +#include "../../IStream.h" + +namespace NArchive { +namespace NRpm { + +HRESULT OpenArchive(IInStream *inStream); + +}} + +#endif diff --git a/CPP/7zip/Archive/RPM/StdAfx.cpp b/CPP/7zip/Archive/RPM/StdAfx.cpp new file mode 100755 index 00000000..d0feea85 --- /dev/null +++ b/CPP/7zip/Archive/RPM/StdAfx.cpp @@ -0,0 +1,3 @@ +// StdAfx.cpp + +#include "StdAfx.h" diff --git a/CPP/7zip/Archive/RPM/StdAfx.h b/CPP/7zip/Archive/RPM/StdAfx.h new file mode 100755 index 00000000..e7fb6986 --- /dev/null +++ b/CPP/7zip/Archive/RPM/StdAfx.h @@ -0,0 +1,8 @@ +// StdAfx.h + +#ifndef __STDAFX_H +#define __STDAFX_H + +#include "../../../Common/MyWindows.h" + +#endif diff --git a/CPP/7zip/Archive/RPM/makefile b/CPP/7zip/Archive/RPM/makefile new file mode 100755 index 00000000..afda1289 --- /dev/null +++ b/CPP/7zip/Archive/RPM/makefile @@ -0,0 +1,42 @@ +PROG = rpm.dll +DEF_FILE = ../Archive.def +CFLAGS = $(CFLAGS) -I ../../../ +LIBS = $(LIBS) oleaut32.lib + +RPM_OBJS = \ + $O\DllExports.obj \ + $O\RpmHandler.obj \ + $O\RpmIn.obj \ + +COMMON_OBJS = \ + $O\Alloc.obj \ + $O\NewHandler.obj \ + +WIN_OBJS = \ + $O\PropVariant.obj \ + +7ZIP_COMMON_OBJS = \ + $O\ProgressUtils.obj \ + $O\StreamUtils.obj \ + +OBJS = \ + $O\StdAfx.obj \ + $(RPM_OBJS) \ + $(COMMON_OBJS) \ + $(WIN_OBJS) \ + $(7ZIP_COMMON_OBJS) \ + $O\CopyCoder.obj \ + $O\resource.res + +!include "../../../Build.mak" + +$(RPM_OBJS): $(*B).cpp + $(COMPL) +$(COMMON_OBJS): ../../../Common/$(*B).cpp + $(COMPL) +$(WIN_OBJS): ../../../Windows/$(*B).cpp + $(COMPL) +$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp + $(COMPL) +$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp + $(COMPL) diff --git a/CPP/7zip/Archive/RPM/resource.rc b/CPP/7zip/Archive/RPM/resource.rc new file mode 100755 index 00000000..926f09aa --- /dev/null +++ b/CPP/7zip/Archive/RPM/resource.rc @@ -0,0 +1,5 @@ +#include "../../MyVersionInfo.rc" + +MY_VERSION_INFO_DLL("Rpm Plugin", "rpm") + +101 ICON "rpm.ico" diff --git a/CPP/7zip/Archive/RPM/rpm.ico b/CPP/7zip/Archive/RPM/rpm.ico Binary files differnew file mode 100755 index 00000000..cdeb8d1b --- /dev/null +++ b/CPP/7zip/Archive/RPM/rpm.ico |