1 /*
2  * Copyright (c) 2016-present, 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  */
9 
10 /**
11  * Helper functions for fuzzing.
12  */
13 
14 #ifndef ZSTD_HELPERS_H
15 #define ZSTD_HELPERS_H
16 
17 #define ZSTD_STATIC_LINKING_ONLY
18 
19 #include "zstd.h"
20 #include <stdint.h>
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 void FUZZ_setRandomParameters(ZSTD_CCtx *cctx, size_t srcSize, uint32_t *state);
27 
28 ZSTD_compressionParameters FUZZ_randomCParams(size_t srcSize, uint32_t *state);
29 ZSTD_frameParameters FUZZ_randomFParams(uint32_t *state);
30 ZSTD_parameters FUZZ_randomParams(size_t srcSize, uint32_t *state);
31 
32 typedef struct {
33   void* buff;
34   size_t size;
35 } FUZZ_dict_t;
36 
37 /* Quickly train a dictionary from a source for fuzzing.
38  * NOTE: Don't use this to train production dictionaries, it is only optimized
39  * for speed, and doesn't care about dictionary quality.
40  */
41 FUZZ_dict_t FUZZ_train(void const* src, size_t srcSize, uint32_t *state);
42 
43 
44 #ifdef __cplusplus
45 }
46 #endif
47 
48 #endif /* ZSTD_HELPERS_H */
49