]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapcommon.c
reduce code duplication
[openldap] / servers / slapd / slapcommon.c
index a5d4b4f5c954e5d5afc41385f90b6c041e7b2d63..71870e745c068a098c9ca2ef9c889c9da0998edb 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2009 The OpenLDAP Foundation.
+ * Copyright 1998-2010 The OpenLDAP Foundation.
  * Portions Copyright 1998-2003 Kurt D. Zeilenga.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
@@ -92,7 +92,7 @@ usage( int tool, const char *progname )
                break;
 
        case SLAPTEST:
-               options = " [-u]\n";
+               options = " [-n databasenumber] [-u]\n";
                break;
 
        case SLAPSCHEMA:
@@ -268,7 +268,7 @@ slap_tool_init(
                break;
 
        case SLAPTEST:
-               options = "d:f:F:o:Quv";
+               options = "d:f:F:n:o:Quv";
                mode |= SLAP_TOOL_READMAIN | SLAP_TOOL_READONLY;
                break;
 
@@ -608,8 +608,11 @@ slap_tool_init(
        }
 
        switch ( tool ) {
-       case SLAPDN:
        case SLAPTEST:
+               if ( dbnum >= 0 )
+                       goto get_db;
+               /* FALLTHRU */
+       case SLAPDN:
        case SLAPAUTH:
                be = NULL;
                goto startup;
@@ -733,6 +736,7 @@ slap_tool_init(
                exit( EXIT_FAILURE );
 
        } else {
+get_db:
                LDAP_STAILQ_FOREACH( be, &backendDB, be_next ) {
                        if ( dbnum == 0 ) break;
                        dbnum--;
@@ -759,6 +763,11 @@ startup:;
                conffile = NULL;
        }
 
+       if ( confdir != NULL ) {
+               ch_free( confdir );
+               confdir = NULL;
+       }
+
        if ( ldiffile != NULL ) {
                ch_free( ldiffile );
                ldiffile = NULL;