X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fvalue.c;h=bb6b7e620b62c13648992eaa592e1af27dd349cc;hb=8a5bbf9b0808a17543cd7141623a91a79c633232;hp=c9e6fbb5774a1560f88990c63cab8a1e528fed5b;hpb=42e0d83cb3a1a1c5b25183f1ab74ce7edbe25de7;p=openldap diff --git a/servers/slapd/value.c b/servers/slapd/value.c index c9e6fbb577..bb6b7e620b 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -1,12 +1,16 @@ /* value.c - routines for dealing with values */ +#include "portable.h" + #include -#include -#include -#include -#include + +#include +#include +#include +#include + #include -#include "portable.h" + #include "slap.h" int @@ -99,8 +103,6 @@ value_normalize( *d = '\0'; } -#define MIN( a, b ) (a < b ? a : b ) - int value_cmp( struct berval *v1, @@ -133,8 +135,8 @@ value_cmp( break; case SYNTAX_BIN: - rc = memcmp( v1->bv_val, v2->bv_val, MIN( v1->bv_len, - v2->bv_len ) ); + rc = ( v1->bv_len == v2->bv_len ) ? memcmp( v1->bv_val, + v2->bv_val, v1->bv_len ) : v1->bv_len - v2->bv_len ; break; } @@ -148,50 +150,6 @@ value_cmp( return( rc ); } -int -value_ncmp( - struct berval *v1, - struct berval *v2, - int syntax, - int len, - int normalize -) -{ - int rc; - - if ( normalize & 1 ) { - v1 = ber_bvdup( v1 ); - value_normalize( v1->bv_val, syntax ); - } - if ( normalize & 2 ) { - v2 = ber_bvdup( v2 ); - value_normalize( v2->bv_val, syntax ); - } - - switch ( syntax ) { - case SYNTAX_CIS: - case (SYNTAX_CIS | SYNTAX_TEL): - rc = strncasecmp( v1->bv_val, v2->bv_val, len ); - break; - - case SYNTAX_CES: - rc = strncmp( v1->bv_val, v2->bv_val, len ); - break; - - case SYNTAX_BIN: - rc = memcmp( v1->bv_val, v2->bv_val, len ); - } - - if ( normalize & 1 ) { - ber_bvfree( v1 ); - } - if ( normalize & 2 ) { - ber_bvfree( v2 ); - } - - return( rc ); -} - int value_find( struct berval **vals,