mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-02-23 14:09:39 +08:00
ITS#10183 ldapmodify: add jump to lineno option
This commit is contained in:
parent
a979b396d1
commit
01a1c1293b
@ -99,6 +99,7 @@ static struct timeval interval_tv;
|
||||
static int txn = 0;
|
||||
static int txnabort = 0;
|
||||
struct berval *txn_id = NULL;
|
||||
static unsigned long jumpline;
|
||||
|
||||
void
|
||||
usage( void )
|
||||
@ -116,6 +117,7 @@ usage( void )
|
||||
" (! indicate s criticality)\n"));
|
||||
fprintf( stderr, _(" -f file read operations from `file'\n"));
|
||||
fprintf( stderr, _(" -i time wait `time' microseconds between operations\n"));
|
||||
fprintf( stderr, _(" -j lineno jump to lineno before processing\n"));
|
||||
fprintf( stderr, _(" -M enable Manage DSA IT control (-MM to make critical)\n"));
|
||||
fprintf( stderr, _(" -P version protocol version (default: 3)\n"));
|
||||
fprintf( stderr,
|
||||
@ -128,7 +130,7 @@ usage( void )
|
||||
|
||||
|
||||
const char options[] = "aE:rS:"
|
||||
"cd:D:e:f:H:i:IMnNO:o:P:QR:U:vVw:WxX:y:Y:Z";
|
||||
"cd:D:e:f:H:i:Ij:MnNO:o:P:QR:U:vVw:WxX:y:Y:Z";
|
||||
|
||||
int
|
||||
handle_private_option( int i )
|
||||
@ -203,6 +205,17 @@ handle_private_option( int i )
|
||||
}
|
||||
break;
|
||||
|
||||
case 'j': /* jump */
|
||||
{
|
||||
char *next;
|
||||
jumpline = strtoul( optarg, &next, 10 );
|
||||
if ( !next || *next ) {
|
||||
fprintf( stderr, "%s: unable to parse jump line number \"%s\"\n", prog, optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r': /* replace (obsolete) */
|
||||
break;
|
||||
|
||||
@ -302,6 +315,9 @@ main( int argc, char **argv )
|
||||
while (( rc == 0 || contoper ) && ( ldifrc = ldif_read_record( ldiffp, &nextline,
|
||||
&rbuf, &lmax )) > 0 )
|
||||
{
|
||||
if ( lineno < jumpline )
|
||||
goto next;
|
||||
|
||||
if ( rejfp ) {
|
||||
len = strlen( rbuf );
|
||||
if (( rejbuf = (char *)ber_memalloc( len+1 )) == NULL ) {
|
||||
@ -317,11 +333,10 @@ main( int argc, char **argv )
|
||||
}
|
||||
|
||||
rc = process_ldif_rec( rbuf, lineno );
|
||||
lineno = nextline+1;
|
||||
|
||||
if ( rc ) retval = rc;
|
||||
if ( rc && rejfp ) {
|
||||
fprintf(rejfp, _("# Error: %s (%d)"), ldap_err2string(rc), rc);
|
||||
fprintf(rejfp, _("# Error: %s (%d) (line=%lu)"), ldap_err2string(rc), rc, lineno);
|
||||
|
||||
matched_msg = NULL;
|
||||
ldap_get_option(ld, LDAP_OPT_MATCHED_DN, &matched_msg);
|
||||
@ -344,6 +359,9 @@ main( int argc, char **argv )
|
||||
}
|
||||
|
||||
if (rejfp) ber_memfree( rejbuf );
|
||||
|
||||
next:
|
||||
lineno = nextline+1;
|
||||
}
|
||||
ber_memfree( rbuf );
|
||||
|
||||
|
@ -23,6 +23,8 @@ ldapmodify, ldapadd \- LDAP modify entry and LDAP add entry tools
|
||||
[\c
|
||||
.BI \-i \ time\fR]
|
||||
[\c
|
||||
.BI \-j \ lineno\fR]
|
||||
[\c
|
||||
.BI \-S \ file\fR]
|
||||
[\c
|
||||
.BR \-M [ M ]]
|
||||
@ -81,6 +83,8 @@ ldapmodify, ldapadd \- LDAP modify entry and LDAP add entry tools
|
||||
[\c
|
||||
.BI \-i \ time\fR]
|
||||
[\c
|
||||
.BI \-j \ lineno\fR]
|
||||
[\c
|
||||
.BI \-S \ file\fR]
|
||||
[\c
|
||||
.BR \-M [ M ]]
|
||||
@ -178,6 +182,11 @@ standard input.
|
||||
.BI \-i \ time
|
||||
Wait \fItime\fP microseconds before issuing an operation.
|
||||
.TP
|
||||
.BI \-j \ lineno
|
||||
Jump to the specified line number in the LDIF file before processing any entries.
|
||||
This allows a load that was aborted due to errors in the input LDIF to be resumed
|
||||
after the errors are corrected.
|
||||
.TP
|
||||
.BI \-S \ file
|
||||
Add or change records which were skipped due to an error are written to \fIfile\fP
|
||||
and the error message returned by the server is added as a comment. Most useful in
|
||||
|
Loading…
Reference in New Issue
Block a user