lz4file.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. LZ4 file library
  3. Header File
  4. Copyright (C) 2022, Xiaomi Inc.
  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. #if defined (__cplusplus)
  31. extern "C" {
  32. #endif
  33. #ifndef LZ4FILE_H
  34. #define LZ4FILE_H
  35. #include <stdio.h>
  36. #include "lz4frame_static.h"
  37. typedef struct LZ4_readFile_s LZ4_readFile_t;
  38. typedef struct LZ4_writeFile_s LZ4_writeFile_t;
  39. /*! LZ4F_readOpen() :
  40. * Set read lz4file handle.
  41. * `lz4f` will set a lz4file handle.
  42. * `fp` must be the return value of the lz4 file opened by fopen.
  43. */
  44. LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_readOpen(LZ4_readFile_t** lz4fRead, FILE* fp);
  45. /*! LZ4F_read() :
  46. * Read lz4file content to buffer.
  47. * `lz4f` must use LZ4_readOpen to set first.
  48. * `buf` read data buffer.
  49. * `size` read data buffer size.
  50. */
  51. LZ4FLIB_STATIC_API size_t LZ4F_read(LZ4_readFile_t* lz4fRead, void* buf, size_t size);
  52. /*! LZ4F_readClose() :
  53. * Close lz4file handle.
  54. * `lz4f` must use LZ4_readOpen to set first.
  55. */
  56. LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_readClose(LZ4_readFile_t* lz4fRead);
  57. /*! LZ4F_writeOpen() :
  58. * Set write lz4file handle.
  59. * `lz4f` will set a lz4file handle.
  60. * `fp` must be the return value of the lz4 file opened by fopen.
  61. */
  62. LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_writeOpen(LZ4_writeFile_t** lz4fWrite, FILE* fp, const LZ4F_preferences_t* prefsPtr);
  63. /*! LZ4F_write() :
  64. * Write buffer to lz4file.
  65. * `lz4f` must use LZ4F_writeOpen to set first.
  66. * `buf` write data buffer.
  67. * `size` write data buffer size.
  68. */
  69. LZ4FLIB_STATIC_API size_t LZ4F_write(LZ4_writeFile_t* lz4fWrite, void* buf, size_t size);
  70. /*! LZ4F_writeClose() :
  71. * Close lz4file handle.
  72. * `lz4f` must use LZ4F_writeOpen to set first.
  73. */
  74. LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_writeClose(LZ4_writeFile_t* lz4fWrite);
  75. #endif /* LZ4FILE_H */
  76. #if defined (__cplusplus)
  77. }
  78. #endif