Fix more CRLF EOL

This commit is contained in:
Con Kolivas 2010-04-25 16:20:51 +10:00
parent b31b370b01
commit e3916090a4
6 changed files with 2913 additions and 2913 deletions

View file

@ -1,194 +1,194 @@
7z ANSI-C Decoder 4.62 7z ANSI-C Decoder 4.62
---------------------- ----------------------
7z ANSI-C provides 7z/LZMA decoding. 7z ANSI-C provides 7z/LZMA decoding.
7z ANSI-C version is simplified version ported from C++ code. 7z ANSI-C version is simplified version ported from C++ code.
LZMA is default and general compression method of 7z format LZMA is default and general compression method of 7z format
in 7-Zip compression program (www.7-zip.org). LZMA provides high in 7-Zip compression program (www.7-zip.org). LZMA provides high
compression ratio and very fast decompression. compression ratio and very fast decompression.
LICENSE LICENSE
------- -------
7z ANSI-C Decoder is part of the LZMA SDK. 7z ANSI-C Decoder is part of the LZMA SDK.
LZMA SDK is written and placed in the public domain by Igor Pavlov. LZMA SDK is written and placed in the public domain by Igor Pavlov.
Files Files
--------------------- ---------------------
7zDecode.* - Low level 7z decoding 7zDecode.* - Low level 7z decoding
7zExtract.* - High level 7z decoding 7zExtract.* - High level 7z decoding
7zHeader.* - .7z format constants 7zHeader.* - .7z format constants
7zIn.* - .7z archive opening 7zIn.* - .7z archive opening
7zItem.* - .7z structures 7zItem.* - .7z structures
7zMain.c - Test application 7zMain.c - Test application
How To Use How To Use
---------- ----------
You must download 7-Zip program from www.7-zip.org. You must download 7-Zip program from www.7-zip.org.
You can create .7z archive with 7z.exe or 7za.exe: You can create .7z archive with 7z.exe or 7za.exe:
7za.exe a archive.7z *.htm -r -mx -m0fb=255 7za.exe a archive.7z *.htm -r -mx -m0fb=255
If you have big number of files in archive, and you need fast extracting, If you have big number of files in archive, and you need fast extracting,
you can use partly-solid archives: you can use partly-solid archives:
7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K 7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K
In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only
512KB for extracting one file from such archive. 512KB for extracting one file from such archive.
Limitations of current version of 7z ANSI-C Decoder Limitations of current version of 7z ANSI-C Decoder
--------------------------------------------------- ---------------------------------------------------
- It reads only "FileName", "Size", "LastWriteTime" and "CRC" information for each file in archive. - It reads only "FileName", "Size", "LastWriteTime" and "CRC" information for each file in archive.
- It supports only LZMA and Copy (no compression) methods with BCJ or BCJ2 filters. - It supports only LZMA and Copy (no compression) methods with BCJ or BCJ2 filters.
- It converts original UTF-16 Unicode file names to UTF-8 Unicode file names. - It converts original UTF-16 Unicode file names to UTF-8 Unicode file names.
These limitations will be fixed in future versions. These limitations will be fixed in future versions.
Using 7z ANSI-C Decoder Test application: Using 7z ANSI-C Decoder Test application:
----------------------------------------- -----------------------------------------
Usage: 7zDec <command> <archive_name> Usage: 7zDec <command> <archive_name>
<Command>: <Command>:
e: Extract files from archive e: Extract files from archive
l: List contents of archive l: List contents of archive
t: Test integrity of archive t: Test integrity of archive
Example: Example:
7zDec l archive.7z 7zDec l archive.7z
lists contents of archive.7z lists contents of archive.7z
7zDec e archive.7z 7zDec e archive.7z
extracts files from archive.7z to current folder. extracts files from archive.7z to current folder.
How to use .7z Decoder How to use .7z Decoder
---------------------- ----------------------
Memory allocation Memory allocation
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
7z Decoder uses two memory pools: 7z Decoder uses two memory pools:
1) Temporary pool 1) Temporary pool
2) Main pool 2) Main pool
Such scheme can allow you to avoid fragmentation of allocated blocks. Such scheme can allow you to avoid fragmentation of allocated blocks.
Steps for using 7z decoder Steps for using 7z decoder
-------------------------- --------------------------
Use code at 7zMain.c as example. Use code at 7zMain.c as example.
1) Declare variables: 1) Declare variables:
inStream /* implements ILookInStream interface */ inStream /* implements ILookInStream interface */
CSzArEx db; /* 7z archive database structure */ CSzArEx db; /* 7z archive database structure */
ISzAlloc allocImp; /* memory functions for main pool */ ISzAlloc allocImp; /* memory functions for main pool */
ISzAlloc allocTempImp; /* memory functions for temporary pool */ ISzAlloc allocTempImp; /* memory functions for temporary pool */
2) call CrcGenerateTable(); function to initialize CRC structures. 2) call CrcGenerateTable(); function to initialize CRC structures.
3) call SzArEx_Init(&db); function to initialize db structures. 3) call SzArEx_Init(&db); function to initialize db structures.
4) call SzArEx_Open(&db, inStream, &allocMain, &allocTemp) to open archive 4) call SzArEx_Open(&db, inStream, &allocMain, &allocTemp) to open archive
This function opens archive "inStream" and reads headers to "db". This function opens archive "inStream" and reads headers to "db".
All items in "db" will be allocated with "allocMain" functions. All items in "db" will be allocated with "allocMain" functions.
SzArEx_Open function allocates and frees temporary structures by "allocTemp" functions. SzArEx_Open function allocates and frees temporary structures by "allocTemp" functions.
5) List items or Extract items 5) List items or Extract items
Listing code: Listing code:
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
{ {
UInt32 i; UInt32 i;
for (i = 0; i < db.db.NumFiles; i++) for (i = 0; i < db.db.NumFiles; i++)
{ {
CFileItem *f = db.db.Files + i; CFileItem *f = db.db.Files + i;
printf("%10d %s\n", (int)f->Size, f->Name); printf("%10d %s\n", (int)f->Size, f->Name);
} }
} }
Extracting code: Extracting code:
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
SZ_RESULT SzAr_Extract( SZ_RESULT SzAr_Extract(
CArchiveDatabaseEx *db, CArchiveDatabaseEx *db,
ILookInStream *inStream, ILookInStream *inStream,
UInt32 fileIndex, /* index of file */ UInt32 fileIndex, /* index of file */
UInt32 *blockIndex, /* index of solid block */ UInt32 *blockIndex, /* index of solid block */
Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
size_t *outBufferSize, /* buffer size for output buffer */ size_t *outBufferSize, /* buffer size for output buffer */
size_t *offset, /* offset of stream for required file in *outBuffer */ size_t *offset, /* offset of stream for required file in *outBuffer */
size_t *outSizeProcessed, /* size of file in *outBuffer */ size_t *outSizeProcessed, /* size of file in *outBuffer */
ISzAlloc *allocMain, ISzAlloc *allocMain,
ISzAlloc *allocTemp); ISzAlloc *allocTemp);
If you need to decompress more than one file, you can send these values from previous call: If you need to decompress more than one file, you can send these values from previous call:
blockIndex, blockIndex,
outBuffer, outBuffer,
outBufferSize, outBufferSize,
You can consider "outBuffer" as cache of solid block. If your archive is solid, You can consider "outBuffer" as cache of solid block. If your archive is solid,
it will increase decompression speed. it will increase decompression speed.
After decompressing you must free "outBuffer": After decompressing you must free "outBuffer":
allocImp.Free(outBuffer); allocImp.Free(outBuffer);
6) call SzArEx_Free(&db, allocImp.Free) to free allocated items in "db". 6) call SzArEx_Free(&db, allocImp.Free) to free allocated items in "db".
Memory requirements for .7z decoding Memory requirements for .7z decoding
------------------------------------ ------------------------------------
Memory usage for Archive opening: Memory usage for Archive opening:
- Temporary pool: - Temporary pool:
- Memory for uncompressed .7z headers - Memory for uncompressed .7z headers
- some other temporary blocks - some other temporary blocks
- Main pool: - Main pool:
- Memory for database: - Memory for database:
Estimated size of one file structures in solid archive: Estimated size of one file structures in solid archive:
- Size (4 or 8 Bytes) - Size (4 or 8 Bytes)
- CRC32 (4 bytes) - CRC32 (4 bytes)
- LastWriteTime (8 bytes) - LastWriteTime (8 bytes)
- Some file information (4 bytes) - Some file information (4 bytes)
- File Name (variable length) + pointer + allocation structures - File Name (variable length) + pointer + allocation structures
Memory usage for archive Decompressing: Memory usage for archive Decompressing:
- Temporary pool: - Temporary pool:
- Memory for LZMA decompressing structures - Memory for LZMA decompressing structures
- Main pool: - Main pool:
- Memory for decompressed solid block - Memory for decompressed solid block
- Memory for temprorary buffers, if BCJ2 fileter is used. Usually these - Memory for temprorary buffers, if BCJ2 fileter is used. Usually these
temprorary buffers can be about 15% of solid block size. temprorary buffers can be about 15% of solid block size.
7z Decoder doesn't allocate memory for compressed blocks. 7z Decoder doesn't allocate memory for compressed blocks.
Instead of this, you must allocate buffer with desired Instead of this, you must allocate buffer with desired
size before calling 7z Decoder. Use 7zMain.c as example. size before calling 7z Decoder. Use 7zMain.c as example.
Defines Defines
------- -------
_SZ_ALLOC_DEBUG - define it if you want to debug alloc/free operations to stderr. _SZ_ALLOC_DEBUG - define it if you want to debug alloc/free operations to stderr.
--- ---
http://www.7-zip.org http://www.7-zip.org
http://www.7-zip.org/sdk.html http://www.7-zip.org/sdk.html
http://www.7-zip.org/support.html http://www.7-zip.org/support.html

View file

@ -1,471 +1,471 @@
7z Format description (2.30 Beta 25) 7z Format description (2.30 Beta 25)
----------------------------------- -----------------------------------
This file contains description of 7z archive format. This file contains description of 7z archive format.
7z archive can contain files compressed with any method. 7z archive can contain files compressed with any method.
See "Methods.txt" for description for defined compressing methods. See "Methods.txt" for description for defined compressing methods.
Format structure Overview Format structure Overview
------------------------- -------------------------
Some fields can be optional. Some fields can be optional.
Archive structure Archive structure
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
SignatureHeader SignatureHeader
[PackedStreams] [PackedStreams]
[PackedStreamsForHeaders] [PackedStreamsForHeaders]
[ [
Header Header
or or
{ {
Packed Header Packed Header
HeaderInfo HeaderInfo
} }
] ]
Header structure Header structure
~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
{ {
ArchiveProperties ArchiveProperties
AdditionalStreams AdditionalStreams
{ {
PackInfo PackInfo
{ {
PackPos PackPos
NumPackStreams NumPackStreams
Sizes[NumPackStreams] Sizes[NumPackStreams]
CRCs[NumPackStreams] CRCs[NumPackStreams]
} }
CodersInfo CodersInfo
{ {
NumFolders NumFolders
Folders[NumFolders] Folders[NumFolders]
{ {
NumCoders NumCoders
CodersInfo[NumCoders] CodersInfo[NumCoders]
{ {
ID ID
NumInStreams; NumInStreams;
NumOutStreams; NumOutStreams;
PropertiesSize PropertiesSize
Properties[PropertiesSize] Properties[PropertiesSize]
} }
NumBindPairs NumBindPairs
BindPairsInfo[NumBindPairs] BindPairsInfo[NumBindPairs]
{ {
InIndex; InIndex;
OutIndex; OutIndex;
} }
PackedIndices PackedIndices
} }
UnPackSize[Folders][Folders.NumOutstreams] UnPackSize[Folders][Folders.NumOutstreams]
CRCs[NumFolders] CRCs[NumFolders]
} }
SubStreamsInfo SubStreamsInfo
{ {
NumUnPackStreamsInFolders[NumFolders]; NumUnPackStreamsInFolders[NumFolders];
UnPackSizes[] UnPackSizes[]
CRCs[] CRCs[]
} }
} }
MainStreamsInfo MainStreamsInfo
{ {
(Same as in AdditionalStreams) (Same as in AdditionalStreams)
} }
FilesInfo FilesInfo
{ {
NumFiles NumFiles
Properties[] Properties[]
{ {
ID ID
Size Size
Data Data
} }
} }
} }
HeaderInfo structure HeaderInfo structure
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
{ {
(Same as in AdditionalStreams) (Same as in AdditionalStreams)
} }
Notes about Notation and encoding Notes about Notation and encoding
--------------------------------- ---------------------------------
7z uses little endian encoding. 7z uses little endian encoding.
7z archive format has optional headers that are marked as 7z archive format has optional headers that are marked as
[] []
Header Header
[] []
REAL_UINT64 means real UINT64. REAL_UINT64 means real UINT64.
UINT64 means real UINT64 encoded with the following scheme: UINT64 means real UINT64 encoded with the following scheme:
Size of encoding sequence depends from first byte: Size of encoding sequence depends from first byte:
First_Byte Extra_Bytes Value First_Byte Extra_Bytes Value
(binary) (binary)
0xxxxxxx : ( xxxxxxx ) 0xxxxxxx : ( xxxxxxx )
10xxxxxx BYTE y[1] : ( xxxxxx << (8 * 1)) + y 10xxxxxx BYTE y[1] : ( xxxxxx << (8 * 1)) + y
110xxxxx BYTE y[2] : ( xxxxx << (8 * 2)) + y 110xxxxx BYTE y[2] : ( xxxxx << (8 * 2)) + y
... ...
1111110x BYTE y[6] : ( x << (8 * 6)) + y 1111110x BYTE y[6] : ( x << (8 * 6)) + y
11111110 BYTE y[7] : y 11111110 BYTE y[7] : y
11111111 BYTE y[8] : y 11111111 BYTE y[8] : y
Property IDs Property IDs
------------ ------------
0x00 = kEnd, 0x00 = kEnd,
0x01 = kHeader, 0x01 = kHeader,
0x02 = kArchiveProperties, 0x02 = kArchiveProperties,
0x03 = kAdditionalStreamsInfo, 0x03 = kAdditionalStreamsInfo,
0x04 = kMainStreamsInfo, 0x04 = kMainStreamsInfo,
0x05 = kFilesInfo, 0x05 = kFilesInfo,
0x06 = kPackInfo, 0x06 = kPackInfo,
0x07 = kUnPackInfo, 0x07 = kUnPackInfo,
0x08 = kSubStreamsInfo, 0x08 = kSubStreamsInfo,
0x09 = kSize, 0x09 = kSize,
0x0A = kCRC, 0x0A = kCRC,
0x0B = kFolder, 0x0B = kFolder,
0x0C = kCodersUnPackSize, 0x0C = kCodersUnPackSize,
0x0D = kNumUnPackStream, 0x0D = kNumUnPackStream,
0x0E = kEmptyStream, 0x0E = kEmptyStream,
0x0F = kEmptyFile, 0x0F = kEmptyFile,
0x10 = kAnti, 0x10 = kAnti,
0x11 = kName, 0x11 = kName,
0x12 = kCreationTime, 0x12 = kCreationTime,
0x13 = kLastAccessTime, 0x13 = kLastAccessTime,
0x14 = kLastWriteTime, 0x14 = kLastWriteTime,
0x15 = kWinAttributes, 0x15 = kWinAttributes,
0x16 = kComment, 0x16 = kComment,
0x17 = kEncodedHeader, 0x17 = kEncodedHeader,
7z format headers 7z format headers
----------------- -----------------
SignatureHeader SignatureHeader
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
BYTE kSignature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; BYTE kSignature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
ArchiveVersion ArchiveVersion
{ {
BYTE Major; // now = 0 BYTE Major; // now = 0
BYTE Minor; // now = 2 BYTE Minor; // now = 2
}; };
UINT32 StartHeaderCRC; UINT32 StartHeaderCRC;
StartHeader StartHeader
{ {
REAL_UINT64 NextHeaderOffset REAL_UINT64 NextHeaderOffset
REAL_UINT64 NextHeaderSize REAL_UINT64 NextHeaderSize
UINT32 NextHeaderCRC UINT32 NextHeaderCRC
} }
........................... ...........................
ArchiveProperties ArchiveProperties
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
BYTE NID::kArchiveProperties (0x02) BYTE NID::kArchiveProperties (0x02)
for (;;) for (;;)
{ {
BYTE PropertyType; BYTE PropertyType;
if (aType == 0) if (aType == 0)
break; break;
UINT64 PropertySize; UINT64 PropertySize;
BYTE PropertyData[PropertySize]; BYTE PropertyData[PropertySize];
} }
Digests (NumStreams) Digests (NumStreams)
~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
BYTE AllAreDefined BYTE AllAreDefined
if (AllAreDefined == 0) if (AllAreDefined == 0)
{ {
for(NumStreams) for(NumStreams)
BIT Defined BIT Defined
} }
UINT32 CRCs[NumDefined] UINT32 CRCs[NumDefined]
PackInfo PackInfo
~~~~~~~~~~~~ ~~~~~~~~~~~~
BYTE NID::kPackInfo (0x06) BYTE NID::kPackInfo (0x06)
UINT64 PackPos UINT64 PackPos
UINT64 NumPackStreams UINT64 NumPackStreams
[] []
BYTE NID::kSize (0x09) BYTE NID::kSize (0x09)
UINT64 PackSizes[NumPackStreams] UINT64 PackSizes[NumPackStreams]
[] []
[] []
BYTE NID::kCRC (0x0A) BYTE NID::kCRC (0x0A)
PackStreamDigests[NumPackStreams] PackStreamDigests[NumPackStreams]
[] []
BYTE NID::kEnd BYTE NID::kEnd
Folder Folder
~~~~~~ ~~~~~~
UINT64 NumCoders; UINT64 NumCoders;
for (NumCoders) for (NumCoders)
{ {
BYTE BYTE
{ {
0:3 DecompressionMethod.IDSize 0:3 DecompressionMethod.IDSize
4: 4:
0 - IsSimple 0 - IsSimple
1 - Is not simple 1 - Is not simple
5: 5:
0 - No Attributes 0 - No Attributes
1 - There Are Attributes 1 - There Are Attributes
7: 7:
0 - Last Method in Alternative_Method_List 0 - Last Method in Alternative_Method_List
1 - There are more alternative methods 1 - There are more alternative methods
} }
BYTE DecompressionMethod.ID[DecompressionMethod.IDSize] BYTE DecompressionMethod.ID[DecompressionMethod.IDSize]
if (!IsSimple) if (!IsSimple)
{ {
UINT64 NumInStreams; UINT64 NumInStreams;
UINT64 NumOutStreams; UINT64 NumOutStreams;
} }
if (DecompressionMethod[0] != 0) if (DecompressionMethod[0] != 0)
{ {
UINT64 PropertiesSize UINT64 PropertiesSize
BYTE Properties[PropertiesSize] BYTE Properties[PropertiesSize]
} }
} }
NumBindPairs = NumOutStreamsTotal - 1; NumBindPairs = NumOutStreamsTotal - 1;
for (NumBindPairs) for (NumBindPairs)
{ {
UINT64 InIndex; UINT64 InIndex;
UINT64 OutIndex; UINT64 OutIndex;
} }
NumPackedStreams = NumInStreamsTotal - NumBindPairs; NumPackedStreams = NumInStreamsTotal - NumBindPairs;
if (NumPackedStreams > 1) if (NumPackedStreams > 1)
for(NumPackedStreams) for(NumPackedStreams)
{ {
UINT64 Index; UINT64 Index;
}; };
Coders Info Coders Info
~~~~~~~~~~~ ~~~~~~~~~~~
BYTE NID::kUnPackInfo (0x07) BYTE NID::kUnPackInfo (0x07)
BYTE NID::kFolder (0x0B) BYTE NID::kFolder (0x0B)
UINT64 NumFolders UINT64 NumFolders
BYTE External BYTE External
switch(External) switch(External)
{ {
case 0: case 0:
Folders[NumFolders] Folders[NumFolders]
case 1: case 1:
UINT64 DataStreamIndex UINT64 DataStreamIndex
} }
BYTE ID::kCodersUnPackSize (0x0C) BYTE ID::kCodersUnPackSize (0x0C)
for(Folders) for(Folders)
for(Folder.NumOutStreams) for(Folder.NumOutStreams)
UINT64 UnPackSize; UINT64 UnPackSize;
[] []
BYTE NID::kCRC (0x0A) BYTE NID::kCRC (0x0A)
UnPackDigests[NumFolders] UnPackDigests[NumFolders]
[] []
BYTE NID::kEnd BYTE NID::kEnd
SubStreams Info SubStreams Info
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
BYTE NID::kSubStreamsInfo; (0x08) BYTE NID::kSubStreamsInfo; (0x08)
[] []
BYTE NID::kNumUnPackStream; (0x0D) BYTE NID::kNumUnPackStream; (0x0D)
UINT64 NumUnPackStreamsInFolders[NumFolders]; UINT64 NumUnPackStreamsInFolders[NumFolders];
[] []
[] []
BYTE NID::kSize (0x09) BYTE NID::kSize (0x09)
UINT64 UnPackSizes[] UINT64 UnPackSizes[]
[] []
[] []
BYTE NID::kCRC (0x0A) BYTE NID::kCRC (0x0A)
Digests[Number of streams with unknown CRC] Digests[Number of streams with unknown CRC]
[] []
BYTE NID::kEnd BYTE NID::kEnd
Streams Info Streams Info
~~~~~~~~~~~~ ~~~~~~~~~~~~
[] []
PackInfo PackInfo
[] []
[] []
CodersInfo CodersInfo
[] []
[] []
SubStreamsInfo SubStreamsInfo
[] []
BYTE NID::kEnd BYTE NID::kEnd
FilesInfo FilesInfo
~~~~~~~~~ ~~~~~~~~~
BYTE NID::kFilesInfo; (0x05) BYTE NID::kFilesInfo; (0x05)
UINT64 NumFiles UINT64 NumFiles
for (;;) for (;;)
{ {
BYTE PropertyType; BYTE PropertyType;
if (aType == 0) if (aType == 0)
break; break;
UINT64 Size; UINT64 Size;
switch(PropertyType) switch(PropertyType)
{ {
kEmptyStream: (0x0E) kEmptyStream: (0x0E)
for(NumFiles) for(NumFiles)
BIT IsEmptyStream BIT IsEmptyStream
kEmptyFile: (0x0F) kEmptyFile: (0x0F)
for(EmptyStreams) for(EmptyStreams)
BIT IsEmptyFile BIT IsEmptyFile
kAnti: (0x10) kAnti: (0x10)
for(EmptyStreams) for(EmptyStreams)
BIT IsAntiFile BIT IsAntiFile
case kCreationTime: (0x12) case kCreationTime: (0x12)
case kLastAccessTime: (0x13) case kLastAccessTime: (0x13)
case kLastWriteTime: (0x14) case kLastWriteTime: (0x14)
BYTE AllAreDefined BYTE AllAreDefined
if (AllAreDefined == 0) if (AllAreDefined == 0)
{ {
for(NumFiles) for(NumFiles)
BIT TimeDefined BIT TimeDefined
} }
BYTE External; BYTE External;
if(External != 0) if(External != 0)
UINT64 DataIndex UINT64 DataIndex
[] []
for(Definded Items) for(Definded Items)
UINT32 Time UINT32 Time
[] []
kNames: (0x11) kNames: (0x11)
BYTE External; BYTE External;
if(External != 0) if(External != 0)
UINT64 DataIndex UINT64 DataIndex
[] []
for(Files) for(Files)
{ {
wchar_t Names[NameSize]; wchar_t Names[NameSize];
wchar_t 0; wchar_t 0;
} }
[] []
kAttributes: (0x15) kAttributes: (0x15)
BYTE AllAreDefined BYTE AllAreDefined
if (AllAreDefined == 0) if (AllAreDefined == 0)
{ {
for(NumFiles) for(NumFiles)
BIT AttributesAreDefined BIT AttributesAreDefined
} }
BYTE External; BYTE External;
if(External != 0) if(External != 0)
UINT64 DataIndex UINT64 DataIndex
[] []
for(Definded Attributes) for(Definded Attributes)
UINT32 Attributes UINT32 Attributes
[] []
} }
} }
Header Header
~~~~~~ ~~~~~~
BYTE NID::kHeader (0x01) BYTE NID::kHeader (0x01)
[] []
ArchiveProperties ArchiveProperties
[] []
[] []
BYTE NID::kAdditionalStreamsInfo; (0x03) BYTE NID::kAdditionalStreamsInfo; (0x03)
StreamsInfo StreamsInfo
[] []
[] []
BYTE NID::kMainStreamsInfo; (0x04) BYTE NID::kMainStreamsInfo; (0x04)
StreamsInfo StreamsInfo
[] []
[] []
FilesInfo FilesInfo
[] []
BYTE NID::kEnd BYTE NID::kEnd
HeaderInfo HeaderInfo
~~~~~~~~~~ ~~~~~~~~~~
[] []
BYTE NID::kEncodedHeader; (0x17) BYTE NID::kEncodedHeader; (0x17)
StreamsInfo for Encoded Header StreamsInfo for Encoded Header
[] []
--- ---
End of document End of document

View file

@ -1,105 +1,105 @@
SECTION .text SECTION .text
%macro CRC1b 0 %macro CRC1b 0
movzx EDX, BYTE [RSI] movzx EDX, BYTE [RSI]
inc RSI inc RSI
movzx EBX, AL movzx EBX, AL
xor EDX, EBX xor EDX, EBX
shr EAX, 8 shr EAX, 8
xor EAX, [RDI + RDX * 4] xor EAX, [RDI + RDX * 4]
dec R8 dec R8
%endmacro %endmacro
align 16 align 16
global CrcUpdateT8 global CrcUpdateT8
CrcUpdateT8: CrcUpdateT8:
push RBX push RBX
push RSI push RSI
push RDI push RDI
push RBP push RBP
mov EAX, ECX mov EAX, ECX
mov RSI, RDX mov RSI, RDX
mov RDI, R9 mov RDI, R9
test R8, R8 test R8, R8
jz sl_end jz sl_end
sl: sl:
test RSI, 7 test RSI, 7
jz sl_end jz sl_end
CRC1b CRC1b
jnz sl jnz sl
sl_end: sl_end:
cmp R8, 16 cmp R8, 16
jb crc_end jb crc_end
mov R9, R8 mov R9, R8
and R8, 7 and R8, 7
add R8, 8 add R8, 8
sub R9, R8 sub R9, R8
add R9, RSI add R9, RSI
xor EAX, [RSI] xor EAX, [RSI]
mov EBX, [RSI + 4] mov EBX, [RSI + 4]
movzx ECX, BL movzx ECX, BL
align 16 align 16
main_loop: main_loop:
mov EDX, [RDI + RCX*4 + 0C00h] mov EDX, [RDI + RCX*4 + 0C00h]
movzx EBP, BH movzx EBP, BH
xor EDX, [RDI + RBP*4 + 0800h] xor EDX, [RDI + RBP*4 + 0800h]
shr EBX, 16 shr EBX, 16
movzx ECX, BL movzx ECX, BL
xor EDX, [RSI + 8] xor EDX, [RSI + 8]
xor EDX, [RDI + RCX*4 + 0400h] xor EDX, [RDI + RCX*4 + 0400h]
movzx ECX, AL movzx ECX, AL
movzx EBP, BH movzx EBP, BH
xor EDX, [RDI + RBP*4 + 0000h] xor EDX, [RDI + RBP*4 + 0000h]
mov EBX, [RSI + 12] mov EBX, [RSI + 12]
xor EDX, [RDI + RCX*4 + 01C00h] xor EDX, [RDI + RCX*4 + 01C00h]
movzx EBP, AH movzx EBP, AH
shr EAX, 16 shr EAX, 16
movzx ECX, AL movzx ECX, AL
xor EDX, [RDI + RBP*4 + 01800h] xor EDX, [RDI + RBP*4 + 01800h]
movzx EBP, AH movzx EBP, AH
mov EAX, [RDI + RCX*4 + 01400h] mov EAX, [RDI + RCX*4 + 01400h]
add RSI, 8 add RSI, 8
xor EAX, [RDI + RBP*4 + 01000h] xor EAX, [RDI + RBP*4 + 01000h]
movzx ECX, BL movzx ECX, BL
xor EAX,EDX xor EAX,EDX
cmp RSI, R9 cmp RSI, R9
jne main_loop jne main_loop
xor EAX, [RSI] xor EAX, [RSI]
crc_end: crc_end:
test R8, R8 test R8, R8
jz fl_end jz fl_end
fl: fl:
CRC1b CRC1b
jnz fl jnz fl
fl_end: fl_end:
pop RBP pop RBP
pop RDI pop RDI
pop RSI pop RSI
pop RBX pop RBX
ret ret
%ifidn __OUTPUT_FORMAT__,elf %ifidn __OUTPUT_FORMAT__,elf
section .note.GNU-stack noalloc noexec nowrite progbits section .note.GNU-stack noalloc noexec nowrite progbits
%endif %endif

View file

@ -1,141 +1,141 @@
7-Zip method IDs (4.61) 7-Zip method IDs (4.61)
----------------------- -----------------------
Each compression or crypto method in 7z has unique binary value (ID). Each compression or crypto method in 7z has unique binary value (ID).
The length of ID in bytes is arbitrary but it can not exceed 63 bits (8 bytes). The length of ID in bytes is arbitrary but it can not exceed 63 bits (8 bytes).
If you want to add some new ID, you have two ways: If you want to add some new ID, you have two ways:
1) Write request for allocating IDs to 7-zip developers. 1) Write request for allocating IDs to 7-zip developers.
2) Generate 8-bytes ID: 2) Generate 8-bytes ID:
3F ZZ ZZ ZZ ZZ ZZ MM MM 3F ZZ ZZ ZZ ZZ ZZ MM MM
3F - Prefix for random IDs (1 byte) 3F - Prefix for random IDs (1 byte)
ZZ ZZ ZZ ZZ ZZ - Developer ID (5 bytes). Use real random bytes. ZZ ZZ ZZ ZZ ZZ - Developer ID (5 bytes). Use real random bytes.
MM MM - Method ID (2 bytes) MM MM - Method ID (2 bytes)
You can notify 7-Zip developers about your Developer ID / Method ID. You can notify 7-Zip developers about your Developer ID / Method ID.
Note: Use new ID only if old codec can not decode data encoded with new version. Note: Use new ID only if old codec can not decode data encoded with new version.
List of defined IDs List of defined IDs
------------------- -------------------
00 - Copy 00 - Copy
01 - Reserved 01 - Reserved
02 - Common 02 - Common
03 Swap 03 Swap
- 2 Swap2 - 2 Swap2
- 4 Swap4 - 4 Swap4
04 Delta (subject to change) 04 Delta (subject to change)
03 - 7z 03 - 7z
01 - LZMA 01 - LZMA
01 - Version 01 - Version
03 - Branch 03 - Branch
01 - x86 01 - x86
03 - BCJ 03 - BCJ
1B - BCJ2 1B - BCJ2
02 - PPC 02 - PPC
05 - PPC (Big Endian) 05 - PPC (Big Endian)
03 - Alpha 03 - Alpha
01 - Alpha 01 - Alpha
04 - IA64 04 - IA64
01 - IA64 01 - IA64
05 - ARM 05 - ARM
01 - ARM 01 - ARM
06 - M68 06 - M68
05 - M68 (Big Endian) 05 - M68 (Big Endian)
07 - ARM Thumb 07 - ARM Thumb
01 - ARMT 01 - ARMT
08 - SPARC 08 - SPARC
05 - SPARC 05 - SPARC
04 - PPMD 04 - PPMD
01 - Version 01 - Version
7F - 7F -
01 - experimental methods. 01 - experimental methods.
80 - reserved for independent developers 80 - reserved for independent developers
E0 - Random IDs E0 - Random IDs
04 - Misc 04 - Misc
00 - Reserved 00 - Reserved
01 - Zip 01 - Zip
00 - Copy (not used). Use {00} instead 00 - Copy (not used). Use {00} instead
01 - Shrink 01 - Shrink
06 - Implode 06 - Implode
08 - Deflate 08 - Deflate
09 - Deflate64 09 - Deflate64
12 - BZip2 (not used). Use {04 02 02} instead 12 - BZip2 (not used). Use {04 02 02} instead
02 - BZip 02 - BZip
02 - BZip2 02 - BZip2
03 - Rar 03 - Rar
01 - Rar15 01 - Rar15
02 - Rar20 02 - Rar20
03 - Rar29 03 - Rar29
04 - Arj 04 - Arj
01 - Arj (1,2,3) 01 - Arj (1,2,3)
02 - Arj 4 02 - Arj 4
05 - Z 05 - Z
06 - Lzh 06 - Lzh
07 - Reserved for 7z 07 - Reserved for 7z
08 - Cab 08 - Cab
09 - NSIS 09 - NSIS
01 - DeflateNSIS 01 - DeflateNSIS
02 - BZip2NSIS 02 - BZip2NSIS
06 - Crypto 06 - Crypto
00 - 00 -
01 - AES 01 - AES
0x - AES-128 0x - AES-128
4x - AES-192 4x - AES-192
8x - AES-256 8x - AES-256
Cx - AES Cx - AES
x0 - ECB x0 - ECB
x1 - CBC x1 - CBC
x2 - CFB x2 - CFB
x3 - OFB x3 - OFB
07 - Reserved 07 - Reserved
0F - Reserved 0F - Reserved
F0 - Misc Ciphers (Real Ciphers without hashing algo) F0 - Misc Ciphers (Real Ciphers without hashing algo)
F1 - Misc Ciphers (Combine) F1 - Misc Ciphers (Combine)
01 - Zip 01 - Zip
01 - Main Zip crypto algo 01 - Main Zip crypto algo
03 - RAR 03 - RAR
02 - 02 -
03 - Rar29 AES-128 + (modified SHA-1) 03 - Rar29 AES-128 + (modified SHA-1)
07 - 7z 07 - 7z
01 - AES-256 + SHA-256 01 - AES-256 + SHA-256
07 - Hash (subject to change) 07 - Hash (subject to change)
00 - 00 -
01 - CRC 01 - CRC
02 - SHA-1 02 - SHA-1
03 - SHA-256 03 - SHA-256
04 - SHA-384 04 - SHA-384
05 - SHA-512 05 - SHA-512
F0 - Misc Hash F0 - Misc Hash
F1 - Misc F1 - Misc
03 - RAR 03 - RAR
03 - Rar29 Password Hashing (modified SHA1) 03 - Rar29 Password Hashing (modified SHA1)
07 - 7z 07 - 7z
01 - SHA-256 Password Hashing 01 - SHA-256 Password Hashing
--- ---
End of document End of document

View file

@ -1,231 +1,231 @@
HISTORY of the LZMA SDK HISTORY of the LZMA SDK
----------------------- -----------------------
4.63 2008-12-31 4.63 2008-12-31
------------------------- -------------------------
- Some minor fixes - Some minor fixes
4.61 beta 2008-11-23 4.61 beta 2008-11-23
------------------------- -------------------------
- The bug in ANSI-C LZMA Decoder was fixed: - The bug in ANSI-C LZMA Decoder was fixed:
If encoded stream was corrupted, decoder could access memory If encoded stream was corrupted, decoder could access memory
outside of allocated range. outside of allocated range.
- Some changes in ANSI-C 7z Decoder interfaces. - Some changes in ANSI-C 7z Decoder interfaces.
- LZMA SDK is placed in the public domain. - LZMA SDK is placed in the public domain.
4.60 beta 2008-08-19 4.60 beta 2008-08-19
------------------------- -------------------------
- Some minor fixes. - Some minor fixes.
4.59 beta 2008-08-13 4.59 beta 2008-08-13
------------------------- -------------------------
- The bug was fixed: - The bug was fixed:
LZMA Encoder in fast compression mode could access memory outside of LZMA Encoder in fast compression mode could access memory outside of
allocated range in some rare cases. allocated range in some rare cases.
4.58 beta 2008-05-05 4.58 beta 2008-05-05
------------------------- -------------------------
- ANSI-C LZMA Decoder was rewritten for speed optimizations. - ANSI-C LZMA Decoder was rewritten for speed optimizations.
- ANSI-C LZMA Encoder was included to LZMA SDK. - ANSI-C LZMA Encoder was included to LZMA SDK.
- C++ LZMA code now is just wrapper over ANSI-C code. - C++ LZMA code now is just wrapper over ANSI-C code.
4.57 2007-12-12 4.57 2007-12-12
------------------------- -------------------------
- Speed optimizations in Ñ++ LZMA Decoder. - Speed optimizations in Ñ++ LZMA Decoder.
- Small changes for more compatibility with some C/C++ compilers. - Small changes for more compatibility with some C/C++ compilers.
4.49 beta 2007-07-05 4.49 beta 2007-07-05
------------------------- -------------------------
- .7z ANSI-C Decoder: - .7z ANSI-C Decoder:
- now it supports BCJ and BCJ2 filters - now it supports BCJ and BCJ2 filters
- now it supports files larger than 4 GB. - now it supports files larger than 4 GB.
- now it supports "Last Write Time" field for files. - now it supports "Last Write Time" field for files.
- C++ code for .7z archives compressing/decompressing from 7-zip - C++ code for .7z archives compressing/decompressing from 7-zip
was included to LZMA SDK. was included to LZMA SDK.
4.43 2006-06-04 4.43 2006-06-04
------------------------- -------------------------
- Small changes for more compatibility with some C/C++ compilers. - Small changes for more compatibility with some C/C++ compilers.
4.42 2006-05-15 4.42 2006-05-15
------------------------- -------------------------
- Small changes in .h files in ANSI-C version. - Small changes in .h files in ANSI-C version.
4.39 beta 2006-04-14 4.39 beta 2006-04-14
------------------------- -------------------------
- The bug in versions 4.33b:4.38b was fixed: - The bug in versions 4.33b:4.38b was fixed:
C++ version of LZMA encoder could not correctly compress C++ version of LZMA encoder could not correctly compress
files larger than 2 GB with HC4 match finder (-mfhc4). files larger than 2 GB with HC4 match finder (-mfhc4).
4.37 beta 2005-04-06 4.37 beta 2005-04-06
------------------------- -------------------------
- Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined. - Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined.
4.35 beta 2005-03-02 4.35 beta 2005-03-02
------------------------- -------------------------
- The bug was fixed in C++ version of LZMA Decoder: - The bug was fixed in C++ version of LZMA Decoder:
If encoded stream was corrupted, decoder could access memory If encoded stream was corrupted, decoder could access memory
outside of allocated range. outside of allocated range.
4.34 beta 2006-02-27 4.34 beta 2006-02-27
------------------------- -------------------------
- Compressing speed and memory requirements for compressing were increased - Compressing speed and memory requirements for compressing were increased
- LZMA now can use only these match finders: HC4, BT2, BT3, BT4 - LZMA now can use only these match finders: HC4, BT2, BT3, BT4
4.32 2005-12-09 4.32 2005-12-09
------------------------- -------------------------
- Java version of LZMA SDK was included - Java version of LZMA SDK was included
4.30 2005-11-20 4.30 2005-11-20
------------------------- -------------------------
- Compression ratio was improved in -a2 mode - Compression ratio was improved in -a2 mode
- Speed optimizations for compressing in -a2 mode - Speed optimizations for compressing in -a2 mode
- -fb switch now supports values up to 273 - -fb switch now supports values up to 273
- The bug in 7z_C (7zIn.c) was fixed: - The bug in 7z_C (7zIn.c) was fixed:
It used Alloc/Free functions from different memory pools. It used Alloc/Free functions from different memory pools.
So if program used two memory pools, it worked incorrectly. So if program used two memory pools, it worked incorrectly.
- 7z_C: .7z format supporting was improved - 7z_C: .7z format supporting was improved
- LZMA# SDK (C#.NET version) was included - LZMA# SDK (C#.NET version) was included
4.27 (Updated) 2005-09-21 4.27 (Updated) 2005-09-21
------------------------- -------------------------
- Some GUIDs/interfaces in C++ were changed. - Some GUIDs/interfaces in C++ were changed.
IStream.h: IStream.h:
ISequentialInStream::Read now works as old ReadPart ISequentialInStream::Read now works as old ReadPart
ISequentialOutStream::Write now works as old WritePart ISequentialOutStream::Write now works as old WritePart
4.27 2005-08-07 4.27 2005-08-07
------------------------- -------------------------
- The bug in LzmaDecodeSize.c was fixed: - The bug in LzmaDecodeSize.c was fixed:
if _LZMA_IN_CB and _LZMA_OUT_READ were defined, if _LZMA_IN_CB and _LZMA_OUT_READ were defined,
decompressing worked incorrectly. decompressing worked incorrectly.
4.26 2005-08-05 4.26 2005-08-05
------------------------- -------------------------
- Fixes in 7z_C code and LzmaTest.c: - Fixes in 7z_C code and LzmaTest.c:
previous versions could work incorrectly, previous versions could work incorrectly,
if malloc(0) returns 0 if malloc(0) returns 0
4.23 2005-06-29 4.23 2005-06-29
------------------------- -------------------------
- Small fixes in C++ code - Small fixes in C++ code
4.22 2005-06-10 4.22 2005-06-10
------------------------- -------------------------
- Small fixes - Small fixes
4.21 2005-06-08 4.21 2005-06-08
------------------------- -------------------------
- Interfaces for ANSI-C LZMA Decoder (LzmaDecode.c) were changed - Interfaces for ANSI-C LZMA Decoder (LzmaDecode.c) were changed
- New additional version of ANSI-C LZMA Decoder with zlib-like interface: - New additional version of ANSI-C LZMA Decoder with zlib-like interface:
- LzmaStateDecode.h - LzmaStateDecode.h
- LzmaStateDecode.c - LzmaStateDecode.c
- LzmaStateTest.c - LzmaStateTest.c
- ANSI-C LZMA Decoder now can decompress files larger than 4 GB - ANSI-C LZMA Decoder now can decompress files larger than 4 GB
4.17 2005-04-18 4.17 2005-04-18
------------------------- -------------------------
- New example for RAM->RAM compressing/decompressing: - New example for RAM->RAM compressing/decompressing:
LZMA + BCJ (filter for x86 code): LZMA + BCJ (filter for x86 code):
- LzmaRam.h - LzmaRam.h
- LzmaRam.cpp - LzmaRam.cpp
- LzmaRamDecode.h - LzmaRamDecode.h
- LzmaRamDecode.c - LzmaRamDecode.c
- -f86 switch for lzma.exe - -f86 switch for lzma.exe
4.16 2005-03-29 4.16 2005-03-29
------------------------- -------------------------
- The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder): - The bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder):
If _LZMA_OUT_READ was defined, and if encoded stream was corrupted, If _LZMA_OUT_READ was defined, and if encoded stream was corrupted,
decoder could access memory outside of allocated range. decoder could access memory outside of allocated range.
- Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster). - Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster).
Old version of LZMA Decoder now is in file LzmaDecodeSize.c. Old version of LZMA Decoder now is in file LzmaDecodeSize.c.
LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c
- Small speed optimization in LZMA C++ code - Small speed optimization in LZMA C++ code
- filter for SPARC's code was added - filter for SPARC's code was added
- Simplified version of .7z ANSI-C Decoder was included - Simplified version of .7z ANSI-C Decoder was included
4.06 2004-09-05 4.06 2004-09-05
------------------------- -------------------------
- The bug in v4.05 was fixed: - The bug in v4.05 was fixed:
LZMA-Encoder didn't release output stream in some cases. LZMA-Encoder didn't release output stream in some cases.
4.05 2004-08-25 4.05 2004-08-25
------------------------- -------------------------
- Source code of filters for x86, IA-64, ARM, ARM-Thumb - Source code of filters for x86, IA-64, ARM, ARM-Thumb
and PowerPC code was included to SDK and PowerPC code was included to SDK
- Some internal minor changes - Some internal minor changes
4.04 2004-07-28 4.04 2004-07-28
------------------------- -------------------------
- More compatibility with some C++ compilers - More compatibility with some C++ compilers
4.03 2004-06-18 4.03 2004-06-18
------------------------- -------------------------
- "Benchmark" command was added. It measures compressing - "Benchmark" command was added. It measures compressing
and decompressing speed and shows rating values. and decompressing speed and shows rating values.
Also it checks hardware errors. Also it checks hardware errors.
4.02 2004-06-10 4.02 2004-06-10
------------------------- -------------------------
- C++ LZMA Encoder/Decoder code now is more portable - C++ LZMA Encoder/Decoder code now is more portable
and it can be compiled by GCC on Linux. and it can be compiled by GCC on Linux.
4.01 2004-02-15 4.01 2004-02-15
------------------------- -------------------------
- Some detection of data corruption was enabled. - Some detection of data corruption was enabled.
LzmaDecode.c / RangeDecoderReadByte LzmaDecode.c / RangeDecoderReadByte
..... .....
{ {
rd->ExtraBytes = 1; rd->ExtraBytes = 1;
return 0xFF; return 0xFF;
} }
4.00 2004-02-13 4.00 2004-02-13
------------------------- -------------------------
- Original version of LZMA SDK - Original version of LZMA SDK
HISTORY of the LZMA HISTORY of the LZMA
------------------- -------------------
2001-2008: Improvements to LZMA compressing/decompressing code, 2001-2008: Improvements to LZMA compressing/decompressing code,
keeping compatibility with original LZMA format keeping compatibility with original LZMA format
1996-2001: Development of LZMA compression format 1996-2001: Development of LZMA compression format
Some milestones: Some milestones:
2001-08-30: LZMA compression was added to 7-Zip 2001-08-30: LZMA compression was added to 7-Zip
1999-01-02: First version of 7-Zip was released 1999-01-02: First version of 7-Zip was released
End of document End of document

3542
zpipe.cpp

File diff suppressed because it is too large Load diff