#define HASH_Update(c,buf,len) lutil_HASHUpdate(c,buf,len)
#define HASH_Final(d,c) lutil_HASHFinal(d,c)
+#define SLAP_NVALUES 1
+
#ifdef SLAP_NVALUES
/* TO BE DELETED */
#define SLAP_MR_DN_FOLD (0)
#define xintegerNormalize NULL
#define xnumericStringNormalize NULL
#define xnameUIDNormalize NULL
+#define xdnNormalize NULL
/* (new) normalization routines */
#define caseExactIA5Normalize IA5StringNormalize
#define caseExactNormalize UTF8StringNormalize
#define caseIgnoreNormalize UTF8StringNormalize
-#define distinguishedNameNormalize NULL
-#define integerNormalize NULL
#define integerFirstComponentNormalize NULL
-#define numericStringNormalize NULL
#define objectIdentifierNormalize NULL
#define objectIdentifierFirstComponentNormalize NULL
-#define generalizedTimeNormalize NULL
-#define uniqueMemberNormalize NULL
-#define bitStringNormalize NULL
-#define telephoneNumberNormalize NULL
+#define distinguishedNameNormalize dnNormalize
#define distinguishedNameMatch dnMatch
#define distinguishedNameIndexer octetStringIndexer
#define distinguishedNameFilter octetStringFilter
-#define uniqueMemberMatch dnMatch
+#define integerOrderingMatch integerMatch
+#define integerFirstComponentMatch NULL
+#define integerIndexer octetStringIndexer
+#define integerFilter octetStringFilter
+
+#define generalizedTimeMatch caseIgnoreIA5Match
+#define generalizedTimeOrderingMatch caseIgnoreIA5Match
+
+#define uniqueMemberMatch dnMatch /* FIXME! */
#define objectIdentifierMatch octetStringMatch
#define objectIdentifierIndexer octetStringIndexer
#define bitStringIndexer octetStringIndexer
#define bitStringFilter octetStringFilter
-#define integerMatch NULL
-#define integerOrderingMatch NULL
-#define integerIndexer NULL
-#define integerFilter NULL
-
-#define generalizedTimeMatch NULL
-#define generalizedTimeOrderingMatch NULL
-
#define caseIgnoreMatch octetStringMatch
#define caseIgnoreOrderingMatch octetStringOrderingMatch
#define caseIgnoreIndexer octetStringIndexer
#define caseIgnoreFilter octetStringFilter
-#define caseIgnoreSubstringsMatch NULL
-#define caseIgnoreSubstringsIndexer NULL
-#define caseIgnoreSubstringsFilter NULL
+#define caseIgnoreSubstringsMatch octetStringSubstringsMatch
+#define caseIgnoreSubstringsIndexer octetStringSubstringsIndexer
+#define caseIgnoreSubstringsFilter octetStringSubstringsFilter
#define caseExactMatch octetStringMatch
#define caseExactOrderingMatch octetStringOrderingMatch
#define caseExactIndexer octetStringIndexer
#define caseExactFilter octetStringFilter
-#define caseExactSubstringsMatch NULL
-#define caseExactSubstringsIndexer NULL
-#define caseExactSubstringsFilter NULL
+#define caseExactSubstringsMatch octetStringSubstringsMatch
+#define caseExactSubstringsIndexer octetStringSubstringsIndexer
+#define caseExactSubstringsFilter octetStringSubstringsFilter
#define caseExactIA5Match octetStringMatch
#define caseExactIA5Indexer octetStringIndexer
#define caseExactIA5Filter octetStringFilter
-#define caseExactIA5SubstringsMatch NULL
-#define caseExactIA5SubstringsIndexer NULL
-#define caseExactIA5SubstringsFilter NULL
+#define caseExactIA5SubstringsMatch octetStringSubstringsMatch
+#define caseExactIA5SubstringsIndexer octetStringSubstringsIndexer
+#define caseExactIA5SubstringsFilter octetStringSubstringsFilter
#define caseIgnoreIA5Match octetStringMatch
#define caseIgnoreIA5Indexer octetStringIndexer
#define telephoneNumberSubstringsIndexer caseExactIA5SubstringsIndexer
#define telephoneNumberSubstringsFilter caseExactIA5SubstringsFilter
+#define booleanIndexer octetStringIndexer
+#define booleanFilter octetStringFilter
#endif
/* validatation routines */
#ifndef SLAP_NVALUES
+#define xdnNormalize dnNormalize
+
/* (new) normalization routines */
#define caseExactNormalize NULL
#define caseExactIA5Normalize NULL
#define objectIdentifierFirstComponentNormalize NULL
#define generalizedTimeNormalize NULL
#define uniqueMemberNormalize NULL
-#define bitStringNormalize NULL
#define telephoneNumberNormalize NULL
#define objectIdentifierIndexer caseIgnoreIA5Indexer
#define objectIdentifierFilter caseIgnoreIA5Filter
-#define OpenLDAPaciMatch NULL
+#define octetStringSubstringsMatch NULL
+#define OpenLDAPaciMatch NULL
#define generalizedTimeMatch caseIgnoreIA5Match
#define generalizedTimeOrderingMatch caseIgnoreIA5Match
#define telephoneNumberFilter caseIgnoreIA5Filter
#define telephoneNumberSubstringsIndexer caseIgnoreIA5SubstringsIndexer
#define telephoneNumberSubstringsFilter caseIgnoreIA5SubstringsFilter
+
+#define booleanIndexer octetStringIndexer
+#define booleanFilter octetStringFilter
#endif
return rc;
}
-#ifndef SLAP_NVALUES
-
+#ifdef SLAP_NVALUES
+static int
+uniqueMemberNormalize(
+ slap_mask_t usage,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *val,
+ struct berval *normalized )
+#else
static int
xnameUIDNormalize(
Syntax *syntax,
struct berval *val,
struct berval *normalized )
+#endif
{
struct berval out;
int rc;
return LDAP_SUCCESS;
}
-#endif
/*
* Handling boolean syntax and matching is quite rigid.
* A more flexible approach would be to allow a variety
}
flags = SLAP_MR_ASSOCIATED(mr, slap_schema.si_mr_caseExactMatch )
- ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
- flags |= ( use & SLAP_MR_EQUALITY_APPROX == SLAP_MR_EQUALITY_APPROX )
+ ? LDAP_UTF8_NOCASEFOLD : LDAP_UTF8_CASEFOLD;
+ flags |= ( ( use & SLAP_MR_EQUALITY_APPROX ) == SLAP_MR_EQUALITY_APPROX )
? LDAP_UTF8_APPROX : 0;
val = UTF8bvnormalize( val, &tmp, flags );
nvalue.bv_len = 1;
}
+ *normalized = nvalue;
return LDAP_SUCCESS;
}
#else
*keysp = keys;
return LDAP_SUCCESS;
}
+#endif
/* Substrings Index generation function */
-static int caseExactIgnoreSubstringsIndexer(
- slap_mask_t use,
+static int
+#ifdef SLAP_NVALUES
+octetStringSubstringsIndexer
+#else
+caseExactIgnoreSubstringsIndexer
+#endif
+ ( slap_mask_t use,
slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
BerVarray values,
BerVarray *keysp )
{
- unsigned casefold, wasspace;
ber_len_t i, j, nkeys;
size_t slen, mlen;
BerVarray keys;
+#ifndef SLAP_NVALUES
BerVarray tvalues, nvalues;
+ unsigned casefold, wasspace;
+#endif
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
digest.bv_val = HASHdigest;
digest.bv_len = sizeof(HASHdigest);
- nkeys=0;
-
+#ifndef SLAP_NVALUES
for( i=0; values[i].bv_val != NULL; i++ ) {
/* empty - just count them */
}
tvalues[i].bv_val = NULL;
nvalues[i].bv_val = NULL;
values = nvalues;
+#endif
+
+ nkeys=0;
for( i=0; values[i].bv_val != NULL; i++ ) {
/* count number of indices to generate */
if( nkeys == 0 ) {
/* no keys to generate */
*keysp = NULL;
+#ifndef SLAP_NVALUES
ber_bvarray_free( tvalues );
ch_free( nvalues );
+#endif
return LDAP_SUCCESS;
}
*keysp = NULL;
}
+#ifndef SLAP_NVALUES
ber_bvarray_free( tvalues );
ch_free( nvalues );
+#endif
return LDAP_SUCCESS;
}
-static int caseExactIgnoreSubstringsFilter(
- slap_mask_t use,
+static int
+#ifdef SLAP_NVALUES
+octetStringSubstringsFilter
+#else
+caseExactIgnoreSubstringsFilter
+#endif
+ ( slap_mask_t use,
slap_mask_t flags,
Syntax *syntax,
MatchingRule *mr,
struct berval *value;
struct berval digest;
+#ifndef SLAP_NVALUES
casefold = ( mr != slap_schema.si_mr_caseExactSubstringsMatch )
? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
*keysp = NULL;
return LDAP_SUCCESS;
}
+#else
+ sa = (SubstringsAssertion *) assertedValue;
+#endif
if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial.bv_val != NULL &&
sa->sa_initial.bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
}
if( nkeys == 0 ) {
+#ifndef SLAP_NVALUES
if ( sa->sa_final.bv_val ) free( sa->sa_final.bv_val );
if ( sa->sa_any ) ber_bvarray_free( sa->sa_any );
if ( sa->sa_initial.bv_val ) free( sa->sa_initial.bv_val );
ch_free( sa );
+#endif
*keysp = NULL;
return LDAP_SUCCESS;
}
ch_free( keys );
*keysp = NULL;
}
+
+#ifndef SLAP_NVALUES
if ( sa->sa_final.bv_val ) free( sa->sa_final.bv_val );
if ( sa->sa_any ) ber_bvarray_free( sa->sa_any );
if ( sa->sa_initial.bv_val ) free( sa->sa_initial.bv_val );
ch_free( sa );
+#endif
return LDAP_SUCCESS;
}
+#ifndef SLAP_NVALUES
static int
caseIgnoreMatch(
LDAP_UTF8_CASEFOLD );
return LDAP_SUCCESS;
}
+#endif
/* Remove all spaces and '-' characters */
static int
+#ifdef SLAP_NVALUES
+telephoneNumberNormalize(
+ slap_mask_t usage,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *val,
+ struct berval *normalized )
+#else
xtelephoneNumberNormalize(
Syntax *syntax,
struct berval *val,
struct berval *normalized )
+#endif
{
char *p, *q;
return LDAP_SUCCESS;
}
-#endif
static int
oidValidate(
return LDAP_INVALID_SYNTAX;
}
-#ifndef SLAP_NVALUES
-
static int
integerMatch(
int *matchp,
/* Skip leading space/sign/zeroes, and get the sign of the *value number */
v = value->bv_val;
vlen = value->bv_len;
+
+#ifndef SLAP_NVALUES
if( mr == slap_schema.si_mr_integerFirstComponentMatch ) {
char *tmp = memchr( v, '$', vlen );
- if( tmp )
- vlen = tmp - v;
- while( vlen && ASCII_SPACE( v[vlen-1] ))
- vlen--;
+ if( tmp ) vlen = tmp - v;
+ while( vlen && ASCII_SPACE( v[vlen-1] )) vlen--;
}
- for( ; vlen && ( *v < '1' || '9' < *v ); v++, vlen-- ) /* ANSI 2.2.1 */
- if( *v == '-' )
- vsign = -1;
- if( vlen == 0 )
- vsign = 0;
+#endif
+
+ for( ; vlen && ( *v < '1' || '9' < *v ); v++, vlen-- ) { /* ANSI 2.2.1 */
+ if( *v == '-' ) vsign = -1;
+ }
+
+ if( vlen == 0 ) vsign = 0;
/* Do the same with the *assertedValue number */
asserted = (struct berval *) assertedValue;
return LDAP_SUCCESS;
}
-#endif
static int
integerValidate(
Syntax *syntax,
if(( val->bv_val[0] == '+' ) || ( val->bv_val[0] == '-' )) {
if( val->bv_len < 2 ) return LDAP_INVALID_SYNTAX;
+
} else if( !ASCII_DIGIT(val->bv_val[0]) ) {
return LDAP_INVALID_SYNTAX;
}
return LDAP_SUCCESS;
}
-#ifndef SLAP_NVALUES
static int
+#ifdef SLAP_NVALUES
+integerNormalize(
+ slap_mask_t use,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *val,
+ struct berval *normalized )
+#else
xintegerNormalize(
Syntax *syntax,
struct berval *val,
struct berval *normalized )
+#endif
{
char *p;
int negative=0;
if( len == 0 ) {
normalized->bv_val = ch_strdup("0");
normalized->bv_len = 1;
- }
- else {
+
+ } else {
normalized->bv_len = len+negative;
normalized->bv_val = ch_malloc( normalized->bv_len + 1 );
- if( negative ) {
- normalized->bv_val[0] = '-';
- }
+ if( negative ) normalized->bv_val[0] = '-';
AC_MEMCPY( normalized->bv_val + negative, p, len );
normalized->bv_val[len+negative] = '\0';
}
return LDAP_SUCCESS;
}
+#ifndef SLAP_NVALUES
+
/* Index generation function */
static int integerIndexer(
slap_mask_t use,
return LDAP_SUCCESS;
}
-#ifdef SLAP_NVALUES
static int
+#ifdef SLAP_NVALUES
IA5StringNormalize(
slap_mask_t use,
Syntax *syntax,
struct berval *val,
struct berval *normalized )
#else
-static int
xIA5StringNormalize(
Syntax *syntax,
struct berval *val,
}
static int
-caseExactIA5SubstringsMatch(
+caseExactIA5SubstringsMatch
+#else
+static int
+octetStringSubstringsMatch
+#endif
+(
int *matchp,
slap_mask_t flags,
Syntax *syntax,
goto done;
}
- match = strncmp( sub->sa_initial.bv_val, left.bv_val,
+ match = memcmp( sub->sa_initial.bv_val, left.bv_val,
sub->sa_initial.bv_len );
if( match != 0 ) {
goto done;
}
- match = strncmp( sub->sa_final.bv_val,
+ match = memcmp( sub->sa_final.bv_val,
&left.bv_val[left.bv_len - sub->sa_final.bv_len],
sub->sa_final.bv_len );
continue;
}
- p = strchr( left.bv_val, *sub->sa_any[i].bv_val );
+ p = memchr( left.bv_val, *sub->sa_any[i].bv_val, left.bv_len );
if( p == NULL ) {
match = 1;
goto done;
}
- match = strncmp( left.bv_val,
+ match = memcmp( left.bv_val,
sub->sa_any[i].bv_val,
sub->sa_any[i].bv_len );
return LDAP_SUCCESS;
}
+#ifndef SLAP_NVALUES
+
/* Index generation function */
static int caseExactIA5Indexer(
slap_mask_t use,
return LDAP_SUCCESS;
}
-#ifndef SLAP_NVALUES
-
static int
+#ifdef SLAP_NVALUES
+numericStringNormalize(
+ slap_mask_t usage,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *val,
+ struct berval *normalized )
+#else
xnumericStringNormalize(
Syntax *syntax,
struct berval *val,
struct berval *normalized )
+#endif
{
/* removal all spaces */
char *p, *q;
return LDAP_SUCCESS;
}
+#ifndef SLAP_NVALUES
static int
objectIdentifierFirstComponentMatch(
int *matchp,
return check_time_syntax(in, 0, parts);
}
-#ifndef SLAP_NVALUES
-
static int
+#ifdef SLAP_NVALUES
+generalizedTimeNormalize(
+ slap_mask_t usage,
+ Syntax *syntax,
+ MatchingRule *mr,
+ struct berval *val,
+ struct berval *normalized )
+#else
xgeneralizedTimeNormalize(
Syntax *syntax,
struct berval *val,
struct berval *normalized )
+#endif
{
int parts[9], rc;
return LDAP_SUCCESS;
}
-#endif
static int
nisNetgroupTripleValidate(
Syntax *syntax,
{"( 1.3.6.1.4.1.1466.115.121.1.11 DESC 'Country String' )",
0, countryStringValidate, xIA5StringNormalize, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.12 DESC 'Distinguished Name' )",
- 0, dnValidate, dnNormalize2, dnPretty2},
+ 0, dnValidate, xdnNormalize, dnPretty2},
{"( 1.3.6.1.4.1.1466.115.121.1.13 DESC 'Data Quality' )",
0, NULL, NULL, NULL},
{"( 1.3.6.1.4.1.1466.115.121.1.14 DESC 'Delivery Method' )",
* Other matching rules in X.520 that we do not use (yet):
*
* 2.5.13.9 numericStringOrderingMatch
- * 2.5.13.19 octetStringSubstringsMatch
* 2.5.13.25 uTCTimeMatch
* 2.5.13.26 uTCTimeOrderingMatch
* 2.5.13.31 directoryStringFirstComponentMatch
{"( 2.5.13.13 NAME 'booleanMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
- NULL, NULL, booleanMatch, NULL, NULL, NULL},
+ NULL,
+ NULL, booleanMatch,
+ booleanIndexer, booleanFilter,
+ NULL},
{"( 2.5.13.14 NAME 'integerMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT, NULL,
NULL,
- bitStringNormalize, bitStringMatch,
+ NULL, bitStringMatch,
bitStringIndexer, bitStringFilter,
NULL},
octetStringOrderingMatch, NULL, NULL,
NULL},
+ {"( 2.5.13.19 NAME 'octetStringSubstringsMatch' "
+ "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
+ SLAP_MR_SUBSTR, NULL,
+ NULL, NULL,
+ octetStringSubstringsMatch, NULL, NULL,
+ NULL},
+
{"( 2.5.13.20 NAME 'telephoneNumberMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT | SLAP_MR_DN_FOLD, NULL,