From e701812f27ac6338500f33c48ed2d707aec99aff Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 24 Dec 2001 04:39:15 +0000 Subject: [PATCH] Make note of deprecated DN routines. Need to write "struct berval" versions --- servers/slapd/dn.c | 54 +++++++++++++++++++++++--------------- servers/slapd/proto-slap.h | 4 +++ 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 55ed2b520f..1a7e19ee5e 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -458,38 +458,48 @@ dnMatch( return( LDAP_SUCCESS ); } +#ifdef SLAP_DN_MIGRATION +/* + * these routines are provided for migration purposes only! + * dn_validate is deprecated in favor of dnValidate + * dn_normalize is deprecated in favor of dnNormalize + * strcmp/strcasecmp for DNs is deprecated in favor of dnMatch + * + * other routines are likewise deprecated but may not yet have + * replacement functions. + */ + /* * dn_validate - validate and compress dn. the dn is * compressed in place are returned if valid. */ - char * -dn_validate( char *dn_in ) +dn_validate( char *dn ) { - struct berval val, *normalized; + struct berval val, *pretty; int rc; - if ( dn_in == NULL || dn_in[ 0 ] == '\0' ) { - return( dn_in ); + if ( dn == NULL || dn[0] == '\0' ) { + return dn; } - val.bv_val = dn_in; - val.bv_len = strlen( dn_in ); + val.bv_val = dn; + val.bv_len = strlen( dn ); - rc = dnPretty( NULL, &val, &normalized ); + rc = dnPretty( NULL, &val, &pretty ); if ( rc != LDAP_SUCCESS ) { - return( NULL ); + return NULL; } - if ( val.bv_len < normalized->bv_len ) { - ber_bvfree( normalized ); - return( NULL ); + if ( val.bv_len < pretty->bv_len ) { + ber_bvfree( pretty ); + return NULL; } - AC_MEMCPY( dn_in, normalized->bv_val, normalized->bv_len + 1 ); - ber_bvfree( normalized ); + AC_MEMCPY( dn, pretty->bv_val, pretty->bv_len + 1 ); + ber_bvfree( pretty ); - return( dn_in ); + return dn; } /* @@ -497,15 +507,14 @@ dn_validate( char *dn_in ) * in a hash database. this involves normalizing the case as well as * the format. the dn is normalized in place as well as returned if valid. */ - char * dn_normalize( char *dn ) { struct berval val, *normalized; int rc; - if ( dn == NULL || dn[ 0 ] == '\0' ) { - return( dn ); + if ( dn == NULL || dn[0] == '\0' ) { + return dn; } val.bv_val = dn; @@ -513,20 +522,21 @@ dn_normalize( char *dn ) rc = dnNormalize( NULL, &val, &normalized ); if ( rc != LDAP_SUCCESS ) { - return( NULL ); + return NULL; } if ( val.bv_len < normalized->bv_len ) { ber_bvfree( normalized ); - return( NULL ); + return NULL; } AC_MEMCPY( dn, normalized->bv_val, normalized->bv_len + 1 ); ber_bvfree( normalized ); - return( dn ); + return dn; } + /* * dn_parent - return the dn's parent, in-place */ @@ -960,3 +970,5 @@ build_new_dn( char ** new_dn, strcat( *new_dn, "," ); strcat( *new_dn, p_dn ); } + +#endif /* SLAP_DN_MIGRATION */ diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 3e6999a9e8..e4adc641e9 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -347,6 +347,8 @@ LDAP_SLAPD_F (int) dnMatch LDAP_P(( struct berval *value, void *assertedValue )); +#define SLAP_DN_MIGRATION +#ifdef SLAP_DN_MIGRATION LDAP_SLAPD_F (char *) dn_validate LDAP_P(( char *dn )); LDAP_SLAPD_F (char *) dn_normalize LDAP_P(( char *dn )); LDAP_SLAPD_F (char *) dn_parent LDAP_P(( Backend *be, const char *dn )); @@ -364,6 +366,8 @@ LDAP_SLAPD_F (void) build_new_dn LDAP_P(( char ** new_dn, const char *e_dn, const char * p_dn, const char * newrdn )); +#endif + /* * entry.c */ -- 2.39.5