~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to libclamav/7z/Types.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Types.h -- Basic types
2
 
2008-11-23 : 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
 
/* aCaB -- lame workaround for "Byte" refef */
14
 
#include <zconf.h>
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
 
/* aCaB -- use Byte defined in zconf.h
47
 
typedef unsigned char Byte;
48
 
*/
49
 
typedef short Int16;
50
 
typedef unsigned short UInt16;
51
 
 
52
 
#ifdef _LZMA_UINT32_IS_ULONG
53
 
typedef long Int32;
54
 
typedef unsigned long UInt32;
55
 
#else
56
 
typedef int Int32;
57
 
typedef unsigned int UInt32;
58
 
#endif
59
 
 
60
 
#ifdef _SZ_NO_INT_64
61
 
 
62
 
/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
63
 
   NOTES: Some code will work incorrectly in that case! */
64
 
 
65
 
typedef long Int64;
66
 
typedef unsigned long UInt64;
67
 
 
68
 
#else
69
 
 
70
 
#if defined(_MSC_VER) || defined(__BORLANDC__)
71
 
typedef __int64 Int64;
72
 
typedef unsigned __int64 UInt64;
73
 
#else
74
 
typedef long long int Int64;
75
 
typedef unsigned long long int UInt64;
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 _MSC_VER
92
 
 
93
 
#if _MSC_VER >= 1300
94
 
#define MY_NO_INLINE __declspec(noinline)
95
 
#else
96
 
#define MY_NO_INLINE
97
 
#endif
98
 
 
99
 
#define MY_CDECL __cdecl
100
 
#define MY_STD_CALL __stdcall
101
 
#define MY_FAST_CALL MY_NO_INLINE __fastcall
102
 
 
103
 
#else
104
 
 
105
 
#define MY_CDECL
106
 
#define MY_STD_CALL
107
 
#define MY_FAST_CALL
108
 
 
109
 
#endif
110
 
 
111
 
 
112
 
/* The following interfaces use first parameter as pointer to structure */
113
 
 
114
 
typedef struct
115
 
{
116
 
  SRes (*Read)(void *p, void *buf, size_t *size);
117
 
    /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
118
 
       (output(*size) < input(*size)) is allowed */
119
 
} ISeqInStream;
120
 
 
121
 
/* it can return SZ_ERROR_INPUT_EOF */
122
 
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
123
 
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
124
 
SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
125
 
 
126
 
typedef struct
127
 
{
128
 
  size_t (*Write)(void *p, const void *buf, size_t size);
129
 
    /* Returns: result - the number of actually written bytes.
130
 
       (result < size) means error */
131
 
} ISeqOutStream;
132
 
 
133
 
typedef enum
134
 
{
135
 
  SZ_SEEK_SET = 0,
136
 
  SZ_SEEK_CUR = 1,
137
 
  SZ_SEEK_END = 2
138
 
} ESzSeek;
139
 
 
140
 
typedef struct
141
 
{
142
 
  SRes (*Read)(void *p, void *buf, size_t *size);  /* same as ISeqInStream::Read */
143
 
  SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
144
 
} ISeekInStream;
145
 
 
146
 
typedef struct
147
 
{
148
 
  SRes (*Look)(void *p, void **buf, size_t *size);
149
 
    /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
150
 
       (output(*size) > input(*size)) is not allowed
151
 
       (output(*size) < input(*size)) is allowed */
152
 
  SRes (*Skip)(void *p, size_t offset);
153
 
    /* offset must be <= output(*size) of Look */
154
 
 
155
 
  SRes (*Read)(void *p, void *buf, size_t *size);
156
 
    /* reads directly (without buffer). It's same as ISeqInStream::Read */
157
 
  SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
158
 
} ILookInStream;
159
 
 
160
 
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
161
 
SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
162
 
 
163
 
/* reads via ILookInStream::Read */
164
 
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
165
 
SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
166
 
 
167
 
#define LookToRead_BUF_SIZE (1 << 14)
168
 
 
169
 
typedef struct
170
 
{
171
 
  ILookInStream s;
172
 
  ISeekInStream *realStream;
173
 
  size_t pos;
174
 
  size_t size;
175
 
  Byte buf[LookToRead_BUF_SIZE];
176
 
} CLookToRead;
177
 
 
178
 
void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
179
 
void LookToRead_Init(CLookToRead *p);
180
 
 
181
 
typedef struct
182
 
{
183
 
  ISeqInStream s;
184
 
  ILookInStream *realStream;
185
 
} CSecToLook;
186
 
 
187
 
void SecToLook_CreateVTable(CSecToLook *p);
188
 
 
189
 
typedef struct
190
 
{
191
 
  ISeqInStream s;
192
 
  ILookInStream *realStream;
193
 
} CSecToRead;
194
 
 
195
 
void SecToRead_CreateVTable(CSecToRead *p);
196
 
 
197
 
typedef struct
198
 
{
199
 
  SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
200
 
    /* Returns: result. (result != SZ_OK) means break.
201
 
       Value (UInt64)(Int64)-1 for size means unknown value. */
202
 
} ICompressProgress;
203
 
 
204
 
typedef struct
205
 
{
206
 
  void *(*Alloc)(void *p, size_t size);
207
 
  void (*Free)(void *p, void *address); /* address can be 0 */
208
 
} ISzAlloc;
209
 
 
210
 
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
211
 
#define IAlloc_Free(p, a) (p)->Free((p), a)
212
 
 
213
 
#endif