fix for solaris openzap from stkn

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@486 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Michael Jerris 2008-05-26 23:53:19 +00:00
parent 3eb33ba8de
commit 714535c190
2 changed files with 33 additions and 6 deletions

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59) AC_PREREQ(2.59)
AC_INIT([openzap],[pre-alpha],[bugs@freeswitch.prg]) AC_INIT([openzap],[pre-alpha],[bugs@freeswitch.org])
AC_CONFIG_SRCDIR([src/libteletone_detect.c]) AC_CONFIG_SRCDIR([src/libteletone_detect.c])
# Checks for programs. # Checks for programs.
@ -26,7 +26,7 @@ AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compile
done done
]) ])
]) ])
AC_ARG_ENABLE(enable_64, [ --enable-64 Enable 64bit compilation]) AC_ARG_ENABLE([enable_64], [AS_HELP_STRING([--enable-64], [Enable 64bit compilation])], [enable_64="$enableval"], [enable_64="no"])
AX_COMPILER_VENDOR AX_COMPILER_VENDOR
@ -46,11 +46,32 @@ sun)
esac esac
AC_CHECK_HEADERS([netinet/sctp.h netdb.h]) AC_CHECK_HEADERS([netinet/sctp.h netdb.h])
AC_CHECK_FUNCS([gethostbyname_r]) AC_CHECK_FUNC([gethostbyname_r],
[], [AC_CHECK_LIB([nsl], [gethostbyname_r])]
)
if test "$ac_cv_func_gethostbyname_r" = "yes" -o "$ac_cv_lib_nsl_gethostbyname_r" = "yes" ; then
AC_MSG_CHECKING([whether gethostbyname_r requires five arguments])
ac_cv_func_gethostbyname_r_five_args="no"
AC_TRY_COMPILE([#include <netdb.h>],
[char *name;
struct hostent *he, *res;
char buffer[2048];
int buflen = 2048;
(void)gethostbyname_r(name, he, buffer, buflen, &res)],
[ac_cv_func_gethostbyname_r_five_args="yes"
AC_DEFINE([HAVE_GETHOSTBYNAME_R_FIVE], [1], [gethostbyname_r has five arguments])]
)
AC_MSG_RESULT([$ac_cv_func_gethostbyname_r_five_args])
AC_DEFINE([HAVE_GETHOSTBYNAME_R],[1],[threadsafe gethostbyname])
fi
# Enable debugging # Enable debugging
AC_ARG_ENABLE(debug, AC_ARG_ENABLE(debug,
[AC_HELP_STRING([--enable-debug],[build with debug information])],[enable_debug="$enable_debug"],[enable_debug="yes"]) [AC_HELP_STRING([--enable-debug],[build with debug information])],[enable_debug="$enableval"],[enable_debug="yes"])
if test "${enable_debug}" = "yes"; then if test "${enable_debug}" = "yes"; then
AC_DEFINE([DEBUG],[],[Enable extra debugging.]) AC_DEFINE([DEBUG],[],[Enable extra debugging.])

View File

@ -74,7 +74,7 @@ static int create_conn_socket(ss7bc_connection_t *mcon, char *local_ip, int loca
int rc; int rc;
struct hostent *result, *local_result; struct hostent *result, *local_result;
char buf[512], local_buf[512]; char buf[512], local_buf[512];
int err = 0; int err = 0, local_err = 0;
memset(&mcon->remote_hp, 0, sizeof(mcon->remote_hp)); memset(&mcon->remote_hp, 0, sizeof(mcon->remote_hp));
memset(&mcon->local_hp, 0, sizeof(mcon->local_hp)); memset(&mcon->local_hp, 0, sizeof(mcon->local_hp));
@ -91,9 +91,15 @@ static int create_conn_socket(ss7bc_connection_t *mcon, char *local_ip, int loca
int flag; int flag;
flag = 1; flag = 1;
#ifdef HAVE_GETHOSTBYNAME_R_FIVE
gethostbyname_r(ip, &mcon->remote_hp, buf, sizeof(buf), &err);
gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_err);
if (!err && !local_err) {
#else
gethostbyname_r(ip, &mcon->remote_hp, buf, sizeof(buf), &result, &err); gethostbyname_r(ip, &mcon->remote_hp, buf, sizeof(buf), &result, &err);
gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_result, &err); gethostbyname_r(local_ip, &mcon->local_hp, local_buf, sizeof(local_buf), &local_result, &local_err);
if (result && local_result) { if (result && local_result) {
#endif
mcon->remote_addr.sin_family = mcon->remote_hp.h_addrtype; mcon->remote_addr.sin_family = mcon->remote_hp.h_addrtype;
memcpy((char *) &mcon->remote_addr.sin_addr.s_addr, mcon->remote_hp.h_addr_list[0], mcon->remote_hp.h_length); memcpy((char *) &mcon->remote_addr.sin_addr.s_addr, mcon->remote_hp.h_addr_list[0], mcon->remote_hp.h_length);
mcon->remote_addr.sin_port = htons(port); mcon->remote_addr.sin_port = htons(port);