zstd_helpers.h 1.4 KB

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