1*2940b44dSPeter Avalos /** 2*2940b44dSPeter Avalos * \file lzma/container.h 3*2940b44dSPeter Avalos * \brief File formats 4*2940b44dSPeter Avalos */ 5*2940b44dSPeter Avalos 6*2940b44dSPeter Avalos /* 7*2940b44dSPeter Avalos * Author: Lasse Collin 8*2940b44dSPeter Avalos * 9*2940b44dSPeter Avalos * This file has been put into the public domain. 10*2940b44dSPeter Avalos * You can do whatever you want with this file. 11*2940b44dSPeter Avalos * 12*2940b44dSPeter Avalos * See ../lzma.h for information about liblzma as a whole. 13*2940b44dSPeter Avalos */ 14*2940b44dSPeter Avalos 15*2940b44dSPeter Avalos #ifndef LZMA_H_INTERNAL 16*2940b44dSPeter Avalos # error Never include this file directly. Use <lzma.h> instead. 17*2940b44dSPeter Avalos #endif 18*2940b44dSPeter Avalos 19*2940b44dSPeter Avalos 20*2940b44dSPeter Avalos /************ 21*2940b44dSPeter Avalos * Encoding * 22*2940b44dSPeter Avalos ************/ 23*2940b44dSPeter Avalos 24*2940b44dSPeter Avalos /** 25*2940b44dSPeter Avalos * \brief Default compression preset 26*2940b44dSPeter Avalos * 27*2940b44dSPeter Avalos * It's not straightforward to recommend a default preset, because in some 28*2940b44dSPeter Avalos * cases keeping the resource usage relatively low is more important that 29*2940b44dSPeter Avalos * getting the maximum compression ratio. 30*2940b44dSPeter Avalos */ 31*2940b44dSPeter Avalos #define LZMA_PRESET_DEFAULT UINT32_C(6) 32*2940b44dSPeter Avalos 33*2940b44dSPeter Avalos 34*2940b44dSPeter Avalos /** 35*2940b44dSPeter Avalos * \brief Mask for preset level 36*2940b44dSPeter Avalos * 37*2940b44dSPeter Avalos * This is useful only if you need to extract the level from the preset 38*2940b44dSPeter Avalos * variable. That should be rare. 39*2940b44dSPeter Avalos */ 40*2940b44dSPeter Avalos #define LZMA_PRESET_LEVEL_MASK UINT32_C(0x1F) 41*2940b44dSPeter Avalos 42*2940b44dSPeter Avalos 43*2940b44dSPeter Avalos /* 44*2940b44dSPeter Avalos * Preset flags 45*2940b44dSPeter Avalos * 46*2940b44dSPeter Avalos * Currently only one flag is defined. 47*2940b44dSPeter Avalos */ 48*2940b44dSPeter Avalos 49*2940b44dSPeter Avalos /** 50*2940b44dSPeter Avalos * \brief Extreme compression preset 51*2940b44dSPeter Avalos * 52*2940b44dSPeter Avalos * This flag modifies the preset to make the encoding significantly slower 53*2940b44dSPeter Avalos * while improving the compression ratio only marginally. This is useful 54*2940b44dSPeter Avalos * when you don't mind wasting time to get as small result as possible. 55*2940b44dSPeter Avalos * 56*2940b44dSPeter Avalos * This flag doesn't affect the memory usage requirements of the decoder (at 57*2940b44dSPeter Avalos * least not significantly). The memory usage of the encoder may be increased 58*2940b44dSPeter Avalos * a little but only at the lowest preset levels (0-3). 59*2940b44dSPeter Avalos */ 60*2940b44dSPeter Avalos #define LZMA_PRESET_EXTREME (UINT32_C(1) << 31) 61*2940b44dSPeter Avalos 62*2940b44dSPeter Avalos 63*2940b44dSPeter Avalos /** 64*2940b44dSPeter Avalos * \brief Calculate approximate memory usage of easy encoder 65*2940b44dSPeter Avalos * 66*2940b44dSPeter Avalos * This function is a wrapper for lzma_raw_encoder_memusage(). 67*2940b44dSPeter Avalos * 68*2940b44dSPeter Avalos * \param preset Compression preset (level and possible flags) 69*2940b44dSPeter Avalos */ 70*2940b44dSPeter Avalos extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset) 71*2940b44dSPeter Avalos lzma_nothrow lzma_attr_pure; 72*2940b44dSPeter Avalos 73*2940b44dSPeter Avalos 74*2940b44dSPeter Avalos /** 75*2940b44dSPeter Avalos * \brief Calculate approximate decoder memory usage of a preset 76*2940b44dSPeter Avalos * 77*2940b44dSPeter Avalos * This function is a wrapper for lzma_raw_decoder_memusage(). 78*2940b44dSPeter Avalos * 79*2940b44dSPeter Avalos * \param preset Compression preset (level and possible flags) 80*2940b44dSPeter Avalos */ 81*2940b44dSPeter Avalos extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset) 82*2940b44dSPeter Avalos lzma_nothrow lzma_attr_pure; 83*2940b44dSPeter Avalos 84*2940b44dSPeter Avalos 85*2940b44dSPeter Avalos /** 86*2940b44dSPeter Avalos * \brief Initialize .xz Stream encoder using a preset number 87*2940b44dSPeter Avalos * 88*2940b44dSPeter Avalos * This function is intended for those who just want to use the basic features 89*2940b44dSPeter Avalos * if liblzma (that is, most developers out there). 90*2940b44dSPeter Avalos * 91*2940b44dSPeter Avalos * \param strm Pointer to lzma_stream that is at least initialized 92*2940b44dSPeter Avalos * with LZMA_STREAM_INIT. 93*2940b44dSPeter Avalos * \param preset Compression preset to use. A preset consist of level 94*2940b44dSPeter Avalos * number and zero or more flags. Usually flags aren't 95*2940b44dSPeter Avalos * used, so preset is simply a number [0, 9] which match 96*2940b44dSPeter Avalos * the options -0 ... -9 of the xz command line tool. 97*2940b44dSPeter Avalos * Additional flags can be be set using bitwise-or with 98*2940b44dSPeter Avalos * the preset level number, e.g. 6 | LZMA_PRESET_EXTREME. 99*2940b44dSPeter Avalos * \param check Integrity check type to use. See check.h for available 100*2940b44dSPeter Avalos * checks. The xz command line tool defaults to 101*2940b44dSPeter Avalos * LZMA_CHECK_CRC64, which is a good choice if you are 102*2940b44dSPeter Avalos * unsure. LZMA_CHECK_CRC32 is good too as long as the 103*2940b44dSPeter Avalos * uncompressed file is not many gigabytes. 104*2940b44dSPeter Avalos * 105*2940b44dSPeter Avalos * \return - LZMA_OK: Initialization succeeded. Use lzma_code() to 106*2940b44dSPeter Avalos * encode your data. 107*2940b44dSPeter Avalos * - LZMA_MEM_ERROR: Memory allocation failed. 108*2940b44dSPeter Avalos * - LZMA_OPTIONS_ERROR: The given compression preset is not 109*2940b44dSPeter Avalos * supported by this build of liblzma. 110*2940b44dSPeter Avalos * - LZMA_UNSUPPORTED_CHECK: The given check type is not 111*2940b44dSPeter Avalos * supported by this liblzma build. 112*2940b44dSPeter Avalos * - LZMA_PROG_ERROR: One or more of the parameters have values 113*2940b44dSPeter Avalos * that will never be valid. For example, strm == NULL. 114*2940b44dSPeter Avalos * 115*2940b44dSPeter Avalos * If initialization fails (return value is not LZMA_OK), all the memory 116*2940b44dSPeter Avalos * allocated for *strm by liblzma is always freed. Thus, there is no need 117*2940b44dSPeter Avalos * to call lzma_end() after failed initialization. 118*2940b44dSPeter Avalos * 119*2940b44dSPeter Avalos * If initialization succeeds, use lzma_code() to do the actual encoding. 120*2940b44dSPeter Avalos * Valid values for `action' (the second argument of lzma_code()) are 121*2940b44dSPeter Avalos * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future, 122*2940b44dSPeter Avalos * there may be compression levels or flags that don't support LZMA_SYNC_FLUSH. 123*2940b44dSPeter Avalos */ 124*2940b44dSPeter Avalos extern LZMA_API(lzma_ret) lzma_easy_encoder( 125*2940b44dSPeter Avalos lzma_stream *strm, uint32_t preset, lzma_check check) 126*2940b44dSPeter Avalos lzma_nothrow lzma_attr_warn_unused_result; 127*2940b44dSPeter Avalos 128*2940b44dSPeter Avalos 129*2940b44dSPeter Avalos /** 130*2940b44dSPeter Avalos * \brief Single-call .xz Stream encoding using a preset number 131*2940b44dSPeter Avalos * 132*2940b44dSPeter Avalos * The maximum required output buffer size can be calculated with 133*2940b44dSPeter Avalos * lzma_stream_buffer_bound(). 134*2940b44dSPeter Avalos * 135*2940b44dSPeter Avalos * \param preset Compression preset to use. See the description 136*2940b44dSPeter Avalos * in lzma_easy_encoder(). 137*2940b44dSPeter Avalos * \param check Type of the integrity check to calculate from 138*2940b44dSPeter Avalos * uncompressed data. 139*2940b44dSPeter Avalos * \param allocator lzma_allocator for custom allocator functions. 140*2940b44dSPeter Avalos * Set to NULL to use malloc() and free(). 141*2940b44dSPeter Avalos * \param in Beginning of the input buffer 142*2940b44dSPeter Avalos * \param in_size Size of the input buffer 143*2940b44dSPeter Avalos * \param out Beginning of the output buffer 144*2940b44dSPeter Avalos * \param out_pos The next byte will be written to out[*out_pos]. 145*2940b44dSPeter Avalos * *out_pos is updated only if encoding succeeds. 146*2940b44dSPeter Avalos * \param out_size Size of the out buffer; the first byte into 147*2940b44dSPeter Avalos * which no data is written to is out[out_size]. 148*2940b44dSPeter Avalos * 149*2940b44dSPeter Avalos * \return - LZMA_OK: Encoding was successful. 150*2940b44dSPeter Avalos * - LZMA_BUF_ERROR: Not enough output buffer space. 151*2940b44dSPeter Avalos * - LZMA_OPTIONS_ERROR 152*2940b44dSPeter Avalos * - LZMA_MEM_ERROR 153*2940b44dSPeter Avalos * - LZMA_DATA_ERROR 154*2940b44dSPeter Avalos * - LZMA_PROG_ERROR 155*2940b44dSPeter Avalos */ 156*2940b44dSPeter Avalos extern LZMA_API(lzma_ret) lzma_easy_buffer_encode( 157*2940b44dSPeter Avalos uint32_t preset, lzma_check check, 158*2940b44dSPeter Avalos lzma_allocator *allocator, const uint8_t *in, size_t in_size, 159*2940b44dSPeter Avalos uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; 160*2940b44dSPeter Avalos 161*2940b44dSPeter Avalos 162*2940b44dSPeter Avalos /** 163*2940b44dSPeter Avalos * \brief Initialize .xz Stream encoder using a custom filter chain 164*2940b44dSPeter Avalos * 165*2940b44dSPeter Avalos * \param strm Pointer to properly prepared lzma_stream 166*2940b44dSPeter Avalos * \param filters Array of filters. This must be terminated with 167*2940b44dSPeter Avalos * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h for 168*2940b44dSPeter Avalos * more information. 169*2940b44dSPeter Avalos * \param check Type of the integrity check to calculate from 170*2940b44dSPeter Avalos * uncompressed data. 171*2940b44dSPeter Avalos * 172*2940b44dSPeter Avalos * \return - LZMA_OK: Initialization was successful. 173*2940b44dSPeter Avalos * - LZMA_MEM_ERROR 174*2940b44dSPeter Avalos * - LZMA_OPTIONS_ERROR 175*2940b44dSPeter Avalos * - LZMA_PROG_ERROR 176*2940b44dSPeter Avalos */ 177*2940b44dSPeter Avalos extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm, 178*2940b44dSPeter Avalos const lzma_filter *filters, lzma_check check) 179*2940b44dSPeter Avalos lzma_nothrow lzma_attr_warn_unused_result; 180*2940b44dSPeter Avalos 181*2940b44dSPeter Avalos 182*2940b44dSPeter Avalos /** 183*2940b44dSPeter Avalos * \brief Initialize .lzma encoder (legacy file format) 184*2940b44dSPeter Avalos * 185*2940b44dSPeter Avalos * The .lzma format is sometimes called the LZMA_Alone format, which is the 186*2940b44dSPeter Avalos * reason for the name of this function. The .lzma format supports only the 187*2940b44dSPeter Avalos * LZMA1 filter. There is no support for integrity checks like CRC32. 188*2940b44dSPeter Avalos * 189*2940b44dSPeter Avalos * Use this function if and only if you need to create files readable by 190*2940b44dSPeter Avalos * legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format 191*2940b44dSPeter Avalos * is strongly recommended. 192*2940b44dSPeter Avalos * 193*2940b44dSPeter Avalos * The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH. 194*2940b44dSPeter Avalos * No kind of flushing is supported, because the file format doesn't make 195*2940b44dSPeter Avalos * it possible. 196*2940b44dSPeter Avalos * 197*2940b44dSPeter Avalos * \return - LZMA_OK 198*2940b44dSPeter Avalos * - LZMA_MEM_ERROR 199*2940b44dSPeter Avalos * - LZMA_OPTIONS_ERROR 200*2940b44dSPeter Avalos * - LZMA_PROG_ERROR 201*2940b44dSPeter Avalos */ 202*2940b44dSPeter Avalos extern LZMA_API(lzma_ret) lzma_alone_encoder( 203*2940b44dSPeter Avalos lzma_stream *strm, const lzma_options_lzma *options) 204*2940b44dSPeter Avalos lzma_nothrow lzma_attr_warn_unused_result; 205*2940b44dSPeter Avalos 206*2940b44dSPeter Avalos 207*2940b44dSPeter Avalos /** 208*2940b44dSPeter Avalos * \brief Calculate output buffer size for single-call Stream encoder 209*2940b44dSPeter Avalos * 210*2940b44dSPeter Avalos * When trying to compress uncompressible data, the encoded size will be 211*2940b44dSPeter Avalos * slightly bigger than the input data. This function calculates how much 212*2940b44dSPeter Avalos * output buffer space is required to be sure that lzma_stream_buffer_encode() 213*2940b44dSPeter Avalos * doesn't return LZMA_BUF_ERROR. 214*2940b44dSPeter Avalos * 215*2940b44dSPeter Avalos * The calculated value is not exact, but it is guaranteed to be big enough. 216*2940b44dSPeter Avalos * The actual maximum output space required may be slightly smaller (up to 217*2940b44dSPeter Avalos * about 100 bytes). This should not be a problem in practice. 218*2940b44dSPeter Avalos * 219*2940b44dSPeter Avalos * If the calculated maximum size doesn't fit into size_t or would make the 220*2940b44dSPeter Avalos * Stream grow past LZMA_VLI_MAX (which should never happen in practice), 221*2940b44dSPeter Avalos * zero is returned to indicate the error. 222*2940b44dSPeter Avalos * 223*2940b44dSPeter Avalos * \note The limit calculated by this function applies only to 224*2940b44dSPeter Avalos * single-call encoding. Multi-call encoding may (and probably 225*2940b44dSPeter Avalos * will) have larger maximum expansion when encoding 226*2940b44dSPeter Avalos * uncompressible data. Currently there is no function to 227*2940b44dSPeter Avalos * calculate the maximum expansion of multi-call encoding. 228*2940b44dSPeter Avalos */ 229*2940b44dSPeter Avalos extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size) 230*2940b44dSPeter Avalos lzma_nothrow; 231*2940b44dSPeter Avalos 232*2940b44dSPeter Avalos 233*2940b44dSPeter Avalos /** 234*2940b44dSPeter Avalos * \brief Single-call .xz Stream encoder 235*2940b44dSPeter Avalos * 236*2940b44dSPeter Avalos * \param filters Array of filters. This must be terminated with 237*2940b44dSPeter Avalos * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h 238*2940b44dSPeter Avalos * for more information. 239*2940b44dSPeter Avalos * \param check Type of the integrity check to calculate from 240*2940b44dSPeter Avalos * uncompressed data. 241*2940b44dSPeter Avalos * \param allocator lzma_allocator for custom allocator functions. 242*2940b44dSPeter Avalos * Set to NULL to use malloc() and free(). 243*2940b44dSPeter Avalos * \param in Beginning of the input buffer 244*2940b44dSPeter Avalos * \param in_size Size of the input buffer 245*2940b44dSPeter Avalos * \param out Beginning of the output buffer 246*2940b44dSPeter Avalos * \param out_pos The next byte will be written to out[*out_pos]. 247*2940b44dSPeter Avalos * *out_pos is updated only if encoding succeeds. 248*2940b44dSPeter Avalos * \param out_size Size of the out buffer; the first byte into 249*2940b44dSPeter Avalos * which no data is written to is out[out_size]. 250*2940b44dSPeter Avalos * 251*2940b44dSPeter Avalos * \return - LZMA_OK: Encoding was successful. 252*2940b44dSPeter Avalos * - LZMA_BUF_ERROR: Not enough output buffer space. 253*2940b44dSPeter Avalos * - LZMA_OPTIONS_ERROR 254*2940b44dSPeter Avalos * - LZMA_MEM_ERROR 255*2940b44dSPeter Avalos * - LZMA_DATA_ERROR 256*2940b44dSPeter Avalos * - LZMA_PROG_ERROR 257*2940b44dSPeter Avalos */ 258*2940b44dSPeter Avalos extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( 259*2940b44dSPeter Avalos lzma_filter *filters, lzma_check check, 260*2940b44dSPeter Avalos lzma_allocator *allocator, const uint8_t *in, size_t in_size, 261*2940b44dSPeter Avalos uint8_t *out, size_t *out_pos, size_t out_size) 262*2940b44dSPeter Avalos lzma_nothrow lzma_attr_warn_unused_result; 263*2940b44dSPeter Avalos 264*2940b44dSPeter Avalos 265*2940b44dSPeter Avalos /************ 266*2940b44dSPeter Avalos * Decoding * 267*2940b44dSPeter Avalos ************/ 268*2940b44dSPeter Avalos 269*2940b44dSPeter Avalos /** 270*2940b44dSPeter Avalos * This flag makes lzma_code() return LZMA_NO_CHECK if the input stream 271*2940b44dSPeter Avalos * being decoded has no integrity check. Note that when used with 272*2940b44dSPeter Avalos * lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK 273*2940b44dSPeter Avalos * if LZMA_TELL_NO_CHECK is used. 274*2940b44dSPeter Avalos */ 275*2940b44dSPeter Avalos #define LZMA_TELL_NO_CHECK UINT32_C(0x01) 276*2940b44dSPeter Avalos 277*2940b44dSPeter Avalos 278*2940b44dSPeter Avalos /** 279*2940b44dSPeter Avalos * This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input 280*2940b44dSPeter Avalos * stream has an integrity check, but the type of the integrity check is not 281*2940b44dSPeter Avalos * supported by this liblzma version or build. Such files can still be 282*2940b44dSPeter Avalos * decoded, but the integrity check cannot be verified. 283*2940b44dSPeter Avalos */ 284*2940b44dSPeter Avalos #define LZMA_TELL_UNSUPPORTED_CHECK UINT32_C(0x02) 285*2940b44dSPeter Avalos 286*2940b44dSPeter Avalos 287*2940b44dSPeter Avalos /** 288*2940b44dSPeter Avalos * This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type 289*2940b44dSPeter Avalos * of the integrity check is known. The type can then be got with 290*2940b44dSPeter Avalos * lzma_get_check(). 291*2940b44dSPeter Avalos */ 292*2940b44dSPeter Avalos #define LZMA_TELL_ANY_CHECK UINT32_C(0x04) 293*2940b44dSPeter Avalos 294*2940b44dSPeter Avalos 295*2940b44dSPeter Avalos /** 296*2940b44dSPeter Avalos * This flag enables decoding of concatenated files with file formats that 297*2940b44dSPeter Avalos * allow concatenating compressed files as is. From the formats currently 298*2940b44dSPeter Avalos * supported by liblzma, only the .xz format allows concatenated files. 299*2940b44dSPeter Avalos * Concatenated files are not allowed with the legacy .lzma format. 300*2940b44dSPeter Avalos * 301*2940b44dSPeter Avalos * This flag also affects the usage of the `action' argument for lzma_code(). 302*2940b44dSPeter Avalos * When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END 303*2940b44dSPeter Avalos * unless LZMA_FINISH is used as `action'. Thus, the application has to set 304*2940b44dSPeter Avalos * LZMA_FINISH in the same way as it does when encoding. 305*2940b44dSPeter Avalos * 306*2940b44dSPeter Avalos * If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH 307*2940b44dSPeter Avalos * as `action' for lzma_code(), but the usage of LZMA_FINISH isn't required. 308*2940b44dSPeter Avalos */ 309*2940b44dSPeter Avalos #define LZMA_CONCATENATED UINT32_C(0x08) 310*2940b44dSPeter Avalos 311*2940b44dSPeter Avalos 312*2940b44dSPeter Avalos /** 313*2940b44dSPeter Avalos * \brief Initialize .xz Stream decoder 314*2940b44dSPeter Avalos * 315*2940b44dSPeter Avalos * \param strm Pointer to properly prepared lzma_stream 316*2940b44dSPeter Avalos * \param memlimit Memory usage limit as bytes. Use UINT64_MAX 317*2940b44dSPeter Avalos * to effectively disable the limiter. 318*2940b44dSPeter Avalos * \param flags Bitwise-or of zero or more of the decoder flags: 319*2940b44dSPeter Avalos * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, 320*2940b44dSPeter Avalos * LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED 321*2940b44dSPeter Avalos * 322*2940b44dSPeter Avalos * \return - LZMA_OK: Initialization was successful. 323*2940b44dSPeter Avalos * - LZMA_MEM_ERROR: Cannot allocate memory. 324*2940b44dSPeter Avalos * - LZMA_OPTIONS_ERROR: Unsupported flags 325*2940b44dSPeter Avalos * - LZMA_PROG_ERROR 326*2940b44dSPeter Avalos */ 327*2940b44dSPeter Avalos extern LZMA_API(lzma_ret) lzma_stream_decoder( 328*2940b44dSPeter Avalos lzma_stream *strm, uint64_t memlimit, uint32_t flags) 329*2940b44dSPeter Avalos lzma_nothrow lzma_attr_warn_unused_result; 330*2940b44dSPeter Avalos 331*2940b44dSPeter Avalos 332*2940b44dSPeter Avalos /** 333*2940b44dSPeter Avalos * \brief Decode .xz Streams and .lzma files with autodetection 334*2940b44dSPeter Avalos * 335*2940b44dSPeter Avalos * This decoder autodetects between the .xz and .lzma file formats, and 336*2940b44dSPeter Avalos * calls lzma_stream_decoder() or lzma_alone_decoder() once the type 337*2940b44dSPeter Avalos * of the input file has been detected. 338*2940b44dSPeter Avalos * 339*2940b44dSPeter Avalos * \param strm Pointer to properly prepared lzma_stream 340*2940b44dSPeter Avalos * \param memlimit Memory usage limit as bytes. Use UINT64_MAX 341*2940b44dSPeter Avalos * to effectively disable the limiter. 342*2940b44dSPeter Avalos * \param flags Bitwise-or of flags, or zero for no flags. 343*2940b44dSPeter Avalos * 344*2940b44dSPeter Avalos * \return - LZMA_OK: Initialization was successful. 345*2940b44dSPeter Avalos * - LZMA_MEM_ERROR: Cannot allocate memory. 346*2940b44dSPeter Avalos * - LZMA_OPTIONS_ERROR: Unsupported flags 347*2940b44dSPeter Avalos * - LZMA_PROG_ERROR 348*2940b44dSPeter Avalos */ 349*2940b44dSPeter Avalos extern LZMA_API(lzma_ret) lzma_auto_decoder( 350*2940b44dSPeter Avalos lzma_stream *strm, uint64_t memlimit, uint32_t flags) 351*2940b44dSPeter Avalos lzma_nothrow lzma_attr_warn_unused_result; 352*2940b44dSPeter Avalos 353*2940b44dSPeter Avalos 354*2940b44dSPeter Avalos /** 355*2940b44dSPeter Avalos * \brief Initialize .lzma decoder (legacy file format) 356*2940b44dSPeter Avalos * 357*2940b44dSPeter Avalos * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. 358*2940b44dSPeter Avalos * There is no need to use LZMA_FINISH, but allowing it may simplify 359*2940b44dSPeter Avalos * certain types of applications. 360*2940b44dSPeter Avalos * 361*2940b44dSPeter Avalos * \return - LZMA_OK 362*2940b44dSPeter Avalos * - LZMA_MEM_ERROR 363*2940b44dSPeter Avalos * - LZMA_PROG_ERROR 364*2940b44dSPeter Avalos */ 365*2940b44dSPeter Avalos extern LZMA_API(lzma_ret) lzma_alone_decoder( 366*2940b44dSPeter Avalos lzma_stream *strm, uint64_t memlimit) 367*2940b44dSPeter Avalos lzma_nothrow lzma_attr_warn_unused_result; 368*2940b44dSPeter Avalos 369*2940b44dSPeter Avalos 370*2940b44dSPeter Avalos /** 371*2940b44dSPeter Avalos * \brief Single-call .xz Stream decoder 372*2940b44dSPeter Avalos * 373*2940b44dSPeter Avalos * \param memlimit Pointer to how much memory the decoder is allowed 374*2940b44dSPeter Avalos * to allocate. The value pointed by this pointer is 375*2940b44dSPeter Avalos * modified if and only if LZMA_MEMLIMIT_ERROR is 376*2940b44dSPeter Avalos * returned. 377*2940b44dSPeter Avalos * \param flags Bitwise-or of zero or more of the decoder flags: 378*2940b44dSPeter Avalos * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, 379*2940b44dSPeter Avalos * LZMA_CONCATENATED. Note that LZMA_TELL_ANY_CHECK 380*2940b44dSPeter Avalos * is not allowed and will return LZMA_PROG_ERROR. 381*2940b44dSPeter Avalos * \param allocator lzma_allocator for custom allocator functions. 382*2940b44dSPeter Avalos * Set to NULL to use malloc() and free(). 383*2940b44dSPeter Avalos * \param in Beginning of the input buffer 384*2940b44dSPeter Avalos * \param in_pos The next byte will be read from in[*in_pos]. 385*2940b44dSPeter Avalos * *in_pos is updated only if decoding succeeds. 386*2940b44dSPeter Avalos * \param in_size Size of the input buffer; the first byte that 387*2940b44dSPeter Avalos * won't be read is in[in_size]. 388*2940b44dSPeter Avalos * \param out Beginning of the output buffer 389*2940b44dSPeter Avalos * \param out_pos The next byte will be written to out[*out_pos]. 390*2940b44dSPeter Avalos * *out_pos is updated only if decoding succeeds. 391*2940b44dSPeter Avalos * \param out_size Size of the out buffer; the first byte into 392*2940b44dSPeter Avalos * which no data is written to is out[out_size]. 393*2940b44dSPeter Avalos * 394*2940b44dSPeter Avalos * \return - LZMA_OK: Decoding was successful. 395*2940b44dSPeter Avalos * - LZMA_FORMAT_ERROR 396*2940b44dSPeter Avalos * - LZMA_OPTIONS_ERROR 397*2940b44dSPeter Avalos * - LZMA_DATA_ERROR 398*2940b44dSPeter Avalos * - LZMA_NO_CHECK: This can be returned only if using 399*2940b44dSPeter Avalos * the LZMA_TELL_NO_CHECK flag. 400*2940b44dSPeter Avalos * - LZMA_UNSUPPORTED_CHECK: This can be returned only if using 401*2940b44dSPeter Avalos * the LZMA_TELL_UNSUPPORTED_CHECK flag. 402*2940b44dSPeter Avalos * - LZMA_MEM_ERROR 403*2940b44dSPeter Avalos * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. 404*2940b44dSPeter Avalos * The minimum required memlimit value was stored to *memlimit. 405*2940b44dSPeter Avalos * - LZMA_BUF_ERROR: Output buffer was too small. 406*2940b44dSPeter Avalos * - LZMA_PROG_ERROR 407*2940b44dSPeter Avalos */ 408*2940b44dSPeter Avalos extern LZMA_API(lzma_ret) lzma_stream_buffer_decode( 409*2940b44dSPeter Avalos uint64_t *memlimit, uint32_t flags, lzma_allocator *allocator, 410*2940b44dSPeter Avalos const uint8_t *in, size_t *in_pos, size_t in_size, 411*2940b44dSPeter Avalos uint8_t *out, size_t *out_pos, size_t out_size) 412*2940b44dSPeter Avalos lzma_nothrow lzma_attr_warn_unused_result; 413