]> git.sur5r.net Git - openldap/commitdiff
ITS#4555 add "-j" option to jump to line of LDIF file before processing.
authorHoward Chu <hyc@openldap.org>
Mon, 29 May 2006 02:41:06 +0000 (02:41 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 29 May 2006 02:41:06 +0000 (02:41 +0000)
Fixed line number in error messages to give the line number of the beginning
of the offending entry.

servers/slapd/slapadd.c
servers/slapd/slapcommon.c
servers/slapd/slapcommon.h

index 11cf55f371a93a12a7b458070c4d9120079a2421..c03724002f8afc084dec626e8889184d1c3c933d 100644 (file)
@@ -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 );
 
                /*
index 1a1ea03441f6e0e5d05edf724f2dc5afe366d571..b9ac4f1beeffe170a9d03e2c55073c4a64948d7a 100644 (file)
@@ -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;
index 9584986915b176593b9115090fac21393b9c07df..a5da19eb763510b2a178679a7b0ed37196ed4a82 100644 (file)
@@ -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