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 );
57 if ( retrieve_ctxcsn == 0 ) {
58 if ( is_entry_syncProviderSubentry( e ) ) {
59 be_entry_release_r( &op, e );
64 if ( retrieve_synccookie == 0 ) {
65 if ( is_entry_syncConsumerSubentry( e ) ) {
66 be_entry_release_r( &op, e );
72 printf( "# id=%08lx\n", (long) id );
76 printf("# no data for entry id=%08lx\n\n", (long) id );
78 if( continuemode ) continue;
82 data = entry2str( e, &len );
83 be_entry_release_r( &op, e );
86 printf("# bad data for entry id=%08lx\n\n", (long) id );
88 if( continuemode ) continue;
92 fputs( data, ldiffp );
93 fputs( "\n", ldiffp );
96 be->be_entry_close( be );