]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/main.c
Add search no-op support.
[openldap] / servers / slapd / main.c
index 785806497e40c26e6d4c710c51afa2230977aa54..53ccf4004767eb5ddae2d1dc302e5ad64165d870 100644 (file)
@@ -1,6 +1,6 @@
 /* $OpenLDAP$ */
 /*
- * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 #include "portable.h"
@@ -15,6 +15,8 @@
 #include <ac/wait.h>
 #include <ac/errno.h>
 
+#include "ldap_pvt.h"
+
 #include "slap.h"
 #include "lutil.h"
 #include "ldif.h"
@@ -25,13 +27,7 @@ static RETSIGTYPE wait4child( int sig );
 
 #ifdef HAVE_NT_SERVICE_MANAGER
 #define MAIN_RETURN(x) return
-struct sockaddr_in     bind_addr;
-
-/* in nt_main.c */
-LDAP_LUTIL_V(SERVICE_STATUS)           SLAPDServiceStatus;
-LDAP_LUTIL_V(SERVICE_STATUS_HANDLE)    hSLAPDServiceStatus;
-extern ldap_pvt_thread_cond_t  started_event,          stopped_event;
-extern int       is_NT_Service;
+static struct sockaddr_in      bind_addr;
 
 void CommenceStartupProcessing( LPCTSTR serverName,
                                                           void(*stopper)(int));
@@ -127,7 +123,7 @@ int main( int argc, char **argv )
 #endif
 {
        int             i, no_detach = 0;
-       int             rc;
+       int             rc = 1;
        char *urls = NULL;
 #if defined(HAVE_SETUID) && defined(HAVE_SETGID)
        char *username = NULL;
@@ -139,6 +135,9 @@ int main( int argc, char **argv )
 #ifdef LOG_LOCAL4
     int            syslogUser = DEFAULT_SYSLOG_USER;
 #endif
+       
+       int g_argc = argc;
+       char **g_argv = argv;
 
 #ifdef HAVE_NT_SERVICE_MANAGER
        char            *configfile = ".\\slapd.conf";
@@ -155,8 +154,6 @@ int main( int argc, char **argv )
        }
 #endif
 
-       g_argc = argc;
-       g_argv = argv;
 
 #ifdef HAVE_NT_SERVICE_MANAGER
        {
@@ -311,9 +308,9 @@ int main( int argc, char **argv )
 
        if( serverName == NULL ) {
                if ( (serverName = strrchr( argv[0], *LDAP_DIRSEP )) == NULL ) {
-                       serverName = ch_strdup( argv[0] );
+                       serverName = argv[0];
                } else {
-                       serverName = ch_strdup( serverName + 1 );
+                       serverName = serverName + 1;
                }
        }
 
@@ -366,7 +363,7 @@ int main( int argc, char **argv )
                goto destroy;
        }
 
-       if ( schema_init( ) != 0 ) {
+       if ( slap_schema_init( ) != 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
                           "main: schema initialization error\n" ));
@@ -385,7 +382,19 @@ int main( int argc, char **argv )
                goto destroy;
        }
 
-       if ( schema_prep( ) != 0 ) {
+       if ( glue_sub_init( ) != 0 ) {
+#ifdef NEW_LOGGING
+               LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
+                          "main: subordinate config error\n"));
+#else
+               Debug( LDAP_DEBUG_ANY,
+                   "subordinate config error\n",
+                   0, 0, 0 );
+#endif
+               goto destroy;
+       }
+
+       if ( slap_schema_check( ) != 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG(( "operation", LDAP_LEVEL_CRIT,
                           "main: schema prep error\n"));
@@ -542,10 +551,14 @@ stop:
 #endif
        slapd_daemon_destroy();
 
+       schema_destroy();
+
 #ifdef HAVE_TLS
        ldap_pvt_tls_destroy();
 #endif
 
+       config_destroy();
+
 #ifdef CSRIMALLOC
        mal_dumpleaktrace( leakfile );
 #endif