]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/dn2entry.c
More cleanup
[openldap] / servers / slapd / back-bdb / dn2entry.c
1 /* dn2entry.c - routines to deal with the dn2id / id2entry glue */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-2000 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(
22         BackendDB       *be,
23         DB_TXN *tid,
24         struct berval *dn,
25         Entry **e,
26         Entry **matched,
27         int flags )
28 {
29         int rc;
30         ID              id, id2 = 0;
31
32         Debug(LDAP_DEBUG_TRACE, "bdb_dn2entry(\"%s\")\n",
33                 dn->bv_val, 0, 0 );
34
35         *e = NULL;
36
37         if( matched != NULL ) {
38                 *matched = NULL;
39                 rc = bdb_dn2id_matched( be, tid, dn, &id, &id2 );
40         } else {
41                 rc = bdb_dn2id( be, tid, dn, &id );
42         }
43
44         if( rc != 0 ) {
45                 return rc;
46         }
47
48         if( id2 == 0 ) {
49                 rc = bdb_id2entry( be, tid, id, e );
50         } else {
51                 rc = bdb_id2entry( be, tid, id2, matched );
52         }
53
54         return rc;
55 }