]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/dn2entry.c
Switch to openldap-data
[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         Debug(LDAP_DEBUG_TRACE, "bdb_dn2entry_rw(\"%s\")\n",
34                 dn->bv_val, 0, 0 );
35
36         *e = NULL;
37
38         if( matched != NULL ) {
39                 *matched = NULL;
40                 rc = bdb_dn2id_matched( be, tid, dn, &id, &id2 );
41         } else {
42                 rc = bdb_dn2id( be, tid, dn, &id );
43         }
44
45         if( rc != 0 ) {
46                 return rc;
47         }
48
49         if( id2 == 0 ) {
50                 rc = bdb_id2entry_rw( be, tid, id, e, rw );
51         } else {
52                 rc = bdb_id2entry_r( be, tid, id2, matched);
53         }
54
55         return rc;
56 }