]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/id2children.c
Merge in all devel changes since 2.0-alpha2.
[openldap] / servers / slapd / back-ldbm / id2children.c
1 /* id2children.c - routines to deal with the id2children index */
2 /* $OpenLDAP$ */
3 /*
4  * Copyright 1998-1999 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 <ac/socket.h>
14
15 #include "slap.h"
16 #include "back-ldbm.h"
17
18
19 int
20 has_children(
21     Backend     *be,
22     Entry       *p
23 )
24 {
25         DBCache *db;
26         Datum           key;
27         int             rc = 0;
28         ID_BLOCK                *idl;
29
30         ldbm_datum_init( key );
31
32         Debug( LDAP_DEBUG_TRACE, "=> has_children( %ld )\n", p->e_id , 0, 0 );
33
34         if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX,
35             LDBM_WRCREAT )) == NULL ) {
36                 Debug( LDAP_DEBUG_ANY,
37                     "<= has_children -1 could not open \"dn2id%s\"\n",
38                     LDBM_SUFFIX, 0, 0 );
39                 return( 0 );
40         }
41
42         key.dsize = strlen( p->e_ndn ) + 2;
43         key.dptr = ch_malloc( key.dsize );
44         sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, p->e_ndn );
45
46         idl = idl_fetch( be, db, key );
47
48         free( key.dptr );
49
50         ldbm_cache_close( be, db );
51
52         if( idl != NULL ) {
53                 idl_free( idl );
54                 rc = 1;
55         }
56
57         Debug( LDAP_DEBUG_TRACE, "<= has_children( %ld ): %s\n",
58                 p->e_id, rc ? "yes" : "no", 0 );
59         return( rc );
60 }