1 /* Types.h -- Basic types
2 2008-11-23 : Igor Pavlov : Public domain */
17 #define SZ_ERROR_DATA 1
18 #define SZ_ERROR_MEM 2
19 #define SZ_ERROR_CRC 3
20 #define SZ_ERROR_UNSUPPORTED 4
21 #define SZ_ERROR_PARAM 5
22 #define SZ_ERROR_INPUT_EOF 6
23 #define SZ_ERROR_OUTPUT_EOF 7
24 #define SZ_ERROR_READ 8
25 #define SZ_ERROR_WRITE 9
26 #define SZ_ERROR_PROGRESS 10
27 #define SZ_ERROR_FAIL 11
28 #define SZ_ERROR_THREAD 12
30 #define SZ_ERROR_ARCHIVE 16
31 #define SZ_ERROR_NO_ARCHIVE 17
42 #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
46 typedef unsigned char Byte
;
49 typedef unsigned short UInt16
;
51 #ifdef _LZMA_UINT32_IS_ULONG
53 typedef unsigned long UInt32
;
56 typedef unsigned int UInt32
;
61 /* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
62 NOTES: Some code will work incorrectly in that case! */
65 typedef unsigned long UInt64
;
69 #if defined(_MSC_VER) || defined(__BORLANDC__)
70 typedef __int64 Int64
;
71 typedef unsigned __int64 UInt64
;
73 typedef long long int Int64
;
74 typedef unsigned long long int UInt64
;
79 #ifdef _LZMA_NO_SYSTEM_SIZE_T
93 #define MY_NO_INLINE __declspec(noinline)
98 #define MY_CDECL __cdecl
99 #define MY_STD_CALL __stdcall
100 #define MY_FAST_CALL MY_NO_INLINE __fastcall
111 /* The following interfaces use first parameter as pointer to structure */
115 SRes (*Read
)(void *p
, void *buf
, size_t *size
);
116 /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
117 (output(*size) < input(*size)) is allowed */
120 /* it can return SZ_ERROR_INPUT_EOF */
121 SRes
SeqInStream_Read(ISeqInStream
*stream
, void *buf
, size_t size
);
122 SRes
SeqInStream_Read2(ISeqInStream
*stream
, void *buf
, size_t size
, SRes errorType
);
123 SRes
SeqInStream_ReadByte(ISeqInStream
*stream
, Byte
*buf
);
127 size_t (*Write
)(void *p
, const void *buf
, size_t size
);
128 /* Returns: result - the number of actually written bytes.
129 (result < size) means error */
141 SRes (*Read
)(void *p
, void *buf
, size_t *size
); /* same as ISeqInStream::Read */
142 SRes (*Seek
)(void *p
, Int64
*pos
, ESzSeek origin
);
147 SRes (*Look
)(void *p
, void **buf
, size_t *size
);
148 /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
149 (output(*size) > input(*size)) is not allowed
150 (output(*size) < input(*size)) is allowed */
151 SRes (*Skip
)(void *p
, size_t offset
);
152 /* offset must be <= output(*size) of Look */
154 SRes (*Read
)(void *p
, void *buf
, size_t *size
);
155 /* reads directly (without buffer). It's same as ISeqInStream::Read */
156 SRes (*Seek
)(void *p
, Int64
*pos
, ESzSeek origin
);
159 SRes
LookInStream_LookRead(ILookInStream
*stream
, void *buf
, size_t *size
);
160 SRes
LookInStream_SeekTo(ILookInStream
*stream
, UInt64 offset
);
162 /* reads via ILookInStream::Read */
163 SRes
LookInStream_Read2(ILookInStream
*stream
, void *buf
, size_t size
, SRes errorType
);
164 SRes
LookInStream_Read(ILookInStream
*stream
, void *buf
, size_t size
);
166 #define LookToRead_BUF_SIZE (1 << 14)
171 ISeekInStream
*realStream
;
174 Byte buf
[LookToRead_BUF_SIZE
];
177 void LookToRead_CreateVTable(CLookToRead
*p
, int lookahead
);
178 void LookToRead_Init(CLookToRead
*p
);
183 ILookInStream
*realStream
;
186 void SecToLook_CreateVTable(CSecToLook
*p
);
191 ILookInStream
*realStream
;
194 void SecToRead_CreateVTable(CSecToRead
*p
);
198 SRes (*Progress
)(void *p
, UInt64 inSize
, UInt64 outSize
);
199 /* Returns: result. (result != SZ_OK) means break.
200 Value (UInt64)(Int64)-1 for size means unknown value. */
205 void *(*Alloc
)(void *p
, size_t size
);
206 void (*Free
)(void *p
, void *address
); /* address can be 0 */
209 #define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
210 #define IAlloc_Free(p, a) (p)->Free((p), a)