| 1 | /* SPDX-License-Identifier: 0BSD */ | 
|---|
| 2 |  | 
|---|
| 3 | /* | 
|---|
| 4 | * Definitions for handling the .xz file format | 
|---|
| 5 | * | 
|---|
| 6 | * Author: Lasse Collin <lasse.collin@tukaani.org> | 
|---|
| 7 | */ | 
|---|
| 8 |  | 
|---|
| 9 | #ifndef XZ_STREAM_H | 
|---|
| 10 | #define XZ_STREAM_H | 
|---|
| 11 |  | 
|---|
| 12 | #if defined(__KERNEL__) && !XZ_INTERNAL_CRC32 | 
|---|
| 13 | #	include <linux/crc32.h> | 
|---|
| 14 | #	undef crc32 | 
|---|
| 15 | #	define xz_crc32(buf, size, crc) \ | 
|---|
| 16 | (~crc32_le(~(uint32_t)(crc), buf, size)) | 
|---|
| 17 | #endif | 
|---|
| 18 |  | 
|---|
| 19 | /* | 
|---|
| 20 | * See the .xz file format specification at | 
|---|
| 21 | * https://tukaani.org/xz/xz-file-format.txt | 
|---|
| 22 | * to understand the container format. | 
|---|
| 23 | */ | 
|---|
| 24 |  | 
|---|
| 25 | #define  12 | 
|---|
| 26 |  | 
|---|
| 27 | #define  "\3757zXZ" | 
|---|
| 28 | #define  6 | 
|---|
| 29 |  | 
|---|
| 30 | #define  "YZ" | 
|---|
| 31 | #define  2 | 
|---|
| 32 |  | 
|---|
| 33 | /* | 
|---|
| 34 | * Variable-length integer can hold a 63-bit unsigned integer or a special | 
|---|
| 35 | * value indicating that the value is unknown. | 
|---|
| 36 | * | 
|---|
| 37 | * Experimental: vli_type can be defined to uint32_t to save a few bytes | 
|---|
| 38 | * in code size (no effect on speed). Doing so limits the uncompressed and | 
|---|
| 39 | * compressed size of the file to less than 256 MiB and may also weaken | 
|---|
| 40 | * error detection slightly. | 
|---|
| 41 | */ | 
|---|
| 42 | typedef uint64_t vli_type; | 
|---|
| 43 |  | 
|---|
| 44 | #define VLI_MAX ((vli_type)-1 / 2) | 
|---|
| 45 | #define VLI_UNKNOWN ((vli_type)-1) | 
|---|
| 46 |  | 
|---|
| 47 | /* Maximum encoded size of a VLI */ | 
|---|
| 48 | #define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7) | 
|---|
| 49 |  | 
|---|
| 50 | /* Integrity Check types */ | 
|---|
| 51 | enum xz_check { | 
|---|
| 52 | XZ_CHECK_NONE = 0, | 
|---|
| 53 | XZ_CHECK_CRC32 = 1, | 
|---|
| 54 | XZ_CHECK_CRC64 = 4, | 
|---|
| 55 | XZ_CHECK_SHA256 = 10 | 
|---|
| 56 | }; | 
|---|
| 57 |  | 
|---|
| 58 | /* Maximum possible Check ID */ | 
|---|
| 59 | #define XZ_CHECK_MAX 15 | 
|---|
| 60 |  | 
|---|
| 61 | #endif | 
|---|
| 62 |  | 
|---|