From: Juan Gomez Date: Wed, 24 Mar 1999 20:26:43 +0000 (+0000) Subject: Added a new function: build_new_dn(), which builds new dn for entries X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~340 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dccfdb97e9663cfb5c814d487d44268741faefb8;p=openldap Added a new function: build_new_dn(), which builds new dn for entries being renamed through modrdn/moddn. This in preparation to add support for MODDN v3. --- diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 57d8788ecd..6c06f23ca9 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -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,51 @@ 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 ) +{ + + *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() */ diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index e513159139..b4baf447f8 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -139,7 +139,8 @@ int dn_type LDAP_P(( char *dn )); char * dn_upcase LDAP_P(( char *dn )); char * rdn_attr_value LDAP_P(( char * rdn )); char * rdn_attr_type LDAP_P(( char * rdn )); - +void build_new_dn LDAP_P(( char ** new_dn, char *e_dn, char * p_dn, + char * newrdn )); /* * entry.c */