/* unimplemented matching routines */
#define caseIgnoreListMatch NULL
#define caseIgnoreListSubstringsMatch NULL
-#define presentationAddressMatch NULL
#define protocolInformationMatch NULL
#define integerFirstComponentMatch NULL
#define integerIndexer caseIgnoreIA5Indexer
#define integerFilter caseIgnoreIA5Filter
+#define telephoneNumberIndexer caseIgnoreIA5Indexer
+#define telephoneNumberFilter caseIgnoreIA5Filter
+#define telephoneNumberSubstringsIndexer caseIgnoreIA5SubstringsIndexer
+#define telephoneNumberSubstringsFilter caseIgnoreIA5SubstringsFilter
+
static char *strcasechr( const char *str, int c )
{
char *lower = strchr( str, TOLOWER(c) );
if( in->bv_len < 3 ) {
return LDAP_INVALID_SYNTAX;
}
+
if( in->bv_val[0] != 'B' ||
in->bv_val[1] != '\'' ||
in->bv_val[in->bv_len-1] != '\'' )
}
#if UTF8MATCH
-static int
-UTF8casecmp(
- struct berval *right,
- struct berval *left )
-{
- ber_len_t r, l;
- int rlen, llen;
- ldap_unicode_t ru, lu;
- ldap_unicode_t ruu, luu;
-
- for( r=0, l=0;
- r < right->bv_len && l < left->bv_len;
- r+=rlen, l+=llen )
- {
- /*
- * XXYYZ: we convert to ucs4 even though -llunicode
- * expects ucs2 in an unsigned long
- */
- ru = ldap_utf8_to_ucs4( &right->bv_val[r] );
- if( ru == LDAP_UCS4_INVALID ) {
- return 1;
- }
-
- lu = ldap_utf8_to_ucs4( &left->bv_val[l] );
- if( lu == LDAP_UCS4_INVALID ) {
- return -1;
- }
-
- ruu = uctoupper( ru );
- luu = uctoupper( lu );
-
- if( ruu > luu ) {
- return 1;
- } else if( luu > ruu ) {
- return -1;
- }
-
- rlen = LDAP_UTF8_CHARLEN( &right->bv_val[r] );
- llen = LDAP_UTF8_CHARLEN( &left->bv_val[l] );
- }
-
- if( r < right->bv_len ) {
- /* less left */
- return -1;
- }
-
- if( l < left->bv_len ) {
- /* less right */
- return 1;
- }
-
- return 0;
-}
-
/* case insensitive UTF8 strncmp with offset for second string */
static int
UTF8oncasecmp(
ber_len_t offset )
{
ber_len_t r, l;
- int rlen, llen;
- int rslen, lslen;
+ ber_len_t rlen, llen;
+ ber_len_t rslen, lslen;
ldap_unicode_t ru, lu;
ldap_unicode_t ruu, luu;
mlen = strlen( mr->smr_oid );
for( i=0; values[i] != NULL; i++ ) {
- struct berval *value = values[i];
+ struct berval *value;
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( values[i]->bv_val, UTF8_NOCASEFOLD ) );
+#else
+ value = values[i];
+#endif
HASH_Init( &HASHcontext );
if( prefix != NULL && prefix->bv_len > 0 ) {
value->bv_val, value->bv_len );
HASH_Final( HASHdigest, &HASHcontext );
+#if UTF8MATCH
+ ber_bvfree( value );
+#endif
+
keys[i] = ber_bvdup( &digest );
}
slen = strlen( syntax->ssyn_oid );
mlen = strlen( mr->smr_oid );
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( ((struct berval *) assertValue)->bv_val, UTF8_NOCASEFOLD ) );
+#else
value = (struct berval *) assertValue;
+#endif
keys = ch_malloc( sizeof( struct berval * ) * 2 );
keys[0] = ber_bvdup( &digest );
keys[1] = NULL;
+#if UTF8MATCH
+ ber_bvfree( value );
+#endif
+
*keysp = keys;
return LDAP_SUCCESS;
}
ber_len_t j,max;
struct berval *value;
+ if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
+
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( values[i]->bv_val, UTF8_NOCASEFOLD ) );
+#else
value = values[i];
- if( value->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
+#endif
if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
}
}
+
+#if UTF8MATCH
+ ber_bvfree( value );
+#endif
+
}
if( nkeys > 0 ) {
sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( sa->sa_initial->bv_val, UTF8_NOCASEFOLD ) );
+#else
value = sa->sa_initial;
+#endif
klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
value->bv_val, klen );
HASH_Final( HASHdigest, &HASHcontext );
+#if UTF8MATCH
+ ber_bvfree( value );
+#endif
keys[nkeys++] = ber_bvdup( &digest );
}
continue;
}
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( sa->sa_any[i]->bv_val, UTF8_NOCASEFOLD ) );
+#else
value = sa->sa_any[i];
+#endif
for(j=0;
j <= value->bv_len - SLAP_INDEX_SUBSTR_MAXLEN;
keys[nkeys++] = ber_bvdup( &digest );
}
+
+#if UTF8MATCH
+ ber_bvfree( value );
+#endif
}
}
sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( sa->sa_final->bv_val, UTF8_NOCASEFOLD ) );
+#else
value = sa->sa_final;
+#endif
klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
&value->bv_val[value->bv_len-klen], klen );
HASH_Final( HASHdigest, &HASHcontext );
+#if UTF8MATCH
+ ber_bvfree( value );
+#endif
keys[nkeys++] = ber_bvdup( &digest );
}
void *assertedValue )
{
#if UTF8MATCH
- *matchp = UTF8casecmp( value, (struct berval *) assertedValue );
+ *matchp = UTF8normcmp( value->bv_val,
+ ((struct berval *) assertedValue)->bv_val,
+ UTF8_CASEFOLD );
#else
int match = value->bv_len - ((struct berval *) assertedValue)->bv_len;
mlen = strlen( mr->smr_oid );
for( i=0; values[i] != NULL; i++ ) {
- struct berval *value = ber_bvdup( values[i] );
+ struct berval *value;
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( values[i]->bv_val, UTF8_CASEFOLD ) );
+#else
+ value = ber_bvdup( values[i] );
ldap_pvt_str2upper( value->bv_val );
-
+#endif
HASH_Init( &HASHcontext );
if( prefix != NULL && prefix->bv_len > 0 ) {
HASH_Update( &HASHcontext,
slen = strlen( syntax->ssyn_oid );
mlen = strlen( mr->smr_oid );
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( ((struct berval *) assertValue)->bv_val, UTF8_CASEFOLD ) );
+#else
value = ber_bvdup( (struct berval *) assertValue );
ldap_pvt_str2upper( value->bv_val );
+#endif
keys = ch_malloc( sizeof( struct berval * ) * 2 );
if( values[i]->bv_len < SLAP_INDEX_SUBSTR_MINLEN ) continue;
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( values[i]->bv_val, UTF8_CASEFOLD ) );
+#else
value = ber_bvdup( values[i] );
ldap_pvt_str2upper( value->bv_val );
+#endif
if( ( flags & SLAP_INDEX_SUBSTR_ANY ) &&
( value->bv_len >= SLAP_INDEX_SUBSTR_MAXLEN ) )
sa->sa_initial->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
pre = SLAP_INDEX_SUBSTR_INITIAL_PREFIX;
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( sa->sa_initial->bv_val, UTF8_CASEFOLD ) );
+#else
value = ber_bvdup( sa->sa_initial );
ldap_pvt_str2upper( value->bv_val );
+#endif
klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
continue;
}
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( sa->sa_any[i]->bv_val, UTF8_CASEFOLD ) );
+#else
value = ber_bvdup( sa->sa_any[i] );
ldap_pvt_str2upper( value->bv_val );
+#endif
for(j=0;
j <= value->bv_len - SLAP_INDEX_SUBSTR_MAXLEN;
sa->sa_final->bv_len >= SLAP_INDEX_SUBSTR_MINLEN )
{
pre = SLAP_INDEX_SUBSTR_FINAL_PREFIX;
+#if UTF8MATCH
+ value = ber_bvstr( UTF8normalize( sa->sa_final->bv_val, UTF8_CASEFOLD ) );
+#else
value = ber_bvdup( sa->sa_final );
ldap_pvt_str2upper( value->bv_val );
+#endif
klen = SLAP_INDEX_SUBSTR_MAXLEN < value->bv_len
? SLAP_INDEX_SUBSTR_MAXLEN : value->bv_len;
Syntax *syntax,
struct berval *val )
{
- ber_len_t i;
-
if( val->bv_len != 2 ) return LDAP_INVALID_SYNTAX;
if( !SLAP_PRINTABLE(val->bv_val[0]) ) {
{
ber_len_t i;
- /* disallow empty numeric strings */
-
for(i=0; i < in->bv_len; i++) {
if( !SLAP_NUMERIC(in->bv_val[i]) ) {
return LDAP_INVALID_SYNTAX;
}
}
- assert( newval->bv_val < p );
+ assert( newval->bv_val <= p );
assert( q <= p );
/* null terminate */
/* OpenLDAP Experimental Syntaxes */
{"( 1.3.6.1.4.1.4203.666.2.1 DESC 'OpenLDAP Experimental ACI' )",
- 0, IA5StringValidate /* THIS WILL CHANGE FOR NEW ACI SYNTAX */,
+ 0, UTF8StringValidate /* THIS WILL CHANGE FOR NEW ACI SYNTAX */,
NULL, NULL},
{"( 1.3.6.1.4.1.4203.666.2.2 DESC 'OpenLDAP authPassword' )",
0, NULL, NULL, NULL},
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT,
NULL, NULL,
- telephoneNumberMatch, NULL, NULL,
+ telephoneNumberMatch,
+ telephoneNumberIndexer,
+ telephoneNumberFilter,
NULL},
{"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
SLAP_MR_SUBSTR | SLAP_MR_EXT,
NULL, NULL,
- telephoneNumberSubstringsMatch, NULL, NULL,
+ telephoneNumberSubstringsMatch,
+ telephoneNumberSubstringsIndexer,
+ telephoneNumberSubstringsFilter,
NULL},
{"( 2.5.13.22 NAME 'presentationAddressMatch' "
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
SLAP_MR_EQUALITY | SLAP_MR_EXT,
NULL, NULL,
- presentationAddressMatch, NULL, NULL,
+ NULL, NULL, NULL,
NULL},
{"( 2.5.13.23 NAME 'uniqueMemberMatch' "