|
||||
File indexing completed on 2024-05-18 08:30:07
0001 /** 0002 * \file api/lzma.h 0003 * \brief The public API of liblzma data compression library 0004 * 0005 * liblzma is a public domain general-purpose data compression library with 0006 * a zlib-like API. The native file format is .xz, but also the old .lzma 0007 * format and raw (no headers) streams are supported. Multiple compression 0008 * algorithms (filters) are supported. Currently LZMA2 is the primary filter. 0009 * 0010 * liblzma is part of XZ Utils <http://tukaani.org/xz/>. XZ Utils includes 0011 * a gzip-like command line tool named xz and some other tools. XZ Utils 0012 * is developed and maintained by Lasse Collin. 0013 * 0014 * Major parts of liblzma are based on Igor Pavlov's public domain LZMA SDK 0015 * <http://7-zip.org/sdk.html>. 0016 * 0017 * The SHA-256 implementation is based on the public domain code found from 0018 * 7-Zip <http://7-zip.org/>, which has a modified version of the public 0019 * domain SHA-256 code found from Crypto++ <http://www.cryptopp.com/>. 0020 * The SHA-256 code in Crypto++ was written by Kevin Springle and Wei Dai. 0021 */ 0022 0023 /* 0024 * Author: Lasse Collin 0025 * 0026 * This file has been put into the public domain. 0027 * You can do whatever you want with this file. 0028 */ 0029 0030 #ifndef LZMA_H 0031 #define LZMA_H 0032 0033 /***************************** 0034 * Required standard headers * 0035 *****************************/ 0036 0037 /* 0038 * liblzma API headers need some standard types and macros. To allow 0039 * including lzma.h without requiring the application to include other 0040 * headers first, lzma.h includes the required standard headers unless 0041 * they already seem to be included already or if LZMA_MANUAL_HEADERS 0042 * has been defined. 0043 * 0044 * Here's what types and macros are needed and from which headers: 0045 * - stddef.h: size_t, NULL 0046 * - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n), 0047 * UINT32_MAX, UINT64_MAX 0048 * 0049 * However, inttypes.h is a little more portable than stdint.h, although 0050 * inttypes.h declares some unneeded things compared to plain stdint.h. 0051 * 0052 * The hacks below aren't perfect, specifically they assume that inttypes.h 0053 * exists and that it typedefs at least uint8_t, uint32_t, and uint64_t, 0054 * and that, in case of incomplete inttypes.h, unsigned int is 32-bit. 0055 * If the application already takes care of setting up all the types and 0056 * macros properly (for example by using gnulib's stdint.h or inttypes.h), 0057 * we try to detect that the macros are already defined and don't include 0058 * inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to 0059 * force this file to never include any system headers. 0060 * 0061 * Some could argue that liblzma API should provide all the required types, 0062 * for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was 0063 * seen as an unnecessary mess, since most systems already provide all the 0064 * necessary types and macros in the standard headers. 0065 * 0066 * Note that liblzma API still has lzma_bool, because using stdbool.h would 0067 * break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't 0068 * necessarily the same as sizeof(bool) in C++. 0069 */ 0070 0071 #ifndef LZMA_MANUAL_HEADERS 0072 /* 0073 * I suppose this works portably also in C++. Note that in C++, 0074 * we need to get size_t into the global namespace. 0075 */ 0076 # include <stddef.h> 0077 0078 /* 0079 * Skip inttypes.h if we already have all the required macros. If we 0080 * have the macros, we assume that we have the matching typedefs too. 0081 */ 0082 # if !defined(UINT32_C) || !defined(UINT64_C) \ 0083 || !defined(UINT32_MAX) || !defined(UINT64_MAX) 0084 /* 0085 * MSVC versions older than 2013 have no C99 support, and 0086 * thus they cannot be used to compile liblzma. Using an 0087 * existing liblzma.dll with old MSVC can work though(*), 0088 * but we need to define the required standard integer 0089 * types here in a MSVC-specific way. 0090 * 0091 * (*) If you do this, the existing liblzma.dll probably uses 0092 * a different runtime library than your MSVC-built 0093 * application. Mixing runtimes is generally bad, but 0094 * in this case it should work as long as you avoid 0095 * the few rarely-needed liblzma functions that allocate 0096 * memory and expect the caller to free it using free(). 0097 */ 0098 # if defined(_WIN32) && defined(_MSC_VER) && _MSC_VER < 1800 0099 typedef unsigned __int8 uint8_t; 0100 typedef unsigned __int32 uint32_t; 0101 typedef unsigned __int64 uint64_t; 0102 # else 0103 /* Use the standard inttypes.h. */ 0104 # ifdef __cplusplus 0105 /* 0106 * C99 sections 7.18.2 and 7.18.4 specify 0107 * that C++ implementations define the limit 0108 * and constant macros only if specifically 0109 * requested. Note that if you want the 0110 * format macros (PRIu64 etc.) too, you need 0111 * to define __STDC_FORMAT_MACROS before 0112 * including lzma.h, since re-including 0113 * inttypes.h with __STDC_FORMAT_MACROS 0114 * defined doesn't necessarily work. 0115 */ 0116 # ifndef __STDC_LIMIT_MACROS 0117 # define __STDC_LIMIT_MACROS 1 0118 # endif 0119 # ifndef __STDC_CONSTANT_MACROS 0120 # define __STDC_CONSTANT_MACROS 1 0121 # endif 0122 # endif 0123 0124 # include <inttypes.h> 0125 # endif 0126 0127 /* 0128 * Some old systems have only the typedefs in inttypes.h, and 0129 * lack all the macros. For those systems, we need a few more 0130 * hacks. We assume that unsigned int is 32-bit and unsigned 0131 * long is either 32-bit or 64-bit. If these hacks aren't 0132 * enough, the application has to setup the types manually 0133 * before including lzma.h. 0134 */ 0135 # ifndef UINT32_C 0136 # if defined(_WIN32) && defined(_MSC_VER) 0137 # define UINT32_C(n) n ## UI32 0138 # else 0139 # define UINT32_C(n) n ## U 0140 # endif 0141 # endif 0142 0143 # ifndef UINT64_C 0144 # if defined(_WIN32) && defined(_MSC_VER) 0145 # define UINT64_C(n) n ## UI64 0146 # else 0147 /* Get ULONG_MAX. */ 0148 # include <limits.h> 0149 # if ULONG_MAX == 4294967295UL 0150 # define UINT64_C(n) n ## ULL 0151 # else 0152 # define UINT64_C(n) n ## UL 0153 # endif 0154 # endif 0155 # endif 0156 0157 # ifndef UINT32_MAX 0158 # define UINT32_MAX (UINT32_C(4294967295)) 0159 # endif 0160 0161 # ifndef UINT64_MAX 0162 # define UINT64_MAX (UINT64_C(18446744073709551615)) 0163 # endif 0164 # endif 0165 #endif /* ifdef LZMA_MANUAL_HEADERS */ 0166 0167 0168 /****************** 0169 * LZMA_API macro * 0170 ******************/ 0171 0172 /* 0173 * Some systems require that the functions and function pointers are 0174 * declared specially in the headers. LZMA_API_IMPORT is for importing 0175 * symbols and LZMA_API_CALL is to specify the calling convention. 0176 * 0177 * By default it is assumed that the application will link dynamically 0178 * against liblzma. #define LZMA_API_STATIC in your application if you 0179 * want to link against static liblzma. If you don't care about portability 0180 * to operating systems like Windows, or at least don't care about linking 0181 * against static liblzma on them, don't worry about LZMA_API_STATIC. That 0182 * is, most developers will never need to use LZMA_API_STATIC. 0183 * 0184 * The GCC variants are a special case on Windows (Cygwin and MinGW). 0185 * We rely on GCC doing the right thing with its auto-import feature, 0186 * and thus don't use __declspec(dllimport). This way developers don't 0187 * need to worry about LZMA_API_STATIC. Also the calling convention is 0188 * omitted on Cygwin but not on MinGW. 0189 */ 0190 #ifndef LZMA_API_IMPORT 0191 # if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__) 0192 # define LZMA_API_IMPORT __declspec(dllimport) 0193 # else 0194 # define LZMA_API_IMPORT 0195 # endif 0196 #endif 0197 0198 #ifndef LZMA_API_CALL 0199 # if defined(_WIN32) && !defined(__CYGWIN__) 0200 # define LZMA_API_CALL __cdecl 0201 # else 0202 # define LZMA_API_CALL 0203 # endif 0204 #endif 0205 0206 #ifndef LZMA_API 0207 # define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL 0208 #endif 0209 0210 0211 /*********** 0212 * nothrow * 0213 ***********/ 0214 0215 /* 0216 * None of the functions in liblzma may throw an exception. Even 0217 * the functions that use callback functions won't throw exceptions, 0218 * because liblzma would break if a callback function threw an exception. 0219 */ 0220 #ifndef lzma_nothrow 0221 # if defined(__cplusplus) 0222 # if __cplusplus >= 201103L || (defined(_MSVC_LANG) \ 0223 && _MSVC_LANG >= 201103L) 0224 # define lzma_nothrow noexcept 0225 # else 0226 # define lzma_nothrow throw() 0227 # endif 0228 # elif defined(__GNUC__) && (__GNUC__ > 3 \ 0229 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) 0230 # define lzma_nothrow __attribute__((__nothrow__)) 0231 # else 0232 # define lzma_nothrow 0233 # endif 0234 #endif 0235 0236 0237 /******************** 0238 * GNU C extensions * 0239 ********************/ 0240 0241 /* 0242 * GNU C extensions are used conditionally in the public API. It doesn't 0243 * break anything if these are sometimes enabled and sometimes not, only 0244 * affects warnings and optimizations. 0245 */ 0246 #if defined(__GNUC__) && __GNUC__ >= 3 0247 # ifndef lzma_attribute 0248 # define lzma_attribute(attr) __attribute__(attr) 0249 # endif 0250 0251 /* warn_unused_result was added in GCC 3.4. */ 0252 # ifndef lzma_attr_warn_unused_result 0253 # if __GNUC__ == 3 && __GNUC_MINOR__ < 4 0254 # define lzma_attr_warn_unused_result 0255 # endif 0256 # endif 0257 0258 #else 0259 # ifndef lzma_attribute 0260 # define lzma_attribute(attr) 0261 # endif 0262 #endif 0263 0264 0265 #ifndef lzma_attr_pure 0266 # define lzma_attr_pure lzma_attribute((__pure__)) 0267 #endif 0268 0269 #ifndef lzma_attr_const 0270 # define lzma_attr_const lzma_attribute((__const__)) 0271 #endif 0272 0273 #ifndef lzma_attr_warn_unused_result 0274 # define lzma_attr_warn_unused_result \ 0275 lzma_attribute((__warn_unused_result__)) 0276 #endif 0277 0278 0279 /************** 0280 * Subheaders * 0281 **************/ 0282 0283 #ifdef __cplusplus 0284 extern "C" { 0285 #endif 0286 0287 /* 0288 * Subheaders check that this is defined. It is to prevent including 0289 * them directly from applications. 0290 */ 0291 #define LZMA_H_INTERNAL 1 0292 0293 /* Basic features */ 0294 #include "lzma/version.h" 0295 #include "lzma/base.h" 0296 #include "lzma/vli.h" 0297 #include "lzma/check.h" 0298 0299 /* Filters */ 0300 #include "lzma/filter.h" 0301 #include "lzma/bcj.h" 0302 #include "lzma/delta.h" 0303 #include "lzma/lzma12.h" 0304 0305 /* Container formats */ 0306 #include "lzma/container.h" 0307 0308 /* Advanced features */ 0309 #include "lzma/stream_flags.h" 0310 #include "lzma/block.h" 0311 #include "lzma/index.h" 0312 #include "lzma/index_hash.h" 0313 0314 /* Hardware information */ 0315 #include "lzma/hardware.h" 0316 0317 /* 0318 * All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications 0319 * re-including the subheaders. 0320 */ 0321 #undef LZMA_H_INTERNAL 0322 0323 #ifdef __cplusplus 0324 } 0325 #endif 0326 0327 #endif /* ifndef LZMA_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.5 LXR engine. The LXR team |