]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/tools/slapadd.c
Use IPV6_V6ONLY on IPv6 sockets if available. This way we only get IPv6
[openldap] / servers / slapd / tools / slapadd.c
index 55e0d4fe086ed6974cca8fb202fe663eb67ed7fd..d14114c50c0e18a60a6b5164a9b4505a28032342 100644 (file)
@@ -52,9 +52,11 @@ main( int argc, char **argv )
        }
 
        while( ldif_read_record( ldiffp, &lineno, &buf, &lmax ) ) {
-               ID id;
                Entry *e = str2entry( buf );
-               struct berval bvtext = { textlen, textbuf };
+               struct berval bvtext;
+
+               bvtext.bv_len = textlen;
+               bvtext.bv_val = textbuf;
 
                if( e == NULL ) {
                        fprintf( stderr, "%s: could not parse entry (line=%d)\n",
@@ -81,12 +83,12 @@ main( int argc, char **argv )
                        fprintf( stderr, "%s: line %d: "
                                "database (%s) not configured to hold \"%s\"\n",
                                progname, lineno,
-                               be ? be->be_suffix[0]->bv_val : "<none>",
+                               be ? be->be_suffix[0].bv_val : "<none>",
                                e->e_dn );
                        fprintf( stderr, "%s: line %d: "
                                "database (%s) not configured to hold \"%s\"\n",
                                progname, lineno,
-                               be ? be->be_nsuffix[0]->bv_val : "<none>",
+                               be ? be->be_nsuffix[0].bv_val : "<none>",
                                e->e_ndn );
                        rc = EXIT_FAILURE;
                        entry_free( e );
@@ -113,7 +115,8 @@ main( int argc, char **argv )
                        if( sc == NULL ) {
                                struct berval vals[2];
 
-                               int ret = structural_class( oc->a_vals, vals,
+                               /* int ret = */ 
+                                       structural_class( oc->a_vals, vals,
                                        NULL, &text, textbuf, textlen );
 
                                if( vals[0].bv_len == 0 ) {
@@ -146,20 +149,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 );