]> git.sur5r.net Git - openldap/commitdiff
Implement slapi_rdn2typeval and slapi_dn_plus_rdn
authorLuke Howard <lukeh@openldap.org>
Sun, 23 May 2004 12:43:59 +0000 (12:43 +0000)
committerLuke Howard <lukeh@openldap.org>
Sun, 23 May 2004 12:43:59 +0000 (12:43 +0000)
servers/slapd/slapi/slapi_utils.c

index c68f48d651343677b7c781b2f240b9a58c505026..4f8146474b54d088b15f2f1132f8ea287f49bd5d 100644 (file)
@@ -4012,3 +4012,62 @@ int slapi_int_access_allowed( Operation *op,
 #endif /* LDAP_SLAPI */
 }
 
+/*
+ * There is no documentation for this.
+ */
+int slapi_rdn2typeval( char *rdn, char **type, struct berval *bv )
+{
+#ifdef LDAP_SLAPI
+       LDAPRDN lrdn;
+       LDAPAVA *ava;
+       int rc;
+       char *p;
+
+       *type = NULL;
+
+       bv->bv_len = 0;
+       bv->bv_val = NULL;
+
+       rc = ldap_str2rdn( rdn, &lrdn, &p, LDAP_DN_FORMAT_LDAPV3 );
+       if ( rc != LDAP_SUCCESS ) {
+               return -1;
+       }
+
+       if ( lrdn[1] != NULL ) {
+               return -1; /* not single valued */
+       }
+
+       ava = lrdn[0];
+
+       *type = slapi_ch_strdup( ava->la_attr.bv_val );
+       ber_dupbv( bv, &ava->la_value );
+
+       ldap_rdnfree(lrdn);
+
+       return 0;
+#else
+       return -1;
+#endif /* LDAP_SLAPI */
+}
+
+char *slapi_dn_plus_rdn( const char *dn, const char *rdn )
+{
+#ifdef LDAP_SLAPI
+       struct berval new_dn, parent_dn, newrdn;
+
+       new_dn.bv_val = NULL;
+
+       parent_dn.bv_val = (char *)dn;
+       parent_dn.bv_len = strlen( dn );
+
+       newrdn.bv_val = (char *)rdn;
+       newrdn.bv_len = strlen( rdn );
+
+       build_new_dn( &new_dn, &parent_dn, &newrdn, NULL );
+
+       return new_dn.bv_val;
+#else
+       return NULL;
+#endif /* LDAP_SLAPI */
+}
+