2004-12-23 15:16:30 +02:00
|
|
|
#ifndef __CMPH_H__
|
|
|
|
#define __CMPH_H__
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "cmph_types.h"
|
|
|
|
|
2005-01-21 22:42:33 +02:00
|
|
|
typedef struct __config_t cmph_config_t;
|
|
|
|
typedef struct __cmph_t cmph_t;
|
2004-12-23 15:16:30 +02:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void *data;
|
2005-01-18 23:06:08 +02:00
|
|
|
cmph_uint32 nkeys;
|
|
|
|
int (*read)(void *, char **, cmph_uint32 *);
|
|
|
|
void (*dispose)(void *, char *, cmph_uint32);
|
2004-12-23 15:16:30 +02:00
|
|
|
void (*rewind)(void *);
|
2005-01-24 22:25:58 +02:00
|
|
|
} cmph_io_adapter_t;
|
|
|
|
|
|
|
|
/** Adapter pattern API **/
|
2005-01-25 22:42:03 +02:00
|
|
|
/* please call free() in the created adapters */
|
2005-01-24 22:25:58 +02:00
|
|
|
cmph_io_adapter_t *cmph_io_nlfile_adapter(FILE * keys_fd);
|
|
|
|
cmph_io_adapter_t *cmph_io_nlnkfile_adapter(FILE * keys_fd, cmph_uint32 nkeys);
|
2005-07-28 00:13:02 +03:00
|
|
|
cmph_io_adapter_t *cmph_io_vector_adapter(char ** vector, cmph_uint32 nkeys);
|
2004-12-23 15:16:30 +02:00
|
|
|
|
2005-01-21 23:14:55 +02:00
|
|
|
/** Hash configuration API **/
|
2005-01-24 22:25:58 +02:00
|
|
|
cmph_config_t *cmph_config_new(cmph_io_adapter_t *key_source);
|
2005-01-21 22:42:33 +02:00
|
|
|
void cmph_config_set_hashfuncs(cmph_config_t *mph, CMPH_HASH *hashfuncs);
|
|
|
|
void cmph_config_set_verbosity(cmph_config_t *mph, cmph_uint32 verbosity);
|
|
|
|
void cmph_config_set_graphsize(cmph_config_t *mph, float c);
|
|
|
|
void cmph_config_set_algo(cmph_config_t *mph, CMPH_ALGO algo);
|
|
|
|
void cmph_config_destroy(cmph_config_t *mph);
|
2004-12-23 15:16:30 +02:00
|
|
|
|
2005-01-21 23:14:55 +02:00
|
|
|
/** Hash API **/
|
|
|
|
cmph_t *cmph_new(cmph_config_t *mph);
|
2005-01-21 22:42:33 +02:00
|
|
|
cmph_uint32 cmph_search(cmph_t *mphf, const char *key, cmph_uint32 keylen);
|
|
|
|
cmph_uint32 cmph_size(cmph_t *mphf);
|
|
|
|
void cmph_destroy(cmph_t *mphf);
|
2004-12-23 15:16:30 +02:00
|
|
|
|
2005-01-21 23:14:55 +02:00
|
|
|
/** Hash serialization/deserialization */
|
|
|
|
int cmph_dump(cmph_t *mphf, FILE *f);
|
|
|
|
cmph_t *cmph_load(FILE *f);
|
|
|
|
|
2004-12-23 15:16:30 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|