Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Definitions for handling the .xz file format
0003  *
0004  * Author: Lasse Collin <lasse.collin@tukaani.org>
0005  *
0006  * This file has been put into the public domain.
0007  * You can do whatever you want with this file.
0008  */
0009 
0010 #ifndef XZ_STREAM_H
0011 #define XZ_STREAM_H
0012 
0013 #if defined(__KERNEL__) && !XZ_INTERNAL_CRC32
0014 #   include <linux/crc32.h>
0015 #   undef crc32
0016 #   define xz_crc32(buf, size, crc) \
0017         (~crc32_le(~(uint32_t)(crc), buf, size))
0018 #endif
0019 
0020 /*
0021  * See the .xz file format specification at
0022  * https://tukaani.org/xz/xz-file-format.txt
0023  * to understand the container format.
0024  */
0025 
0026 #define STREAM_HEADER_SIZE 12
0027 
0028 #define HEADER_MAGIC "\3757zXZ"
0029 #define HEADER_MAGIC_SIZE 6
0030 
0031 #define FOOTER_MAGIC "YZ"
0032 #define FOOTER_MAGIC_SIZE 2
0033 
0034 /*
0035  * Variable-length integer can hold a 63-bit unsigned integer or a special
0036  * value indicating that the value is unknown.
0037  *
0038  * Experimental: vli_type can be defined to uint32_t to save a few bytes
0039  * in code size (no effect on speed). Doing so limits the uncompressed and
0040  * compressed size of the file to less than 256 MiB and may also weaken
0041  * error detection slightly.
0042  */
0043 typedef uint64_t vli_type;
0044 
0045 #define VLI_MAX ((vli_type)-1 / 2)
0046 #define VLI_UNKNOWN ((vli_type)-1)
0047 
0048 /* Maximum encoded size of a VLI */
0049 #define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7)
0050 
0051 /* Integrity Check types */
0052 enum xz_check {
0053     XZ_CHECK_NONE = 0,
0054     XZ_CHECK_CRC32 = 1,
0055     XZ_CHECK_CRC64 = 4,
0056     XZ_CHECK_SHA256 = 10
0057 };
0058 
0059 /* Maximum possible Check ID */
0060 #define XZ_CHECK_MAX 15
0061 
0062 #endif