xz_stream.h 1.4 KB

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