lz4frame_static.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. LZ4 auto-framing library
  3. Header File for static linking only
  4. Copyright (C) 2011-2016, Yann Collet.
  5. BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
  6. Redistribution and use in source and binary forms, with or without
  7. modification, are permitted provided that the following conditions are
  8. met:
  9. * Redistributions of source code must retain the above copyright
  10. notice, this list of conditions and the following disclaimer.
  11. * Redistributions in binary form must reproduce the above
  12. copyright notice, this list of conditions and the following disclaimer
  13. in the documentation and/or other materials provided with the
  14. distribution.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  16. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  17. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  19. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. You can contact the author at :
  27. - LZ4 source repository : https://github.com/lz4/lz4
  28. - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
  29. */
  30. #ifndef LZ4FRAME_STATIC_H_0398209384
  31. #define LZ4FRAME_STATIC_H_0398209384
  32. #if defined (__cplusplus)
  33. extern "C" {
  34. #endif
  35. /* lz4frame_static.h should be used solely in the context of static linking.
  36. * It contains definitions which are not stable and may change in the future.
  37. * Never use it in the context of DLL linking.
  38. */
  39. /* --- Dependency --- */
  40. #include "lz4frame.h"
  41. /* --- Error List --- */
  42. #define LZ4F_LIST_ERRORS(ITEM) \
  43. ITEM(OK_NoError) \
  44. ITEM(ERROR_GENERIC) \
  45. ITEM(ERROR_maxBlockSize_invalid) \
  46. ITEM(ERROR_blockMode_invalid) \
  47. ITEM(ERROR_contentChecksumFlag_invalid) \
  48. ITEM(ERROR_compressionLevel_invalid) \
  49. ITEM(ERROR_headerVersion_wrong) \
  50. ITEM(ERROR_blockChecksum_invalid) \
  51. ITEM(ERROR_reservedFlag_set) \
  52. ITEM(ERROR_allocation_failed) \
  53. ITEM(ERROR_srcSize_tooLarge) \
  54. ITEM(ERROR_dstMaxSize_tooSmall) \
  55. ITEM(ERROR_frameHeader_incomplete) \
  56. ITEM(ERROR_frameType_unknown) \
  57. ITEM(ERROR_frameSize_wrong) \
  58. ITEM(ERROR_srcPtr_wrong) \
  59. ITEM(ERROR_decompressionFailed) \
  60. ITEM(ERROR_headerChecksum_invalid) \
  61. ITEM(ERROR_contentChecksum_invalid) \
  62. ITEM(ERROR_frameDecoding_alreadyStarted) \
  63. ITEM(ERROR_maxCode)
  64. #define LZ4F_GENERATE_ENUM(ENUM) LZ4F_##ENUM,
  65. /* enum list is exposed, to handle specific errors */
  66. typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM) } LZ4F_errorCodes;
  67. LZ4F_errorCodes LZ4F_getErrorCode(size_t functionResult);
  68. /**********************************
  69. * Bulk processing dictionary API
  70. *********************************/
  71. typedef struct LZ4F_CDict_s LZ4F_CDict;
  72. /*! LZ4_createCDict() :
  73. * When compressing multiple messages / blocks with the same dictionary, it's recommended to load it just once.
  74. * LZ4_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
  75. * LZ4_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
  76. * `dictBuffer` can be released after LZ4_CDict creation, since its content is copied within CDict */
  77. LZ4F_CDict* LZ4F_createCDict(const void* dictBuffer, size_t dictSize);
  78. void LZ4F_freeCDict(LZ4F_CDict* CDict);
  79. /*! LZ4_compressFrame_usingCDict() :
  80. * Compress an entire srcBuffer into a valid LZ4 frame using a digested Dictionary.
  81. * If cdict==NULL, compress without a dictionary.
  82. * dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr).
  83. * If this condition is not respected, function will fail (@return an errorCode).
  84. * The LZ4F_preferences_t structure is optional : you may provide NULL as argument,
  85. * but it's not recommended, as it's the only way to provide dictID in the frame header.
  86. * @return : number of bytes written into dstBuffer.
  87. * or an error code if it fails (can be tested using LZ4F_isError()) */
  88. size_t LZ4F_compressFrame_usingCDict(void* dst, size_t dstCapacity,
  89. const void* src, size_t srcSize,
  90. const LZ4F_CDict* cdict,
  91. const LZ4F_preferences_t* preferencesPtr);
  92. /*! LZ4F_compressBegin_usingCDict() :
  93. * Inits streaming dictionary compression, and writes the frame header into dstBuffer.
  94. * dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes.
  95. * `prefsPtr` is optional : you may provide NULL as argument,
  96. * however, it's the only way to provide dictID in the frame header.
  97. * @return : number of bytes written into dstBuffer for the header,
  98. * or an error code (which can be tested using LZ4F_isError()) */
  99. size_t LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctx,
  100. void* dstBuffer, size_t dstCapacity,
  101. const LZ4F_CDict* cdict,
  102. const LZ4F_preferences_t* prefsPtr);
  103. /*! LZ4F_decompress_usingDict() :
  104. * Same as LZ4F_decompress(), using a predefined dictionary.
  105. * Dictionary is used "in place", without any preprocessing.
  106. * It must remain accessible throughout the entire frame decoding. */
  107. size_t LZ4F_decompress_usingDict(LZ4F_dctx* dctxPtr,
  108. void* dstBuffer, size_t* dstSizePtr,
  109. const void* srcBuffer, size_t* srcSizePtr,
  110. const void* dict, size_t dictSize,
  111. const LZ4F_decompressOptions_t* decompressOptionsPtr);
  112. #if defined (__cplusplus)
  113. }
  114. #endif
  115. #endif /* LZ4FRAME_STATIC_H_0398209384 */