- if ( dnExtractRdn( dn_in, &rdn ) != LDAP_SUCCESS ) {
- ber_bvfree( rdn );
- return 0;
- }
-
- retval = rdn->bv_len;
- ber_bvfree( rdn );
-
- return retval;
-}
-
-/*
- * FIXME: should be replaced by dnExtractRdn() (together with dn_rdnlen)
- */
-char * dn_rdn(
- Backend *be,
- const char *dn_in )
-{
-#if 0
- char *rdn;
- int i = dn_rdnlen( be, dn_in );
-
- rdn = ch_malloc( i + 1 );
- strncpy(rdn, dn_in, i);
- rdn[i] = '\0';
- return rdn;
-#endif
- struct berval *rdn = NULL;
- char *retval;
-
- assert( dn_in );
-
- if ( dn_in == NULL ) {
- return NULL;
- }
-
- while ( dn_in[ 0 ] && ASCII_SPACE( dn_in[ 0 ] ) ) {
- dn_in++;
- }
-
- if ( dn_in[ 0 ] == '\0' ) {
- return NULL;
- }
-
- if ( be != NULL && be_issuffix( be, dn_in ) ) {
- return NULL;
- }
-
- if ( dnExtractRdn( dn_in, &rdn ) != LDAP_SUCCESS ) {
- ber_bvfree( rdn );
- return NULL;
- }
-
- retval = rdn->bv_val;
- free( rdn );
-
- return retval;
-}
-
-/*
- * return a charray of all subtrees to which the DN resides in
- */
-char **dn_subtree(
- Backend *be,
- const char *dn )
-{
- char **subtree = NULL;
-
- do {
- charray_add( &subtree, dn );
-
- dn = dn_parent( be, dn );
-
- } while ( dn != NULL );
-
- return subtree;
-}
-
-/*
- * dn_issuffix - tells whether suffix is a suffix of dn.
- * Both dn and suffix must be normalized.
- * deprecated in favor of dnIsSuffix()
- */
-int
-dn_issuffix(
- const char *dn,
- const char *suffix
-)
-{
- struct berval bvdn, bvsuffix;
-
- assert( dn );
- assert( suffix );
-
- bvdn.bv_val = (char *) dn;
- bvdn.bv_len = strlen( dn );
- bvsuffix.bv_val = (char *) suffix;
- bvsuffix.bv_len = strlen( suffix );
-
- return dnIsSuffix( &bvdn, &bvsuffix );
-}
-
-/*
- * 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
- * Inc. or Purdue University.
- *
- * Redistribution and use in source and binary forms are permitted
- * without restriction or fee of any kind as long as this notice
- * is preserved.
- *
- */
-
-/* get_next_substring:
- *
- * Gets next substring in s, using d (or the end of the string '\0') as a
- * string delimiter, and places it in a duplicated memory space. Leading
- * spaces are ignored. String s **must** be null-terminated.
- */
-
-static char *
-get_next_substring( const char * s, char d )
-{
-
- char *str, *r;
-
- r = str = ch_malloc( strlen(s) + 1 );
-
- /* Skip leading spaces */
-
- while ( *s && ASCII_SPACE(*s) ) {
- s++;
- }
-
- /* Copy word */
-
- while ( *s && (*s != d) ) {
-
- /* Don't stop when you see trailing spaces may be a multi-word
- * string, i.e. name=John Doe!
- */
-
- *str++ = *s++;
- }
-
- *str = '\0';
-
- return r;
-
-}
-
-
-/* rdn_attr_type:
- *
- * Given a string (i.e. an rdn) of the form:
- * "attribute_type = attribute_value"
- * this function returns the type of an attribute, that is the
- * string "attribute_type" which is placed in newly allocated
- * memory. The returned string will be null-terminated.
- */