18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Definitions for handling the .xz file format 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Author: Lasse Collin <lasse.collin@tukaani.org> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This file has been put into the public domain. 78c2ecf20Sopenharmony_ci * You can do whatever you want with this file. 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#ifndef XZ_STREAM_H 118c2ecf20Sopenharmony_ci#define XZ_STREAM_H 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#if defined(__KERNEL__) && !XZ_INTERNAL_CRC32 148c2ecf20Sopenharmony_ci# include <linux/crc32.h> 158c2ecf20Sopenharmony_ci# undef crc32 168c2ecf20Sopenharmony_ci# define xz_crc32(buf, size, crc) \ 178c2ecf20Sopenharmony_ci (~crc32_le(~(uint32_t)(crc), buf, size)) 188c2ecf20Sopenharmony_ci#endif 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci * See the .xz file format specification at 228c2ecf20Sopenharmony_ci * https://tukaani.org/xz/xz-file-format.txt 238c2ecf20Sopenharmony_ci * to understand the container format. 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#define STREAM_HEADER_SIZE 12 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#define HEADER_MAGIC "\3757zXZ" 298c2ecf20Sopenharmony_ci#define HEADER_MAGIC_SIZE 6 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define FOOTER_MAGIC "YZ" 328c2ecf20Sopenharmony_ci#define FOOTER_MAGIC_SIZE 2 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* 358c2ecf20Sopenharmony_ci * Variable-length integer can hold a 63-bit unsigned integer or a special 368c2ecf20Sopenharmony_ci * value indicating that the value is unknown. 378c2ecf20Sopenharmony_ci * 388c2ecf20Sopenharmony_ci * Experimental: vli_type can be defined to uint32_t to save a few bytes 398c2ecf20Sopenharmony_ci * in code size (no effect on speed). Doing so limits the uncompressed and 408c2ecf20Sopenharmony_ci * compressed size of the file to less than 256 MiB and may also weaken 418c2ecf20Sopenharmony_ci * error detection slightly. 428c2ecf20Sopenharmony_ci */ 438c2ecf20Sopenharmony_citypedef uint64_t vli_type; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define VLI_MAX ((vli_type)-1 / 2) 468c2ecf20Sopenharmony_ci#define VLI_UNKNOWN ((vli_type)-1) 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci/* Maximum encoded size of a VLI */ 498c2ecf20Sopenharmony_ci#define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7) 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/* Integrity Check types */ 528c2ecf20Sopenharmony_cienum xz_check { 538c2ecf20Sopenharmony_ci XZ_CHECK_NONE = 0, 548c2ecf20Sopenharmony_ci XZ_CHECK_CRC32 = 1, 558c2ecf20Sopenharmony_ci XZ_CHECK_CRC64 = 4, 568c2ecf20Sopenharmony_ci XZ_CHECK_SHA256 = 10 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci/* Maximum possible Check ID */ 608c2ecf20Sopenharmony_ci#define XZ_CHECK_MAX 15 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#endif 63