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