#define SUBLEN 3
+/* #define DN_INDICES 1 *//* generate dn eq, subtree, and parent indices */
+#define DN_EQ_PREFIX '='
+#define DN_SUBTREE_PREFIX '+'
+#define DN_PARENT_PREFIX '-'
+
/*
* there is a single index for each attribute. these prefixes ensure
* that there is no collision among keys.
/* allow 3 characters per byte + PREFIX + EOS */
#define CONT_SIZE ( sizeof(long)*3 + 1 + 1 )
-/* #define CONT_POSTFIX 1 *//* postfix original key */
+
+#undef CONT_POSTFIX /* postfix original key */
#define UNKNOWN_PREFIX '?' /* prefix for unknown keys */
return( -1 );
}
- dn = ch_strdup( dn );
- (void) dn_normalize_case( dn );
-
+#ifndef DN_INDICES
key.dptr = dn;
- key.dsize = strlen( dn ) + 1;
+ key.dsize = strlen( key.dptr ) + 1;
+#else
+ key.dsize = strlen( dn ) + 2;
+ key.dptr = ch_malloc( key.dsize );
+ sprintf( key.dptr, "%c%s", DN_EQ_PREFIX, dn );
+#endif
+
data.dptr = (char *) &id;
data.dsize = sizeof(ID);
rc = ldbm_cache_store( db, key, data, flags );
- free( dn );
ldbm_cache_close( be, db );
+#ifdef DN_INDICES
+ free( key.dptr );
+#endif
+
Debug( LDAP_DEBUG_TRACE, "<= dn2id_add %d\n", rc, 0, 0 );
return( rc );
}
ldbm_datum_init( key );
ldbm_datum_init( data );
- dn = ch_strdup( dn );
Debug( LDAP_DEBUG_TRACE, "=> dn2id( \"%s\" )\n", dn, 0, 0 );
- (void) dn_normalize_case( dn );
/* first check the cache */
if ( (id = cache_find_entry_dn2id( be, &li->li_cache, dn )) != NOID ) {
- free( dn );
Debug( LDAP_DEBUG_TRACE, "<= dn2id %ld (in cache)\n", id,
0, 0 );
return( id );
if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT ))
== NULL ) {
- free( dn );
Debug( LDAP_DEBUG_ANY, "<= dn2id could not open dn2id%s\n",
LDBM_SUFFIX, 0, 0 );
return( NOID );
}
+#ifndef DN_INDICES
key.dptr = dn;
- key.dsize = strlen( dn ) + 1;
+ key.dsize = strlen( key.dptr ) + 1;
+#else
+ key.dsize = strlen( dn ) + 2;
+ key.dptr = ch_malloc( key.dsize );
+ sprintf( key.dptr, "%c%s", DN_EQ_PREFIX, dn );
+#endif
data = ldbm_cache_fetch( db, key );
ldbm_cache_close( be, db );
- free( dn );
+
+#ifdef DN_INDICES
+ free( key.dptr );
+#endif
if ( data.dptr == NULL ) {
Debug( LDAP_DEBUG_TRACE, "<= dn2id NOID\n", 0, 0, 0 );
return( -1 );
}
- dn = ch_strdup( dn );
- (void) dn_normalize_case( dn );
+#ifndef DN_INDICES
key.dptr = dn;
- key.dsize = strlen( dn ) + 1;
+ key.dsize = strlen( key.dptr ) + 1;
+#else
+ key.dsize = strlen( dn ) + 2;
+ key.dptr = ch_malloc( key.dsize );
+ sprintf( key.dptr, "%c%s", DN_EQ_PREFIX, dn );
+#endif
rc = ldbm_cache_delete( db, key );
- free( dn );
+#ifdef DN_INDICES
+ free( key.dptr );
+#endif
ldbm_cache_close( be, db );
id );
} else {
(void) dn_normalize_case( val );
+#ifndef DN_INDICES
key.dptr = val;
key.dsize = strlen( val ) + 1;
+#else
+ key.dsize = strlen( val ) + 2;
+ key.dptr = ch_malloc( key.dsize );
+ sprintf( key.dptr, "%c%s", DN_EQ_PREFIX, val );
+#endif
data.dptr = (char *) &id;
data.dsize = sizeof(ID);
if ( ldbm_store( db->dbc_db, key, data,
perror( "dn2id ldbm_store" );
exit( EXIT_FAILURE );
}
+#ifdef DN_INDICES
+ free( val );
+#endif
}
}
if ( buf )