1229159Sadrian/* 2229159Sadrian * Definitions for handling the .xz file format 3229159Sadrian * 4229159Sadrian * Author: Lasse Collin <lasse.collin@tukaani.org> 5229159Sadrian * 6229159Sadrian * This file has been put into the public domain. 7229159Sadrian * You can do whatever you want with this file. 8229159Sadrian */ 9229159Sadrian 10229159Sadrian#ifndef XZ_STREAM_H 11229159Sadrian#define XZ_STREAM_H 12229159Sadrian 13229159Sadrian#if defined(__KERNEL__) && !XZ_INTERNAL_CRC32 14229159Sadrian# include <linux/crc32.h> 15229159Sadrian# undef crc32 16229159Sadrian# define xz_crc32(buf, size, crc) \ 17229159Sadrian (~crc32_le(~(uint32_t)(crc), buf, size)) 18229159Sadrian#endif 19229159Sadrian 20229159Sadrian/* 21229159Sadrian * See the .xz file format specification at 22229159Sadrian * http://tukaani.org/xz/xz-file-format.txt 23229159Sadrian * to understand the container format. 24229159Sadrian */ 25229159Sadrian 26229159Sadrian#define STREAM_HEADER_SIZE 12 27229159Sadrian 28229159Sadrian#define HEADER_MAGIC "\3757zXZ" 29229159Sadrian#define HEADER_MAGIC_SIZE 6 30229159Sadrian 31229159Sadrian#define FOOTER_MAGIC "YZ" 32229159Sadrian#define FOOTER_MAGIC_SIZE 2 33229159Sadrian 34229159Sadrian/* 35229159Sadrian * Variable-length integer can hold a 63-bit unsigned integer or a special 36229159Sadrian * value indicating that the value is unknown. 37229159Sadrian * 38229159Sadrian * Experimental: vli_type can be defined to uint32_t to save a few bytes 39229159Sadrian * in code size (no effect on speed). Doing so limits the uncompressed and 40229159Sadrian * compressed size of the file to less than 256 MiB and may also weaken 41229159Sadrian * error detection slightly. 42229159Sadrian */ 43229159Sadriantypedef uint64_t vli_type; 44229159Sadrian 45229159Sadrian#define VLI_MAX ((vli_type)-1 / 2) 46229159Sadrian#define VLI_UNKNOWN ((vli_type)-1) 47229159Sadrian 48229159Sadrian/* Maximum encoded size of a VLI */ 49229159Sadrian#define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7) 50229159Sadrian 51229159Sadrian/* Integrity Check types */ 52229159Sadrianenum xz_check { 53229159Sadrian XZ_CHECK_NONE = 0, 54229159Sadrian XZ_CHECK_CRC32 = 1, 55229159Sadrian XZ_CHECK_CRC64 = 4, 56229159Sadrian XZ_CHECK_SHA256 = 10 57229159Sadrian}; 58229159Sadrian 59229159Sadrian/* Maximum possible Check ID */ 60229159Sadrian#define XZ_CHECK_MAX 15 61229159Sadrian 62229159Sadrian#endif 63