]> git.sur5r.net Git - openldap/blobdiff - servers/ldapd/main.c
Some gcc -W... cleanup
[openldap] / servers / ldapd / main.c
index abcbf2c4d8912097b7392032dc050c86e60199ce..9ef964106cb94780fa8a673f8aa4e5792edbc60b 100644 (file)
 #include <quipu/ds_error.h>
 
 #include "lber.h"
+#include "../../libraries/liblber/lber-int.h"  /* get struct sockbuf */
 #include "ldap.h"
 #include "common.h"
+#include "lutil.h"             /* Get lutil_detach() */
 
 #ifdef HAVE_TCPD
 #include <tcpd.h>
@@ -48,11 +50,11 @@ int deny_severity = LOG_NOTICE;
 #endif /* TCP_WRAPPERS */
 
 void log_and_exit();
-static set_socket();
-static do_queries();
+static int     set_socket();
+static void    do_queries();
 static RETSIGTYPE wait4child();
 #ifdef LDAP_CONNECTIONLESS
-static udp_init();
+static int     udp_init();
 #endif
 
 #ifdef LDAP_DEBUG
@@ -83,8 +85,8 @@ int   RunFromInetd = 0;
 
 extern char Versionstr[];
 
-static usage( name )
-char   *name;
+static void
+usage( char *name )
 {
        fprintf( stderr, "usage: %s [-d debuglvl] [-p port] [-l] [-c dsa] [-r referraltimeout]", name );
 #ifdef LDAP_CONNECTIONLESS
@@ -99,6 +101,7 @@ char *name;
        fprintf( stderr, "\n" );
 }
 
+int
 main (argc, argv)
 int    argc;
 char   **argv;
@@ -262,11 +265,15 @@ char      **argv;
         * that have exited
         */
        if (!RunFromInetd) {
-#ifdef LDAP_SETPROCTITLE
+#ifdef LDAP_PROCTITLE
                setproctitle( "initializing" );
 #endif
 #ifndef VMS
-               (void) detach();
+#  ifdef LDAP_DEBUG
+               lutil_detach( ldap_debug, 1 );
+#  else
+               lutil_detach( 0, 1 );
+#  endif
 #endif
                (void) SIGNAL( SIGCHLD, (void *) wait4child );
                (void) SIGNAL( SIGINT, (void *) log_and_exit );
@@ -301,7 +308,7 @@ char        **argv;
        (void) get_syntaxes();
        if (RunFromInetd) {
                len = sizeof( socktype );
-               getsockopt( ns, SOL_SOCKET, SO_TYPE, &socktype, &len );
+               getsockopt( ns, SOL_SOCKET, SO_TYPE, (char *)&socktype, &len );
                if ( socktype == SOCK_DGRAM ) {
 #ifdef LDAP_CONNECTIONLESS
                        Debug( LDAP_DEBUG_ARGS,
@@ -332,7 +339,7 @@ char        **argv;
                                    inet_ntoa( from.sin_addr ) );
                        }
 
-#ifdef LDAP_SETPROCTITLE
+#ifdef LDAP_PROCTITLE
                        sprintf( title, "%s %d\n", hp == NULL ?
                            inet_ntoa( from.sin_addr ) : hp->h_name, myport );
                        setproctitle( title );
@@ -357,7 +364,7 @@ char        **argv;
         * if we are doing CLDAP as well, handle those requests on the fly
         */
 
-#ifdef LDAP_SETPROCTITLE
+#ifdef LDAP_PROCTITLE
 #ifdef LDAP_CONNECTIONLESS
         sprintf( title, "listening %s/%s %d", do_tcp ? "tcp" : "",
             do_udp ? "udp" : "", myport );
@@ -438,7 +445,7 @@ char        **argv;
 #ifdef VMS
                /* This is for debug on terminal on VMS */
                close( tcps );
-#ifdef LDAP_SETPROCTITLE
+#ifdef LDAP_PROCTITLE
                setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
                    hp->h_name );
 #endif
@@ -452,7 +459,7 @@ char        **argv;
                switch( pid = fork() ) {
                case 0:         /* child */
                        close( tcps );
-#ifdef LDAP_SETPROCTITLE
+#ifdef LDAP_PROCTITLE
                         sprintf( title, "%s (%d)\n", hp == NULL ?
                                inet_ntoa( from.sin_addr ) : hp->h_name,
                                myport );
@@ -484,14 +491,14 @@ char      **argv;
        /* NOT REACHED */
 }
 
-static
+static void
 do_queries(
     int        clientsock,
     int        udp             /* is this a UDP (CLDAP) request? */
 )
 {
        fd_set          readfds;
-       int             rc, i;
+       int             rc;
        struct timeval  timeout;
        Sockbuf         sb;
 #ifdef LDAP_CONNECTIONLESS
@@ -540,6 +547,7 @@ do_queries(
 
 #ifdef LDAP_DEBUG
                if ( ldap_debug & LDAP_DEBUG_CONNS ) {
+                       int i;
                        Debug( LDAP_DEBUG_CONNS, "FDLIST:", 0, 0, 0 );
                        for ( i = 0; i < dtblsize; i++ ) {
                                if ( FD_ISSET( i, &readfds ) ) {
@@ -598,7 +606,8 @@ do_queries(
        /* NOT REACHED */
 }
 
-static set_socket(
+static int
+set_socket(
     int        port,
     int        udp     /* UDP port? */
 )