From d6a37432bd4349fca19e93272e9baf32a8bdf065 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 28 Dec 2001 08:38:24 +0000 Subject: [PATCH] Changed dn_rdn/dn_rdnlen to struct berval --- servers/slapd/acl.c | 4 ++-- servers/slapd/back-bdb/dn2id.c | 4 ++-- servers/slapd/back-bdb/modrdn.c | 2 +- servers/slapd/back-ldbm/modrdn.c | 2 +- servers/slapd/back-passwd/search.c | 4 ++-- servers/slapd/dn.c | 34 +++++++----------------------- servers/slapd/limits.c | 2 +- servers/slapd/proto-slap.h | 4 ++-- 8 files changed, 19 insertions(+), 37 deletions(-) diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 912279a111..4c232a5dc3 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -361,7 +361,7 @@ acl_get( if ( !DN_SEPARATOR( e->e_ndn[dnlen - patlen - 1] ) || DN_ESCAPE( e->e_ndn[dnlen - patlen - 2] ) ) continue; - rdnlen = dn_rdnlen( NULL, e->e_ndn ); + rdnlen = dn_rdnlen( NULL, &e->e_nname ); if ( rdnlen != dnlen - patlen - 1 ) continue; @@ -567,7 +567,7 @@ acl_mask( if ( !DN_SEPARATOR( op->o_ndn.bv_val[odnlen - patlen - 1] ) || DN_ESCAPE( op->o_ndn.bv_val[odnlen - patlen - 2] ) ) continue; - rdnlen = dn_rdnlen( NULL, op->o_ndn.bv_val ); + rdnlen = dn_rdnlen( NULL, &op->o_ndn ); if ( rdnlen != odnlen - patlen - 1 ) continue; diff --git a/servers/slapd/back-bdb/dn2id.c b/servers/slapd/back-bdb/dn2id.c index b5a8bc91ef..4fca067aaf 100644 --- a/servers/slapd/back-bdb/dn2id.c +++ b/servers/slapd/back-bdb/dn2id.c @@ -646,9 +646,9 @@ bdb_dn2id_add( diskNode *d; idNode *n; - nrlen = dn_rdnlen( be, e->e_ndn ); + nrlen = dn_rdnlen( be, &e->e_nname ); if (nrlen) { - rlen = dn_rdnlen( be, e->e_dn ); + rlen = dn_rdnlen( be, &e->e_name ); } else { rlen = 0; } diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index 58d99b00db..c67b5a3180 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -435,7 +435,7 @@ retry: /* transaction retry */ new_rdn_vals[0], new_rdn_types[0], 0 ); /* Retrieve the old rdn from the entry's dn */ - if ( ( old_rdn = dn_rdn( be, dn->bv_val ) ) == NULL ) { + if ( ( old_rdn = dn_rdn( be, dn ) ) == NULL ) { Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: can't figure out old_rdn from dn\n", 0, 0, 0 ); diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index f6a9d9be87..d62ca57599 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -527,7 +527,7 @@ ldbm_back_modrdn( #endif /* Retrieve the old rdn from the entry's dn */ - if ( (old_rdn = dn_rdn( be, dn->bv_val )) == NULL ) { + if ( (old_rdn = dn_rdn( be, dn )) == NULL ) { #ifdef NEW_LOGGING LDAP_LOG(( "backend", LDAP_LEVEL_INFO, "ldbm_back_modrdn: can't figure out old_rdn from dn (%s)\n", diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index 42399bc72e..30d1cd69f8 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -92,7 +92,7 @@ passwd_back_search( /* Use the first attribute of the DN * as an attribute within the entry itself. */ - rdn = dn_rdn(NULL, base->bv_val); + rdn = dn_rdn(NULL, base); if( rdn == NULL || (s = strchr(rdn, '=')) == NULL ) { err = LDAP_INVALID_DN_SYNTAX; @@ -204,7 +204,7 @@ passwd_back_search( goto done; } - rdn = dn_rdn( NULL, base->bv_val ); + rdn = dn_rdn( NULL, base ); if ( (user = rdn_attr_value(rdn)) == NULL) { err = LDAP_OPERATIONS_ERROR; diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 588fc4a1eb..4b3394a822 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -726,9 +726,8 @@ dnExtractRdn( int dn_rdnlen( Backend *be, - const char *dn_in ) + struct berval *dn_in ) { - struct berval bv; struct berval *rdn = NULL; int retval = 0; @@ -738,23 +737,15 @@ dn_rdnlen( return 0; } - while ( dn_in[ 0 ] && ASCII_SPACE( dn_in[ 0 ] ) ) { - dn_in++; - } - - if ( dn_in[ 0 ] == '\0' ) { + if ( !dn_in->bv_len ) { return 0; } - if ( be != NULL && be_issuffix( be, dn_in ) ) { + if ( be != NULL && be_issuffix( be, dn_in->bv_val ) ) { return 0; } - bv.bv_val = (char *) dn_in; - bv.bv_len = strlen( bv.bv_val ); - - if ( dnExtractRdn( &bv, &rdn ) != LDAP_SUCCESS ) { - ber_bvfree( rdn ); + if ( dnExtractRdn( dn_in, &rdn ) != LDAP_SUCCESS ) { return 0; } @@ -769,9 +760,8 @@ dn_rdnlen( */ char * dn_rdn( Backend *be, - const char *dn_in ) + struct berval *dn_in ) { - struct berval bv; struct berval *rdn = NULL; char *retval; @@ -781,23 +771,15 @@ char * dn_rdn( return NULL; } - while ( dn_in[ 0 ] && ASCII_SPACE( dn_in[ 0 ] ) ) { - dn_in++; - } - - if ( dn_in[ 0 ] == '\0' ) { + if ( !dn_in->bv_len ) { return NULL; } - if ( be != NULL && be_issuffix( be, dn_in ) ) { + if ( be != NULL && be_issuffix( be, dn_in->bv_val ) ) { return NULL; } - bv.bv_val = (char *) dn_in; - bv.bv_len = strlen( bv.bv_val ); - - if ( dnExtractRdn( &bv, &rdn ) != LDAP_SUCCESS ) { - ber_bvfree( rdn ); + if ( dnExtractRdn( dn_in, &rdn ) != LDAP_SUCCESS ) { return NULL; } diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index 8503330516..c7070504d4 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -83,7 +83,7 @@ get_limits( * if ndn is more that one rdn * below dn_pat, continue */ - if ( (size_t) dn_rdnlen( NULL, ndn->bv_val ) != d - 1 ) { + if ( (size_t) dn_rdnlen( NULL, ndn ) != d - 1 ) { break; } } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 71d78ca13c..ef98b8e5c3 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -390,8 +390,8 @@ LDAP_SLAPD_F (int) rdnValidate LDAP_P(( struct berval * rdn )); 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 )); -LDAP_SLAPD_F (char *) dn_rdn LDAP_P(( Backend *be, const char *dn )); -LDAP_SLAPD_F (int) dn_rdnlen LDAP_P(( Backend *be, const char *dn )); +LDAP_SLAPD_F (char *) dn_rdn LDAP_P(( Backend *be, struct berval *dn )); +LDAP_SLAPD_F (int) dn_rdnlen LDAP_P(( Backend *be, struct berval *dn )); LDAP_SLAPD_F (int) dn_issuffix LDAP_P(( const char *dn, const char *suffix )); LDAP_SLAPD_F (char *) rdn_attr_value LDAP_P(( const char * rdn )); LDAP_SLAPD_F (char *) rdn_attr_type LDAP_P(( const char * rdn )); -- 2.39.5