X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fslapcat.c;h=930feb7a677723b438b19bfa0667d7c509a05a05;hb=543c588772b22a029b60e72e45e68032935ecd54;hp=7daeaa645a185f0c25be1699e3cbad8cc2c07793;hpb=cdd94c7aa16636d564c018fa27a5428e906fad47;p=openldap diff --git a/servers/slapd/slapcat.c b/servers/slapd/slapcat.c index 7daeaa645a..930feb7a67 100644 --- a/servers/slapd/slapcat.c +++ b/servers/slapd/slapcat.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2004 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * Portions Copyright 1998-2003 Kurt D. Zeilenga. * Portions Copyright 2003 IBM Corporation. * All rights reserved. @@ -30,6 +30,15 @@ #include #include "slapcommon.h" +#include "ldif.h" + +static int gotsig; + +static RETSIGTYPE +slapcat_sig( int sig ) +{ + gotsig=1; +} int slapcat( int argc, char **argv ) @@ -41,6 +50,15 @@ 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 || @@ -58,15 +76,19 @@ slapcat( int argc, char **argv ) 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; @@ -87,20 +109,6 @@ slapcat( int argc, char **argv ) } } - 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 ); } @@ -115,8 +123,8 @@ slapcat( int argc, char **argv ) break; } - fputs( data, ldiffp ); - fputs( "\n", ldiffp ); + fputs( data, ldiffp->fp ); + fputs( "\n", ldiffp->fp ); } be->be_entry_close( be );