]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/dn.c
Added connection initialisation and destruction notification. Now backends can regist...
[openldap] / servers / slapd / dn.c
index 2d02628ed3f86ba93acbcad1f1a42b0783691599..4f28d164b8989490de6b653ce3aa95a3328986c9 100644 (file)
@@ -155,7 +155,7 @@ dn_parent(
 )
 {
        char    *s;
-       int     inquote, gotesc;
+       int     inquote;
 
        if( dn == NULL ) {
                return NULL;
@@ -169,7 +169,7 @@ dn_parent(
                return( NULL );
        }
 
-       if ( be_issuffix( be, dn ) ) {
+       if ( be != NULL && be_issuffix( be, dn ) ) {
                return( NULL );
        }
 
@@ -225,7 +225,7 @@ char * dn_rdn(
     char       *dn )
 {
        char    *s;
-       int     inquote, gotesc;
+       int     inquote;
 
        if( dn == NULL ) {
                return NULL;
@@ -239,7 +239,7 @@ char * dn_rdn(
                return( NULL );
        }
 
-       if ( be_issuffix( be, dn ) ) {
+       if ( be != NULL && be_issuffix( be, dn ) ) {
                return( NULL );
        }
 
@@ -345,7 +345,8 @@ dn_upcase( char *dn )
 
 
 /*
- * get_next_substring(), rdn_attr_type(), and rdn_attr_value()
+ * get_next_substring(), rdn_attr_type(), rdn_attr_value(), and
+ * build_new_dn().
  * 
  * Copyright 1999, Juan C. Gomez, All rights reserved.
  * This software is not subject to any license of Silicon Graphics 
@@ -440,3 +441,58 @@ rdn_attr_value( char * rdn )
        return NULL;
 
 }/* char * rdn_attr_value() */
+
+
+/* build_new_dn:
+ *
+ * Used by ldbm/bdb2_back_modrdn to create the new dn of entries being
+ * renamed.
+ *
+ * new_dn = parent (p_dn)  + separator(s) + rdn (newrdn) + null.
+ */
+
+void
+build_new_dn( char ** new_dn, char *e_dn, char * p_dn, char * newrdn )
+{
+
+    if ( p_dn == NULL ) {
+
+       *new_dn = ch_strdup( newrdn );
+       return;
+
+    }
+    
+    *new_dn = (char *) ch_malloc( strlen( p_dn ) + strlen( newrdn ) + 3 );
+
+    if ( dn_type( e_dn ) == DN_X500 ) {
+
+       strcpy( *new_dn, newrdn );
+       strcat( *new_dn, "," );
+       strcat( *new_dn, p_dn );
+
+    } else {
+
+       char    *s;
+       char    sep[2];
+
+       strcpy( *new_dn, newrdn );
+       s = strchr( newrdn, '\0' );
+       s--;
+
+       if ( (*s != '.') && (*s != '@') ) {
+
+           if ( (s = strpbrk( e_dn, ".@" )) != NULL ) {
+
+               sep[0] = *s;
+               sep[1] = '\0';
+               strcat( *new_dn, sep );
+
+           }/* if ( (s = strpbrk( dn, ".@" )) != NULL ) */
+
+       }/* if ( *s != '.' && *s != '@' ) */
+
+       strcat( *new_dn, p_dn );
+
+    }/* if ( dn_type( e_dn ) == DN_X500 ) {}else */
+    
+}/* void build_new_dn() */