-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3rdParty: rename 7-Zip to lzma and don't include tar.gz
- Loading branch information
1 parent
ccbd6bc
commit 7c6b239
Showing
138 changed files
with
38,519 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
/* 7z.h -- 7z interface | ||
2023-04-02 : Igor Pavlov : Public domain */ | ||
|
||
#ifndef ZIP7_INC_7Z_H | ||
#define ZIP7_INC_7Z_H | ||
|
||
#include "7zTypes.h" | ||
|
||
EXTERN_C_BEGIN | ||
|
||
#define k7zStartHeaderSize 0x20 | ||
#define k7zSignatureSize 6 | ||
|
||
extern const Byte k7zSignature[k7zSignatureSize]; | ||
|
||
typedef struct | ||
{ | ||
const Byte *Data; | ||
size_t Size; | ||
} CSzData; | ||
|
||
/* CSzCoderInfo & CSzFolder support only default methods */ | ||
|
||
typedef struct | ||
{ | ||
size_t PropsOffset; | ||
UInt32 MethodID; | ||
Byte NumStreams; | ||
Byte PropsSize; | ||
} CSzCoderInfo; | ||
|
||
typedef struct | ||
{ | ||
UInt32 InIndex; | ||
UInt32 OutIndex; | ||
} CSzBond; | ||
|
||
#define SZ_NUM_CODERS_IN_FOLDER_MAX 4 | ||
#define SZ_NUM_BONDS_IN_FOLDER_MAX 3 | ||
#define SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX 4 | ||
|
||
typedef struct | ||
{ | ||
UInt32 NumCoders; | ||
UInt32 NumBonds; | ||
UInt32 NumPackStreams; | ||
UInt32 UnpackStream; | ||
UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX]; | ||
CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX]; | ||
CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX]; | ||
} CSzFolder; | ||
|
||
|
||
SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd); | ||
|
||
typedef struct | ||
{ | ||
UInt32 Low; | ||
UInt32 High; | ||
} CNtfsFileTime; | ||
|
||
typedef struct | ||
{ | ||
Byte *Defs; /* MSB 0 bit numbering */ | ||
UInt32 *Vals; | ||
} CSzBitUi32s; | ||
|
||
typedef struct | ||
{ | ||
Byte *Defs; /* MSB 0 bit numbering */ | ||
// UInt64 *Vals; | ||
CNtfsFileTime *Vals; | ||
} CSzBitUi64s; | ||
|
||
#define SzBitArray_Check(p, i) (((p)[(i) >> 3] & (0x80 >> ((i) & 7))) != 0) | ||
|
||
#define SzBitWithVals_Check(p, i) ((p)->Defs && ((p)->Defs[(i) >> 3] & (0x80 >> ((i) & 7))) != 0) | ||
|
||
typedef struct | ||
{ | ||
UInt32 NumPackStreams; | ||
UInt32 NumFolders; | ||
|
||
UInt64 *PackPositions; // NumPackStreams + 1 | ||
CSzBitUi32s FolderCRCs; // NumFolders | ||
|
||
size_t *FoCodersOffsets; // NumFolders + 1 | ||
UInt32 *FoStartPackStreamIndex; // NumFolders + 1 | ||
UInt32 *FoToCoderUnpackSizes; // NumFolders + 1 | ||
Byte *FoToMainUnpackSizeIndex; // NumFolders | ||
UInt64 *CoderUnpackSizes; // for all coders in all folders | ||
|
||
Byte *CodersData; | ||
|
||
UInt64 RangeLimit; | ||
} CSzAr; | ||
|
||
UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex); | ||
|
||
SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, | ||
ILookInStreamPtr stream, UInt64 startPos, | ||
Byte *outBuffer, size_t outSize, | ||
ISzAllocPtr allocMain); | ||
|
||
typedef struct | ||
{ | ||
CSzAr db; | ||
|
||
UInt64 startPosAfterHeader; | ||
UInt64 dataPos; | ||
|
||
UInt32 NumFiles; | ||
|
||
UInt64 *UnpackPositions; // NumFiles + 1 | ||
// Byte *IsEmptyFiles; | ||
Byte *IsDirs; | ||
CSzBitUi32s CRCs; | ||
|
||
CSzBitUi32s Attribs; | ||
// CSzBitUi32s Parents; | ||
CSzBitUi64s MTime; | ||
CSzBitUi64s CTime; | ||
|
||
UInt32 *FolderToFile; // NumFolders + 1 | ||
UInt32 *FileToFolder; // NumFiles | ||
|
||
size_t *FileNameOffsets; /* in 2-byte steps */ | ||
Byte *FileNames; /* UTF-16-LE */ | ||
} CSzArEx; | ||
|
||
#define SzArEx_IsDir(p, i) (SzBitArray_Check((p)->IsDirs, i)) | ||
|
||
#define SzArEx_GetFileSize(p, i) ((p)->UnpackPositions[(i) + 1] - (p)->UnpackPositions[i]) | ||
|
||
void SzArEx_Init(CSzArEx *p); | ||
void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc); | ||
UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder); | ||
int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize); | ||
|
||
/* | ||
if dest == NULL, the return value specifies the required size of the buffer, | ||
in 16-bit characters, including the null-terminating character. | ||
if dest != NULL, the return value specifies the number of 16-bit characters that | ||
are written to the dest, including the null-terminating character. */ | ||
|
||
size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest); | ||
|
||
/* | ||
size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex); | ||
UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest); | ||
*/ | ||
|
||
|
||
|
||
/* | ||
SzArEx_Extract extracts file from archive | ||
*outBuffer must be 0 before first call for each new archive. | ||
Extracting cache: | ||
If you need to decompress more than one file, you can send | ||
these values from previous call: | ||
*blockIndex, | ||
*outBuffer, | ||
*outBufferSize | ||
You can consider "*outBuffer" as cache of solid block. If your archive is solid, | ||
it will increase decompression speed. | ||
If you use external function, you can declare these 3 cache variables | ||
(blockIndex, outBuffer, outBufferSize) as static in that external function. | ||
Free *outBuffer and set *outBuffer to 0, if you want to flush cache. | ||
*/ | ||
|
||
SRes SzArEx_Extract( | ||
const CSzArEx *db, | ||
ILookInStreamPtr inStream, | ||
UInt32 fileIndex, /* index of file */ | ||
UInt32 *blockIndex, /* index of solid block */ | ||
Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ | ||
size_t *outBufferSize, /* buffer size for output buffer */ | ||
size_t *offset, /* offset of stream for required file in *outBuffer */ | ||
size_t *outSizeProcessed, /* size of file in *outBuffer */ | ||
ISzAllocPtr allocMain, | ||
ISzAllocPtr allocTemp); | ||
|
||
|
||
/* | ||
SzArEx_Open Errors: | ||
SZ_ERROR_NO_ARCHIVE | ||
SZ_ERROR_ARCHIVE | ||
SZ_ERROR_UNSUPPORTED | ||
SZ_ERROR_MEM | ||
SZ_ERROR_CRC | ||
SZ_ERROR_INPUT_EOF | ||
SZ_ERROR_FAIL | ||
*/ | ||
|
||
SRes SzArEx_Open(CSzArEx *p, ILookInStreamPtr inStream, | ||
ISzAllocPtr allocMain, ISzAllocPtr allocTemp); | ||
|
||
EXTERN_C_END | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* 7zAlloc.c -- Allocation functions for 7z processing | ||
2023-03-04 : Igor Pavlov : Public domain */ | ||
|
||
#include "Precomp.h" | ||
|
||
#include <stdlib.h> | ||
|
||
#include "7zAlloc.h" | ||
|
||
/* #define SZ_ALLOC_DEBUG */ | ||
/* use SZ_ALLOC_DEBUG to debug alloc/free operations */ | ||
|
||
#ifdef SZ_ALLOC_DEBUG | ||
|
||
/* | ||
#ifdef _WIN32 | ||
#include "7zWindows.h" | ||
#endif | ||
*/ | ||
|
||
#include <stdio.h> | ||
static int g_allocCount = 0; | ||
static int g_allocCountTemp = 0; | ||
|
||
static void Print_Alloc(const char *s, size_t size, int *counter) | ||
{ | ||
const unsigned size2 = (unsigned)size; | ||
fprintf(stderr, "\n%s count = %10d : %10u bytes; ", s, *counter, size2); | ||
(*counter)++; | ||
} | ||
static void Print_Free(const char *s, int *counter) | ||
{ | ||
(*counter)--; | ||
fprintf(stderr, "\n%s count = %10d", s, *counter); | ||
} | ||
#endif | ||
|
||
void *SzAlloc(ISzAllocPtr p, size_t size) | ||
{ | ||
UNUSED_VAR(p) | ||
if (size == 0) | ||
return 0; | ||
#ifdef SZ_ALLOC_DEBUG | ||
Print_Alloc("Alloc", size, &g_allocCount); | ||
#endif | ||
return malloc(size); | ||
} | ||
|
||
void SzFree(ISzAllocPtr p, void *address) | ||
{ | ||
UNUSED_VAR(p) | ||
#ifdef SZ_ALLOC_DEBUG | ||
if (address) | ||
Print_Free("Free ", &g_allocCount); | ||
#endif | ||
free(address); | ||
} | ||
|
||
void *SzAllocTemp(ISzAllocPtr p, size_t size) | ||
{ | ||
UNUSED_VAR(p) | ||
if (size == 0) | ||
return 0; | ||
#ifdef SZ_ALLOC_DEBUG | ||
Print_Alloc("Alloc_temp", size, &g_allocCountTemp); | ||
/* | ||
#ifdef _WIN32 | ||
return HeapAlloc(GetProcessHeap(), 0, size); | ||
#endif | ||
*/ | ||
#endif | ||
return malloc(size); | ||
} | ||
|
||
void SzFreeTemp(ISzAllocPtr p, void *address) | ||
{ | ||
UNUSED_VAR(p) | ||
#ifdef SZ_ALLOC_DEBUG | ||
if (address) | ||
Print_Free("Free_temp ", &g_allocCountTemp); | ||
/* | ||
#ifdef _WIN32 | ||
HeapFree(GetProcessHeap(), 0, address); | ||
return; | ||
#endif | ||
*/ | ||
#endif | ||
free(address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* 7zAlloc.h -- Allocation functions | ||
2023-03-04 : Igor Pavlov : Public domain */ | ||
|
||
#ifndef ZIP7_INC_7Z_ALLOC_H | ||
#define ZIP7_INC_7Z_ALLOC_H | ||
|
||
#include "7zTypes.h" | ||
|
||
EXTERN_C_BEGIN | ||
|
||
void *SzAlloc(ISzAllocPtr p, size_t size); | ||
void SzFree(ISzAllocPtr p, void *address); | ||
|
||
void *SzAllocTemp(ISzAllocPtr p, size_t size); | ||
void SzFreeTemp(ISzAllocPtr p, void *address); | ||
|
||
EXTERN_C_END | ||
|
||
#endif |
Oops, something went wrong.