[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
IT-68: Please include in devel distribution.
The patch included in this email is a simple one and has been tested in
**************IRIX 6.5*****************************************
where configure script detects the following:
checking number of arguments of gethostbyname_r... 5
checking number of arguments of gethostbyaddr_r... 7
and fills include/portable.h with:
/* define this to the number of args gethostbyname_r() expects */
#define GETHOSTBYNAME_R_NARGS 5
/* define this to the numebr of args gethostbyaddr_r() expects */
#define GETHOSTBYADDR_R_NARGS 7
**************RH Linux 5.2 (Linux Kernel 2.0.36)*******************
where configure script detects the following:
checking number of arguments of gethostbyname_r... 6
checking number of arguments of gethostbyaddr_r... 8
and fills include/portable.h with:
/* define this to the number of args gethostbyname_r() expects */
#define GETHOSTBYNAME_R_NARGS 6
/* define this to the numebr of args gethostbyaddr_r() expects */
#define GETHOSTBYADDR_R_NARGS 8
__________________________________________________________
Compilation and tests completed OK in each system after runing configure
script.
I know this does not causes any significant functionality loss but it is
painful
for those who want openLDAP to work in their various systems without
specifying many options or trying to figure out why the software does
not
compile in their systems even when they have gethostbyname/addr_r.
Thanks, Juan
PS: I have also posted this patch in ftp://ftp.openldap.org/incoming and
will soon
update the related IT, please discard config_gethostbyaddr_patch
config_gethostbyaddr_patch_new.
diff -rc ldap_old/configure.in ldap/configure.in
*** ldap_old/configure.in Mon Feb 22 12:01:24 1999
--- ldap/configure.in Wed Feb 24 09:12:31 1999
***************
*** 1516,1523 ****
--- 1516,1537 ----
ol_cv_func_ctime_r=0
fi
+ if test "$ac_cv_func_gethostbyname_r" = yes ; then
+ OL_FUNC_GETHOSTBYNAME_R_NARGS
+ else
+ ol_cv_func_gethostbyname_r=0
+ fi
+
+ if test "$ac_cv_func_gethostbyaddr_r" = yes ; then
+ OL_FUNC_GETHOSTBYADDR_R_NARGS
+ else
+ ol_cv_func_gethostbyaddr_r=0
+ fi
+
if test "$ac_cv_func_ctime_r" = yes \
-a "$ol_cv_func_ctime_r_nargs" -ge 2 -a "$ol_cv_func_ctime_r_nargs" -le 3 \
+ -a "$ol_cv_func_gethostbyname_r_nargs" -ge 5 -a "$ol_cv_func_gethostbyname_r_nargs" -le 6 \
+ -a "$ol_cv_func_gethostbyaddr_r_nargs" -ge 5 -a "$ol_cv_func_gethostbyaddr_r_nargs" -le 6 \
-a "$ac_cv_func_gethostbyaddr_r" = yes \
-a "$ac_cv_func_gethostbyname_r" = yes \
; then
diff -rc ldap_old/libraries/libldap/util-int.c ldap/libraries/libldap/util-int.c
*** ldap_old/libraries/libldap/util-int.c Sat Feb 20 09:33:24 1999
--- ldap/libraries/libldap/util-int.c Wed Feb 24 11:47:30 1999
***************
*** 19,24 ****
--- 19,25 ----
* in file LICENSE in the top-level directory of the distribution.
*/
+
#include "portable.h"
#include <stdlib.h>
***************
*** 90,95 ****
--- 91,101 ----
int *herrno_ptr )
{
#if defined( HAVE_GETHOSTBYNAME_R )
+
+ # if (GETHOSTBYNAME_R_NARGS > 6) || (GETHOSTBYNAME_R_NARGS < 5)
+ Ouch! gethostbyname_r() must have either 5 or 6 args
+ #endif
+
# define NEED_SAFE_REALLOC 1
int r=-1;
int buflen=BUFSTART;
***************
*** 97,104 ****
--- 103,121 ----
for(;buflen<BUFMAX;) {
if (safe_realloc( buf, buflen )==NULL)
return r;
+
+ #if (GETHOSTBYNAME_R_NARGS < 6)
+ r = ((*result=gethostbyname_r( name, resbuf, *buf,\
+ buflen, herrno_ptr ))== NULL) ?\
+ -1 : 0;
+ #else
r = gethostbyname_r( name, resbuf, *buf,
buflen, result, herrno_ptr );
+ #endif
+
+ Debug( LDAP_DEBUG_TRACE, "ldap_pvt_gethostbyname_a: host=%s, r=%d\n",\
+ name, r, 0 );
+
#ifdef NETDB_INTERNAL
if ((r<0) &&
(*herrno_ptr==NETDB_INTERNAL) &&
***************
*** 157,162 ****
--- 174,184 ----
int *herrno_ptr )
{
#if defined( HAVE_GETHOSTBYADDR_R )
+
+ #if (GETHOSTBYADDR_R_NARGS > 8) || (GETHOSTBYADDR_R_NARGS < 7)
+ Ouch! gethostbyaddr_r() must have either 7 or 8 args
+ #endif
+
# undef NEED_SAFE_REALLOC
# define NEED_SAFE_REALLOC
int r=-1;
***************
*** 165,173 ****
--- 187,203 ----
for(;buflen<BUFMAX;) {
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;
+ #else
r = gethostbyaddr_r( addr, len, type,
resbuf, *buf, buflen,
result, herrno_ptr );
+ #endif
+
#ifdef NETDB_INTERNAL
if ((r<0) &&
(*herrno_ptr==NETDB_INTERNAL) &&
diff -rc ldap_old/include/portable.h.in ldap/include/portable.h.in
*** ldap_old/include/portable.h.in Mon Feb 22 12:01:25 1999
--- ldap/include/portable.h.in Wed Feb 24 09:12:34 1999
***************
*** 115,120 ****
--- 115,126 ----
/* define this to the number of arguments ctime_r() expects */
#undef CTIME_R_NARGS
+ /* define this to the number of args gethostbyname_r() expects */
+ #undef GETHOSTBYNAME_R_NARGS
+
+ /* define this to the numebr of args gethostbyaddr_r() expects */
+ #undef GETHOSTBYADDR_R_NARGS
+
/* define this if sys_errlist is not defined in stdio.h or errno.h */
#undef DECL_SYS_ERRLIST
diff -rc ldap_old/build/openldap.m4 ldap/build/openldap.m4
*** ldap_old/build/openldap.m4 Tue Jan 26 11:55:54 1999
--- ldap/build/openldap.m4 Wed Feb 24 13:04:27 1999
***************
*** 443,446 ****
AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs)
fi
])dnl
!
--- 443,517 ----
AC_DEFINE_UNQUOTED(CTIME_R_NARGS, $ol_cv_func_ctime_r_nargs)
fi
])dnl
! dnl ====================================================================
! dnl check no of arguments for gethostbyname_r
! AC_DEFUN(OL_FUNC_GETHOSTBYNAME_R_NARGS,
! [AC_CACHE_CHECK(number of arguments of gethostbyname_r, ol_cv_func_gethostbyname_r_nargs,
! [AC_TRY_COMPILE([#include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <netdb.h>
! #define BUFSIZE (sizeof(struct hostent)+10)],
! [struct hostent hent; char buffer[BUFSIZE];
! int bufsize=BUFSIZE;int h_errno;
! (void)gethostbyname_r( "segovia.cs.purdue.edu", &hent, buffer, bufsize, &h_errno);
! return 0;],
! ol_cv_func_gethostbyname_r_nargs=5, ol_cv_func_gethostbyname_r_nargs=0)
! if test $ol_cv_func_gethostbyname_r_nargs = 0 ; then
! AC_TRY_COMPILE([#include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <netdb.h>
! #define BUFSIZE (sizeof(struct hostent)+10)],
! [struct hostent hent;struct hostent *rhent;
! char buffer[BUFSIZE];
! int bufsize=BUFSIZE;int h_errno;
! (void)gethostbyname_r( "segovia.cs.purdue.edu",
! &hent, buffer, bufsize, &rhent, &h_errno);
! return 0;],
! ol_cv_func_gethostbyname_r_nargs=6, ol_cv_func_gethostbyname_r_nargs=0)
! fi
! ])
! if test $ol_cv_func_gethostbyname_r_nargs -gt 1 ; then
! AC_DEFINE_UNQUOTED(GETHOSTBYNAME_R_NARGS, $ol_cv_func_gethostbyname_r_nargs)
! fi
! ])dnl
! dnl check no of arguments for gethostbyaddr_r
! AC_DEFUN(OL_FUNC_GETHOSTBYADDR_R_NARGS,
! [AC_CACHE_CHECK(number of arguments of gethostbyaddr_r, ol_cv_func_gethostbyaddr_r_nargs,
! [AC_TRY_COMPILE([#include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <netdb.h>
! #define BUFSIZE (sizeof(struct hostent)+10)],
! [struct hostent hent; char buffer[BUFSIZE];
! struct in_addr add={0x70707070};
! size_t alen=sizeof(struct in_addr);
! int bufsize=BUFSIZE;int h_errno;
! (void)gethostbyaddr_r( (void *)&(add.s_addr),
! alen, AF_INET, &hent, buffer, bufsize, &h_errno);
! return 0;],
! ol_cv_func_gethostbyaddr_r_nargs=7,
! ol_cv_func_gethostbyaddr_r_nargs=0)
! if test $ol_cv_func_gethostbyaddr_r_nargs = 0 ; then
! AC_TRY_COMPILE([#include <sys/types.h>
! #include <sys/socket.h>
! #include <netinet/in.h>
! #include <netdb.h>
! #define BUFSIZE (sizeof(struct hostent)+10)],
! [struct hostent hent; struct hostent *rhent; char buffer[BUFSIZE];
! struct in_addr add={0x70707070};
! size_t alen=sizeof(struct in_addr);
! int bufsize=BUFSIZE;int h_errno;
! (void)gethostbyaddr_r( (void *)&(add.s_addr),
! alen, AF_INET, &hent, buffer, bufsize,
! &rhent, &h_errno);
! return 0;],
! ol_cv_func_gethostbyaddr_r_nargs=8,
! ol_cv_func_gethostbyaddr_r_nargs=0)
! fi
! ])
! if test $ol_cv_func_gethostbyaddr_r_nargs -gt 1 ; then
! AC_DEFINE_UNQUOTED(GETHOSTBYADDR_R_NARGS, $ol_cv_func_gethostbyaddr_r_nargs)
! fi
! ])dnl