2 * \file lzma/stream_flags.h
3 * \brief .lzma Stream Header and Stream Footer encoder and decoder
5 * \author Copyright (C) 1999-2006 Igor Pavlov
6 * \author Copyright (C) 2007 Lasse Collin
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
19 #ifndef LZMA_H_INTERNAL
20 # error Never include this file directly. Use <lzma.h> instead.
25 * \brief Size of Stream Header and Stream Footer
27 * Stream Header and Stream Footer have the same size and they are not
28 * going to change even if a newer version of the .lzma file format is
29 * developed in future.
31 #define LZMA_STREAM_HEADER_SIZE 12
35 * Options for encoding and decoding Stream Header and Stream Footer
39 * Backward Size must be a multiple of four bytes. In this Stream
40 * format version Backward Size is the size of the Index field.
42 lzma_vli backward_size;
43 # define LZMA_BACKWARD_SIZE_MIN 4
44 # define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34)
47 * Type of the Check calculated from uncompressed data
49 lzma_check_type check;
55 * \brief Encode Stream Header
57 * \param out Beginning of the output buffer of
58 * LZMA_STREAM_HEADER_SIZE bytes.
59 * \param options Stream Header options to be encoded.
60 * options->index_size is ignored and doesn't
61 * need to be initialized.
63 * \return - LZMA_OK: Encoding was successful.
64 * - LZMA_PROG_ERROR: Invalid options.
66 extern lzma_ret lzma_stream_header_encode(
67 const lzma_stream_flags *options, uint8_t *out);
71 * \brief Encode Stream Footer
73 * \param out Beginning of the output buffer of
74 * LZMA_STREAM_HEADER_SIZE bytes.
75 * \param options Stream Footer options to be encoded.
77 * \return - LZMA_OK: Encoding was successful.
78 * - LZMA_PROG_ERROR: Invalid options.
80 extern lzma_ret lzma_stream_footer_encode(
81 const lzma_stream_flags *options, uint8_t *out);
85 * \brief Decode Stream Header
87 * \param options Stream Header options to be encoded.
88 * \param in Beginning of the input buffer of
89 * LZMA_STREAM_HEADER_SIZE bytes.
91 * options->index_size is always set to LZMA_VLI_VALUE_UNKNOWN. This is to
92 * help comparing Stream Flags from Stream Header and Stream Footer with
93 * lzma_stream_flags_equal().
95 * \return - LZMA_OK: Decoding was successful.
96 * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
97 * buffer cannot be Stream Header.
98 * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header
100 * - LZMA_HEADER_ERROR: Unsupported options are present
103 extern lzma_ret lzma_stream_header_decode(
104 lzma_stream_flags *options, const uint8_t *in);
108 * \brief Decode Stream Footer
110 * \param options Stream Header options to be encoded.
111 * \param in Beginning of the input buffer of
112 * LZMA_STREAM_HEADER_SIZE bytes.
114 * \return - LZMA_OK: Decoding was successful.
115 * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
116 * buffer cannot be Stream Footer.
117 * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the footer
119 * - LZMA_HEADER_ERROR: Unsupported options are present
122 extern lzma_ret lzma_stream_footer_decode(
123 lzma_stream_flags *options, const uint8_t *in);
127 * \brief Compare two lzma_stream_flags structures
129 * index_size values are compared only if both are not LZMA_VLI_VALUE_UNKNOWN.
131 * \return true if both structures are considered equal; false otherwise.
133 extern lzma_bool lzma_stream_flags_equal(
134 const lzma_stream_flags *a, lzma_stream_flags *b);