lz4io.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. LZ4io.h - LZ4 File/Stream Interface
  3. Copyright (C) Yann Collet 2011-2020
  4. GPL v2 License
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License along
  14. with this program; if not, write to the Free Software Foundation, Inc.,
  15. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. You can contact the author at :
  17. - LZ4 source repository : https://github.com/lz4/lz4
  18. - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
  19. */
  20. /*
  21. Note : this is stand-alone program.
  22. It is not part of LZ4 compression library, it is a user code of the LZ4 library.
  23. - The license of LZ4 library is BSD.
  24. - The license of xxHash library is BSD.
  25. - The license of this source file is GPLv2.
  26. */
  27. #ifndef LZ4IO_H_237902873
  28. #define LZ4IO_H_237902873
  29. /*--- Dependency ---*/
  30. #include <stddef.h> /* size_t */
  31. /* ************************************************** */
  32. /* Special input/output values */
  33. /* ************************************************** */
  34. #define stdinmark "stdin"
  35. #define stdoutmark "stdout"
  36. #define NULL_OUTPUT "null"
  37. #ifdef _WIN32
  38. #define nulmark "nul"
  39. #else
  40. #define nulmark "/dev/null"
  41. #endif
  42. /* ************************************************** */
  43. /* ****************** Type Definitions ************** */
  44. /* ************************************************** */
  45. typedef struct LZ4IO_prefs_s LZ4IO_prefs_t;
  46. LZ4IO_prefs_t* LZ4IO_defaultPreferences(void);
  47. void LZ4IO_freePreferences(LZ4IO_prefs_t* prefs);
  48. /* ************************************************** */
  49. /* ****************** Functions ********************* */
  50. /* ************************************************** */
  51. /* if output_filename == stdoutmark, writes to stdout */
  52. int LZ4IO_compressFilename(const char* input_filename, const char* output_filename, int compressionlevel, const LZ4IO_prefs_t* prefs);
  53. int LZ4IO_decompressFilename(const char* input_filename, const char* output_filename, const LZ4IO_prefs_t* prefs);
  54. /* if suffix == stdoutmark, writes to stdout */
  55. int LZ4IO_compressMultipleFilenames(const char** inFileNamesTable, int ifntSize, const char* suffix, int compressionlevel, const LZ4IO_prefs_t* prefs);
  56. int LZ4IO_decompressMultipleFilenames(const char** inFileNamesTable, int ifntSize, const char* suffix, const LZ4IO_prefs_t* prefs);
  57. /* ************************************************** */
  58. /* ****************** Parameters ******************** */
  59. /* ************************************************** */
  60. int LZ4IO_setDictionaryFilename(LZ4IO_prefs_t* const prefs, const char* dictionaryFilename);
  61. /* Default setting : passThrough = 0;
  62. return : passThrough mode (0/1) */
  63. int LZ4IO_setPassThrough(LZ4IO_prefs_t* const prefs, int yes);
  64. /* Default setting : overwrite = 1;
  65. return : overwrite mode (0/1) */
  66. int LZ4IO_setOverwrite(LZ4IO_prefs_t* const prefs, int yes);
  67. /* Default setting : testMode = 0;
  68. return : testMode (0/1) */
  69. int LZ4IO_setTestMode(LZ4IO_prefs_t* const prefs, int yes);
  70. /* blockSizeID : valid values : 4-5-6-7
  71. return : 0 if error, blockSize if OK */
  72. size_t LZ4IO_setBlockSizeID(LZ4IO_prefs_t* const prefs, unsigned blockSizeID);
  73. /* blockSize : valid values : 32 -> 4MB
  74. return : 0 if error, actual blocksize if OK */
  75. size_t LZ4IO_setBlockSize(LZ4IO_prefs_t* const prefs, size_t blockSize);
  76. /* Default setting : independent blocks */
  77. typedef enum { LZ4IO_blockLinked=0, LZ4IO_blockIndependent} LZ4IO_blockMode_t;
  78. int LZ4IO_setBlockMode(LZ4IO_prefs_t* const prefs, LZ4IO_blockMode_t blockMode);
  79. /* Default setting : no block checksum */
  80. int LZ4IO_setBlockChecksumMode(LZ4IO_prefs_t* const prefs, int xxhash);
  81. /* Default setting : stream checksum enabled */
  82. int LZ4IO_setStreamChecksumMode(LZ4IO_prefs_t* const prefs, int xxhash);
  83. /* Default setting : 0 (no notification) */
  84. int LZ4IO_setNotificationLevel(int level);
  85. /* Default setting : 0 (disabled) */
  86. int LZ4IO_setSparseFile(LZ4IO_prefs_t* const prefs, int enable);
  87. /* Default setting : 0 == no content size present in frame header */
  88. int LZ4IO_setContentSize(LZ4IO_prefs_t* const prefs, int enable);
  89. /* Default setting : 0 == src file preserved */
  90. void LZ4IO_setRemoveSrcFile(LZ4IO_prefs_t* const prefs, unsigned flag);
  91. /* Default setting : 0 == favor compression ratio
  92. * Note : 1 only works for high compression levels (10+) */
  93. void LZ4IO_favorDecSpeed(LZ4IO_prefs_t* const prefs, int favor);
  94. /* implement --list
  95. * @return 0 on success, 1 on error */
  96. int LZ4IO_displayCompressedFilesInfo(const char** inFileNames, size_t ifnIdx);
  97. #endif /* LZ4IO_H_237902873 */