예제 #1
0
void
bdb_attr_index_destroy( struct bdb_info *bdb )
{
	int i;

	for ( i=0; i<bdb->bi_nattrs; i++ ) 
		bdb_attr_info_free( bdb->bi_attrs[i] );

	free( bdb->bi_attrs );
}
예제 #2
0
void bdb_attr_index_free( struct bdb_info *bdb, AttributeDescription *ad )
{
	int i;

	i = bdb_attr_slot( bdb, ad, NULL );
	if ( i >= 0 ) {
		bdb_attr_info_free( bdb->bi_attrs[i] );
		bdb->bi_nattrs--;
		for (; i<bdb->bi_nattrs; i++)
			bdb->bi_attrs[i] = bdb->bi_attrs[i+1];
	}
}
예제 #3
0
void bdb_attr_flush( struct bdb_info *bdb )
{
	int i;

	for ( i=0; i<bdb->bi_nattrs; i++ ) {
		if ( bdb->bi_attrs[i]->ai_indexmask & BDB_INDEX_DELETING ) {
			int j;
			bdb_attr_info_free( bdb->bi_attrs[i] );
			bdb->bi_nattrs--;
			for (j=i; j<bdb->bi_nattrs; j++)
				bdb->bi_attrs[j] = bdb->bi_attrs[j+1];
			i--;
		}
	}
}
예제 #4
0
ID bdb_tool_entry_next(
	BackendDB *be )
{
	int rc;
	ID id;
	struct bdb_info *bdb = (struct bdb_info *) be->be_private;

	assert( be != NULL );
	assert( slapMode & SLAP_TOOL_MODE );
	assert( bdb != NULL );

	/* Get the header */
	data.ulen = data.dlen = sizeof( ehbuf );
	data.data = ehbuf;
	data.flags |= DB_DBT_PARTIAL;
	rc = cursor->c_get( cursor, &key, &data, DB_NEXT );

	if( rc ) {
		/* If we're doing linear indexing and there are more attrs to
		 * index, and we're at the end of the database, start over.
		 */
		if ( index_nattrs && rc == DB_NOTFOUND ) {
			/* optional - do a checkpoint here? */
			bdb_attr_info_free( bdb->bi_attrs[0] );
			bdb->bi_attrs[0] = bdb->bi_attrs[index_nattrs];
			index_nattrs--;
			rc = cursor->c_get( cursor, &key, &data, DB_FIRST );
			if ( rc ) {
				return NOID;
			}
		} else {
			return NOID;
		}
	}

	BDB_DISK2ID( key.data, &id );
	previd = id;
	return id;
}
예제 #5
0
파일: tools.c 프로젝트: rouzier/openldap
ID bdb_tool_entry_next(
	BackendDB *be )
{
	int rc;
	ID id;
	struct bdb_info *bdb;

	assert( be != NULL );
	assert( slapMode & SLAP_TOOL_MODE );

	bdb = (struct bdb_info *) be->be_private;
	assert( bdb != NULL );

next:;
	/* Get the header */
	data.ulen = data.dlen = sizeof( ehbuf );
	data.data = ehbuf;
	data.flags |= DB_DBT_PARTIAL;
	rc = cursor->c_get( cursor, &key, &data, DB_NEXT );

	if( rc ) {
		/* If we're doing linear indexing and there are more attrs to
		 * index, and we're at the end of the database, start over.
		 */
		if ( index_nattrs && rc == DB_NOTFOUND ) {
			/* optional - do a checkpoint here? */
			bdb_attr_info_free( bdb->bi_attrs[0] );
			bdb->bi_attrs[0] = bdb->bi_attrs[index_nattrs];
			index_nattrs--;
			rc = cursor->c_get( cursor, &key, &data, DB_FIRST );
			if ( rc ) {
				return NOID;
			}
		} else {
			return NOID;
		}
	}

	BDB_DISK2ID( key.data, &id );
	previd = id;

	if ( tool_filter || tool_base ) {
		static Operation op = {0};
		static Opheader ohdr = {0};

		op.o_hdr = &ohdr;
		op.o_bd = be;
		op.o_tmpmemctx = NULL;
		op.o_tmpmfuncs = &ch_mfuncs;

		if ( tool_next_entry ) {
			bdb_entry_release( &op, tool_next_entry, 0 );
			tool_next_entry = NULL;
		}

		rc = bdb_tool_entry_get_int( be, id, &tool_next_entry );
		if ( rc == LDAP_NO_SUCH_OBJECT ) {
			goto next;
		}

		assert( tool_next_entry != NULL );

#ifdef BDB_HIER
		/* TODO: needed until BDB_HIER is handled accordingly
		 * in bdb_tool_entry_get_int() */
		if ( tool_base && !dnIsSuffixScope( &tool_next_entry->e_nname, tool_base, tool_scope ) )
		{
			bdb_entry_release( &op, tool_next_entry, 0 );
			tool_next_entry = NULL;
			goto next;
		}
#endif

		if ( tool_filter && test_filter( NULL, tool_next_entry, tool_filter ) != LDAP_COMPARE_TRUE )
		{
			bdb_entry_release( &op, tool_next_entry, 0 );
			tool_next_entry = NULL;
			goto next;
		}
	}

	return id;
}