# Process this file with autoconf to produce a configure script.
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])
# Checks for programs.
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
esac
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
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
AC_DEFINE([DEBUG],[],[Enable extra debugging.])
int rc;
struct hostent *result, *local_result;
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->local_hp, 0, sizeof(mcon->local_hp));
int flag;
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(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) {
+#endif
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);
mcon->remote_addr.sin_port = htons(port);