Commit be1cb93c authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Sync with HEAD

parent 0211ba1d
......@@ -33,34 +33,32 @@
#include "ldap-int.h"
#if defined( LDAP_R_COMPILE )
# include <ldap_pvt_thread.h>
#else
#ifndef LDAP_R_COMPILE
# undef HAVE_REENTRANT_FUNCTIONS
#endif
# undef HAVE_CTIME_R
# undef HAVE_GETHOSTBYNAME_R
# undef HAVE_GETHOSTBYADDR_R
#else
# include <ldap_pvt_thread.h>
ldap_pvt_thread_mutex_t ldap_int_resolv_mutex;
#if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \
&& defined( CTIME_R_NARGS )
# define USE_CTIME_R
#endif
# define USE_CTIME_R
# else
static ldap_pvt_thread_mutex_t ldap_int_ctime_mutex;
# endif
#if defined(HAVE_GETHOSTBYNAME_R) && \
(GETHOSTBYNAME_R_NARGS > 6 || GETHOSTBYNAME_R_NARGS < 5)
# if defined(HAVE_GETHOSTBYNAME_R) && \
(GETHOSTBYNAME_R_NARGS < 5) || (6 < GETHOSTBYNAME_R_NARGS)
/* Don't know how to handle this version, pretend it's not there */
# undef HAVE_GETHOSTBYNAME_R
#endif
#if defined(HAVE_GETHOSTBYADDR_R) && \
(GETHOSTBYADDR_R_NARGS > 8 || GETHOSTBYADDR_R_NARGS < 7)
# endif
# if defined(HAVE_GETHOSTBYADDR_R) && \
(GETHOSTBYADDR_R_NARGS < 7) || (8 < GETHOSTBYADDR_R_NARGS)
/* Don't know how to handle this version, pretend it's not there */
# undef HAVE_GETHOSTBYADDR_R
#endif
#ifdef LDAP_R_COMPILE
# ifndef USE_CTIME_R
static ldap_pvt_thread_mutex_t ldap_int_ctime_mutex;
# endif
# ifdef HAVE_RES_QUERY
ldap_pvt_thread_mutex_t ldap_int_resolv_mutex;
# endif
#endif /* LDAP_R_COMPILE */
......@@ -78,13 +76,17 @@ char *ldap_pvt_ctime( const time_t *tp, char *buf )
# endif
#else
# ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ldap_int_ctime_mutex );
# endif
AC_MEMCPY( buf, ctime(tp), 26 );
# ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ldap_int_ctime_mutex );
# endif
return buf;
#endif
}
......@@ -95,7 +97,8 @@ char *ldap_pvt_ctime( const time_t *tp, char *buf )
static char *safe_realloc( char **buf, int len );
#if !defined(HAVE_GETHOSTBYNAME_R) && defined(LDAP_R_COMPILE)
static int copy_hostent( struct hostent *res, char **buf, struct hostent * src );
static int copy_hostent( struct hostent *res,
char **buf, struct hostent * src );
#endif
int ldap_pvt_gethostbyname_a(
......@@ -116,9 +119,8 @@ int ldap_pvt_gethostbyname_a(
return r;
#if (GETHOSTBYNAME_R_NARGS < 6)
r = ((*result=gethostbyname_r( name, resbuf, *buf,
buflen, herrno_ptr ))== NULL) ?
-1 : 0;
*result=gethostbyname_r( name, resbuf, *buf, buflen, herrno_ptr );
r = (*result == NULL) ? -1 : 0;
#else
r = gethostbyname_r( name, resbuf, *buf,
buflen, result, herrno_ptr );
......@@ -197,10 +199,9 @@ int ldap_pvt_gethostbyaddr_a(
if (safe_realloc( buf, buflen )==NULL)
return r;
#if (GETHOSTBYADDR_R_NARGS < 8)
r = ((*result=gethostbyaddr_r( addr, len, type,
resbuf, *buf, buflen,
herrno_ptr )) == NULL) ?
-1 : 0;
*result=gethostbyaddr_r( addr, len, type,
resbuf, *buf, buflen, herrno_ptr );
r = (*result == NULL) ? -1 : 0;
#else
r = gethostbyaddr_r( addr, len, type,
resbuf, *buf, buflen,
......@@ -243,7 +244,8 @@ int ldap_pvt_gethostbyaddr_a(
ldap_pvt_thread_mutex_unlock( &ldap_int_resolv_mutex );
return retval;
return retval;
#else /* gethostbyaddr() */
*buf = NULL;
*result = gethostbyaddr( addr, len, type );
......@@ -266,24 +268,23 @@ void ldap_int_utils_init( void )
done=1;
#ifdef LDAP_R_COMPILE
#if !defined( USE_CTIME_R ) && !defined( HAVE_REENTRANT_FUNCTIONS )
ldap_pvt_thread_mutex_init( &ldap_int_ctime_mutex );
#endif
#ifdef HAVE_RES_QUERY
ldap_pvt_thread_mutex_init( &ldap_int_resolv_mutex );
#endif
/* call other module init functions here... */
#endif
}
#if defined( NEED_COPY_HOSTENT )
# undef NEED_SAFE_REALLOC
#define NEED_SAFE_REALLOC
static char *cpy_aliases( char ***tgtio, char *buf, char **src )
static char *cpy_aliases(
char ***tgtio,
char *buf,
char **src )
{
int len;
char **tgt=*tgtio;
......@@ -297,7 +298,11 @@ static char *cpy_aliases( char ***tgtio, char *buf, char **src )
return buf;
}
static char *cpy_addresses( char ***tgtio, char *buf, char **src, int len )
static char *cpy_addresses(
char ***tgtio,
char *buf,
char **src,
int len )
{
char **tgt=*tgtio;
for( ; (*src) ; src++ ) {
......@@ -309,7 +314,10 @@ static char *cpy_addresses( char ***tgtio, char *buf, char **src, int len )
return buf;
}
static int copy_hostent( struct hostent *res, char **buf, struct hostent * src )
static int copy_hostent(
struct hostent *res,
char **buf,
struct hostent * src )
{
char **p;
char **tp;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment