]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/tools.c
zap charray
[openldap] / servers / slapd / back-ldbm / tools.c
index 96ce80f562fec545781ee4e2ae800cef23dac5d0..5d0855bfe53ed749a95d6268b5d6b0854fa572e8 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
  */
 
@@ -47,8 +47,8 @@ int ldbm_tool_entry_open(
        if ( (id2entry = ldbm_cache_open( be, "id2entry", LDBM_SUFFIX, flags ))
            == NULL ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "backend", LDAP_LEVEL_CRIT,
-                          "Could not open/create id2entry%s\n", LDBM_SUFFIX ));
+               LDAP_LOG( BACK_LDBM, CRIT,
+                          "Could not open/create id2entry%s\n", LDBM_SUFFIX, 0, 0 );
 #else
                Debug( LDAP_DEBUG_ANY, "Could not open/create id2entry" LDBM_SUFFIX "\n",
                    0, 0, 0 );
@@ -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,15 +177,20 @@ 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;
        }
 
        e->e_id = li->li_nextid++;
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
-               "ldbm_tool_entry_put: (%s)%ld\n", e->e_dn, e->e_id ));
+       LDAP_LOG( BACK_LDBM, ENTRY,
+               "ldbm_tool_entry_put: (%s)%ld\n", e->e_dn, e->e_id ,0 );
 #else
        Debug( LDAP_DEBUG_TRACE, "=> ldbm_tool_entry_put( %ld, \"%s\" )\n",
                e->e_id, e->e_dn, 0 );
@@ -192,29 +198,33 @@ ID ldbm_tool_entry_put(
 
        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;
        }
 
        if( id != NOID ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
+               LDAP_LOG( BACK_LDBM, ENTRY,
                        "ldbm_tool_entry_put: \"%s\" already exists (id=%ld)\n",
-                       e->e_dn, id ));
+                       e->e_dn, id, 0 );
 #else
                Debug( LDAP_DEBUG_TRACE,
                        "<= 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_nname, e->e_id );
        if( rc != 0 ) {
+               strncpy( text->bv_val, "dn2id add failed", text->bv_len );
                return NOID;
        }
 
@@ -237,6 +247,7 @@ ID ldbm_tool_entry_put(
 
        if( rc != 0 ) {
                (void) dn2id_delete( be, &e->e_nname, e->e_id );
+               strncpy( text->bv_val, "cache store failed", text->bv_len );
                return NOID;
        }
 
@@ -251,8 +262,8 @@ int ldbm_tool_entry_reindex(
        Entry *e;
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
-                  "ldbm_tool_entry_reindex: ID=%ld\n", (long)id ));
+       LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_tool_entry_reindex: ID=%ld\n", 
+               (long)id, 0, 0 );
 #else
        Debug( LDAP_DEBUG_ARGS, "=> ldbm_tool_entry_reindex( %ld )\n",
                (long) id, 0, 0 );
@@ -263,9 +274,9 @@ int ldbm_tool_entry_reindex(
 
        if( e == NULL ) {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
-                          "ldbm_tool_entry_reindex: could not locate id %ld\n", 
-                          (long)id ));
+               LDAP_LOG( BACK_LDBM, INFO,
+                  "ldbm_tool_entry_reindex: could not locate id %ld\n", 
+                  (long)id, 0, 0  );
 #else
                Debug( LDAP_DEBUG_ANY,
                        "ldbm_tool_entry_reindex:: could not locate id=%ld\n",
@@ -283,8 +294,8 @@ int ldbm_tool_entry_reindex(
         */
 
 #ifdef NEW_LOGGING
-       LDAP_LOG(( "backend", LDAP_LEVEL_ENTRY,
-                  "ldbm_tool_entry_reindex: (%s) %ld\n", e->e_dn, id ));
+       LDAP_LOG( BACK_LDBM, ENTRY,
+                  "ldbm_tool_entry_reindex: (%s) %ld\n", e->e_dn, id, 0 );
 #else
        Debug( LDAP_DEBUG_TRACE, "=> ldbm_tool_entry_reindex( %ld, \"%s\" )\n",
                id, e->e_dn, 0 );