From: Pierangelo Masarati Date: Tue, 24 Aug 2004 09:29:11 +0000 (+0000) Subject: move call to frontend API X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~660 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=00f1c085cf04fd2539ec3d38e0bbd283c20b4a60;p=openldap move call to frontend API --- diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 91311fbe51..b118680126 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -45,12 +45,6 @@ meta_send_entry( LDAPMessage *e ); -static int -is_one_level_rdn( - const char *rdn, - int from -); - int meta_back_search( Operation *op, SlapReply *rs ) { @@ -163,9 +157,12 @@ meta_back_search( Operation *op, SlapReply *rs ) break; case LDAP_SCOPE_ONELEVEL: - if ( is_one_level_rdn( li->targets[ i ]->suffix.bv_val, - suffixlen - op->o_req_ndn.bv_len - 1 ) - && dnIsSuffix( &li->targets[ i ]->suffix, &op->o_req_ndn ) ) { + { + struct berval rdn = li->targets[ i ]->suffix; + rdn.bv_len -= op->o_req_ndn.bv_len + STRLENOF( "," ); + if ( dnIsOneLevelRDN( &rdn ) + && dnIsSuffix( &li->targets[ i ]->suffix, &op->o_req_ndn ) ) + { /* * if there is exactly one level, * make the target suffix the new @@ -176,6 +173,7 @@ meta_back_search( Operation *op, SlapReply *rs ) is_scope++; break; } /* else continue with the next case */ + } case LDAP_SCOPE_BASE: /* @@ -739,18 +737,4 @@ meta_send_entry( return LDAP_SUCCESS; } -static int -is_one_level_rdn( - const char *rdn, - int from -) -{ - for ( ; from--; ) { - if ( DN_SEPARATOR( rdn[ from ] ) ) { - return 0; - } - } - - return 1; -} diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 44528fa2f6..388ea12366 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -1259,6 +1259,19 @@ dnIsSuffix( return( strcmp( dn->bv_val + d, suffix->bv_val ) == 0 ); } +int +dnIsOneLevelRDN( struct berval *rdn ) +{ + ber_len_t len = rdn->bv_len; + for ( ; len--; ) { + if ( DN_SEPARATOR( rdn->bv_val[ len ] ) ) { + return 0; + } + } + + return 1; +} + #ifdef HAVE_TLS /* * Convert an X.509 DN into a normalized LDAP DN diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 8f398a7d43..87a62dfba8 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -488,6 +488,8 @@ LDAP_SLAPD_F (int) rdnMatch LDAP_P(( LDAP_SLAPD_F (int) dnIsSuffix LDAP_P(( const struct berval *dn, const struct berval *suffix )); +LDAP_SLAPD_F (int) dnIsOneLevelRDN LDAP_P(( struct berval *rdn )); + LDAP_SLAPD_F (int) dnExtractRdn LDAP_P(( struct berval *dn, struct berval *rdn, void *ctx ));