1
Fork 0
turbonss/src/hash.h

66 lines
2.7 KiB
C
Raw Normal View History

2004-12-23 15:16:30 +02:00
#ifndef __CMPH_HASH_H__
#define __CMPH_HASH_H__
#include "cmph_types.h"
typedef union __hash_state_t hash_state_t;
2004-12-23 15:16:30 +02:00
hash_state_t *hash_state_new(CMPH_HASH, cmph_uint32 hashsize);
2008-03-23 02:46:34 +02:00
/** \fn cmph_uint32 hash(hash_state_t *state, const char *key, cmph_uint32 keylen);
* \param state is a pointer to a hash_state_t structure
* \param key is a pointer to a key
* \param keylen is the key length
* \return an integer that represents a hash value of 32 bits.
*/
cmph_uint32 hash(hash_state_t *state, const char *key, cmph_uint32 keylen);
2008-03-23 02:46:34 +02:00
/** \fn void hash_vector(hash_state_t *state, const char *key, cmph_uint32 keylen, cmph_uint32 * hashes);
* \param state is a pointer to a hash_state_t structure
* \param key is a pointer to a key
* \param keylen is the key length
* \param hashes is a pointer to a memory large enough to fit three 32-bit integers.
*/
void hash_vector(hash_state_t *state, const char *key, cmph_uint32 keylen, cmph_uint32 * hashes);
void hash_state_dump(hash_state_t *state, char **buf, cmph_uint32 *buflen);
2008-03-23 02:46:34 +02:00
hash_state_t * hash_state_copy(hash_state_t *src_state);
2008-03-23 02:46:34 +02:00
hash_state_t *hash_state_load(const char *buf, cmph_uint32 buflen);
2008-03-23 02:46:34 +02:00
void hash_state_destroy(hash_state_t *state);
2004-12-23 15:16:30 +02:00
2008-03-26 22:26:48 +02:00
/** \fn void hash_state_pack(hash_state_t *state, void *hash_packed);
* \brief Support the ability to pack a hash function into a preallocated contiguous memory space pointed by hash_packed.
* \param state points to the hash function
* \param hash_packed pointer to the contiguous memory area used to store the hash function. The size of hash_packed must be at least hash_state_packed_size()
*/
void hash_state_pack(hash_state_t *state, void *hash_packed);
/** \fn cmph_uint32 hash_state_packed_size(hash_state_t *state);
* \brief Return the amount of space needed to pack a hash function.
* \param state points to a hash function
* \return the size of the packed function or zero for failures
*/
cmph_uint32 hash_state_packed_size(hash_state_t *state);
/** \fn cmph_uint32 hash_packed(void *hash_packed, const char *k, cmph_uint32 keylen);
* \param hash_packed is a pointer to a contiguous memory area
* \param key is a pointer to a key
* \param keylen is the key length
* \return an integer that represents a hash value of 32 bits.
*/
cmph_uint32 hash_packed(void *hash_packed, const char *k, cmph_uint32 keylen);
/** \fn hash_vector_packed(void *hash_packed, const char *k, cmph_uint32 keylen, cmph_uint32 * hashes);
* \param hash_packed is a pointer to a contiguous memory area
* \param key is a pointer to a key
* \param keylen is the key length
* \param hashes is a pointer to a memory large enough to fit three 32-bit integers.
*/
void hash_vector_packed(void *hash_packed, const char *k, cmph_uint32 keylen, cmph_uint32 * hashes);
2004-12-23 15:16:30 +02:00
#endif