#include <stdio.h>
#include <ac/ctype.h>
+#include <ac/errno.h>
#include <ac/socket.h>
#include <ac/string.h>
/* check to see if there's an id included */
next = s;
- if ( isdigit( *s ) ) {
+ if ( isdigit( (unsigned char) *s ) ) {
id = atoi( s );
if ( (s = ldif_getline( &next )) == NULL ) {
Debug( LDAP_DEBUG_TRACE,
0, 0, 0 );
return( NULL );
}
- e->e_id = id;
- entry_rdwr_init(e);
+ e->e_id = id;
+ e->e_private = NULL;
/* dn + attributes */
e->e_attrs = NULL;
if ( strcasecmp( type, "dn" ) == 0 ) {
if ( e->e_dn != NULL ) {
Debug( LDAP_DEBUG_ANY,
- "str2entry: entry %lu has multiple dns \"%s\" and \"%s\" (second ignored)\n",
+ "str2entry: entry %ld has multiple dns \"%s\" and \"%s\" (second ignored)\n",
e->e_id, e->e_dn, value );
continue;
}
if ( e->e_ndn != NULL ) {
Debug( LDAP_DEBUG_ANY,
- "str2entry: entry %lu already has a normalized dn \"%s\" for \"%s\" (first ignored)\n",
+ "str2entry: entry %ld already has a normalized dn \"%s\" for \"%s\" (first ignored)\n",
e->e_id, e->e_ndn, value );
free( e->e_ndn );
}
/* check to make sure there was a dn: line */
if ( e->e_dn == NULL ) {
- Debug( LDAP_DEBUG_ANY, "str2entry: entry %lu has no dn\n",
+ Debug( LDAP_DEBUG_ANY, "str2entry: entry %ld has no dn\n",
e->e_id, 0, 0 );
entry_free( e );
return( NULL );
if ( e->e_ndn == NULL ) {
Debug( LDAP_DEBUG_ANY,
- "str2entry: entry %lu (\"%s\") has no normalized dn\n",
+ "str2entry: entry %ld (\"%s\") has no normalized dn\n",
e->e_id, e->e_dn, 0 );
entry_free( e );
return( NULL );
}
- Debug(LDAP_DEBUG_TRACE, "<= str2entry 0x%lx\n", (unsigned long)e, 0,0);
+ Debug(LDAP_DEBUG_TRACE, "<= str2entry(%s) -> %ld (0x%lx)\n",
+ e->e_dn, e->e_id, (unsigned long)e );
return( e );
}
void
entry_free( Entry *e )
{
- int i;
Attribute *a, *next;
- /* XXX check that no reader/writer locks exist */
-#ifdef LDAP_DEBUG
- assert( !ldap_pvt_thread_rdwr_wchk(&e->e_rdwr) &&
- !ldap_pvt_thread_rdwr_rchk(&e->e_rdwr) );
-#endif
-
if ( e->e_dn != NULL ) {
free( e->e_dn );
+ e->e_dn = NULL;
}
if ( e->e_ndn != NULL ) {
free( e->e_ndn );
+ e->e_ndn = NULL;
}
for ( a = e->e_attrs; a != NULL; a = next ) {
next = a->a_next;
attr_free( a );
}
+ e->e_attrs = NULL;
+ e->e_private = NULL;
free( e );
}
-int
-entry_rdwr_lock(Entry *e, int rw)
-{
- Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%slock: ID: %ld\n",
- rw ? "w" : "r", e->e_id, 0);
- if (rw)
- return ldap_pvt_thread_rdwr_wlock(&e->e_rdwr);
- else
- return ldap_pvt_thread_rdwr_rlock(&e->e_rdwr);
-}
-
-int
-entry_rdwr_rlock(Entry *e)
-{
- return entry_rdwr_lock( e, 0 );
-}
-
-int
-entry_rdwr_wlock(Entry *e)
-{
- return entry_rdwr_lock( e, 1 );
-}
+/*
+ * These routines are used only by Backend.
+ *
+ * the Entry has three entry points (ways to find things):
+ *
+ * by entry e.g., if you already have an entry from the cache
+ * and want to delete it. (really by entry ptr)
+ * by dn e.g., when looking for the base object of a search
+ * by id e.g., for search candidates
+ *
+ * these correspond to three different avl trees that are maintained.
+ */
int
-entry_rdwr_unlock(Entry *e, int rw)
+entry_cmp( Entry *e1, Entry *e2 )
{
- Debug( LDAP_DEBUG_ARGS, "entry_rdwr_%sunlock: ID: %ld\n",
- rw ? "w" : "r", e->e_id, 0);
- if (rw)
- return ldap_pvt_thread_rdwr_wunlock(&e->e_rdwr);
- else
- return ldap_pvt_thread_rdwr_runlock(&e->e_rdwr);
+ return( e1 < e2 ? -1 : (e1 > e2 ? 1 : 0) );
}
int
-entry_rdwr_runlock(Entry *e)
+entry_dn_cmp( Entry *e1, Entry *e2 )
{
- return entry_rdwr_unlock( e, 0 );
+ /* compare their normalized UPPERCASED dn's */
+ return( strcmp( e1->e_ndn, e2->e_ndn ) );
}
int
-entry_rdwr_wunlock(Entry *e)
+entry_id_cmp( Entry *e1, Entry *e2 )
{
- return entry_rdwr_unlock( e, 1 );
+ return( e1->e_id < e2->e_id ? -1 : (e1->e_id > e2->e_id ? 1 : 0) );
}
-int
-entry_rdwr_init(Entry *e)
-{
- return ldap_pvt_thread_rdwr_init( &e->e_rdwr );
-}