mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
ITS#4555 add "-j" option to jump to line of LDIF file before processing.
Fixed line number in error messages to give the line number of the beginning of the offending entry.
This commit is contained in:
parent
795841b5a4
commit
59ca2d198f
@ -62,7 +62,7 @@ slapadd( int argc, char **argv )
|
||||
int match;
|
||||
int ret;
|
||||
int checkvals;
|
||||
int lineno;
|
||||
int lineno, nextline;
|
||||
int lmax;
|
||||
int rc = EXIT_SUCCESS;
|
||||
int manage = 0;
|
||||
@ -93,7 +93,7 @@ slapadd( int argc, char **argv )
|
||||
checkvals = (slapMode & SLAP_TOOL_QUICK) ? 0 : 1;
|
||||
|
||||
lmax = 0;
|
||||
lineno = 0;
|
||||
nextline = 0;
|
||||
|
||||
if( !dryrun && be->be_entry_open( be, 1 ) != 0 ) {
|
||||
fprintf( stderr, "%s: could not open database.\n",
|
||||
@ -106,7 +106,13 @@ slapadd( int argc, char **argv )
|
||||
maxcsn.bv_len = 0;
|
||||
}
|
||||
|
||||
while( ldif_read_record( ldiffp, &lineno, &buf, &lmax ) ) {
|
||||
/* nextline is the line number of the end of the current entry */
|
||||
for( lineno=1; ldif_read_record( ldiffp, &nextline, &buf, &lmax );
|
||||
lineno=nextline+1 ) {
|
||||
|
||||
if ( lineno < jumpline )
|
||||
continue;
|
||||
|
||||
Entry *e = str2entry2( buf, checkvals );
|
||||
|
||||
/*
|
||||
|
@ -71,7 +71,7 @@ usage( int tool, const char *progname )
|
||||
|
||||
case SLAPADD:
|
||||
options = " [-c]\n\t[-g] [-n databasenumber | -b suffix]\n"
|
||||
"\t[-l ldiffile] [-q] [-u] [-s] [-w]\n";
|
||||
"\t[-l ldiffile] [-j linenumber] [-q] [-u] [-s] [-w]\n";
|
||||
break;
|
||||
|
||||
case SLAPAUTH:
|
||||
@ -241,7 +241,7 @@ slap_tool_init(
|
||||
|
||||
switch( tool ) {
|
||||
case SLAPADD:
|
||||
options = "b:cd:f:F:gl:n:o:qstuvw";
|
||||
options = "b:cd:f:F:gj:l:n:o:qstuvw";
|
||||
break;
|
||||
|
||||
case SLAPCAT:
|
||||
@ -331,6 +331,12 @@ slap_tool_init(
|
||||
use_glue = 0;
|
||||
break;
|
||||
|
||||
case 'j': /* jump to linenumber */
|
||||
if ( lutil_atoi( &jumpline, optarg ) ) {
|
||||
usage( tool, progname );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l': /* LDIF file */
|
||||
ldiffile = strdup( optarg );
|
||||
break;
|
||||
|
@ -39,6 +39,7 @@ typedef struct tool_vars {
|
||||
int tv_continuemode;
|
||||
int tv_nosubordinates;
|
||||
int tv_dryrun;
|
||||
int tv_jumpline;
|
||||
Filter *tv_filter;
|
||||
struct berval tv_sub_ndn;
|
||||
struct LDIFFP *tv_ldiffp;
|
||||
@ -64,6 +65,7 @@ extern tool_vars tool_globals;
|
||||
|
||||
#define be tool_globals.tv_be
|
||||
#define verbose tool_globals.tv_verbose
|
||||
#define jumpline tool_globals.tv_jumpline
|
||||
#define update_ctxcsn tool_globals.tv_update_ctxcsn
|
||||
#define continuemode tool_globals.tv_continuemode
|
||||
#define nosubordinates tool_globals.tv_nosubordinates
|
||||
|
Loading…
Reference in New Issue
Block a user