Evince
Evince is a document viewer capable of displaying multiple and single page document formats like PDF and Postscript.
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
7zTypes.h
Go to the documentation of this file.
1
/* 7zTypes.h -- Basic types
2
2017-04-03 : 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
#include <stddef.h>
12
13
#ifndef EXTERN_C_BEGIN
14
#ifdef __cplusplus
15
#define EXTERN_C_BEGIN extern "C" {
16
#define EXTERN_C_END }
17
#else
18
#define EXTERN_C_BEGIN
19
#define EXTERN_C_END
20
#endif
21
#endif
22
23
EXTERN_C_BEGIN
24
25
#define SZ_OK 0
26
27
#define SZ_ERROR_DATA 1
28
#define SZ_ERROR_MEM 2
29
#define SZ_ERROR_CRC 3
30
#define SZ_ERROR_UNSUPPORTED 4
31
#define SZ_ERROR_PARAM 5
32
#define SZ_ERROR_INPUT_EOF 6
33
#define SZ_ERROR_OUTPUT_EOF 7
34
#define SZ_ERROR_READ 8
35
#define SZ_ERROR_WRITE 9
36
#define SZ_ERROR_PROGRESS 10
37
#define SZ_ERROR_FAIL 11
38
#define SZ_ERROR_THREAD 12
39
40
#define SZ_ERROR_ARCHIVE 16
41
#define SZ_ERROR_NO_ARCHIVE 17
42
43
typedef
int
SRes
;
44
45
#ifdef _WIN32
46
/* typedef DWORD WRes; */
47
typedef
unsigned
WRes
;
48
#else
49
typedef
int
WRes
;
50
#endif
51
52
#ifndef RINOK
53
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
54
#endif
55
56
typedef
unsigned
char
Byte
;
57
typedef
short
Int16
;
58
typedef
unsigned
short
UInt16
;
59
60
#ifdef _LZMA_UINT32_IS_ULONG
61
typedef
long
Int32
;
62
typedef
unsigned
long
UInt32
;
63
#else
64
typedef
int
Int32
;
65
typedef
unsigned
int
UInt32
;
66
#endif
67
68
#ifdef _SZ_NO_INT_64
69
70
/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
71
NOTES: Some code will work incorrectly in that case! */
72
73
typedef
long
Int64
;
74
typedef
unsigned
long
UInt64
;
75
76
#else
77
78
#if defined(_MSC_VER) || defined(__BORLANDC__)
79
typedef
__int64
Int64
;
80
typedef
unsigned
__int64
UInt64
;
81
#define UINT64_CONST(n) n
82
#else
83
typedef
long
long
int
Int64
;
84
typedef
unsigned
long
long
int
UInt64
;
85
#define UINT64_CONST(n) n ## ULL
86
#endif
87
88
#endif
89
90
#ifdef _LZMA_NO_SYSTEM_SIZE_T
91
typedef
UInt32
SizeT
;
92
#else
93
typedef
size_t
SizeT
;
94
#endif
95
96
typedef
int
Bool
;
97
#define True 1
98
#define False 0
99
100
101
#ifdef _WIN32
102
#define MY_STD_CALL __stdcall
103
#else
104
#define MY_STD_CALL
105
#endif
106
107
#ifdef _MSC_VER
108
109
#if _MSC_VER >= 1300
110
#define MY_NO_INLINE __declspec(noinline)
111
#else
112
#define MY_NO_INLINE
113
#endif
114
115
#define MY_FORCE_INLINE __forceinline
116
117
#define MY_CDECL __cdecl
118
#define MY_FAST_CALL __fastcall
119
120
#else
121
122
#define MY_NO_INLINE
123
#define MY_FORCE_INLINE
124
#define MY_CDECL
125
#define MY_FAST_CALL
126
127
/* inline keyword : for C++ / C99 */
128
129
/* GCC, clang: */
130
/*
131
#if defined (__GNUC__) && (__GNUC__ >= 4)
132
#define MY_FORCE_INLINE __attribute__((always_inline))
133
#define MY_NO_INLINE __attribute__((noinline))
134
#endif
135
*/
136
137
#endif
138
139
140
/* The following interfaces use first parameter as pointer to structure */
141
142
typedef
struct
IByteIn
IByteIn
;
143
struct
IByteIn
144
{
145
Byte
(*
Read
)(
const
IByteIn
*p);
/* reads one byte, returns 0 in case of EOF or error */
146
};
147
#define IByteIn_Read(p) (p)->Read(p)
148
149
150
typedef
struct
IByteOut
IByteOut
;
151
struct
IByteOut
152
{
153
void (*
Write
)(
const
IByteOut
*p,
Byte
b);
154
};
155
#define IByteOut_Write(p, b) (p)->Write(p, b)
156
157
158
typedef
struct
ISeqInStream
ISeqInStream
;
159
struct
ISeqInStream
160
{
161
SRes
(*
Read
)(
const
ISeqInStream
*p,
void
*buf,
size_t
*
size
);
162
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
163
(output(*size) < input(*size)) is allowed */
164
};
165
#define ISeqInStream_Read(p, buf, size) (p)->Read(p, buf, size)
166
167
/* it can return SZ_ERROR_INPUT_EOF */
168
SRes
SeqInStream_Read
(
const
ISeqInStream
*stream,
void
*buf,
size_t
size);
169
SRes
SeqInStream_Read2
(
const
ISeqInStream
*stream,
void
*buf,
size_t
size,
SRes
errorType);
170
SRes
SeqInStream_ReadByte
(
const
ISeqInStream
*stream,
Byte
*buf);
171
172
173
typedef
struct
ISeqOutStream
ISeqOutStream
;
174
struct
ISeqOutStream
175
{
176
size_t (*
Write
)(
const
ISeqOutStream
*p,
const
void
*buf,
size_t
size
);
177
/* Returns: result - the number of actually written bytes.
178
(result < size) means error */
179
};
180
#define ISeqOutStream_Write(p, buf, size) (p)->Write(p, buf, size)
181
182
typedef
enum
183
{
184
SZ_SEEK_SET
= 0,
185
SZ_SEEK_CUR
= 1,
186
SZ_SEEK_END
= 2
187
}
ESzSeek
;
188
189
190
typedef
struct
ISeekInStream
ISeekInStream
;
191
struct
ISeekInStream
192
{
193
SRes
(*
Read
)(
const
ISeekInStream
*p,
void
*buf,
size_t
*
size
);
/* same as ISeqInStream::Read */
194
SRes
(*
Seek
)(
const
ISeekInStream
*p,
Int64
*pos,
ESzSeek
origin);
195
};
196
#define ISeekInStream_Read(p, buf, size) (p)->Read(p, buf, size)
197
#define ISeekInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
198
199
200
typedef
struct
ILookInStream
ILookInStream
;
201
struct
ILookInStream
202
{
203
SRes
(*
Look
)(
const
ILookInStream
*p,
const
void
**buf,
size_t
*
size
);
204
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
205
(output(*size) > input(*size)) is not allowed
206
(output(*size) < input(*size)) is allowed */
207
SRes
(*
Skip
)(
const
ILookInStream
*p,
size_t
offset);
208
/* offset must be <= output(*size) of Look */
209
210
SRes
(*
Read
)(
const
ILookInStream
*p,
void
*buf,
size_t
*
size
);
211
/* reads directly (without buffer). It's same as ISeqInStream::Read */
212
SRes
(*
Seek
)(
const
ILookInStream
*p,
Int64
*pos,
ESzSeek
origin);
213
};
214
215
#define ILookInStream_Look(p, buf, size) (p)->Look(p, buf, size)
216
#define ILookInStream_Skip(p, offset) (p)->Skip(p, offset)
217
#define ILookInStream_Read(p, buf, size) (p)->Read(p, buf, size)
218
#define ILookInStream_Seek(p, pos, origin) (p)->Seek(p, pos, origin)
219
220
221
SRes
LookInStream_LookRead
(
const
ILookInStream
*stream,
void
*buf,
size_t
*size);
222
SRes
LookInStream_SeekTo
(
const
ILookInStream
*stream,
UInt64
offset);
223
224
/* reads via ILookInStream::Read */
225
SRes
LookInStream_Read2
(
const
ILookInStream
*stream,
void
*buf,
size_t
size,
SRes
errorType);
226
SRes
LookInStream_Read
(
const
ILookInStream
*stream,
void
*buf,
size_t
size);
227
228
229
230
typedef
struct
231
{
232
ILookInStream
vt
;
233
const
ISeekInStream
*
realStream
;
234
235
size_t
pos
;
236
size_t
size
;
/* it's data size */
237
238
/* the following variables must be set outside */
239
Byte
*
buf
;
240
size_t
bufSize
;
241
}
CLookToRead2
;
242
243
void
LookToRead2_CreateVTable
(
CLookToRead2
*p,
int
lookahead);
244
245
#define LookToRead2_Init(p) { (p)->pos = (p)->size = 0; }
246
247
248
typedef
struct
249
{
250
ISeqInStream
vt
;
251
const
ILookInStream
*
realStream
;
252
}
CSecToLook
;
253
254
void
SecToLook_CreateVTable
(
CSecToLook
*p);
255
256
257
258
typedef
struct
259
{
260
ISeqInStream
vt
;
261
const
ILookInStream
*
realStream
;
262
}
CSecToRead
;
263
264
void
SecToRead_CreateVTable
(
CSecToRead
*p);
265
266
267
typedef
struct
ICompressProgress
ICompressProgress
;
268
269
struct
ICompressProgress
270
{
271
SRes
(*
Progress
)(
const
ICompressProgress
*p,
UInt64
inSize,
UInt64
outSize);
272
/* Returns: result. (result != SZ_OK) means break.
273
Value (UInt64)(Int64)-1 for size means unknown value. */
274
};
275
#define ICompressProgress_Progress(p, inSize, outSize) (p)->Progress(p, inSize, outSize)
276
277
278
279
typedef
struct
ISzAlloc
ISzAlloc
;
280
typedef
const
ISzAlloc
*
ISzAllocPtr
;
281
282
struct
ISzAlloc
283
{
284
void
*(*Alloc)(
ISzAllocPtr
p,
size_t
size
);
285
void (*
Free
)(
ISzAllocPtr
p,
void
*address);
/* address can be 0 */
286
};
287
288
#define ISzAlloc_Alloc(p, size) (p)->Alloc(p, size)
289
#define ISzAlloc_Free(p, a) (p)->Free(p, a)
290
291
/* deprecated */
292
#define IAlloc_Alloc(p, size) ISzAlloc_Alloc(p, size)
293
#define IAlloc_Free(p, a) ISzAlloc_Free(p, a)
294
295
296
297
298
299
#ifndef MY_offsetof
300
#ifdef offsetof
301
#define MY_offsetof(type, m) offsetof(type, m)
302
/*
303
#define MY_offsetof(type, m) FIELD_OFFSET(type, m)
304
*/
305
#else
306
#define MY_offsetof(type, m) ((size_t)&(((type *)0)->m))
307
#endif
308
#endif
309
310
311
312
#ifndef MY_container_of
313
314
/*
315
#define MY_container_of(ptr, type, m) container_of(ptr, type, m)
316
#define MY_container_of(ptr, type, m) CONTAINING_RECORD(ptr, type, m)
317
#define MY_container_of(ptr, type, m) ((type *)((char *)(ptr) - offsetof(type, m)))
318
#define MY_container_of(ptr, type, m) (&((type *)0)->m == (ptr), ((type *)(((char *)(ptr)) - MY_offsetof(type, m))))
319
*/
320
321
/*
322
GCC shows warning: "perhaps the 'offsetof' macro was used incorrectly"
323
GCC 3.4.4 : classes with constructor
324
GCC 4.8.1 : classes with non-public variable members"
325
*/
326
327
#define MY_container_of(ptr, type, m) ((type *)((char *)(1 ? (ptr) : &((type *)0)->m) - MY_offsetof(type, m)))
328
329
330
#endif
331
332
#define CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m) ((type *)(ptr))
333
334
/*
335
#define CONTAINER_FROM_VTBL(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
336
*/
337
#define CONTAINER_FROM_VTBL(ptr, type, m) MY_container_of(ptr, type, m)
338
339
#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
340
/*
341
#define CONTAINER_FROM_VTBL_CLS(ptr, type, m) CONTAINER_FROM_VTBL(ptr, type, m)
342
*/
343
344
345
346
#ifdef _WIN32
347
348
#define CHAR_PATH_SEPARATOR '\\'
349
#define WCHAR_PATH_SEPARATOR L'\\'
350
#define STRING_PATH_SEPARATOR "\\"
351
#define WSTRING_PATH_SEPARATOR L"\\"
352
353
#else
354
355
#define CHAR_PATH_SEPARATOR '/'
356
#define WCHAR_PATH_SEPARATOR L'/'
357
#define STRING_PATH_SEPARATOR "/"
358
#define WSTRING_PATH_SEPARATOR L"/"
359
360
#endif
361
362
EXTERN_C_END
363
364
#endif
evince-master
cut-n-paste
unarr
lzmasdk
7zTypes.h
Generated on Thu Jul 13 2017 13:41:45 for Evince by
1.8.4