Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:55:48

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