Clean up some logic, based upon Novell patches

This commit is contained in:
Kurt Zeilenga 2001-05-02 19:52:09 +00:00
parent f90bb83986
commit db71f0c8a7
2 changed files with 20 additions and 16 deletions

View File

@ -626,18 +626,23 @@ main( int argc, char **argv )
}
rc = 0;
if ( fp == NULL ) {
for ( ; optind < argc; ++optind ) {
rc = dodelete( ld, argv[ optind ] );
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 );
}
}
}
} 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 );

View File

@ -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;
}
}