Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
7z.h
Go to the documentation of this file.
1/* 7z.h -- 7z interface
22023-04-02 : Igor Pavlov : Public domain */
3
4#ifndef ZIP7_INC_7Z_H
5#define ZIP7_INC_7Z_H
6
7#include "7zTypes.h"
8
10
11#define k7zStartHeaderSize 0x20
12#define k7zSignatureSize 6
13
15
16typedef struct
17{
18 const Byte *Data;
19 size_t Size;
20} CSzData;
21
22/* CSzCoderInfo & CSzFolder support only default methods */
23
31
32typedef struct
33{
36} CSzBond;
37
38#define SZ_NUM_CODERS_IN_FOLDER_MAX 4
39#define SZ_NUM_BONDS_IN_FOLDER_MAX 3
40#define SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX 4
41
52
53
55
56typedef struct
57{
61
62typedef struct
63{
64 Byte *Defs; /* MSB 0 bit numbering */
67
68typedef struct
69{
70 Byte *Defs; /* MSB 0 bit numbering */
71 // UInt64 *Vals;
74
75#define SzBitArray_Check(p, i) (((p)[(i) >> 3] & (0x80 >> ((i) & 7))) != 0)
76
77#define SzBitWithVals_Check(p, i) ((p)->Defs && ((p)->Defs[(i) >> 3] & (0x80 >> ((i) & 7))) != 0)
78
79typedef struct
80{
83
84 UInt64 *PackPositions; // NumPackStreams + 1
85 CSzBitUi32s FolderCRCs; // NumFolders
86
87 size_t *FoCodersOffsets; // NumFolders + 1
88 UInt32 *FoStartPackStreamIndex; // NumFolders + 1
89 UInt32 *FoToCoderUnpackSizes; // NumFolders + 1
91 UInt64 *CoderUnpackSizes; // for all coders in all folders
92
94
96} CSzAr;
97
98UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex);
99
100SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
101 ILookInStreamPtr stream, UInt64 startPos,
102 Byte *outBuffer, size_t outSize,
103 ISzAllocPtr allocMain);
104
105typedef struct
106{
108
111
113
114 UInt64 *UnpackPositions; // NumFiles + 1
115 // Byte *IsEmptyFiles;
118
120 // CSzBitUi32s Parents;
123
124 UInt32 *FolderToFile; // NumFolders + 1
125 UInt32 *FileToFolder; // NumFiles
126
127 size_t *FileNameOffsets; /* in 2-byte steps */
128 Byte *FileNames; /* UTF-16-LE */
129} CSzArEx;
130
131#define SzArEx_IsDir(p, i) (SzBitArray_Check((p)->IsDirs, i))
132
133#define SzArEx_GetFileSize(p, i) ((p)->UnpackPositions[(i) + 1] - (p)->UnpackPositions[i])
134
135void SzArEx_Init(CSzArEx *p);
136void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc);
137UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
138int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize);
139
140/*
141if dest == NULL, the return value specifies the required size of the buffer,
142 in 16-bit characters, including the null-terminating character.
143if dest != NULL, the return value specifies the number of 16-bit characters that
144 are written to the dest, including the null-terminating character. */
145
146size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
147
148/*
149size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex);
150UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
151*/
152
153
154
155/*
156 SzArEx_Extract extracts file from archive
157
158 *outBuffer must be 0 before first call for each new archive.
159
160 Extracting cache:
161 If you need to decompress more than one file, you can send
162 these values from previous call:
163 *blockIndex,
164 *outBuffer,
165 *outBufferSize
166 You can consider "*outBuffer" as cache of solid block. If your archive is solid,
167 it will increase decompression speed.
168
169 If you use external function, you can declare these 3 cache variables
170 (blockIndex, outBuffer, outBufferSize) as static in that external function.
171
172 Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
173*/
174
176 const CSzArEx *db,
177 ILookInStreamPtr inStream,
178 UInt32 fileIndex, /* index of file */
179 UInt32 *blockIndex, /* index of solid block */
180 Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
181 size_t *outBufferSize, /* buffer size for output buffer */
182 size_t *offset, /* offset of stream for required file in *outBuffer */
183 size_t *outSizeProcessed, /* size of file in *outBuffer */
184 ISzAllocPtr allocMain,
185 ISzAllocPtr allocTemp);
186
187
188/*
189SzArEx_Open Errors:
190SZ_ERROR_NO_ARCHIVE
191SZ_ERROR_ARCHIVE
192SZ_ERROR_UNSUPPORTED
193SZ_ERROR_MEM
194SZ_ERROR_CRC
195SZ_ERROR_INPUT_EOF
196SZ_ERROR_FAIL
197*/
198
199SRes SzArEx_Open(CSzArEx *p, ILookInStreamPtr inStream,
200 ISzAllocPtr allocMain, ISzAllocPtr allocTemp);
201
203
204#endif
SRes SzArEx_Extract(const CSzArEx *db, ILookInStreamPtr inStream, UInt32 fileIndex, UInt32 *blockIndex, Byte **outBuffer, size_t *outBufferSize, size_t *offset, size_t *outSizeProcessed, ISzAllocPtr allocMain, ISzAllocPtr allocTemp)
Definition 7zArcIn.c:1650
#define SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX
Definition 7z.h:40
SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd)
Definition 7zArcIn.c:444
void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc)
Definition 7zArcIn.c:153
size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest)
Definition 7zArcIn.c:1727
UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex)
Definition 7zArcIn.c:855
const Byte k7zSignature[k7zSignatureSize]
Definition 7zArcIn.c:60
#define k7zSignatureSize
Definition 7z.h:12
UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder)
int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize)
SRes SzArEx_Open(CSzArEx *p, ILookInStreamPtr inStream, ISzAllocPtr allocMain, ISzAllocPtr allocTemp)
Definition 7zArcIn.c:1640
#define SZ_NUM_BONDS_IN_FOLDER_MAX
Definition 7z.h:39
#define SZ_NUM_CODERS_IN_FOLDER_MAX
Definition 7z.h:38
SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, ILookInStreamPtr stream, UInt64 startPos, Byte *outBuffer, size_t outSize, ISzAllocPtr allocMain)
Definition 7zDec.c:631
void SzArEx_Init(CSzArEx *p)
Definition 7zArcIn.c:130
#define EXTERN_C_BEGIN
Definition 7zTypes.h:20
unsigned long long int UInt64
Definition 7zTypes.h:234
int SRes
Definition 7zTypes.h:45
#define EXTERN_C_END
Definition 7zTypes.h:21
char * dest
Definition lz4.h:806
Definition 7z.h:57
UInt32 Low
Definition 7z.h:58
UInt32 High
Definition 7z.h:59
Definition 7z.h:106
Byte * FileNames
Definition 7z.h:128
UInt32 * FileToFolder
Definition 7z.h:125
CSzBitUi32s Attribs
Definition 7z.h:119
size_t * FileNameOffsets
Definition 7z.h:127
UInt32 NumFiles
Definition 7z.h:112
CSzBitUi32s CRCs
Definition 7z.h:117
CSzBitUi64s CTime
Definition 7z.h:122
UInt64 startPosAfterHeader
Definition 7z.h:109
UInt64 dataPos
Definition 7z.h:110
CSzAr db
Definition 7z.h:107
UInt32 * FolderToFile
Definition 7z.h:124
CSzBitUi64s MTime
Definition 7z.h:121
UInt64 * UnpackPositions
Definition 7z.h:114
Byte * IsDirs
Definition 7z.h:116
Definition 7z.h:80
Byte * CodersData
Definition 7z.h:93
CSzBitUi32s FolderCRCs
Definition 7z.h:85
UInt64 * CoderUnpackSizes
Definition 7z.h:91
UInt32 * FoToCoderUnpackSizes
Definition 7z.h:89
UInt32 * FoStartPackStreamIndex
Definition 7z.h:88
UInt64 RangeLimit
Definition 7z.h:95
UInt32 NumFolders
Definition 7z.h:82
size_t * FoCodersOffsets
Definition 7z.h:87
Byte * FoToMainUnpackSizeIndex
Definition 7z.h:90
UInt32 NumPackStreams
Definition 7z.h:81
UInt64 * PackPositions
Definition 7z.h:84
Definition 7z.h:63
Byte * Defs
Definition 7z.h:64
UInt32 * Vals
Definition 7z.h:65
Definition 7z.h:69
Byte * Defs
Definition 7z.h:70
CNtfsFileTime * Vals
Definition 7z.h:72
Definition 7z.h:33
UInt32 OutIndex
Definition 7z.h:35
UInt32 InIndex
Definition 7z.h:34
Definition 7z.h:25
Byte PropsSize
Definition 7z.h:29
UInt32 MethodID
Definition 7z.h:27
Byte NumStreams
Definition 7z.h:28
size_t PropsOffset
Definition 7z.h:26
Definition 7z.h:17
size_t Size
Definition 7z.h:19
const Byte * Data
Definition 7z.h:18
Definition 7z.h:43
UInt32 NumBonds
Definition 7z.h:45
UInt32 UnpackStream
Definition 7z.h:47
UInt32 NumCoders
Definition 7z.h:44
UInt32 NumPackStreams
Definition 7z.h:46
Definition 7zTypes.h:460
unsigned int UInt32
Definition bzlib_private.h:45
unsigned short UInt16
Definition bzlib_private.h:47
unsigned char Byte
Definition zconf.h:391
#define f(i)
Definition sha256.c:46