From: Kurt Zeilenga Date: Wed, 2 May 2001 19:52:09 +0000 (+0000) Subject: Clean up some logic, based upon Novell patches X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1456 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=db71f0c8a76eda38d15c5c8f5d69f5e214d1870b;p=openldap Clean up some logic, based upon Novell patches --- diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index d4e74126b9..844fed7277 100644 --- a/clients/tools/ldapdelete.c +++ b/clients/tools/ldapdelete.c @@ -626,18 +626,23 @@ main( int argc, char **argv ) } rc = 0; + if ( fp == NULL ) { - for ( ; optind < argc; ++optind ) { - rc = dodelete( ld, argv[ optind ] ); - } - } else { - while ((rc == 0 || contoper) && fgets(buf, sizeof(buf), fp) != NULL) { - buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */ - if ( *buf != '\0' ) { - rc = dodelete( ld, buf ); - } + for ( ; optind < argc; ++optind ) { + rc = dodelete( ld, argv[ optind ] ); + + /* Stop on error and no -c option */ + if( rc != 0 && contoper == 0) break; + } + } else { + while ((rc == 0 || contoper) && fgets(buf, sizeof(buf), fp) != NULL) { + buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */ + + if ( *buf != '\0' ) { + rc = dodelete( ld, buf ); + } + } } - } ldap_unbind( ld ); diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index f919d4e2d1..d75f0627dc 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -48,7 +48,7 @@ static char *sasl_mech = NULL; static char *sasl_secprops = NULL; #endif static int use_tls = 0; -static int ldapadd, replace, not, verbose, contoper, force; +static int ldapadd, not, verbose, contoper, force; static LDAP *ld = NULL; #define LDAPMOD_MAXLINE 4096 @@ -102,7 +102,6 @@ usage( const char *prog ) " specified by \"-f file\".\n" "Add or modify options:\n" " -a add values (default%s)\n" -" -r replace values\n" " -F force all changes records to be used\n" "Common options:\n" @@ -180,9 +179,6 @@ main( int argc, char **argv ) case 'F': /* force all changes records to be used */ force = 1; break; - case 'r': /* default is to replace rather than add values */ - replace = 1; - break; /* Common Options */ case 'C': @@ -376,6 +372,9 @@ main( int argc, char **argv ) prog ); return( EXIT_FAILURE ); #endif + case 'r': /* replace (obsolete) */ + break; + case 'R': #ifdef HAVE_CYRUS_SASL if( sasl_realm != NULL ) { @@ -848,7 +847,7 @@ process_ldif_rec( char *rbuf, int count ) addmodifyop( &pmods, modop, val.bv_val, NULL ); goto end_line; } else { /* no modify op: use default */ - modop = replace ? LDAP_MOD_REPLACE : LDAP_MOD_ADD; + modop = ldapadd ? LDAP_MOD_ADD : LDAP_MOD_REPLACE; } }