goat3d
view libs/openctm/liblzma/Types.h @ 46:9d911100935b
added install/uninstall targets in goatview
added load statistics in goatview
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 08 Dec 2013 03:00:25 +0200 |
parents | |
children |
line source
1 /* Types.h -- Basic types
2 2008-11-23 : Igor Pavlov : Public domain */
4 #ifndef __7Z_TYPES_H
5 #define __7Z_TYPES_H
7 #include <stddef.h>
9 #ifdef _WIN32
10 #include <windows.h>
11 #endif
13 #include "NameMangle.h"
15 #define SZ_OK 0
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
33 typedef int SRes;
35 #ifdef _WIN32
36 typedef DWORD WRes;
37 #else
38 typedef int WRes;
39 #endif
41 #ifndef RINOK
42 #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
43 #endif
45 typedef unsigned char Byte;
46 typedef short Int16;
47 typedef unsigned short UInt16;
49 #ifdef _LZMA_UINT32_IS_ULONG
50 typedef long Int32;
51 typedef unsigned long UInt32;
52 #else
53 typedef int Int32;
54 typedef unsigned int UInt32;
55 #endif
57 #ifdef _SZ_NO_INT_64
59 /* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
60 NOTES: Some code will work incorrectly in that case! */
62 typedef long Int64;
63 typedef unsigned long UInt64;
65 #else
67 #if defined(_MSC_VER) || defined(__BORLANDC__)
68 typedef __int64 Int64;
69 typedef unsigned __int64 UInt64;
70 #else
71 typedef long long int Int64;
72 typedef unsigned long long int UInt64;
73 #endif
75 #endif
77 #ifdef _LZMA_NO_SYSTEM_SIZE_T
78 typedef UInt32 SizeT;
79 #else
80 typedef size_t SizeT;
81 #endif
83 typedef int Bool;
84 #define True 1
85 #define False 0
88 #ifdef _MSC_VER
90 #if _MSC_VER >= 1300
91 #define MY_NO_INLINE __declspec(noinline)
92 #else
93 #define MY_NO_INLINE
94 #endif
96 #define MY_CDECL __cdecl
97 #define MY_STD_CALL __stdcall
98 #define MY_FAST_CALL MY_NO_INLINE __fastcall
100 #else
102 #define MY_CDECL
103 #define MY_STD_CALL
104 #define MY_FAST_CALL
106 #endif
109 /* The following interfaces use first parameter as pointer to structure */
111 typedef struct
112 {
113 SRes (*Read)(void *p, void *buf, size_t *size);
114 /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
115 (output(*size) < input(*size)) is allowed */
116 } ISeqInStream;
118 /* it can return SZ_ERROR_INPUT_EOF */
119 SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
120 SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
121 SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
123 typedef struct
124 {
125 size_t (*Write)(void *p, const void *buf, size_t size);
126 /* Returns: result - the number of actually written bytes.
127 (result < size) means error */
128 } ISeqOutStream;
130 typedef enum
131 {
132 SZ_SEEK_SET = 0,
133 SZ_SEEK_CUR = 1,
134 SZ_SEEK_END = 2
135 } ESzSeek;
137 typedef struct
138 {
139 SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
140 SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
141 } ISeekInStream;
143 typedef struct
144 {
145 SRes (*Look)(void *p, void **buf, size_t *size);
146 /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
147 (output(*size) > input(*size)) is not allowed
148 (output(*size) < input(*size)) is allowed */
149 SRes (*Skip)(void *p, size_t offset);
150 /* offset must be <= output(*size) of Look */
152 SRes (*Read)(void *p, void *buf, size_t *size);
153 /* reads directly (without buffer). It's same as ISeqInStream::Read */
154 SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
155 } ILookInStream;
157 SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
158 SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
160 /* reads via ILookInStream::Read */
161 SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
162 SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
164 #define LookToRead_BUF_SIZE (1 << 14)
166 typedef struct
167 {
168 ILookInStream s;
169 ISeekInStream *realStream;
170 size_t pos;
171 size_t size;
172 Byte buf[LookToRead_BUF_SIZE];
173 } CLookToRead;
175 void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
176 void LookToRead_Init(CLookToRead *p);
178 typedef struct
179 {
180 ISeqInStream s;
181 ILookInStream *realStream;
182 } CSecToLook;
184 void SecToLook_CreateVTable(CSecToLook *p);
186 typedef struct
187 {
188 ISeqInStream s;
189 ILookInStream *realStream;
190 } CSecToRead;
192 void SecToRead_CreateVTable(CSecToRead *p);
194 typedef struct
195 {
196 SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
197 /* Returns: result. (result != SZ_OK) means break.
198 Value (UInt64)(Int64)-1 for size means unknown value. */
199 } ICompressProgress;
201 typedef struct
202 {
203 void *(*Alloc)(void *p, size_t size);
204 void (*Free)(void *p, void *address); /* address can be 0 */
205 } ISzAlloc;
207 #define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
208 #define IAlloc_Free(p, a) (p)->Free((p), a)
210 #endif