Unindented a level. Fixed logging of keys.

This commit is contained in:
Howard Chu 2002-08-30 11:21:20 +00:00
parent f32803e738
commit 9d4f5e13e8

View File

@ -229,6 +229,20 @@ static int idl_delete( ID *ids, ID id )
return 0;
}
static char *
bdb_show_key(
DBT *key,
char *buf )
{
if ( key->size == sizeof( ID ) ) {
unsigned char *c = key->data;
sprintf( buf, "[%02x%02x%02x%02x]", c[0], c[1], c[2], c[3] );
return buf;
} else {
return key->data;
}
}
int
bdb_idl_fetch_key(
BackendDB *be,
@ -240,14 +254,27 @@ bdb_idl_fetch_key(
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
int rc;
DBT data;
#ifdef BDB_IDL_MULTI
DBC *cursor;
#endif
{
char buf[16];
#ifdef NEW_LOGGING
LDAP_LOG( INDEX, ARGS,
"bdb_idl_fetch_key: %s\n",
bdb_show_key( key, buf ), 0, 0 );
#else
Debug( LDAP_DEBUG_ARGS,
"bdb_idl_fetch_key: %s\n",
bdb_show_key( key, buf ), 0, 0 );
#endif
}
assert( ids != NULL );
DBTzero( &data );
#ifdef BDB_IDL_MULTI
{
DBC *cursor;
/* buf must be large enough to grab the entire IDL in one
* get(), otherwise BDB 4 will leak resources on subsequent
* get's. We can safely call get() twice - once for the data,
@ -329,14 +356,13 @@ bdb_idl_fetch_key(
#endif
return rc2;
}
}
#else
#else /* BDB_IDL_MULTI */
data.data = ids;
data.ulen = BDB_IDL_UM_SIZEOF;
data.flags = DB_DBT_USERMEM;
/* fetch it */
rc = db->get( db, tid, key, &data, bdb->bi_db_opflags );
#endif
#endif /* BDB_IDL_MULTI */
if( rc == DB_NOTFOUND ) {
return rc;
@ -383,6 +409,7 @@ bdb_idl_fetch_key(
return rc;
}
int
bdb_idl_insert_key(
BackendDB *be,
@ -394,31 +421,31 @@ bdb_idl_insert_key(
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
int rc;
DBT data;
#ifndef BDB_IDL_MULTI
#ifdef BDB_IDL_MULTI
DBC *cursor;
ID lo, hi, tmp;
char *err;
#else
ID ids[BDB_IDL_DB_SIZE];
#endif
#if 0
/* for printable keys only */
{
char buf[16];
#ifdef NEW_LOGGING
LDAP_LOG( INDEX, ARGS, "bdb_idl_insert_key: %s %ld\n",
(char *)key->data, (long) id, 0 );
LDAP_LOG( INDEX, ARGS,
"bdb_idl_insert_key: %lx %s\n",
(long) id, bdb_show_key( key, buf ), 0 );
#else
Debug( LDAP_DEBUG_ARGS,
"=> bdb_idl_insert_key: %s %ld\n",
(char *)key->data, (long) id, 0 );
#endif
"bdb_idl_insert_key: %lx %s\n",
(long) id, bdb_show_key( key, buf ), 0 );
#endif
}
assert( id != NOID );
DBTzero( &data );
#ifdef BDB_IDL_MULTI
{
DBC *cursor;
ID lo, hi, tmp;
char *err;
data.size = sizeof( ID );
data.ulen = data.size;
data.flags = DB_DBT_USERMEM;
@ -566,7 +593,6 @@ fail:
return rc;
}
rc = cursor->c_close( cursor );
}
#else /* !BDB_IDL_MULTI */
data.data = ids;
data.ulen = sizeof ids;
@ -682,31 +708,31 @@ bdb_idl_delete_key(
struct bdb_info *bdb = (struct bdb_info *) be->be_private;
int rc;
DBT data;
#ifndef BDB_IDL_MULTI
ID ids[BDB_IDL_DB_SIZE];
#endif
#if 0
/* for printable keys only */
#ifdef NEW_LOGGING
LDAP_LOG( INDEX, ARGS, "bdb_idl_delete_key: %s %ld\n",
(char *)key->data, (long) id, 0 );
#else
Debug( LDAP_DEBUG_ARGS,
"=> bdb_idl_delete_key: %s %ld\n",
(char *)key->data, (long) id, 0 );
#endif
#endif
assert( id != NOID );
DBTzero( &data );
#ifdef BDB_IDL_MULTI
{
DBC *cursor;
ID lo, hi, tmp;
char *err;
#else
ID ids[BDB_IDL_DB_SIZE];
#endif
{
char buf[16];
#ifdef NEW_LOGGING
LDAP_LOG( INDEX, ARGS,
"bdb_idl_delete_key: %lx %s\n",
(long) id, bdb_show_key( key, buf ), 0 );
#else
Debug( LDAP_DEBUG_ARGS,
"bdb_idl_delete_key: %lx %s\n",
(long) id, bdb_show_key( key, buf ), 0 );
#endif
}
assert( id != NOID );
DBTzero( &data );
#ifdef BDB_IDL_MULTI
data.data = &tmp;
data.size = sizeof( id );
data.ulen = data.size;
@ -737,14 +763,16 @@ bdb_idl_delete_key(
tmp = id;
rc = cursor->c_get( cursor, key, &data,
DB_GET_BOTH | DB_RMW );
if ( rc != 0 ) {
err = "c_get id";
goto fail;
}
}
if ( rc == 0 ) {
rc = cursor->c_del( cursor, 0 );
if ( rc != 0 ) {
err = "c_del id";
goto fail;
}
}
} else {
/* It's a range, see if we need to rewrite
* the boundaries
@ -811,8 +839,9 @@ fail:
return rc;
}
rc = cursor->c_close( cursor );
}
#else
#else /* BDB_IDL_MULTI */
data.data = ids;
data.ulen = sizeof( ids );
data.flags = DB_DBT_USERMEM;