1 /* 2 * Copyright (c) 2016-present, Yann Collet, 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 11 12 #ifndef FILEIO_H_23981798732 13 #define FILEIO_H_23981798732 14 15 #define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressionParameters */ 16 #include "zstd.h" /* ZSTD_* */ 17 18 #if defined (__cplusplus) 19 extern "C" { 20 #endif 21 22 23 /* ************************************* 24 * Special i/o constants 25 **************************************/ 26 #define stdinmark "/*stdin*\\" 27 #define stdoutmark "/*stdout*\\" 28 #ifdef _WIN32 29 # define nulmark "nul" 30 #else 31 # define nulmark "/dev/null" 32 #endif 33 #define LZMA_EXTENSION ".lzma" 34 #define XZ_EXTENSION ".xz" 35 #define GZ_EXTENSION ".gz" 36 #define ZSTD_EXTENSION ".zst" 37 #define LZ4_EXTENSION ".lz4" 38 39 40 /*-************************************* 41 * Types 42 ***************************************/ 43 typedef enum { FIO_zstdCompression, FIO_gzipCompression, FIO_xzCompression, FIO_lzmaCompression, FIO_lz4Compression } FIO_compressionType_t; 44 45 typedef struct FIO_prefs_s FIO_prefs_t; 46 47 FIO_prefs_t* FIO_createPreferences(void); 48 void FIO_freePreferences(FIO_prefs_t* const prefs); 49 50 typedef struct FIO_display_prefs_s FIO_display_prefs_t; 51 52 /*-************************************* 53 * Parameters 54 ***************************************/ 55 void FIO_setCompressionType(FIO_prefs_t* const prefs, FIO_compressionType_t compressionType); 56 void FIO_overwriteMode(FIO_prefs_t* const prefs); 57 void FIO_setAdaptiveMode(FIO_prefs_t* const prefs, unsigned adapt); 58 void FIO_setAdaptMin(FIO_prefs_t* const prefs, int minCLevel); 59 void FIO_setAdaptMax(FIO_prefs_t* const prefs, int maxCLevel); 60 void FIO_setBlockSize(FIO_prefs_t* const prefs, int blockSize); 61 void FIO_setChecksumFlag(FIO_prefs_t* const prefs, int checksumFlag); 62 void FIO_setDictIDFlag(FIO_prefs_t* const prefs, int dictIDFlag); 63 void FIO_setLdmBucketSizeLog(FIO_prefs_t* const prefs, int ldmBucketSizeLog); 64 void FIO_setLdmFlag(FIO_prefs_t* const prefs, unsigned ldmFlag); 65 void FIO_setLdmHashRateLog(FIO_prefs_t* const prefs, int ldmHashRateLog); 66 void FIO_setLdmHashLog(FIO_prefs_t* const prefs, int ldmHashLog); 67 void FIO_setLdmMinMatch(FIO_prefs_t* const prefs, int ldmMinMatch); 68 void FIO_setMemLimit(FIO_prefs_t* const prefs, unsigned memLimit); 69 void FIO_setNbWorkers(FIO_prefs_t* const prefs, int nbWorkers); 70 void FIO_setOverlapLog(FIO_prefs_t* const prefs, int overlapLog); 71 void FIO_setRemoveSrcFile(FIO_prefs_t* const prefs, unsigned flag); 72 void FIO_setSparseWrite(FIO_prefs_t* const prefs, unsigned sparse); /**< 0: no sparse; 1: disable on stdout; 2: always enabled */ 73 void FIO_setRsyncable(FIO_prefs_t* const prefs, int rsyncable); 74 void FIO_setTargetCBlockSize(FIO_prefs_t* const prefs, size_t targetCBlockSize); 75 void FIO_setLiteralCompressionMode( 76 FIO_prefs_t* const prefs, 77 ZSTD_literalCompressionMode_e mode); 78 79 void FIO_setNoProgress(unsigned noProgress); 80 void FIO_setNotificationLevel(int level); 81 82 /*-************************************* 83 * Single File functions 84 ***************************************/ 85 /** FIO_compressFilename() : 86 @return : 0 == ok; 1 == pb with src file. */ 87 int FIO_compressFilename (FIO_prefs_t* const prefs, 88 const char* outfilename, const char* infilename, const char* dictFileName, 89 int compressionLevel, ZSTD_compressionParameters comprParams); 90 91 /** FIO_decompressFilename() : 92 @return : 0 == ok; 1 == pb with src file. */ 93 int FIO_decompressFilename (FIO_prefs_t* const prefs, 94 const char* outfilename, const char* infilename, const char* dictFileName); 95 96 int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel); 97 98 99 /*-************************************* 100 * Multiple File functions 101 ***************************************/ 102 /** FIO_compressMultipleFilenames() : 103 @return : nb of missing files */ 104 int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs, 105 const char** srcNamesTable, unsigned nbFiles, 106 const char* outFileName, const char* suffix, 107 const char* dictFileName, int compressionLevel, 108 ZSTD_compressionParameters comprParams); 109 110 /** FIO_decompressMultipleFilenames() : 111 @return : nb of missing or skipped files */ 112 int FIO_decompressMultipleFilenames(FIO_prefs_t* const prefs, 113 const char** srcNamesTable, unsigned nbFiles, 114 const char* outFileName, 115 const char* dictFileName); 116 117 118 /*-************************************* 119 * Advanced stuff (should actually be hosted elsewhere) 120 ***************************************/ 121 122 /* custom crash signal handler */ 123 void FIO_addAbortHandler(void); 124 125 126 127 #if defined (__cplusplus) 128 } 129 #endif 130 131 #endif /* FILEIO_H_23981798732 */ 132