Changed AttributeType.sat_cname from char * to struct berval.

(will fix up back-bdb next.)
This commit is contained in:
Howard Chu 2001-11-16 07:45:37 +00:00
parent cc4a51f23c
commit 0bfaa8b4ae
9 changed files with 80 additions and 114 deletions

View File

@ -276,7 +276,8 @@ at_add(
sat = (AttributeType *) ch_calloc( 1, sizeof(AttributeType) );
AC_MEMCPY( &sat->sat_atype, at, sizeof(LDAPAttributeType));
sat->sat_cname = cname;
sat->sat_cname.bv_val = cname;
sat->sat_cname.bv_len = strlen( cname );
ldap_pvt_thread_mutex_init(&sat->sat_ad_mutex);
if ( at->at_sup_oid ) {

View File

@ -507,12 +507,12 @@ ldap_send_entry(
"[rw] searchResult on"
" attr=%s:"
" \"%s\" -> \"%s\"\n",
attr->a_desc->ad_type->sat_cname,
attr->a_desc->ad_type->sat_cname.bv_val,
bv->bv_val, newval ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> searchResult on attr=%s: \"%s\" -> \"%s\"\n",
attr->a_desc->ad_type->sat_cname,
attr->a_desc->ad_type->sat_cname.bv_val,
bv->bv_val, newval );
#endif /* !NEW_LOGGING */

View File

@ -18,29 +18,17 @@
/* for the cache of attribute information (which are indexed, etc.) */
typedef struct ldbm_attrinfo {
#ifdef SLAPD_USE_AD
AttributeDescription *ai_desc; /* attribute description cn;lang-en */
#else
char *ai_desc;
#endif
slap_mask_t ai_indexmask; /* how the attr is indexed */
} AttrInfo;
static int
ainfo_type_cmp(
#ifdef SLAPD_USE_AD
AttributeDescription *desc,
#else
char *desc,
#endif
AttrInfo *a
)
{
#ifdef SLAPD_USE_AD
return ad_cmp( desc, a->ai_desc );
#else
return( strcasecmp( desc, a->ai_desc ) );
#endif
return desc - a->ai_desc;
}
static int
@ -49,21 +37,13 @@ ainfo_cmp(
AttrInfo *b
)
{
#ifdef SLAPD_USE_AD
return ad_cmp( a->ai_desc, b->ai_desc );
#else
return( strcasecmp( a->ai_desc, b->ai_desc ) );
#endif
return a->ai_desc - b->ai_desc;
}
void
attr_mask(
struct ldbminfo *li,
#ifdef SLAPD_USE_AD
AttributeDescription *desc,
#else
const char *desc,
#endif
slap_mask_t *indexmask )
{
AttrInfo *a;
@ -211,11 +191,7 @@ attr_index_config(
#endif
#ifdef SLAPD_USE_AD
a->ai_desc = ad;
#else
a->ai_desc = ch_strdup( ad->ad_cname.bv_val );
#endif
a->ai_indexmask = mask;
@ -241,11 +217,7 @@ attr_index_config(
static void
ainfo_free( void *attr )
{
AttrInfo *ai = attr;
#ifndef SLAPD_USE_AD
free( ai->ai_desc );
#endif
free( ai );
free( attr );
}
void
@ -253,4 +225,3 @@ attr_index_destroy( Avlnode *tree )
{
avl_free( tree, ainfo_free );
}

View File

@ -212,7 +212,7 @@ presence_candidates(
int rc;
char *dbname;
slap_mask_t mask;
struct berval *prefix;
struct berval prefix = {0};
#ifdef NEW_LOGGING
LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
@ -221,7 +221,6 @@ presence_candidates(
Debug( LDAP_DEBUG_TRACE, "=> presence_candidates\n", 0, 0, 0 );
#endif
idl = idl_allids( be );
rc = index_param( be, desc, LDAP_FILTER_PRESENT,
@ -252,7 +251,6 @@ presence_candidates(
0, 0, 0 );
#endif
ber_bvfree( prefix );
return idl;
}
@ -269,15 +267,14 @@ presence_candidates(
dbname, LDBM_SUFFIX, 0 );
#endif
ber_bvfree( prefix );
return idl;
}
if( prefix != NULL ) {
if( prefix.bv_val != NULL ) {
idl_free( idl );
idl = NULL;
rc = key_read( be, db, prefix, &idl );
rc = key_read( be, db, &prefix, &idl );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
@ -304,7 +301,6 @@ presence_candidates(
}
ldbm_cache_close( be, db );
ber_bvfree( prefix );
#ifdef NEW_LOGGING
LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
@ -330,7 +326,7 @@ equality_candidates(
int rc;
char *dbname;
slap_mask_t mask;
struct berval *prefix;
struct berval prefix = {0};
struct berval **keys = NULL;
MatchingRule *mr;
@ -371,18 +367,15 @@ equality_candidates(
0, 0, 0 );
#endif
ber_bvfree( prefix );
return idl;
}
mr = ava->aa_desc->ad_type->sat_equality;
if( !mr ) {
ber_bvfree( prefix );
return idl;
}
if( !mr->smr_filter ) {
ber_bvfree( prefix );
return idl;
}
@ -391,12 +384,10 @@ equality_candidates(
mask,
ava->aa_desc->ad_type->sat_syntax,
mr,
prefix,
&prefix,
ava->aa_value,
&keys );
ber_bvfree( prefix );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "filter", LDAP_LEVEL_ERR,
@ -514,7 +505,7 @@ approx_candidates(
int rc;
char *dbname;
slap_mask_t mask;
struct berval *prefix;
struct berval prefix = {0};
struct berval **keys = NULL;
MatchingRule *mr;
@ -555,7 +546,6 @@ approx_candidates(
0, 0, 0 );
#endif
ber_bvfree( prefix );
return idl;
}
@ -566,12 +556,10 @@ approx_candidates(
}
if( !mr ) {
ber_bvfree( prefix );
return idl;
}
if( !mr->smr_filter ) {
ber_bvfree( prefix );
return idl;
}
@ -580,12 +568,10 @@ approx_candidates(
mask,
ava->aa_desc->ad_type->sat_syntax,
mr,
prefix,
&prefix,
ava->aa_value,
&keys );
ber_bvfree( prefix );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "filter", LDAP_LEVEL_ERR,
@ -760,7 +746,7 @@ substring_candidates(
int rc;
char *dbname;
slap_mask_t mask;
struct berval *prefix;
struct berval prefix = {0};
struct berval **keys = NULL;
MatchingRule *mr;
@ -801,19 +787,16 @@ substring_candidates(
0, 0, 0 );
#endif
ber_bvfree( prefix );
return idl;
}
mr = sub->sa_desc->ad_type->sat_substr;
if( !mr ) {
ber_bvfree( prefix );
return idl;
}
if( !mr->smr_filter ) {
ber_bvfree( prefix );
return idl;
}
@ -822,12 +805,10 @@ substring_candidates(
mask,
sub->sa_desc->ad_type->sat_syntax,
mr,
prefix,
&prefix,
sub,
&keys );
ber_bvfree( prefix );
if( rc != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "filter", LDAP_LEVEL_ERR,

View File

@ -19,47 +19,54 @@ static slap_mask_t index_mask(
Backend *be,
AttributeDescription *desc,
char **dbname,
char **atname )
struct berval *atname )
{
AttributeType *at;
slap_mask_t mask = 0;
attr_mask( be->be_private, desc->ad_cname.bv_val, &mask );
attr_mask( be->be_private, desc, &mask );
if( mask ) {
*atname = desc->ad_cname.bv_val;
*atname = desc->ad_cname;
*dbname = desc->ad_cname.bv_val;
return mask;
}
if( slap_ad_is_lang( desc ) ) {
/* If there is a language tag, did we ever index the base
* type? If so, check for mask, otherwise it's not there.
*/
if( slap_ad_is_lang( desc ) && desc != desc->ad_type->sat_ad ) {
/* has language tag */
attr_mask( be->be_private, desc->ad_type->sat_cname, &mask );
attr_mask( be->be_private, desc->ad_type->sat_ad, &mask );
if( mask & SLAP_INDEX_AUTO_LANG ) {
*atname = desc->ad_cname.bv_val;
*dbname = desc->ad_type->sat_cname;
*atname = desc->ad_cname;
*dbname = desc->ad_type->sat_cname.bv_val;
return mask;
}
if( mask & SLAP_INDEX_LANG ) {
*atname = desc->ad_type->sat_cname;
*dbname = desc->ad_type->sat_cname;
*dbname = desc->ad_type->sat_cname.bv_val;
return mask;
}
}
/* see if supertype defined mask for its subtypes */
for( at = desc->ad_type; at != NULL ; at = at->sat_sup ) {
attr_mask( be->be_private, at->sat_cname, &mask );
/* If no AD, we've never indexed this type */
if (!at->sat_ad)
continue;
attr_mask( be->be_private, at->sat_ad, &mask );
if( mask & SLAP_INDEX_AUTO_SUBTYPES ) {
*atname = desc->ad_type->sat_cname;
*dbname = at->sat_cname;
*dbname = at->sat_cname.bv_val;
return mask;
}
if( mask & SLAP_INDEX_SUBTYPES ) {
*atname = at->sat_cname;
*dbname = at->sat_cname;
*dbname = at->sat_cname.bv_val;
return mask;
}
@ -75,13 +82,12 @@ int index_param(
int ftype,
char **dbnamep,
slap_mask_t *maskp,
struct berval **prefixp )
struct berval *prefixp )
{
slap_mask_t mask;
char *dbname;
char *atname;
mask = index_mask( be, desc, &dbname, &atname );
mask = index_mask( be, desc, &dbname, prefixp );
if( mask == 0 ) {
return LDAP_INAPPROPRIATE_MATCHING;
@ -120,7 +126,6 @@ int index_param(
done:
*dbnamep = dbname;
*prefixp = ber_bvstrdup( atname );
*maskp = mask;
return LDAP_SUCCESS;
}
@ -128,7 +133,7 @@ done:
static int indexer(
Backend *be,
char *dbname,
char *atname,
struct berval *atname,
struct berval **vals,
ID id,
int op,
@ -139,17 +144,13 @@ static int indexer(
DBCache *db;
AttributeDescription *ad = NULL;
struct berval **keys;
struct berval prefix;
assert( mask );
rc = slap_str2ad( atname, &ad, &text );
rc = slap_bv2ad( atname, &ad, &text );
if( rc != LDAP_SUCCESS ) return rc;
prefix.bv_val = atname;
prefix.bv_len = strlen( atname );
db = ldbm_cache_open( be, dbname, LDBM_SUFFIX, LDBM_WRCREAT );
if ( db == NULL ) {
@ -167,7 +168,7 @@ static int indexer(
}
if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) {
key_change( be, db, &prefix, id, op );
key_change( be, db, atname, id, op );
}
if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) ) {
@ -176,7 +177,7 @@ static int indexer(
mask,
ad->ad_type->sat_syntax,
ad->ad_type->sat_equality,
&prefix, vals, &keys );
atname, vals, &keys );
if( rc == LDAP_SUCCESS && keys != NULL ) {
for( i=0; keys[i] != NULL; i++ ) {
@ -192,7 +193,7 @@ static int indexer(
mask,
ad->ad_type->sat_syntax,
ad->ad_type->sat_approx,
&prefix, vals, &keys );
atname, vals, &keys );
if( rc == LDAP_SUCCESS && keys != NULL ) {
for( i=0; keys[i] != NULL; i++ ) {
@ -208,7 +209,7 @@ static int indexer(
mask,
ad->ad_type->sat_syntax,
ad->ad_type->sat_substr,
&prefix, vals, &keys );
atname, vals, &keys );
if( rc == LDAP_SUCCESS && keys != NULL ) {
for( i=0; keys[i] != NULL; i++ ) {
@ -232,7 +233,7 @@ static int index_at_values(
char ** dbnamep,
slap_mask_t *maskp )
{
slap_mask_t mask;
slap_mask_t mask = 0;
slap_mask_t tmpmask = 0;
int lindex = 0;
@ -244,45 +245,57 @@ static int index_at_values(
dbnamep, &tmpmask );
}
attr_mask( be->be_private, type->sat_cname, &mask );
/* If this type has no AD, we've never used it before */
if (type->sat_ad)
attr_mask( be->be_private, type->sat_ad, &mask );
if( mask ) {
*dbnamep = type->sat_cname;
*dbnamep = type->sat_cname.bv_val;
} else if ( tmpmask & SLAP_INDEX_AUTO_SUBTYPES ) {
mask = tmpmask;
}
if( mask ) {
indexer( be, *dbnamep,
type->sat_cname,
&type->sat_cname,
vals, id, op,
mask );
}
if( lang->bv_len ) {
char *dbname = NULL;
size_t tlen = strlen( type->sat_cname );
size_t llen = lang->bv_len;
char *lname = ch_malloc( tlen + llen + sizeof(";") );
struct berval lname;
AttributeDescription *desc;
sprintf( lname, "%s;%s", type->sat_cname, lang->bv_val );
tmpmask = 0;
lname.bv_val = NULL;
attr_mask( be->be_private, lname, &tmpmask );
desc = ad_find_lang(type, lang);
if (desc)
attr_mask( be->be_private, desc, &tmpmask );
if( tmpmask ) {
dbname = lname;
dbname = desc->ad_cname.bv_val;
lname = desc->ad_cname;
mask = tmpmask;
} else if ( mask & SLAP_INDEX_AUTO_LANG ) {
dbname = *dbnamep;
tmpmask = mask;
lname.bv_len = type->sat_cname.bv_len+lang->bv_len + 1;
lname.bv_val = ch_malloc( lname.bv_len + 1 );
strcpy(lname.bv_val, type->sat_cname.bv_val);
lname.bv_val[type->sat_cname.bv_len] = ';';
strcpy(lname.bv_val+type->sat_cname.bv_len+1,
lang->bv_val);
}
if( dbname != NULL ) {
indexer( be, dbname, lname,
indexer( be, dbname, &lname,
vals, id, op,
tmpmask );
mask );
if (!tmpmask)
ch_free( lname.bv_val );
}
ch_free( lname );
}
return LDAP_SUCCESS;

View File

@ -34,7 +34,7 @@ Entry *deref_internal_r LDAP_P((
*/
void attr_mask LDAP_P(( struct ldbminfo *li,
const char *desc,
AttributeDescription *desc,
slap_mask_t *indexmask ));
int attr_index_config LDAP_P(( struct ldbminfo *li,
@ -146,7 +146,7 @@ index_param LDAP_P((
int ftype,
char **dbname,
slap_mask_t *mask,
struct berval **prefix ));
struct berval *prefix ));
extern int
index_values LDAP_P((

View File

@ -725,13 +725,13 @@ meta_send_entry(
"[rw] searchResult on"
" attr=%s:"
" \"%s\" -> \"%s\"\n",
attr->a_desc->ad_type->sat_cname,
attr->a_desc->ad_type->sat_cname.bv_val,
bv->bv_val, newval ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> searchResult on attr=%s:"
" \"%s\" -> \"%s\"\n",
attr->a_desc->ad_type->sat_cname,
attr->a_desc->ad_type->sat_cname.bv_val,
bv->bv_val, newval );
#endif /* !NEW_LOGGING */

View File

@ -202,7 +202,7 @@ oc_check_required( Entry *e, struct berval *ocname )
}
/* not there => schema violation */
if ( a == NULL ) {
return at->sat_cname;
return at->sat_cname.bv_val;
}
}
@ -218,15 +218,15 @@ int oc_check_allowed(
#ifdef NEW_LOGGING
LDAP_LOG(( "schema", LDAP_LEVEL_ENTRY,
"oc_check_allowed: type \"%s\"\n", at->sat_cname ));
"oc_check_allowed: type \"%s\"\n", at->sat_cname.bv_val ));
#else
Debug( LDAP_DEBUG_TRACE,
"oc_check_allowed type \"%s\"\n",
at->sat_cname, 0, 0 );
at->sat_cname.bv_val, 0, 0 );
#endif
/* always allow objectClass attribute */
if ( strcasecmp( at->sat_cname, "objectClass" ) == 0 ) {
if ( strcasecmp( at->sat_cname.bv_val, "objectClass" ) == 0 ) {
return LDAP_SUCCESS;
}

View File

@ -370,7 +370,7 @@ struct slap_attr_desc;
typedef struct slap_attribute_type {
LDAPAttributeType sat_atype;
char *sat_cname;
struct berval sat_cname;
struct slap_attribute_type *sat_sup;
struct slap_attribute_type **sat_subtypes;
MatchingRule *sat_equality;