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