]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/dn2entry.c
Rough in search routine
[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     Backend     *be,
23         DB_TXN *tid,
24     const char *dn,
25         Entry **e,
26     Entry **matched,
27         int flags )
28 {
29         int rc;
30         ID              id;
31         char    *matchedDN = NULL;
32
33         Debug(LDAP_DEBUG_TRACE, "bdb_dn2entry: dn: \"%s\"\n",
34                 dn, 0, 0 );
35
36         if( matched != NULL ) {
37                 rc = bdb_dn2id_matched( be, tid, dn, &id, &matchedDN );
38         } else {
39                 rc = bdb_dn2id( be, tid, dn, &id );
40         }
41
42         if( rc != 0 ) {
43                 return rc;
44         }
45
46         if( matchedDN == NULL ) {
47                 rc = bdb_id2entry( be, tid, id, e );
48         } else {
49                 ch_free( matchedDN );
50                 rc = bdb_id2entry( be, tid, id, matched );
51         }
52
53         return rc;
54 }