zstd_decompress.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (c) Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under both the BSD-style license (found in the
  6. * LICENSE file in the root directory of this source tree) and the GPLv2 (found
  7. * in the COPYING file in the root directory of this source tree).
  8. * You may select, at your option, one of the above-listed licenses.
  9. */
  10. #include <stddef.h> /* size_t */
  11. /******* EXPOSED TYPES ********************************************************/
  12. /*
  13. * Contains the parsed contents of a dictionary
  14. * This includes Huffman and FSE tables used for decoding and data on offsets
  15. */
  16. typedef struct dictionary_s dictionary_t;
  17. /******* END EXPOSED TYPES ****************************************************/
  18. /******* DECOMPRESSION FUNCTIONS **********************************************/
  19. /// Zstandard decompression functions.
  20. /// `dst` must point to a space at least as large as the reconstructed output.
  21. size_t ZSTD_decompress(void *const dst, const size_t dst_len,
  22. const void *const src, const size_t src_len);
  23. /// If `dict != NULL` and `dict_len >= 8`, does the same thing as
  24. /// `ZSTD_decompress` but uses the provided dict
  25. size_t ZSTD_decompress_with_dict(void *const dst, const size_t dst_len,
  26. const void *const src, const size_t src_len,
  27. dictionary_t* parsed_dict);
  28. /// Get the decompressed size of an input stream so memory can be allocated in
  29. /// advance
  30. /// Returns -1 if the size can't be determined
  31. /// Assumes decompression of a single frame
  32. size_t ZSTD_get_decompressed_size(const void *const src, const size_t src_len);
  33. /******* END DECOMPRESSION FUNCTIONS ******************************************/
  34. /******* DICTIONARY MANAGEMENT ***********************************************/
  35. /*
  36. * Return a valid dictionary_t pointer for use with dictionary initialization
  37. * or decompression
  38. */
  39. dictionary_t* create_dictionary(void);
  40. /*
  41. * Parse a provided dictionary blob for use in decompression
  42. * `src` -- must point to memory space representing the dictionary
  43. * `src_len` -- must provide the dictionary size
  44. * `dict` -- will contain the parsed contents of the dictionary and
  45. * can be used for decompression
  46. */
  47. void parse_dictionary(dictionary_t *const dict, const void *src,
  48. size_t src_len);
  49. /*
  50. * Free internal Huffman tables, FSE tables, and dictionary content
  51. */
  52. void free_dictionary(dictionary_t *const dict);
  53. /******* END DICTIONARY MANAGEMENT *******************************************/