Only public symbols were prefixed with cmph, and the API was changed to agree with the initial txt2html documentation

This commit is contained in:
fc_botelho
2005-01-21 20:42:33 +00:00
parent 4dda0a3b62
commit 3ed086d14a
28 changed files with 475 additions and 493 deletions

View File

@@ -10,85 +10,84 @@
//#define DEBUG
#include "debug.h"
const char *cmph_names[] = { "czech", "bmz", NULL }; /* included -- Fabiano */
const char *cmph_names[] = { "bmz", "czech", NULL }; /* included -- Fabiano */
cmph_mph_t *cmph_mph_new(CMPH_ALGO algo, cmph_key_source_t *key_source)
cmph_config_t *cmph_config_new(cmph_key_source_t *key_source)
{
cmph_mph_t *mph = NULL;
DEBUGP("Creating mph with algorithm %s\n", cmph_names[algo]);
switch (algo)
{
case CMPH_CZECH:
mph = cmph_czech_mph_new(key_source);
break;
case CMPH_BMZ: /* included -- Fabiano */
DEBUGP("new bmz algorithm \n");
mph = cmph_bmz_mph_new(key_source);
break;
default:
assert(0);
}
cmph_config_t *mph = NULL;
mph = __config_new(key_source);
assert(mph);
mph->algo = CMPH_CZECH; // default value
return mph;
}
void cmph_mph_destroy(cmph_mph_t *mph)
void cmph_config_set_algo(cmph_config_t *mph, CMPH_ALGO algo)
{
mph->algo = algo;
}
void cmph_config_destroy(cmph_config_t *mph)
{
DEBUGP("Destroying mph with algo %s\n", cmph_names[mph->algo]);
switch (mph->algo)
{
case CMPH_CZECH:
cmph_czech_mph_destroy(mph);
czech_config_destroy(mph);
break;
case CMPH_BMZ: /* included -- Fabiano */
cmph_bmz_mph_destroy(mph);
bmz_config_destroy(mph);
break;
default:
assert(0);
}
__config_destroy(mph);
}
void cmph_mph_set_verbosity(cmph_mph_t *mph, cmph_uint32 verbosity)
void cmph_config_set_verbosity(cmph_config_t *mph, cmph_uint32 verbosity)
{
mph->verbosity = verbosity;
}
void cmph_mph_set_hashfuncs(cmph_mph_t *mph, CMPH_HASH *hashfuncs)
void cmph_config_set_hashfuncs(cmph_config_t *mph, CMPH_HASH *hashfuncs)
{
switch (mph->algo)
{
case CMPH_CZECH:
cmph_czech_mph_set_hashfuncs(mph, hashfuncs);
czech_config_set_hashfuncs(mph, hashfuncs);
break;
case CMPH_BMZ: /* included -- Fabiano */
cmph_bmz_mph_set_hashfuncs(mph, hashfuncs);
bmz_config_set_hashfuncs(mph, hashfuncs);
break;
default:
break;
}
return;
}
void cmph_mph_set_graphsize(cmph_mph_t *mph, float c)
void cmph_config_set_graphsize(cmph_config_t *mph, float c)
{
mph->c = c;
return;
}
cmph_mphf_t *cmph_mph_create(cmph_mph_t *mph)
cmph_t *cmph_new(cmph_config_t *mph)
{
cmph_mphf_t *mphf = NULL;
cmph_t *mphf = NULL;
float c = mph->c;
DEBUGP("Creating mph with algorithm %s\n", cmph_names[mph->algo]);
switch (mph->algo)
{
case CMPH_CZECH:
DEBUGP("Creating czech hash\n");
mph->data = czech_config_new(mph->key_source);
if (c == 0) c = 2.09;
mphf = cmph_czech_mph_create(mph, c);
mphf = czech_new(mph, c);
break;
case CMPH_BMZ: /* included -- Fabiano */
DEBUGP("Creating bmz hash\n");
mph->data = bmz_config_new(mph->key_source);
if (c == 0) c = 1.15;
mphf = cmph_bmz_mph_create(mph, c);
mphf = bmz_new(mph, c);
break;
default:
assert(0);
@@ -96,15 +95,15 @@ cmph_mphf_t *cmph_mph_create(cmph_mph_t *mph)
return mphf;
}
int cmph_mphf_dump(cmph_mphf_t *mphf, FILE *f)
int cmph_dump(cmph_t *mphf, FILE *f)
{
switch (mphf->algo)
{
case CMPH_CZECH:
return cmph_czech_mphf_dump(mphf, f);
return czech_dump(mphf, f);
break;
case CMPH_BMZ: /* included -- Fabiano */
return cmph_bmz_mphf_dump(mphf, f);
return bmz_dump(mphf, f);
break;
default:
assert(0);
@@ -112,22 +111,22 @@ int cmph_mphf_dump(cmph_mphf_t *mphf, FILE *f)
assert(0);
return 0;
}
cmph_mphf_t *cmph_mphf_load(FILE *f)
cmph_t *cmph_load(FILE *f)
{
cmph_mphf_t *mphf = NULL;
cmph_t *mphf = NULL;
DEBUGP("Loading mphf generic parts\n");
mphf = cmph__mphf_load(f);
mphf = __cmph_load(f);
if (mphf == NULL) return NULL;
DEBUGP("Loading mphf algorithm dependent parts\n");
switch (mphf->algo)
{
case CMPH_CZECH:
cmph_czech_mphf_load(f, mphf);
czech_load(f, mphf);
break;
case CMPH_BMZ: /* included -- Fabiano */
DEBUGP("Loading bmz algorithm dependent parts\n");
cmph_bmz_mphf_load(f, mphf);
bmz_load(f, mphf);
break;
default:
assert(0);
@@ -137,16 +136,16 @@ cmph_mphf_t *cmph_mphf_load(FILE *f)
}
cmph_uint32 cmph_mphf_search(cmph_mphf_t *mphf, const char *key, cmph_uint32 keylen)
cmph_uint32 cmph_search(cmph_t *mphf, const char *key, cmph_uint32 keylen)
{
DEBUGP("mphf algorithm: %u \n", mphf->algo);
switch(mphf->algo)
{
case CMPH_CZECH:
return cmph_czech_mphf_search(mphf, key, keylen);
return czech_search(mphf, key, keylen);
case CMPH_BMZ: /* included -- Fabiano */
DEBUGP("bmz algorithm search\n");
return cmph_bmz_mphf_search(mphf, key, keylen);
return bmz_search(mphf, key, keylen);
default:
assert(0);
}
@@ -154,20 +153,20 @@ cmph_uint32 cmph_mphf_search(cmph_mphf_t *mphf, const char *key, cmph_uint32 key
return 0;
}
cmph_uint32 cmph_mphf_size(cmph_mphf_t *mphf)
cmph_uint32 cmph_size(cmph_t *mphf)
{
return mphf->size;
}
void cmph_mphf_destroy(cmph_mphf_t *mphf)
void cmph_destroy(cmph_t *mphf)
{
switch(mphf->algo)
{
case CMPH_CZECH:
cmph_czech_mphf_destroy(mphf);
czech_destroy(mphf);
return;
case CMPH_BMZ: /* included -- Fabiano */
cmph_bmz_mphf_destroy(mphf);
bmz_destroy(mphf);
return;
default:
assert(0);