openldap/servers/slapd/back-bdb/dn2entry.c

64 lines
1.1 KiB
C
Raw Normal View History

2000-09-25 06:48:13 +08:00
/* dn2entry.c - routines to deal with the dn2id / id2entry glue */
/* $OpenLDAP$ */
/*
2002-01-05 05:17:25 +08:00
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
2000-09-25 06:48:13 +08:00
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include "back-bdb.h"
/*
* dn2entry - look up dn in the cache/indexes and return the corresponding
* entry.
*/
int
bdb_dn2entry_rw(
BackendDB *be,
2000-09-25 06:48:13 +08:00
DB_TXN *tid,
struct berval *dn,
2000-09-25 06:48:13 +08:00
Entry **e,
Entry **matched,
int flags,
int rw,
u_int32_t locker,
DB_LOCK *lock )
2000-09-25 06:48:13 +08:00
{
int rc;
2001-12-29 18:25:19 +08:00
ID id, id2 = 0;
2000-09-25 06:48:13 +08:00
2002-03-27 04:04:30 +08:00
#ifdef NEW_LOGGING
LDAP_LOG (( "db2entry", LDAP_LEVEL_ARGS, "bdb_dn2entry_rw(\"%s\")\n",
dn->bv_val ));
#else
Debug(LDAP_DEBUG_TRACE, "bdb_dn2entry_rw(\"%s\")\n",
dn->bv_val, 0, 0 );
2002-03-27 04:04:30 +08:00
#endif
2000-09-25 06:48:13 +08:00
2000-09-27 01:47:24 +08:00
*e = NULL;
2000-09-25 06:48:13 +08:00
if( matched != NULL ) {
2000-09-27 01:47:24 +08:00
*matched = NULL;
2002-06-11 03:02:25 +08:00
rc = bdb_dn2id_matched( be, tid, dn, &id, &id2, flags );
2000-09-25 06:48:13 +08:00
} else {
2002-06-11 03:02:25 +08:00
rc = bdb_dn2id( be, tid, dn, &id, flags );
2000-09-25 06:48:13 +08:00
}
if( rc != 0 ) {
return rc;
}
2001-12-29 18:25:19 +08:00
if( id2 == 0 ) {
rc = bdb_id2entry_rw( be, tid, id, e, rw, locker, lock );
2000-09-25 06:48:13 +08:00
} else {
rc = bdb_id2entry_r( be, tid, id2, matched, locker, lock );
2000-09-25 06:48:13 +08:00
}
return rc;
2000-09-27 01:47:24 +08:00
}