]> git.sur5r.net Git - openldap/commitdiff
Check the ldif file without actually creating the db (but inits the files;
authorPierangelo Masarati <ando@openldap.org>
Mon, 28 Jan 2002 20:36:29 +0000 (20:36 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 28 Jan 2002 20:36:29 +0000 (20:36 +0000)
maybe I should trim this also).  Useful to check LARGE ldif files which
will require TONS on indices without failing at the very last entry for
a silly typo after 45 min. or more :)

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

index 55e0d4fe086ed6974cca8fb202fe663eb67ed7fd..b6b05bdae7818fe84e300369a81ed0ab32ea896e 100644 (file)
@@ -52,7 +52,6 @@ main( int argc, char **argv )
        }
 
        while( ldif_read_record( ldiffp, &lineno, &buf, &lmax ) ) {
-               ID id;
                Entry *e = str2entry( buf );
                struct berval bvtext = { textlen, textbuf };
 
@@ -146,20 +145,25 @@ main( int argc, char **argv )
                        }
                }
 
-               id = be->be_entry_put( be, e, &bvtext );
-               if( id == NOID ) {
-                       fprintf( stderr, "%s: could not add entry dn=\"%s\" (line=%d): %s\n",
-                               progname, e->e_dn, lineno, bvtext.bv_val );
-                       rc = EXIT_FAILURE;
-                       entry_free( e );
-                       if( continuemode ) continue;
-                       break;
-
-               }
+               if (!dryrun) {
+                       ID id = be->be_entry_put( be, e, &bvtext );
+                       if( id == NOID ) {
+                               fprintf( stderr, "%s: could not add entry dn=\"%s\" (line=%d): %s\n",
+                                       progname, e->e_dn, lineno, bvtext.bv_val );
+                               rc = EXIT_FAILURE;
+                               entry_free( e );
+                               if( continuemode ) continue;
+                               break;
+                       }
                
-               if ( verbose ) {
-                       fprintf( stderr, "added: \"%s\" (%08lx)\n",
-                               e->e_dn, (long) id );
+                       if ( verbose ) {
+                               fprintf( stderr, "added: \"%s\" (%08lx)\n",
+                                       e->e_dn, (long) id );
+                       }
+               } else {
+                       if ( verbose ) {
+                               fprintf( stderr, "(dry) added: \"%s\"\n", e->e_dn );
+                       }
                }
 
                entry_free( e );
index 8343877c8e50a0b5d7baa71f69bd1254ad77ef47..bcea08993ff788d556dfc9a97ebbd94afb4f20d9 100644 (file)
@@ -25,6 +25,7 @@ int           truncatemode = 0;
 int            verbose         = 0;
 int            continuemode = 0;
 int            nosubordinates = 0;
+int            dryrun = 0;
 
 char   *ldiffile       = NULL;
 FILE   *ldiffp         = NULL;
@@ -97,7 +98,7 @@ slap_tool_init(
 
        switch( tool ) {
        case SLAPADD:
-               options = "b:cd:f:l:n:tv";
+               options = "b:cd:f:l:n:tuv";
                break;
 
        case SLAPINDEX:
@@ -148,6 +149,10 @@ slap_tool_init(
                        mode |= SLAP_TRUNCATE_MODE;
                        break;
 
+               case 'u':       /* dry run */
+                       dryrun++;
+                       break;
+
                case 'v':       /* turn on verbose */
                        verbose++;
                        break;
index 2dd0c485448e93e94881c4379918497e29801f58..aef22fcc62ec40dd8fb71237cc2d17e1e932db47 100644 (file)
@@ -26,6 +26,7 @@ extern        int             appendmode;
 extern int             verbose;
 extern int             continuemode;
 extern int             nosubordinates;
+extern int             dryrun;
 
 extern char    *ldiffile;
 extern FILE    *ldiffp;