]> git.sur5r.net Git - openldap/blobdiff - clients/gopher/go500.c
Server Side Sorting now RFC2891
[openldap] / clients / gopher / go500.c
index a7e9b868be87aecb3dceec9509cdf50ec78b30d8..2b7c4ed6752af712cff475b8d0cdf4caf5c51fd2 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
 #include <ac/unistd.h>
 #include <ac/wait.h>
 
+#include <ac/param.h>
 #include <ac/setproctitle.h>
 
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
@@ -141,11 +139,12 @@ main( int argc, char **argv )
 #ifdef GO500_HOSTNAME
        strcpy( myhost, GO500_HOSTNAME );
 #else
-       if ( myhost[0] == '\0' && gethostname( myhost, sizeof(myhost) )
+       if ( myhost[0] == '\0' && gethostname( myhost, sizeof(myhost)-1 )
            == -1 ) {
                perror( "gethostname" );
                exit( EXIT_FAILURE );
        }
+       myhost[sizeof(myhost)-1] = '\0';
 #endif
 
 #ifdef HAVE_SYSCONF
@@ -183,7 +182,7 @@ main( int argc, char **argv )
        if ( dosyslog ) {
 #ifdef LOG_LOCAL3
                openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL3 );
-#else
+#elif LOG_DEBUG
                openlog( myname, OPENLOG_OPTIONS );
 #endif
        }
@@ -202,8 +201,8 @@ main( int argc, char **argv )
                fromlen = sizeof(from);
                if ( getpeername( 0, (struct sockaddr *) &from, &fromlen )
                    == 0 ) {
-                       hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr),
-                           sizeof(from.sin_addr.s_addr), AF_INET );
+                       hp = gethostbyaddr( (char *) &(from.sin_addr),
+                           sizeof(from.sin_addr), AF_INET );
                        Debug( LDAP_DEBUG_ARGS, "connection from %s (%s)\n",
                            (hp == NULL) ? "unknown" : hp->h_name,
                            inet_ntoa( from.sin_addr ), 0 );
@@ -215,7 +214,7 @@ main( int argc, char **argv )
                        }
 
 #ifdef LDAP_PROCTITLE
-                       setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
+                       setproctitle( "%s", hp == NULL ? inet_ntoa( from.sin_addr ) :
                            hp->h_name );
 #endif
                }
@@ -246,8 +245,8 @@ main( int argc, char **argv )
                        exit( EXIT_FAILURE );
                }
 
-               hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr),
-                   sizeof(from.sin_addr.s_addr), AF_INET );
+               hp = gethostbyaddr( (char *) &(from.sin_addr),
+                   sizeof(from.sin_addr), AF_INET );
 
                if ( dosyslog ) {
                        syslog( LOG_INFO, "TCP connection from %s (%s)",
@@ -346,7 +345,7 @@ wait4child( int sig )
                ;       /* NULL */
 #endif
 
-       (void) SIGNAL( SIGCHLD, wait4child );
+       (void) SIGNAL_REINSTALL ( SIGCHLD, wait4child );
 }
 
 static void