spress.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef SPRESS_HEADER
  2. #define SPRESS_HEADER
  3. #define SPRESS_DEBUG (0)
  4. #include <string.h>
  5. #include <stdint.h>
  6. typedef uint32_t size_t;
  7. typedef struct spress_header {
  8. uint16_t magic; /* 0xed2b */
  9. uint8_t major_version; /* (0x1) - reject images with higher major versions */
  10. uint8_t minor_version; /* (0x0) - allow images with higer minor versions */
  11. uint8_t file_hdr_sz; /* file header size */
  12. uint8_t chunk_hdr_sz; /* chunk header size */
  13. uint16_t chunk_sz; /* chunk size */
  14. uint32_t compress_sz; /* compress file size */
  15. uint32_t decompress_sz; /* decompress file size */
  16. } spress_header_t;
  17. #define SPRESS_HEADER_MAGIC 0xed2b
  18. #define SPRESS_BLK_SIZE sizeof(uint32_t)
  19. #define SPRESS_BLK_MIN 2
  20. #define SPRESS_BLK_MAX 128
  21. #define CHUNK_TYPE_RAW 0x0
  22. #define CHUNK_TYPE_FILL 0x1
  23. #define CHUNK_TYPE_MASK 0x1
  24. typedef struct chunk_header {
  25. uint8_t data_sz; /* size for chunk data (bit0: 0-raw, 1-fill) */
  26. } chunk_header_t;
  27. size_t spr_size_decompressed(const char* source);
  28. size_t spr_size_compressed(const char* source);
  29. size_t spr_compress(const char* source, char* destination, size_t size);
  30. size_t spr_decompress(const char* source, char* destination);
  31. size_t spr_compress_index(const char* source, char* destination, size_t size);
  32. size_t spr_compress_data(const char* source, char* destination, size_t size);
  33. #endif