| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#ifndef ZIP7_INC_7Z_H |
| 5 |
#define ZIP7_INC_7Z_H |
| 6 |
|
| 7 |
#include "7zTypes.h" |
| 8 |
|
| 9 |
EXTERN_C_BEGIN |
| 10 |
|
| 11 |
#define k7zStartHeaderSize 0x20 |
| 12 |
#define k7zSignatureSize 6 |
| 13 |
|
| 14 |
extern const Byte k7zSignature[k7zSignatureSize]; |
| 15 |
|
| 16 |
typedef struct |
| 17 |
{ |
| 18 |
const Byte *Data; |
| 19 |
size_t Size; |
| 20 |
} CSzData; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
typedef struct |
| 25 |
{ |
| 26 |
size_t PropsOffset; |
| 27 |
UInt32 MethodID; |
| 28 |
Byte NumStreams; |
| 29 |
Byte PropsSize; |
| 30 |
} CSzCoderInfo; |
| 31 |
|
| 32 |
typedef struct |
| 33 |
{ |
| 34 |
UInt32 InIndex; |
| 35 |
UInt32 OutIndex; |
| 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 |
|
| 42 |
typedef struct |
| 43 |
{ |
| 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; |
| 52 |
|
| 53 |
|
| 54 |
SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd); |
| 55 |
|
| 56 |
typedef struct |
| 57 |
{ |
| 58 |
UInt32 Low; |
| 59 |
UInt32 High; |
| 60 |
} CNtfsFileTime; |
| 61 |
|
| 62 |
typedef struct |
| 63 |
{ |
| 64 |
Byte *Defs; |
| 65 |
UInt32 *Vals; |
| 66 |
} CSzBitUi32s; |
| 67 |
|
| 68 |
typedef struct |
| 69 |
{ |
| 70 |
Byte *Defs; |
| 71 |
|
| 72 |
CNtfsFileTime *Vals; |
| 73 |
} CSzBitUi64s; |
| 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 |
|
| 79 |
typedef struct |
| 80 |
{ |
| 81 |
UInt32 NumPackStreams; |
| 82 |
UInt32 NumFolders; |
| 83 |
|
| 84 |
UInt64 *PackPositions; |
| 85 |
CSzBitUi32s FolderCRCs; |
| 86 |
|
| 87 |
size_t *FoCodersOffsets; |
| 88 |
UInt32 *FoStartPackStreamIndex; |
| 89 |
UInt32 *FoToCoderUnpackSizes; |
| 90 |
Byte *FoToMainUnpackSizeIndex; |
| 91 |
UInt64 *CoderUnpackSizes; |
| 92 |
|
| 93 |
Byte *CodersData; |
| 94 |
|
| 95 |
UInt64 RangeLimit; |
| 96 |
} CSzAr; |
| 97 |
|
| 98 |
UInt64 SzAr_GetFolderUnpackSize(const CSzAr *p, UInt32 folderIndex); |
| 99 |
|
| 100 |
SRes SzAr_DecodeFolder(const CSzAr *p, UInt32 folderIndex, |
| 101 |
ILookInStreamPtr stream, UInt64 startPos, |
| 102 |
Byte *outBuffer, size_t outSize, |
| 103 |
ISzAllocPtr allocMain); |
| 104 |
|
| 105 |
typedef struct |
| 106 |
{ |
| 107 |
CSzAr db; |
| 108 |
|
| 109 |
UInt64 startPosAfterHeader; |
| 110 |
UInt64 dataPos; |
| 111 |
|
| 112 |
UInt32 NumFiles; |
| 113 |
|
| 114 |
UInt64 *UnpackPositions; |
| 115 |
|
| 116 |
Byte *IsDirs; |
| 117 |
CSzBitUi32s CRCs; |
| 118 |
|
| 119 |
CSzBitUi32s Attribs; |
| 120 |
|
| 121 |
CSzBitUi64s MTime; |
| 122 |
CSzBitUi64s CTime; |
| 123 |
|
| 124 |
UInt32 *FolderToFile; |
| 125 |
UInt32 *FileToFolder; |
| 126 |
|
| 127 |
size_t *FileNameOffsets; |
| 128 |
Byte *FileNames; |
| 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 |
|
| 135 |
void SzArEx_Init(CSzArEx *p); |
| 136 |
void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc); |
| 137 |
UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder); |
| 138 |
int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize); |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest); |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
SRes SzArEx_Extract( |
| 176 |
const CSzArEx *db, |
| 177 |
ILookInStreamPtr inStream, |
| 178 |
UInt32 fileIndex, |
| 179 |
UInt32 *blockIndex, |
| 180 |
Byte **outBuffer, |
| 181 |
size_t *outBufferSize, |
| 182 |
size_t *offset, |
| 183 |
size_t *outSizeProcessed, |
| 184 |
ISzAllocPtr allocMain, |
| 185 |
ISzAllocPtr allocTemp); |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
SRes SzArEx_Open(CSzArEx *p, ILookInStreamPtr inStream, |
| 200 |
ISzAllocPtr allocMain, ISzAllocPtr allocTemp); |
| 201 |
|
| 202 |
EXTERN_C_END |
| 203 |
|
| 204 |
#endif |