opnsense-src/sys/contrib/zstd/programs/fileio.h

159 lines
6 KiB
C
Raw Normal View History

2017-08-22 07:02:59 -04:00
/*
2020-05-23 16:37:33 -04:00
* Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
2017-04-15 15:47:16 -04:00
* All rights reserved.
*
2017-08-22 07:02:59 -04:00
* This source code is licensed under both the BSD-style license (found in the
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
* in the COPYING file in the root directory of this source tree).
2017-11-09 10:38:02 -05:00
* You may select, at your option, one of the above-listed licenses.
2017-04-15 15:47:16 -04:00
*/
#ifndef FILEIO_H_23981798732
#define FILEIO_H_23981798732
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_compressionParameters */
2020-05-23 16:37:33 -04:00
#include "../lib/zstd.h" /* ZSTD_* */
2017-04-15 15:47:16 -04:00
#if defined (__cplusplus)
extern "C" {
#endif
/* *************************************
* Special i/o constants
**************************************/
#define stdinmark "/*stdin*\\"
#define stdoutmark "/*stdout*\\"
#ifdef _WIN32
2019-11-06 01:42:00 -05:00
# define nulmark "NUL"
2017-04-15 15:47:16 -04:00
#else
# define nulmark "/dev/null"
#endif
2019-11-06 01:42:00 -05:00
/**
* We test whether the extension we found starts with 't', and if so, we append
* ".tar" to the end of the output name.
*/
2017-04-15 15:47:16 -04:00
#define LZMA_EXTENSION ".lzma"
#define XZ_EXTENSION ".xz"
2019-11-06 01:42:00 -05:00
#define TXZ_EXTENSION ".txz"
2017-04-15 15:47:16 -04:00
#define GZ_EXTENSION ".gz"
2019-11-06 01:42:00 -05:00
#define TGZ_EXTENSION ".tgz"
2017-04-15 15:47:16 -04:00
#define ZSTD_EXTENSION ".zst"
2019-11-06 01:42:00 -05:00
#define TZSTD_EXTENSION ".tzst"
#define LZ4_EXTENSION ".lz4"
2019-11-06 01:42:00 -05:00
#define TLZ4_EXTENSION ".tlz4"
2017-04-15 15:47:16 -04:00
/*-*************************************
* Types
***************************************/
typedef enum { FIO_zstdCompression, FIO_gzipCompression, FIO_xzCompression, FIO_lzmaCompression, FIO_lz4Compression } FIO_compressionType_t;
2017-04-15 15:47:16 -04:00
2019-04-18 20:31:04 -04:00
typedef struct FIO_prefs_s FIO_prefs_t;
FIO_prefs_t* FIO_createPreferences(void);
void FIO_freePreferences(FIO_prefs_t* const prefs);
typedef struct FIO_display_prefs_s FIO_display_prefs_t;
2017-04-15 15:47:16 -04:00
/*-*************************************
* Parameters
***************************************/
2019-04-18 20:31:04 -04:00
void FIO_setCompressionType(FIO_prefs_t* const prefs, FIO_compressionType_t compressionType);
void FIO_overwriteMode(FIO_prefs_t* const prefs);
void FIO_setAdaptiveMode(FIO_prefs_t* const prefs, unsigned adapt);
void FIO_setAdaptMin(FIO_prefs_t* const prefs, int minCLevel);
void FIO_setAdaptMax(FIO_prefs_t* const prefs, int maxCLevel);
void FIO_setBlockSize(FIO_prefs_t* const prefs, int blockSize);
void FIO_setChecksumFlag(FIO_prefs_t* const prefs, int checksumFlag);
void FIO_setDictIDFlag(FIO_prefs_t* const prefs, int dictIDFlag);
void FIO_setLdmBucketSizeLog(FIO_prefs_t* const prefs, int ldmBucketSizeLog);
void FIO_setLdmFlag(FIO_prefs_t* const prefs, unsigned ldmFlag);
void FIO_setLdmHashRateLog(FIO_prefs_t* const prefs, int ldmHashRateLog);
void FIO_setLdmHashLog(FIO_prefs_t* const prefs, int ldmHashLog);
void FIO_setLdmMinMatch(FIO_prefs_t* const prefs, int ldmMinMatch);
void FIO_setMemLimit(FIO_prefs_t* const prefs, unsigned memLimit);
void FIO_setNbWorkers(FIO_prefs_t* const prefs, int nbWorkers);
void FIO_setOverlapLog(FIO_prefs_t* const prefs, int overlapLog);
void FIO_setRemoveSrcFile(FIO_prefs_t* const prefs, unsigned flag);
void FIO_setSparseWrite(FIO_prefs_t* const prefs, unsigned sparse); /**< 0: no sparse; 1: disable on stdout; 2: always enabled */
void FIO_setRsyncable(FIO_prefs_t* const prefs, int rsyncable);
2019-11-06 01:42:00 -05:00
void FIO_setStreamSrcSize(FIO_prefs_t* const prefs, size_t streamSrcSize);
2019-08-08 11:30:49 -04:00
void FIO_setTargetCBlockSize(FIO_prefs_t* const prefs, size_t targetCBlockSize);
2019-11-06 01:42:00 -05:00
void FIO_setSrcSizeHint(FIO_prefs_t* const prefs, size_t srcSizeHint);
void FIO_setTestMode(FIO_prefs_t* const prefs, int testMode);
2019-04-18 20:31:04 -04:00
void FIO_setLiteralCompressionMode(
FIO_prefs_t* const prefs,
ZSTD_literalCompressionMode_e mode);
2017-04-15 15:47:16 -04:00
2019-04-18 20:31:04 -04:00
void FIO_setNoProgress(unsigned noProgress);
void FIO_setNotificationLevel(int level);
2019-11-06 01:42:00 -05:00
void FIO_setExcludeCompressedFile(FIO_prefs_t* const prefs, int excludeCompressedFiles);
2020-05-23 16:37:33 -04:00
void FIO_setPatchFromMode(FIO_prefs_t* const prefs, int value);
void FIO_setContentSize(FIO_prefs_t* const prefs, int value);
2017-04-15 15:47:16 -04:00
/*-*************************************
* Single File functions
***************************************/
/** FIO_compressFilename() :
2019-11-06 01:42:00 -05:00
* @return : 0 == ok; 1 == pb with src file. */
2019-04-18 20:31:04 -04:00
int FIO_compressFilename (FIO_prefs_t* const prefs,
2019-11-06 01:42:00 -05:00
const char* outfilename, const char* infilename,
const char* dictFileName, int compressionLevel,
ZSTD_compressionParameters comprParams);
2017-04-15 15:47:16 -04:00
/** FIO_decompressFilename() :
2019-11-06 01:42:00 -05:00
* @return : 0 == ok; 1 == pb with src file. */
2019-04-18 20:31:04 -04:00
int FIO_decompressFilename (FIO_prefs_t* const prefs,
const char* outfilename, const char* infilename, const char* dictFileName);
2017-04-15 15:47:16 -04:00
2017-07-14 10:51:28 -04:00
int FIO_listMultipleFiles(unsigned numFiles, const char** filenameTable, int displayLevel);
2017-04-15 15:47:16 -04:00
2018-10-22 16:00:30 -04:00
2017-04-15 15:47:16 -04:00
/*-*************************************
* Multiple File functions
***************************************/
/** FIO_compressMultipleFilenames() :
2019-11-06 01:42:00 -05:00
* @return : nb of missing files */
2019-04-18 20:31:04 -04:00
int FIO_compressMultipleFilenames(FIO_prefs_t* const prefs,
2019-11-06 01:42:00 -05:00
const char** inFileNamesTable, unsigned nbFiles,
const char* outDirName,
2018-10-22 15:45:18 -04:00
const char* outFileName, const char* suffix,
2017-04-15 15:47:16 -04:00
const char* dictFileName, int compressionLevel,
2018-10-22 16:00:30 -04:00
ZSTD_compressionParameters comprParams);
2017-04-15 15:47:16 -04:00
/** FIO_decompressMultipleFilenames() :
2019-11-06 01:42:00 -05:00
* @return : nb of missing or skipped files */
2019-04-18 20:31:04 -04:00
int FIO_decompressMultipleFilenames(FIO_prefs_t* const prefs,
const char** srcNamesTable, unsigned nbFiles,
2019-11-06 01:42:00 -05:00
const char* outDirName,
2018-10-22 15:45:18 -04:00
const char* outFileName,
2017-04-15 15:47:16 -04:00
const char* dictFileName);
2019-11-06 01:42:00 -05:00
/* FIO_checkFilenameCollisions() :
* Checks for and warns if there are any files that would have the same output path
*/
int FIO_checkFilenameCollisions(const char** filenameTable, unsigned nbFiles);
2017-04-15 15:47:16 -04:00
2018-10-22 16:00:30 -04:00
/*-*************************************
* Advanced stuff (should actually be hosted elsewhere)
***************************************/
/* custom crash signal handler */
void FIO_addAbortHandler(void);
2017-04-15 15:47:16 -04:00
#if defined (__cplusplus)
}
#endif
#endif /* FILEIO_H_23981798732 */