]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/dn2entry.c
Added LDAP_LOG messages
[openldap] / servers / slapd / back-bdb / dn2entry.c
1 /* dn2entry.c - routines to deal with the dn2id / id2entry glue */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
5  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6  */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11 #include <ac/string.h>
12
13 #include "back-bdb.h"
14
15 /*
16  * dn2entry - look up dn in the cache/indexes and return the corresponding
17  * entry.
18  */
19
20 int
21 bdb_dn2entry_rw(
22         BackendDB       *be,
23         DB_TXN *tid,
24         struct berval *dn,
25         Entry **e,
26         Entry **matched,
27         int flags,
28         int rw )
29 {
30         int rc;
31         ID              id, id2 = 0;
32
33 #ifdef NEW_LOGGING
34         LDAP_LOG (( "db2entry", LDAP_LEVEL_ARGS, "bdb_dn2entry_rw(\"%s\")\n",
35                 dn->bv_val ));
36 #else
37         Debug(LDAP_DEBUG_TRACE, "bdb_dn2entry_rw(\"%s\")\n",
38                 dn->bv_val, 0, 0 );
39 #endif
40
41         *e = NULL;
42
43         if( matched != NULL ) {
44                 *matched = NULL;
45                 rc = bdb_dn2id_matched( be, tid, dn, &id, &id2 );
46         } else {
47                 rc = bdb_dn2id( be, tid, dn, &id );
48         }
49
50         if( rc != 0 ) {
51                 return rc;
52         }
53
54         if( id2 == 0 ) {
55                 rc = bdb_id2entry_rw( be, tid, id, e, rw );
56         } else {
57                 rc = bdb_id2entry_r( be, tid, id2, matched);
58         }
59
60         return rc;
61 }