aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/api/lzma/metadata.h
blob: 69592a3a65eefd8428934c5146ae97ab4166ebf9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
 * \file        lzma/metadata.h
 * \brief       Metadata handling
 *
 * \author      Copyright (C) 1999-2006 Igor Pavlov
 * \author      Copyright (C) 2007 Lasse Collin
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

#ifndef LZMA_H_INTERNAL
#	error Never include this file directly. Use <lzma.h> instead.
#endif


/**
 * \brief       Information stored into a Metadata Block
 *
 * This structure holds all the information that can be stored to
 * a Metadata Block.
 */
typedef struct {
	/**
	 * \brief       Size of Header Metadata Block
	 */
	lzma_vli header_metadata_size;

	/**
	 * \brief       Total Size of the Stream
	 */
	lzma_vli total_size;

	/**
	 * \brief       Uncompressed Size of the Stream
	 */
	lzma_vli uncompressed_size;

	/**
	 * \brief       Index of the Blocks stored in the Stream
	 */
	lzma_index *index;

	/**
	 * \brief       Extra information
	 */
	lzma_extra *extra;

} lzma_metadata;


/**
 * \brief       Calculate the encoded size of Metadata
 *
 * \return      Uncompressed size of the Metadata in encoded form. This value
 *              may be passed to Block encoder as Uncompressed Size when using
 *              Metadata filter. On error, zero is returned.
 */
extern lzma_vli lzma_metadata_size(const lzma_metadata *metadata);


/**
 * \brief       Initializes Metadata encoder
 *
 * \param       coder       Pointer to a pointer to hold Metadata encoder's
 *                          internal state. Original value is ignored, thus
 *                          you don't need to initialize the pointer.
 * \param       allocator   Custom memory allocator; usually NULL.
 * \param       metadata    Pointer to Metadata to encoded
 *
 * \return      - LZMA_OK: Initialization succeeded.
 *              - LZMA_MEM_ERROR: Cannot allocate memory for *coder.
 *
 * The initialization function makes internal copy of the *metadata structure.
 * However, the linked lists metadata->index and metadata->extra are NOT
 * copied. Thus, the application may destroy *metadata after initialization
 * if it likes, but not Index or Extra.
 */
extern lzma_ret lzma_metadata_encoder(lzma_stream *strm,
		lzma_options_block *options, const lzma_metadata *metadata);


/**
 * \brief       Initializes Metadata decoder
 *
 * \param       want_extra    If this is true, Extra Records will be stored
 *                            to metadata->extra. If this is false, Extra
 *                            Records will be parsed but not stored anywhere,
 *                            metadata->extra will be set to NULL.
 */
extern lzma_ret lzma_metadata_decoder(
		lzma_stream *strm, lzma_options_block *options,
		lzma_metadata *metadata, lzma_bool want_extra);