int
be_issuffix(
Backend *be,
- const char *suffix
+ struct berval *bvsuffix
)
{
int i;
- struct berval bvsuffix = { strlen( suffix ), (char *)suffix };
for ( i = 0; be->be_nsuffix != NULL && be->be_nsuffix[i] != NULL; i++ ) {
- if ( ber_bvcmp( be->be_nsuffix[i], &bvsuffix ) == 0 ) {
+ if ( ber_bvcmp( be->be_nsuffix[i], bvsuffix ) == 0 ) {
return( 1 );
}
}
#include "slap.h"
+const struct berval slap_empty_bv = { 0, "" };
+
#define SLAP_LDAPDN_PRETTY 0x1
/*
*/
int
dnParent(
- const char *dn,
- const char **pdn )
+ struct berval *dn,
+ struct berval *pdn )
{
const char *p;
- p = strchr( dn, ',' );
+ p = strchr( dn->bv_val, ',' );
/* one-level dn */
if ( p == NULL ) {
- *pdn = "";
+ pdn->bv_val = "";
+ pdn->bv_len = 0;
return LDAP_SUCCESS;
}
p++;
assert( ATTR_LEADCHAR( p[ 0 ] ) );
- *pdn = p;
+ pdn->bv_val = p;
+ pdn->bv_len = dn->bv_len - (p - dn->bv_val);
return LDAP_SUCCESS;
}
const char *dn )
{
const char *pdn;
+ struct berval bv;
if ( dn == NULL ) {
return NULL;
return NULL;
}
- if ( be != NULL && be_issuffix( be, dn ) ) {
+ bv.bv_val = dn;
+ bv.bv_len = strlen(bv.bv_val);
+ if ( be != NULL && be_issuffix( be, &bv ) ) {
return NULL;
}
}
/*
- * FIXME: should be replaced by dnExtractRdn()
+ * We can assume the input is a prettied or normalized DN
*/
int
dn_rdnlen(
return 0;
}
- if ( be != NULL && be_issuffix( be, dn_in->bv_val ) ) {
+ if ( be != NULL && be_issuffix( be, dn_in ) ) {
return 0;
}
- rc = ldap_str2rdn( dn_in->bv_val, NULL, (char **)&p,
- LDAP_DN_FORMAT_LDAP | LDAP_DN_SKIP );
- if ( rc != LDAP_SUCCESS ) {
- return 0;
- }
+ p = strchr( dn_in->bv_val, ',' );
- return p - dn_in->bv_val;
+ return p ? p - dn_in->bv_val : dn_in->bv_len;
}
int noSubordinates ));
LDAP_SLAPD_F (int) be_issuffix LDAP_P(( Backend *be,
- const char *suffix ));
+ struct berval *suffix ));
LDAP_SLAPD_F (int) be_isroot LDAP_P(( Backend *be,
struct berval *ndn ));
LDAP_SLAPD_F (int) be_isroot_pw LDAP_P(( Backend *be,
#define dn_match(dn1, dn2) ( ber_bvcmp((dn1), (dn2)) == 0 )
+LDAP_SLAPD_V( const struct berval ) slap_empty_bv;
+
LDAP_SLAPD_F (int) dnValidate LDAP_P((
Syntax *syntax,
struct berval *val ));
struct berval * parent_dn,
struct berval * newrdn ));
-LDAP_SLAPD_F (int) dnParent LDAP_P(( const char *dn, const char **pdn ));
+LDAP_SLAPD_F (int) dnParent LDAP_P(( struct berval *dn, struct berval *pdn ));
#define SLAP_DN_MIGRATION
#ifdef SLAP_DN_MIGRATION