Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: third_party/lzma_sdk/Types.h

Issue 10025017: [OTS] Add lzma_sdk (Closed) Base URL: http://ots.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/lzma_sdk/README.ots ('k') | third_party/lzma_sdk/lzma_sdk.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /* Types.h -- Basic types
2 2010-10-09 : Igor Pavlov : Public domain */
3
4 #ifndef __7Z_TYPES_H
5 #define __7Z_TYPES_H
6
7 #include <stddef.h>
8
9 #ifdef _WIN32
10 #include <windows.h>
11 #endif
12
13 namespace ots {
14 namespace lzma {
15
16 #define SZ_OK 0
17
18 #define SZ_ERROR_DATA 1
19 #define SZ_ERROR_MEM 2
20 #define SZ_ERROR_CRC 3
21 #define SZ_ERROR_UNSUPPORTED 4
22 #define SZ_ERROR_PARAM 5
23 #define SZ_ERROR_INPUT_EOF 6
24 #define SZ_ERROR_OUTPUT_EOF 7
25 #define SZ_ERROR_READ 8
26 #define SZ_ERROR_WRITE 9
27 #define SZ_ERROR_PROGRESS 10
28 #define SZ_ERROR_FAIL 11
29 #define SZ_ERROR_THREAD 12
30
31 #define SZ_ERROR_ARCHIVE 16
32 #define SZ_ERROR_NO_ARCHIVE 17
33
34 typedef int SRes;
35
36 #ifdef _WIN32
37 typedef DWORD WRes;
38 #else
39 typedef int WRes;
40 #endif
41
42 #ifndef RINOK
43 #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
44 #endif
45
46 typedef unsigned char Byte;
47 typedef short Int16;
48 typedef unsigned short UInt16;
49
50 #ifdef _LZMA_UINT32_IS_ULONG
51 typedef long Int32;
52 typedef unsigned long UInt32;
53 #else
54 typedef int Int32;
55 typedef unsigned int UInt32;
56 #endif
57
58 #ifdef _SZ_NO_INT_64
59
60 /* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
61 NOTES: Some code will work incorrectly in that case! */
62
63 typedef long Int64;
64 typedef unsigned long UInt64;
65
66 #else
67
68 #if defined(_MSC_VER) || defined(__BORLANDC__)
69 typedef __int64 Int64;
70 typedef unsigned __int64 UInt64;
71 #define UINT64_CONST(n) n
72 #else
73 typedef long long int Int64;
74 typedef unsigned long long int UInt64;
75 #define UINT64_CONST(n) n ## ULL
76 #endif
77
78 #endif
79
80 #ifdef _LZMA_NO_SYSTEM_SIZE_T
81 typedef UInt32 SizeT;
82 #else
83 typedef size_t SizeT;
84 #endif
85
86 typedef int Bool;
87 #define True 1
88 #define False 0
89
90
91 #ifdef _WIN32
92 #define MY_STD_CALL __stdcall
93 #else
94 #define MY_STD_CALL
95 #endif
96
97 #ifdef _MSC_VER
98
99 #if _MSC_VER >= 1300
100 #define MY_NO_INLINE __declspec(noinline)
101 #else
102 #define MY_NO_INLINE
103 #endif
104
105 #define MY_CDECL __cdecl
106 #define MY_FAST_CALL __fastcall
107
108 #else
109
110 #define MY_CDECL
111 #define MY_FAST_CALL
112
113 #endif
114
115
116 /* The following interfaces use first parameter as pointer to structure */
117
118 typedef struct
119 {
120 Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */
121 } IByteIn;
122
123 typedef struct
124 {
125 void (*Write)(void *p, Byte b);
126 } IByteOut;
127
128 typedef struct
129 {
130 SRes (*Read)(void *p, void *buf, size_t *size);
131 /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
132 (output(*size) < input(*size)) is allowed */
133 } ISeqInStream;
134
135 /* it can return SZ_ERROR_INPUT_EOF */
136 SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
137 SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorT ype);
138 SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
139
140 typedef struct
141 {
142 size_t (*Write)(void *p, const void *buf, size_t size);
143 /* Returns: result - the number of actually written bytes.
144 (result < size) means error */
145 } ISeqOutStream;
146
147 typedef enum
148 {
149 SZ_SEEK_SET = 0,
150 SZ_SEEK_CUR = 1,
151 SZ_SEEK_END = 2
152 } ESzSeek;
153
154 typedef struct
155 {
156 SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
157 SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
158 } ISeekInStream;
159
160 typedef struct
161 {
162 SRes (*Look)(void *p, const void **buf, size_t *size);
163 /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
164 (output(*size) > input(*size)) is not allowed
165 (output(*size) < input(*size)) is allowed */
166 SRes (*Skip)(void *p, size_t offset);
167 /* offset must be <= output(*size) of Look */
168
169 SRes (*Read)(void *p, void *buf, size_t *size);
170 /* reads directly (without buffer). It's same as ISeqInStream::Read */
171 SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
172 } ILookInStream;
173
174 SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
175 SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
176
177 /* reads via ILookInStream::Read */
178 SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes erro rType);
179 SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
180
181 #define LookToRead_BUF_SIZE (1 << 14)
182
183 typedef struct
184 {
185 ILookInStream s;
186 ISeekInStream *realStream;
187 size_t pos;
188 size_t size;
189 Byte buf[LookToRead_BUF_SIZE];
190 } CLookToRead;
191
192 void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
193 void LookToRead_Init(CLookToRead *p);
194
195 typedef struct
196 {
197 ISeqInStream s;
198 ILookInStream *realStream;
199 } CSecToLook;
200
201 void SecToLook_CreateVTable(CSecToLook *p);
202
203 typedef struct
204 {
205 ISeqInStream s;
206 ILookInStream *realStream;
207 } CSecToRead;
208
209 void SecToRead_CreateVTable(CSecToRead *p);
210
211 typedef struct
212 {
213 SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
214 /* Returns: result. (result != SZ_OK) means break.
215 Value (UInt64)(Int64)-1 for size means unknown value. */
216 } ICompressProgress;
217
218 typedef struct
219 {
220 void *(*Alloc)(void *p, size_t size);
221 void (*Free)(void *p, void *address); /* address can be 0 */
222 } ISzAlloc;
223
224 #define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
225 #define IAlloc_Free(p, a) (p)->Free((p), a)
226
227 #ifdef _WIN32
228
229 #define CHAR_PATH_SEPARATOR '\\'
230 #define WCHAR_PATH_SEPARATOR L'\\'
231 #define STRING_PATH_SEPARATOR "\\"
232 #define WSTRING_PATH_SEPARATOR L"\\"
233
234 #else
235
236 #define CHAR_PATH_SEPARATOR '/'
237 #define WCHAR_PATH_SEPARATOR L'/'
238 #define STRING_PATH_SEPARATOR "/"
239 #define WSTRING_PATH_SEPARATOR L"/"
240
241 #endif
242
243 } // namespace lzma
244 } // namespace ots
245
246 #endif
OLDNEW
« no previous file with comments | « third_party/lzma_sdk/README.ots ('k') | third_party/lzma_sdk/lzma_sdk.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698