Commit 1f22c52b authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

SLAP_SCHEMA_NOT_COMPAT: add calls to dummy value_normalize()

SLAP_SCHEMA_NOT_COMPAT: Need to sort out normalization of substring components
parent 75b51d52
......@@ -33,6 +33,7 @@ int
get_ava(
BerElement *ber,
AttributeAssertion **ava,
unsigned usage,
char **text
)
{
......@@ -60,6 +61,16 @@ get_ava(
return rc;
}
rc = value_normalize( aa->aa_desc, usage, value, text );
if( rc != LDAP_SUCCESS ) {
ch_free( type.bv_val );
ber_bvfree( value );
ad_free( aa->aa_desc, 1 );
ch_free( aa );
return rc;
}
aa->aa_value = value;
*ava = aa;
......
......@@ -105,6 +105,15 @@ do_compare(
text, NULL, NULL );
goto cleanup;
}
rc = value_normalize( ava.aa_desc, SLAP_MR_EQUALITY, &value, &text );
if( rc != LDAP_SUCCESS ) {
send_ldap_result( conn, op, rc, NULL,
text, NULL, NULL );
goto cleanup;
}
ava.aa_value = &value;
Debug( LDAP_DEBUG_ARGS, "do_compare: dn (%s) attr (%s) value (%s)\n",
......
......@@ -94,11 +94,15 @@ get_filter(
case LDAP_FILTER_EQUALITY:
Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 );
if ( (err = get_ava( ber, &f->f_ava, text )) != LDAP_SUCCESS ) {
#ifdef SLAPD_SCHEMA_NOT_COMPAT
err = get_ava( ber, &f->f_ava, SLAP_MR_EQUALITY, text );
#else
err = get_ava( ber, &f->f_ava, text );
#endif
if ( err != LDAP_SUCCESS ) {
break;
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
assert( f->f_ava != NULL );
......@@ -127,7 +131,12 @@ get_filter(
case LDAP_FILTER_GE:
Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 );
if ( (err = get_ava( ber, &f->f_ava, text )) != LDAP_SUCCESS ) {
#ifdef SLAPD_SCHEMA_NOT_COMPAT
err = get_ava( ber, &f->f_ava, SLAP_MR_ORDERING, text );
#else
err = get_ava( ber, &f->f_ava, text );
#endif
if ( err != LDAP_SUCCESS ) {
break;
}
......@@ -152,10 +161,16 @@ get_filter(
case LDAP_FILTER_LE:
Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 );
if ( (err = get_ava( ber, &f->f_ava, text )) != LDAP_SUCCESS ) {
#ifdef SLAPD_SCHEMA_NOT_COMPAT
err = get_ava( ber, &f->f_ava, SLAP_MR_ORDERING, text );
#else
err = get_ava( ber, &f->f_ava, text );
#endif
if ( err != LDAP_SUCCESS ) {
break;
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
*fstr = ch_malloc( sizeof("(<=)")
+ f->f_av_desc->ad_cname->bv_len
......@@ -214,7 +229,12 @@ get_filter(
case LDAP_FILTER_APPROX:
Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 );
if ( (err = get_ava( ber, &f->f_ava, text )) != LDAP_SUCCESS ) {
#ifdef SLAPD_SCHEMA_NOT_COMPAT
err = get_ava( ber, &f->f_ava, SLAP_MR_APPROX, text );
#else
err = get_ava( ber, &f->f_ava, text );
#endif
if ( err != LDAP_SUCCESS ) {
break;
}
......
......@@ -112,10 +112,6 @@ LIBSLAPD_F (char *) at_canonical_name LDAP_P(( const char * a_type ));
LIBSLAPD_F (void) attr_free LDAP_P(( Attribute *a ));
LIBSLAPD_F (Attribute *) attr_dup LDAP_P(( Attribute *a ));
LIBSLAPD_F (char *) attr_normalize LDAP_P(( char *s ));
LIBSLAPD_F (int) attr_merge_fast LDAP_P(( Entry *e, const char *type,
struct berval **vals, int nvals, int naddvals, int *maxvals,
Attribute ***a ));
#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F (int) attr_merge LDAP_P(( Entry *e,
......@@ -125,8 +121,12 @@ LIBSLAPD_F (Attribute *) attrs_find LDAP_P(( Attribute *a, AttributeDescription
LIBSLAPD_F (Attribute *) attr_find LDAP_P(( Attribute *a, AttributeDescription *desc ));
LIBSLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, AttributeDescription *desc ));
#else
LIBSLAPD_F (char *) attr_normalize LDAP_P(( char *s ));
LIBSLAPD_F (int) attr_merge LDAP_P(( Entry *e, const char *type,
struct berval **vals ));
LIBSLAPD_F (int) attr_merge_fast LDAP_P(( Entry *e, const char *type,
struct berval **vals, int nvals, int naddvals, int *maxvals,
Attribute ***a ));
LIBSLAPD_F (Attribute *) attr_find LDAP_P(( Attribute *a, const char *type ));
LIBSLAPD_F (int) attr_delete LDAP_P(( Attribute **attrs, const char *type ));
LIBSLAPD_F (int) attr_syntax LDAP_P(( const char *type ));
......@@ -143,6 +143,7 @@ LIBSLAPD_F (Attribute *) attrs_dup LDAP_P(( Attribute *a ));
LIBSLAPD_F (int) get_ava LDAP_P((
BerElement *ber,
AttributeAssertion **ava,
unsigned usage,
char **text ));
LIBSLAPD_F (void) ava_free LDAP_P((
AttributeAssertion *ava,
......@@ -662,11 +663,19 @@ LIBSLAPD_F (char *) suffix_alias LDAP_P(( Backend *be, char *ndn ));
* value.c
*/
#ifdef SLAPD_SCHEMA_NOT_COMPAT
LIBSLAPD_F (int) value_normalize LDAP_P((
AttributeDescription *ad,
unsigned usage,
struct berval *val,
char ** text ));
#else
LIBSLAPD_F (int) value_add_fast LDAP_P(( struct berval ***vals, struct berval **addvals, int nvals, int naddvals, int *maxvals ));
LIBSLAPD_F (int) value_add LDAP_P(( struct berval ***vals, struct berval **addvals ));
LIBSLAPD_F (void) value_normalize LDAP_P(( char *s, int syntax ));
LIBSLAPD_F (int) value_cmp LDAP_P(( struct berval *v1, struct berval *v2, int syntax, int normalize ));
LIBSLAPD_F (int) value_find LDAP_P(( struct berval **vals, struct berval *v, int syntax, int normalize ));
#endif
/*
* user.c
......
......@@ -18,6 +18,42 @@
#include "slap.h"
int
value_add(
struct berval ***vals,
struct berval **addvals
)
{
int n, nn, i, j;
for ( nn = 0; addvals != NULL && addvals[nn] != NULL; nn++ )
; /* NULL */
if ( *vals == NULL ) {
*vals = (struct berval **) ch_malloc( (nn + 1)
* sizeof(struct berval *) );
n = 0;
} else {
for ( n = 0; (*vals)[n] != NULL; n++ )
; /* NULL */
*vals = (struct berval **) ch_realloc( (char *) *vals,
(n + nn + 1) * sizeof(struct berval *) );
}
for ( i = 0, j = 0; i < nn; i++ ) {
if ( addvals[i]->bv_len > 0 ) {
(*vals)[n + j] = ber_bvdup( addvals[i] );
if( (*vals)[n + j++] == NULL ) break;
}
}
(*vals)[n + j] = NULL;
return( 0 );
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
/* not yet implemented */
#else
int
value_add_fast(
struct berval ***vals,
......@@ -49,42 +85,20 @@ value_add_fast(
return( 0 );
}
#endif
#ifdef SLAPD_SCHEMA_NOT_COMPAT
int
value_add(
struct berval ***vals,
struct berval **addvals
)
value_normalize(
AttributeDescription *ad,
unsigned usage,
struct berval *val,
char **text )
{
int n, nn, i, j;
for ( nn = 0; addvals != NULL && addvals[nn] != NULL; nn++ )
; /* NULL */
if ( *vals == NULL ) {
*vals = (struct berval **) ch_malloc( (nn + 1)
* sizeof(struct berval *) );
n = 0;
} else {
for ( n = 0; (*vals)[n] != NULL; n++ )
; /* NULL */
*vals = (struct berval **) ch_realloc( (char *) *vals,
(n + nn + 1) * sizeof(struct berval *) );
}
for ( i = 0, j = 0; i < nn; i++ ) {
if ( addvals[i]->bv_len > 0 ) {
(*vals)[n + j] = ber_bvdup( addvals[i] );
if( (*vals)[n + j++] == NULL ) break;
}
}
(*vals)[n + j] = NULL;
return( 0 );
/* not yet implemented */
return LDAP_SUCCESS;
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
/* not yet implemented */
#else
void
value_normalize(
......@@ -112,7 +126,11 @@ value_normalize(
}
*d = '\0';
}
#endif
#ifdef SLAPD_SCHEMA_NOT_COMPAT
/* not yet implemented */
#else
int
value_cmp(
struct berval *v1,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment