annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/lzma.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 /* SPDX-License-Identifier: 0BSD */
jpayne@69 2
jpayne@69 3 /**
jpayne@69 4 * \file api/lzma.h
jpayne@69 5 * \brief The public API of liblzma data compression library
jpayne@69 6 * \mainpage
jpayne@69 7 *
jpayne@69 8 * liblzma is a general-purpose data compression library with a zlib-like API.
jpayne@69 9 * The native file format is .xz, but also the old .lzma format and raw (no
jpayne@69 10 * headers) streams are supported. Multiple compression algorithms (filters)
jpayne@69 11 * are supported. Currently LZMA2 is the primary filter.
jpayne@69 12 *
jpayne@69 13 * liblzma is part of XZ Utils <https://tukaani.org/xz/>. XZ Utils
jpayne@69 14 * includes a gzip-like command line tool named xz and some other tools.
jpayne@69 15 * XZ Utils is developed and maintained by Lasse Collin.
jpayne@69 16 *
jpayne@69 17 * Major parts of liblzma are based on code written by Igor Pavlov,
jpayne@69 18 * specifically the LZMA SDK <https://7-zip.org/sdk.html>.
jpayne@69 19 *
jpayne@69 20 * The SHA-256 implementation in liblzma is based on code written by
jpayne@69 21 * Wei Dai in Crypto++ Library <https://www.cryptopp.com/>.
jpayne@69 22 *
jpayne@69 23 * liblzma is distributed under the BSD Zero Clause License (0BSD).
jpayne@69 24 */
jpayne@69 25
jpayne@69 26 /*
jpayne@69 27 * Author: Lasse Collin
jpayne@69 28 */
jpayne@69 29
jpayne@69 30 #ifndef LZMA_H
jpayne@69 31 #define LZMA_H
jpayne@69 32
jpayne@69 33 /*****************************
jpayne@69 34 * Required standard headers *
jpayne@69 35 *****************************/
jpayne@69 36
jpayne@69 37 /*
jpayne@69 38 * liblzma API headers need some standard types and macros. To allow
jpayne@69 39 * including lzma.h without requiring the application to include other
jpayne@69 40 * headers first, lzma.h includes the required standard headers unless
jpayne@69 41 * they already seem to be included already or if LZMA_MANUAL_HEADERS
jpayne@69 42 * has been defined.
jpayne@69 43 *
jpayne@69 44 * Here's what types and macros are needed and from which headers:
jpayne@69 45 * - stddef.h: size_t, NULL
jpayne@69 46 * - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n),
jpayne@69 47 * UINT32_MAX, UINT64_MAX
jpayne@69 48 *
jpayne@69 49 * However, inttypes.h is a little more portable than stdint.h, although
jpayne@69 50 * inttypes.h declares some unneeded things compared to plain stdint.h.
jpayne@69 51 *
jpayne@69 52 * The hacks below aren't perfect, specifically they assume that inttypes.h
jpayne@69 53 * exists and that it typedefs at least uint8_t, uint32_t, and uint64_t,
jpayne@69 54 * and that, in case of incomplete inttypes.h, unsigned int is 32-bit.
jpayne@69 55 * If the application already takes care of setting up all the types and
jpayne@69 56 * macros properly (for example by using gnulib's stdint.h or inttypes.h),
jpayne@69 57 * we try to detect that the macros are already defined and don't include
jpayne@69 58 * inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to
jpayne@69 59 * force this file to never include any system headers.
jpayne@69 60 *
jpayne@69 61 * Some could argue that liblzma API should provide all the required types,
jpayne@69 62 * for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was
jpayne@69 63 * seen as an unnecessary mess, since most systems already provide all the
jpayne@69 64 * necessary types and macros in the standard headers.
jpayne@69 65 *
jpayne@69 66 * Note that liblzma API still has lzma_bool, because using stdbool.h would
jpayne@69 67 * break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't
jpayne@69 68 * necessarily the same as sizeof(bool) in C++.
jpayne@69 69 */
jpayne@69 70
jpayne@69 71 #ifndef LZMA_MANUAL_HEADERS
jpayne@69 72 /*
jpayne@69 73 * I suppose this works portably also in C++. Note that in C++,
jpayne@69 74 * we need to get size_t into the global namespace.
jpayne@69 75 */
jpayne@69 76 # include <stddef.h>
jpayne@69 77
jpayne@69 78 /*
jpayne@69 79 * Skip inttypes.h if we already have all the required macros. If we
jpayne@69 80 * have the macros, we assume that we have the matching typedefs too.
jpayne@69 81 */
jpayne@69 82 # if !defined(UINT32_C) || !defined(UINT64_C) \
jpayne@69 83 || !defined(UINT32_MAX) || !defined(UINT64_MAX)
jpayne@69 84 /*
jpayne@69 85 * MSVC versions older than 2013 have no C99 support, and
jpayne@69 86 * thus they cannot be used to compile liblzma. Using an
jpayne@69 87 * existing liblzma.dll with old MSVC can work though(*),
jpayne@69 88 * but we need to define the required standard integer
jpayne@69 89 * types here in a MSVC-specific way.
jpayne@69 90 *
jpayne@69 91 * (*) If you do this, the existing liblzma.dll probably uses
jpayne@69 92 * a different runtime library than your MSVC-built
jpayne@69 93 * application. Mixing runtimes is generally bad, but
jpayne@69 94 * in this case it should work as long as you avoid
jpayne@69 95 * the few rarely-needed liblzma functions that allocate
jpayne@69 96 * memory and expect the caller to free it using free().
jpayne@69 97 */
jpayne@69 98 # if defined(_WIN32) && defined(_MSC_VER) && _MSC_VER < 1800
jpayne@69 99 typedef unsigned __int8 uint8_t;
jpayne@69 100 typedef unsigned __int32 uint32_t;
jpayne@69 101 typedef unsigned __int64 uint64_t;
jpayne@69 102 # else
jpayne@69 103 /* Use the standard inttypes.h. */
jpayne@69 104 # ifdef __cplusplus
jpayne@69 105 /*
jpayne@69 106 * C99 sections 7.18.2 and 7.18.4 specify
jpayne@69 107 * that C++ implementations define the limit
jpayne@69 108 * and constant macros only if specifically
jpayne@69 109 * requested. Note that if you want the
jpayne@69 110 * format macros (PRIu64 etc.) too, you need
jpayne@69 111 * to define __STDC_FORMAT_MACROS before
jpayne@69 112 * including lzma.h, since re-including
jpayne@69 113 * inttypes.h with __STDC_FORMAT_MACROS
jpayne@69 114 * defined doesn't necessarily work.
jpayne@69 115 */
jpayne@69 116 # ifndef __STDC_LIMIT_MACROS
jpayne@69 117 # define __STDC_LIMIT_MACROS 1
jpayne@69 118 # endif
jpayne@69 119 # ifndef __STDC_CONSTANT_MACROS
jpayne@69 120 # define __STDC_CONSTANT_MACROS 1
jpayne@69 121 # endif
jpayne@69 122 # endif
jpayne@69 123
jpayne@69 124 # include <inttypes.h>
jpayne@69 125 # endif
jpayne@69 126
jpayne@69 127 /*
jpayne@69 128 * Some old systems have only the typedefs in inttypes.h, and
jpayne@69 129 * lack all the macros. For those systems, we need a few more
jpayne@69 130 * hacks. We assume that unsigned int is 32-bit and unsigned
jpayne@69 131 * long is either 32-bit or 64-bit. If these hacks aren't
jpayne@69 132 * enough, the application has to setup the types manually
jpayne@69 133 * before including lzma.h.
jpayne@69 134 */
jpayne@69 135 # ifndef UINT32_C
jpayne@69 136 # if defined(_WIN32) && defined(_MSC_VER)
jpayne@69 137 # define UINT32_C(n) n ## UI32
jpayne@69 138 # else
jpayne@69 139 # define UINT32_C(n) n ## U
jpayne@69 140 # endif
jpayne@69 141 # endif
jpayne@69 142
jpayne@69 143 # ifndef UINT64_C
jpayne@69 144 # if defined(_WIN32) && defined(_MSC_VER)
jpayne@69 145 # define UINT64_C(n) n ## UI64
jpayne@69 146 # else
jpayne@69 147 /* Get ULONG_MAX. */
jpayne@69 148 # include <limits.h>
jpayne@69 149 # if ULONG_MAX == 4294967295UL
jpayne@69 150 # define UINT64_C(n) n ## ULL
jpayne@69 151 # else
jpayne@69 152 # define UINT64_C(n) n ## UL
jpayne@69 153 # endif
jpayne@69 154 # endif
jpayne@69 155 # endif
jpayne@69 156
jpayne@69 157 # ifndef UINT32_MAX
jpayne@69 158 # define UINT32_MAX (UINT32_C(4294967295))
jpayne@69 159 # endif
jpayne@69 160
jpayne@69 161 # ifndef UINT64_MAX
jpayne@69 162 # define UINT64_MAX (UINT64_C(18446744073709551615))
jpayne@69 163 # endif
jpayne@69 164 # endif
jpayne@69 165 #endif /* ifdef LZMA_MANUAL_HEADERS */
jpayne@69 166
jpayne@69 167
jpayne@69 168 /******************
jpayne@69 169 * LZMA_API macro *
jpayne@69 170 ******************/
jpayne@69 171
jpayne@69 172 /*
jpayne@69 173 * Some systems require that the functions and function pointers are
jpayne@69 174 * declared specially in the headers. LZMA_API_IMPORT is for importing
jpayne@69 175 * symbols and LZMA_API_CALL is to specify the calling convention.
jpayne@69 176 *
jpayne@69 177 * By default it is assumed that the application will link dynamically
jpayne@69 178 * against liblzma. #define LZMA_API_STATIC in your application if you
jpayne@69 179 * want to link against static liblzma. If you don't care about portability
jpayne@69 180 * to operating systems like Windows, or at least don't care about linking
jpayne@69 181 * against static liblzma on them, don't worry about LZMA_API_STATIC. That
jpayne@69 182 * is, most developers will never need to use LZMA_API_STATIC.
jpayne@69 183 *
jpayne@69 184 * The GCC variants are a special case on Windows (Cygwin and MinGW-w64).
jpayne@69 185 * We rely on GCC doing the right thing with its auto-import feature,
jpayne@69 186 * and thus don't use __declspec(dllimport). This way developers don't
jpayne@69 187 * need to worry about LZMA_API_STATIC. Also the calling convention is
jpayne@69 188 * omitted on Cygwin but not on MinGW-w64.
jpayne@69 189 */
jpayne@69 190 #ifndef LZMA_API_IMPORT
jpayne@69 191 # if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__)
jpayne@69 192 # define LZMA_API_IMPORT __declspec(dllimport)
jpayne@69 193 # else
jpayne@69 194 # define LZMA_API_IMPORT
jpayne@69 195 # endif
jpayne@69 196 #endif
jpayne@69 197
jpayne@69 198 #ifndef LZMA_API_CALL
jpayne@69 199 # if defined(_WIN32) && !defined(__CYGWIN__)
jpayne@69 200 # define LZMA_API_CALL __cdecl
jpayne@69 201 # else
jpayne@69 202 # define LZMA_API_CALL
jpayne@69 203 # endif
jpayne@69 204 #endif
jpayne@69 205
jpayne@69 206 #ifndef LZMA_API
jpayne@69 207 # define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL
jpayne@69 208 #endif
jpayne@69 209
jpayne@69 210
jpayne@69 211 /***********
jpayne@69 212 * nothrow *
jpayne@69 213 ***********/
jpayne@69 214
jpayne@69 215 /*
jpayne@69 216 * None of the functions in liblzma may throw an exception. Even
jpayne@69 217 * the functions that use callback functions won't throw exceptions,
jpayne@69 218 * because liblzma would break if a callback function threw an exception.
jpayne@69 219 */
jpayne@69 220 #ifndef lzma_nothrow
jpayne@69 221 # if defined(__cplusplus)
jpayne@69 222 # if __cplusplus >= 201103L || (defined(_MSVC_LANG) \
jpayne@69 223 && _MSVC_LANG >= 201103L)
jpayne@69 224 # define lzma_nothrow noexcept
jpayne@69 225 # else
jpayne@69 226 # define lzma_nothrow throw()
jpayne@69 227 # endif
jpayne@69 228 # elif defined(__GNUC__) && (__GNUC__ > 3 \
jpayne@69 229 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
jpayne@69 230 # define lzma_nothrow __attribute__((__nothrow__))
jpayne@69 231 # else
jpayne@69 232 # define lzma_nothrow
jpayne@69 233 # endif
jpayne@69 234 #endif
jpayne@69 235
jpayne@69 236
jpayne@69 237 /********************
jpayne@69 238 * GNU C extensions *
jpayne@69 239 ********************/
jpayne@69 240
jpayne@69 241 /*
jpayne@69 242 * GNU C extensions are used conditionally in the public API. It doesn't
jpayne@69 243 * break anything if these are sometimes enabled and sometimes not, only
jpayne@69 244 * affects warnings and optimizations.
jpayne@69 245 */
jpayne@69 246 #if defined(__GNUC__) && __GNUC__ >= 3
jpayne@69 247 # ifndef lzma_attribute
jpayne@69 248 # define lzma_attribute(attr) __attribute__(attr)
jpayne@69 249 # endif
jpayne@69 250
jpayne@69 251 /* warn_unused_result was added in GCC 3.4. */
jpayne@69 252 # ifndef lzma_attr_warn_unused_result
jpayne@69 253 # if __GNUC__ == 3 && __GNUC_MINOR__ < 4
jpayne@69 254 # define lzma_attr_warn_unused_result
jpayne@69 255 # endif
jpayne@69 256 # endif
jpayne@69 257
jpayne@69 258 #else
jpayne@69 259 # ifndef lzma_attribute
jpayne@69 260 # define lzma_attribute(attr)
jpayne@69 261 # endif
jpayne@69 262 #endif
jpayne@69 263
jpayne@69 264
jpayne@69 265 #ifndef lzma_attr_pure
jpayne@69 266 # define lzma_attr_pure lzma_attribute((__pure__))
jpayne@69 267 #endif
jpayne@69 268
jpayne@69 269 #ifndef lzma_attr_const
jpayne@69 270 # define lzma_attr_const lzma_attribute((__const__))
jpayne@69 271 #endif
jpayne@69 272
jpayne@69 273 #ifndef lzma_attr_warn_unused_result
jpayne@69 274 # define lzma_attr_warn_unused_result \
jpayne@69 275 lzma_attribute((__warn_unused_result__))
jpayne@69 276 #endif
jpayne@69 277
jpayne@69 278
jpayne@69 279 /**************
jpayne@69 280 * Subheaders *
jpayne@69 281 **************/
jpayne@69 282
jpayne@69 283 #ifdef __cplusplus
jpayne@69 284 extern "C" {
jpayne@69 285 #endif
jpayne@69 286
jpayne@69 287 /*
jpayne@69 288 * Subheaders check that this is defined. It is to prevent including
jpayne@69 289 * them directly from applications.
jpayne@69 290 */
jpayne@69 291 #define LZMA_H_INTERNAL 1
jpayne@69 292
jpayne@69 293 /* Basic features */
jpayne@69 294 #include "lzma/version.h"
jpayne@69 295 #include "lzma/base.h"
jpayne@69 296 #include "lzma/vli.h"
jpayne@69 297 #include "lzma/check.h"
jpayne@69 298
jpayne@69 299 /* Filters */
jpayne@69 300 #include "lzma/filter.h"
jpayne@69 301 #include "lzma/bcj.h"
jpayne@69 302 #include "lzma/delta.h"
jpayne@69 303 #include "lzma/lzma12.h"
jpayne@69 304
jpayne@69 305 /* Container formats */
jpayne@69 306 #include "lzma/container.h"
jpayne@69 307
jpayne@69 308 /* Advanced features */
jpayne@69 309 #include "lzma/stream_flags.h"
jpayne@69 310 #include "lzma/block.h"
jpayne@69 311 #include "lzma/index.h"
jpayne@69 312 #include "lzma/index_hash.h"
jpayne@69 313
jpayne@69 314 /* Hardware information */
jpayne@69 315 #include "lzma/hardware.h"
jpayne@69 316
jpayne@69 317 /*
jpayne@69 318 * All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications
jpayne@69 319 * re-including the subheaders.
jpayne@69 320 */
jpayne@69 321 #undef LZMA_H_INTERNAL
jpayne@69 322
jpayne@69 323 #ifdef __cplusplus
jpayne@69 324 }
jpayne@69 325 #endif
jpayne@69 326
jpayne@69 327 #endif /* ifndef LZMA_H */