]> git.sur5r.net Git - openldap/commitdiff
prepare for ldap_bv2dn()
authorPierangelo Masarati <ando@openldap.org>
Wed, 13 Feb 2002 10:05:22 +0000 (10:05 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 13 Feb 2002 10:05:22 +0000 (10:05 +0000)
include/ldap.h
libraries/libldap/getdn.c
servers/slapd/dn.c

index 396e32ad7be8dd1ee4cb8a49ca4780939b3fc6b6..625f8f2c39defe895e6c75d9a3ff8078bfcbd3b8 100644 (file)
@@ -1203,6 +1203,12 @@ ldap_rdnfree LDAP_P(( LDAPRDN *rdn ));
 LDAP_F( void )
 ldap_dnfree LDAP_P(( LDAPDN *dn ));
 
+LDAP_F( int )
+ldap_bv2dn LDAP_P(( 
+       struct berval *bv, 
+       LDAPDN **dn, 
+       unsigned flags ));
+
 LDAP_F( int )
 ldap_str2dn LDAP_P((
        LDAP_CONST char *str,
index 945d42d2b2af6478f3015641740cf241020e9c2d..f3c60465fd42b44a6bca5f3f58fe3164b1d50d24 100644 (file)
@@ -598,6 +598,23 @@ ldap_dnfree( LDAPDN *dn )
 #define        TMP_AVA_SLOTS   8
 #define        TMP_RDN_SLOTS   32
 
+int
+ldap_bv2dn( struct berval *bv, LDAPDN **dn, unsigned flags )
+{
+       assert( bv );
+       assert( dn );
+       
+       /* 
+        * FIXME: ldap_bv2dn() and ldap_str2dn() will be swapped,
+        * i.e. ldap_str2dn() will become a wrapper for ldap_bv2dn()
+        */
+       if ( bv->bv_len != strlen( bv->bv_val ) ) {
+               return LDAP_INVALID_DN_SYNTAX;
+       }
+
+       return ldap_str2dn( bv->bv_val, dn, flags );
+}
+
 int
 ldap_str2dn( LDAP_CONST char *str, LDAPDN **dn, unsigned flags )
 {
index f871e38ce7526289fbd467303ca77840cbff3e0e..031c6c7fa8aca62ea108f9c00caa64c392933d82 100644 (file)
@@ -116,12 +116,7 @@ dnValidate(
                return( LDAP_SUCCESS );
        }
 
-       /* FIXME: str2dn should take a bv and handle this */
-       if( strlen( in->bv_val ) != in->bv_len ) {
-               return LDAP_INVALID_SYNTAX;
-       }
-
-       rc = ldap_str2dn( in->bv_val, &dn, LDAP_DN_FORMAT_LDAP );
+       rc = ldap_bv2dn( in, &dn, LDAP_DN_FORMAT_LDAP );
 
        /*
         * Schema-aware validate
@@ -354,7 +349,7 @@ dnNormalize2(
                /*
                 * Go to structural representation
                 */
-               rc = ldap_str2dn( val->bv_val, &dn, LDAP_DN_FORMAT_LDAP );
+               rc = ldap_bv2dn( val, &dn, LDAP_DN_FORMAT_LDAP );
                if ( rc != LDAP_SUCCESS ) {
                        return LDAP_INVALID_SYNTAX;
                }
@@ -424,13 +419,8 @@ dnPretty2(
                LDAPDN          *dn = NULL;
                int             rc;
 
-               /* FIXME: str2dn should take a bv and handle this */
-               if( strlen( val->bv_val ) != val->bv_len ) {
-                       return LDAP_INVALID_SYNTAX;
-               }
-
                /* FIXME: should be liberal in what we accept */
-               rc = ldap_str2dn( val->bv_val, &dn, LDAP_DN_FORMAT_LDAP );
+               rc = ldap_bv2dn( val, &dn, LDAP_DN_FORMAT_LDAP );
                if ( rc != LDAP_SUCCESS ) {
                        return LDAP_INVALID_SYNTAX;
                }
@@ -495,7 +485,7 @@ dnPrettyNormal(
                }
 
                /* FIXME: should be liberal in what we accept */
-               rc = ldap_str2dn( val->bv_val, &dn, LDAP_DN_FORMAT_LDAP );
+               rc = ldap_bv2dn( val, &dn, LDAP_DN_FORMAT_LDAP );
                if ( rc != LDAP_SUCCESS ) {
                        return LDAP_INVALID_SYNTAX;
                }