1 /* id2children.c - routines to deal with the id2children index */
3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 #include <ac/string.h>
12 #include <ac/socket.h>
15 #include "back-ldbm.h"
29 ldbm_datum_init( key );
31 Debug( LDAP_DEBUG_TRACE, "=> id2children_add( %ld, %ld )\n",
32 p ? p->e_id : 0, e->e_id, 0 );
34 if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
35 LDBM_WRCREAT )) == NULL ) {
36 Debug( LDAP_DEBUG_ANY,
37 "<= id2children_add -1 could not open \"id2children%s\"\n",
42 sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
44 key.dsize = strlen( buf ) + 1;
46 if ( idl_insert_key( be, db, key, e->e_id ) != 0 ) {
47 Debug( LDAP_DEBUG_TRACE, "<= id2children_add -1 (idl_insert)\n",
49 ldbm_cache_close( be, db );
53 ldbm_cache_close( be, db );
55 Debug( LDAP_DEBUG_TRACE, "<= id2children_add 0\n", 0, 0, 0 );
71 Debug( LDAP_DEBUG_TRACE, "=> id2children_remove( %ld, %ld )\n", p ? p->e_id
74 if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
75 LDBM_WRCREAT )) == NULL ) {
76 Debug( LDAP_DEBUG_ANY,
77 "<= id2children_remove -1 could not open \"id2children%s\"\n",
82 ldbm_datum_init( key );
83 sprintf( buf, "%c%ld", EQ_PREFIX, p ? p->e_id : 0 );
85 key.dsize = strlen( buf ) + 1;
87 if ( idl_delete_key( be, db, key, e->e_id ) != 0 ) {
89 Debug( LDAP_DEBUG_ANY,
90 "<= id2children_remove: idl_delete_key failure\n",
92 ldbm_cache_close( be, db );
95 Debug( LDAP_DEBUG_ANY,
96 "<= id2children_remove: ignoring idl_delete_key failure\n",
101 ldbm_cache_close( be, db );
103 Debug( LDAP_DEBUG_TRACE, "<= id2children_remove 0\n", 0, 0, 0 );
122 ldbm_datum_init( key );
124 Debug( LDAP_DEBUG_TRACE, "=> has_children( %ld )\n", p->e_id , 0, 0 );
127 if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX,
128 LDBM_WRCREAT )) == NULL ) {
129 Debug( LDAP_DEBUG_ANY,
130 "<= has_children -1 could not open \"id2children%s\"\n",
135 sprintf( buf, "%c%ld", EQ_PREFIX, p->e_id );
137 key.dsize = strlen( buf ) + 1;
140 if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX,
141 LDBM_WRCREAT )) == NULL ) {
142 Debug( LDAP_DEBUG_ANY,
143 "<= has_children -1 could not open \"dn2id%s\"\n",
148 key.dsize = strlen( p->e_ndn ) + 2;
149 key.dptr = ch_malloc( key.dsize );
150 sprintf( key.dptr, "%c%s", DN_ONE_PREFIX, p->e_ndn );
153 idl = idl_fetch( be, db, key );
155 ldbm_cache_close( be, db );
162 Debug( LDAP_DEBUG_TRACE, "<= has_children( %ld ): %s\n",
163 p->e_id, rc ? "yes" : "no", 0 );