2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2003 The OpenLDAP Foundation.
5 * Portions Copyright 1998-2003 Kurt D. Zeilenga.
6 * Portions Copyright 2003 IBM Corporation.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by Kurt Zeilenga for inclusion
19 * in OpenLDAP Software. Additional signficant contributors include
27 #include <ac/stdlib.h>
29 #include <ac/socket.h>
30 #include <ac/string.h>
32 #include "slapcommon.h"
35 main( int argc, char **argv )
38 int rc = EXIT_SUCCESS;
41 slap_tool_init( "slapcat", SLAPCAT, argc, argv );
43 if( !be->be_entry_open ||
44 !be->be_entry_close ||
45 !be->be_entry_first ||
49 fprintf( stderr, "%s: database doesn't support necessary operations.\n",
54 if( be->be_entry_open( be, 0 ) != 0 ) {
55 fprintf( stderr, "%s: could not open database.\n",
60 for ( id = be->be_entry_first( be );
62 id = be->be_entry_next( be ) )
66 Entry* e = be->be_entry_get( be, id );
70 printf("# no data for entry id=%08lx\n\n", (long) id );
72 if( continuemode ) continue;
76 if( sub_ndn.bv_len && !dnIsSuffix( &e->e_nname, &sub_ndn ) ) {
77 be_entry_release_r( &op, e );
81 if ( retrieve_ctxcsn == 0 ) {
82 if ( is_entry_syncProviderSubentry( e ) ) {
83 be_entry_release_r( &op, e );
88 if ( retrieve_synccookie == 0 ) {
89 if ( is_entry_syncConsumerSubentry( e ) ) {
90 be_entry_release_r( &op, e );
96 printf( "# id=%08lx\n", (long) id );
99 data = entry2str( e, &len );
100 be_entry_release_r( &op, e );
102 if ( data == NULL ) {
103 printf("# bad data for entry id=%08lx\n\n", (long) id );
105 if( continuemode ) continue;
109 fputs( data, ldiffp );
110 fputs( "\n", ldiffp );
113 be->be_entry_close( be );