LzmaTypes.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (c) 1999-2008 Igor Pavlov
  4. * Copyright (C) 2008 Free Software Foundation, Inc.
  5. *
  6. * GRUB is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * GRUB is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /*
  20. * This code was taken from LZMA SDK 4.58 beta, and was slightly modified
  21. * to adapt it to GRUB's requirement.
  22. *
  23. * See <http://www.7-zip.org>, for more information about LZMA.
  24. */
  25. #ifndef __7Z_TYPES_H
  26. #define __7Z_TYPES_H
  27. #define SZ_OK 0
  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. #define SZ_ERROR_ARCHIVE 16
  41. #define SZ_ERROR_NO_ARCHIVE 17
  42. typedef int SRes;
  43. #ifndef RINOK
  44. #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
  45. #endif
  46. typedef unsigned char Byte;
  47. typedef short Int16;
  48. typedef unsigned short UInt16;
  49. #ifdef _LZMA_UINT32_IS_ULONG
  50. typedef long Int32;
  51. typedef unsigned long UInt32;
  52. #else
  53. typedef int Int32;
  54. typedef unsigned int UInt32;
  55. #endif
  56. /* #define _SZ_NO_INT_64 */
  57. /* define it if your compiler doesn't support 64-bit integers */
  58. #ifdef _SZ_NO_INT_64
  59. typedef long Int64;
  60. typedef unsigned long UInt64;
  61. #else
  62. #if defined(_MSC_VER) || defined(__BORLANDC__)
  63. typedef __int64 Int64;
  64. typedef unsigned __int64 UInt64;
  65. #else
  66. typedef long long int Int64;
  67. typedef unsigned long long int UInt64;
  68. #endif
  69. #endif
  70. #ifdef _LZMA_NO_SYSTEM_SIZE_T
  71. typedef UInt32 SizeT;
  72. #else
  73. #include <stddef.h>
  74. typedef size_t SizeT;
  75. #endif
  76. typedef int Bool;
  77. #define True 1
  78. #define False 0
  79. #ifdef _MSC_VER
  80. #if _MSC_VER >= 1300
  81. #define MY_NO_INLINE __declspec(noinline)
  82. #else
  83. #define MY_NO_INLINE
  84. #endif
  85. #define MY_CDECL __cdecl
  86. #define MY_STD_CALL __stdcall
  87. #define MY_FAST_CALL MY_NO_INLINE __fastcall
  88. #else
  89. #define MY_CDECL
  90. #define MY_STD_CALL
  91. #define MY_FAST_CALL
  92. #endif
  93. /* The following interfaces use first parameter as pointer to structure */
  94. typedef struct
  95. {
  96. SRes (*Read)(void *p, void *buf, size_t *size);
  97. /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
  98. (output(*size) < input(*size)) is allowed */
  99. } ISeqInStream;
  100. typedef struct
  101. {
  102. size_t (*Write)(void *p, const void *buf, size_t size);
  103. /* Returns: result - the number of actually written bytes.
  104. (result < size) means error */
  105. } ISeqOutStream;
  106. typedef struct
  107. {
  108. SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
  109. /* Returns: result. (result != SZ_OK) means break.
  110. Value (UInt64)(Int64)-1 for size means unknown value. */
  111. } ICompressProgress;
  112. typedef struct
  113. {
  114. void *(*Alloc)(void *p, size_t size);
  115. void (*Free)(void *p, void *address); /* address can be 0 */
  116. } ISzAlloc;
  117. #define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
  118. #define IAlloc_Free(p, a) (p)->Free((p), a)
  119. #endif