X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=clients%2Fgopher%2Fgo500.c;h=bbd64abefed641be2cee7a96655fae3455839391;hb=34c945b86d995d762826f90b24f51189ba1d8af3;hp=333787677a14ef869a5b8c13120d16681f44eec7;hpb=42e0d83cb3a1a1c5b25183f1ab74ce7edbe25de7;p=openldap diff --git a/clients/gopher/go500.c b/clients/gopher/go500.c index 333787677a..bbd64abefe 100644 --- a/clients/gopher/go500.c +++ b/clients/gopher/go500.c @@ -10,32 +10,35 @@ * is provided ``as is'' without express or implied warranty. */ +#include "portable.h" + #include -#include -#include -#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_SYS_PARAM_H #include -#include -#include -#include -#include -#include -#include +#endif + #include -#include -#ifdef aix -#include -#endif /* aix */ -#include -#include "portable.h" + #include "ldapconfig.h" #include "lber.h" #include "ldap.h" -#include "disptmpl.h" -#ifdef USE_SYSCONF -#include -#endif /* USE_SYSCONF */ +#if LDAP_VERSION < LDAP_VERSION3 +/* quick fix until we have ldap_set_options */ +#include "../libraries/libldap/ldap-int.h" +#endif + +#include "disptmpl.h" int debug; int dosyslog; @@ -52,7 +55,7 @@ char myhost[MAXHOSTNAMELEN]; int myport; static set_socket(); -static SIG_FN wait4child(); +static RETSIGTYPE wait4child(); static do_queries(); static do_error(); static do_search(); @@ -78,7 +81,7 @@ char **argv; struct hostent *hp; struct sockaddr_in from; int fromlen; - SIG_FN wait4child(); + RETSIGTYPE wait4child(); extern char *optarg; extern char **Argv; extern int Argc; @@ -140,11 +143,20 @@ char **argv; } #endif -#ifdef USE_SYSCONF +#ifdef HAVE_SYSCONF dtblsize = sysconf( _SC_OPEN_MAX ); -#else /* USE_SYSCONF */ +#elif HAVE_GETDTABLESIZE dtblsize = getdtablesize(); -#endif /* USE_SYSCONF */ +#else + dtblsize = FD_SETSIZE; +#endif + +#ifdef FD_SETSIZE + if (dtblsize > FD_SETSIZE) { + dtblsize = FD_SETSIZE; + } +#endif /* FD_SETSIZE*/ + /* detach if stderr is redirected or no debugging */ if ( inetd == 0 ) @@ -170,7 +182,7 @@ char **argv; s = set_socket( port ); /* arrange to reap children */ - (void) signal( SIGCHLD, (void *) wait4child ); + (void) SIGNAL( SIGCHLD, wait4child ); } else { myport = GO500_PORT; @@ -292,20 +304,24 @@ int port; return( s ); } -static SIG_FN +static RETSIGTYPE wait4child() { +#ifndef HAVE_WAITPID WAITSTATUSTYPE status; +#endif if ( debug ) printf( "parent: catching child status\n" ); -#ifdef USE_WAITPID + +#ifdef HAVE_WAITPID while (waitpid ((pid_t) -1, 0, WAIT_FLAGS) > 0) -#else /* USE_WAITPID */ - while ( wait3( &status, WAIT_FLAGS, 0 ) > 0 ) -#endif /* USE_WAITPID */ - ; /* NULL */ + ; /* NULL */ +#else + while ( wait3( &status, WAIT_FLAGS, 0 ) > 0 ) + ; /* NULL */ +#endif - (void) signal( SIGCHLD, (void *) wait4child ); + (void) SIGNAL( SIGCHLD, wait4child ); } static @@ -372,7 +388,7 @@ int s; } ld->ld_deref = GO500_DEREF; - if ( (rc = ldap_simple_bind_s( ld, GO500_BINDDN, NULL )) + if ( (rc = ldap_simple_bind_s( ld, GO500_BINDDN, GO500_BIND_CRED )) != LDAP_SUCCESS ) { fprintf(fp, "0An error occurred (explanation)\t@%d\t%s\t%d\r\n",