Don't udpate LastOverSpeedTick when using aqua_speed
[ryzomcore.git] / nel / 3rdparty / seven_zip / 7z.h
blob6c7886e38b13308f1b476d287d97038695b51c92
1 /* 7z.h -- 7z interface
2 2017-04-03 : Igor Pavlov : Public domain */
4 #ifndef __7Z_H
5 #define __7Z_H
7 #include "7zTypes.h"
9 EXTERN_C_BEGIN
11 #define k7zStartHeaderSize 0x20
12 #define k7zSignatureSize 6
14 extern const Byte k7zSignature[k7zSignatureSize];
16 typedef struct
18 const Byte *Data;
19 size_t Size;
20 } CSzData;
22 /* CSzCoderInfo & CSzFolder support only default methods */
24 typedef struct
26 size_t PropsOffset;
27 UInt32 MethodID;
28 Byte NumStreams;
29 Byte PropsSize;
30 } CSzCoderInfo;
32 typedef struct
34 UInt32 InIndex;
35 UInt32 OutIndex;
36 } CSzBond;
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
42 typedef struct
44 UInt32 NumCoders;
45 UInt32 NumBonds;
46 UInt32 NumPackStreams;
47 UInt32 UnpackStream;
48 UInt32 PackStreams[SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX];
49 CSzBond Bonds[SZ_NUM_BONDS_IN_FOLDER_MAX];
50 CSzCoderInfo Coders[SZ_NUM_CODERS_IN_FOLDER_MAX];
51 } CSzFolder;
54 SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd);
56 typedef struct
58 UInt32 Low;
59 UInt32 High;
60 } CNtfsFileTime;
62 typedef struct
64 Byte *Defs; /* MSB 0 bit numbering */
65 UInt32 *Vals;
66 } CSzBitUi32s;
68 typedef struct
70 Byte *Defs; /* MSB 0 bit numbering */
71 // UInt64 *Vals;
72 CNtfsFileTime *Vals;
73 } CSzBitUi64s;
75 #define SzBitArray_Check(p, i) (((p)[(i) >> 3] & (0x80 >> ((i) & 7))) != 0)
77 #define SzBitWithVals_Check(p, i) ((p)->Defs && ((p)->Defs[(i) >> 3] & (0x80 >> ((i) & 7))) != 0)
79 typedef struct
81 UInt32 NumPackStreams;
82 UInt32 NumFolders;
84 UInt64 *PackPositions; // NumPackStreams + 1
85 CSzBitUi32s FolderCRCs; // NumFolders
87 size_t *FoCodersOffsets; // NumFolders + 1
88 UInt32 *FoStartPackStreamIndex; // NumFolders + 1
89 UInt32 *FoToCoderUnpackSizes; // NumFolders + 1
90 Byte *FoToMainUnpackSizeIndex; // NumFolders
91 UInt64 *CoderUnpackSizes; // for all coders in all folders
93 Byte *CodersData;
94 } CSzAr;
96 UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex);
98 SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex,
99 ILookInStream *stream, UInt64 startPos,
100 Byte *outBuffer, size_t outSize,
101 ISzAllocPtr allocMain);
103 typedef struct
105 CSzAr db;
107 UInt64 startPosAfterHeader;
108 UInt64 dataPos;
110 UInt32 NumFiles;
112 UInt64 *UnpackPositions; // NumFiles + 1
113 // Byte *IsEmptyFiles;
114 Byte *IsDirs;
115 CSzBitUi32s CRCs;
117 CSzBitUi32s Attribs;
118 // CSzBitUi32s Parents;
119 CSzBitUi64s MTime;
120 CSzBitUi64s CTime;
122 UInt32 *FolderToFile; // NumFolders + 1
123 UInt32 *FileToFolder; // NumFiles
125 size_t *FileNameOffsets; /* in 2-byte steps */
126 Byte *FileNames; /* UTF-16-LE */
127 } CSzArEx;
129 #define SzArEx_IsDir(p, i) (SzBitArray_Check((p)->IsDirs, i))
131 #define SzArEx_GetFileSize(p, i) ((p)->UnpackPositions[(i) + 1] - (p)->UnpackPositions[i])
133 void SzArEx_Init(CSzArEx *p);
134 void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc);
135 UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
136 int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize);
139 if dest == NULL, the return value specifies the required size of the buffer,
140 in 16-bit characters, including the null-terminating character.
141 if dest != NULL, the return value specifies the number of 16-bit characters that
142 are written to the dest, including the null-terminating character. */
144 size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
147 size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex);
148 UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
154 SzArEx_Extract extracts file from archive
156 *outBuffer must be 0 before first call for each new archive.
158 Extracting cache:
159 If you need to decompress more than one file, you can send
160 these values from previous call:
161 *blockIndex,
162 *outBuffer,
163 *outBufferSize
164 You can consider "*outBuffer" as cache of solid block. If your archive is solid,
165 it will increase decompression speed.
167 If you use external function, you can declare these 3 cache variables
168 (blockIndex, outBuffer, outBufferSize) as static in that external function.
170 Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
173 SRes SzArEx_Extract(
174 const CSzArEx *db,
175 ILookInStream *inStream,
176 UInt32 fileIndex, /* index of file */
177 UInt32 *blockIndex, /* index of solid block */
178 Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
179 size_t *outBufferSize, /* buffer size for output buffer */
180 size_t *offset, /* offset of stream for required file in *outBuffer */
181 size_t *outSizeProcessed, /* size of file in *outBuffer */
182 ISzAllocPtr allocMain,
183 ISzAllocPtr allocTemp);
187 SzArEx_Open Errors:
188 SZ_ERROR_NO_ARCHIVE
189 SZ_ERROR_ARCHIVE
190 SZ_ERROR_UNSUPPORTED
191 SZ_ERROR_MEM
192 SZ_ERROR_CRC
193 SZ_ERROR_INPUT_EOF
194 SZ_ERROR_FAIL
197 SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream,
198 ISzAllocPtr allocMain, ISzAllocPtr allocTemp);
200 EXTERN_C_END
202 #endif