/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
* Portions Copyright 1998-2003 Kurt D. Zeilenga.
* Portions Copyright 2003 IBM Corporation.
* All rights reserved.
#include <ac/string.h>
#include "slapcommon.h"
+#include "ldif.h"
+
+static volatile sig_atomic_t gotsig;
+
+static RETSIGTYPE
+slapcat_sig( int sig )
+{
+ gotsig=1;
+}
int
slapcat( int argc, char **argv )
slap_tool_init( progname, SLAPCAT, argc, argv );
+#ifdef SIGPIPE
+ (void) SIGNAL( SIGPIPE, slapcat_sig );
+#endif
+#ifdef SIGHUP
+ (void) SIGNAL( SIGHUP, slapcat_sig );
+#endif
+ (void) SIGNAL( SIGINT, slapcat_sig );
+ (void) SIGNAL( SIGTERM, slapcat_sig );
+
if( !be->be_entry_open ||
!be->be_entry_close ||
!be->be_entry_first ||
exit( EXIT_FAILURE );
}
+ op.o_bd = be;
for ( id = be->be_entry_first( be );
id != NOID;
id = be->be_entry_next( be ) )
{
char *data;
int len;
- Entry* e = be->be_entry_get( be, id );
- op.o_bd = be;
+ Entry* e;
+ if ( gotsig )
+ break;
+
+ e = be->be_entry_get( be, id );
if ( e == NULL ) {
printf("# no data for entry id=%08lx\n\n", (long) id );
rc = EXIT_FAILURE;
}
}
- if ( retrieve_ctxcsn == 0 ) {
- if ( is_entry_syncProviderSubentry( e ) ) {
- be_entry_release_r( &op, e );
- continue;
- }
- }
-
- if ( retrieve_synccookie == 0 ) {
- if ( is_entry_syncConsumerSubentry( e ) ) {
- be_entry_release_r( &op, e );
- continue;
- }
- }
-
if( verbose ) {
printf( "# id=%08lx\n", (long) id );
}
break;
}
- fputs( data, ldiffp );
- fputs( "\n", ldiffp );
+ if ( fputs( data, ldiffp->fp ) == EOF ||
+ fputs( "\n", ldiffp->fp ) == EOF ) {
+ fprintf(stderr, "%s: error writing output.\n",
+ progname);
+ rc = EXIT_FAILURE;
+ break;
+ }
}
be->be_entry_close( be );
- slap_tool_destroy();
+ if ( slap_tool_destroy())
+ rc = EXIT_FAILURE;
return rc;
}