version with cmph prefix

This commit is contained in:
fc_botelho
2005-01-18 21:06:08 +00:00
parent ac4a2f539f
commit 264a1996c8
29 changed files with 718 additions and 717 deletions

View File

@@ -5,10 +5,10 @@
//#define DEBUG
#include "debug.h"
mph_t *__mph_new(MPH_ALGO algo, key_source_t *key_source)
cmph_mph_t *cmph__mph_new(CMPH_ALGO algo, cmph_key_source_t *key_source)
{
mph_t *mph = (mph_t *)malloc(sizeof(mph_t));
DEBUGP("Creating mph with algorithm %s\n", mph_names[algo]);
cmph_mph_t *mph = (cmph_mph_t *)malloc(sizeof(cmph_mph_t));
DEBUGP("Creating mph with algorithm %s\n", cmph_names[algo]);
if (mph == NULL) return NULL;
mph->algo = algo;
mph->key_source = key_source;
@@ -17,51 +17,51 @@ mph_t *__mph_new(MPH_ALGO algo, key_source_t *key_source)
return mph;
}
void __mph_destroy(mph_t *mph)
void cmph__mph_destroy(cmph_mph_t *mph)
{
free(mph);
}
void __mphf_dump(mphf_t *mphf, FILE *fd)
void cmph__mphf_dump(cmph_mphf_t *mphf, FILE *fd)
{
uint32 nsize = htonl(mphf->size);
fwrite(mph_names[mphf->algo], (uint32)(strlen(mph_names[mphf->algo]) + 1), 1, fd);
cmph_uint32 nsize = htonl(mphf->size);
fwrite(cmph_names[mphf->algo], (cmph_uint32)(strlen(cmph_names[mphf->algo]) + 1), 1, fd);
fwrite(&nsize, sizeof(mphf->size), 1, fd);
}
mphf_t *__mphf_load(FILE *f)
cmph_mphf_t *cmph__mphf_load(FILE *f)
{
mphf_t *mphf = NULL;
uint32 i;
cmph_mphf_t *mphf = NULL;
cmph_uint32 i;
char algo_name[BUFSIZ];
char *ptr = algo_name;
MPH_ALGO algo = MPH_COUNT;
CMPH_ALGO algo = CMPH_COUNT;
DEBUGP("Loading mphf\n");
while(1)
{
uint32 c = fread(ptr, 1, 1, f);
cmph_uint32 c = fread(ptr, 1, 1, f);
if (c != 1) return NULL;
if (*ptr == 0) break;
++ptr;
}
for(i = 0; i < MPH_COUNT; ++i)
for(i = 0; i < CMPH_COUNT; ++i)
{
if (strcmp(algo_name, mph_names[i]) == 0)
if (strcmp(algo_name, cmph_names[i]) == 0)
{
algo = i;
}
}
if (algo == MPH_COUNT)
if (algo == CMPH_COUNT)
{
DEBUGP("Algorithm %s not found\n", algo_name);
return NULL;
}
mphf = (mphf_t *)malloc(sizeof(mphf_t));
mphf = (cmph_mphf_t *)malloc(sizeof(cmph_mphf_t));
mphf->algo = algo;
fread(&(mphf->size), sizeof(mphf->size), 1, f);
mphf->size = ntohl(mphf->size);
mphf->data = NULL;
DEBUGP("Algorithm is %s and mphf is sized %u\n", mph_names[algo], mphf->size);
DEBUGP("Algorithm is %s and mphf is sized %u\n", cmph_names[algo], mphf->size);
return mphf;
}