示例#1
0
AttrInfo *
bdb_attr_mask(
	struct bdb_info	*bdb,
	AttributeDescription *desc )
{
	int i = bdb_attr_slot( bdb, desc, NULL );
	return i < 0 ? NULL : bdb->bi_attrs[i];
}
示例#2
0
文件: index.c 项目: cptaffe/openldap
/* Get the list of which indices apply to this attr */
int
bdb_index_recset(
	struct bdb_info *bdb,
	Attribute *a,
	AttributeType *type,
	struct berval *tags,
	IndexRec *ir )
{
	int rc, slot;
	AttrList *al;

	if( type->sat_sup ) {
		/* recurse */
		rc = bdb_index_recset( bdb, a, type->sat_sup, tags, ir );
		if( rc ) return rc;
	}
	/* If this type has no AD, we've never used it before */
	if( type->sat_ad ) {
		slot = bdb_attr_slot( bdb, type->sat_ad, NULL );
		if ( slot >= 0 ) {
			ir[slot].ai = bdb->bi_attrs[slot];
			al = ch_malloc( sizeof( AttrList ));
			al->attr = a;
			al->next = ir[slot].attrs;
			ir[slot].attrs = al;
		}
	}
	if( tags->bv_len ) {
		AttributeDescription *desc;

		desc = ad_find_tags( type, tags );
		if( desc ) {
			slot = bdb_attr_slot( bdb, desc, NULL );
			if ( slot >= 0 ) {
				ir[slot].ai = bdb->bi_attrs[slot];
				al = ch_malloc( sizeof( AttrList ));
				al->attr = a;
				al->next = ir[slot].attrs;
				ir[slot].attrs = al;
			}
		}
	}
	return LDAP_SUCCESS;
}
示例#3
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];
	}
}
示例#4
0
static int
ainfo_insert( struct bdb_info *bdb, AttrInfo *a )
{
	int x;
	int i = bdb_attr_slot( bdb, a->ai_desc, &x );

	/* Is it a dup? */
	if ( i >= 0 )
		return -1;

	bdb->bi_attrs = ch_realloc( bdb->bi_attrs, ( bdb->bi_nattrs+1 ) * 
		sizeof( AttrInfo * ));
	if ( x < bdb->bi_nattrs )
		AC_MEMCPY( &bdb->bi_attrs[x+1], &bdb->bi_attrs[x],
			( bdb->bi_nattrs - x ) * sizeof( AttrInfo *));
	bdb->bi_attrs[x] = a;
	bdb->bi_nattrs++;
	return 0;
}