goat3d

diff libs/openctm/liblzma/Types.h @ 14:188c697b3b49

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