xz_stream.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* xz_stream.h - Definitions for handling the .xz file format */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2010 Free Software Foundation, Inc.
  5. *
  6. * GRUB is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * GRUB is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /*
  20. * This file is based on code from XZ embedded project
  21. * http://tukaani.org/xz/embedded.html
  22. */
  23. #ifndef XZ_STREAM_H
  24. #define XZ_STREAM_H
  25. /*
  26. * See the .xz file format specification at
  27. * http://tukaani.org/xz/xz-file-format.txt
  28. * to understand the container format.
  29. */
  30. #define STREAM_HEADER_SIZE 12
  31. #define HEADER_MAGIC "\3757zXZ\0"
  32. #define HEADER_MAGIC_SIZE 6
  33. #define FOOTER_MAGIC "YZ"
  34. #define FOOTER_MAGIC_SIZE 2
  35. /*
  36. * Variable-length integer can hold a 63-bit unsigned integer, or a special
  37. * value to indicate that the value is unknown.
  38. */
  39. typedef uint64_t vli_type;
  40. #define VLI_MAX ((vli_type)-1 / 2)
  41. #define VLI_UNKNOWN ((vli_type)-1)
  42. /* Maximum encoded size of a VLI */
  43. #define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7)
  44. #endif