#else
char *ai_desc;
#endif
- slap_index ai_indexmask; /* how the attr is indexed */
+ slap_mask_t ai_indexmask; /* how the attr is indexed */
} AttrInfo;
static int
#else
const char *desc,
#endif
- slap_index *indexmask )
+ slap_mask_t *indexmask )
{
AttrInfo *a;
{
int rc;
int i;
- slap_index mask;
+ slap_mask_t mask;
char **attrs;
char **indexes = NULL;
mask = 0;
for ( i = 0; indexes[i] != NULL; i++ ) {
- slap_index index;
+ slap_mask_t index;
rc = slap_str2index( indexes[i], &index );
if( rc != LDAP_SUCCESS ) {
ldap_pvt_thread_mutex_t li_root_mutex;
ldap_pvt_thread_mutex_t li_add_mutex;
int li_mode;
- slap_index li_defaultmask;
+ slap_mask_t li_defaultmask;
char *li_directory;
Cache li_cache;
Avlnode *li_attrs;
Backend *be, AttributeAssertion *ava );
static ID_BLOCK *substring_candidates(
Backend *be,
- Filter *f );
+ SubstringsAssertion *sub );
static ID_BLOCK *list_candidates(
Backend *be,
Filter *flist,
case LDAP_FILTER_SUBSTRINGS:
Debug( LDAP_DEBUG_FILTER, "\tSUBSTRINGS\n", 0, 0, 0 );
- result = substring_candidates( be, f );
+ result = substring_candidates( be, f->f_sub );
break;
case LDAP_FILTER_GE:
DBCache *db;
int rc;
char *dbname;
- slap_index mask;
+ slap_mask_t mask;
struct berval *prefix;
Debug( LDAP_DEBUG_TRACE, "=> presence_candidates\n", 0, 0, 0 );
&dbname, &mask, &prefix );
if( rc != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_ANY,
+ "<= presence_candidates: index_param failed (%d)\n",
+ rc, 0, 0 );
return idl;
}
if( dbname == NULL ) {
/* not indexed */
+ Debug( LDAP_DEBUG_TRACE,
+ "<= presense_candidates: not indexed\n",
+ 0, 0, 0 );
ber_bvfree( prefix );
return idl;
}
int i;
int rc;
char *dbname;
- slap_index mask;
+ slap_mask_t mask;
struct berval *prefix;
struct berval **keys = NULL;
MatchingRule *mr;
&dbname, &mask, &prefix );
if( rc != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_ANY,
+ "<= equality_candidates: index_param failed (%d)\n",
+ rc, 0, 0 );
return idl;
}
if( dbname == NULL ) {
/* not indexed */
+ Debug( LDAP_DEBUG_TRACE,
+ "<= equality_candidates: not indexed\n",
+ 0, 0, 0 );
ber_bvfree( prefix );
return idl;
}
mr = ava->aa_desc->ad_type->sat_equality;
if( !mr ) {
ber_bvfree( prefix );
- /* return LDAP_INAPPROPRIATE_MATCHING; */
return idl;
}
rc = (mr->smr_filter)(
LDAP_FILTER_EQUALITY,
+ mask,
ava->aa_desc->ad_type->sat_syntax,
mr,
prefix,
ber_bvfree( prefix );
if( rc != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<= equality_candidates: (%s%s) MR filter failed (%d)\n",
+ dbname, LDBM_SUFFIX, rc );
+ return idl;
+ }
+
+ if( keys == NULL ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<= equality_candidates: no keys (%s%s)\n",
+ dbname, LDBM_SUFFIX, 0 );
return idl;
}
int i;
int rc;
char *dbname;
- slap_index mask;
+ slap_mask_t mask;
struct berval *prefix;
struct berval **keys = NULL;
MatchingRule *mr;
idl = idl_allids( be );
- rc = index_param( be, ava->aa_desc, LDAP_FILTER_EQUALITY,
+ rc = index_param( be, ava->aa_desc, LDAP_FILTER_APPROX,
&dbname, &mask, &prefix );
if( rc != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_ANY,
+ "<= approx_candidates: index_param failed (%d)\n",
+ rc, 0, 0 );
return idl;
}
if( dbname == NULL ) {
/* not indexed */
+ Debug( LDAP_DEBUG_ANY,
+ "<= approx_candidates: not indexed\n",
+ 0, 0, 0 );
ber_bvfree( prefix );
return idl;
}
mr = ava->aa_desc->ad_type->sat_approx;
- if( mr == NULL ) {
+ if( !mr ) {
/* no approx matching rule, try equality matching rule */
mr = ava->aa_desc->ad_type->sat_equality;
}
if( !mr ) {
ber_bvfree( prefix );
- /* return LDAP_INAPPROPRIATE_MATCHING; */
return idl;
}
}
rc = (mr->smr_filter)(
- LDAP_FILTER_EQUALITY,
+ LDAP_FILTER_APPROX,
+ mask,
ava->aa_desc->ad_type->sat_syntax,
mr,
prefix,
ber_bvfree( prefix );
if( rc != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<= approx_candidates: (%s%s) MR filter failed (%d)\n",
+ dbname, LDBM_SUFFIX, rc );
+ return idl;
+ }
+
+ if( keys == NULL ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<= approx_candidates: no keys (%s%s)\n",
+ dbname, LDBM_SUFFIX, 0 );
return idl;
}
static ID_BLOCK *
substring_candidates(
Backend *be,
- Filter *f
+ SubstringsAssertion *sub
)
{
ID_BLOCK *idl;
+ DBCache *db;
+ int i;
+ int rc;
+ char *dbname;
+ slap_mask_t mask;
+ struct berval *prefix;
+ struct berval **keys = NULL;
+ MatchingRule *mr;
- Debug( LDAP_DEBUG_TRACE, "=> substring_candidates\n", 0, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "=> substrings_candidates\n", 0, 0, 0 );
idl = idl_allids( be );
- Debug( LDAP_DEBUG_TRACE, "<= substring_candidates %ld\n",
+
+ rc = index_param( be, sub->sa_desc, LDAP_FILTER_SUBSTRINGS,
+ &dbname, &mask, &prefix );
+
+ if( rc != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_ANY,
+ "<= substrings_candidates: index_param failed (%d)\n",
+ rc, 0, 0 );
+ return idl;
+ }
+
+ if( dbname == NULL ) {
+ /* not indexed */
+ Debug( LDAP_DEBUG_ANY,
+ "<= substrings_candidates: not indexed\n",
+ 0, 0, 0 );
+ 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;
+ }
+
+ rc = (mr->smr_filter)(
+ LDAP_FILTER_SUBSTRINGS,
+ mask,
+ sub->sa_desc->ad_type->sat_syntax,
+ mr,
+ prefix,
+ sub,
+ &keys );
+
+ ber_bvfree( prefix );
+
+ if( rc != LDAP_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<= substrings_candidates: (%s%s) MR filter failed (%d)\n",
+ dbname, LDBM_SUFFIX, rc );
+ return idl;
+ }
+
+ if( keys == NULL ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "<= substrings_candidates: (0x%04lx) no keys (%s%s)\n",
+ mask, dbname, LDBM_SUFFIX );
+ return idl;
+ }
+
+ db = ldbm_cache_open( be, dbname, LDBM_SUFFIX, LDBM_READER );
+
+ if ( db == NULL ) {
+ Debug( LDAP_DEBUG_ANY,
+ "<= substrings_candidates db open failed (%s%s)\n",
+ dbname, LDBM_SUFFIX, 0 );
+ return idl;
+ }
+
+ for ( i= 0; keys[i] != NULL; i++ ) {
+ ID_BLOCK *save;
+ ID_BLOCK *tmp;
+
+ rc = key_read( be, db, keys[i], &tmp );
+
+ if( rc != LDAP_SUCCESS ) {
+ idl_free( idl );
+ idl = NULL;
+ Debug( LDAP_DEBUG_TRACE, "<= substrings_candidates key read failed (%d)\n",
+ rc, 0, 0 );
+ break;
+ }
+
+ if( tmp == NULL ) {
+ idl_free( idl );
+ idl = NULL;
+ Debug( LDAP_DEBUG_TRACE, "<= substrings_candidates NULL\n",
+ 0, 0, 0 );
+ break;
+ }
+
+ save = idl;
+ idl = idl_intersection( be, idl, tmp );
+ idl_free( save );
+
+ if( idl == NULL ) break;
+ }
+
+ ber_bvecfree( keys );
+
+ ldbm_cache_close( be, db );
+
+ Debug( LDAP_DEBUG_TRACE, "<= substrings_candidates %ld\n",
idl ? ID_BLOCK_NIDS(idl) : 0, 0, 0 );
return( idl );
}
-
char **atname )
{
AttributeType *at;
- slap_index mask = 0;
+ slap_mask_t mask = 0;
/* we do support indexing of binary attributes */
if( slap_ad_is_binary( desc ) ) return 0;
AttributeDescription *desc,
int ftype,
char **dbnamep,
- slap_index *maskp,
+ slap_mask_t *maskp,
struct berval **prefixp )
{
- slap_index mask;
+ slap_mask_t mask;
char *dbname;
char *atname;
struct berval **vals,
ID id,
int op,
- slap_index mask )
+ slap_mask_t mask )
{
int rc, i;
const char *text;
if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) ) {
rc = ad->ad_type->sat_equality->smr_indexer(
+ LDAP_FILTER_EQUALITY,
mask,
ad->ad_type->sat_syntax,
ad->ad_type->sat_equality,
if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) ) {
rc = ad->ad_type->sat_approx->smr_indexer(
+ LDAP_FILTER_APPROX,
mask,
ad->ad_type->sat_syntax,
ad->ad_type->sat_approx,
if( IS_SLAP_INDEX( mask, SLAP_INDEX_SUBSTR ) ) {
rc = ad->ad_type->sat_substr->smr_indexer(
+ LDAP_FILTER_SUBSTRINGS,
mask,
ad->ad_type->sat_syntax,
ad->ad_type->sat_substr,
ID id,
int op,
char ** dbnamep,
- slap_index *maskp )
+ slap_mask_t *maskp )
{
- slap_index mask;
- slap_index tmpmask = 0;
+ slap_mask_t mask;
+ slap_mask_t tmpmask = 0;
int lindex = 0;
if( type->sat_sup ) {
int op )
{
char *dbname = NULL;
- slap_index mask;
+ slap_mask_t mask;
if( slap_ad_is_binary( desc ) ) {
/* binary attributes have no index capabilities */
void attr_mask LDAP_P(( struct ldbminfo *li,
const char *desc,
- slap_index *indexmask ));
+ slap_mask_t *indexmask ));
int attr_index_config LDAP_P(( struct ldbminfo *li,
const char *fname, int lineno,
AttributeDescription *desc,
int ftype,
char **dbname,
- slap_index *mask,
+ slap_mask_t *mask,
struct berval **prefix ));
extern int
return( prefix );
}
-int slap_str2index( const char *str, slap_index *idx )
+int slap_str2index( const char *str, slap_mask_t *idx )
{
if ( strcasecmp( str, "pres" ) == 0 ) {
*idx = SLAP_INDEX_PRESENT;
* index.c
*/
LDAP_SLAPD_F (int) slap_index2prefix LDAP_P(( int indextype ));
-LDAP_SLAPD_F (int) slap_str2index LDAP_P(( const char *str, slap_index *idx ));
+LDAP_SLAPD_F (int) slap_str2index LDAP_P(( const char *str, slap_mask_t *idx ));
/*
* connection.c
static int
octetStringMatch(
int *matchp,
- unsigned flags,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
/* Index generation function */
int octetStringIndexer(
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
/* Index generation function */
int octetStringFilter(
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
static int
dnMatch(
int *matchp,
- unsigned flags,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
static int
booleanMatch(
int *matchp,
- unsigned flags,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
static int
caseExactIA5Match(
int *matchp,
- unsigned flags,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
static int
caseExactIA5SubstringsMatch(
int *matchp,
- unsigned flags,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
/* Index generation function */
int caseExactIA5Indexer(
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
/* Index generation function */
int caseExactIA5Filter(
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
/* Substrings Index generation function */
int caseExactIA5SubstringsIndexer(
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
continue;
}
- if( flags & SLAP_MR_SUBSTR_INITIAL ) {
+ if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
}
}
- if( flags & SLAP_MR_SUBSTR_ANY ) {
+ if( flags & SLAP_INDEX_SUBSTR_ANY ) {
if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
}
}
- if( flags & SLAP_MR_SUBSTR_FINAL ) {
+ if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
value = values[i];
if( value->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
- if( ( flags & SLAP_MR_SUBSTR_ANY ) &&
+ if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
{
char pre = SLAP_INDEX_SUBSTR_PREFIX;
for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) {
char pre;
- if( flags & SLAP_MR_SUBSTR_INITIAL ) {
+ if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
keys[nkeys++] = ber_bvdup( &digest );
}
- if( flags & SLAP_MR_SUBSTR_FINAL ) {
+ if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
}
}
- keys[nkeys] = NULL;
- *keysp = keys;
+ if( nkeys > 0 ) {
+ keys[nkeys] = NULL;
+ *keysp = keys;
+ } else {
+ ch_free( keys );
+ *keysp = NULL;
+ }
+
return LDAP_SUCCESS;
}
int caseExactIA5SubstringsFilter(
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
struct berval *value;
struct berval digest;
- if( sa->sa_initial != NULL &&
+ if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL &&
sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
nkeys++;
}
- if( sa->sa_any ) {
+ if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) {
ber_len_t i;
for( i=0; sa->sa_any[i] != NULL; i++ ) {
if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
}
}
- if( sa->sa_final != NULL &&
+ if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final != NULL &&
sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
nkeys++;
keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) );
nkeys = 0;
- if( sa->sa_initial != NULL &&
+ if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial != NULL &&
sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
keys[nkeys++] = ber_bvdup( &digest );
}
- if( sa->sa_any ) {
+ if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) {
ber_len_t i, j;
pre = SLAP_INDEX_SUBSTR_PREFIX;
klen = SLAP_INDEX_SUBSTR_MAXLEN;
}
}
- if( sa->sa_final != NULL &&
+ if( flags & SLAP_INDEX_SUBSTR_FINAL && sa->sa_final != NULL &&
sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
keys[nkeys++] = ber_bvdup( &digest );
}
- keys[nkeys] = NULL;
+ if( nkeys > 0 ) {
+ keys[nkeys] = NULL;
+ *keysp = keys;
+ } else {
+ ch_free( keys );
+ *keysp = NULL;
+ }
- *keysp = keys;
return LDAP_SUCCESS;
}
static int
caseIgnoreIA5Match(
int *matchp,
- unsigned flags,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
static int
caseIgnoreIA5SubstringsMatch(
int *matchp,
- unsigned flags,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
/* Index generation function */
int caseIgnoreIA5Indexer(
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
/* Index generation function */
int caseIgnoreIA5Filter(
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
ber_bvfree( value );
*keysp = keys;
+
return LDAP_SUCCESS;
}
/* Substrings Index generation function */
int caseIgnoreIA5SubstringsIndexer(
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
continue;
}
- if( flags & SLAP_MR_SUBSTR_INITIAL ) {
+ if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
}
}
- if( flags & SLAP_MR_SUBSTR_ANY ) {
+ if( flags & SLAP_INDEX_SUBSTR_ANY ) {
if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += values[i]->bv_len - ( SLAP_INDEX_SUBSTR_MAXLEN - 1 );
}
}
- if( flags & SLAP_MR_SUBSTR_FINAL ) {
+ if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
if( values[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
nkeys += SLAP_INDEX_SUBSTR_MAXLEN -
( SLAP_INDEX_SUBSTR_MINLEN - 1);
value = ber_bvdup( values[i] );
ldap_pvt_str2upper( value->bv_val );
- if( ( flags & SLAP_MR_SUBSTR_ANY ) &&
+ if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
{
char pre = SLAP_INDEX_SUBSTR_PREFIX;
for( j=SLAP_INDEX_SUBSTR_MINLEN; j<=max; j++ ) {
char pre;
- if( flags & SLAP_MR_SUBSTR_INITIAL ) {
+ if( flags & SLAP_INDEX_SUBSTR_INITIAL ) {
pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
keys[nkeys++] = ber_bvdup( &digest );
}
- if( flags & SLAP_MR_SUBSTR_FINAL ) {
+ if( flags & SLAP_INDEX_SUBSTR_FINAL ) {
pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
lutil_MD5Init( &MD5context );
if( prefix != NULL && prefix->bv_len > 0 ) {
ber_bvfree( value );
}
- keys[nkeys] = NULL;
- *keysp = keys;
+ if( nkeys > 0 ) {
+ keys[nkeys] = NULL;
+ *keysp = keys;
+ } else {
+ ch_free( keys );
+ *keysp = NULL;
+ }
+
return LDAP_SUCCESS;
}
int caseIgnoreIA5SubstringsFilter(
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *prefix,
struct berval *value;
struct berval digest;
- if( sa->sa_initial != NULL &&
+ if((flags & SLAP_INDEX_SUBSTR_INITIAL) && sa->sa_initial != NULL &&
sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
nkeys++;
}
- if( sa->sa_any ) {
+ if((flags & SLAP_INDEX_SUBSTR_ANY) && sa->sa_any != NULL ) {
ber_len_t i;
for( i=0; sa->sa_any[i] != NULL; i++ ) {
if( sa->sa_any[i]->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) {
}
}
- if( sa->sa_final != NULL &&
+ if((flags & SLAP_INDEX_SUBSTR_FINAL) && sa->sa_final != NULL &&
sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
nkeys++;
keys = ch_malloc( sizeof( struct berval * ) * (nkeys+1) );
nkeys = 0;
- if( sa->sa_initial != NULL &&
+ if((flags & SLAP_INDEX_SUBSTR_INITIAL) && sa->sa_initial != NULL &&
sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
keys[nkeys++] = ber_bvdup( &digest );
}
- if( sa->sa_any ) {
+ if((flags & SLAP_INDEX_SUBSTR_ANY) && sa->sa_any != NULL ) {
ber_len_t i, j;
pre = SLAP_INDEX_SUBSTR_PREFIX;
klen = SLAP_INDEX_SUBSTR_MAXLEN;
}
}
- if( sa->sa_final != NULL &&
+ if((flags & SLAP_INDEX_SUBSTR_FINAL) && sa->sa_final != NULL &&
sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
keys[nkeys++] = ber_bvdup( &digest );
}
- keys[nkeys] = NULL;
+ if( nkeys > 0 ) {
+ keys[nkeys] = NULL;
+ *keysp = keys;
+ } else {
+ ch_free( keys );
+ *keysp = NULL;
+ }
- *keysp = keys;
return LDAP_SUCCESS;
}
static int
objectIdentifierFirstComponentMatch(
int *matchp,
- unsigned flags,
+ slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value,
#define SLAP_INDEX_LANG 0x4000UL /* use index with lang subtypes */
#define SLAP_INDEX_AUTO_LANG 0x8000UL /* use mask with lang subtypes */
-typedef long slap_index;
+typedef unsigned long slap_mask_t;
/*
* there is a single index for each attribute. these prefixes ensure
/* Normalizer */
typedef int slap_mr_normalize_func LDAP_P((
- unsigned use,
+ slap_mask_t use,
struct slap_syntax *syntax, /* NULL if in is asserted value */
struct slap_matching_rule *mr,
struct berval * in,
/* Match (compare) function */
typedef int slap_mr_match_func LDAP_P((
int *match,
- unsigned flags,
+ slap_mask_t use,
struct slap_syntax *syntax, /* syntax of stored value */
struct slap_matching_rule *mr,
struct berval * value,
/* Index generation function */
typedef int slap_mr_indexer_func LDAP_P((
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t mask,
struct slap_syntax *syntax, /* syntax of stored value */
struct slap_matching_rule *mr,
struct berval *prefix,
/* Filter index function */
typedef int slap_mr_filter_func LDAP_P((
- unsigned flags,
+ slap_mask_t use,
+ slap_mask_t mask,
struct slap_syntax *syntax, /* syntax of stored value */
struct slap_matching_rule *mr,
struct berval *prefix,
typedef struct slap_matching_rule {
LDAPMatchingRule smr_mrule;
- unsigned smr_usage;
+ slap_mask_t smr_usage;
#define SLAP_MR_TYPE_MASK 0xFF00U
#define SLAP_MR_SUBTYPE_MASK 0x00F0U