1 /*
2  * Definitions for handling the .xz file format
3  *
4  * Author: Lasse Collin <lasse.collin@tukaani.org>
5  *
6  * This file has been put into the public domain.
7  * You can do whatever you want with this file.
8  */
9 
10 #ifndef XZ_STREAM_H
11 #define XZ_STREAM_H
12 
13 /*
14  * See the .xz file format specification at
15  * http://tukaani.org/xz/xz-file-format.txt
16  * to understand the container format.
17  */
18 
19 #define STREAM_HEADER_SIZE 12
20 
21 #define HEADER_MAGIC "\3757zXZ"
22 #define HEADER_MAGIC_SIZE 6
23 
24 #define FOOTER_MAGIC "YZ"
25 #define FOOTER_MAGIC_SIZE 2
26 
27 /*
28  * Variable-length integer can hold a 63-bit unsigned integer or a special
29  * value indicating that the value is unknown.
30  *
31  * Experimental: vli_type can be defined to uint32_t to save a few bytes
32  * in code size (no effect on speed). Doing so limits the uncompressed and
33  * compressed size of the file to less than 256 MiB and may also weaken
34  * error detection slightly.
35  */
36 typedef uint64_t vli_type;
37 
38 #define VLI_MAX ((vli_type)-1 / 2)
39 #define VLI_UNKNOWN ((vli_type)-1)
40 
41 /* Maximum encoded size of a VLI */
42 #define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7)
43 
44 /* Integrity Check types */
45 enum xz_check {
46 	XZ_CHECK_NONE = 0,
47 	XZ_CHECK_CRC32 = 1,
48 	XZ_CHECK_CRC64 = 4,
49 	XZ_CHECK_SHA256 = 10
50 };
51 
52 /* Maximum possible Check ID */
53 #define XZ_CHECK_MAX 15
54 
55 #endif
56