47 lines
1020 B
C
47 lines
1020 B
C
#ifndef BHASH_H_INCLUDED
|
|
#define BHASH_H_INCLUDED
|
|
|
|
#include <stdint.h>
|
|
|
|
#define BHASH_MOD32_ERR UINT32_MAX
|
|
|
|
typedef struct bhash bhash_t;
|
|
|
|
struct bhash
|
|
{
|
|
uint8_t *bh_data; /* Current data buffer */
|
|
size_t bh_len; /* Data length */
|
|
double bh_bits_avail; /* Bits available */
|
|
double bh_bits_used; /* Bits used */
|
|
};
|
|
|
|
/*
|
|
* Initialize new instance of Bhash
|
|
*/
|
|
void bhash_init(bhash_t *bh, const void *data, size_t data_len);
|
|
|
|
/*
|
|
* Destroy a bhash object and its associated data
|
|
*/
|
|
void bhash_fini(bhash_t *bh);
|
|
|
|
/*
|
|
* Perform a divison of the whole bhash data using the 32-bit `mod` variable
|
|
* and return the 32-bit reminder.
|
|
*
|
|
* This function returns BHASH_MOD32_ERR on error.
|
|
*/
|
|
uint32_t bhash_mod32(bhash_t *bh, uint32_t mod);
|
|
|
|
/*
|
|
* Return the number of total bits available in hash
|
|
*/
|
|
double bhash_bits_avail(bhash_t *bh);
|
|
|
|
/*
|
|
* Return the number of bits used in bhash
|
|
*/
|
|
double bhash_bits_used(bhash_t *bh);
|
|
|
|
#endif /* BHASH_H_INCLUDED */
|