RetroArch
7zTypes.h
Go to the documentation of this file.
1 /* 7zTypes.h -- Basic types
2 2013-11-12 : Igor Pavlov : Public domain */
3 
4 #ifndef __7Z_TYPES_H
5 #define __7Z_TYPES_H
6 
7 #include <stdint.h>
8 #include <stddef.h>
9 
10 #ifndef EXTERN_C_BEGIN
11 #ifdef __cplusplus
12 #define EXTERN_C_BEGIN extern "C" {
13 #define EXTERN_C_END }
14 #else
15 #define EXTERN_C_BEGIN
16 #define EXTERN_C_END
17 #endif
18 #endif
19 
21 
22 #ifndef _7ZIP_ST
23 #define _7ZIP_ST
24 #endif
25 
26 #define SZ_OK 0
27 
28 #define SZ_ERROR_DATA 1
29 #define SZ_ERROR_MEM 2
30 #define SZ_ERROR_CRC 3
31 #define SZ_ERROR_UNSUPPORTED 4
32 #define SZ_ERROR_PARAM 5
33 #define SZ_ERROR_INPUT_EOF 6
34 #define SZ_ERROR_OUTPUT_EOF 7
35 #define SZ_ERROR_READ 8
36 #define SZ_ERROR_WRITE 9
37 #define SZ_ERROR_PROGRESS 10
38 #define SZ_ERROR_FAIL 11
39 #define SZ_ERROR_THREAD 12
40 
41 #define SZ_ERROR_ARCHIVE 16
42 #define SZ_ERROR_NO_ARCHIVE 17
43 
44 typedef int SRes;
45 
46 #ifdef _WIN32
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 #ifdef _MSC_VER
57 #define MY_FAST_CALL __fastcall
58 #else
59 #define MY_FAST_CALL
60 #endif
61 
62 /* The following interfaces use first parameter as pointer to structure */
63 
64 typedef struct
65 {
66  unsigned char (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */
67 } IByteIn;
68 
69 typedef struct
70 {
71  void (*Write)(void *p, unsigned char b);
72 } IByteOut;
73 
74 typedef struct
75 {
76  SRes (*Read)(void *p, void *buf, size_t *size);
77  /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
78  (output(*size) < input(*size)) is allowed */
79 } ISeqInStream;
80 
81 /* it can return SZ_ERROR_INPUT_EOF */
83 SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
85 
86 typedef struct
87 {
88  size_t (*Write)(void *p, const void *buf, size_t size);
89  /* Returns: result - the number of actually written bytes.
90  (result < size) means error */
92 
93 typedef enum
94 {
98 } ESzSeek;
99 
100 typedef struct
101 {
102  SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
103  SRes (*Seek)(void *p, int64_t *pos, ESzSeek origin);
104 } ISeekInStream;
105 
106 typedef struct
107 {
108  SRes (*Look)(void *p, const void **buf, size_t *size);
109  /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
110  (output(*size) > input(*size)) is not allowed
111  (output(*size) < input(*size)) is allowed */
112  SRes (*Skip)(void *p, size_t offset);
113  /* offset must be <= output(*size) of Look */
114 
115  SRes (*Read)(void *p, void *buf, size_t *size);
116  /* reads directly (without buffer). It's same as ISeqInStream::Read */
117  SRes (*Seek)(void *p, int64_t *pos, ESzSeek origin);
118 } ILookInStream;
119 
122 
123 /* reads via ILookInStream::Read */
124 SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
126 
127 #define LookToRead_BUF_SIZE (1 << 14)
128 
129 typedef struct
130 {
133  size_t pos;
134  size_t size;
135  unsigned char buf[LookToRead_BUF_SIZE];
136 } CLookToRead;
137 
138 void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
140 
141 typedef struct
142 {
145 } CSecToLook;
146 
148 
149 typedef struct
150 {
153 } CSecToRead;
154 
156 
157 typedef struct
158 {
159  SRes (*Progress)(void *p, uint64_t inSize, uint64_t outSize);
161 
162 typedef struct
163 {
164  void *(*Alloc)(void *p, size_t size);
165  void (*Free)(void *p, void *address); /* address can be 0 */
166 } ISzAlloc;
167 
168 #define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
169 #define IAlloc_Free(p, a) (p)->Free((p), a)
170 
172 
173 #endif
Definition: 7zTypes.h:162
Definition: 7zTypes.h:96
ISeqInStream s
Definition: 7zTypes.h:151
SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size)
Definition: 7zStream.c:68
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType)
Definition: 7zStream.c:54
ILookInStream * realStream
Definition: 7zTypes.h:144
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:8418
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType)
Definition: 7zStream.c:12
GLuint address
Definition: glext.h:10300
Definition: 7zTypes.h:100
int WRes
Definition: 7zTypes.h:49
Definition: 7zTypes.h:69
GLsizeiptr size
Definition: glext.h:6559
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size)
Definition: 7zStream.c:26
ISeekInStream * realStream
Definition: 7zTypes.h:132
size_t size
Definition: 7zTypes.h:134
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
void SecToRead_CreateVTable(CSecToRead *p)
Definition: 7zStream.c:170
Definition: 7zTypes.h:86
Definition: 7zTypes.h:64
GLboolean GLboolean GLboolean b
Definition: glext.h:6844
void SecToLook_CreateVTable(CSecToLook *p)
Definition: 7zStream.c:159
ISeqInStream s
Definition: 7zTypes.h:143
#define EXTERN_C_END
Definition: 7zTypes.h:16
int SRes
Definition: 7zTypes.h:44
Definition: 7zTypes.h:141
void LookToRead_Init(CLookToRead *p)
Definition: 7zStream.c:148
SRes SeqInStream_ReadByte(ISeqInStream *stream, unsigned char *buf)
ILookInStream s
Definition: 7zTypes.h:131
GLfloat GLfloat p
Definition: glext.h:9809
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size)
Definition: 7zStream.c:44
GLuint GLuint stream
Definition: glext.h:8189
size_t pos
Definition: 7zTypes.h:133
Definition: 7zTypes.h:157
signed __int64 int64_t
Definition: stdint.h:135
Definition: 7zTypes.h:129
#define EXTERN_C_BEGIN
Definition: 7zTypes.h:15
ESzSeek
Definition: 7zTypes.h:93
Definition: 7zTypes.h:95
SRes LookInStream_SeekTo(ILookInStream *stream, uint64_t offset)
Definition: 7zStream.c:38
Definition: 7zTypes.h:74
Definition: 7zTypes.h:97
GLintptr offset
Definition: glext.h:6560
#define LookToRead_BUF_SIZE
Definition: 7zTypes.h:127
Definition: 7zTypes.h:149
ILookInStream * realStream
Definition: 7zTypes.h:152
Definition: 7zTypes.h:106
unsigned __int64 uint64_t
Definition: stdint.h:136
void LookToRead_CreateVTable(CLookToRead *p, int lookahead)
Definition: 7zStream.c:138