xref: /freebsd/sys/contrib/zstd/programs/fileio.h (revision 4bc52338)
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_setLiteralCompressionMode(
75         FIO_prefs_t* const prefs,
76         ZSTD_literalCompressionMode_e mode);
77 
78 void FIO_setNoProgress(unsigned noProgress);
79 void FIO_setNotificationLevel(int level);
80 
81 /*-*************************************
82 *  Single File functions
83 ***************************************/
84 /** FIO_compressFilename() :
85     @return : 0 == ok;  1 == pb with src file. */
86 int FIO_compressFilename (FIO_prefs_t* const prefs,
87                           const char* outfilename, const char* infilename, const char* dictFileName,
88                           int compressionLevel, ZSTD_compressionParameters comprParams);
89 
90 /** FIO_decompressFilename() :
91     @return : 0 == ok;  1 == pb with src file. */
92 int FIO_decompressFilename (FIO_prefs_t* const prefs,
93                             const char* outfilename, const char* infilename, const char* dictFileName);
94 
95 int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel);
96 
97 
98 /*-*************************************
99 *  Multiple File functions
100 ***************************************/
101 /** FIO_compressMultipleFilenames() :
102     @return : nb of missing files */
103 int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs,
104                                   const char** srcNamesTable, unsigned nbFiles,
105                                   const char* outFileName, const char* suffix,
106                                   const char* dictFileName, int compressionLevel,
107                                   ZSTD_compressionParameters comprParams);
108 
109 /** FIO_decompressMultipleFilenames() :
110     @return : nb of missing or skipped files */
111 int FIO_decompressMultipleFilenames(FIO_prefs_t* const prefs,
112                                     const char** srcNamesTable, unsigned nbFiles,
113                                     const char* outFileName,
114                                     const char* dictFileName);
115 
116 
117 /*-*************************************
118 *  Advanced stuff (should actually be hosted elsewhere)
119 ***************************************/
120 
121 /* custom crash signal handler */
122 void FIO_addAbortHandler(void);
123 
124 
125 
126 #if defined (__cplusplus)
127 }
128 #endif
129 
130 #endif  /* FILEIO_H_23981798732 */
131