]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/main.c
#include <ac/ctype.h>, needed by last commit
[openldap] / servers / slapd / main.c
index e3b0560f1c01b360c6b7347ff80fbaea05dc6e01..3fc69e45e7c5eba98d00bec579d9d889aa212e62 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <stdio.h>
 
+#include <ac/ctype.h>
 #include <ac/socket.h>
 #include <ac/string.h>
 #include <ac/time.h>
@@ -271,6 +272,14 @@ int main( int argc, char **argv )
 
        slap_sl_mem_init();
 
+       if (( rc = slap_schema_init( )) != 0 ) {
+               Debug( LDAP_DEBUG_ANY,
+                   "schema initialization error\n",
+                   0, 0, 0 );
+
+               MAIN_RETURN(rc);
+       }
+
        serverName = lutil_progname( "slapd", argc, argv );
 
        if ( strcmp( serverName, "slapd" ) ) {
@@ -361,7 +370,7 @@ int main( int argc, char **argv )
                        scp = (struct sync_cookie *) ch_calloc( 1,
                                                                                sizeof( struct sync_cookie ));
                        ber_str2bv( optarg, 0, 1, &scp->octet_str );
-                       slap_parse_sync_cookie( scp );
+                       slap_parse_sync_cookie( scp, NULL );
 
                        LDAP_STAILQ_FOREACH( scp_entry, &slap_sync_cookie, sc_next ) {
                                if ( scp->rid == scp_entry->rid ) {
@@ -378,7 +387,21 @@ int main( int argc, char **argv )
                case 'd':       /* set debug level and 'do not detach' flag */
                        no_detach = 1;
 #ifdef LDAP_DEBUG
-                       slap_debug |= atoi( optarg );
+                       if ( optarg != NULL && optarg[ 0 ] != '-' && !isdigit( optarg[ 0 ] ) )
+                       {
+                               int     level;
+
+                               if ( str2loglevel( optarg, &level ) ) {
+                                       fprintf( stderr,
+                                               "unrecognized log level "
+                                               "\"%s\"\n", optarg );
+                                       goto destroy;
+                               }
+
+                               slap_debug |= level;
+                       } else {
+                               slap_debug |= atoi( optarg );
+                       }
 #else
                        if ( atoi( optarg ) != 0 )
                                fputs( "must compile with LDAP_DEBUG for debugging\n",
@@ -577,13 +600,6 @@ unhandled_option:;
        }
 #endif
 
-       if ( slap_schema_init( ) != 0 ) {
-               Debug( LDAP_DEBUG_ANY,
-                   "schema initialization error\n",
-                   0, 0, 0 );
-
-               goto destroy;
-       }
 
        if ( slap_init( serverMode, serverName ) != 0 ) {
                rc = 1;
@@ -609,16 +625,6 @@ unhandled_option:;
        (void) ldap_pvt_tls_set_option( NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &rc );
 #endif
 
-#ifdef LDAP_SLAPI
-       if ( slapi_int_initialize() != 0 ) {
-               Debug( LDAP_DEBUG_ANY,
-                   "slapi initialization error\n",
-                   0, 0, 0 );
-
-               goto destroy;
-       }
-#endif /* LDAP_SLAPI */
-
        if ( frontend_init() ) {
                goto destroy;
        }