]> git.sur5r.net Git - openldap/blobdiff - clients/gopher/go500gw.c
s/<stdlib.h>/<ac/stdlib.h>/
[openldap] / clients / gopher / go500gw.c
index 5e903beb65cfa23c375b8c170232a62f47848e34..9381acda5bd208da291e2d12edad3956118304cd 100644 (file)
@@ -13,7 +13,8 @@
 #include "portable.h"
 
 #include <stdio.h>
-#include <stdlib.h>
+
+#include <ac/stdlib.h>
 
 #include <ac/ctype.h>
 #include <ac/signal.h>
 #include <ac/time.h>
 #include <ac/unistd.h>
 #include <ac/wait.h>
-extern int strcasecmp(const char *, const char *);
 
 #include <ac/setproctitle.h>
 
-#include <sys/resource.h>
-
 #ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
 #endif
 
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
+
 #include "lber.h"
 #include "ldap.h"
+
+#define ldap_debug debug
 #include "ldap_log.h"
+
 #include "lutil.h"
 
 #include "disptmpl.h"
@@ -43,6 +49,8 @@ extern int strcasecmp(const char *, const char *);
 #include "ldapconfig.h"
 
 int    debug;
+int ldap_syslog;
+int ldap_syslog_level;
 int    dosyslog;
 int    inetd;
 int    dtblsize;
@@ -94,7 +102,6 @@ main (int  argc, char **argv )
        struct hostent          *hp;
        struct sockaddr_in      from;
        int                     fromlen;
-       extern char             *optarg;
 
 #if defined( LDAP_PROCTITLE ) && !defined( HAVE_SETPROCTITLE )
        /* for setproctitle */
@@ -109,12 +116,7 @@ main (int  argc, char **argv )
                        break;
 
                case 'd':       /* debugging level */
-                       debug = atoi( optarg );
-#ifdef LDAP_DEBUG
-                       ldap_debug = debug;
-#else
-                       fprintf( stderr, "warning: ldap debugging requires LDAP_DEBUG\n" );
-#endif
+                       debug |= atoi( optarg );
                        break;
 
                case 'f':       /* ldap filter file */
@@ -193,6 +195,15 @@ main (int  argc, char **argv )
        else
                myname = strdup( myname + 1 );
 
+       if ( debug ) {
+               ber_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
+               ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug);
+       }
+       
+#ifdef SIGPIPE
+       (void) SIGNAL( SIGPIPE, SIG_IGN );
+#endif
+
        if ( dosyslog ) {
 #ifdef LOG_LOCAL3
                openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL3 );
@@ -235,7 +246,7 @@ main (int  argc, char **argv )
 
                do_queries( 0 );
 
-               close( 0 );
+               tcp_close( 0 );
 
                exit( 0 );
        }
@@ -272,7 +283,7 @@ main (int  argc, char **argv )
 
                switch( pid = fork() ) {
                case 0:         /* child */
-                       close( s );
+                       tcp_close( s );
                        do_queries( ns );
                        break;
 
@@ -281,7 +292,7 @@ main (int  argc, char **argv )
                        break;
 
                default:        /* parent */
-                       close( ns );
+                       tcp_close( ns );
                        if ( debug )
                                fprintf( stderr, "forked child %d\n", pid );
                        break;
@@ -344,10 +355,10 @@ wait4child( int sig )
        if ( debug ) printf( "parent: catching child status\n" );
 
 #ifdef HAVE_WAITPID
-       while (waitpid ((pid_t) -1, NULL, WAIT_FLAGS) > 0)
+       while (waitpid ((pid_t) -1, (int *) NULL, WAIT_FLAGS) > 0)
                ;       /* NULL */
 #else 
-       while (wait3( &status, WAIT_FLAGS, 0 ) > 0 )
+       while (wait4( (pid_t) -1, &status, WAIT_FLAGS, 0 ) > 0 )
                ;       /* NULL */
 #endif
 
@@ -386,7 +397,7 @@ do_queries( int s )
        if ( debug ) {
                fprintf( stderr, "got %d bytes\n", len );
 #ifdef LDAP_DEBUG
-               lber_bprint( buf, len );
+               ber_bprint( buf, len );
 #endif
        }
 
@@ -401,7 +412,7 @@ do_queries( int s )
        query = buf;
 
        /* strip off leading white space */
-       while ( isspace( *query )) {
+       while ( isspace( (unsigned char) *query )) {
                ++query;
                --len;
        }
@@ -555,7 +566,7 @@ do_menu( LDAP *ld, FILE *fp, char *dn )
 {
        char            **s;
        char            *rdn = NULL;
-       FriendlyMap     *fm = NULL;
+       LDAPFriendlyMap *fm = NULL;
 
        if ( strcmp( dn, "" ) != 0 ) {
                s = ldap_explode_dn( dn, 1 );
@@ -587,7 +598,7 @@ do_list( LDAP *ld, FILE *fp, char *dn )
        int             rc;
        LDAPMessage     *e, *res;
        struct timeval  timeout;
-       FriendlyMap     *fm = NULL;
+       LDAPFriendlyMap *fm = NULL;
        static char     *attrs[] = { "objectClass", 0 };
        int deref = LDAP_DEREF_FINDING;
 
@@ -790,8 +801,7 @@ do_search( LDAP *ld, FILE *fp, char *query )
        }
 
        if ( count == 1 ) {
-               char    *dn, **s, **oc;
-               int     rc;
+               char    *dn, **oc;
 
                e = ldap_first_entry( ld, res );
                oc = ldap_get_values( ld, e, "objectClass" );