TianoCore EDK2
master
Loading...
Searching...
No Matches
7zTypes.h
1
/* 7zTypes.h -- Basic types
2
2018-08-04 : Igor Pavlov : Public domain */
3
4
#ifndef __7Z_TYPES_H
5
#define __7Z_TYPES_H
6
7
#ifdef _WIN32
8
/* #include <windows.h> */
9
#endif
10
11
#ifdef EFIAPI
12
#include "
UefiLzma.h
"
13
#else
14
#include <stddef.h>
15
#endif
16
17
#ifndef EXTERN_C_BEGIN
18
#ifdef __cplusplus
19
#define EXTERN_C_BEGIN extern "C"
{
20
#define EXTERN_C_END }
21
#else
22
#define EXTERN_C_BEGIN
23
#define EXTERN_C_END
24
#endif
25
#endif
26
27
EXTERN_C_BEGIN
28
29
#define SZ_OK 0
30
31
#define SZ_ERROR_DATA 1
32
#define SZ_ERROR_MEM 2
33
#define SZ_ERROR_CRC 3
34
#define SZ_ERROR_UNSUPPORTED 4
35
#define SZ_ERROR_PARAM 5
36
#define SZ_ERROR_INPUT_EOF 6
37
#define SZ_ERROR_OUTPUT_EOF 7
38
#define SZ_ERROR_READ 8
39
#define SZ_ERROR_WRITE 9
40
#define SZ_ERROR_PROGRESS 10
41
#define SZ_ERROR_FAIL 11
42
#define SZ_ERROR_THREAD 12
43
44
#define SZ_ERROR_ARCHIVE 16
45
#define SZ_ERROR_NO_ARCHIVE 17
46
47
typedef
int
SRes;
48
49
#ifdef _WIN32
50
51
/* typedef DWORD WRes; */
52
typedef
unsigned
WRes;
53
#define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x)
54
55
#else
56
57
typedef
int
WRes;
58
#define MY__FACILITY_WIN32 7
59
#define MY__FACILITY__WRes MY__FACILITY_WIN32
60
#define MY_SRes_HRESULT_FROM_WRes(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (MY__FACILITY__WRes << 16) | 0x80000000)))
61
62
#endif
63
64
#ifndef RINOK
65
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
66
#endif
67
68
typedef
unsigned
char
Byte;
69
typedef
short
Int16;
70
typedef
unsigned
short
UInt16;
71
72
#ifdef _LZMA_UINT32_IS_ULONG
73
typedef
long
Int32;
74
typedef
unsigned
long
UInt32;
75
#else
76
typedef
int
Int32;
77
typedef
unsigned
int
UInt32;
78
#endif
79
80
#ifdef _SZ_NO_INT_64
81
82
/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
83
NOTES: Some code will work incorrectly in that case! */
84
85
typedef
long
Int64;
86
typedef
unsigned
long
UInt64;
87
88
#else
89
90
#if defined (_MSC_VER) || defined (__BORLANDC__)
91
typedef
__int64 Int64;
92
typedef
unsigned
__int64 UInt64;
93
#define UINT64_CONST(n) n
94
#else
95
typedef
long
long
int
Int64;
96
typedef
unsigned
long
long
int
UInt64;
97
#define UINT64_CONST(n) n ## ULL
98
#endif
99
100
#endif
101
102
#ifdef _LZMA_NO_SYSTEM_SIZE_T
103
typedef
UInt32 SizeT;
104
#else
105
typedef
size_t
SizeT;
106
#endif
107
108
typedef
int
BoolInt;
109
/* typedef BoolInt Bool; */
110
#define True 1
111
#define False 0
112
113
#ifdef _WIN32
114
#define MY_STD_CALL __stdcall
115
#else
116
#define MY_STD_CALL
117
#endif
118
119
#if defined (_MSC_VER) && !defined (__clang__)
120
121
#if _MSC_VER >= 1300
122
#define MY_NO_INLINE __declspec(noinline)
123
#else
124
#define MY_NO_INLINE
125
#endif
126
127
#define MY_FORCE_INLINE __forceinline
128
129
#define MY_CDECL __cdecl
130
#define MY_FAST_CALL __fastcall
131
132
#else
133
134
#define MY_NO_INLINE
135
#define MY_FORCE_INLINE
136
#define MY_CDECL
137
#define MY_FAST_CALL
138
139
/* inline keyword : for C++ / C99 */
140
141
/* GCC, clang: */
142
143
/*
144
#if defined (__GNUC__) && (__GNUC__ >= 4)
145
#define MY_FORCE_INLINE __attribute__((always_inline))
146
#define MY_NO_INLINE __attribute__((noinline))
147
#endif
148
*/
149
150
#endif
151
152
/* The following interfaces use first parameter as pointer to structure */
153
154
typedef
struct
IByteIn
IByteIn
;
155
struct
IByteIn
{
156
Byte (*Read)(
157
const
IByteIn
*p
158
);
/* reads one byte, returns 0 in case of EOF or error */
159
};
160
161
#define IByteIn_Read(p) (p)->Read(p)
162
163
typedef
struct
IByteOut
IByteOut
;
164
struct
IByteOut
{
165
void (*Write)(
166
const
IByteOut
*p,
167
Byte b
168
);
169
};
170
171
#define IByteOut_Write(p, b) (p)->Write(p, b)
172
173
typedef
struct
ISeqInStream
ISeqInStream
;
174
struct
ISeqInStream
{
175
SRes (*Read)(
176
const
ISeqInStream
*p,
177
void
*buf,
178
size_t
*size
179
);
180
181
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
182
(output(*size) < input(*size)) is allowed */
183
};
184
185
#define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size)
186
187
/* it can return SZ_ERROR_INPUT_EOF */
188
SRes
189
SeqInStream_Read (
190
const
ISeqInStream
*stream,
191
void
*buf,
192
size_t
size
193
);
194
195
SRes
196
SeqInStream_Read2 (
197
const
ISeqInStream
*stream,
198
void
*buf,
199
size_t
size,
200
SRes errorType
201
);
202
203
SRes
204
SeqInStream_ReadByte (
205
const
ISeqInStream
*stream,
206
Byte *buf
207
);
208
209
typedef
struct
ISeqOutStream
ISeqOutStream
;
210
struct
ISeqOutStream
{
211
size_t (*Write)(
212
const
ISeqOutStream
*p,
213
const
void
*buf,
214
size_t
size
215
);
216
217
/* Returns: result - the number of actually written bytes.
218
(result < size) means error */
219
};
220
221
#define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size)
222
223
typedef
enum
{
224
SZ_SEEK_SET = 0,
225
SZ_SEEK_CUR = 1,
226
SZ_SEEK_END = 2
227
} ESzSeek;
228
229
typedef
struct
ISeekInStream
ISeekInStream
;
230
struct
ISeekInStream
{
231
SRes (*Read)(
232
const
ISeekInStream
*p,
233
void
*buf,
234
size_t
*size
235
);
/* same as ISeqInStream::Read */
236
SRes (*Seek)(
237
const
ISeekInStream
*p,
238
Int64 *pos,
239
ESzSeek origin
240
);
241
};
242
243
#define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size)
244
#define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
245
246
typedef
struct
ILookInStream
ILookInStream
;
247
struct
ILookInStream
{
248
SRes (*Look)(
249
const
ILookInStream
*p,
250
const
void
**buf,
251
size_t
*size
252
);
253
254
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
255
(output(*size) > input(*size)) is not allowed
256
(output(*size) < input(*size)) is allowed */
257
SRes (*Skip)(
258
const
ILookInStream
*p,
259
size_t
offset
260
);
261
/* offset must be <= output(*size) of Look */
262
263
SRes (*Read)(
264
const
ILookInStream
*p,
265
void
*buf,
266
size_t
*size
267
);
268
/* reads directly (without buffer). It's same as ISeqInStream::Read */
269
SRes (*Seek)(
270
const
ILookInStream
*p,
271
Int64 *pos,
272
ESzSeek origin
273
);
274
};
275
276
#define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size)
277
#define ILookInStream_Skip(p, offset) (p)->Skip(p, offset)
278
#define ILookInStream_Read(p, buf, size) (p)->Read(p, buf, size)
279
#define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
280
281
SRes
282
LookInStream_LookRead (
283
const
ILookInStream
*stream,
284
void
*buf,
285
size_t
*size
286
);
287
288
SRes
289
LookInStream_SeekTo (
290
const
ILookInStream
*stream,
291
UInt64 offset
292
);
293
294
/* reads via ILookInStream::Read */
295
SRes
296
LookInStream_Read2 (
297
const
ILookInStream
*stream,
298
void
*buf,
299
size_t
size,
300
SRes errorType
301
);
302
303
SRes
304
LookInStream_Read (
305
const
ILookInStream
*stream,
306
void
*buf,
307
size_t
size
308
);
309
310
typedef
struct
{
311
ILookInStream
vt;
312
const
ISeekInStream
*realStream;
313
314
size_t
pos;
315
size_t
size;
/* it's data size */
316
317
/* the following variables must be set outside */
318
Byte *buf;
319
size_t
bufSize;
320
}
CLookToRead2
;
321
322
void
323
LookToRead2_CreateVTable (
324
CLookToRead2
*p,
325
int
lookahead
326
);
327
328
#define LookToRead2_Init(p) { (p)->pos = (p)->size = 0; }
329
330
typedef
struct
{
331
ISeqInStream
vt;
332
const
ILookInStream
*realStream;
333
}
CSecToLook
;
334
335
void
336
SecToLook_CreateVTable (
337
CSecToLook
*p
338
);
339
340
typedef
struct
{
341
ISeqInStream
vt;
342
const
ILookInStream
*realStream;
343
}
CSecToRead
;
344
345
void
346
SecToRead_CreateVTable (
347
CSecToRead
*p
348
);
349
350
typedef
struct
ICompressProgress
ICompressProgress
;
351
352
struct
ICompressProgress
{
353
SRes (*Progress)(
354
const
ICompressProgress
*p,
355
UInt64 inSize,
356
UInt64 outSize
357
);
358
359
/* Returns: result. (result != SZ_OK) means break.
360
Value (UInt64)(Int64)-1 for size means unknown value. */
361
};
362
363
#define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize)
364
365
typedef
struct
ISzAlloc
ISzAlloc
;
366
typedef
const
ISzAlloc
*
ISzAllocPtr
;
367
368
struct
ISzAlloc
{
369
void
*(*Alloc)(
370
ISzAllocPtr
p,
371
size_t
size
372
);
373
void (*Free)(
374
ISzAllocPtr
p,
375
void
*address
376
);
/* address can be 0 */
377
};
378
379
#define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size)
380
#define ISzAlloc_Free(p, a) (p)->Free(p, a)
381
382
/* deprecated */
383
#define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size)
384
#define IAlloc_Free(p, a) ISzAlloc_Free(p, a)
385
386
#ifndef MY_offsetof
387
#ifdef offsetof
388
#define MY_offsetof(type, m) offsetof(type, m)
389
390
/*
391
#define MY_offsetof(type, m) FIELD_OFFSET(type, m)
392
*/
393
#else
394
#define MY_offsetof(type, m) ((size_t)&(((type *)0)->m))
395
#endif
396
#endif
397
398
#ifndef MY_container_of
399
400
/*
401
#define MY_container_of(ptr, type, m) container_of(ptr, type, m)
402
#define MY_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m)
403
#define MY_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m)))
404
#define MY_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m))))
405
*/
406
407
/*
408
GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly"
409
GCC 3.4.4 : classes with constructor
410
GCC 4.8.1 : classes with non-public variable members"
411
*/
412
413
#define MY_container_of(ptr, type, m) ((type *)((char *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m)))
414
415
#endif
416
417
#define CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(ptr))
418
419
/*
420
#define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
421
*/
422
#define CONTAINER_FROM_VTBL(ptr, type, m) MY_container_of(ptr, type, m)
423
424
#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
425
426
/*
427
#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m)
428
*/
429
430
#ifdef _WIN32
431
432
#define CHAR_PATH_SEPARATOR '\\'
433
#define WCHAR_PATH_SEPARATOR L'\\'
434
#define STRING_PATH_SEPARATOR "\\"
435
#define WSTRING_PATH_SEPARATOR L"\\"
436
437
#else
438
439
#define CHAR_PATH_SEPARATOR '/'
440
#define WCHAR_PATH_SEPARATOR L'/'
441
#define STRING_PATH_SEPARATOR "/"
442
#define WSTRING_PATH_SEPARATOR L"/"
443
444
#endif
445
446
EXTERN_C_END
447
448
#endif
UefiLzma.h
CLookToRead2
Definition:
7zTypes.h:310
CSecToLook
Definition:
7zTypes.h:330
CSecToRead
Definition:
7zTypes.h:340
IByteIn
Definition:
7zTypes.h:155
IByteOut
Definition:
7zTypes.h:164
ICompressProgress
Definition:
7zTypes.h:352
ILookInStream
Definition:
7zTypes.h:247
ISeekInStream
Definition:
7zTypes.h:230
ISeqInStream
Definition:
7zTypes.h:174
ISeqOutStream
Definition:
7zTypes.h:210
ISzAlloc
Definition:
7zTypes.h:368
MdeModulePkg
Library
LzmaCustomDecompressLib
Sdk
C
7zTypes.h
Generated on Fri Nov 15 2024 18:01:11 for TianoCore EDK2 by
1.9.6