/*
- * Copyright 1998-2001 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*
* Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
*/
struct metadncacheentry {
- char *dn;
- int target;
+ struct berval dn;
+ int target;
- time_t lastupdated;
+ time_t lastupdated;
};
/*
{
struct metadncacheentry *cc1 = ( struct metadncacheentry * )c1;
struct metadncacheentry *cc2 = ( struct metadncacheentry * )c2;
-
+
/*
* case sensitive, because the dn MUST be normalized
*/
- return strcmp( cc1->dn, cc2->dn );
+ return ber_bvcmp( &cc1->dn, &cc2->dn);
}
/*
/*
* case sensitive, because the dn MUST be normalized
*/
- return ( strcmp( cc1->dn, cc2->dn ) == 0 ) ? -1 : 0;
+ return ( ber_bvcmp( &cc1->dn, &cc2->dn ) == 0 ) ? -1 : 0;
}
/*
int
meta_dncache_get_target(
struct metadncache *cache,
- const char *ndn
+ struct berval *ndn
)
{
struct metadncacheentry tmp_entry, *entry;
time_t curr_time;
int target = -1;
- tmp_entry.dn = ( char * )ndn;
+ assert( cache );
+ assert( ndn );
+
+ tmp_entry.dn = *ndn;
ldap_pvt_thread_mutex_lock( &cache->mutex );
entry = ( struct metadncacheentry * )avl_find( cache->tree,
( caddr_t )&tmp_entry, meta_dncache_cmp );
int
meta_dncache_update_entry(
struct metadncache *cache,
- const char *ndn,
+ struct berval *ndn,
int target
)
{
time_t curr_time = 0L;
int err = 0;
+ assert( cache );
+ assert( ndn );
+
/*
* if cache->ttl < 0, cache never expires;
* if cache->ttl = 0 no cache is used; shouldn't get here
curr_time = time( NULL );
}
- tmp_entry.dn = ( char * )ndn;
+ tmp_entry.dn = *ndn;
ldap_pvt_thread_mutex_lock( &cache->mutex );
entry = ( struct metadncacheentry * )avl_find( cache->tree,
return -1;
}
- entry->dn = ch_strdup( ndn );
- if ( entry->dn == NULL ) {
+ ber_dupbv( &entry->dn, ndn );
+ if ( entry->dn.bv_val == NULL ) {
ldap_pvt_thread_mutex_unlock( &cache->mutex );
return -1;
}
int
meta_dncache_delete_entry(
struct metadncache *cache,
- const char *ndn
+ struct berval *ndn
)
{
struct metadncacheentry *entry, tmp_entry;
- tmp_entry.dn = ( char * )ndn;
+ assert( cache );
+ assert( ndn );
+
+ tmp_entry.dn = *ndn;
ldap_pvt_thread_mutex_lock( &cache->mutex );
entry = avl_delete( &cache->tree, ( caddr_t )&tmp_entry,
meta_dncache_cmp );
- ldap_pvt_thread_mutex_lock( &cache->mutex );
+ ldap_pvt_thread_mutex_unlock( &cache->mutex );
if ( entry != NULL ) {
meta_dncache_free( ( void * )entry );
{
struct metadncacheentry *entry = ( struct metadncacheentry * )e;
- free( entry->dn );
+ free( entry->dn.bv_val );
}