xref: /freebsd/sys/contrib/zstd/programs/fileio.h (revision 0f743729abbfc5c9d78a713f72241a4d4bd601ec)
10c16b537SWarner Losh /*
20c16b537SWarner Losh  * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
30c16b537SWarner Losh  * All rights reserved.
40c16b537SWarner Losh  *
50c16b537SWarner Losh  * This source code is licensed under both the BSD-style license (found in the
60c16b537SWarner Losh  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
70c16b537SWarner Losh  * in the COPYING file in the root directory of this source tree).
80c16b537SWarner Losh  * You may select, at your option, one of the above-listed licenses.
90c16b537SWarner Losh  */
100c16b537SWarner Losh 
110c16b537SWarner Losh 
120c16b537SWarner Losh #ifndef FILEIO_H_23981798732
130c16b537SWarner Losh #define FILEIO_H_23981798732
140c16b537SWarner Losh 
150c16b537SWarner Losh #define ZSTD_STATIC_LINKING_ONLY   /* ZSTD_compressionParameters */
160c16b537SWarner Losh #include "zstd.h"                  /* ZSTD_* */
170c16b537SWarner Losh 
180c16b537SWarner Losh #if defined (__cplusplus)
190c16b537SWarner Losh extern "C" {
200c16b537SWarner Losh #endif
210c16b537SWarner Losh 
220c16b537SWarner Losh 
230c16b537SWarner Losh /* *************************************
240c16b537SWarner Losh *  Special i/o constants
250c16b537SWarner Losh **************************************/
260c16b537SWarner Losh #define stdinmark  "/*stdin*\\"
270c16b537SWarner Losh #define stdoutmark "/*stdout*\\"
280c16b537SWarner Losh #ifdef _WIN32
290c16b537SWarner Losh #  define nulmark "nul"
300c16b537SWarner Losh #else
310c16b537SWarner Losh #  define nulmark "/dev/null"
320c16b537SWarner Losh #endif
330c16b537SWarner Losh #define LZMA_EXTENSION  ".lzma"
340c16b537SWarner Losh #define XZ_EXTENSION    ".xz"
350c16b537SWarner Losh #define GZ_EXTENSION    ".gz"
360c16b537SWarner Losh #define ZSTD_EXTENSION  ".zst"
370c16b537SWarner Losh #define LZ4_EXTENSION   ".lz4"
380c16b537SWarner Losh 
390c16b537SWarner Losh 
400c16b537SWarner Losh /*-*************************************
410c16b537SWarner Losh *  Types
420c16b537SWarner Losh ***************************************/
430c16b537SWarner Losh typedef enum { FIO_zstdCompression, FIO_gzipCompression, FIO_xzCompression, FIO_lzmaCompression, FIO_lz4Compression } FIO_compressionType_t;
440c16b537SWarner Losh 
450c16b537SWarner Losh 
460c16b537SWarner Losh /*-*************************************
470c16b537SWarner Losh *  Parameters
480c16b537SWarner Losh ***************************************/
490c16b537SWarner Losh void FIO_setCompressionType(FIO_compressionType_t compressionType);
500c16b537SWarner Losh void FIO_overwriteMode(void);
51*0f743729SConrad Meyer void FIO_setAdaptiveMode(unsigned adapt);
52*0f743729SConrad Meyer void FIO_setAdaptMin(int minCLevel);
53*0f743729SConrad Meyer void FIO_setAdaptMax(int maxCLevel);
540c16b537SWarner Losh void FIO_setBlockSize(unsigned blockSize);
55*0f743729SConrad Meyer void FIO_setChecksumFlag(unsigned checksumFlag);
56*0f743729SConrad Meyer void FIO_setDictIDFlag(unsigned dictIDFlag);
57*0f743729SConrad Meyer void FIO_setLdmBucketSizeLog(unsigned ldmBucketSizeLog);
580c16b537SWarner Losh void FIO_setLdmFlag(unsigned ldmFlag);
59*0f743729SConrad Meyer void FIO_setLdmHashEveryLog(unsigned ldmHashEveryLog);
600c16b537SWarner Losh void FIO_setLdmHashLog(unsigned ldmHashLog);
610c16b537SWarner Losh void FIO_setLdmMinMatch(unsigned ldmMinMatch);
62*0f743729SConrad Meyer void FIO_setMemLimit(unsigned memLimit);
63*0f743729SConrad Meyer void FIO_setNbWorkers(unsigned nbWorkers);
64*0f743729SConrad Meyer void FIO_setNotificationLevel(unsigned level);
65*0f743729SConrad Meyer void FIO_setOverlapLog(unsigned overlapLog);
66*0f743729SConrad Meyer void FIO_setRemoveSrcFile(unsigned flag);
67*0f743729SConrad Meyer void FIO_setSparseWrite(unsigned sparse);  /**< 0: no sparse; 1: disable on stdout; 2: always enabled */
680c16b537SWarner Losh 
690c16b537SWarner Losh 
700c16b537SWarner Losh /*-*************************************
710c16b537SWarner Losh *  Single File functions
720c16b537SWarner Losh ***************************************/
730c16b537SWarner Losh /** FIO_compressFilename() :
740c16b537SWarner Losh     @return : 0 == ok;  1 == pb with src file. */
750c16b537SWarner Losh int FIO_compressFilename (const char* outfilename, const char* infilename, const char* dictFileName,
76*0f743729SConrad Meyer                           int compressionLevel, ZSTD_compressionParameters comprParams);
770c16b537SWarner Losh 
780c16b537SWarner Losh /** FIO_decompressFilename() :
790c16b537SWarner Losh     @return : 0 == ok;  1 == pb with src file. */
800c16b537SWarner Losh int FIO_decompressFilename (const char* outfilename, const char* infilename, const char* dictFileName);
810c16b537SWarner Losh 
820c16b537SWarner Losh int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel);
830c16b537SWarner Losh 
84*0f743729SConrad Meyer 
850c16b537SWarner Losh /*-*************************************
860c16b537SWarner Losh *  Multiple File functions
870c16b537SWarner Losh ***************************************/
880c16b537SWarner Losh /** FIO_compressMultipleFilenames() :
890c16b537SWarner Losh     @return : nb of missing files */
900c16b537SWarner Losh int FIO_compressMultipleFilenames(const char** srcNamesTable, unsigned nbFiles,
91052d3c12SConrad Meyer                                   const char* outFileName, const char* suffix,
920c16b537SWarner Losh                                   const char* dictFileName, int compressionLevel,
93*0f743729SConrad Meyer                                   ZSTD_compressionParameters comprParams);
940c16b537SWarner Losh 
950c16b537SWarner Losh /** FIO_decompressMultipleFilenames() :
960c16b537SWarner Losh     @return : nb of missing or skipped files */
970c16b537SWarner Losh int FIO_decompressMultipleFilenames(const char** srcNamesTable, unsigned nbFiles,
98052d3c12SConrad Meyer                                     const char* outFileName,
990c16b537SWarner Losh                                     const char* dictFileName);
1000c16b537SWarner Losh 
1010c16b537SWarner Losh 
102*0f743729SConrad Meyer /*-*************************************
103*0f743729SConrad Meyer *  Advanced stuff (should actually be hosted elsewhere)
104*0f743729SConrad Meyer ***************************************/
105*0f743729SConrad Meyer 
106*0f743729SConrad Meyer /* custom crash signal handler */
107*0f743729SConrad Meyer void FIO_addAbortHandler(void);
108*0f743729SConrad Meyer 
109*0f743729SConrad Meyer 
110*0f743729SConrad Meyer 
1110c16b537SWarner Losh #if defined (__cplusplus)
1120c16b537SWarner Losh }
1130c16b537SWarner Losh #endif
1140c16b537SWarner Losh 
1150c16b537SWarner Losh #endif  /* FILEIO_H_23981798732 */
116