1999-02-06 00:23:03 +08:00
|
|
|
/* id2children.c - routines to deal with the id2children index */
|
1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1999-02-06 00:23:03 +08:00
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
|
|
|
|
#include <ac/socket.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "back-bdb2.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
bdb2i_has_children(
|
1999-02-08 19:42:14 +08:00
|
|
|
BackendDB *be,
|
1999-02-06 00:23:03 +08:00
|
|
|
Entry *p
|
|
|
|
)
|
|
|
|
{
|
|
|
|
struct dbcache *db;
|
|
|
|
Datum key;
|
|
|
|
int rc = 0;
|
|
|
|
ID_BLOCK *idl;
|
|
|
|
|
|
|
|
ldbm_datum_init( key );
|
|
|
|
|
1999-02-12 20:13:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "=> bdb2i_has_children( %ld )\n", p->e_id , 0, 0 );
|
1999-02-06 00:23:03 +08:00
|
|
|
|
1999-08-18 03:00:59 +08:00
|
|
|
if ( (db = bdb2i_cache_open( be, "dn2id", BDB2_SUFFIX,
|
1999-02-06 00:23:03 +08:00
|
|
|
LDBM_WRCREAT )) == NULL ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY,
|
1999-08-18 03:00:59 +08:00
|
|
|
"<= bdb2i_has_children: could not open \"dn2id" BDB2_SUFFIX "\"\n",
|
|
|
|
0, 0, 0 );
|
1999-02-06 00:23:03 +08:00
|
|
|
return( 0 );
|
|
|
|
}
|
|
|
|
|
1999-08-18 03:00:59 +08:00
|
|
|
key.dsize = strlen( p->e_ndn ) + 2;
|
|
|
|
key.dptr = ch_malloc( key.dsize );
|
|
|
|
sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, p->e_ndn );
|
1999-02-06 00:23:03 +08:00
|
|
|
|
|
|
|
idl = bdb2i_idl_fetch( be, db, key );
|
|
|
|
|
1999-08-18 03:00:59 +08:00
|
|
|
free( key.dptr );
|
|
|
|
|
1999-02-06 00:23:03 +08:00
|
|
|
bdb2i_cache_close( be, db );
|
|
|
|
|
|
|
|
if( idl != NULL ) {
|
|
|
|
bdb2i_idl_free( idl );
|
|
|
|
rc = 1;
|
|
|
|
}
|
|
|
|
|
1999-02-12 20:13:03 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "<= bdb2i_has_children( %ld ): %s\n",
|
1999-02-06 00:23:03 +08:00
|
|
|
p->e_id, rc ? "yes" : "no", 0 );
|
|
|
|
return( rc );
|
|
|
|
}
|