]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/tools/slapcat.c
slapi-plugin.h goes in include
[openldap] / servers / slapd / tools / slapcat.c
index f5d035e4abf5d8ecff355d6b6128e7f1834e35b4..96fd0c9caf17b9e71feb834e0a753a8b1e72341d 100644 (file)
@@ -1,5 +1,6 @@
+/* $OpenLDAP$ */
 /*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 #include "portable.h"
@@ -21,12 +22,10 @@ main( int argc, char **argv )
 
        slap_tool_init( "slapcat", SLAPCAT, argc, argv );
 
-       slap_startup( be );
-
-       if( !be->be_entry_open &&
-               !be->be_entry_close &&
-               !be->be_entry_first &&
-               !be->be_entry_next &&
+       if( !be->be_entry_open ||
+               !be->be_entry_close ||
+               !be->be_entry_first ||
+               !be->be_entry_next ||
                !be->be_entry_get )
        {
                fprintf( stderr, "%s: database doesn't support necessary operations.\n",
@@ -55,10 +54,19 @@ main( int argc, char **argv )
                if ( e == NULL ) {
                        printf("# no data for entry id=%08lx\n\n", (long) id );
                        rc = EXIT_FAILURE;
-                       continue;
+                       if( continuemode ) continue;
+                       break;
                }
 
                data = entry2str( e, &len );
+               be_entry_release_r( be, 0L, 0L, e );
+
+               if ( data == NULL ) {
+                       printf("# bad data for entry id=%08lx\n\n", (long) id );
+                       rc = EXIT_FAILURE;
+                       if( continuemode ) continue;
+                       break;
+               }
 
                fputs( data, ldiffp );
                fputs( "\n", ldiffp );
@@ -66,8 +74,6 @@ main( int argc, char **argv )
 
        be->be_entry_close( be );
 
-       slap_shutdown( be );
-       slap_destroy();
-
+       slap_tool_destroy();
        return rc;
 }