From 32399d9bd98226063ee311134c3f5ad0b3b46a5c Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Thu, 27 Feb 2003 03:29:07 +0000 Subject: [PATCH] axe mr_ptr in favor or schema_prep --- servers/slapd/schema_init.c | 34 +++++++--------------------------- servers/slapd/schema_prep.c | 7 +++++++ servers/slapd/slap.h | 3 +++ 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 1822e719e5..37d291ba88 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -87,21 +87,6 @@ #define telephoneNumberSubstringsIndexer caseIgnoreIA5SubstringsIndexer #define telephoneNumberSubstringsFilter caseIgnoreIA5SubstringsFilter -static MatchingRule *caseExactMatchingRule; -static MatchingRule *caseExactSubstringsMatchingRule; -static MatchingRule *integerFirstComponentMatchingRule; - -static const struct MatchingRulePtr { - const char *oid; - MatchingRule **mr; -} mr_ptr [] = { - /* must match OIDs below */ - { "2.5.13.5", &caseExactMatchingRule }, - { "2.5.13.7", &caseExactSubstringsMatchingRule }, - { "2.5.13.29", &integerFirstComponentMatchingRule } -}; - - static char *bvcasechr( struct berval *bv, unsigned char c, ber_len_t *len ) { ber_len_t i; @@ -1102,7 +1087,7 @@ caseExactIgnoreSubstringsMatch( char *nav = NULL; unsigned casefold; - casefold = ( mr != caseExactSubstringsMatchingRule ) + casefold = ( mr != slap_schema.si_mr_caseExactSubstringsMatch ) ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD; if ( UTF8bvnormalize( value, &left, casefold ) == NULL ) { @@ -1272,7 +1257,7 @@ static int caseExactIgnoreIndexer( slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; - casefold = ( mr != caseExactMatchingRule ) + casefold = ( mr != slap_schema.si_mr_caseExactMatch ) ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD; for( i=0; values[i].bv_val != NULL; i++ ) { @@ -1349,7 +1334,7 @@ static int caseExactIgnoreFilter( slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; - casefold = ( mr != caseExactMatchingRule ) + casefold = ( mr != slap_schema.si_mr_caseExactMatch ) ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD; UTF8bvnormalize( (struct berval *) assertedValue, &value, casefold ); @@ -1415,7 +1400,7 @@ static int caseExactIgnoreSubstringsIndexer( /* we should have at least one value at this point */ assert( i > 0 ); - casefold = ( mr != caseExactSubstringsMatchingRule ) + casefold = ( mr != slap_schema.si_mr_caseExactSubstringsMatch ) ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD; tvalues = ch_malloc( sizeof( struct berval ) * (i+1) ); @@ -1616,7 +1601,7 @@ static int caseExactIgnoreSubstringsFilter( struct berval *value; struct berval digest; - casefold = ( mr != caseExactSubstringsMatchingRule ) + casefold = ( mr != slap_schema.si_mr_caseExactSubstringsMatch ) ? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD; sa = UTF8SubstringsassertionNormalize( assertedValue, casefold ); @@ -1875,7 +1860,7 @@ integerMatch( /* Skip leading space/sign/zeroes, and get the sign of the *value number */ v = value->bv_val; vlen = value->bv_len; - if( mr == integerFirstComponentMatchingRule ) { + if( mr == slap_schema.si_mr_integerFirstComponentMatch ) { char *tmp = memchr( v, '$', vlen ); if( tmp ) vlen = tmp - v; @@ -4847,7 +4832,7 @@ slap_schema_init( void ) mrule_defs[i].mrd_compat_syntaxes == NULL ) { fprintf( stderr, - "slap_schema_init: Ingoring unusable matching rule %s\n", + "slap_schema_init: Ignoring unusable matching rule %s\n", mrule_defs[i].mrd_desc ); continue; } @@ -4862,9 +4847,6 @@ slap_schema_init( void ) } } - for ( i=0; i < (int)(sizeof(mr_ptr)/sizeof(mr_ptr[0])); i++ ) - *mr_ptr[i].mr = mr_find( mr_ptr[i].oid ); - res = slap_schema_load(); schema_init_done = 1; return res; @@ -4877,8 +4859,6 @@ schema_destroy( void ) oidm_destroy(); oc_destroy(); at_destroy(); - for ( i=0; i < (int)(sizeof(mr_ptr)/sizeof(mr_ptr[0])); i++ ) - *mr_ptr[i].mr = NULL; mr_destroy(); mru_destroy(); syn_destroy(); diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 4d13356fb0..abb2b2217a 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -796,10 +796,17 @@ static struct slap_schema_mr_map { char *ssmm_name; size_t ssmm_offset; } mr_map[] = { + { "caseExactMatch", + offsetof(struct slap_internal_schema, si_mr_caseExactMatch) }, + { "caseExactSubstringsMatch", + offsetof(struct slap_internal_schema, si_mr_caseExactSubstringsMatch) }, { "distinguishedNameMatch", offsetof(struct slap_internal_schema, si_mr_distinguishedNameMatch) }, { "integerMatch", offsetof(struct slap_internal_schema, si_mr_integerMatch) }, + { "integerFirstComponentMatch", + offsetof(struct slap_internal_schema, + si_mr_integerFirstComponentMatch) }, { NULL, 0 } }; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 9dea20e0aa..8d033a96a2 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -790,7 +790,10 @@ struct slap_internal_schema { /* Matching Rules */ MatchingRule *si_mr_distinguishedNameMatch; + MatchingRule *si_mr_caseExactMatch; + MatchingRule *si_mr_caseExactSubstringsMatch; MatchingRule *si_mr_integerMatch; + MatchingRule *si_mr_integerFirstComponentMatch; /* Syntaxes */ Syntax *si_syn_octetString; -- 2.39.5