]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb2/id2children.c
Use #ifdef, not #if
[openldap] / servers / slapd / back-bdb2 / id2children.c
1 /* id2children.c - routines to deal with the id2children index */
2 /* $OpenLDAP$ */
3
4 #include "portable.h"
5
6 #include <stdio.h>
7 #include <ac/string.h>
8
9 #include <ac/socket.h>
10
11 #include "slap.h"
12 #include "back-bdb2.h"
13
14 int
15 bdb2i_has_children(
16     BackendDB   *be,
17     Entry       *p
18 )
19 {
20         struct dbcache  *db;
21         Datum           key;
22         int             rc = 0;
23         ID_BLOCK                *idl;
24
25         ldbm_datum_init( key );
26
27         Debug( LDAP_DEBUG_TRACE, "=> bdb2i_has_children( %ld )\n", p->e_id , 0, 0 );
28
29         if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX,
30             LDBM_WRCREAT )) == NULL ) {
31                 Debug( LDAP_DEBUG_ANY,
32                     "<= bdb2i_has_children: could not open \"dn2id" BDB2_SUFFIX "\"\n",
33                     0, 0, 0 );
34                 return( 0 );
35         }
36
37         key.dsize = strlen( p->e_ndn ) + 2;
38         key.dptr = ch_malloc( key.dsize );
39         sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, p->e_ndn );
40
41         idl = bdb2i_idl_fetch( be, db, key );
42
43         free( key.dptr );
44
45         bdb2i_cache_close( be, db );
46
47         if( idl != NULL ) {
48                 bdb2i_idl_free( idl );
49                 rc = 1;
50         }
51
52         Debug( LDAP_DEBUG_TRACE, "<= bdb2i_has_children( %ld ): %s\n",
53                                         p->e_id, rc ? "yes" : "no", 0 );
54         return( rc );
55 }