diff src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHeader.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/win32/7zip/7z/CPP/7zip/Archive/Rar/RarHeader.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,224 @@
     1.4 +// Archive/RarHeader.h
     1.5 +
     1.6 +#ifndef __ARCHIVE_RAR_HEADER_H
     1.7 +#define __ARCHIVE_RAR_HEADER_H
     1.8 +
     1.9 +#include "Common/Types.h"
    1.10 +
    1.11 +namespace NArchive{
    1.12 +namespace NRar{
    1.13 +namespace NHeader{
    1.14 +
    1.15 +const int kMarkerSize = 7;
    1.16 +extern Byte kMarker[kMarkerSize];
    1.17 +  
    1.18 +const int kArchiveSolid = 0x1;
    1.19 +
    1.20 +namespace NBlockType
    1.21 +{
    1.22 +  enum EBlockType
    1.23 +  {
    1.24 +    kMarker        = 0x72,
    1.25 +    kArchiveHeader = 0x73,
    1.26 +    kFileHeader    = 0x74,
    1.27 +    kCommentHeader = 0x75,
    1.28 +    kOldAuthenticity = 0x76,
    1.29 +    kSubBlock       = 0x77,
    1.30 +    kRecoveryRecord = 0x78,
    1.31 +    kAuthenticity   = 0x79,
    1.32 +
    1.33 +    kEndOfArchive   = 0x7B // Is not safe
    1.34 +  };
    1.35 +}
    1.36 +
    1.37 +namespace NArchive
    1.38 +{
    1.39 +  const UInt16 kVolume  = 1;
    1.40 +  const UInt16 kComment = 2;
    1.41 +  const UInt16 kLock    = 4;
    1.42 +  const UInt16 kSolid   = 8;
    1.43 +  const UInt16 kNewVolName = 0x10; // ('volname.partN.rar')
    1.44 +  const UInt16 kAuthenticity  = 0x20;
    1.45 +  const UInt16 kRecovery = 0x40;
    1.46 +  const UInt16 kBlockEncryption  = 0x80;
    1.47 +  const UInt16 kFirstVolume = 0x100; // (set only by RAR 3.0 and later)
    1.48 +  const UInt16 kEncryptVer = 0x200; // RAR 3.6 there is EncryptVer Byte in End of MainHeader
    1.49 +  
    1.50 +  const int kHeaderSizeMin = 7;
    1.51 +
    1.52 +  struct CBlock
    1.53 +  {
    1.54 +    UInt16 CRC;
    1.55 +    Byte Type;
    1.56 +    UInt16 Flags;
    1.57 +    UInt16 Size;
    1.58 +    UInt16 Reserved1;
    1.59 +    UInt32 Reserved2;
    1.60 +    // UInt16 GetRealCRC() const;
    1.61 +  };
    1.62 +  
    1.63 +  const int kArchiveHeaderSize = 13;
    1.64 +
    1.65 +  const int kBlockHeadersAreEncrypted = 0x80;
    1.66 +
    1.67 +  struct CHeader360: public CBlock
    1.68 +  {
    1.69 +    Byte EncryptVersion;
    1.70 +    bool IsEncrypted() const { return (Flags & NHeader::NArchive::kBlockEncryption) != 0; }
    1.71 +    bool IsThereEncryptVer() const { return (Flags & NHeader::NArchive::kEncryptVer) != 0; }
    1.72 +    bool IsEncryptOld() const { return (!IsThereEncryptVer() || EncryptVersion < 36); }
    1.73 +    UInt32 GetBaseSize() const { return kArchiveHeaderSize + (IsEncryptOld() ? 0 : 1); }
    1.74 +  };
    1.75 +}
    1.76 +
    1.77 +namespace NFile
    1.78 +{
    1.79 +  const int kSplitBefore = 1 << 0;
    1.80 +  const int kSplitAfter  = 1 << 1;
    1.81 +  const int kEncrypted   = 1 << 2;
    1.82 +  const int kComment     = 1 << 3;
    1.83 +  const int kSolid       = 1 << 4;
    1.84 +  
    1.85 +  const int kDictBitStart     = 5;
    1.86 +  const int kNumDictBits  = 3;
    1.87 +  const int kDictMask         = (1 << kNumDictBits) - 1;
    1.88 +  const int kDictDirectoryValue  = 0x7;
    1.89 +  
    1.90 +  const int kSize64Bits    = 1 << 8;
    1.91 +  const int kUnicodeName   = 1 << 9;
    1.92 +  const int kSalt          = 1 << 10;
    1.93 +  const int kOldVersion    = 1 << 11;
    1.94 +  const int kExtTime       = 1 << 12;
    1.95 +  // const int kExtFlags      = 1 << 13;
    1.96 +  // const int kSkipIfUnknown = 1 << 14;
    1.97 +
    1.98 +  const int kLongBlock    = 1 << 15;
    1.99 +  
   1.100 +  /*
   1.101 +  struct CBlock
   1.102 +  {
   1.103 +    // UInt16 HeadCRC;
   1.104 +    // Byte Type;
   1.105 +    // UInt16 Flags;
   1.106 +    // UInt16 HeadSize;
   1.107 +    UInt32 PackSize;
   1.108 +    UInt32 UnPackSize;
   1.109 +    Byte HostOS;
   1.110 +    UInt32 FileCRC;
   1.111 +    UInt32 Time;
   1.112 +    Byte UnPackVersion;
   1.113 +    Byte Method;
   1.114 +    UInt16 NameSize;
   1.115 +    UInt32 Attributes;
   1.116 +  };
   1.117 +  */
   1.118 +
   1.119 +  /*
   1.120 +  struct CBlock32
   1.121 +  {
   1.122 +    UInt16 HeadCRC;
   1.123 +    Byte Type;
   1.124 +    UInt16 Flags;
   1.125 +    UInt16 HeadSize;
   1.126 +    UInt32 PackSize;
   1.127 +    UInt32 UnPackSize;
   1.128 +    Byte HostOS;
   1.129 +    UInt32 FileCRC;
   1.130 +    UInt32 Time;
   1.131 +    Byte UnPackVersion;
   1.132 +    Byte Method;
   1.133 +    UInt16 NameSize;
   1.134 +    UInt32 Attributes;
   1.135 +    UInt16 GetRealCRC(const void *aName, UInt32 aNameSize,
   1.136 +        bool anExtraDataDefined = false, Byte *anExtraData = 0) const;
   1.137 +  };
   1.138 +  struct CBlock64
   1.139 +  {
   1.140 +    UInt16 HeadCRC;
   1.141 +    Byte Type;
   1.142 +    UInt16 Flags;
   1.143 +    UInt16 HeadSize;
   1.144 +    UInt32 PackSizeLow;
   1.145 +    UInt32 UnPackSizeLow;
   1.146 +    Byte HostOS;
   1.147 +    UInt32 FileCRC;
   1.148 +    UInt32 Time;
   1.149 +    Byte UnPackVersion;
   1.150 +    Byte Method;
   1.151 +    UInt16 NameSize;
   1.152 +    UInt32 Attributes;
   1.153 +    UInt32 PackSizeHigh;
   1.154 +    UInt32 UnPackSizeHigh;
   1.155 +    UInt16 GetRealCRC(const void *aName, UInt32 aNameSize) const;
   1.156 +  };
   1.157 +  */
   1.158 +  
   1.159 +  const int kLabelFileAttribute            = 0x08;
   1.160 +  const int kWinFileDirectoryAttributeMask = 0x10;
   1.161 +  
   1.162 +  enum CHostOS
   1.163 +  {
   1.164 +    kHostMSDOS = 0,
   1.165 +      kHostOS2   = 1,
   1.166 +      kHostWin32 = 2,
   1.167 +      kHostUnix  = 3,
   1.168 +      kHostMacOS = 4,
   1.169 +      kHostBeOS = 5
   1.170 +  };
   1.171 +}
   1.172 +
   1.173 +namespace NBlock
   1.174 +{
   1.175 +  const UInt16 kLongBlock = 1 << 15;
   1.176 +  struct CBlock
   1.177 +  {
   1.178 +    UInt16 CRC;
   1.179 +    Byte Type;
   1.180 +    UInt16 Flags;
   1.181 +    UInt16 HeadSize;
   1.182 +    //  UInt32 DataSize;
   1.183 +  };
   1.184 +}
   1.185 +
   1.186 +/*
   1.187 +struct CSubBlock
   1.188 +{
   1.189 +  UInt16 HeadCRC;
   1.190 +  Byte HeadType;
   1.191 +  UInt16 Flags;
   1.192 +  UInt16 HeadSize;
   1.193 +  UInt32 DataSize;
   1.194 +  UInt16 SubType;
   1.195 +  Byte Level; // Reserved : Must be 0
   1.196 +};
   1.197 +
   1.198 +struct CCommentBlock
   1.199 +{
   1.200 +  UInt16 HeadCRC;
   1.201 +  Byte HeadType;
   1.202 +  UInt16 Flags;
   1.203 +  UInt16 HeadSize;
   1.204 +  UInt16 UnpSize;
   1.205 +  Byte UnpVer;
   1.206 +  Byte Method;
   1.207 +  UInt16 CommCRC;
   1.208 +};
   1.209 +
   1.210 +
   1.211 +struct CProtectHeader
   1.212 +{
   1.213 +  UInt16 HeadCRC;
   1.214 +  Byte HeadType;
   1.215 +  UInt16 Flags;
   1.216 +  UInt16 HeadSize;
   1.217 +  UInt32 DataSize;
   1.218 +  Byte Version;
   1.219 +  UInt16 RecSectors;
   1.220 +  UInt32 TotalBlocks;
   1.221 +  Byte Mark[8];
   1.222 +};
   1.223 +*/
   1.224 +
   1.225 +}}}
   1.226 +
   1.227 +#endif