dnl YAZ Toolkit, Index Data 1994-2006
dnl See the file LICENSE for details.
-dnl $Id: configure.ac,v 1.32 2006-08-16 22:50:06 adam Exp $
+dnl $Id: configure.ac,v 1.33 2006-08-30 12:04:42 adam Exp $
AC_PREREQ(2.59)
AC_INIT([yaz],[2.1.27],[adam@indexdata.dk])
AC_CONFIG_SRCDIR(configure.ac)
])
fi
dnl ------ various functions
-AC_CHECK_FUNCS(vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64)
+AC_CHECK_FUNCS(gethostbyname_r vsnprintf gettimeofday poll strerror_r localtime_r usleep fopen64)
case $host in
*-*-darwin*)
trypoll="no";
* Copyright (C) 1995-2005, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tcpip.c,v 1.19 2006-08-24 13:25:45 adam Exp $
+ * $Id: tcpip.c,v 1.20 2006-08-30 12:04:43 adam Exp $
*/
/**
* \file tcpip.c
int default_port)
{
struct hostent *hp;
+#if HAVE_GETHOSTBYNAME_R
+ struct hostent h;
+ char hbuf[1024];
+ int h_error;
+#endif
char *p, buf[512];
short int port = default_port;
- unsigned tmpadd;
+ in_addr_t tmpadd;
if (!tcpip_init ())
return 0;
}
add->sin_port = htons(port);
if (!strcmp("@", buf))
+ {
add->sin_addr.s_addr = INADDR_ANY;
+ }
+ else if ((tmpadd = inet_addr(buf)) != INADDR_NONE)
+ {
+ memcpy(&add->sin_addr.s_addr, &tmpadd, sizeof(struct in_addr));
+ }
+#if HAVE_GETHOSTBYNAME_R
+ else if (gethostbyname_r(buf, &h, hbuf, sizeof(hbuf), &hp, &h_error) == 0)
+ {
+ memcpy(&add->sin_addr.s_addr, *hp->h_addr_list,
+ sizeof(struct in_addr));
+ }
+#else
else if ((hp = gethostbyname(buf)))
+ {
memcpy(&add->sin_addr.s_addr, *hp->h_addr_list,
sizeof(struct in_addr));
- else if ((tmpadd = (unsigned) inet_addr(buf)) != 0)
- memcpy(&add->sin_addr.s_addr, &tmpadd, sizeof(struct in_addr));
+ }
+#endif
else
return 0;
return 1;