From fa9f7a7d8e1ce3fab417bab23fb9806efa4a45b2 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 17 May 2000 20:29:26 +0000 Subject: [PATCH] SLAPD_SCHEMA_NOT_COMPAT: add framework for substr value normalization Calls value_normalize per substr component (like old code), likely should have/call substr_normalize which takes all components at once (to allow more sophisticated normalization) --- servers/slapd/filter.c | 40 ++++++++++++++++++++++++++++++++++++++-- servers/slapd/slap.h | 21 +++++++++++++++------ 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index fac3aee18d..7157aa3d98 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -429,6 +429,8 @@ get_substring_filter( for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; tag = ber_next_element( ber, &len, last ) ) { + unsigned usage; + rc = ber_scanf( ber, "O", &val ); if ( rc == LBER_ERROR ) { rc = SLAPD_DISCONNECT; @@ -441,15 +443,47 @@ get_substring_filter( goto return_error; } - rc = LDAP_PROTOCOL_ERROR; +#ifdef SLAPD_SCHEMA_NOT_COMPAT + switch ( tag ) { + case LDAP_SUBSTRING_INITIAL: + usage = SLAP_MR_SUBSTR_INITIAL; + break; + + case LDAP_SUBSTRING_ANY: + usage = SLAP_MR_SUBSTR_ANY; + break; + + case LDAP_SUBSTRING_FINAL: + usage = SLAP_MR_SUBSTR_FINAL; + break; + + default: + rc = LDAP_PROTOCOL_ERROR; + + Debug( LDAP_DEBUG_FILTER, + " unknown substring choice=%ld\n", + (long) tag, 0, 0 ); + + ber_bvfree( val ); + goto return_error; + } + + rc = value_normalize( f->f_sub_desc, usage, val, text ); + + if( rc != LDAP_SUCCESS ) { + ber_bvfree( val ); + goto return_error; + } +#else -#ifndef SLAPD_SCHEMA_NOT_COMPAT /* we should call a substring syntax normalization routine */ value_normalize( val->bv_val, syntax ); /* this is bogus, value_normalize should take a berval */ val->bv_len = strlen( val->bv_val ); #endif + rc = LDAP_PROTOCOL_ERROR; + switch ( tag ) { case LDAP_SUBSTRING_INITIAL: Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); @@ -457,6 +491,8 @@ get_substring_filter( ber_bvfree( val ); goto return_error; } + + f->f_sub_initial = val; if( fstr ) { diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 6c0637a213..69b541c537 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -205,12 +205,21 @@ typedef int slap_mr_filter_func LDAP_P(( typedef struct slap_matching_rule { LDAP_MATCHING_RULE smr_mrule; unsigned smr_usage; -#define SLAP_MR_NONE 0x00U -#define SLAP_MR_EQUALITY 0x01U -#define SLAP_MR_APPROX 0x02U -#define SLAP_MR_ORDERING 0x04U -#define SLAP_MR_SUBSTR 0x08U -#define SLAP_MR_EXT 0x10U + +#define SLAP_MR_TYPE_MASK 0xFF00U +#define SLAP_MR_SUBTYPE_MASK 0x00FFU + +#define SLAP_MR_NONE 0x0000U +#define SLAP_MR_EQUALITY 0x0100U +#define SLAP_MR_APPROX 0x0200U +#define SLAP_MR_ORDERING 0x0400U +#define SLAP_MR_SUBSTR 0x0800U +#define SLAP_MR_EXT 0x1000U + +#define SLAP_MR_SUBSTR_INITIAL (SLAP_MR_SUBSTR | 0x0001U ) +#define SLAP_MR_SUBSTR_ANY (SLAP_MR_SUBSTR | 0x0002U ) +#define SLAP_MR_SUBSTR_FINAL (SLAP_MR_SUBSTR | 0x0004U ) + Syntax *smr_syntax; slap_mr_convert_func *smr_convert; slap_mr_normalize_func *smr_normalize; -- 2.39.5