]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/modify.c
error message from be_entry_put tool backend function
[openldap] / servers / slapd / back-ldbm / modify.c
index 5f771dbc81d05ef2cb5213e8c61a7c62d43df9c6..6e263639d6ff0b0f7842b83840de6286890db0d2 100644 (file)
@@ -1,7 +1,7 @@
 /* modify.c - ldbm backend modify routine */
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -71,7 +71,7 @@ int ldbm_modify_internal(
                        Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: add\n", 0, 0, 0);
 #endif
 
-                       err = add_values( e, mod, op->o_ndn );
+                       err = add_values( e, mod, op->o_ndn.bv_val );
 
                        if( err != LDAP_SUCCESS ) {
                                *text = "modify: add values failed";
@@ -94,7 +94,7 @@ int ldbm_modify_internal(
                        Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: delete\n", 0, 0, 0);
 #endif
 
-                       err = delete_values( e, mod, op->o_ndn );
+                       err = delete_values( e, mod, op->o_ndn.bv_val );
                        assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
                        if( err != LDAP_SUCCESS ) {
                                *text = "modify: delete values failed";
@@ -116,7 +116,7 @@ int ldbm_modify_internal(
                        Debug(LDAP_DEBUG_ARGS, "ldbm_modify_internal: replace\n", 0, 0, 0);
 #endif
 
-                       err = replace_values( e, mod, op->o_ndn );
+                       err = replace_values( e, mod, op->o_ndn.bv_val );
                        assert( err != LDAP_TYPE_OR_VALUE_EXISTS );
                        if( err != LDAP_SUCCESS ) {
                                *text = "modify: replace values failed";
@@ -143,7 +143,7 @@ int ldbm_modify_internal(
                         * We need to add index if necessary.
                         */
                        mod->sm_op = LDAP_MOD_ADD;
-                       err = add_values( e, mod, op->o_ndn );
+                       err = add_values( e, mod, op->o_ndn.bv_val );
 
                        if ( err == LDAP_TYPE_OR_VALUE_EXISTS ) {
                                err = LDAP_SUCCESS;
@@ -202,7 +202,7 @@ int ldbm_modify_internal(
        ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
 
        /* check that the entry still obeys the schema */
-       rc = entry_schema_check( e, save_attrs, text, textbuf, textlen );
+       rc = entry_schema_check( be, e, save_attrs, text, textbuf, textlen );
        if ( rc != LDAP_SUCCESS ) {
                attrs_free( e->e_attrs );
                e->e_attrs = save_attrs;
@@ -245,8 +245,8 @@ ldbm_back_modify(
     Backend    *be,
     Connection *conn,
     Operation  *op,
-    const char *dn,
-    const char *ndn,
+    struct berval      *dn,
+    struct berval      *ndn,
     Modifications      *modlist
 )
 {
@@ -270,13 +270,12 @@ ldbm_back_modify(
        /* acquire and lock entry */
        if ( (e = dn2entry_w( be, ndn, &matched )) == NULL ) {
                char* matched_dn = NULL;
-               struct berval **refs;
+               BVarray refs;
 
                if ( matched != NULL ) {
                        matched_dn = ch_strdup( matched->e_dn );
                        refs = is_entry_referral( matched )
-                               ? get_entry_referrals( be, conn, op, matched,
-                                       dn, LDAP_SCOPE_DEFAULT )
+                               ? get_entry_referrals( be, conn, op, matched )
                                : NULL;
                        cache_return_entry_r( &li->li_cache, matched );
                } else {
@@ -287,7 +286,7 @@ ldbm_back_modify(
                send_ldap_result( conn, op, LDAP_REFERRAL,
                        matched_dn, NULL, refs, NULL );
 
-               ber_bvecfree( refs );
+               if ( refs ) bvarray_free( refs );
                free( matched_dn );
 
                return( -1 );
@@ -296,12 +295,12 @@ ldbm_back_modify(
     if ( !manageDSAit && is_entry_referral( e ) ) {
                /* parent is a referral, don't allow add */
                /* parent is an alias, don't allow add */
-               struct berval **refs = get_entry_referrals( be,
-                       conn, op, e, dn, LDAP_SCOPE_DEFAULT );
+               BVarray refs = get_entry_referrals( be,
+                       conn, op, e );
 
 #ifdef NEW_LOGGING
                LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
-                          "ldbm_back_modify: entry (%s) is referral\n", ndn ));
+                          "ldbm_back_modify: entry (%s) is referral\n", ndn->bv_val ));
 #else
                Debug( LDAP_DEBUG_TRACE, "entry is referral\n", 0,
                    0, 0 );
@@ -311,13 +310,13 @@ ldbm_back_modify(
                send_ldap_result( conn, op, LDAP_REFERRAL,
                    e->e_dn, NULL, refs, NULL );
 
-               ber_bvecfree( refs );
+               if ( refs ) bvarray_free( refs );
 
                goto error_return;
        }
        
        /* Modify the entry */
-       rc = ldbm_modify_internal( be, conn, op, ndn, modlist, e,
+       rc = ldbm_modify_internal( be, conn, op, ndn->bv_val, modlist, e,
                &text, textbuf, textlen );
 
        if( rc != LDAP_SUCCESS ) {
@@ -370,33 +369,33 @@ add_values(
                        return LDAP_INAPPROPRIATE_MATCHING;
                }
 
-               for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+               for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
                        int rc;
                        int j;
                        const char *text = NULL;
-                       struct berval *asserted;
+                       struct berval asserted;
 
                        rc = value_normalize( mod->sm_desc,
                                SLAP_MR_EQUALITY,
-                               mod->sm_bvalues[i],
+                               &mod->sm_bvalues[i],
                                &asserted,
                                &text );
 
                        if( rc != LDAP_SUCCESS ) return rc;
 
-                       for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+                       for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
                                int match;
                                int rc = value_match( &match, mod->sm_desc, mr,
                                        SLAP_MR_VALUE_SYNTAX_MATCH,
-                                       a->a_vals[j], asserted, &text );
+                                       &a->a_vals[j], &asserted, &text );
 
                                if( rc == LDAP_SUCCESS && match == 0 ) {
-                                       ber_bvfree( asserted );
+                                       free( asserted.bv_val );
                                        return LDAP_TYPE_OR_VALUE_EXISTS;
                                }
                        }
 
-                       ber_bvfree( asserted );
+                       free( asserted.bv_val );
                }
        }
 
@@ -456,26 +455,26 @@ delete_values(
        }
 
        /* find each value to delete */
-       for ( i = 0; mod->sm_bvalues[i] != NULL; i++ ) {
+       for ( i = 0; mod->sm_bvalues[i].bv_val != NULL; i++ ) {
                int rc;
                const char *text = NULL;
 
-               struct berval *asserted;
+               struct berval asserted;
 
                rc = value_normalize( mod->sm_desc,
                        SLAP_MR_EQUALITY,
-                       mod->sm_bvalues[i],
+                       &mod->sm_bvalues[i],
                        &asserted,
                        &text );
 
                if( rc != LDAP_SUCCESS ) return rc;
 
                found = 0;
-               for ( j = 0; a->a_vals[j] != NULL; j++ ) {
+               for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
                        int match;
                        int rc = value_match( &match, mod->sm_desc, mr,
                                SLAP_MR_VALUE_SYNTAX_MATCH,
-                               a->a_vals[j], asserted, &text );
+                               &a->a_vals[j], &asserted, &text );
 
                        if( rc == LDAP_SUCCESS && match != 0 ) {
                                continue;
@@ -485,16 +484,16 @@ delete_values(
                        found = 1;
 
                        /* delete it */
-                       ber_bvfree( a->a_vals[j] );
-                       for ( k = j + 1; a->a_vals[k] != NULL; k++ ) {
+                       free( a->a_vals[j].bv_val );
+                       for ( k = j + 1; a->a_vals[k].bv_val != NULL; k++ ) {
                                a->a_vals[k - 1] = a->a_vals[k];
                        }
-                       a->a_vals[k - 1] = NULL;
+                       a->a_vals[k - 1].bv_val = NULL;
 
                        break;
                }
 
-               ber_bvfree( asserted );
+               free( asserted.bv_val );
 
                /* looked through them all w/o finding it */
                if ( ! found ) {
@@ -512,7 +511,7 @@ delete_values(
        }
 
        /* if no values remain, delete the entire attribute */
-       if ( a->a_vals[0] == NULL ) {
+       if ( a->a_vals[0].bv_val == NULL ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
                           "delete_values: removing entire attribute %s\n", desc ));