/* ==================================================================== * Copyright (c) 1999-2000 Ralf S. Engelschall. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RALF S. ENGELSCHALL OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * ==================================================================== */ /* ** act_hash.c -- Dynamic Hash Table */ #ifndef _ACT_HASH_H_ #define _ACT_HASH_H_ /* the opaque hashing data structure */ struct act_hash_st; typedef struct act_hash_st act_hash_t; /* context entries for hashing */ #define ACT_HASH_METHOD ACT_CTX_ID(ptr,HASH,0) #define ACT_HASH_FUNC ACT_CTX_ID(ptr,HASH,1) #define ACT_HASH_TABLESIZE ACT_CTX_ID(int,HASH,2) #define ACT_HASH_MAXLOADFCTR ACT_CTX_ID(int,HASH,3) #define ACT_HASH_MINLOADFCTR ACT_CTX_ID(int,HASH,4) /* types corresponding to the dispatch functions */ typedef void *(*act_hash_new_t) (act_ctx_t *); typedef int (*act_hash_insert_t) (act_ctx_t *, void *, void *, int, void *, int, int); typedef int (*act_hash_lookup_t) (act_ctx_t *, void *, void *, int, void **, int *); typedef int (*act_hash_delete_t) (act_ctx_t *, void *, void *, int); typedef int (*act_hash_size_t) (act_ctx_t *, void *, long *, long *); typedef int (*act_hash_free_t) (act_ctx_t *, void *); /* the dispatch structure for the hash implementation method */ typedef struct act_hash_method_st { unsigned int m_tag; act_hash_new_t m_new; act_hash_insert_t m_insert; act_hash_lookup_t m_lookup; act_hash_delete_t m_delete; act_hash_size_t m_size; act_hash_free_t m_free; } act_hash_method_t; /* the magic cookie which identifies a method structure */ #define ACT_HASH_METHOD_TAG 0xBEEF /* the hashing API functions */ act_hash_t *act_hash_new(act_ctx_t *); act_ctx_t *act_hash_ctx(act_hash_t *); int act_hash_insert(act_hash_t *, void *, int, void *, int, int); int act_hash_lookup(act_hash_t *, void *, int, void **, int *); int act_hash_delete(act_hash_t *, void *, int); int act_hash_size(act_hash_t *, long *, long *); int act_hash_free(act_hash_t *); #define act_hash_mth(name) \ &(act_hash_##name) #define __act_hash_mth_proto(name) \ extern act_hash_method_t act_hash_##name __act_hash_mth_proto(oh); __act_hash_mth_proto(lh); typedef unsigned long (*act_hash_fct_t)(unsigned char *, unsigned int); #define act_hash_fct(name) \ __act_hash_fct_##name #define __act_hash_fct_proto(name) \ extern unsigned long __act_hash_fct_##name(unsigned char *, unsigned int) __act_hash_fct_proto(djbx33a); __act_hash_fct_proto(djbx33x); __act_hash_fct_proto(vocong); __act_hash_fct_proto(bjddj); __act_hash_fct_proto(crc32); __act_hash_fct_proto(cpoaat); __act_hash_fct_proto(ozsdbm); __act_hash_fct_proto(fonovo); __act_hash_fct_proto(kazlib); __act_hash_fct_proto(buzhash); __act_hash_fct_proto(pearson); __act_hash_fct_proto(jotcl); __act_hash_fct_proto(cbu); __act_hash_fct_proto(cvs); #endif /* _ACT_HASH_H_ */