Eneboo - Documentación para desarrolladores
src/libdigidoc/openssl/include/openssl/lhash.h
Ir a la documentación de este archivo.
00001 /* crypto/lhash/lhash.h */
00002 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
00003  * All rights reserved.
00004  *
00005  * This package is an SSL implementation written
00006  * by Eric Young (eay@cryptsoft.com).
00007  * The implementation was written so as to conform with Netscapes SSL.
00008  * 
00009  * This library is free for commercial and non-commercial use as long as
00010  * the following conditions are aheared to.  The following conditions
00011  * apply to all code found in this distribution, be it the RC4, RSA,
00012  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
00013  * included with this distribution is covered by the same copyright terms
00014  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
00015  * 
00016  * Copyright remains Eric Young's, and as such any Copyright notices in
00017  * the code are not to be removed.
00018  * If this package is used in a product, Eric Young should be given attribution
00019  * as the author of the parts of the library used.
00020  * This can be in the form of a textual message at program startup or
00021  * in documentation (online or textual) provided with the package.
00022  * 
00023  * Redistribution and use in source and binary forms, with or without
00024  * modification, are permitted provided that the following conditions
00025  * are met:
00026  * 1. Redistributions of source code must retain the copyright
00027  *    notice, this list of conditions and the following disclaimer.
00028  * 2. Redistributions in binary form must reproduce the above copyright
00029  *    notice, this list of conditions and the following disclaimer in the
00030  *    documentation and/or other materials provided with the distribution.
00031  * 3. All advertising materials mentioning features or use of this software
00032  *    must display the following acknowledgement:
00033  *    "This product includes cryptographic software written by
00034  *     Eric Young (eay@cryptsoft.com)"
00035  *    The word 'cryptographic' can be left out if the rouines from the library
00036  *    being used are not cryptographic related :-).
00037  * 4. If you include any Windows specific code (or a derivative thereof) from 
00038  *    the apps directory (application code) you must include an acknowledgement:
00039  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
00040  * 
00041  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
00042  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00043  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00044  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00045  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00046  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00047  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00048  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00049  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00050  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00051  * SUCH DAMAGE.
00052  * 
00053  * The licence and distribution terms for any publically available version or
00054  * derivative of this code cannot be changed.  i.e. this code cannot simply be
00055  * copied and put under another distribution licence
00056  * [including the GNU Public Licence.]
00057  */
00058 
00059 /* Header for dynamic hash table routines
00060  * Author - Eric Young
00061  */
00062 
00063 #ifndef HEADER_LHASH_H
00064 #define HEADER_LHASH_H
00065 
00066 #include <openssl/e_os2.h>
00067 #ifndef OPENSSL_NO_FP_API
00068 #include <stdio.h>
00069 #endif
00070 
00071 #ifndef OPENSSL_NO_BIO
00072 #include <openssl/bio.h>
00073 #endif
00074 
00075 #ifdef  __cplusplus
00076 extern "C" {
00077 #endif
00078 
00079 typedef struct lhash_node_st
00080         {
00081         void *data;
00082         struct lhash_node_st *next;
00083 #ifndef OPENSSL_NO_HASH_COMP
00084         unsigned long hash;
00085 #endif
00086         } LHASH_NODE;
00087 
00088 typedef int (*LHASH_COMP_FN_TYPE)(const void *, const void *);
00089 typedef unsigned long (*LHASH_HASH_FN_TYPE)(const void *);
00090 typedef void (*LHASH_DOALL_FN_TYPE)(void *);
00091 typedef void (*LHASH_DOALL_ARG_FN_TYPE)(void *, void *);
00092 
00093 /* Macros for declaring and implementing type-safe wrappers for LHASH callbacks.
00094  * This way, callbacks can be provided to LHASH structures without function
00095  * pointer casting and the macro-defined callbacks provide per-variable casting
00096  * before deferring to the underlying type-specific callbacks. NB: It is
00097  * possible to place a "static" in front of both the DECLARE and IMPLEMENT
00098  * macros if the functions are strictly internal. */
00099 
00100 /* First: "hash" functions */
00101 #define DECLARE_LHASH_HASH_FN(f_name,o_type) \
00102         unsigned long f_name##_LHASH_HASH(const void *);
00103 #define IMPLEMENT_LHASH_HASH_FN(f_name,o_type) \
00104         unsigned long f_name##_LHASH_HASH(const void *arg) { \
00105                 o_type a = (o_type)arg; \
00106                 return f_name(a); }
00107 #define LHASH_HASH_FN(f_name) f_name##_LHASH_HASH
00108 
00109 /* Second: "compare" functions */
00110 #define DECLARE_LHASH_COMP_FN(f_name,o_type) \
00111         int f_name##_LHASH_COMP(const void *, const void *);
00112 #define IMPLEMENT_LHASH_COMP_FN(f_name,o_type) \
00113         int f_name##_LHASH_COMP(const void *arg1, const void *arg2) { \
00114                 o_type a = (o_type)arg1; \
00115                 o_type b = (o_type)arg2; \
00116                 return f_name(a,b); }
00117 #define LHASH_COMP_FN(f_name) f_name##_LHASH_COMP
00118 
00119 /* Third: "doall" functions */
00120 #define DECLARE_LHASH_DOALL_FN(f_name,o_type) \
00121         void f_name##_LHASH_DOALL(void *);
00122 #define IMPLEMENT_LHASH_DOALL_FN(f_name,o_type) \
00123         void f_name##_LHASH_DOALL(void *arg) { \
00124                 o_type a = (o_type)arg; \
00125                 f_name(a); }
00126 #define LHASH_DOALL_FN(f_name) f_name##_LHASH_DOALL
00127 
00128 /* Fourth: "doall_arg" functions */
00129 #define DECLARE_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
00130         void f_name##_LHASH_DOALL_ARG(void *, void *);
00131 #define IMPLEMENT_LHASH_DOALL_ARG_FN(f_name,o_type,a_type) \
00132         void f_name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
00133                 o_type a = (o_type)arg1; \
00134                 a_type b = (a_type)arg2; \
00135                 f_name(a,b); }
00136 #define LHASH_DOALL_ARG_FN(f_name) f_name##_LHASH_DOALL_ARG
00137 
00138 typedef struct lhash_st
00139         {
00140         LHASH_NODE **b;
00141         LHASH_COMP_FN_TYPE comp;
00142         LHASH_HASH_FN_TYPE hash;
00143         unsigned int num_nodes;
00144         unsigned int num_alloc_nodes;
00145         unsigned int p;
00146         unsigned int pmax;
00147         unsigned long up_load; /* load times 256 */
00148         unsigned long down_load; /* load times 256 */
00149         unsigned long num_items;
00150 
00151         unsigned long num_expands;
00152         unsigned long num_expand_reallocs;
00153         unsigned long num_contracts;
00154         unsigned long num_contract_reallocs;
00155         unsigned long num_hash_calls;
00156         unsigned long num_comp_calls;
00157         unsigned long num_insert;
00158         unsigned long num_replace;
00159         unsigned long num_delete;
00160         unsigned long num_no_delete;
00161         unsigned long num_retrieve;
00162         unsigned long num_retrieve_miss;
00163         unsigned long num_hash_comps;
00164 
00165         int error;
00166         } LHASH;
00167 
00168 #define LH_LOAD_MULT    256
00169 
00170 /* Indicates a malloc() error in the last call, this is only bad
00171  * in lh_insert(). */
00172 #define lh_error(lh)    ((lh)->error)
00173 
00174 LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c);
00175 void lh_free(LHASH *lh);
00176 void *lh_insert(LHASH *lh, void *data);
00177 void *lh_delete(LHASH *lh, const void *data);
00178 void *lh_retrieve(LHASH *lh, const void *data);
00179 void lh_doall(LHASH *lh, LHASH_DOALL_FN_TYPE func);
00180 void lh_doall_arg(LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg);
00181 unsigned long lh_strhash(const char *c);
00182 unsigned long lh_num_items(const LHASH *lh);
00183 
00184 #ifndef OPENSSL_NO_FP_API
00185 void lh_stats(const LHASH *lh, FILE *out);
00186 void lh_node_stats(const LHASH *lh, FILE *out);
00187 void lh_node_usage_stats(const LHASH *lh, FILE *out);
00188 #endif
00189 
00190 #ifndef OPENSSL_NO_BIO
00191 void lh_stats_bio(const LHASH *lh, BIO *out);
00192 void lh_node_stats_bio(const LHASH *lh, BIO *out);
00193 void lh_node_usage_stats_bio(const LHASH *lh, BIO *out);
00194 #endif
00195 #ifdef  __cplusplus
00196 }
00197 #endif
00198 
00199 #endif
00200 
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'