Fix VPN dialog password field focus
[chromium-blink-merge.git] / third_party / lzma_sdk / 7z.h
blob01c4cac6a7bec9ad60c762d2d82dad8cb151c45d
1 /* 7z.h -- 7z interface
2 2010-03-11 : Igor Pavlov : Public domain */
4 #ifndef __7Z_H
5 #define __7Z_H
7 #include "7zBuf.h"
9 EXTERN_C_BEGIN
11 #define k7zStartHeaderSize 0x20
12 #define k7zSignatureSize 6
13 extern Byte k7zSignature[k7zSignatureSize];
14 #define k7zMajorVersion 0
16 enum EIdEnum
18 k7zIdEnd,
19 k7zIdHeader,
20 k7zIdArchiveProperties,
21 k7zIdAdditionalStreamsInfo,
22 k7zIdMainStreamsInfo,
23 k7zIdFilesInfo,
24 k7zIdPackInfo,
25 k7zIdUnpackInfo,
26 k7zIdSubStreamsInfo,
27 k7zIdSize,
28 k7zIdCRC,
29 k7zIdFolder,
30 k7zIdCodersUnpackSize,
31 k7zIdNumUnpackStream,
32 k7zIdEmptyStream,
33 k7zIdEmptyFile,
34 k7zIdAnti,
35 k7zIdName,
36 k7zIdCTime,
37 k7zIdATime,
38 k7zIdMTime,
39 k7zIdWinAttributes,
40 k7zIdComment,
41 k7zIdEncodedHeader,
42 k7zIdStartPos,
43 k7zIdDummy
46 typedef struct
48 UInt32 NumInStreams;
49 UInt32 NumOutStreams;
50 UInt64 MethodID;
51 CBuf Props;
52 } CSzCoderInfo;
54 void SzCoderInfo_Init(CSzCoderInfo *p);
55 void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc);
57 typedef struct
59 UInt32 InIndex;
60 UInt32 OutIndex;
61 } CSzBindPair;
63 typedef struct
65 CSzCoderInfo *Coders;
66 CSzBindPair *BindPairs;
67 UInt32 *PackStreams;
68 UInt64 *UnpackSizes;
69 UInt32 NumCoders;
70 UInt32 NumBindPairs;
71 UInt32 NumPackStreams;
72 int UnpackCRCDefined;
73 UInt32 UnpackCRC;
75 UInt32 NumUnpackStreams;
76 } CSzFolder;
78 void SzFolder_Init(CSzFolder *p);
79 UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
80 int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex);
81 UInt32 SzFolder_GetNumOutStreams(CSzFolder *p);
82 UInt64 SzFolder_GetUnpackSize(CSzFolder *p);
84 SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes,
85 ILookInStream *stream, UInt64 startPos,
86 Byte *outBuffer, size_t outSize, ISzAlloc *allocMain);
88 typedef struct
90 UInt32 Low;
91 UInt32 High;
92 } CNtfsFileTime;
94 typedef struct
96 CNtfsFileTime MTime;
97 UInt64 Size;
98 UInt32 Crc;
99 UInt32 Attrib;
100 Byte HasStream;
101 Byte IsDir;
102 Byte IsAnti;
103 Byte CrcDefined;
104 Byte MTimeDefined;
105 Byte AttribDefined;
106 } CSzFileItem;
108 void SzFile_Init(CSzFileItem *p);
110 typedef struct
112 UInt64 *PackSizes;
113 Byte *PackCRCsDefined;
114 UInt32 *PackCRCs;
115 CSzFolder *Folders;
116 CSzFileItem *Files;
117 UInt32 NumPackStreams;
118 UInt32 NumFolders;
119 UInt32 NumFiles;
120 } CSzAr;
122 void SzAr_Init(CSzAr *p);
123 void SzAr_Free(CSzAr *p, ISzAlloc *alloc);
127 SzExtract extracts file from archive
129 *outBuffer must be 0 before first call for each new archive.
131 Extracting cache:
132 If you need to decompress more than one file, you can send
133 these values from previous call:
134 *blockIndex,
135 *outBuffer,
136 *outBufferSize
137 You can consider "*outBuffer" as cache of solid block. If your archive is solid,
138 it will increase decompression speed.
140 If you use external function, you can declare these 3 cache variables
141 (blockIndex, outBuffer, outBufferSize) as static in that external function.
143 Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
146 typedef struct
148 CSzAr db;
150 UInt64 startPosAfterHeader;
151 UInt64 dataPos;
153 UInt32 *FolderStartPackStreamIndex;
154 UInt64 *PackStreamStartPositions;
155 UInt32 *FolderStartFileIndex;
156 UInt32 *FileIndexToFolderIndexMap;
158 size_t *FileNameOffsets; /* in 2-byte steps */
159 CBuf FileNames; /* UTF-16-LE */
160 } CSzArEx;
162 void SzArEx_Init(CSzArEx *p);
163 void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc);
164 UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder);
165 int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize);
168 if dest == NULL, the return value specifies the required size of the buffer,
169 in 16-bit characters, including the null-terminating character.
170 if dest != NULL, the return value specifies the number of 16-bit characters that
171 are written to the dest, including the null-terminating character. */
173 size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest);
175 SRes SzArEx_Extract(
176 const CSzArEx *db,
177 ILookInStream *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 ISzAlloc *allocMain,
185 ISzAlloc *allocTemp);
189 SzArEx_Open Errors:
190 SZ_ERROR_NO_ARCHIVE
191 SZ_ERROR_ARCHIVE
192 SZ_ERROR_UNSUPPORTED
193 SZ_ERROR_MEM
194 SZ_ERROR_CRC
195 SZ_ERROR_INPUT_EOF
196 SZ_ERROR_FAIL
199 SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp);
201 EXTERN_C_END
203 #endif