util_ldap_cache.h revision 769fec4a3ee740c172676c243aeb02171d80872e
b66914021bd429f41311d2909a7e9289866da7fdnd/* ====================================================================
b51bf223f42d43ca6b1b33c95124edcfa5a871a4nd * The Apache Software License, Version 1.1
b66914021bd429f41311d2909a7e9289866da7fdnd * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
b66914021bd429f41311d2909a7e9289866da7fdnd * reserved.
08cb74ca432a8c24e39f17dedce527e6a47b8001jerenkrantz * Redistribution and use in source and binary forms, with or without
b66914021bd429f41311d2909a7e9289866da7fdnd * modification, are permitted provided that the following conditions
b66914021bd429f41311d2909a7e9289866da7fdnd * are met:
b66914021bd429f41311d2909a7e9289866da7fdnd * 1. Redistributions of source code must retain the above copyright
b66914021bd429f41311d2909a7e9289866da7fdnd * notice, this list of conditions and the following disclaimer.
b66914021bd429f41311d2909a7e9289866da7fdnd * 2. Redistributions in binary form must reproduce the above copyright
b66914021bd429f41311d2909a7e9289866da7fdnd * notice, this list of conditions and the following disclaimer in
b66914021bd429f41311d2909a7e9289866da7fdnd * the documentation and/or other materials provided with the
b66914021bd429f41311d2909a7e9289866da7fdnd * distribution.
b66914021bd429f41311d2909a7e9289866da7fdnd * 3. The end-user documentation included with the redistribution,
b66914021bd429f41311d2909a7e9289866da7fdnd * if any, must include the following acknowledgment:
b66914021bd429f41311d2909a7e9289866da7fdnd * "This product includes software developed by the
eed2a23d9b5986937f1e2b1c120be97744508a72nd * Apache Software Foundation (http://www.apache.org/)."
eed2a23d9b5986937f1e2b1c120be97744508a72nd * Alternately, this acknowledgment may appear in the software itself,
eed2a23d9b5986937f1e2b1c120be97744508a72nd * if and wherever such third-party acknowledgments normally appear.
eed2a23d9b5986937f1e2b1c120be97744508a72nd * 4. The names "Apache" and "Apache Software Foundation" must
eed2a23d9b5986937f1e2b1c120be97744508a72nd * not be used to endorse or promote products derived from this
eed2a23d9b5986937f1e2b1c120be97744508a72nd * software without prior written permission. For written
eed2a23d9b5986937f1e2b1c120be97744508a72nd * permission, please contact apache@apache.org.
eed2a23d9b5986937f1e2b1c120be97744508a72nd * 5. Products derived from this software may not be called "Apache",
eed2a23d9b5986937f1e2b1c120be97744508a72nd * nor may "Apache" appear in their name, without prior written
eed2a23d9b5986937f1e2b1c120be97744508a72nd * permission of the Apache Software Foundation.
eed2a23d9b5986937f1e2b1c120be97744508a72nd * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
eed2a23d9b5986937f1e2b1c120be97744508a72nd * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
eed2a23d9b5986937f1e2b1c120be97744508a72nd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
eed2a23d9b5986937f1e2b1c120be97744508a72nd * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
eed2a23d9b5986937f1e2b1c120be97744508a72nd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
eed2a23d9b5986937f1e2b1c120be97744508a72nd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
eed2a23d9b5986937f1e2b1c120be97744508a72nd * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
eed2a23d9b5986937f1e2b1c120be97744508a72nd * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
eed2a23d9b5986937f1e2b1c120be97744508a72nd * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
eed2a23d9b5986937f1e2b1c120be97744508a72nd * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
eed2a23d9b5986937f1e2b1c120be97744508a72nd * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
eed2a23d9b5986937f1e2b1c120be97744508a72nd * SUCH DAMAGE.
eed2a23d9b5986937f1e2b1c120be97744508a72nd * ====================================================================
eed2a23d9b5986937f1e2b1c120be97744508a72nd * This software consists of voluntary contributions made by many
eed2a23d9b5986937f1e2b1c120be97744508a72nd * individuals on behalf of the Apache Software Foundation. For more
eed2a23d9b5986937f1e2b1c120be97744508a72nd * information on the Apache Software Foundation, please see
eed2a23d9b5986937f1e2b1c120be97744508a72nd * This switches LDAP support on or off.
eed2a23d9b5986937f1e2b1c120be97744508a72nd/* this whole thing disappears if LDAP is not enabled */
eed2a23d9b5986937f1e2b1c120be97744508a72nd * LDAP Cache Manager
eed2a23d9b5986937f1e2b1c120be97744508a72ndtypedef struct util_cache_node_t {
eed2a23d9b5986937f1e2b1c120be97744508a72nd unsigned long maxentries; /* Maximum number of cache entries */
eed2a23d9b5986937f1e2b1c120be97744508a72nd unsigned long numentries; /* Current number of cache entries */
eed2a23d9b5986937f1e2b1c120be97744508a72nd unsigned long fullmark; /* Used to keep track of when cache becomes 3/4 full */
eed2a23d9b5986937f1e2b1c120be97744508a72nd apr_time_t marktime; /* Time that the cache became 3/4 full */
eed2a23d9b5986937f1e2b1c120be97744508a72nd unsigned long (*hash)(void *); /* Func to hash the payload */
eed2a23d9b5986937f1e2b1c120be97744508a72nd int (*compare)(void *, void *); /* Func to compare two payloads */
eed2a23d9b5986937f1e2b1c120be97744508a72nd void * (*copy)(util_ald_cache_t *cache, void *); /* Func to alloc mem and copy payload to new mem */
eed2a23d9b5986937f1e2b1c120be97744508a72nd void (*free)(util_ald_cache_t *cache, void *); /* Func to free mem used by the payload */
eed2a23d9b5986937f1e2b1c120be97744508a72nd unsigned long numpurges; /* No. of times the cache has been purged */
eed2a23d9b5986937f1e2b1c120be97744508a72nd double avg_purgetime; /* Average time to purge the cache */
bcf004854091600aa279525d6772e1827114d39dnd unsigned long npurged; /* Number of elements purged in last purge. This is not
9963f91528694fb21e93da8584c31f226c6de97akess obvious: it won't be 3/4 the size of the cache if
eed2a23d9b5986937f1e2b1c120be97744508a72nd there were a lot of expired entries. */
eed2a23d9b5986937f1e2b1c120be97744508a72nd if (!st->util_ldap_cache_lock) apr_thread_rwlock_create(&st->util_ldap_cache_lock, st->pool)
typedef struct util_url_node_t {
const char *url;
typedef struct util_search_node_t {
typedef struct util_compare_node_t {
const char *attrib;
const char *value;
int result;
typedef struct util_dn_compare_node_t {
/* util_ldap_cache.c */
unsigned long util_ldap_url_node_hash(void *n);
int util_ldap_url_node_compare(void *a, void *b);
unsigned long util_ldap_search_node_hash(void *n);
int util_ldap_search_node_compare(void *a, void *b);
unsigned long util_ldap_compare_node_hash(void *n);
int util_ldap_compare_node_compare(void *a, void *b);
unsigned long util_ldap_dn_compare_node_hash(void *n);
int util_ldap_dn_compare_node_compare(void *a, void *b);
/* util_ldap_cache_mgr.c */
unsigned long (*hashfunc)(void *),
int (*comparefunc)(void *, void *),
char *name);