00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef APU_LDAP_CACHE_H
00018 #define APU_LDAP_CACHE_H
00019
00025
00026 #if APR_HAS_LDAP
00027
00028
00029
00030
00031
00032
00033 #include "util_ldap.h"
00034
00035 typedef struct util_cache_node_t {
00036 void *payload;
00037 apr_time_t add_time;
00038 struct util_cache_node_t *next;
00039 } util_cache_node_t;
00040
00041 typedef struct util_ald_cache util_ald_cache_t;
00042
00043 struct util_ald_cache {
00044 unsigned long size;
00045 unsigned long maxentries;
00046 unsigned long numentries;
00047 unsigned long fullmark;
00048 apr_time_t marktime;
00049 unsigned long (*hash)(void *);
00050 int (*compare)(void *, void *);
00051 void * (*copy)(util_ald_cache_t *cache, void *);
00052 void (*free)(util_ald_cache_t *cache, void *);
00053 void (*display)(request_rec *r, util_ald_cache_t *cache, void *);
00054 util_cache_node_t **nodes;
00055
00056 unsigned long numpurges;
00057 double avg_purgetime;
00058 apr_time_t last_purge;
00059 unsigned long npurged;
00060
00061
00062
00063 unsigned long fetches;
00064 unsigned long hits;
00065 unsigned long inserts;
00066 unsigned long removes;
00067
00068 #if APR_HAS_SHARED_MEMORY
00069 apr_shm_t *shm_addr;
00070 apr_rmm_t *rmm_addr;
00071 #endif
00072
00073 };
00074
00075 #ifndef WIN32
00076 #define ALD_MM_FILE_MODE ( S_IRUSR|S_IWUSR )
00077 #else
00078 #define ALD_MM_FILE_MODE ( _S_IREAD|_S_IWRITE )
00079 #endif
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 typedef struct util_url_node_t {
00093 const char *url;
00094 util_ald_cache_t *search_cache;
00095 util_ald_cache_t *compare_cache;
00096 util_ald_cache_t *dn_compare_cache;
00097 } util_url_node_t;
00098
00099
00100
00101
00102
00103
00104 typedef struct util_search_node_t {
00105 const char *username;
00106 const char *dn;
00107 const char *bindpw;
00108
00109 apr_time_t lastbind;
00110 const char **vals;
00111 int numvals;
00112 } util_search_node_t;
00113
00114
00115
00116
00117
00118 typedef struct util_compare_node_t {
00119 const char *dn;
00120 const char *attrib;
00121 const char *value;
00122 apr_time_t lastcompare;
00123 int result;
00124 } util_compare_node_t;
00125
00126
00127
00128
00129
00130 typedef struct util_dn_compare_node_t {
00131 const char *reqdn;
00132 const char *dn;
00133 } util_dn_compare_node_t;
00134
00135
00136
00137
00138
00139
00140
00141 unsigned long util_ldap_url_node_hash(void *n);
00142 int util_ldap_url_node_compare(void *a, void *b);
00143 void *util_ldap_url_node_copy(util_ald_cache_t *cache, void *c);
00144 void util_ldap_url_node_free(util_ald_cache_t *cache, void *n);
00145 void util_ldap_url_node_display(request_rec *r, util_ald_cache_t *cache, void *n);
00146
00147 unsigned long util_ldap_search_node_hash(void *n);
00148 int util_ldap_search_node_compare(void *a, void *b);
00149 void *util_ldap_search_node_copy(util_ald_cache_t *cache, void *c);
00150 void util_ldap_search_node_free(util_ald_cache_t *cache, void *n);
00151 void util_ldap_search_node_display(request_rec *r, util_ald_cache_t *cache, void *n);
00152
00153 unsigned long util_ldap_compare_node_hash(void *n);
00154 int util_ldap_compare_node_compare(void *a, void *b);
00155 void *util_ldap_compare_node_copy(util_ald_cache_t *cache, void *c);
00156 void util_ldap_compare_node_free(util_ald_cache_t *cache, void *n);
00157 void util_ldap_compare_node_display(request_rec *r, util_ald_cache_t *cache, void *n);
00158
00159 unsigned long util_ldap_dn_compare_node_hash(void *n);
00160 int util_ldap_dn_compare_node_compare(void *a, void *b);
00161 void *util_ldap_dn_compare_node_copy(util_ald_cache_t *cache, void *c);
00162 void util_ldap_dn_compare_node_free(util_ald_cache_t *cache, void *n);
00163 void util_ldap_dn_compare_node_display(request_rec *r, util_ald_cache_t *cache, void *n);
00164
00165
00166
00167
00168
00169 void util_ald_free(util_ald_cache_t *cache, const void *ptr);
00170 void *util_ald_alloc(util_ald_cache_t *cache, unsigned long size);
00171 const char *util_ald_strdup(util_ald_cache_t *cache, const char *s);
00172
00173
00174 unsigned long util_ald_hash_string(int nstr, ...);
00175 void util_ald_cache_purge(util_ald_cache_t *cache);
00176 util_url_node_t *util_ald_create_caches(util_ldap_state_t *s, const char *url);
00177 util_ald_cache_t *util_ald_create_cache(util_ldap_state_t *st,
00178 long cache_size,
00179 unsigned long (*hashfunc)(void *),
00180 int (*comparefunc)(void *, void *),
00181 void * (*copyfunc)(util_ald_cache_t *cache, void *),
00182 void (*freefunc)(util_ald_cache_t *cache, void *),
00183 void (*displayfunc)(request_rec *r, util_ald_cache_t *cache, void *));
00184
00185 void util_ald_destroy_cache(util_ald_cache_t *cache);
00186 void *util_ald_cache_fetch(util_ald_cache_t *cache, void *payload);
00187 void *util_ald_cache_insert(util_ald_cache_t *cache, void *payload);
00188 void util_ald_cache_remove(util_ald_cache_t *cache, void *payload);
00189 char *util_ald_cache_display_stats(request_rec *r, util_ald_cache_t *cache, char *name, char *id);
00190
00191 #endif
00192 #endif