]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/zstd/contrib/experimental_dict_builders/randomDictBuilder/io.h
Update to Zstandard 1.4.0
[FreeBSD/FreeBSD.git] / sys / contrib / zstd / contrib / experimental_dict_builders / randomDictBuilder / io.h
1 #include <stdio.h>  /* fprintf */
2 #include <stdlib.h> /* malloc, free, qsort */
3 #include <string.h>   /* strcmp, strlen */
4 #include <errno.h>    /* errno */
5 #include <ctype.h>
6 #include "zstd_internal.h" /* includes zstd.h */
7 #include "fileio.h"   /* stdinmark, stdoutmark, ZSTD_EXTENSION */
8 #include "platform.h"         /* Large Files support */
9 #include "util.h"
10 #include "zdict.h"
11
12
13 /*-*************************************
14 *  Structs
15 ***************************************/
16 typedef struct {
17     U64 totalSizeToLoad;
18     unsigned oneSampleTooLarge;
19     unsigned nbSamples;
20 } fileStats;
21
22 typedef struct {
23   const void* srcBuffer;
24   const size_t *samplesSizes;
25   size_t nbSamples;
26 }sampleInfo;
27
28
29
30 /*! getSampleInfo():
31  *  Load from input files and add samples to buffer
32  * @return: a sampleInfo struct containing infomation about buffer where samples are stored,
33  *          size of each sample, and total number of samples
34  */
35 sampleInfo* getSampleInfo(const char** fileNamesTable, unsigned nbFiles, size_t chunkSize,
36                           unsigned maxDictSize, const unsigned displayLevel);
37
38
39
40 /*! freeSampleInfo():
41  *  Free memory allocated for info
42  */
43 void freeSampleInfo(sampleInfo *info);
44
45
46
47 /*! saveDict():
48  *  Save data stored on buff to dictFileName
49  */
50 void saveDict(const char* dictFileName, const void* buff, size_t buffSize);
51
52
53 unsigned readU32FromChar(const char** stringPtr);
54
55 /** longCommandWArg() :
56  *  check if *stringPtr is the same as longCommand.
57  *  If yes, @return 1 and advances *stringPtr to the position which immediately follows longCommand.
58  * @return 0 and doesn't modify *stringPtr otherwise.
59  */
60 unsigned longCommandWArg(const char** stringPtr, const char* longCommand);