127b27ec6Sopenharmony_ci#include <stddef.h> 227b27ec6Sopenharmony_ci#include <stdint.h> 327b27ec6Sopenharmony_ci#include <stdio.h> 427b27ec6Sopenharmony_ci#include <stdlib.h> 527b27ec6Sopenharmony_ci 627b27ec6Sopenharmony_ci#include "fuzz_helpers.h" 727b27ec6Sopenharmony_ci#include "lz4frame.h" 827b27ec6Sopenharmony_ci#include "lz4hc.h" 927b27ec6Sopenharmony_ci 1027b27ec6Sopenharmony_ci/* Struct used for maintaining the state of the data */ 1127b27ec6Sopenharmony_citypedef struct FUZZ_dataProducer_s FUZZ_dataProducer_t; 1227b27ec6Sopenharmony_ci 1327b27ec6Sopenharmony_ci/* Returns a data producer state struct. Use for producer initialization. */ 1427b27ec6Sopenharmony_ciFUZZ_dataProducer_t *FUZZ_dataProducer_create(const uint8_t *data, size_t size); 1527b27ec6Sopenharmony_ci 1627b27ec6Sopenharmony_ci/* Frees the data producer */ 1727b27ec6Sopenharmony_civoid FUZZ_dataProducer_free(FUZZ_dataProducer_t *producer); 1827b27ec6Sopenharmony_ci 1927b27ec6Sopenharmony_ci/* Returns 32 bits from the end of data */ 2027b27ec6Sopenharmony_ciuint32_t FUZZ_dataProducer_retrieve32(FUZZ_dataProducer_t *producer); 2127b27ec6Sopenharmony_ci 2227b27ec6Sopenharmony_ci/* Returns value between [min, max] */ 2327b27ec6Sopenharmony_ciuint32_t FUZZ_getRange_from_uint32(uint32_t seed, uint32_t min, uint32_t max); 2427b27ec6Sopenharmony_ci 2527b27ec6Sopenharmony_ci/* Combination of above two functions for non adaptive use cases. ie where size is not involved */ 2627b27ec6Sopenharmony_ciuint32_t FUZZ_dataProducer_range32(FUZZ_dataProducer_t *producer, uint32_t min, 2727b27ec6Sopenharmony_ci uint32_t max); 2827b27ec6Sopenharmony_ci 2927b27ec6Sopenharmony_ci/* Returns lz4 preferences */ 3027b27ec6Sopenharmony_ciLZ4F_preferences_t FUZZ_dataProducer_preferences(FUZZ_dataProducer_t* producer); 3127b27ec6Sopenharmony_ci 3227b27ec6Sopenharmony_ci/* Returns lz4 frame info */ 3327b27ec6Sopenharmony_ciLZ4F_frameInfo_t FUZZ_dataProducer_frameInfo(FUZZ_dataProducer_t* producer); 3427b27ec6Sopenharmony_ci 3527b27ec6Sopenharmony_ci/* Returns the size of the remaining bytes of data in the producer */ 3627b27ec6Sopenharmony_cisize_t FUZZ_dataProducer_remainingBytes(FUZZ_dataProducer_t *producer); 37