Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-01-20 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:49 +0300
commitd9666cf046a8453b33b3e2fbf4d82295a9f87df3 (patch)
treec722ed19b844b53042aec0c1d7d2f8381140a5ed /CPP/7zip/Archive/RPM/RpmIn.cpp
parent804edc5756fede54dbb1aefda6d39d306111938d (diff)
4.44 beta
Diffstat (limited to 'CPP/7zip/Archive/RPM/RpmIn.cpp')
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmIn.cpp112
1 files changed, 112 insertions, 0 deletions
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;
+}
+
+}}