APG v2.1.0

This commit is contained in:
Adel I. Mirzazhanov
2002-09-13 15:10:49 +07:00
committed by skinc
parent 8087f2a5e4
commit 900ff5ea18
44 changed files with 2999 additions and 880 deletions

27
bloom.h
View File

@@ -1,5 +1,5 @@
/*
** Copyright (c) 2001
** Copyright (c) 2001, 2002
** Adel I. Mirzazhanov. All rights reserved
**
** Redistribution and use in source and binary forms, with or without
@@ -41,19 +41,10 @@
#include <strings.h>
#include <math.h>
/* Add prototype support. */
#ifndef PROTO
#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
#define PROTO(ARGS) ARGS
#else
#define PROTO(ARGS) ()
#endif
#endif
#include "sha/sha.h"
#include "md5/md5.h"
#define FSIZE_BIT(word_count) ((unsigned long int)(4.0/(1.0-pow( 0.9,1.0/((double)word_count)))))
#define FSIZE_BYTE(word_count) ((((unsigned long int)(4.0/(1.0-pow( 0.9,1.0/((double)word_count)))))/8)+1)
#define FSIZE_BIT(word_count) ((unsigned long int)(5.0/(1.0-pow( 0.84151068, 1.0/((double)word_count)))))
#define FSIZE_BYTE(word_count) ((((unsigned long int)(5.0/(1.0-pow( 0.84151068, 1.0/((double)word_count)))))/8)+1)
#define APGBFHDRSIZE 12
@@ -61,20 +52,22 @@
#define FALSE 0
#define MAX_DICT_STRLEN 255
#define H_NUM 5
typedef unsigned long int h_val; /* should be 32-bit */
typedef unsigned short int flag;
struct apg_bf_hdr {
char id[8];
unsigned long int fs;
char id[8]; /* ID */
unsigned long int fs; /* filter size */
};
extern int insert_word(char *word, FILE *file, h_val filter_size);
extern int check_word(char *word, FILE *file, h_val filter_size);
extern FILE * create_filter(char * f_name, unsigned long int n_words);
extern FILE * open_filter(char * f_name);
extern FILE * open_filter(char * f_name, const char *mode);
extern int close_filter(FILE *f_dsk);
extern h_val get_filtersize(FILE *f);
extern h_val count_words(FILE *dict_file);
#endif /* APG_BLOOM_H */
#endif /* APG_BLOOM_H */