]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/tools.c
Add a default case with assert() just in case.
[openldap] / servers / slapd / back-ldbm / tools.c
index a497be625b458a5a304fe634325026af956881af..f8858c485bc507920a8d45d90875f70103685f89 100644 (file)
@@ -1,7 +1,7 @@
 /* tools.c - tools for slap tools */
 /* $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
  */
 
@@ -166,7 +166,8 @@ Entry* ldbm_tool_entry_get( BackendDB *be, ID id )
 
 ID ldbm_tool_entry_put(
        BackendDB *be,
-       Entry *e )
+       Entry *e,
+       struct berval *text )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        Datum key, data;
@@ -176,7 +177,12 @@ ID ldbm_tool_entry_put(
        assert( slapMode & SLAP_TOOL_MODE );
        assert( id2entry != NULL );
 
+       assert( text );
+       assert( text->bv_val );
+       assert( text->bv_val[0] == '\0' );
+
        if ( next_id_get( be, &id ) || id == NOID ) {
+               strncpy( text->bv_val, "unable to get nextid", text->bv_len );
                return NOID;
        }
 
@@ -190,8 +196,9 @@ ID ldbm_tool_entry_put(
                e->e_id, e->e_dn, 0 );
 #endif
 
-       if ( dn2id( be, e->e_ndn, &id ) ) {
+       if ( dn2id( be, &e->e_nname, &id ) ) {
                /* something bad happened to ldbm cache */
+               strncpy( text->bv_val, "ldbm cache corrupted", text->bv_len );
                return NOID;
        }
 
@@ -205,16 +212,19 @@ ID ldbm_tool_entry_put(
                        "<= ldbm_tool_entry_put: \"%s\" already exists (id=%ld)\n",
                        e->e_ndn, id, 0 );
 #endif
+               strncpy( text->bv_val, "already exists", text->bv_len );
                return NOID;
        }
 
        rc = index_entry_add( be, e, e->e_attrs );
        if( rc != 0 ) {
+               strncpy( text->bv_val, "index add failed", text->bv_len );
                return NOID;
        }
 
-       rc = dn2id_add( be, e->e_ndn, e->e_id );
+       rc = dn2id_add( be, &e->e_nname, e->e_id );
        if( rc != 0 ) {
+               strncpy( text->bv_val, "dn2id add failed", text->bv_len );
                return NOID;
        }
 
@@ -236,7 +246,8 @@ ID ldbm_tool_entry_put(
        rc = ldbm_cache_store( id2entry, key, data, LDBM_REPLACE );
 
        if( rc != 0 ) {
-               (void) dn2id_delete( be, e->e_ndn, e->e_id );
+               (void) dn2id_delete( be, &e->e_nname, e->e_id );
+               strncpy( text->bv_val, "cache store failed", text->bv_len );
                return NOID;
        }
 
@@ -290,7 +301,7 @@ int ldbm_tool_entry_reindex(
                id, e->e_dn, 0 );
 #endif
 
-       dn2id_add( be, e->e_ndn, e->e_id );
+       dn2id_add( be, &e->e_nname, e->e_id );
        rc = index_entry_add( be, e, e->e_attrs );
 
        entry_free( e );