brintos

brintos / linux-shallow public Read only

0
0
Text · 1.4 KiB · 55f9f6f Raw
62 lines · c
1/* SPDX-License-Identifier: 0BSD */2 3/*4 * Definitions for handling the .xz file format5 *6 * Author: Lasse Collin <lasse.collin@tukaani.org>7 */8 9#ifndef XZ_STREAM_H10#define XZ_STREAM_H11 12#if defined(__KERNEL__) && !XZ_INTERNAL_CRC3213#	include <linux/crc32.h>14#	undef crc3215#	define xz_crc32(buf, size, crc) \16		(~crc32_le(~(uint32_t)(crc), buf, size))17#endif18 19/*20 * See the .xz file format specification at21 * https://tukaani.org/xz/xz-file-format.txt22 * to understand the container format.23 */24 25#define STREAM_HEADER_SIZE 1226 27#define HEADER_MAGIC "\3757zXZ"28#define HEADER_MAGIC_SIZE 629 30#define FOOTER_MAGIC "YZ"31#define FOOTER_MAGIC_SIZE 232 33/*34 * Variable-length integer can hold a 63-bit unsigned integer or a special35 * value indicating that the value is unknown.36 *37 * Experimental: vli_type can be defined to uint32_t to save a few bytes38 * in code size (no effect on speed). Doing so limits the uncompressed and39 * compressed size of the file to less than 256 MiB and may also weaken40 * error detection slightly.41 */42typedef 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 */51enum xz_check {52	XZ_CHECK_NONE = 0,53	XZ_CHECK_CRC32 = 1,54	XZ_CHECK_CRC64 = 4,55	XZ_CHECK_SHA256 = 1056};57 58/* Maximum possible Check ID */59#define XZ_CHECK_MAX 1560 61#endif62