zstd_v03.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include <contrib/libs/zstd06/renames.h>
  2. /*
  3. zstd_v03 - decoder for 0.3 format
  4. Header File
  5. Copyright (C) 2015, Yann Collet.
  6. BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions are
  9. met:
  10. * Redistributions of source code must retain the above copyright
  11. notice, this list of conditions and the following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the following disclaimer
  14. in the documentation and/or other materials provided with the
  15. distribution.
  16. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  17. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  19. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  20. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  21. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  22. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. You can contact the author at :
  28. - zstd source repository : https://github.com/Cyan4973/zstd
  29. - ztsd public forum : https://groups.google.com/forum/#!forum/lz4c
  30. */
  31. #pragma once
  32. #if defined (__cplusplus)
  33. extern "C" {
  34. #endif
  35. /* *************************************
  36. * Includes
  37. ***************************************/
  38. #include <stddef.h> /* size_t */
  39. /* *************************************
  40. * Simple one-step function
  41. ***************************************/
  42. /**
  43. ZSTDv03_decompress() : decompress ZSTD frames compliant with v0.3.x format
  44. compressedSize : is the exact source size
  45. maxOriginalSize : is the size of the 'dst' buffer, which must be already allocated.
  46. It must be equal or larger than originalSize, otherwise decompression will fail.
  47. return : the number of bytes decompressed into destination buffer (originalSize)
  48. or an errorCode if it fails (which can be tested using ZSTDv01_isError())
  49. */
  50. size_t ZSTDv03_decompress( void* dst, size_t maxOriginalSize,
  51. const void* src, size_t compressedSize);
  52. /**
  53. ZSTDv03_isError() : tells if the result of ZSTDv03_decompress() is an error
  54. */
  55. unsigned ZSTDv03_isError(size_t code);
  56. /* *************************************
  57. * Advanced functions
  58. ***************************************/
  59. typedef struct ZSTDv03_Dctx_s ZSTDv03_Dctx;
  60. ZSTDv03_Dctx* ZSTDv03_createDCtx(void);
  61. size_t ZSTDv03_freeDCtx(ZSTDv03_Dctx* dctx);
  62. size_t ZSTDv03_decompressDCtx(void* ctx,
  63. void* dst, size_t maxOriginalSize,
  64. const void* src, size_t compressedSize);
  65. /* *************************************
  66. * Streaming functions
  67. ***************************************/
  68. size_t ZSTDv03_resetDCtx(ZSTDv03_Dctx* dctx);
  69. size_t ZSTDv03_nextSrcSizeToDecompress(ZSTDv03_Dctx* dctx);
  70. size_t ZSTDv03_decompressContinue(ZSTDv03_Dctx* dctx, void* dst, size_t maxDstSize, const void* src, size_t srcSize);
  71. /**
  72. Use above functions alternatively.
  73. ZSTD_nextSrcSizeToDecompress() tells how much bytes to provide as 'srcSize' to ZSTD_decompressContinue().
  74. ZSTD_decompressContinue() will use previous data blocks to improve compression if they are located prior to current block.
  75. Result is the number of bytes regenerated within 'dst'.
  76. It can be zero, which is not an error; it just means ZSTD_decompressContinue() has decoded some header.
  77. */
  78. /* *************************************
  79. * Prefix - version detection
  80. ***************************************/
  81. #define ZSTDv03_magicNumber 0xFD2FB523 /* v0.3 */
  82. #if defined (__cplusplus)
  83. }
  84. #endif