Mercurial > vba-linux
diff src/win32/7zip/7z/C/Types.h @ 1:f9f4f1b99eed
importing src directory
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 03 Mar 2012 10:31:27 -0600 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/win32/7zip/7z/C/Types.h Sat Mar 03 10:31:27 2012 -0600 1.3 @@ -0,0 +1,208 @@ 1.4 +/* Types.h -- Basic types 1.5 +2008-11-23 : Igor Pavlov : Public domain */ 1.6 + 1.7 +#ifndef __7Z_TYPES_H 1.8 +#define __7Z_TYPES_H 1.9 + 1.10 +#include <stddef.h> 1.11 + 1.12 +#ifdef _WIN32 1.13 +#include <windows.h> 1.14 +#endif 1.15 + 1.16 +#define SZ_OK 0 1.17 + 1.18 +#define SZ_ERROR_DATA 1 1.19 +#define SZ_ERROR_MEM 2 1.20 +#define SZ_ERROR_CRC 3 1.21 +#define SZ_ERROR_UNSUPPORTED 4 1.22 +#define SZ_ERROR_PARAM 5 1.23 +#define SZ_ERROR_INPUT_EOF 6 1.24 +#define SZ_ERROR_OUTPUT_EOF 7 1.25 +#define SZ_ERROR_READ 8 1.26 +#define SZ_ERROR_WRITE 9 1.27 +#define SZ_ERROR_PROGRESS 10 1.28 +#define SZ_ERROR_FAIL 11 1.29 +#define SZ_ERROR_THREAD 12 1.30 + 1.31 +#define SZ_ERROR_ARCHIVE 16 1.32 +#define SZ_ERROR_NO_ARCHIVE 17 1.33 + 1.34 +typedef int SRes; 1.35 + 1.36 +#ifdef _WIN32 1.37 +typedef DWORD WRes; 1.38 +#else 1.39 +typedef int WRes; 1.40 +#endif 1.41 + 1.42 +#ifndef RINOK 1.43 +#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } 1.44 +#endif 1.45 + 1.46 +typedef unsigned char Byte; 1.47 +typedef short Int16; 1.48 +typedef unsigned short UInt16; 1.49 + 1.50 +#ifdef _LZMA_UINT32_IS_ULONG 1.51 +typedef long Int32; 1.52 +typedef unsigned long UInt32; 1.53 +#else 1.54 +typedef int Int32; 1.55 +typedef unsigned int UInt32; 1.56 +#endif 1.57 + 1.58 +#ifdef _SZ_NO_INT_64 1.59 + 1.60 +/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. 1.61 + NOTES: Some code will work incorrectly in that case! */ 1.62 + 1.63 +typedef long Int64; 1.64 +typedef unsigned long UInt64; 1.65 + 1.66 +#else 1.67 + 1.68 +#if defined(_MSC_VER) || defined(__BORLANDC__) 1.69 +typedef __int64 Int64; 1.70 +typedef unsigned __int64 UInt64; 1.71 +#else 1.72 +typedef long long int Int64; 1.73 +typedef unsigned long long int UInt64; 1.74 +#endif 1.75 + 1.76 +#endif 1.77 + 1.78 +#ifdef _LZMA_NO_SYSTEM_SIZE_T 1.79 +typedef UInt32 SizeT; 1.80 +#else 1.81 +typedef size_t SizeT; 1.82 +#endif 1.83 + 1.84 +typedef int Bool; 1.85 +#define True 1 1.86 +#define False 0 1.87 + 1.88 + 1.89 +#ifdef _MSC_VER 1.90 + 1.91 +#if _MSC_VER >= 1300 1.92 +#define MY_NO_INLINE __declspec(noinline) 1.93 +#else 1.94 +#define MY_NO_INLINE 1.95 +#endif 1.96 + 1.97 +#define MY_CDECL __cdecl 1.98 +#define MY_STD_CALL __stdcall 1.99 +#define MY_FAST_CALL MY_NO_INLINE __fastcall 1.100 + 1.101 +#else 1.102 + 1.103 +#define MY_CDECL 1.104 +#define MY_STD_CALL 1.105 +#define MY_FAST_CALL 1.106 + 1.107 +#endif 1.108 + 1.109 + 1.110 +/* The following interfaces use first parameter as pointer to structure */ 1.111 + 1.112 +typedef struct 1.113 +{ 1.114 + SRes (*Read)(void *p, void *buf, size_t *size); 1.115 + /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. 1.116 + (output(*size) < input(*size)) is allowed */ 1.117 +} ISeqInStream; 1.118 + 1.119 +/* it can return SZ_ERROR_INPUT_EOF */ 1.120 +SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size); 1.121 +SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType); 1.122 +SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf); 1.123 + 1.124 +typedef struct 1.125 +{ 1.126 + size_t (*Write)(void *p, const void *buf, size_t size); 1.127 + /* Returns: result - the number of actually written bytes. 1.128 + (result < size) means error */ 1.129 +} ISeqOutStream; 1.130 + 1.131 +typedef enum 1.132 +{ 1.133 + SZ_SEEK_SET = 0, 1.134 + SZ_SEEK_CUR = 1, 1.135 + SZ_SEEK_END = 2 1.136 +} ESzSeek; 1.137 + 1.138 +typedef struct 1.139 +{ 1.140 + SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */ 1.141 + SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); 1.142 +} ISeekInStream; 1.143 + 1.144 +typedef struct 1.145 +{ 1.146 + SRes (*Look)(void *p, void **buf, size_t *size); 1.147 + /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. 1.148 + (output(*size) > input(*size)) is not allowed 1.149 + (output(*size) < input(*size)) is allowed */ 1.150 + SRes (*Skip)(void *p, size_t offset); 1.151 + /* offset must be <= output(*size) of Look */ 1.152 + 1.153 + SRes (*Read)(void *p, void *buf, size_t *size); 1.154 + /* reads directly (without buffer). It's same as ISeqInStream::Read */ 1.155 + SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); 1.156 +} ILookInStream; 1.157 + 1.158 +SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size); 1.159 +SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset); 1.160 + 1.161 +/* reads via ILookInStream::Read */ 1.162 +SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType); 1.163 +SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size); 1.164 + 1.165 +#define LookToRead_BUF_SIZE (1 << 14) 1.166 + 1.167 +typedef struct 1.168 +{ 1.169 + ILookInStream s; 1.170 + ISeekInStream *realStream; 1.171 + size_t pos; 1.172 + size_t size; 1.173 + Byte buf[LookToRead_BUF_SIZE]; 1.174 +} CLookToRead; 1.175 + 1.176 +void LookToRead_CreateVTable(CLookToRead *p, int lookahead); 1.177 +void LookToRead_Init(CLookToRead *p); 1.178 + 1.179 +typedef struct 1.180 +{ 1.181 + ISeqInStream s; 1.182 + ILookInStream *realStream; 1.183 +} CSecToLook; 1.184 + 1.185 +void SecToLook_CreateVTable(CSecToLook *p); 1.186 + 1.187 +typedef struct 1.188 +{ 1.189 + ISeqInStream s; 1.190 + ILookInStream *realStream; 1.191 +} CSecToRead; 1.192 + 1.193 +void SecToRead_CreateVTable(CSecToRead *p); 1.194 + 1.195 +typedef struct 1.196 +{ 1.197 + SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize); 1.198 + /* Returns: result. (result != SZ_OK) means break. 1.199 + Value (UInt64)(Int64)-1 for size means unknown value. */ 1.200 +} ICompressProgress; 1.201 + 1.202 +typedef struct 1.203 +{ 1.204 + void *(*Alloc)(void *p, size_t size); 1.205 + void (*Free)(void *p, void *address); /* address can be 0 */ 1.206 +} ISzAlloc; 1.207 + 1.208 +#define IAlloc_Alloc(p, size) (p)->Alloc((p), size) 1.209 +#define IAlloc_Free(p, a) (p)->Free((p), a) 1.210 + 1.211 +#endif