xref: /freebsd/sys/contrib/zstd/programs/fileio.h (revision 4f52dfbb8d6c4d446500c5b097e3806ec219fbd4)
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 
46 /*-*************************************
47 *  Parameters
48 ***************************************/
49 void FIO_setCompressionType(FIO_compressionType_t compressionType);
50 void FIO_overwriteMode(void);
51 void FIO_setNotificationLevel(unsigned level);
52 void FIO_setSparseWrite(unsigned sparse);  /**< 0: no sparse; 1: disable on stdout; 2: always enabled */
53 void FIO_setDictIDFlag(unsigned dictIDFlag);
54 void FIO_setChecksumFlag(unsigned checksumFlag);
55 void FIO_setRemoveSrcFile(unsigned flag);
56 void FIO_setMemLimit(unsigned memLimit);
57 void FIO_setNbWorkers(unsigned nbWorkers);
58 void FIO_setBlockSize(unsigned blockSize);
59 void FIO_setOverlapLog(unsigned overlapLog);
60 void FIO_setLdmFlag(unsigned ldmFlag);
61 void FIO_setLdmHashLog(unsigned ldmHashLog);
62 void FIO_setLdmMinMatch(unsigned ldmMinMatch);
63 void FIO_setLdmBucketSizeLog(unsigned ldmBucketSizeLog);
64 void FIO_setLdmHashEveryLog(unsigned ldmHashEveryLog);
65 
66 
67 /*-*************************************
68 *  Single File functions
69 ***************************************/
70 /** FIO_compressFilename() :
71     @return : 0 == ok;  1 == pb with src file. */
72 int FIO_compressFilename (const char* outfilename, const char* infilename, const char* dictFileName,
73                           int compressionLevel, ZSTD_compressionParameters* comprParams);
74 
75 /** FIO_decompressFilename() :
76     @return : 0 == ok;  1 == pb with src file. */
77 int FIO_decompressFilename (const char* outfilename, const char* infilename, const char* dictFileName);
78 
79 int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel);
80 
81 /*-*************************************
82 *  Multiple File functions
83 ***************************************/
84 /** FIO_compressMultipleFilenames() :
85     @return : nb of missing files */
86 int FIO_compressMultipleFilenames(const char** srcNamesTable, unsigned nbFiles,
87                                   const char* outFileName, const char* suffix,
88                                   const char* dictFileName, int compressionLevel,
89                                   ZSTD_compressionParameters* comprParams);
90 
91 /** FIO_decompressMultipleFilenames() :
92     @return : nb of missing or skipped files */
93 int FIO_decompressMultipleFilenames(const char** srcNamesTable, unsigned nbFiles,
94                                     const char* outFileName,
95                                     const char* dictFileName);
96 
97 
98 #if defined (__cplusplus)
99 }
100 #endif
101 
102 #endif  /* FILEIO_H_23981798732 */
103