"Fossies" - the Fresh Open Source Software Archive

Member "apg-2.2.3/bloom.h" (7 Aug 2003, 3290 Bytes) of package /linux/privat/old/apg-2.2.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /*
    2 ** Copyright (c) 2001, 2002, 2003
    3 ** Adel I. Mirzazhanov. All rights reserved
    4 **
    5 ** Redistribution and use in source and binary forms, with or without
    6 ** modification, are permitted provided that the following conditions
    7 ** are met:
    8 ** 
    9 **     1.Redistributions of source code must retain the above copyright notice,
   10 **       this list of conditions and the following disclaimer. 
   11 **     2.Redistributions in binary form must reproduce the above copyright
   12 **       notice, this list of conditions and the following disclaimer in the
   13 **       documentation and/or other materials provided with the distribution. 
   14 **     3.The name of the author may not be used to endorse or promote products
   15 **       derived from this software without specific prior written permission. 
   16 **        
   17 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR  ``AS IS'' AND ANY EXPRESS
   18 ** OR IMPLIED WARRANTIES, INCLUDING,  BUT NOT LIMITED TO, THE IMPLIED
   19 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20 ** ARE DISCLAIMED.  IN  NO  EVENT  SHALL THE AUTHOR BE LIABLE FOR ANY
   21 ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO,  PROCUREMENT OF SUBSTITUTE
   23 ** GOODS OR SERVICES;  LOSS OF USE,  DATA,  OR  PROFITS;  OR BUSINESS
   24 ** INTERRUPTION)  HOWEVER  CAUSED  AND  ON  ANY  THEORY OF LIABILITY,
   25 ** WHETHER  IN  CONTRACT,   STRICT   LIABILITY,  OR  TORT  (INCLUDING
   26 ** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   27 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   28 */
   29 
   30 
   31 
   32 /*
   33 ** Header file  for bloom filter algorithm implementation
   34 */
   35 #ifndef APG_BLOOM_H
   36 #define APG_BLOOM_H 1
   37 
   38 #include <stdio.h>
   39 #include <stdlib.h>
   40 #include <string.h>
   41 #if !defined(WIN32) && !defined(_WIN32) && !defined(__WIN32) && !defined(__WIN32__)
   42 #include <strings.h>
   43 #endif
   44 #include <math.h>
   45 
   46 #include "sha/sha.h"
   47 
   48 #define APGBF_ID      "APGBF"
   49 #define APGBF_VERSION "110" /* Version 1.1.0 */
   50 
   51 /* Bloom filter modes flags */
   52 #define BF_CASE_INSENSITIVE 0x01
   53 #define BF_RESERVED1        0x02
   54 #define BF_RESERVED2        0x04
   55 #define BF_RESERVED3        0x08
   56 #define BF_RESERVED4        0x10
   57 #define BF_RESERVED5        0x20
   58 #define BF_RESERVED6        0x40
   59 #define BF_RESERVED7        0x80
   60 
   61 #define APGBFHDRSIZE      13
   62 
   63 #define TRUE              1
   64 #define FALSE             0
   65 
   66 #define MAX_DICT_STRLEN   255
   67 #define H_NUM   5
   68 
   69 typedef unsigned long int      h_val; /* should be 32-bit */
   70 typedef unsigned short int     flag;
   71 typedef unsigned char          f_mode;
   72 
   73 struct apg_bf_hdr {
   74   char id[5];           /* filter ID      */
   75   char version[3];      /* filter version */
   76   unsigned long int fs; /* filter size    */
   77   f_mode mode;          /* filter flags   */
   78 };
   79 
   80 extern int insert_word(char *word, FILE *file, h_val filter_size, f_mode mode);
   81 extern int check_word(char *word, FILE *file, h_val filter_size, f_mode mode);
   82 extern FILE * create_filter(char * f_name, unsigned long int n_words, f_mode mode); 
   83 extern FILE * open_filter(char * f_name, const char *mode); 
   84 extern int close_filter(FILE *f_dsk);
   85 extern h_val get_filtersize(FILE *f); 
   86 extern f_mode get_filtermode(FILE *f); 
   87 extern h_val count_words(FILE *dict_file);
   88 #ifdef APGBFM
   89 extern int print_flt_info(FILE * filter);
   90 #endif /* APGBFM */
   91 #endif /* APG_BLOOM_H */