3 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 #include <ac/stdlib.h>
12 #include <ac/socket.h>
13 #include <ac/string.h>
15 #include "slapcommon.h"
18 main( int argc, char **argv )
21 int rc = EXIT_SUCCESS;
24 slap_tool_init( "slapcat", SLAPCAT, argc, argv );
26 if( !be->be_entry_open ||
27 !be->be_entry_close ||
28 !be->be_entry_first ||
32 fprintf( stderr, "%s: database doesn't support necessary operations.\n",
37 if( be->be_entry_open( be, 0 ) != 0 ) {
38 fprintf( stderr, "%s: could not open database.\n",
43 for ( id = be->be_entry_first( be );
45 id = be->be_entry_next( be ) )
49 Entry* e = be->be_entry_get( be, id );
52 if( sub_ndn.bv_len && !dnIsSuffix( &e->e_nname, &sub_ndn ) ) {
53 be_entry_release_r( &op, e );
58 printf( "# id=%08lx\n", (long) id );
62 printf("# no data for entry id=%08lx\n\n", (long) id );
64 if( continuemode ) continue;
68 data = entry2str( e, &len );
69 be_entry_release_r( &op, e );
72 printf("# bad data for entry id=%08lx\n\n", (long) id );
74 if( continuemode ) continue;
78 fputs( data, ldiffp );
79 fputs( "\n", ldiffp );
82 be->be_entry_close( be );