static void idl_dump( ID *ids )
{
if( BDB_IDL_IS_RANGE( ids ) ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_INFO, "IDL: range (%ld - %ld)\n",
+ (long) BDB_IDL_RANGE_FIRST( ids ),
+ (long) BDB_IDL_RANGE_LAST( ids ) ));
+#else
Debug( LDAP_DEBUG_ANY,
"IDL: range ( %ld - %ld )\n",
(long) BDB_IDL_RANGE_FIRST( ids ),
(long) BDB_IDL_RANGE_LAST( ids ) );
+#endif
} else {
ID i;
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_INFO, "IDL: size %ld",
+ (long) ids[0] ));
+#else
Debug( LDAP_DEBUG_ANY, "IDL: size %ld", (long) ids[0], 0, 0 );
+#endif
for( i=1; i<=ids[0]; i++ ) {
if( i % 16 == 1 ) {
Debug( LDAP_DEBUG_ANY, "\n", 0, 0, 0 );
}
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_INFO, "%02lx",(long)ids[i] ));
+#else
Debug( LDAP_DEBUG_ANY, " %02lx", (long) ids[i], 0, 0 );
+#endif
}
Debug( LDAP_DEBUG_ANY, "\n", 0, 0, 0 );
unsigned x = bdb_idl_search( ids, id );
#if IDL_DEBUG > 1
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_DETAIL1, "insert: %04lx at %d\n",
+ (long) id, x ));
+#else
Debug( LDAP_DEBUG_ANY, "insert: %04lx at %d\n", (long) id, x, 0 );
idl_dump( ids );
+#endif
#elif IDL_DEBUG > 0
idl_check( ids );
#endif
unsigned x = bdb_idl_search( ids, id );
#if IDL_DEBUG > 1
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_DETAIL1, "delete: %04lx at %d\n",
+ (long) id, x ));
+#else
Debug( LDAP_DEBUG_ANY, "delete: %04lx at %d\n", (long) id, x, 0 );
idl_dump( ids );
+#endif
#elif IDL_DEBUG > 0
idl_check( ids );
#endif
rc = db->cursor( db, tid, &cursor, bdb->bi_db_opflags );
if( rc != 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: cursor failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
"cursor failed: %s (%d)\n", db_strerror(rc), rc, 0 );
+#endif
return rc;
}
rc = cursor->c_get( cursor, key, &data, flags | DB_SET );
/* On disk, a range is denoted by 0 in the first element */
if (ids[1] == 0) {
if (ids[0] != BDB_IDL_RANGE_SIZE) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "=> bdb_idl_fetch_key: range size mismatch: expected %ld, got %ld\n", BDB_IDL_RANGE_SIZE, ids[0] ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
"range size mismatch: expected %ld, got %ld\n",
BDB_IDL_RANGE_SIZE, ids[0], 0 );
+#endif
cursor->c_close( cursor );
return -1;
}
}
rc2 = cursor->c_close( cursor );
if (rc2) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: close failed: %s (%d)\n", db_strerror(rc2), rc2 ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
- "close failed: %s (%d)\n", db_strerror(rc2), rc2, 0 );
+ "close failed: %s (%d)\n", db_strerror(rc2), rc2, 0 )
+#endif
return rc2;
}
}
return rc;
} else if( rc != 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: get failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
"get failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
+#endif
return rc;
} else if ( data.size == 0 || data.size % sizeof( ID ) ) {
/* size not multiple of ID size */
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: odd size: expected %ld multiple, got %ld\n", (long) sizeof( ID ), (long) data.size ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
"odd size: expected %ld multiple, got %ld\n",
(long) sizeof( ID ), (long) data.size, 0 );
+#endif
return -1;
} else if ( data.size != BDB_IDL_SIZEOF(ids) ) {
/* size mismatch */
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_fetch_key: get size mismatch: expected %ld, got %ld\n", (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_fetch_key: "
"get size mismatch: expected %ld, got %ld\n",
(long) ((1 + ids[0]) * sizeof( ID )), (long) data.size, 0 );
+#endif
return -1;
}
#if 0
/* for printable keys only */
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ARGS, "bdb_idl_insert_key: %s %ld\n", (char *)key->data, (long) id ));
+#else
Debug( LDAP_DEBUG_ARGS,
"=> bdb_idl_insert_key: %s %ld\n",
(char *)key->data, (long) id, 0 );
+#endif
#endif
assert( id != NOID );
id > BDB_IDL_RANGE_LAST(buf) ) {
rc = db->cursor( db, tid, &cursor, bdb->bi_db_opflags );
if ( rc != 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: cursor failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
"cursor failed: %s (%d)\n", db_strerror(rc), rc, 0 );
+#endif
return rc;
}
if ( id < BDB_IDL_RANGE_FIRST(buf) ) {
rc = cursor->c_get( cursor, key, &data, DB_GET_BOTH | DB_RMW );
if ( rc != 0 ) {
err = "c_get";
-fail: Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
+fail:
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: %s failed: %s (%d)\n", err, db_strerror(rc), rc ));
+#else
+ Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
"%s failed: %s (%d)\n", err, db_strerror(rc), rc );
+#endif
if ( cursor ) cursor->c_close( cursor );
return rc;
}
data.size = 2 * sizeof( ID );
} else if ( rc != 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: get failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
"get failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
+#endif
return rc;
} else if ( data.size == 0 || data.size % sizeof( ID ) ) {
/* size not multiple of ID size */
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: odd size: expected %ld multiple, got %ld\n", (long) sizeof( ID ), (long) data.size ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
"odd size: expected %ld multiple, got %ld\n",
(long) sizeof( ID ), (long) data.size, 0 );
+#endif
return -1;
} else if ( data.size != BDB_IDL_SIZEOF(ids) ) {
/* size mismatch */
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: odd size: expected %ld multiple, got %ld\n", (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
"get size mismatch: expected %ld, got %ld\n",
(long) ((1 + ids[0]) * sizeof( ID )), (long) data.size, 0 );
+#endif
return -1;
} else if ( BDB_IDL_IS_RANGE(ids) ) {
rc = bdb_idl_insert( ids, id );
if( rc == -1 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_DETAIL1, "bdb_idl_insert_key: dup\n" ));
+#else
Debug( LDAP_DEBUG_TRACE, "=> bdb_idl_insert_key: dup\n",
0, 0, 0 );
+#endif
return 0;
}
if( rc != 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: insert failed: (%d)\n", rc ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
"bdb_idl_insert failed (%d)\n",
rc, 0, 0 );
+#endif
return rc;
}
if( rc == DB_KEYEXIST ) rc = 0;
if( rc != 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_insert_key: put failed: (%d)\n", db_strerror(rc), rc ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_insert_key: "
"put failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
+#endif
}
return rc;
}
#if 0
/* for printable keys only */
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ARGS, "bdb_idl_delete_key: %s %ld\n", (char *)key->data, (long) id ));
+#else
Debug( LDAP_DEBUG_ARGS,
"=> bdb_idl_delete_key: %s %ld\n",
(char *)key->data, (long) id, 0 );
+#endif
#endif
assert( id != NOID );
rc = db->get( db, tid, key, &data, DB_RMW | bdb->bi_db_opflags );
if ( rc != 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: get failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: "
"get failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
+#endif
return rc;
} else if ( data.size == 0 || data.size % sizeof( ID ) ) {
/* size not multiple of ID size */
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: odd size: expected: %ld multiple, got %ld\n", (long) sizeof( ID ), (long) data.size ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: "
"odd size: expected %ld multiple, got %ld\n",
(long) sizeof( ID ), (long) data.size, 0 );
+#endif
return -1;
} else if ( BDB_IDL_IS_RANGE(ids) ) {
} else if ( data.size != (1 + ids[0]) * sizeof( ID ) ) {
/* size mismatch */
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: get size mismatch: expected: %ld, got %ld\n", (long) ((1 + ids[0]) * sizeof( ID )), (long) data.size ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: "
"get size mismatch: expected %ld, got %ld\n",
(long) ((1 + ids[0]) * sizeof( ID )), (long) data.size, 0 );
+#endif
return -1;
} else {
rc = idl_delete( ids, id );
if( rc != 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: delete failed: (%d)\n", rc ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: "
"idl_delete failed (%d)\n",
rc, 0, 0 );
+#endif
return rc;
}
/* delete the key */
rc = db->del( db, tid, key, 0 );
if( rc != 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: delete failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
Debug( LDAP_DEBUG_ANY, "=> bdb_idl_delete_key: "
"delete failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
+#endif
}
return rc;
}
#endif /* BDB_IDL_MULTI */
if( rc != 0 ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG(( "idl", LDAP_LEVEL_ERR, "bdb_idl_delete_key: put failed: %s (%d)\n", db_strerror(rc), rc ));
+#else
Debug( LDAP_DEBUG_ANY,
"=> bdb_idl_delete_key: put failed: %s (%d)\n",
db_strerror(rc), rc, 0 );
+#endif
}
return rc;